OSDN Git Service

speach rename to speech
authoryasushiito <yasushiito@git.sourceforge.jp>
Sun, 27 May 2012 02:25:28 +0000 (11:25 +0900)
committeryasushiito <yasushiito@git.sourceforge.jp>
Sun, 27 May 2012 02:25:28 +0000 (11:25 +0900)
87 files changed:
app/assets/javascripts/common.js [new file with mode: 0644]
app/assets/javascripts/system.js [new file with mode: 0644]
app/assets/javascripts/work.js [new file with mode: 0644]
app/assets/stylesheets/speech_baloons.css.scss [moved from app/assets/stylesheets/speach_baloons.css.scss with 100% similarity]
app/assets/stylesheets/speech_templates.css.scss [moved from app/assets/stylesheets/speach_templates.css.scss with 100% similarity]
app/assets/stylesheets/speechbaloons.css.scss [moved from app/assets/stylesheets/speachbaloons.css.scss with 100% similarity]
app/assets/stylesheets/speeches.css.scss [moved from app/assets/stylesheets/speaches.css.scss with 100% similarity]
app/controllers/panels_controller.rb
app/controllers/speach_balloon_templates_controller.rb [deleted file]
app/controllers/speech_balloon_templates_controller.rb [new file with mode: 0644]
app/controllers/speech_balloons_controller.rb [moved from app/controllers/speach_balloons_controller.rb with 50% similarity]
app/controllers/speech_templates_controller.rb [moved from app/controllers/speach_templates_controller.rb with 51% similarity]
app/controllers/speeches_controller.rb [moved from app/controllers/speaches_controller.rb with 57% similarity]
app/helpers/speach_balloon_templates_helper.rb [deleted file]
app/helpers/speach_balloons_helper.rb [deleted file]
app/helpers/speach_templates_helper.rb [deleted file]
app/helpers/speaches_helper.rb [deleted file]
app/helpers/speech_balloon_templates_helper.rb [new file with mode: 0644]
app/helpers/speech_balloons_helper.rb [new file with mode: 0644]
app/helpers/speech_templates_helper.rb [new file with mode: 0644]
app/helpers/speeches_helper.rb [new file with mode: 0644]
app/models/balloon.rb
app/models/balloon_template.rb
app/models/comic.rb
app/models/panel.rb
app/models/speach.rb [deleted file]
app/models/speach_balloon_template.rb [deleted file]
app/models/speach_template.rb [deleted file]
app/models/speech.rb [new file with mode: 0644]
app/models/speech_balloon.rb [moved from app/models/speach_balloon.rb with 64% similarity]
app/models/speech_balloon_template.rb [new file with mode: 0644]
app/models/speech_template.rb [new file with mode: 0644]
app/views/balloon_templates/index.html.erb
app/views/balloon_templates/list.html.erb
app/views/layouts/application.html.erb
app/views/layouts/test.html.erb
app/views/panels/_standard.html.erb
app/views/panels/index.html.erb
app/views/speach_balloon_templates/_form.html.erb [deleted file]
app/views/speach_balloon_templates/index.html.erb [deleted file]
app/views/speach_balloon_templates/list.html.erb [deleted file]
app/views/speach_balloons/index.html.erb [deleted file]
app/views/speach_balloons/list.html.erb [deleted file]
app/views/speach_templates/index.html.erb [deleted file]
app/views/speach_templates/list.html.erb [deleted file]
app/views/speaches/index.html.erb [deleted file]
app/views/speaches/list.html.erb [deleted file]
app/views/speech_balloon_templates/_form.html.erb [new file with mode: 0644]
app/views/speech_balloon_templates/browse.html.erb [moved from app/views/speach_balloons/browse.html.erb with 64% similarity]
app/views/speech_balloon_templates/index.html.erb [new file with mode: 0644]
app/views/speech_balloon_templates/list.html.erb [new file with mode: 0644]
app/views/speech_balloon_templates/show.html.erb [moved from app/views/speach_balloon_templates/show.html.erb with 57% similarity]
app/views/speech_balloons/browse.html.erb [moved from app/views/speach_balloon_templates/browse.html.erb with 64% similarity]
app/views/speech_balloons/index.html.erb [new file with mode: 0644]
app/views/speech_balloons/list.html.erb [new file with mode: 0644]
app/views/speech_balloons/show.html.erb [moved from app/views/speach_balloons/show.html.erb with 57% similarity]
app/views/speech_templates/index.html.erb [new file with mode: 0644]
app/views/speech_templates/list.html.erb [new file with mode: 0644]
app/views/speeches/index.html.erb [new file with mode: 0644]
app/views/speeches/list.html.erb [new file with mode: 0644]
app/views/system/browse.html.erb
config/routes.rb
db/migrate/20111206115439_create_balloon_templates.rb
db/migrate/20111206120252_create_speech_templates.rb [moved from db/migrate/20111206120252_create_speach_templates.rb with 59% similarity]
db/migrate/20111206130635_create_speeches.rb [moved from db/migrate/20111206130635_create_speaches.rb with 55% similarity]
db/migrate/20111208235818_create_speech_balloons.rb [moved from db/migrate/20111208235818_create_speach_balloons.rb with 58% similarity]
db/migrate/20120424100555_create_speach_balloon_templates.rb [deleted file]
db/migrate/20120424100555_create_speech_balloon_templates.rb [new file with mode: 0644]
db/schema.rb
spec/controllers/balloon_templates_controller_spec.rb
spec/controllers/speach_balloon_templates_controller_spec.rb [deleted file]
spec/controllers/speach_balloons_controller_spec.rb [deleted file]
spec/controllers/speaches_controller_spec.rb [deleted file]
spec/controllers/speech_balloon_templates_controller_spec.rb [new file with mode: 0644]
spec/controllers/speech_balloons_controller_spec.rb [new file with mode: 0644]
spec/controllers/speech_templates_controller_spec.rb [moved from spec/controllers/speach_templates_controller_spec.rb with 58% similarity]
spec/controllers/speeches_controller_spec.rb [new file with mode: 0644]
spec/factories.rb
spec/helpers/speech_balloon_templates_helper_spec.rb [moved from spec/helpers/speach_balloon_templates_helper_spec.rb with 70% similarity]
spec/helpers/speech_balloons_helper_spec.rb [moved from spec/helpers/speach_balloons_helper_spec.rb with 75% similarity]
spec/helpers/speech_templates_helper_spec.rb [moved from spec/helpers/speach_templates_helper_spec.rb with 74% similarity]
spec/helpers/speeches_helper_spec.rb [moved from spec/helpers/speaches_helper_spec.rb with 77% similarity]
spec/models/panel_spec.rb
spec/models/speech_balloon_spec.rb [moved from spec/models/speach_balloon_spec.rb with 76% similarity]
spec/models/speech_balloon_template_spec.rb [moved from spec/models/speach_balloon_template_spec.rb with 71% similarity]
spec/models/speech_spec.rb [moved from spec/models/speach_spec.rb with 53% similarity]
spec/models/speech_template_spec.rb [moved from spec/models/speach_template_spec.rb with 75% similarity]

diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js
new file mode 100644 (file)
index 0000000..c37ca43
--- /dev/null
@@ -0,0 +1,2387 @@
+/*\r
+ * pettanR common.js\r
+ *   version 0.4.19\r
+ * \r
+ * author: itozyun\r
+ */\r
+\r
+/*\r
+ * http://pettanr.sourceforge.jp/test/type.html
+ */\r
+       var Type = {\r
+               isObject : function(v) {\r
+                       return v !== null && Type.isArray(v) === false && typeof v === 'object';\r
+               },\r
+               isFunction : function(v) {\r
+                       return typeof v === 'function';\r
+               },\r
+               isArray : function(v) {\r
+                       return Object.prototype.toString.call(v) === "[object Array]";\r
+               },\r
+               isBoolean : function(v) {\r
+                       return typeof v === 'boolean';\r
+               },\r
+               isString : function(v) {\r
+                       return typeof v === 'string';\r
+               },\r
+               isNumber : function(v) {\r
+                       return typeof v === 'number';\r
+               },\r
+               isFinite : function(v){\r
+                       return Type.isNumber(v) === true && isFinite(v);\r
+               },\r
+               isHTMLElement : function(v){\r
+                       if( 'HTMLElement' in window ){\r
+                               Type.isHTMLElement = function(v){\r
+                                       return v instanceof HTMLElement;\r
+                               }\r
+                       } else {\r
+                               Type.isHTMLElement = function(v) {\r
+                                       if( Type.isObject(v) === false ){\r
+                                               return false;\r
+                                       }\r
+                                       var r;\r
+                                       if(v && v.nodeType === 1){\r
+                                               try{\r
+                                                       r = v.cloneNode(false);\r
+                                               } catch(n) {\r
+                                                       return false;\r
+                                               }\r
+                                               if(r === v) return false;\r
+                                               try{\r
+                                                       r.nodeType = 9;\r
+                                                       return r.nodeType === 1;\r
+                                               } catch(n) {}\r
+                                               return true;\r
+                                       }\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       return Type.isHTMLElement(v);\r
+               },\r
+               /*\r
+               isElementCollection : function(v) {\r
+                       return (Object.prototype.toString.call(v) === "[object HTMLCollection]");\r
+               },\r
+               */\r
+               isNull : function(v) {\r
+                       return v === null;\r
+               },\r
+               isUndefined : function(v) {\r
+                       return typeof v === 'undefined';\r
+               }\r
+       };\r
+\r
+\r
+var pettanr = ( function(){\r
+       var     FUNCTION_ARRAY = [],\r
+               URL = document.location.href.split( '#')[ 0],\r
+               IS_LOCAL = URL.indexOf( 'file:') === 0,\r
+               URL_PARAMS = ( function(){\r
+                       var search = document.location.search,\r
+                               l = search.length;\r
+                   if( 1 < l){\r
+                       var     query = search.substring( 1),\r
+                                       params = query.split( '&'),\r
+                                       ret = {}, elm, name, v;\r
+                       while( params.length > 0){\r
+                           elm = params.shift().split( '=');\r
+                                       name = decodeURIComponent( elm[ 0]);\r
+                                       if( elm.length === 2){\r
+                                               v = decodeURIComponent( elm[ 1]);\r
+                                               if( '' + parseFloat( v) === v) v = parseFloat( v);\r
+                                               if( '' + parseInt( v, 10 ) === '0' + v) v = parseInt( v, 10 );\r
+                                               if( v === 'true') v = true;\r
+                                               if( v === 'false') v = false;\r
+                                               if( v === 'null') v = null;\r
+                                               if( v === 'undefined') v = undefined;\r
+                                   ret[ name] = v;\r
+                                       } else\r
+                                       if( elm.length === 1){\r
+                                               ret[ name] = true;\r
+                                       }\r
+                       }\r
+                       return ret;\r
+                   }\r
+                   return {};\r
+               })(),\r
+               IS_DEBUG = Type.isBoolean( URL_PARAMS.debug ) ? URL_PARAMS.debug : IS_LOCAL === true,\r
+               jqWindow , jqDocument , jqBody;\r
+       return {\r
+               version: '0.4.19',\r
+               init: function(){\r
+                       jqWindow = $( window);\r
+                       jqDocument = $( document);\r
+                       jqBody = $( document.body);\r
+                       \r
+                       var l = FUNCTION_ARRAY.length,\r
+                               _fn;\r
+                       for( var i=0; i<l; i++){\r
+                               _fn = FUNCTION_ARRAY[ i];\r
+                               _fn.init && _fn.init( _fn === pettanr.view ? FUNCTION_ARRAY : undefined );\r
+                       }\r
+                       \r
+                       delete pettanr.init;\r
+               },\r
+               fn: function( _fn){\r
+                       FUNCTION_ARRAY.push( _fn);\r
+                       pettanr.init === undefined && _fn.init && _fn.init();\r
+               },\r
+               jqWindow: function(){\r
+                       return jqWindow;\r
+               },\r
+               jqDocument: function(){\r
+                       return jqDocument;\r
+               },\r
+               jqBody: function(){\r
+                       return jqBody;\r
+               },\r
+               URL_PARAMS: URL_PARAMS,\r
+               ROOT_PATH: ( function(){\r
+                       // script と html の ドメインが一致\r
+                       var _h1 = document.getElementsByTagName( 'h1')[ 0],\r
+                               _a = _h1.getElementsByTagName( 'a')[ 0],\r
+                               _root = _a.href.split( '\/'),\r
+                               _current = document.location.href.split( '\/'),\r
+                               ret = '.\/';\r
+                       for( var i=0, l=_current.length - _root.length; i<l; ++i){\r
+                               ret = '.' + ret;\r
+                       }\r
+                       return ret;\r
+                       // script と html の ドメインが不一致\r
+               })(),\r
+               LOCAL: IS_LOCAL,\r
+               DEBUG: IS_DEBUG,\r
+               LINE_FEED_CODE_TEXTAREA: ( function(){\r
+                       var text = document.createElement('textarea');\r
+                       text.value = '\n';\r
+                       return text.value;\r
+               })(),\r
+               LINE_FEED_CODE_PRE: ( function(){\r
+                       var pre = document.createElement('pre');\r
+                       pre.appendChild( document.createTextNode('\n'));\r
+                       return pre.firstChild.data;\r
+               })(),\r
+               IS_IFRAME: !!window.parent\r
+       }\r
+})();\r
+\r
+/*\r
+ * pettanr.util\r
+ * \r
+ *   extend( baseInstance, extend)\r
+ *   cleanCommnetNode()\r
+ *   cleanElement()\r
+ *   getElementSize( _elm)\r
+ *   getImageSize()\r
+ *   getAbsolutePath()\r
+ *   getGrobalObjectName()\r
+ * \r
+ */\r
+pettanr.util = ( function(){\r
+       var ELM_SIZE_GETTER = ( function(){\r
+                       var ret = document.createElement( 'DIV'),\r
+                               style = ret.style;\r
+                       ret.id = 'elmSizeGetter';\r
+                       style.position = 'absolute';\r
+                       style.left = '0px';\r
+                       style.top = '-9999px';\r
+                       style.visibility = 'hidden';\r
+                       document.body.appendChild( ret);\r
+                       return ret;\r
+               })(),\r
+               IMG_SIZE_GETTER = ( function(){\r
+                       var ret = ELM_SIZE_GETTER.cloneNode( true);\r
+                       ret.id = 'imgSizeGetter';\r
+                       document.body.appendChild( ret);\r
+                       return ret;\r
+               })(),\r
+               CLEAN_TARGET_ELEMENT = 'script,style,object,applet,embed,iframe,frame,base,bgsound,frameset,listing'.split( ',');\r
+       \r
+       /* clean comment node */\r
+       cleanCommnetNode();\r
+       \r
+       /* clean noscript */\r
+       var nodeNoscript = document.getElementsByTagName( 'noscript'),\r
+               noscript;\r
+       for(var i=0; i<nodeNoscript.length; ++i){\r
+               noscript = nodeNoscript[i];\r
+               noscript.parentNode && noscript.parentNode.removeChild( noscript);\r
+       }\r
+       nodeNoscript = noscript = null;\r
+       \r
+       function cleanCommnetNode( _targetElm){\r
+               search( _targetElm || document.body );\r
+               \r
+               function search( _elm){\r
+                       if( !_elm) return;\r
+                       if( _elm.nodeType === 8){\r
+                               _elm.parentNode.removeChild( _elm);\r
+                               return;\r
+                       }\r
+                       var i, l, _children = _elm.childNodes, _array = [];\r
+                       if( _children && typeof _children.length === 'number'){\r
+                               // liveNode > array\r
+                               for( i=0, l=_children.length; i<l; ++i){\r
+                                       _array.push( _children[ i ] );\r
+                               }\r
+                               while( _array.length !== 0 ){\r
+                                       search( _array.shift());\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       return {\r
+               extend: function( baseInstance, extend){\r
+                       for( var key in extend){\r
+                               if( typeof baseInstance[ key] === 'undefined'){\r
+                                       baseInstance[ key] = extend[ key];\r
+                               } else\r
+                               if( typeof baseInstance[ key] === typeof extend[ key]){\r
+                                       baseInstance[ key] = extend[ key];\r
+                               } else {\r
+                                       alert( 'extend error');\r
+                               }\r
+                       }\r
+                       return baseInstance;\r
+               },      \r
+               cleanCommnetNode: cleanCommnetNode,\r
+               cleanElement: function( _targetElm){\r
+                       var _nodes, _elm, _array, j, m;\r
+                       for( var i=0, l=CLEAN_TARGET_ELEMENT.length; i<l; ++i){\r
+                               _nodes = _targetElm.getElementsByTagName( CLEAN_TARGET_ELEMENT[ i]);\r
+                               _array = [];\r
+                               for( j=0, m = _nodes.length; j<m; ++j){\r
+                                       _array.push( _nodes[ j]);\r
+                               }\r
+                               for( j=0, m = _array.length; j<m; ++j){\r
+                                       _elm = _nodes[ j];\r
+                                       _elm.parentNode && _elm.parentNode.removeChild( _elm);\r
+                               }\r
+                       }\r
+                       cleanCommnetNode( _targetElm);\r
+                       if( pettanr.ua.isIE === false) return;\r
+                       _nodes = _targetElm.all || _targetElm.getElementsByName( '*');\r
+                       for( i=0, l = _nodes.length; i<l; ++i){\r
+                               _elm = _nodes[ i];\r
+                               _elm.style.filter = '';\r
+                               _elm.style.behavior = '';\r
+                       }\r
+               },\r
+               getElementSize: function( _elm){\r
+                       if( !_elm){\r
+                               return {\r
+                                       width:  0,\r
+                                       height: 0\r
+                               }\r
+                       }\r
+                       var     parentElm = _elm.parentNode,\r
+                               prevElm = _elm.previousSibling,\r
+                               nextElm = _elm.nextSibling,\r
+                               displayNone = _elm.style.display === 'none';\r
+                       if( displayNone === true) _elm.style.display = '';\r
+                       ELM_SIZE_GETTER.appendChild( _elm);\r
+                       var ret = {\r
+                               width:          _elm.offsetWidth,\r
+                               height:         _elm.offsetHeight\r
+                       }\r
+                       if( displayNone === true) _elm.style.display = 'none';\r
+                       if( nextElm){\r
+                               parentElm.insertBefore( _elm, nextElm);\r
+                       } else          \r
+                       if( prevElm && prevElm.nextSibling){\r
+                               parentElm.insertBefore( _elm, prevElm.nextSibling);\r
+                       } else {\r
+                               parentElm && parentElm.appendChild( _elm);\r
+                       }                       \r
+                       return ret;\r
+               },\r
+               getImageSize: function( img){\r
+                       var     parentElm = img.parentNode,\r
+                               prevElm = img.previousSibling,\r
+                               nextElm = img.nextSibling,\r
+                               displayNone = img.style.display === 'none';\r
+                       if( displayNone === true) img.style.display = '';\r
+                       IMG_SIZE_GETTER.appendChild( img);\r
+                       \r
+                       var size = getActualDimension( img);\r
+                       \r
+                       IMG_SIZE_GETTER.removeChild( img);\r
+                       if( displayNone === true) img.style.display = 'none';\r
+                       if( nextElm){\r
+                               parentElm.insertBefore( img, nextElm);\r
+                       } else          \r
+                       if( prevElm && prevElm.nextSibling){\r
+                               parentElm.insertBefore( img, prevElm.nextSibling);\r
+                       } else {\r
+                               parentElm && parentElm.appendChild( img);\r
+                       }\r
+                       \r
+               /* LICENSE: MIT\r
+                * AUTHOR: uupaa.js@gmail.com\r
+                */\r
+                       function getActualDimension(image) {\r
+                               var run, mem, w, h, key = "actual";\r
+                       \r
+                       // for Firefox, Safari, Google Chrome\r
+                               if ("naturalWidth" in image) {\r
+                                       return {\r
+                                               width:  image.naturalWidth,\r
+                                               height: image.naturalHeight\r
+                                       };\r
+                               }\r
+                       \r
+                               if ("src" in image) { // HTMLImageElement\r
+                                       if (image[key] && image[key].src === image.src) {\r
+                                               return image[key];\r
+                                       }\r
+                                       if (document.uniqueID) { // for IE\r
+                                               run = image.runtimeStyle;\r
+                                               mem = { w: run.width, h: run.height }; // keep runtimeStyle\r
+                                               run.width  = "auto"; // override\r
+                                               run.height = "auto";\r
+                                               w = image.width;\r
+                                               h = image.height;\r
+                                               run.width  = mem.w; // restore\r
+                                               run.height = mem.h;\r
+                                       } else { // for Opera and Other\r
+                                               mem = { w: image.width, h: image.height }; // keep current style\r
+                                               image.removeAttribute("width");\r
+                                               image.removeAttribute("height");\r
+                                               w = image.width;\r
+                                               h = image.height;\r
+                                               image.width  = mem.w; // restore\r
+                                               image.height = mem.h;\r
+                                       }\r
+                                       return image[key] = { width: w, height: h, src: image.src }; // bond\r
+                               }\r
+                               // HTMLCanvasElement\r
+                               return { width: image.width, height: image.height };\r
+                       }\r
+                       \r
+                       return size;\r
+               },\r
+               loadImage: function( URLorELM, onLoad, onError, delay, timeout){\r
+                       delay = delay || 250;\r
+                       timeout = timeout || 5000;\r
+                       var type = typeof URLorELM,\r
+                               img, images, src, abstractPath;\r
+                       if( type === 'string'){\r
+                               src = URLorELM;\r
+                               // images = [];\r
+                       } else\r
+                       // http://d.hatena.ne.jp/hottolinkblog/20090228/1235823487\r
+                       if( type === 'object' && typeof URLorELM.hspace !== 'undefined' && typeof URLorELM.vspace !== 'undefined'){\r
+                               img = URLorELM;\r
+                               images = [ img];\r
+                               src = img.src;\r
+                       } else {\r
+                               return;\r
+                       }\r
+                       abstractPath = this.getAbsolutePath( src);\r
+                       \r
+                       loadImage( images, abstractPath, onLoadAsync, onErrorAsync, delay, timeout);\r
+                       \r
+                       function onLoadAsync( abspath, actualW, actualH){\r
+                               if( abstractPath !== abspath) return;\r
+                               var _g_onUpdateFunction = pettanr.util.createGlobalFunction( onLoad);\r
+                                       _onTimeout = pettanr.util.createGlobalFunc( [\r
+                                               'function(){',\r
+                                                       'window["', _g_onUpdateFunction, '"]( "', abspath, '", ', actualW, ',  ', actualH, ');',\r
+                                                       'window["', _g_onUpdateFunction, '"] = null;',\r
+                                               '}'\r
+                                       ].join( ''));\r
+                               onLoad && setTimeout( window[ _onTimeout], 0);\r
+                               window[ _onTimeout] = null;\r
+                       }\r
+                       function onErrorAsync( abspath){\r
+                               if( abstractPath !== abspath) return;\r
+                               var _g_onUpdateFunction = pettanr.util.createGlobalFunction( onError);\r
+                                       _onTimeout = pettanr.util.createGlobalFunc( [\r
+                                               'function(){',\r
+                                                       'window["', _g_onUpdateFunction, '"]( "', abspath, '");',\r
+                                                       'window["', _g_onUpdateFunction, '"] = null;',\r
+                                               '}'\r
+                                       ].join( ''));\r
+                               onError && setTimeout( window[ _onTimeout], 0);\r
+                               window[ _onTimeout] = null;\r
+                       }\r
+                       \r
+               /*  LICENSE: MIT?\r
+                *  URL: http://d.hatena.ne.jp/uupaa/20080413/1208067631\r
+                *  AUTHOR: uupaa.js@gmail.com\r
+                * \r
+                *  fixed for ie6-8 by pettanr\r
+                *   new Image -> document.createElement( 'img')\r
+                */\r
+                       function loadImage( images, abspath, onLoad, onError, delay, timeout) {\r
+                               images = images || document.images;\r
+                               var img,\r
+                                       i = 0, l = images.length,\r
+                                       tick = 0;\r
+                               for(; i < l; ++i) {\r
+                                       img = images[i];\r
+                                       if ( img.src === abspath && img.complete) {\r
+                                               var size = pettanr.util.getImageSize( img);\r
+                                               onLoad( abspath, size.width, size.height);\r
+                                               return;\r
+                                       }\r
+                               }\r
+                               img = document.createElement( 'img'); //var img = new Image(); ではieでimgのsizeが取れない、、、removeChildも失敗し、imgSizeGetterにimgが残る\r
+                               img.finish = false;\r
+                               img.onabort = img.onerror = function() {\r
+                                       if (img.finish) { return; }\r
+                                       img.finish = true;\r
+                                       onError(abspath);\r
+                                       img.onload = img.onabort = img.onerror = "";\r
+                               };\r
+                               img.onload  = function() {\r
+                                       img.finish = true;\r
+                                       if (window.opera && !img.complete) {\r
+                                               onError(abspath);\r
+                                               img.onload = img.onabort = img.onerror = "";\r
+                                               return;\r
+                                       }\r
+                                       var size = pettanr.util.getImageSize( img);\r
+                                       onLoad( abspath, size.width, size.height);\r
+                                       img.onload = img.onabort = img.onerror = "";\r
+                                       //img = void 0;\r
+                               };\r
+                               img.src = abspath;\r
+                               if (!img.finish && timeout) {\r
+                                       setTimeout(function() {\r
+                                               if (img.finish) { return; }\r
+                                               if (img.complete) {\r
+                                                       img.finish = true;\r
+                                                       if (img.width) { return; }\r
+                                                       onError(abspath);\r
+                                                       img.onload = img.onabort = img.onerror = "";\r
+                                                       return;\r
+                                               }\r
+                                               if ((tick += delay) > timeout) {\r
+                                                       img.finish = true;\r
+                                                       onError(abspath);\r
+                                                       img.onload = img.onabort = img.onerror = "";\r
+                                                       return;\r
+                                               }\r
+                                               setTimeout(arguments.callee, delay);\r
+                                       }, 0);\r
+                               }\r
+                       }\r
+               },\r
+               getAbsolutePath: function( path) {\r
+                       var e = document.createElement("div");\r
+                       e.innerHTML = '<a href=\"' + path + '\" />';\r
+                       return e.firstChild.href;\r
+               },\r
+               getAbsolutePosition: function( _elm){\r
+                       // Find the destination's position\r
+                       var     destx = _elm.offsetLeft,\r
+                               desty = _elm.offsetTop,\r
+                               thisNode = _elm,\r
+                               body = document.body;\r
+                       while (thisNode.offsetParent && thisNode.offsetParent !== body){\r
+                               thisNode = thisNode.offsetParent;\r
+                               destx += thisNode.offsetLeft;\r
+                               desty += thisNode.offsetTop;\r
+                       }\r
+                       return {\r
+                               x:      destx,\r
+                               y:      desty\r
+                       }\r
+               },\r
+               pullHtmlAsTemplete: function( IDorELM){\r
+                       if( typeof IDorELM === 'string'){\r
+                               IDorELM = document.getElementById( IDorELM);\r
+                       }\r
+                       if( !IDorELM) return;\r
+                       IDorELM.parentNode && IDorELM.parentNode.removeChild( IDorELM);\r
+                       if( IDorELM.id && IDorELM.id.indexOf( 'templete-') === 0){\r
+                               IDorELM.removeAttribute( 'id');\r
+                       }\r
+                       return IDorELM;\r
+               },\r
+               getElementsByClassName: function( _elm, _className, opt_tagName){\r
+                       var _all = !opt_tagName || opt_tagName === '*',\r
+                               _nodes = _all === true ? ( _elm.all || _elm.getElementsByTagName( '*')) : _elm.getElementsByTagName( opt_tagName),\r
+                               _node, _classes, ret = [];\r
+                       for( var i=0, l = _nodes.length; i<l; ++i){\r
+                               _node = _nodes[ i];\r
+                               _node.nodeType === 1 && this.hasClassName( _node, _className) === true && ret.push( _node);\r
+                       }\r
+                       return ret;\r
+               },\r
+               getChildIndex: function( _parent, _child){\r
+                       var _children = _parent.getElementsByTagName( _child.tagName ),\r
+                               l = _children.length;\r
+                       for(var i=0; i<l; ++i){\r
+                               if( _children[ i] === _child) return i;\r
+                       }\r
+                       return -1;\r
+               },\r
+               hasClassName: function( _elm, _className){\r
+                       var _classes = ( _elm.className || '').split( ' ');\r
+                       for( var i=0, l=_classes.length; i<l; ++i){\r
+                               if( _classes[ i] === _className) return true;\r
+                       }\r
+                       return false;\r
+               },\r
+               removeAllChildren: function ( _elm){\r
+                       while( _elm.firstChild){\r
+                               remove( _elm.firstChild);\r
+                       }\r
+                       function remove( _node){\r
+                               while( _node.firstChild){\r
+                                       remove( _node.firstChild);\r
+                               }\r
+                               _node.parentNode && _node.parentNode.removeChild( _node);\r
+                       }\r
+               },\r
+               getIndex: function( _array, _element){\r
+                       if( Array.prototype.indexof ){\r
+                               pettanr.util.getIndex = function( _array, _element){\r
+                                       return _array.indexof( _element);\r
+                               }\r
+                       } else {\r
+                               pettanr.util.getIndex = function( _array, _element){\r
+                                       for( var i=0, l = _array.length; i<l; ++i){\r
+                                               if( _array[ i] === _element) return i;\r
+                                       }\r
+                                       return -1;                                      \r
+                               }\r
+                       }\r
+                       return pettanr.util.getIndex( _array, _element);\r
+               },\r
+               copyArray: function( _array ){\r
+                       var ret = new Array( l );\r
+                       for(var i=0, l = _array.length; i<l; ++i){\r
+                               ret[ i ] = _array[ i ];\r
+                       }\r
+                       return ret;\r
+               },\r
+               /*\r
+                * \r
+                */\r
+               createGlobalFunction: function( _func) {\r
+                       var randomKey = null;\r
+                       while( true) {\r
+                               randomKey = '_glovalFunction_' + ( '' + Math.random()).replace( /\./,'');\r
+                               if( eval( 'typeof '+randomKey) === 'undefined') {\r
+                                       break;\r
+                               }\r
+                       }\r
+                       window[ randomKey] = _func;\r
+                       return randomKey;\r
+               },\r
+               createGlobalFunc: function( func){\r
+                       var randomKey = null;\r
+                       while(true) {\r
+                               randomKey = 'hogeGlovalFunc_'+(''+Math.random()).replace(/\./,'');\r
+                               if(eval('typeof '+randomKey) == 'undefined') {\r
+                                       break;\r
+                               }\r
+                       }\r
+                       eval(randomKey+'='+((typeof func=='string') ? func : func.toString()));\r
+                       return randomKey;\r
+               },\r
+               createGlobalVar: function( obj){\r
+                       var randomKey = null;\r
+                       while(true) {\r
+                               randomKey = 'hogeGlovalVar_'+(''+Math.random()).replace(/\./,'');\r
+                               if(eval('typeof '+randomKey+'') == 'undefined') {\r
+                                       break;\r
+                               }\r
+                       }\r
+                       var globalObj = eval(randomKey+'={}');\r
+                       globalObj.value = obj;\r
+                       return randomKey;\r
+               },\r
+               createGlobalUniqueName: function(){\r
+                       var randomKey = null;\r
+                       while(true) {\r
+                               randomKey = '_uniqueName'+(''+Math.random()).replace(/\./,'');\r
+                               if( typeof window[randomKey] === 'undefined'){\r
+                                       break;\r
+                               }\r
+                       }\r
+                       return randomKey;\r
+               },\r
+               createIframe: function( id, callback){\r
+                       var ua = pettanr.ua;\r
+            var el = document.createElement( ua.isIE ? '<iframe name="' + id + '" frameborder="0" scrolling="no">' : 'iframe');\r
+\r
+            if( ua.isIE){\r
+                               el.onreadystatechange = detect;\r
+            } else {\r
+               // iron(chrome) の場合、append の前に onload を指定しないと onload が呼ばれない\r
+               el.onload = onLoad;\r
+               //setTimeout( asynkCallback, 0 );\r
+                       }\r
+\r
+                       document.body.appendChild( el);\r
+            el.id = el.name = id;\r
+            el.setAttribute( 'name', id);\r
+            el.style.cssText = 'width:1px;height:1px;visibility:hidden;position:absolute;top:1px;left:1px;';\r
+                       // http://d.hatena.ne.jp/onozaty/20070830/p1\r
+                       // [JavaScript]IE6ではJavaScriptで動的に作成したiframeに対してsubmitできない(IE7は未確認) ->解決\r
+                       el.contentWindow.name = id;                                     \r
+            \r
+            window[id] = el;\r
+\r
+            function detect(){\r
+                if ( this.readyState === "complete") {\r
+                    this.onreadystatechange = new Function();\r
+                    this.onreadystatechange = null;\r
+                    setTimeout( asynkCallback, 0 );\r
+                }\r
+            }\r
+                       function onLoad(){\r
+                               el.onload = null;\r
+                               setTimeout( asynkCallback, 0 );\r
+                       }\r
+                       function asynkCallback(){\r
+                               callback( el );\r
+                       }\r
+               }\r
+       }\r
+})();\r
+\r
+/*\r
+ * pettanr.ua\r
+ * \r
+ *   detect userAgent\r
+ *   detect plug in\r
+ */\r
+pettanr.ua = ( function(){\r
+       var ua = (function(){\r
+                       var acme = {};\r
+                       \r
+                       var n = navigator;\r
+                       var dua = n.userAgent;\r
+                       var dav = n.appVersion;\r
+                       var tv = parseFloat(dav);\r
+                       acme.isOpera = (dua.indexOf("Opera") >= 0) ? tv: undefined;\r
+                       acme.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : undefined;\r
+                       acme.isWebKit = parseFloat(dua.split("WebKit/")[1]) || undefined;\r
+                       acme.isChrome = parseFloat(dua.split("Chrome/")[1]) || undefined;\r
+                       var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0);\r
+                       if(index && !acme.isChrome){\r
+                               acme.isSafari = parseFloat(dav.split("Version/")[1]);\r
+                               if(!acme.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3){\r
+                                       acme.isSafari = 2;\r
+                               }\r
+                       }\r
+                       if(document.all && !acme.isOpera){\r
+                               acme.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;\r
+                       }\r
+                       \r
+                       return acme;\r
+               })(),\r
+               isIE = navigator.userAgent.toLowerCase().indexOf( 'msie') !== -1,\r
+               ieVersion = isIE === true ? parseInt( navigator.appVersion.toLowerCase().replace( /.*msie[ ]/, '').match( /^[0-9]+/)) : 0,\r
+               ieRenderingVersion = ieVersion === 8 ? document.documentMode : ieVersion,\r
+               isStanderdMode = document.compatMode === 'CSS1Compat',\r
+               ActiveX = ( function(){\r
+                       if( isIE === false || ieVersion > 8) return false;\r
+                       var     b = document.body,\r
+                               c = b.className || '',\r
+                               x,\r
+                               ret = pettanr.URL_PARAMS.ActiveX,\r
+                               ns = 'pettanr-ActiveX-',\r
+                               enabled = 'enabled',\r
+                               disabled = 'disabled';\r
+                       if( ret !== true && ret !== false){\r
+                               if( pettanr.util.hasClassName( b, ns + enabled) === true) return true;\r
+                               if( pettanr.util.hasClassName( b, ns + disabled) === true) return false;\r
+                               x = document.createElement('div');\r
+                               b.appendChild(x);\r
+                               x.style.cssText = 'width:1px;height:1px;line-height:1px;filter:progid:DXImageTransform.Microsoft.Shadow()';\r
+                               ret = x.offsetHeight > 1;\r
+                               b.removeChild(x);\r
+                       }\r
+                       b.className += [ c !== '' ? ' ' : c, ns, ret === true ? enabled : disabled ].join( '');\r
+                       return ret;\r
+               })(),\r
+               VML = ( function(){\r
+                       if( ActiveX === false || isIE === false || ieVersion > 8) return false;\r
+                       var globalObjectName = pettanr.util.createGlobalUniqueName(),\r
+                               script,\r
+                               id = 'detectVML';\r
+                       document.write( [ '<!--[if gte vml 1]><script id="', id, '">window', '.', globalObjectName, '=1;<\/script><![endif]-->'].join( ''));\r
+                       if( window[globalObjectName] === 1){\r
+                               script = document.getElementById( id);\r
+                               script.parentNode.removeChild( script);\r
+                               window[globalObjectName] = null;\r
+                               return true;\r
+                       }\r
+                       return false;\r
+               })(),\r
+               isStandAloneMode = ( function(){\r
+                       if( isIE === false) return false;\r
+                       if( VML === true) return false;\r
+                       var globalObjectName = pettanr.util.createGlobalUniqueName(),\r
+                               script,\r
+                               id = 'detectStandAlone';\r
+                       document.write( [ '<!--[if IE ', Math.floor( ieVersion), ']><script id="', id, '">window', '.', globalObjectName, '=1;<\/script><![endif]-->'].join( ''));\r
+                       if( window[globalObjectName] === 1){\r
+                               script = document.getElementById( id);\r
+                               script.parentNode.removeChild( script);\r
+                               window[globalObjectName] = null;\r
+                               return false;\r
+                       }\r
+                       return true;\r
+               })();\r
+       return {\r
+               IE:                                     ua.isIE,\r
+               GECKO:                          0,\r
+               OPERA:                          ua.isOpera,\r
+               KHTML:                          ua.isKhtml,\r
+               WEBKIT:                         ua.isWebKit,\r
+               CHROME:                         ua.isChrome,\r
+               isIE:                           isIE,\r
+               ieVersion:                      ieVersion,\r
+               ieRenderingVersion:     ieRenderingVersion,\r
+               isStanderdMode:         isStanderdMode,\r
+               VENDER_PREFIX: ( function() {\r
+                       var ua = navigator.userAgent.toLowerCase();\r
+                       if ( ua.indexOf('opera') !== -1) {\r
+                               return 'O';\r
+                       } else if ( ua.indexOf('msie') !== -1) {\r
+                               return 'ms';\r
+                       } else if ( ua.indexOf('webkit') !== -1) {\r
+                               return 'webkit';\r
+                       } else if ( navigator.product === 'Gecko') {\r
+                               return 'Moz';\r
+                       }\r
+                       return '';\r
+               })(),\r
+               ACTIVEX: ActiveX,\r
+               VML: VML,\r
+               STANDALONE: isStandAloneMode,\r
+               startVML: function(){\r
+                       delete this.startVML;\r
+                       if( pettanr.ua.VML !== true) return false;\r
+                       if (!document.namespaces["v"]) {\r
+                       document.namespaces.add("v", "urn:schemas-microsoft-com:vml", "#default#VML");\r
+                   }\r
+                   document.createStyleSheet().cssText = "v\:shape,v\:image{behavior:url(#default#VML);display:block;};";\r
+               }\r
+       }\r
+})();\r
+\r
+\r
+pettanr.CONST = ( function(){\r
+       var isLocal = pettanr.LOCAL === true || pettanr.URL_PARAMS.exjson === false,\r
+               isLocalhost = document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0,\r
+               PETTANR_ROOT_PATH = isLocalhost === true ? 'http:\/\/localhost:3000\/' : 'http:\/\/pettanr.heroku.com\/';\r
+               \r
+       return {\r
+               PETTANR_ROOT_PATH:                      PETTANR_ROOT_PATH,\r
+               URL_ORIGINAL_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'original_pictures.json',\r
+               URL_RESOURCE_PICTURES_JSON: ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'resource_pictures.json',\r
+               URL_COMICS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'comics.json',\r
+               URL_PANELS_JSON:                        ( isLocal === true ? 'json\/' : PETTANR_ROOT_PATH) + 'panels.json',\r
+               NS_PETTANR_COMIC:                       'pettanr-comic',\r
+               RESOURCE_PICTURE_PATH:          ( isLocal === true ? '' : PETTANR_ROOT_PATH) + 'resource_pictures\/',\r
+               CREATE_COMIC_JS:                        isLocal === true ? 'js\/create_new_comic.js' : PETTANR_ROOT_PATH + 'comics\/new.js',\r
+               CREATE_PANEL_JS:                        isLocal === true ? 'js\/create_new_panel.js' : PETTANR_ROOT_PATH + 'panels\/new.js',\r
+               UPLOAD_PICTURE_JS:                      isLocal === true ? 'js\/upload_picture.js' : PETTANR_ROOT_PATH + 'original_pictures\/new.js',\r
+               REGISTER_ARTIST_JS:                     isLocal === true ? 'js\/register_artist.js' : PETTANR_ROOT_PATH + 'artists\/new.js',\r
+               JQUERY_URL:                                     isLocal === true ? 'javascripts\/jquery-1.6.2.min.js' : PETTANR_ROOT_PATH + 'assets\/jquery-162_min.js'\r
+       }\r
+})();\r
+\r
+pettanr.view = ( function(){\r
+       /* create iframe overlay for user console */\r
+       var location = document.location.pathname,\r
+               isWorkPage =    document.location.href.indexOf( 'http:\/\/localhost:3000\/' ) === 0 ||\r
+                                               document.location.href.indexOf( pettanr.CONST.PETTANR_ROOT_PATH ) === 0 ||\r
+                                               location.indexOf( '\/work.html') !== -1 ||\r
+                                               location.indexOf( '\work.html') !== -1, // for ie6\r
+               deep =  location.indexOf( '\/diary\/') !== -1 ||\r
+                               location.indexOf( '\/test\/') !== -1 ||\r
+                               location.indexOf( '\/help\/') !== -1 ||\r
+                               location.indexOf( '\/sitemap\/') !== -1 ||\r
+                               location.indexOf( '\/wiki\/') !== -1,\r
+               LoginUserNavi;\r
+\r
+       if( isWorkPage === false){\r
+               LoginUserNavi = {\r
+                       show: function(){\r
+                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+                               document.location.href = [\r
+                                               deep === true ? '../' : '',\r
+                                               'work.html',\r
+                                               typeof i === 'number' ? '?view=' + i : ''\r
+                                       ].join( '');\r
+                               return false;\r
+                       },\r
+                       hide: function(){}\r
+               }\r
+       } else {\r
+               LoginUserNavi = {\r
+                       show: function(){\r
+                               var i = pettanr.util.getChildIndex( this.parentNode, this );\r
+                               i !== -1 && bootApplication( i );\r
+                               return false;\r
+                       },\r
+                       hide: function(){}\r
+               }\r
+       }\r
+\r
+       /* debug info */\r
+       // ua version, lang, os, plugin ( vml, svg), standerdmode, balloon, rimg\r
+\r
+/*\r
+ * window resize event, overlay と currentなviewに流す\r
+ * view modeの保持\r
+ *      editor, overlay, comic-viewer, image-explorer\r
+ * fadeIn, faseOut\r
+ */\r
+\r
+       var jqWindow,\r
+               APPLICATION_LIST = [],\r
+               LUNCHER_APPLICATION_LIST = [],\r
+               currentApplication = null;\r
+       \r
+       var AbstractBasicPane = function(){\r
+               this.rootElement = null;\r
+               this.parentElement = null;\r
+               this.nextSibling = null;\r
+               this.onOpen = function( _w, _h /*, _option */ ){\r
+                       // overrride\r
+               };\r
+               this.onClose = function(){\r
+                       // overrride\r
+                       return true;\r
+               } // false の場合、close の拒否 \r
+               this.onPaneResize = function( _w, _h ){}\r
+               this.open = function( _w, _h /*, _option */ ){\r
+                       if( this.nextSibling && this.nextSibling.parentNode === this.parentElement ){\r
+                               this.parentElement.insertBefore( this.rootElement, this.nextSibling );\r
+                       } else\r
+                       if( this.parentElement ){\r
+                               this.parentElement.appendChild( this.rootElement );\r
+                       } else {\r
+                               this.rootElement && document.body.appendChild( this.rootElement );\r
+                       }\r
+                       if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
+                               if( Type.isHTMLElement( this.rootElement ) === true ){\r
+                                       // 小さすぎる!、と表示\r
+                               }\r
+                       }\r
+                       if( arguments.length > 2){\r
+                               // argumentsRellay( this.onOpen, arguments );\r
+                               this.onOpen.apply( this, arguments );\r
+                       } else {\r
+                               this.onOpen( _w, _h );\r
+                       }\r
+               }\r
+               this.close = function(){\r
+                       if( this.onClose() === false ){\r
+                               \r
+                       }\r
+                       if( this.rootElement && this.rootElement.parentNode ){\r
+                               this.rootElement.parentNode.removeChild( this.rootElement );\r
+                       }\r
+               }\r
+               this.resize = function( _w, _h ){\r
+                       if( this.MIN_WIDTH > _w || this.MIN_HEIGHT > _h ){\r
+                               if( Type.isHTMLElement( this.rootElement ) === true ){\r
+                                       // 小さすぎる!、と表示\r
+                               }\r
+                               return;\r
+                       }\r
+                       this.onPaneResize( _w, _h );\r
+               }\r
+               this.MIN_WIDTH = 240;\r
+               this.MIN_HEIGHT = 240;\r
+       }\r
+       \r
+       var AbstractApplication = function(){\r
+               this.displayName = 'app name';\r
+               this.ID = 'app id';\r
+       }\r
+       AbstractApplication.prototype = new AbstractBasicPane();\r
+       \r
+       var ApplicationReference = function( _application ){\r
+               this.inOverlay = false;\r
+               this.boot = function( /* _option */ ){\r
+                       if( arguments.length > 0 ){\r
+                               bootApplication( _application, pettanr.util.copyArray( arguments ) );\r
+                       } else {\r
+                               bootApplication( _application );\r
+                       }\r
+               }\r
+               this.bootInOverlay = function( /* _option */ ){\r
+                       this.inOverlay = true;\r
+                       pettanr.overlay.show( _application );\r
+                       \r
+                       if( arguments.length > 0 ){\r
+                               var _arguments = pettanr.util.copyArray( arguments );\r
+                               _arguments.unshift( jqWindow.width(), jqWindow.height() )\r
+                               // argumentsRellay( _application.open, _arguments );\r
+                               _application.open.apply( _application, _arguments );\r
+                       } else {\r
+                               _application.open( jqWindow.width(), jqWindow.height() );\r
+                       }\r
+               }\r
+               this.shutdown = function(){\r
+                       if( this.inOverlay === true ){\r
+                               pettanr.overlay.hide();\r
+                               _application.close();\r
+                               this.inOverlay = false;\r
+                       } else {\r
+                               bootApplication( 0 );\r
+                       }\r
+               }\r
+               this.addToLancher = function(){\r
+                       if( pettanr.util.getIndex( LUNCHER_APPLICATION_LIST, _application ) !== -1 ) return;\r
+                       LUNCHER_APPLICATION_LIST.push( _application );\r
+       \r
+                       var navi = document.getElementById('global-navi'),\r
+                               item = document.createElement('a');\r
+                       navi.appendChild( item );\r
+                       navi.style.width = ( ( item.offsetWidth || 80 ) * LUNCHER_APPLICATION_LIST.length ) + 'px';\r
+                       item.href = '#';\r
+                       item.appendChild( document.createTextNode( _application.displayName ));\r
+                       item.onclick = LoginUserNavi.show;\r
+               }\r
+       }\r
+\r
+       function bootApplication( APPLICATIONorINDEX, _arguments ){\r
+               if( isWorkPage === false ) return;\r
+\r
+               var _application,\r
+                       i, j, l, \r
+                       nodesA = document.getElementById('global-navi').getElementsByTagName( 'a') || [],\r
+                       _index = -1;\r
+               if( typeof APPLICATIONorINDEX === 'number' && APPLICATIONorINDEX < LUNCHER_APPLICATION_LIST.length){\r
+                       _application = LUNCHER_APPLICATION_LIST[ APPLICATIONorINDEX ];\r
+               } else\r
+               if( typeof APPLICATIONorINDEX === 'string' ){\r
+                       for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+                               if( APPLICATIONorINDEX === APPLICATION_LIST[ i ].ID ){\r
+                                       _application = APPLICATION_LIST[ i ];\r
+                                       break;\r
+                               }\r
+                       }\r
+               } else\r
+               if( pettanr.view.isApplicationInstance( APPLICATIONorINDEX ) === true ){\r
+                       _application = APPLICATIONorINDEX;\r
+               } else\r
+               if( !currentApplication ){\r
+                       _application = LUNCHER_APPLICATION_LIST[ 0 ];\r
+               } else {\r
+                       return;\r
+               }\r
+               \r
+               if( !_application ) return;\r
+               \r
+               for( i=0, l=LUNCHER_APPLICATION_LIST.length; i<l; ++i ){\r
+                       if( _application === LUNCHER_APPLICATION_LIST[ i ] ){\r
+                               for( j=0, l=nodesA.length; j<l; ++j ){\r
+                                       nodesA[ j ].className = i === j ? 'current' : '';\r
+                               }                                       \r
+                               break;\r
+                       }\r
+               }\r
+               \r
+               if( currentApplication === _application ) return;\r
+               \r
+               currentApplication && currentApplication.close();\r
+\r
+               currentApplication = _application;\r
+               \r
+               if( _arguments ){\r
+                       _arguments.unshift( jqWindow.width(), jqWindow.height() );\r
+                       _application.open.apply( _application, _arguments );\r
+                       // argumentsRellay( _application.open, _arguments );\r
+               } else {\r
+                       _application.open( jqWindow.width(), jqWindow.height() );\r
+               }\r
+               pettanr.view.currentID = _application.ID;\r
+       }\r
+       \r
+       function argumentsRellay( _method, _arguments ){\r
+               alert( typeof _method )\r
+               l = _arguments.length;\r
+               if( l > 0 ){\r
+                       var _arg = [];\r
+                       for( i=0; i<l; ++i ){\r
+                               _arg.push( 'a[' + i + ']' );\r
+                       }\r
+                       window['_method'] = _method;\r
+                       //eval( '_method(' + _arg.join(',') + ')' );\r
+                       var f = new Function( 'a', '_method(' + _arg.join(',') + ')' );\r
+                       f( _arguments );\r
+                       window['_method'] = undefined;\r
+               } else {\r
+                       _method();\r
+               }               \r
+       }\r
+       \r
+       function onWindowResize(){\r
+               var w = jqWindow.width(),\r
+                       h = jqWindow.height();\r
+               currentApplication && currentApplication.resize && currentApplication.resize( w, h );\r
+               pettanr.overlay.currentID !== null && pettanr.overlay.onWindowResize( w, h );\r
+       }\r
+\r
+       return {\r
+               init: function( _funcArray ){\r
+                       jqWindow = pettanr.jqWindow();\r
+                       jqWindow.resize( onWindowResize );\r
+                       \r
+                       var _option = {}; // urlパラメータ\r
+\r
+                       bootApplication( pettanr.URL_PARAMS.view || 0 );\r
+                       \r
+                       delete pettanr.view.init;\r
+               },\r
+               createBasicPane: function( _class, _options ){\r
+                       _class.prototype = new AbstractBasicPane();\r
+                       return new _class( _options );\r
+               },\r
+               _getAbstractApplication: function(){\r
+                       return new AbstractApplication();\r
+               },\r
+               registerApplication: function( _class, _options ){\r
+                       _class.prototype = new AbstractApplication();\r
+                       _application = new _class( _options );\r
+                       \r
+                       var elm = _application.rootElement;\r
+                       if( Type.isHTMLElement( elm ) === false ) return null;\r
+                        \r
+                       _application.parentElement = elm.parentNode;\r
+                       _application.nextSibling = elm.nextSibling;\r
+                       \r
+                       if( elm.parentNode ){\r
+                               elm.parentNode.removeChild( elm );\r
+                       }\r
+                       APPLICATION_LIST.push( _application );\r
+                       return new ApplicationReference( _application );\r
+               },\r
+               isBasicPaneInstance: function( _basicPane ){\r
+                       return  _basicPane instanceof AbstractBasicPane;\r
+               },\r
+               isApplicationInstance: function( _application ){\r
+                       return _application instanceof AbstractApplication;\r
+               },\r
+               isApplicationReference: function( _reference ){\r
+                       return _reference instanceof ApplicationReference;\r
+               },\r
+               currentID:      null,\r
+               EDITOR:         'editor',\r
+               OVERLAY:        'overlay'\r
+       }\r
+})();\r
+\r
+pettanr.overlay = ( function(){\r
+       var SHADOW_OPACITY = 0.5,\r
+               ELM_CONTAINER = document.getElementById( 'overlay-container' ),\r
+               jqConteiner, jqShadow, jqCloseButton,// jqBody, \r
+               currentOverlay = null,\r
+               visible = false,\r
+               windowW, windowH;\r
+\r
+       function close(){\r
+               currentOverlay && currentOverlay.close();\r
+               pettanr.overlay.hide();         \r
+       }\r
+       function asyncResize(){\r
+               currentOverlay.resize( windowW, windowH);\r
+       }\r
+       function onCloseClick( e){\r
+               close();\r
+               e.preventDefault();\r
+               return false;           \r
+       }\r
+       function onFadeInComplete(){\r
+               \r
+       }\r
+       function onFadeOutComplete(){\r
+               if( currentOverlay.rootElement && currentOverlay.rootElement.parentNode === ELM_CONTAINER ){\r
+                       ELM_CONTAINER.removeChild( currentOverlay.rootElement );\r
+               }\r
+               currentOverlay = null;\r
+       }\r
+       return {\r
+               init: function(){\r
+                       //jqBody = pettanr.jqBody();\r
+                       jqConteiner = $( '#overlay-container');\r
+                       jqShadow = $( '#overlay-shadow');\r
+                       jqCloseButton = $( '#overlay-close-button').click( onCloseClick );\r
+                       \r
+                       pettanr.key.addKeyDownEvent( pettanr.view.OVERLAY, 27, false, false, close); // 27.esc\r
+                       \r
+                       delete pettanr.overlay.init;\r
+               },\r
+               show: function( _overlay ){\r
+                       if( visible === true && currentOverlay === _overlay ) return;\r
+                       if( pettanr.view.isApplicationInstance( _overlay ) === false ) return;\r
+                       \r
+                       document.body.style.overflow = 'hidden';\r
+                       ELM_CONTAINER.insertBefore( _overlay.rootElement, document.getElementById( 'overlay-close-button' ));\r
+                       \r
+                       jqConteiner.stop().css( {\r
+                               filter:         '',\r
+                               opacity:        '',\r
+                               top:            document.documentElement.scrollTop || document.body.scrollTop\r
+                       }).fadeIn( onFadeInComplete );\r
+                       \r
+                       this.visible = visible = true;\r
+                       currentOverlay = _overlay;\r
+                       this.currentID = _overlay.ID;\r
+                       // jqCloseButton.toggle( !!_overlay.onClose );\r
+               },\r
+               hide: function(){\r
+                       if( visible === false) return;\r
+                       document.body.style.overflow = '';\r
+                       jqConteiner.stop().css( {\r
+                               filter:         '',\r
+                               opacity:        ''\r
+                       }).fadeOut( onFadeOutComplete );\r
+                       this.visible = visible = false;\r
+                       this.currentID = null;\r
+               },\r
+               visible: visible,\r
+               currentID: null,\r
+               onWindowResize: function( _windowW, _windowH ){\r
+                       jqConteiner.css({\r
+                               height:         _windowH,\r
+                               top:            document.documentElement.scrollTop || document.body.scrollTop\r
+                       });\r
+                       jqShadow.css( { height: _windowH});\r
+                       windowW = _windowW;\r
+                       windowH = _windowH;\r
+                       // 先にeditorのcanvasを確定する。\r
+                       currentOverlay && setTimeout( asyncResize, 0);\r
+               },\r
+               registerOverlay: function( _basicPane){\r
+                       var _api = pettanr.view.createBasicPane( _basicPane );\r
+                       // OverlayAPI\r
+                       return {\r
+                               show: function( _basicPane ){\r
+                                       \r
+                               },\r
+                               hide: function( _basciPane ){\r
+                                       \r
+                               },\r
+                               isCurrent: function( _basicPane ){\r
+                                       \r
+                               }\r
+                       }\r
+               },\r
+               isOverlay: function( _basicPane ){\r
+                       \r
+               }\r
+       }\r
+})();\r
+\r
+/* ----------------------------------------\r
+ * KEY\r
+ * \r
+ *  - EDITABLE_TEXT_CONTROL\r
+ * \r
+ *    .SHIFT_DOWN_EVENT:       'shiftDown',\r
+ *    .SHIFT_UP_EVENT:         'shiftUp',\r
+ *    .CTRL_DOWN_EVENT:                'ctrlDown',\r
+ *    .CTRL_UP_EVENT:          'ctrlUp',\r
+ *    .SPACE_DOWN_EVENT:       'spaceDown',\r
+ *    .SPACE_UP_EVENT:         'spaceUp',\r
+ *    .init:                           function,\r
+ *    .addKeyDownEvent:                function,\r
+ *    .keyEventDispatcher:     function,\r
+ * \r
+ * ショートカットキーの監視とテキスト入力(input, textarea)、チェックボックスを管理する。\r
+ * キー入力はdocumentで受けて、テキスト編集中(input, textarea)はそちらにキーイベント流す。\r
+ * \r
+ */\r
+pettanr.key = ( function(){\r
+       var log,\r
+               jqWindow,\r
+               keyOperationChatcher,\r
+               KEYEVENT_ARRAY = [],\r
+               shiftEnabled = false,\r
+               ctrlEnabled = false;\r
+       \r
+       function keyHit( e){\r
+               log.html( [ e.keyCode, e.shiftKey, e.ctrlKey, e.altKey, e.type].join( ','));\r
+               //keyOperationChatcher.val( '');\r
+               var cancel = false,\r
+                       callback = e.type,\r
+                       key = e.keyCode,\r
+                       overlayEnabled = pettanr.overlay.visible === true,\r
+                       currentViewID = overlayEnabled === true ? pettanr.overlay.currentID : pettanr.view.currentID;\r
+               if( callback === 'keypress') callback = 'keydown';\r
+               if( pettanr.form.keyEventRellay( e) === false){\r
+                       var shift = e.shiftKey,\r
+                               ctrl = e.ctrlKey,\r
+                               l = KEYEVENT_ARRAY.length,\r
+                               d;\r
+                       if( key === 16 || e.shiftKey === true){\r
+                               shiftEnabled = callback !== 'keyup';\r
+                       }\r
+                       if( key === 17 || e.ctrlKey === true){\r
+                               ctrlEnabled = callback !== 'keyup';\r
+                       }\r
+\r
+                       for( var i=0; i<l; i++){\r
+                               d = KEYEVENT_ARRAY[ i];\r
+                               if( (\r
+                                               d.viewID === currentViewID ||\r
+                                                       ( overlayEnabled === true && d.viewID === pettanr.view.OVERLAY)\r
+                                       ) &&\r
+                                       d.keyCode === key &&\r
+                                       ( d.shift === undefined || d.shift === shift) &&\r
+                                       ( d.ctrl === undefined || d.ctrl === ctrl)\r
+                               ){\r
+                                       ( function( func, e){\r
+                                               func && setTimeout( function(){\r
+                                                       func( e);\r
+                                                       func = e = null;\r
+                                               }, 0);\r
+                                       })( d[callback], e);\r
+                                       cancel = true;\r
+                               }\r
+                       }\r
+               }\r
+               if( cancel === true || key === 18 || key === 9 || key === 27 || e.altKey === true){ // 13.enter 18.esc 9.tab 27.esc   || ( key === 13 && overlayEnabled === false)\r
+                       e.preventDefault();\r
+               e.keyCode = 0;\r
+               e.cancelBubble = true;\r
+               e.returnValue = false;\r
+                       return false;\r
+               }\r
+       }\r
+       \r
+       var keyPress = pettanr.ua.isIE === true && pettanr.ua.ieRenderingVersion < 8 ? ( function( e){\r
+                       var key = e.keyCode;\r
+                       if( key === 13 || key === 27){\r
+                               keyHit( e);\r
+                               return false;\r
+                       }\r
+       }) : null;\r
+       \r
+       return {\r
+               init: function(){\r
+                       log = $( '#key-event-log').html( 'ready');\r
+\r
+                       jqWindow = pettanr.jqWindow().focus();\r
+                       keyOperationChatcher = pettanr.jqDocument()\r
+                               .keydown( keyHit)\r
+                               .keyup( keyHit)\r
+                               .mouseenter( function(){\r
+                                       jqWindow.focus();\r
+                               });\r
+                       keyPress && keyOperationChatcher.keypress( keyPress);\r
+\r
+                       delete pettanr.key.init;\r
+               },\r
+               addKeyDownEvent: function( _viewID, _keyCode, _shift, _ctrl, _callbackFunction){\r
+                       KEYEVENT_ARRAY.push( {\r
+                               viewID:                 _viewID,\r
+                               keyCode:                _keyCode,\r
+                               shift:                  _shift,\r
+                               ctrl:                   _ctrl,\r
+                               keydown:                _callbackFunction\r
+                       });\r
+               },\r
+               addKeyUpdateEvent: function( _viewID, _keyCode, _shift, _ctrl, _callbackFunction){\r
+                       KEYEVENT_ARRAY.push( {\r
+                               viewID:         _viewID,\r
+                               keyCode:        _keyCode,\r
+                               shift:          _shift,\r
+                               ctrl:           _ctrl,\r
+                               keydown:        _callbackFunction,\r
+                               keyup:          _callbackFunction\r
+                       });\r
+               },\r
+               addCursorEvent: function( _viewID, _shift, _ctrl, _callbackFunction){\r
+                       \r
+               },\r
+               keyEventDispatcher: function(){\r
+                       return keyOperationChatcher;\r
+               },\r
+               shiftEnabled: function(){\r
+                       return shiftEnabled;\r
+               },\r
+               ctrlEnabled: function(){\r
+                       return ctrlEnabled;\r
+               }\r
+       }\r
+})();\r
+\r
+/*\r
+ * pettanr.form\r
+ * \r
+ * keyEventRellay\r
+ *  form -> overlay -> view\r
+ * \r
+ */\r
+pettanr.form = ( function(){\r
+       var     FORM_GROUP_TABLE = {},\r
+               currentID = null,\r
+               currentItem = null,\r
+               ELM_A_ORIGIN = ( function(){\r
+                       var ret = document.createElement( 'a');\r
+                       ret.href = '#';\r
+                       return ret;\r
+               })(),\r
+               ELM_INPUT_TEXT = ( function(){\r
+                       var ret = document.createElement( 'input');\r
+                       ret.type = 'text';\r
+                       return ret;\r
+               })();\r
+               \r
+       var InputTextClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater){\r
+               validater = typeof validater === 'function' ? validater : null;\r
+               \r
+               var elmValue = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'editable-value' )[ 0],\r
+                       value,\r
+                       index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1,\r
+                       instance,\r
+                       focus = false,\r
+                       visible = true,\r
+                       enabled = true,\r
+                       elmA = ELM_A_ORIGIN.cloneNode( true );\r
+               \r
+               if( elmValue === undefined){\r
+                       alert( 'error!');\r
+               }\r
+               value = elmValue.innerHTML;\r
+               elmValue.innerHTML = '';\r
+               elmValue.className += ' editable-text';\r
+               try {\r
+                       elmA.innerHTML = value;\r
+               } catch(e){\r
+                       alert( value + elmA)\r
+               }\r
+               \r
+               elmValue.appendChild( elmA );\r
+               WRAPPER_ELM.onclick = onClick;\r
+               \r
+               function onClick( e){\r
+                       focus = true;\r
+                       start( instance);\r
+                       elmA.style.display = 'none';\r
+                       elmValue.appendChild( ELM_INPUT_TEXT);\r
+                       ELM_INPUT_TEXT.value = value;\r
+                       ELM_INPUT_TEXT.focus();\r
+                       ELM_INPUT_TEXT.select();\r
+                       e && e.preventDefault();\r
+                       return false;\r
+               }\r
+               \r
+               return {\r
+                       init: function(){\r
+                               instance = this;\r
+                               delete this.init;\r
+                       },\r
+                       value: function( _value){\r
+                               if( _value !== undefined){\r
+                                       elmA.innerHTML = _value;\r
+                                       value = _value;\r
+                                       \r
+                                       if( focus === true){\r
+                                               ELM_INPUT_TEXT.value = value;\r
+                                       }\r
+                               }\r
+                               currentItem === instance && this.finish();\r
+                               return value;\r
+                       },\r
+                       start: function(){\r
+                               onClick();\r
+                       },\r
+                       finish: function( keep){\r
+                               var _newValue = ELM_INPUT_TEXT.value,\r
+                                       _validated = validater !== null ? '' + validater( _newValue) : _newValue;\r
+                               _newValue = keep !== true ? _validated : value;\r
+\r
+                               elmValue.removeChild( ELM_INPUT_TEXT);\r
+                               \r
+                               elmA.innerHTML = _newValue;\r
+                               elmA.style.display = 'block';\r
+                               \r
+                               ON_UPDATE_FUNCTION && _newValue !== value && ON_UPDATE_FUNCTION( _newValue, value);\r
+                               finish( instance);\r
+                               value = _newValue;\r
+                               focus = false;\r
+                       },\r
+                       enabled: function(){\r
+                               return enabled;\r
+                       },\r
+                       visible: function( _visible){\r
+                               if( _visible === true){\r
+                                       WRAPPER_ELM.style.display = '';\r
+                                       visible = true;\r
+                               } else\r
+                               if( _visible === false){\r
+                                       WRAPPER_ELM.style.display = 'none';\r
+                                       visible = false;\r
+                               }\r
+                               return visible;\r
+                       },\r
+                       index : index,\r
+                       groupID: GROUP_ID\r
+               }\r
+       }\r
+\r
+       var FileInputClass = function( WRAPPER_ELM, ON_UPDATE_FUNCTION, GROUP_ID, validater, elmFileInput){\r
+               validater = typeof validater === 'function' ? validater : null;\r
+               \r
+               var elmFilePath = pettanr.util.getElementsByClassName( WRAPPER_ELM, 'file-path')[ 0],\r
+                       value,\r
+                       index = GROUP_ID ? FORM_GROUP_TABLE[ GROUP_ID].length : -1,\r
+                       instance,\r
+                       focus = false,\r
+                       visible = true,\r
+                       enabled = true;\r
+               elmFileInput = WRAPPER_ELM.getElementsByTagName('input')[0] || elmFileInput || document.createElement( 'input');\r
+               elmFileInput.type = 'file';\r
+               elmFileInput.style.visivility = 'hidden';\r
+\r
+               WRAPPER_ELM.onclick = onClick;\r
+               elmFileInput.onchenge = onChange;\r
+               \r
+               function onClick( e){\r
+                       focus = true;\r
+                       start( instance);\r
+                       elmFileInput.click();\r
+                       return false;\r
+               }\r
+               \r
+               function onChange(){\r
+                       elmFilePath.innerHTML = elmFileInput.value;\r
+               }\r
+               return {\r
+                       init: function(){\r
+                               instance = this;\r
+                               delete this.init;\r
+                       },\r
+                       start: function(){\r
+                               onClick();\r
+                       },\r
+                       finish: function( keep){\r
+                               focus = false;\r
+                       },\r
+                       enabled: function(){\r
+                               return enabled;\r
+                       },\r
+                       visible: function( _visible){\r
+                               if( _visible === true){\r
+                                       WRAPPER_ELM.style.display = '';\r
+                                       visible = true;\r
+                               } else\r
+                               if( _visible === false){\r
+                                       WRAPPER_ELM.style.display = 'none';\r
+                                       visible = false;\r
+                               }\r
+                               return visible;\r
+                       },\r
+                       index : index,\r
+                       groupID: GROUP_ID\r
+               }\r
+       }\r
+\r
+\r
+       function start( _currentItem){\r
+               currentItem !== _currentItem && currentItem && currentItem.finish();\r
+               currentItem = _currentItem;\r
+       }\r
+       function finish( _currentItem){\r
+               if( currentItem !== _currentItem) return;\r
+               currentItem = null;\r
+       }\r
+\r
+       function tabShift( _groupID, _index, _way){\r
+               var GROUP_ARRAY = FORM_GROUP_TABLE[ _groupID] || [],\r
+                       l = GROUP_ARRAY.length,\r
+                       i = _index +_way;\r
+               if( l < 2) return;\r
+               while( i !== _index){\r
+                       i = i < 0 ?\r
+                               l -1 :\r
+                               i === l ? 0 : i; // 0 < i < l\r
+                       if( GROUP_ARRAY[ i].enabled() === true && GROUP_ARRAY[ i].visible() === true) break;\r
+                       i += _way;\r
+               }\r
+               if( i === _index) return;\r
+               setTimeout( GROUP_ARRAY[ i].start, 0);\r
+       }\r
+\r
+       return {\r
+               init: function(){},\r
+               focus: function(){\r
+                       return currentItem !== null; \r
+               },\r
+               keyEventRellay: function( e){\r
+                       if( e.type === 'keyup') return false;\r
+                       if( currentItem === null) return false;\r
+                       \r
+                       var keyCode = e.keyCode;\r
+                       if( keyCode === 13 || keyCode === 27 || keyCode === 9 || keyCode === 18 || e.altKey === true){ // 13.return 27.esc 9.tab 18.alt\r
+                               var _groupID = currentItem.groupID,\r
+                                       _index = currentItem.index;\r
+                               currentItem.finish( keyCode === 27);\r
+                               keyCode === 9 && _groupID && tabShift( _groupID, _index, e.shiftKey === true ? -1 : 1);\r
+                               keyCode === 13 && _groupID && tabShift( _groupID, _index, 1);\r
+                       }\r
+                       return true;\r
+               },\r
+               createInputText: function( _elm, _onUpdate, _groupID, _validater){\r
+                       if( typeof _groupID === 'string' && !FORM_GROUP_TABLE[ _groupID]){\r
+                               FORM_GROUP_TABLE[ _groupID] = [];\r
+                       }\r
+                       var ret = new InputTextClass( _elm, _onUpdate, _groupID, _validater);\r
+                       ret.init();\r
+                       _groupID && FORM_GROUP_TABLE[ _groupID].push( ret);\r
+                       return ret;\r
+               },\r
+               createFileInput: function( _elm, _onUpdate, _groupID, _validater, _elmFileInput){\r
+                       if( typeof _groupID === 'string' && !FORM_GROUP_TABLE[ _groupID]){\r
+                               FORM_GROUP_TABLE[ _groupID] = [];\r
+                       }\r
+                       var ret = FileInputClass( _elm, _onUpdate, _groupID, _validater, _elmFileInput);\r
+                       ret.init();\r
+                       _groupID && FORM_GROUP_TABLE[ _groupID].push( ret);\r
+                       return ret;\r
+               },\r
+               createCheckBox: function(){\r
+                       \r
+               },\r
+               createRadio: function(){\r
+                       \r
+               },\r
+               createButton: function(){\r
+                       \r
+               },\r
+               createListBox: function(){\r
+                       \r
+               }\r
+       }\r
+})();\r
+\r
+\r
+/* ----------------------------------------\r
+ * Vector Support\r
+ * \r
+ *              __________\r
+ *             /          \\r
+ *            /            \\r
+ *            |,startX,Y    |\r
+ * tailX,Y - <              |\r
+ *            |'endX,Y      |\r
+ *            \            /\r
+ *                \__________/\r
+ * \r
+ * SVG\r
+ * -----------------------\r
+ * ie9, other modern browser\r
+ * \r
+ * XML\r
+ * -----------------------\r
+ * ie5.5-8\r
+ * \r
+ * 内部の角度計算は radian で統一したい。\r
+ * 当初 vectorEnabled = true で一度書いてみる。\r
+ * 駄目なら、代替のイメージのsrcの用意もここで担当。\r
+ * 閲覧と編集両方で使う。\r
+ * \r
+ */\r
+pettanr.balloon = ( function() {\r
+       var MIN_BALLOON_WIDTH = 30,\r
+               MIN_BALLOON_HEIGHT = 30,\r
+               TAIL_WIDTH = 6,\r
+               TAIL_HEIGHT = 10,\r
+               STROKE_WIDTH = 1.2,\r
+               PADDING_TOP = TAIL_HEIGHT,\r
+               PADDING_LEFT = TAIL_HEIGHT,\r
+               ACCURACY = 1, // 有効少数桁        \r
+               IS_VML = pettanr.ua.isIE === true && pettanr.ua.ieVersion < 9,\r
+               ELM_BALLOON_ORIGIN = ( function(){\r
+                       var ret;\r
+                       try {\r
+                               if( IS_VML === true){\r
+                                       ret = document.createElement( 'DIV');\r
+                                       var shape = document.createElement( 'v:shape');\r
+                                       shape.coordorigin = "0,0";\r
+                                       shape.strokecolor = "black";\r
+                                       shape.strokeweight = STROKE_WIDTH;\r
+                                       shape.fillcolor = "white";\r
+                                       ret.appendChild( shape);\r
+                               } else {\r
+                                       var kSVGNS = 'http://www.w3.org/2000/svg';\r
+                                       ret = document.createElementNS( kSVGNS, 'svg');\r
+                                       var path = document.createElementNS( kSVGNS, 'path');\r
+                                       path.setAttribute( 'fill', "white");\r
+                                       path.setAttribute( 'stroke', "black");\r
+                                       path.setAttribute( 'strokeWidth', STROKE_WIDTH);\r
+                                       ret.appendChild( path);\r
+                               }\r
+                               return ret;     \r
+                       } catch( e){\r
+                               return null;\r
+                       }\r
+               })(),\r
+               NUM_BALLOON_IMAGE = 24,\r
+               vectorEnabled = ELM_BALLOON_ORIGIN !== null && pettanr.URL_PARAMS.vector !== false;\r
+       if( IS_VML === true && pettanr.ua.VML === false) vectorEnabled = false;\r
+\r
+       var XBROWSER_BALLOON_CLASS = function( w, h, a){\r
+               var balloonElm = vectorEnabled === true ? ELM_BALLOON_ORIGIN.cloneNode( true) : document.createElement( 'img'), // pettanr.imageに変更\r
+                       path = balloonElm.getElementsByTagName( 'path')[ 0],\r
+                       shape = balloonElm.getElementsByTagName( 'shape')[ 0],\r
+                       cos = Math.cos, sin = Math.sin,\r
+                       abs = Math.abs, pow = Math.pow,\r
+                       round = Math.round,\r
+                       floor = Math.floor,\r
+                       TARGET = TAIL_WIDTH * TAIL_WIDTH,\r
+                       DEG_TO_RAD = Math.PI / 180,\r
+                       l = ',';\r
+               \r
+               draw( a, w, h);\r
+               \r
+               function draw( _a, _w, _h){\r
+                       a = _a !== undefined ? _a : a;\r
+                       w = _w !== undefined ? _w -PADDING_TOP *2 : w;\r
+                       h = _h !== undefined ? _h -PADDING_LEFT *2 : h;\r
+\r
+                       if( vectorEnabled === false){\r
+                               balloonElm.setAttribute( 'src', balloonUrlBuilder( a));\r
+                               return;\r
+                       }\r
+                       \r
+                       var rx = w /2,\r
+                               ry = h /2,\r
+                               tailRad = a * DEG_TO_RAD,\r
+                               tailX = rx +( rx +TAIL_HEIGHT) * cos( tailRad),\r
+                               tailY = ry +( ry +TAIL_HEIGHT) * sin( tailRad),\r
+                               startX, startY, endX, endY;\r
+               /*\r
+                * tailの太さをTAIL_WIDTHに一致させるため、角度を絞りつつ計算\r
+                */\r
+                       var startRad, endRad,\r
+                               _startX, _startY, _endX, _endY,\r
+                               tailDeg = 0, d;\r
+                       \r
+                       for( var i = 45; i > 0.01; i /= 2){\r
+                               d = ( tailDeg +i) /2;\r
+                               startRad = ( a +d) * DEG_TO_RAD;\r
+                               endRad = ( a -d) * DEG_TO_RAD;\r
+                               \r
+                               _startX = rx +cos( startRad) *rx;\r
+                               _startY = ry +sin( startRad) *ry;\r
+                               _endX = rx +cos( endRad) *rx;\r
+                               _endY = ry +sin( endRad) *ry;   //円弧上のY位置=円中心Y+sin(角度×PI÷180)×円半径\r
+                                       \r
+                               if( pow( ( _startX -_endX), 2) + pow( ( _startY -_endY), 2) < TARGET){\r
+                                       tailDeg += i;\r
+                                       startX = _startX;\r
+                                       startY = _startY;\r
+                                       endX = _endX;\r
+                                       endY = _endY;                                           \r
+                               }\r
+                       }\r
+\r
+               /*\r
+                * \r
+                */                     \r
+                       if( IS_VML === true){\r
+                               var _tailX = tailX *10,\r
+                                       _tailY = tailY *10,\r
+                                       __startX = startX *10,\r
+                                       __startY = startY *10,\r
+                                       __endX = endX *10,\r
+                                       __endY = endY *10,\r
+                                       __w = w *10,\r
+                                       __h = h *10;\r
+                               \r
+                               shape.style.width = w +'px';\r
+                               shape.style.height = h +'px';\r
+                               shape.coordsize = [ __w, __h].join( l);\r
+                               shape.path = [\r
+                                       ' ar ', 0, l, 0, l, __w, l, __h, l,\r
+                                       round( __endX), l, round( __endY), l,\r
+                                       round( __startX), l, round( __startY),\r
+                                       ' l ', round( _tailX), l, round( _tailY),\r
+                                       ' x e'\r
+                               ].join( '');\r
+\r
+                               balloonElm.style.marginTop =  _tailY < 0 ? floor( ( 60 +_tailY) /10) : 10;\r
+                               balloonElm.style.marginLeft = _tailX < 0 ? floor( ( 60 +_tailX) /10) : 10;\r
+                       } else {\r
+                               balloonElm.setAttribute( 'width', w +PADDING_LEFT *2);\r
+                               balloonElm.setAttribute( 'height', h +PADDING_TOP *2);\r
+                               path.setAttribute( 'd', [\r
+                                       'M', cround( tailX + PADDING_LEFT), l, cround( tailY +PADDING_TOP),\r
+                                       'L', cround( startX +PADDING_LEFT), l, cround( startY +PADDING_TOP),\r
+                                       'A', rx, l, ry,\r
+                                       '0 1 1',                        // flag\r
+                                       cround( endX +PADDING_LEFT), l, cround( endY +PADDING_TOP),\r
+                                       'z'\r
+                               ].join( ' '));\r
+                       }\r
+                       function cround( v, r){\r
+                               r = r || ACCURACY;\r
+                               return round( v *pow( 10.0, r)) /pow( 10.0, r);\r
+                       }\r
+               }\r
+               \r
+               function balloonUrlBuilder( _a){\r
+                       var d = 360 /NUM_BALLOON_IMAGE;\r
+                       _a += 90 +d /2;\r
+                       return [ 'system_pictures\/_w', _a < 360 -d /2 ? floor( _a /d) : 0, '.gif'].join( '');\r
+               }\r
+               return {\r
+                       elm: balloonElm,\r
+                       resize: draw,\r
+                       angle: function( _a){\r
+                               _a !== undefined && _a !== a &&\r
+                                       vectorEnabled === false ? balloonUrlBuilder( _a) : draw( _a);\r
+                               return a;\r
+                       },\r
+                       type: function( _type){\r
+                               //draw( _a);\r
+                       },\r
+                       getURL: function(){\r
+                               return balloonUrlBuilder( a);\r
+                       },\r
+                       destroy: function(){\r
+                               balloonElm.parentNode && balloonElm.parentNode.removeChild( balloonElm);\r
+                               balloonElm = null;\r
+                               delete this.destroy;\r
+                       }\r
+               }\r
+       };\r
+       \r
+       IS_VML === false && vectorEnabled === true && ( function(){\r
+               var detect = XBROWSER_BALLOON_CLASS.apply( {}, [ 100, 100, 0]),\r
+                       size = pettanr.util.getElementSize( detect.elm);\r
+               vectorEnabled = size.width !== 0 && size.height !== 0;\r
+               detect.destroy();\r
+               detect = size = null;\r
+       })();\r
+\r
+       return {\r
+           createBalloon: function( _w, _h, _a){\r
+               return XBROWSER_BALLOON_CLASS.apply( {}, [ _w, _h, _a]);\r
+           },\r
+               TYPE_NONE:                              0,\r
+               TYPE_SPEACH_BALLOON:    1,\r
+               TYPE_THINKING:                  2,\r
+               TYPE_BOM:                               3,\r
+               TYPE_BLACK_BOX:                 4,\r
+               TYPE_BLUE_BOX:                  5\r
+       }\r
+})();\r
+\r
+/* ----------------------------------------\r
+ *  pettanr.image\r
+ *  \r
+ *   xBackendな画像反転、画像描画機能。\r
+ *   \r
+ *   画像の反転\r
+ *     - css3\r
+ *     - ActiveX (ie)\r
+ *     - VML (ie)\r
+ *     - canvas ??\r
+ *     - flash(lite)\r
+ *     - silverlight\r
+ *     - pettan server\r
+ *   \r
+ *   png画像の表示(アルファpngをサポートしないie6以下のため)\r
+ *     - ActiveX\r
+ *     - VML\r
+ *     - flash(lite)\r
+ *     - silverlight\r
+ *     \r
+ *     -moz-transform:scale( -1, -1);\r
+ */\r
+pettanr.image = ( function(){\r
+       var REG_PNG = /\.png?/i,\r
+               IS_CSS3 = 0,\r
+               IS_VML = 1,\r
+               IS_ACTIVEX = 2,\r
+               IS_CANVAS = 3,\r
+               IS_FLASH = 4,\r
+               IS_SILVERLIGHT = 5,\r
+               IS_SERVER = 6,\r
+               IS_ACTIVEX_SERVER = 7,\r
+               BACKEND = ( function(){\r
+                       if( pettanr.DEBUG === true && pettanr.URL_PARAMS.rimg){\r
+                               var rimg = pettanr.URL_PARAMS.rimg.toLowerCase();\r
+                               if( rimg === 'css3') return IS_CSS3;\r
+                               if( rimg === 'activex') return IS_ACTIVEX;\r
+                               if( rimg === 'vml') return IS_VML;\r
+                       }\r
+                       if( pettanr.ua.isIE === false || pettanr.ua.ieVersion >= 9) return IS_CSS3; // 不十分!\r
+                       if( pettanr.ua.VML === true) return IS_VML;\r
+                       if( pettanr.ua.ACTIVEX === true) return IS_ACTIVEX;\r
+                       if( pettanr.FLASH === true) return IS_FLASH;\r
+                       if( pettanr.SILVERLIGHT === true) return IS_SILVERLIGHT;\r
+                       return IS_SERVER;\r
+               })(),\r
+               BACKEND_WHEN_PNG = ( function(){\r
+                       if( pettanr.ua.isIE === false || pettanr.ua.ieVersion > 6) return BACKEND;\r
+                       if( pettanr.ua.VML === true) return IS_VML;\r
+                       if( pettanr.FLASH === true) return IS_FLASH;\r
+                       if( pettanr.SILVERLIGHT === true) return IS_SILVERLIGHT;\r
+                       if( pettanr.ua.ACTIVEX === true) return IS_ACTIVEX_SERVER;\r
+                       return IS_SERVER;\r
+               })(),\r
+               ReversibleImageClass,\r
+               ReversibleImageClassWithPingfix;\r
+       \r
+       var XBackendReversibleImageClass = ( function(){\r
+               var CLASS_NAME = 'reversible-image-container',\r
+                       CLASS_NAME_LOADING = CLASS_NAME + ' loading',\r
+                       CLASS_NAME_ERROR = CLASS_NAME +' error',\r
+                       RETRY_DELAY = 5000;\r
+                       NUM_RETRY = 3;\r
+               \r
+               var css3Image = function( url, w, h, onLoadCallback){\r
+                       var elmWrap = document.createElement( 'div'),\r
+                               elmImg,\r
+                               loaded = false,\r
+                               retryTimer = null;\r
+                       elmWrap.className = CLASS_NAME_LOADING;\r
+                       pettanr.util.loadImage( url, onLoad, onError, 100, 10000);\r
+                       function onLoad( _url, _actualW, _actualH){\r
+                               if( elmWrap === null) return;\r
+                               elmImg = new Image;\r
+                               /*\r
+                                * createElement 直後に append しないと、ie(ActiveX)で img が正しく表示されない.\r
+                                */\r
+                               elmWrap.appendChild( elmImg);\r
+                               elmImg.setAttribute( 'src', url);\r
+                               elmWrap.className = CLASS_NAME;\r
+                               onLoadCallback && onLoadCallback( _url, _actualW, _actualH);\r
+                               onLoadCallback = null;\r
+                               loaded = true;\r
+                               resize( w, h);\r
+                       }\r
+                       function onError( _url){\r
+                               if( elmWrap === null) return;\r
+                               elmWrap.className = CLASS_NAME_ERROR;\r
+                               retryTimer = setTimeout( function(){\r
+                                       elmWrap.className = CLASS_NAME_LOADING;\r
+                                       pettanr.util.loadImage( url, onLoad, onError, 100, 10000);\r
+                               }, RETRY_DELAY);\r
+                       }\r
+                       function resize( _w, _h){\r
+                               w = _w !== undefined ? _w : w;\r
+                               h = _h !== undefined ? _h : h;\r
+                               if( loaded === false) return;\r
+                               elmImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : '';\r
+                       }\r
+                       return {\r
+                               elm : elmWrap,\r
+                               resize: resize,\r
+                               destroy: function(){\r
+                                       loaded === true && elmWrap.removeChild( elmImg);\r
+                                       retryTimer !== null && clearTimeout( retryTimer);\r
+                                       elmWrap = vmlImg = onLoadCallback = retryTimer = null;\r
+                                       elmWrap = elmImg = onLoadCallback = null;\r
+                                       delete this.destroy;\r
+                               }\r
+                       }\r
+               }\r
+               var activexImage = css3Image;\r
+               var vmlImage = function( url, w, h, onLoadCallback ){\r
+                       var elmWrap = document.createElement( 'div'),\r
+                               vmlImg,\r
+                               loaded = false,\r
+                               retryTimer = null;\r
+                       elmWrap.className = CLASS_NAME_LOADING;\r
+                       pettanr.util.loadImage( url, onLoad, onError, 100, 10000);\r
+                       function onLoad( _url, _actualW, _actualH){\r
+                               if( elmWrap === null) return;\r
+                               elmWrap.className = CLASS_NAME;\r
+                               vmlImg = document.createElement( 'v:image');\r
+                               vmlImg.src = url;\r
+                               loaded = true;\r
+                               resize( w, h);\r
+                               onLoadCallback && onLoadCallback( _url, _actualW, _actualH);\r
+                               onLoadCallback = null;\r
+                       }\r
+                       function onError( _url){\r
+                               if( elmWrap === null) return;\r
+                               elmWrap.className = CLASS_NAME_ERROR;\r
+                               retryTimer = setTimeout( function(){\r
+                                       elmWrap.className = CLASS_NAME_LOADING;\r
+                                       pettanr.util.loadImage( url, onLoad, onError, 100, 10000);\r
+                               }, RETRY_DELAY);\r
+                       }\r
+                       function resize( _w, _h){\r
+                               w = _w !== undefined ? _w : w;\r
+                               h = _h !== undefined ? _h : h;\r
+                               if( loaded !== true) return;\r
+                               vmlImg.style.width = w < 0 ? -w : w +'px';\r
+                               vmlImg.style.height = h < 0 ? -h : h +'px';\r
+                               //if( flipH !== _flipH || flipV !== _flipV){\r
+                                       vmlImg.parentNode === elmWrap && elmWrap.removeChild( vmlImg );\r
+                               //}\r
+                                       vmlImg.className = w < 0 || h < 0 ? ( 'img-flip-' + ( w < 0 && h < 0 ? 'vh' : ( w < 0 ? 'h' : 'v'))) : '';\r
+                                       elmWrap.appendChild( vmlImg);\r
+                       }\r
+                       return {\r
+                               elm : elmWrap,\r
+                               resize: resize,\r
+                               destroy: function(){\r
+                                       loaded === true && elmWrap.removeChild( vmlImg);\r
+                                       retryTimer !== null && clearTimeout( retryTimer);\r
+                                       elmWrap = vmlImg = onLoadCallback = retryTimer = null;\r
+                                       delete this.destroy;\r
+                               }\r
+                       }\r
+               }\r
+               var serverImage = function( url, w, h, onLoadCallback){\r
+                       \r
+               }\r
+               \r
+               return function( url, w, h, onLoadCallback ){\r
+                               var flipH = w < 0,\r
+                                       flipV = h < 0,\r
+                                       onLoadCallbackAsync = onLoadCallback,// ? function(){ setTimeout( onLoadCallback, 0);} : undefined,// 一度読み込んだ画像は即座にonLoadになるため遅延\r
+                                       xBackendImage = ( function( urlIsXDomain ){\r
+                                               if( BACKEND === IS_CSS3) return new css3Image( url, w, h, onLoadCallbackAsync );\r
+                                               if( BACKEND === IS_VML) return new vmlImage( url, w, h, onLoadCallbackAsync );\r
+                                               if( BACKEND === IS_ACTIVEX) return new activexImage( url, w, h, onLoadCallbackAsync );\r
+                                               return new serverImage( url, w, h, onLoadCallbackAsync );\r
+                                       })();\r
+                               return {\r
+                                       elm: xBackendImage.elm,\r
+                                       w: function( _w){\r
+                                               _w !== undefined && xBackendImage.resize( _w, h);\r
+                                               return w;\r
+                                       },\r
+                                       h: function( _h){\r
+                                               _h !== undefined && xBackendImage.resize( w, _h);\r
+                                               return h;\r
+                                       },\r
+                                       resize: xBackendImage.resize,\r
+                                       destroy: function(){\r
+                                               xBackendImage.destroy && xBackendImage.destroy();\r
+                                               xBackendImage = onLoadCallback = onLoadCallbackAsync = null;\r
+                                               delete this.destroy;\r
+                                       }\r
+                               }\r
+                       }\r
+       })();\r
+       return {\r
+               createReversibleImage: function( url, w, h, onLoadCallback){\r
+                       return XBackendReversibleImageClass.apply( {}, [ url, w, h, onLoadCallback]);\r
+               }\r
+       }\r
+})();\r
+\r
+/*\r
+ * bind : 製本
+ */\r
+pettanr.bind = ( function(){\r
+       var BIND_WORKER_ARRAY = [],\r
+               NAMESPACE_CLASSNAME = pettanr.CONST.NS_PETTANR_COMIC + '-',\r
+               RESOURCE_PICTURE_PATH = pettanr.CONST.RESOURCE_PICTURE_PATH,\r
+               ELM_DETECT_WIDTH = ( function(){\r
+                       var ret = document.createElement( 'div');\r
+                       ret.style.cssText = 'width: auto;height: 0;padding: 0;margin: 0;display: block;visibility: hidden;float: none;position: static;';\r
+                       return ret;\r
+               })();\r
+\r
+       /*\r
+        * original\r
+        *   http://d.hatena.ne.jp/uupaa/20090720/1248097177\r
+        */\r
+       var ResizeAgentClass = function( onResizeFunction, opt_elmCheck){\r
+               var     _globalLock = 0,\r
+                       _size = { w: 0, h: 0 };\r
+                       _ie = !!document.all,\r
+                       _quirks = (document.compatMode || "") !== "CSS1Compat",\r
+                       _ieroot = _quirks ? "body" : "documentElement";\r
+                       _root = opt_elmCheck ? opt_elmCheck : ( _ie ? document[_ieroot] : window);\r
+\r
+               function getInnerSize() {\r
+                       return {\r
+                               w: _root.innerWidth  || _root.clientWidth,\r
+                               h: _root.innerHeight || _root.clientHeight\r
+                       };\r
+               }\r
+\r
+               function loop() {\r
+                       if (!_globalLock++) {\r
+                               var size = getInnerSize();\r
+                               if (_size.w !== size.w || _size.h !== size.h) { // resized\r
+                                       _size = size; // update\r
+                                       onResizeFunction( _size);\r
+                               }\r
+                               setTimeout( unlock, 0); // delay unlock\r
+                       }\r
+                       setTimeout(loop, 500);\r
+               }\r
+               function unlock(){\r
+                       _globalLock = 0;\r
+               }\r
+               loop();\r
+       }\r
+       \r
+       \r
+       var ElementBuilder = ( function(){\r
+               var ELM_TITLE_ORIGN = ( function(){\r
+                               \r
+                       })(),\r
+                       ELM_TEXT_ORIGN = ( function(){\r
+                               var _table = document.createElement( 'table'),\r
+                                       _tr = document.createElement( 'tr');\r
+                               _table.appendChild( _tr);\r
+                               _tr.appendChild( document.createElement( 'td'));\r
+                               _table.cellspacing = '0';\r
+                               return _table;\r
+                       })();\r
+               \r
+               function buildComicElement(){\r
+                       \r
+               }\r
+               \r
+               function buildPanelElement( elmTarget, json, noClassnameMode){\r
+                       var _elmPanel = document.createElement( 'div'),\r
+                               _style = {\r
+                                               "border-width":         typeof json.border === 'number' ? json.border + 'px' : 0,\r
+                                               width:                          json.width + 'px',\r
+                                               height:                         json.height + 'px'\r
+                               },\r
+                               _cssText = [],\r
+                               _comicElements = json.panel_elements || [],\r
+                               _comicElement, _elmImgWrap, _rImg, _rPic, _balloon, _elmBalloonWrap, _elmText;\r
+                       if( noClassnameMode === true){\r
+                               \r
+                       } else {\r
+                               _elmPanel.className = NAMESPACE_CLASSNAME + 'panel';\r
+                       }\r
+                       for( var _key in _style){\r
+                               _cssText.push( _key + ':' + _style[ _key]);\r
+                       }\r
+                       _elmPanel.style.cssText = _cssText.join( ';');\r
+                       elmTarget.appendChild( _elmPanel);\r
+                       \r
+                       for( var i=0, l=_comicElements.length; i<l; ++i){\r
+                               _comicElement = _comicElements[ i];\r
+                               if( _comicElement.resource_picture){\r
+                                       _rPic = _comicElement.resource_picture || {};\r
+                                       _rImg = pettanr.image.createReversibleImage(\r
+                                                       [ RESOURCE_PICTURE_PATH, _rPic.id, '.', _rPic.ext].join( ''),\r
+                                                       _comicElement.width, _comicElement.height\r
+                                               );\r
+                                       _elmImgWrap = document.createElement( 'div');\r
+                                       _elmPanel.appendChild( _elmImgWrap);\r
+                                       _elmImgWrap.appendChild( _rImg.elm);\r
+                                       _elmImgWrap.className = NAMESPACE_CLASSNAME + 'image';\r
+                                       _elmImgWrap.style.cssText = [\r
+                                               'width:', Math.abs( _comicElement.width), 'px;',\r
+                                               'height:', Math.abs( _comicElement.height), 'px;',\r
+                                               'left:', _comicElement.x, 'px;',\r
+                                               'top:', _comicElement.y, 'px;',\r
+                                               'z-index:', _comicElement.z, ';'\r
+                                       ].join( '');\r
+                               } else {\r
+                                       _elmBalloonWrap = document.createElement( 'div');\r
+                                       _elmPanel.appendChild( _elmBalloonWrap);\r
+                                       _elmBalloonWrap.className = NAMESPACE_CLASSNAME + 'balloon';\r
+                                       _elmBalloonWrap.style.cssText = [\r
+                                               'width:', _comicElement.width, 'px;',\r
+                                               'height:', _comicElement.height, 'px;',\r
+                                               'left:', _comicElement.x, 'px;',\r
+                                               'top:', _comicElement.y, 'px;',\r
+                                               'z-index:', _comicElement.z, ';'\r
+                                       ].join( '');\r
+\r
+                                       _balloon = pettanr.balloon.createBalloon( _comicElement.width, _comicElement.height, _comicElement.tail);\r
+                                       _elmBalloonWrap.appendChild( _balloon.elm);\r
+                                       \r
+                                       _elmText = ELM_TEXT_ORIGN.cloneNode( true);\r
+                                       _elmBalloonWrap.appendChild( _elmText);\r
+                                       _elmText.className = NAMESPACE_CLASSNAME + 'speach';\r
+                                       _elmText.getElementsByTagName( 'td')[ 0].appendChild( document.createTextNode( 'hello'));\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               return {\r
+                       build: function( elmTarget, json, zoom, noClassnameMode){\r
+                               // clean elmTarget\r
+                               pettanr.util.removeAllChildren( elmTarget);\r
+                               \r
+                               // json is Comic ? Panel ?\r
+                               if( json.panels){\r
+                                       // comic\r
+                                       \r
+                               } else\r
+                               if( json.panel_elements){\r
+                                       // panel\r
+                                       buildPanelElement( elmTarget, json, noClassnameMode);\r
+                               } else {\r
+                                       // invalid json\r
+                               }\r
+                       }\r
+               }\r
+       })();\r
+       \r
+       var BindWorkerClass = function( elmTarget, json, zoomSelfEnabled, noClassnameMode){\r
+               typeof json === 'object' && build( elmTarget, json);\r
+               \r
+               var elmDetectW = ELM_DETECT_WIDTH.cloneNode( false)\r
+               \r
+               if( zoomSelfEnabled === true){\r
+                       elmTarget.parentNode.insertBefore( elmDetectW, elmTarget);\r
+                       new ResizeAgentClass( onResize, elmDetectW);\r
+               }\r
+               function onResize(){\r
+                       \r
+               }\r
+               json && ElementBuilder.build( elmTarget, json, zoomSelfEnabled, noClassnameMode);\r
+               \r
+               return {\r
+                       init: function(){\r
+                               \r
+                       },\r
+                       zoom: function(){\r
+                               \r
+                       },\r
+                       json: function( _json){\r
+                               json = _json;\r
+                               ElementBuilder.build( elmTarget, _json, zoomSelfEnabled, noClassnameMode);\r
+                       },\r
+                       targetElement: function(){\r
+                               \r
+                       },\r
+                       layput: function(){\r
+                               \r
+                       },\r
+                       destroy: function(){\r
+                               \r
+                       }\r
+               }\r
+       }\r
+       \r
+       return {\r
+               createBindWorker: function( elmTarget, opt_COMICJSONorPANELJSON, opt_zoomSelfEnabled, opt_noClassnameMode){\r
+                       var ret = new BindWorkerClass( elmTarget, opt_COMICJSONorPANELJSON, !!opt_zoomSelfEnabled, !!opt_noClassnameMode);\r
+                       BIND_WORKER_ARRAY.push( ret);\r
+                       return ret;\r
+               },\r
+               isBindWorkerInstance: function( _bindWorker){\r
+                       \r
+               }\r
+       }\r
+})();\r
+\r
+var VisualEffect = ( function(){\r
+       \r
+       var ANIMATION_TICKET_ARRAY = [],\r
+               fpms = 50,\r
+               TIMER = null,\r
+               FILTER = 'filter',\r
+               OPACITY = 'opacity',\r
+               REG_ALPHA = /alpha\([^)]*\)/i,\r
+               CORON = ':',\r
+               EMPTY = '',\r
+               SEMICORON = ';';\r
+       \r
+       function startAnimation( _elm, _cssObject, _onComplete, _onEnterFrame, _numFrames){\r
+               var _ticket;\r
+               for( var i=0, l=ANIMATION_TICKET_ARRAY.length; i<l; ++i){\r
+                       _ticket = ANIMATION_TICKET_ARRAY[ i];\r
+                       if( _ticket.elm === _elm) {\r
+                               _ticket.destroy();\r
+                               break;\r
+                       }\r
+               }\r
+               //  coputedStyle と _cssObject を比較して , 一致及び非数は削除しつつ コピー\r
+               //  filter opacity の追加 REG_ALPHA.test( _value ) ? _value.replace( REG_ALPHA, opacity ) : _value + " " + opacity\r
+               /*\r
+                * cssObject をまわす\r
+                * 非数は削除\r
+                * cssText と一致も削除\r
+                * coputedStyle と一致も削除\r
+                * updateTraget ととして記録\r
+                * 初期値を cssObject としてセット\r
+                * cssTest にセット zoom もセット 
+                */\r
+               \r
+               //\r
+               /*\r
+                       var style = elem.style,\r
+                               currentStyle = elem.currentStyle,\r
+                               opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",\r
+                               filter = currentStyle && currentStyle.filter || style.filter || "";\r
+\r
+                       // IE has trouble with opacity if it does not have layout\r
+                       // Force it by setting the zoom level\r
+                       style.zoom = 1;
+                */\r
+               \r
+               var _currentParameters = [],\r
+                       _offsetParameters = [],\r
+                       _endParameters = [],\r
+                       _targetAttributes = [];\r
+               \r
+               ANIMATION_TICKET_ARRAY.push( new AnimationTaskClass(\r
+                       _elm,\r
+                       _currentParameters, _offsetParameters, _endParameters, _targetAttributes,\r
+                       typeof _onComplete === 'function' ? _onComplete : null,\r
+                       typeof _onEnterFrame === 'function' ? _onEnterFrame : null,\r
+                       _numFrames\r
+               ));\r
+               \r
+               if( TIMER === null){\r
+                       TIMER = window.setInterval( onEnterFrame, fpms);\r
+               }\r
+       }\r
+       function onEnterFrame(){\r
+               var _ticket,\r
+                       i = 0;\r
+               while( i<ANIMATION_TICKET_ARRAY.length){\r
+                       _ticket = ANIMATION_TICKET_ARRAY[ i];\r
+                       if( _ticket.onEnterFrame() === true){\r
+                               _ticket.destroy();\r
+                               ANIMATION_TICKET_ARRAY.splice( i, 1);\r
+                       } else {\r
+                               ++i;\r
+                       }\r
+               }\r
+               if( ANIMATION_TICKET_ARRAY.length === 0){\r
+                       window.clearInterval( TIMER);\r
+                       TIMER = null;\r
+               }\r
+       }\r
+       function updateCss( _elm, _updateParameters, _targetAttributes, _numAttributes){\r
+               if( _numAttributes > 1){\r
+                       var _cssTexts = _elm.style.cssText.split( ';'), _css,\r
+                               _separate,\r
+                               _cssObject = {}, _target, _value, _number, _px,\r
+                               j;\r
+                       for(var i=0, l=_cssTexts.length; i<l; ++i){\r
+                               _css = _cssTexts[ i];\r
+                               _separate = _css.indexOf( ':');\r
+                               if( _separate >= 3){\r
+                                       _target = _css.substr( 0, _separate +1);\r
+                                       _value = _css.substr( _separate +1);\r
+                                       /*\r
+                                        * ie filter
+                                        */\r
+                                       if( _target === FILTER){\r
+                                               for( j=0; j<_numAttributes; ++j){\r
+                                                       if( _targetAttributes[ j] === OPACITY){\r
+                                                               _cssTexts[ i] = [\r
+                                                                               _target, ':',\r
+                                                                               _value.replace( REG_ALPHA, "alpha(opacity=" + _updateParameters[ j] * 100 + ")")\r
+                                                                       ].join( '');\r
+                                                               break;\r
+                                                       }\r
+                                               }\r
+                                       /*\r
+                                        * other
+                                        */\r
+                                       } else {\r
+                                               _number = '' + parseFloat( _value);\r
+                                               _px = _value.indexOf( _number);\r
+                                               _px = _px > 0 ? _value.substr( _px + _number.length) : '';\r
+                                               for( j=0; j<_numAttributes; ++j){\r
+                                                       if( _targetAttributes[ j] === _target){\r
+                                                               _cssTexts[ i] = [ _target, ':', _updateParameters[ j], _px].join( '');\r
+                                                               break;\r
+                                                       }\r
+                                               }                                               \r
+                                       }\r
+                               }\r
+                       }\r
+                       _elm.style.cssText = _cssTexts.join( ';');\r
+                       return; \r
+               }\r
+               /*\r
+                * 一度に update する Attributes が少ない場合、cssText は使用しない.
+                */\r
+       }\r
+       \r
+       var AnimationTaskClass = function( ELM, currentParameters, offsetParameters, endParameters, targetAttributes, onComplete, onEnterFrame, numFrames){\r
+               var l = targetAttributes.length;\r
+               return {\r
+                       elm:    ELM,\r
+                       onEnterFrame: function(){\r
+                               var _updateCss = {}, i;\r
+                               if( numFrames === 1){\r
+                                       for( i=0; i<l; ++i){\r
+                                               _updateCss[ targetAttributes[ i]] = endParameters[ i];\r
+                                               ++i;\r
+                                       }\r
+                                       updateCss( ELM, currentParameters, targetAttributes, l);\r
+                                       onComplete !== null && onComplete();\r
+                               } else {\r
+                                       for( i=0; i<l; ++i){\r
+                                               _updateCss[ targetAttributes[ i]] = currentParameters[ i] = Math.floor( currentParameters[ i] + offsetParameters[ i]);\r
+                                               ++i;\r
+                                       }\r
+                                       updateCss( ELM, currentParameters, targetAttributes, l);\r
+                                       onEnterFrame !== null && onEnterFrame( _updateCss);\r
+                               }\r
+                               --numFrames;\r
+                               return numFrames === 0;\r
+                       },\r
+                       destroy: function(){\r
+                               ELM = onComplete = onEnterFrame = null;\r
+                       }\r
+               }\r
+       }\r
+       \r
+       var VisualEffectClass = function( ELM){\r
+               var isHtmlElement;\r
+               \r
+               function registerAnime( _cssObject, _onComplete, _onEnterFrame, _time){\r
+                       var _numFrames = Math.floor( _time / fpms);\r
+                       startAnimation( ELM, _cssObject, _onComplete, _onEnterFrame, _numFrames);\r
+               }\r
+               function startFadeIn(){\r
+                       \r
+               }\r
+               function startFadeOut(){\r
+                       \r
+               }\r
+               function update( _x, _y, _w, _h){\r
+                       var _cssText = ELM.style.cssText;\r
+                       \r
+               }\r
+               \r
+               this.anime = registerAnime;\r
+               this.fadeIn = startFadeIn;\r
+               this.fadeOut = startFadeOut;\r
+               this.update = update;\r
+       }\r
+       \r
+       return {\r
+               createVisualEffect: function( _elm){\r
+                       return new VisualEffectClass( _elm);\r
+               },\r
+               isInstanceOfVisualEffect: function( _instance){\r
+                       return _instance instanceof VisualEffectClass;\r
+               }\r
+       }\r
+})();\r
+\r
+\r
+\r
+/*\r
+ *  Google Analytics\r
+ */\r
+\r
+if( pettanr.LOCAL === false){\r
+       var _gaq = _gaq || [];\r
+       _gaq.push(['_setAccount', 'UA-28023955-1']);\r
+       _gaq.push(['_trackPageview']);\r
+       \r
+       (function() {\r
+               var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\r
+               ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\r
+               var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\r
+       })();   \r
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/system.js b/app/assets/javascripts/system.js
new file mode 100644 (file)
index 0000000..22c8c97
--- /dev/null
@@ -0,0 +1,2061 @@
+/*
+ * pettanR system.js
+ *   version 0.4.20
+ *   
+ * author:
+ *   itozyun
+ * licence:
+ *   3-clause BSD
+ */
+
+
+pettanr.log = ( function(){
+       return {
+               init: function(){}
+       }
+})();
+
+pettanr.io = ( function(){
+       
+       return {
+               init: function(){}
+       }
+})();
+
+/*
+ * 画像一覧は
+ *     お気に入り画像一覧 > tag:ペン次郎 > ペン次郎:笑う
+ *  最近アップロードされた画像 > images
+ *  最近使われた画像 > images
+ *  キャラクター画像庫 > アニマル系 > tag:ペン次郎 > ペン次郎:笑う
+ *  風景画像庫 >
+ *  効果画像庫 >
+ *  アイテム画像庫 >
+ *  
+ * 画像一覧を読み込むタイミング
+ */
+pettanr.file = ( function(){
+       var FILE_TYPE_IS_FOLDER = 1,
+               numFileType = FILE_TYPE_IS_FOLDER,
+               FILEDATA_RESITER = [],                  // store all of fileData( json object )
+               FILEDATA_ACCESS = [],                   // file operations for Kernel only ! hide from Out of pettanr.file
+               FILE_OBJECT_POOL = [],
+               EVENT_LISTENER_REGISTER = [],
+               TREE_ARRAY = [],
+               TREE_ACCESS_ARRAY = [];
+       
+       var REQUEST_CONTROLER = ( function(){
+               var REQUEST_TICKET_RESISTER = [],
+                       DATA_TYPE_ARRAY = 'json,xml,html,text'.split( ','),
+                       DATA_IS_JSON = 0,
+                       DATA_IS_XML = 1,
+                       DATA_IS_HTML = 2,
+                       DATA_IS_TEXT = 3,
+                       numError = 0;
+               
+               var RequestTicketClass = function( _type, _data, _url, _onLoad, _onError){
+                       this.type = DATA_TYPE_ARRAY[ _type];
+                       this.data = _data;
+                       this.url = _url;
+                       this.onLoad = _onLoad;
+                       this.onError = _onError;
+                       this.state = 0;
+               };
+               
+               function request(){
+                       if( REQUEST_TICKET_RESISTER.length === 0) return;
+                       var _ticket = REQUEST_TICKET_RESISTER.shift();
+                       $.ajax({
+                               url:            _ticket.url,
+                               dataType:       _ticket.type,
+                               success:        function( _data){
+                                       _ticket.onLoad( _ticket.data, _data);
+                               },
+                               error:          function(){
+                                       ++numError;
+                                       _ticket.onError( _ticket.data);
+                               }
+                       });
+               }
+               
+               return {
+                       getNumTask: function(){
+                               return REQUEST_TICKET_RESISTER.length;
+                       },
+                       getNumError: function(){
+                               return numError;
+                       },
+                       getJson: function( _data, _url, _onLoad, _onError){
+                               REQUEST_TICKET_RESISTER.push( new RequestTicketClass( DATA_IS_JSON, _data, _url, _onLoad, _onError));
+                               request();
+                       }
+               }
+       })();
+
+
+
+       var FILE_CONTROLER = {
+               createTree: function( _rootFileData){
+                       var _tree = new TreeClass( _rootFileData);
+                       _tree.init();
+                       TREE_ARRAY.push( _tree);
+                       return _tree;
+               },
+               getFileUID: function( FILEDATAorFILE ){
+                       if( FILEDATAorFILE instanceof FileClass ){
+                               return FILEDATAorFILE.getUID();
+                       }
+                       
+                       var uid = pettanr.util.getIndex( FILEDATA_RESITER, FILEDATAorFILE );
+                       if( uid === -1){
+                               uid = FILEDATA_RESITER.length;
+                               FILEDATA_RESITER.push( FILEDATAorFILE );
+                       }
+                       return uid;
+               },
+               getFileDataAccess: function( UIDorFILEorFILEDATA){
+                       var _uid, _data, _access;
+                       
+                       if( typeof UIDorFILEorFILEDATA === 'number'){
+                               _data = FILEDATA_RESITER[ UIDorFILEorFILEDATA] || null;
+                       } else
+                       if( UIDorFILEorFILEDATA instanceof FileClass){
+                               _uid = UIDorFILEorFILEDATA.getUID();
+                               _data = FILEDATA_RESITER[ _uid ] || null;
+                       } else {
+                               _data = UIDorFILEorFILEDATA || null;
+                       }
+                       
+                       if( _data === null || typeof _data !== 'object') return null;
+                       for( var i=0, l = FILEDATA_ACCESS.length; i<l; ++i){
+                               _access = FILEDATA_ACCESS[ i];
+                               if( _access.DATA === _data) return _access;
+                       }
+                       return null;
+               },      
+               getFileData: function( UIDorFILEorFILEDATA){
+                       var _access = FILE_CONTROLER.getFileDataAccess( UIDorFILEorFILEDATA);
+                       return _access !== null ? _access.DATA : null;
+               },
+               getChildren: function( UIDorFILEorFILEDATA){
+                       var _data = FILE_CONTROLER.getFileData( UIDorFILEorFILEDATA);
+                       return _data !== null ? _data.children || null : null;
+               },
+               getDriver: function( _file){
+                       var _data = FILE_CONTROLER.getFileData( _file);
+                       return _data !== null && _data.driver ? _data.driver : FileDriverBase;
+               },
+               getUpdateFlag: function( _file, _bit){
+                       var _driver = FILE_CONTROLER.getDriver( _file ),
+                               _policy;
+                       if( typeof _driver.getUpdatePolicy === 'function'){
+                               _policy = _driver.getUpdatePolicy( _file );
+                               
+                       }
+                       if( typeof _policy !== 'number') {
+                               _policy = FileDriverBase.getUpdatePolicy( _file )
+                       }
+                       return _policy % ( _bit * 2) >= _bit;
+               },
+               move: function( _prentUID, _targetfile, _newFolder, _newIndex, _opt_callback){
+                       var _parentData = FILE_CONTROLER.getFileDataAccess( _prentUID),
+                               _parentType = _parentData.TYPE,
+                               _targetData = FILE_CONTROLER.getFileDataAccess( _targetfile),
+                               _targetType = _targetData.TYPE;
+               },
+               replace: function( _uid, _file, _newIndex){
+                       
+               },
+               addEventListener: function( FILEorNULL, _eventType, _callback){
+                       var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL;
+                       EVENT_LISTENER_REGISTER.push( new FileEventTicketClass( _uid, _eventType, _callback));
+               },
+               removeEventListener: function( FILEorNULL, _eventType, _callback){
+                       var _uid = FILEorNULL instanceof FileClass ? FILEorNULL.getUID() : FILEorNULL,
+                               _ticket;
+                       for(var i=0, l = EVENT_LISTENER_REGISTER.length; i<l; ++i){
+                               _ticket = EVENT_LISTENER_REGISTER[i];
+                               if( _ticket.fileUID === _uid && _ticket.eventType === _eventType && _ticket.callBack === _callback){
+                                       EVENT_LISTENER_REGISTER.splice( i, 1);
+                                       _ticket.destroy();
+                               }
+                       }
+               },
+               getTreeAccess: function(){
+                       
+               },
+               fileEventRellay: function( _uid, _event ){
+                       var _fileAccess = FILE_CONTROLER.getFileDataAccess( _uid );
+                       if( _fileAccess === null ) return;
+                       var _treeUID =  _fileAccess.TREE.getUID(),
+                               _treeAccess = TREE_ACCESS_ARRAY[ _treeUID ],
+                               _data = _fileAccess.DATA,
+                               _tree;
+                       if( !_treeAccess ) return;
+                       _treeAccess.dispatchFileEvent( _event );
+                       for( var i=0, l = TREE_ARRAY.length; i<l; ++i){
+                               if( i !== _treeUID ){
+                                       _tree = TREE_ARRAY[ i ];
+                                       if( FILE_CONTROLER.getFileData( _tree.getCurrentFile() ) === _data ){
+                                               _treeAccess = TREE_ACCESS_ARRAY[ _tree.getUID() ];
+                                               _treeAccess && _treeAccess.dispatchFileEvent( _event );
+                                       }
+                               }
+                       }
+               }
+       }
+
+       var TreeClass = function( rootFileData ){
+               var PARENT_FILE_RESITER = [],
+                       ACCESS = {
+                               dispatchFileEvent:      dispatchFileEvent
+                       },
+                       EVENT_LISTENER_ARRAY = [],
+                       rootFile,
+                       currentFile,
+                       instance;
+                       
+               TREE_ACCESS_ARRAY.push( ACCESS );
+               
+               function dispatchFileEvent( e ){
+                       var _eventType = e.eventType,
+                               _targetFile = e.targetFile,
+                               _uid = _targetFile.getUID(),
+                               _ticket, _type, _callback;
+                       for(var i=0, l = EVENT_LISTENER_REGISTER.length; i<l; ++i ){
+                               _ticket = EVENT_LISTENER_REGISTER[ i ];
+                               _type = _ticket.eventType;
+                               _callback = _ticket.callBack;
+                               if( _eventType === _type && _uid === _ticket.fileUID ){
+                                       _callback( _eventType, _targetFile, e.key, e.value );
+                               } else
+                               if( _type === pettanr.file.TREE_EVENT.UPDATE && _eventType === pettanr.file.FILE_EVENT.GET_SEQENTIAL_FILES ){
+                                       _callback( _eventType, _targetFile );
+                               }
+                       }
+               }
+               
+               return {
+                       init: function(){
+                               instance = this;
+                               currentFile = rootFile = new FileClass( instance, null, rootFileData );
+                               // rootFile.init();
+                               currentFile.getSeqentialFiles();
+                               delete this.init;
+                       },
+                       getUID: function(){
+                               return pettanr.util.getIndex( TREE_ACCESS_ARRAY, ACCESS );
+                       },
+                       getRootFile : function(){
+                               return rootFile;
+                       },
+                       getCurrentFile: function(){
+                               return currentFile;
+                       },
+                       hierarchy: function(){
+                               return PARENT_FILE_RESITER.length;
+                       },
+                       getParentFileAt: function( _index){
+                               var l = PARENT_FILE_RESITER.length;
+                               if( typeof _index !== 'number' || _index < 0 || _index >= l) return null;
+                               return PARENT_FILE_RESITER[ l -1 -_index];
+                       },
+                       down: function( _index){
+                               if( typeof _index !== 'number' || _index < 0 || _index >= currentFile.getChildFileLength()) return;
+                               PARENT_FILE_RESITER.unshift( currentFile );
+                               currentFile = currentFile.getChildFileByIndex( _index );
+                               currentFile.getSeqentialFiles();
+                               return currentFile;
+                       },
+                       up: function( _index){
+                               var l = PARENT_FILE_RESITER.length;
+                               if( l === 0) return null;
+                               
+                               if( currentFile ){
+                                       var _currentFile = currentFile;
+                                       currentFile = null;
+                                       _currentFile.destroy();
+                               }
+                               if( typeof _index === 'number'){
+                                       if( _index >= l) return null;
+                                       currentFile = this.getParentFileAt( _index );
+                                       PARENT_FILE_RESITER.splice( 0, l -_index);
+                               } else {
+                                       currentFile = PARENT_FILE_RESITER.shift();
+                               }
+                               currentFile.getSeqentialFiles();
+                               return currentFile;     
+                       },
+                       addTreeEventListener: function( _eventType, _callback){
+                               FILE_CONTROLER.addEventListener( null, _eventType, _callback);
+                       },
+                       removeTreeEventListener: function( _eventType, _callback){
+                               FILE_CONTROLER.removeEventListener( null, _eventType, _callback);
+                       },
+                       destroy: function(){
+                               FILE_CONTROLER.destroyTree( instance.getUID() );
+                               // removeEvent
+                               var _currentFile = currentFile;
+                               currentFile = rootFile = rootFileData = null;
+                               // currentFile, rootFile を null にしないと .File.destroy() ができない.
+                               _currentFile.destroy();
+                               while( PARENT_FILE_RESITER.length > 0 ){
+                                       _currentFile = PARENT_FILE_RESITER.shift();
+                                       _currentFile.destroy();
+                               }
+                               instance = null;
+                       }
+               }
+       };
+
+       var FileEventTicketClass = function( UID, _eventType, _callback){
+               this.fileUID = UID;
+               this.eventType = _eventType;
+               this.callBack = _callback;
+               this.destroy = function(){
+                       this.callBack = _callback = null;
+               }
+       }
+       
+       var FileEventClass = function( eventType, file, key, value){
+               this.eventType = eventType;
+               this.targetFile = file;
+               this.updatedAttribute = key;
+               this.updatedValue = value;
+       }
+
+/*
+ * fileのdataはobjectで保持している。
+ * pettanr.file.の外からファイルをみるときは、FileClassを通して操作する。
+ * fileの変更、それに付随して追加されたイベントは、TreeClassで管理される。
+ * treeがdestryされると、fileのイベントリスナーも全て削除される。
+ * 他の tree も data の共通する currentFile に対してのみは、file の変更イベントを受け取って流す.
+ * 
+ * parentData のほうがいい!
+ */
+       
+       var FileClass = function( tree, parentData, data ){
+               var uid = FILE_CONTROLER.getFileUID( data ),
+                       instance = this;
+               
+               FILEDATA_ACCESS.push(
+                       {
+                               TREE:                           tree,
+                               parentData:                     parentData,
+                               DATA:                           data,
+                               dispatchFileEvent:      dispatchEvent
+                       }
+               );
+               
+               tree = parentData = data = null;
+               
+               function dispatchEvent( e ){
+                       FILE_CONTROLER.fileEventRellay( uid, e );
+               }
+               this.getUID = function(){
+                       return uid;
+               }
+       };
+       
+       FileClass.prototype = {
+               isChildFile: function( _FILEorFILEDATA){
+                       return this.getChildFileIndex( _FILEorFILEDATA) !== -1;
+               },
+               getSeqentialFiles: function(){
+                       var _driver = FILE_CONTROLER.getDriver( this );
+                       if( _driver !== null && typeof _driver.getSeqentialFiles === 'function' ){
+                               _driver.getSeqentialFiles( this );
+                       }
+               },
+               addEventListener: function( _eventType, _callback ){
+                       FILE_CONTROLER.addEventListener( this, _eventType, _callback );
+               },
+               removeEventListener: function( _eventType, _callback ){
+                       FILE_CONTROLER.removeEventListener( this, _eventType, _callback );
+               },
+               getChildFileLength: function(){
+                       var children = FILE_CONTROLER.getChildren( this );
+                       return Type.isArray( children ) === true ? children.length : -1;
+               },
+               getChildFileIndex: function( _FILEorFILEDATA ){
+                       var children = FILE_CONTROLER.getChildren( this);
+                       if( Type.isArray( children ) === false ) return -1;
+                       var l = children.length,
+                               _fileData = FILE_CONTROLER.getFileData( _FILEorFILEDATA );
+                       if( _fileData === null ) return -1;
+                       for( var i=0; i<l; ++i ){
+                               if( children[ i ] === _fileData ) return i;
+                       }
+                       return -1;
+               },
+               getName: function(){
+                       var driver = FILE_CONTROLER.getDriver( this );
+                       if( typeof driver.getName === 'function'){
+                               return driver.getName( this );
+                       }
+                       return FileDriverBase.getName( this);
+               },
+               getThumbnail: function(){
+                       var driver = FILE_CONTROLER.getDriver( this);
+                       if( typeof driver.getThumbnail === 'function'){
+                               return driver.getThumbnail( this);
+                       }
+                       return FileDriverBase.getThumbnail( this);
+               },
+               getType: function(){
+                       var _data = FILE_CONTROLER.getFileData( this);
+                       return typeof _data.type === 'number' ? _data.type : pettanr.file.FILE_TYPE.UNKNOWN;
+               },
+               getState: function(){
+                       var _data = FILE_CONTROLER.getFileData( this);
+                       return typeof _data.state === 'number' ? _data.state : pettanr.file.FILE_STATE.OK;
+               },
+               getSummary: function(){
+                       var driver = FILE_CONTROLER.getDriver( this );
+                       if( typeof driver.getSummary === 'function'){
+                               return driver.getSummary( this );
+                       }
+                       return FileDriverBase.getSummary( this);
+               },
+               isWritable: function(){
+                       return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.WRITE );
+               },
+               isSortable: function(){
+                       return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.SORT );
+               },              
+               isCreatable: function(){
+                       return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.CREATE );
+               },
+               isRenamable: function(){
+                       return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.RENAME );
+               },
+               isDeletable: function(){
+                       return FILE_CONTROLER.getUpdateFlag( this, pettanr.file.FILE_UPDATE_POLICY.DELETE );
+               },
+               read: function(){
+                       // simpleDeepCopy
+                       var driver = FILE_CONTROLER.getDriver( this );
+                       if( typeof driver.read === 'function'){
+                               return driver.read( this );
+                       }
+                       return FileDriverBase.read( this );
+               },
+               write: function( _newData, _onUpdateFunction ){
+                       var driver = FILE_CONTROLER.getDriver( this );
+                       if( typeof driver.write === 'function'){
+                               return driver.write( this, _newData, _onUpdateFunction );
+                       }
+                       return FileDriverBase.write( this, _newData, _onUpdateFunction );
+               },
+               viewerApplicationList: function(){
+                       var driver = FILE_CONTROLER.getDriver( this );
+                       if( typeof driver.viewerApplicationList === 'function'){
+                               return driver.viewerApplicationList( this );
+                       }
+                       return FileDriverBase.viewerApplicationList( this );
+               },
+               editorApplicationList: function(){
+                       var driver = FILE_CONTROLER.getDriver( this );
+                       if( typeof driver.editorApplicationList === 'function'){
+                               return driver.editorApplicationList( this );
+                       }
+                       return FileDriverBase.viwerApps( this );
+               },
+               create: function(){
+                       
+               },
+               sort: function(){
+                       
+               },
+               onCopy: function(){
+                       
+               },
+               onDelete: function(){
+                       
+               },
+               getChildFileByIndex: function( _index ){
+                       var _access = FILE_CONTROLER.getFileDataAccess( this ),
+                               _children = FILE_CONTROLER.getChildren( this );
+                       if( typeof _index !== 'number' || _index < 0 || Type.isArray( _children ) === false || _index >= _children.length) return null;
+                       var _file = new FileClass( _access.TREE, _access.data, _children[ _index ]);
+                       // _file.init();
+                       return _file;
+               },
+               move: function( _newFolder, _newIndex, opt_callback ){
+                       var _access = FILE_CONTROLER.getFileDataAccess( this );
+                       _access.TREE.move( _access.parentData, this.getUID(), _newFolder, _newIndex, opt_callback );
+               },
+               replace: function( _newIndex, opt_callback ){
+                       var _access = FILE_CONTROLER.getFileDataAccess( this );
+                       _access.TREE.replace( _access.parentData, this.getUID(), _newIndex, opt_callback);
+               },
+               /**
+                * サーチ
+                * 探しているファイルの属性と値を指定.一致する child の index を配列で返す.
+                */
+               search: function( obj, rule ){
+                       var _children = FILE_CONTROLER.getChildren( this ),
+                               _child,
+                               ret = [], k, c;
+                       for( var i=0, l=_children.length; i<l; ++i ){
+                               _child = _children[ i ];
+                               c = true;
+                               for( k in obj ){
+                                       if( obj[ k ] !== _child[ k ] ){
+                                               c = false;
+                                               break;
+                                       }
+                               }
+                               c === true && ret.push( i );
+                       }
+                       return ret;
+               },
+               destroy: function(){
+                       var _access = FILE_CONTROLER.getFileDataAccess( this );
+                       var TREE = _access.TREE;
+                       if( TREE.getCurrentFile() === this ) return;
+                       if( TREE.getRootFile() === this ) return;
+                       for( var i=0, l = TREE.hierarchy(); i<l; ++i ){
+                               if( TREE.getParentFileAt( i ) === this ){
+                                       return;
+                               }
+                       }
+                       var _index = pettanr.util.getIndex( FILEDATA_ACCESS, _access );
+                       if( _index === -1 || _access === null ) return;
+                       // event の 削除
+                       FILEDATA_ACCESS.splice( _index, 1 );
+                       delete _access.DATA;
+                       delete _access.TREE;
+                       delete _access.parentData;
+                       delete _access.dispatchFileEvent;
+               }
+       }
+
+       /*
+        * FileDriverBase
+        */
+       var FileDriverBase = {
+               getSeqentialFiles: function( _file){
+               },
+               getName: function( _file){
+                       var _data = FILE_CONTROLER.getFileData( _file);
+                       return _data.name || 'No Name';
+               },
+               getThumbnail: function( _file){
+                       var _data = FILE_CONTROLER.getFileData( _file),
+                               _type = _data.type,
+                               _className = '';
+                       if( _type === pettanr.file.FILE_TYPE.FOLDER){
+                               _className = 'folder';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.IMAGE){
+                               
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.TEXT){
+                               
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.HTML){
+                               
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.CSV){
+                               
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.JSON){
+                               
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.XML){
+                               
+                       }
+                       return {
+                               image:          null,
+                               className:      ' file-type-' + _className
+                       }
+               },
+               getSummary: function( _file ){
+                       var _data = FILE_CONTROLER.getFileData( _file ),
+                               _type = _data.type;
+                       if( _type === pettanr.file.FILE_TYPE.FOLDER){
+                               return 'folder';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.IMAGE){
+                               return 'image file';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.TEXT){
+                               return 'text file';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.HTML){
+                               return 'html document file';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.CSV){
+                               return 'csv daat file';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.JSON){
+                               return 'json data file';
+                       } else
+                       if( _type === pettanr.file.FILE_TYPE.XML){
+                               return 'xml data file';
+                       }
+                       return '';
+               },
+               getUpdatePolicy: function( _file ){
+                       // debug用 全てのメニューを許可
+                       return pettanr.file.FILE_UPDATE_POLICY.DSRWC;
+               },
+               read: function( _file ){
+                       var data = FILE_CONTROLER.getFileData( _file ),
+                               protects = pettanr.file.FILE_DATA_PROPERTY_RESERVED;
+                       
+                       function clone( src ) {
+                               var ret;
+                               if( Type.isArray(src) === true ){
+                                       ret = [];
+                               } else
+                               if( Type.isObject(src) === true ){
+                                       ret = {};
+                               } else
+                               if( Type.isNumber(src) === true || Type.isString(src) === true || Type.isBoolean( src ) === true ){
+                                       return src;
+                               } else {
+                                       return null;
+                               }
+                               for( var key in src ){
+                                       if( pettanr.util.getIndex( protects, key ) === -1 ){
+                                               //alert( key )
+                                               ret[ key ] = clone( src[ key ]);
+                                       }
+                               }
+                               return ret;
+                       };
+                               
+                       return clone( data );
+               },
+               write: function( _file, _newData, _onUpdateFunction ){
+                       var _data = FILE_CONTROLER.getFileData( _file ),
+                               _type = _data.type;
+                       return false;
+               },
+               viewerApplicationList: function(){
+                       return [];
+               },
+               editorApplicationList: function(){
+                       return [];
+               },
+               onCreate: function(){
+                       
+               },
+               onSort: function(){
+                       
+               },
+               onCopy: function(){
+                       
+               },
+               onDelete: function(){
+                       
+               }
+       }
+
+       var ROOT_FILEDATA = {
+                       name:           'system root',
+                       type:           FILE_TYPE_IS_FOLDER,
+                       children:       []
+               },
+               SYSTEM_TREE = FILE_CONTROLER.createTree( ROOT_FILEDATA),
+               ROOT_FILE = SYSTEM_TREE.getRootFile();
+       
+       function createFolderUnderRoot( _fileData){
+               ROOT_FILEDATA.children.push( _fileData);
+               FILE_CONTROLER.getFileDataAccess( ROOT_FILE)
+                       .dispatchFileEvent( new FileEventClass( pettanr.file.FILE_EVENT.GET_SEQENTIAL_FILES, ROOT_FILE, 'children', null));
+       }
+       function createFileEvent( _eventType, _file, _key, _value){
+               return new FileEventClass( _eventType, _file, _key, _value);
+       }
+       function createFileTypeID(){
+               return ++numFileType;
+       }
+       
+       return {
+               init: function(){
+                       //REQUEST_CONTROLER.init();
+                       //FILE_CONTROLER.init();
+                       delete pettanr.file.init;
+               },
+               registerDriver: function( _driver ){
+                       _driver.prototype = FileDriverBase;
+                       /*
+                        * File API
+                        */
+                       return {
+                               createFolderUnderRoot:  createFolderUnderRoot,
+                               getFileDataAccess:              FILE_CONTROLER.getFileDataAccess,
+                               getFileData:                    FILE_CONTROLER.getFileData,
+                               getJson:                                REQUEST_CONTROLER.getJson,
+                               createFileEvent:                createFileEvent,
+                               createFileTypeID:               createFileTypeID
+                       }
+               },
+               createTree: function( _rootFile){
+                       return FILE_CONTROLER.createTree( _rootFile);
+               },
+               isTreeInstance: function( _tree){
+                       return _tree instanceof TreeClass;
+               },
+               isFileInstance: function( _file){
+                       return _file instanceof FileClass;
+               },
+               FILE_TYPE: {
+                       UNKNOWN:        0,
+                       FOLDER:         FILE_TYPE_IS_FOLDER,
+                       IMAGE:          createFileTypeID(),
+                       TEXT:           createFileTypeID(),
+                       HTML:           createFileTypeID(),
+                       CSV:            createFileTypeID(),
+                       JSON:           createFileTypeID(),
+                       XML:            createFileTypeID()
+               },
+               FILE_STATE: {
+                       UNKNOWN:        0,
+                       OK:                     1,
+                       LOADING:        2,
+                       ERROR:          3,
+                       BROKEN:         4
+               },
+               FILE_UPDATE_POLICY: {
+                       _____:          parseInt( '00000', 2),
+                       ____C:          parseInt( '00001', 2), // hasCreateMenu
+                       ___W_:          parseInt( '00010', 2), // isWritable
+                       ___WC:          parseInt( '00011', 2), // isWritable
+                       __R__:          parseInt( '00100', 2), // isRenamable
+                       __R_C:          parseInt( '00101', 2), // hasCreateMenu
+                       __RW_:          parseInt( '00110', 2), // isWritable
+                       __RWC:          parseInt( '00111', 2), // isWritable
+                       _S___:          parseInt( '01000', 2), // childrenIsSortable
+                       _S__C:          parseInt( '01001', 2),
+                       _S_W_:          parseInt( '01010', 2),
+                       _S_WC:          parseInt( '01011', 2),
+                       _SR__:          parseInt( '01100', 2),
+                       _SR_C:          parseInt( '01101', 2),
+                       _SRW_:          parseInt( '01110', 2),
+                       _SRWC:          parseInt( '01111', 2),
+                       D____:          parseInt( '10000', 2),
+                       D___C:          parseInt( '10001', 2), // hasCreateMenu
+                       D__W_:          parseInt( '10010', 2), // isWritable
+                       D__WC:          parseInt( '10011', 2), // isWritable
+                       D_R__:          parseInt( '10100', 2), // isRenamable
+                       D_R_C:          parseInt( '10101', 2), // hasCreateMenu
+                       D_RW_:          parseInt( '10110', 2), // isWritable
+                       D_RWC:          parseInt( '10111', 2), // isWritable
+                       DS___:          parseInt( '11000', 2), // childrenIsSortable
+                       DS__C:          parseInt( '11001', 2),
+                       DS_W_:          parseInt( '11010', 2),
+                       DS_WC:          parseInt( '11011', 2),
+                       DSR__:          parseInt( '11100', 2),
+                       DSR_C:          parseInt( '11101', 2),
+                       DSRW_:          parseInt( '11110', 2),
+                       DSRWC:          parseInt( '11111', 2),
+                       CREATE:         1,
+                       WRAITE:         2,
+                       RENAME:         4,
+                       SORT:           8,
+                       DELETE:         16
+               },
+               TREE_EVENT: {
+                       UPDATE:                         'onTreeUpdate'
+               },
+               FILE_EVENT: {
+                       UPDATE_ATTRIVUTE:       'onFileUpdate',
+                       GET_SEQENTIAL_FILES:'gotSeqentilFiles'
+               },
+               FILE_DATA_PROPERTY_RESERVED: [
+                       'children', 'driver', 'state', 'type'
+               ]
+       }
+})();
+
+pettanr.finder = ( function(){
+       var FINDER_ARRAY = [],
+               ELM_ORIGIN_FINDER_LOCATION_ITEM = pettanr.util.pullHtmlAsTemplete( 'templete-finder-location-item'),
+               ELM_ORIGIN_FINDER_ICON = pettanr.util.pullHtmlAsTemplete( 'templete-finder-icon'),
+               ELM_ORIGIN_CONTAINER = pettanr.util.pullHtmlAsTemplete( 'templete-finder-container'),
+               ICON_HEIGHT = pettanr.util.getElementSize( ELM_ORIGIN_FINDER_ICON).height,
+               ICON_CLASSNAME = 'finder-icon-thumbnail',
+               FINDER_ICON_POOL = [],
+               BREAD_OBJECT_POOL = [];
+       
+       var FinderIconClass = function(){
+               var elmContainer,
+                       ELM_WRAPPER = ELM_ORIGIN_FINDER_ICON.cloneNode( true),
+                       ELM_THUMBNAIL = pettanr.util.getElementsByClassName( ELM_WRAPPER, ICON_CLASSNAME )[0],
+                       ELM_FILENAME = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-filename' )[0],
+                       ELM_DESCRIPTION = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-summary' )[0],
+                       ELM_EDITOR_BUTTON = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-console-editor-apps' )[0],
+                       ELM_VIEWER_BUTTON = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-console-viewer-apps' )[0],
+                       ELM_ACTION_BUTTON = pettanr.util.getElementsByClassName( ELM_WRAPPER, 'finder-icon-console-action' )[0],
+                       file, w, index, style, instansce,
+                       onDownCallback, onEditorCallback, onViewerCallback, onActionCallback,
+                       viewerList, editorList;
+               ELM_WRAPPER.onmouseover = onOver;
+               function onOver(){
+                       ELM_WRAPPER.style.backgroundColor = '#eee';
+               }
+               ELM_WRAPPER.onmouseout = onOut;
+               function onOut(){
+                       ELM_WRAPPER.style.backgroundColor = '';
+               }
+               
+               ELM_WRAPPER.onclick = onDownClick;
+               function onDownClick(){
+                       onDownCallback( index);
+                       return false;
+               }
+               ELM_EDITOR_BUTTON.onclick = onEditorClick;
+               function onEditorClick(){
+                       onEditorCallback( file, editorList[ 0 ] );
+                       return false;
+               }
+               ELM_VIEWER_BUTTON.onclick = onViwerClick;
+               function onViwerClick(){
+                       onViewerCallback( file, viewerList[ 0 ] );
+                       return false;
+               }
+               ELM_ACTION_BUTTON.onclick = onActionClick;
+               function onActionClick(){
+                       onActionCallback( file );
+                       return false;
+               }
+               function draw(){
+                       var _thumb = file.getThumbnail();
+                       if( _thumb.image ){
+                               ELM_THUMBNAIL.className = ICON_CLASSNAME + ' has-thumbnail';
+                               ELM_THUMBNAIL.style.backgroundImage = [ 'url(', _thumb.image, ')'].join( '');
+                       } else {
+                               ELM_THUMBNAIL.className = ICON_CLASSNAME + ' ' + _thumb.className;
+                               ELM_THUMBNAIL.style.backgroundImage = '';
+                       }
+                       ELM_FILENAME.firstChild.data = file.getName();
+                       ELM_DESCRIPTION.firstChild.data = file.getSummary();
+                       
+                       if( Type.isArray( viewerList ) === true && viewerList.length > 0 ){
+                               ELM_VIEWER_BUTTON.style.display = '';
+                       } else {
+                               ELM_VIEWER_BUTTON.style.display = 'none';
+                       };
+                       if( Type.isArray( editorList ) === true && editorList.length > 0 ){
+                               ELM_EDITOR_BUTTON.style.display = '';
+                       } else {
+                               ELM_EDITOR_BUTTON.style.display = 'none';
+                       };
+               }
+               function resize(){
+                       ELM_WRAPPER.style.top = (index * ICON_HEIGHT) +'px';
+               }
+               function onCollect(){
+                       elmContainer.removeChild( ELM_WRAPPER );
+                       elmContainer = null;
+                       FINDER_ICON_POOL.push( instansce );
+               }
+               
+               return {
+                       init: function( _file, _elmContainer, _w, _index, _style, _onDownCallback, _onEditorCallback, _onViewerCallback, _onActionCallback ){
+                               instansce = this;
+                               if( elmContainer !== _elmContainer){
+                                       _elmContainer.appendChild( ELM_WRAPPER);
+                                       elmContainer = _elmContainer;
+                               }
+                               if( file !== _file){
+                                       file && file.destroy();
+                                       file = _file;
+                                       viewerList = file.viewerApplicationList();
+                                       editorList = file.editorApplicationList();
+                                       draw();
+                               }
+                               if( index !== _index){
+                                       index = _index;
+                                       resize();
+                               }
+                               onDownCallback = _onDownCallback;
+                               onEditorCallback = _onEditorCallback;
+                               onViewerCallback = _onViewerCallback;
+                               onActionCallback = _onActionCallback;
+                       },
+                       elm: ELM_WRAPPER,
+                       index: function( _index){
+                               
+                               return index;
+                       },
+                       style: function( _style){
+                               
+                               return style;
+                       },
+                       onResize: function( w ){
+                               
+                       },
+                       destroy: function(){
+                               elmContainer.removeChild( ELM_WRAPPER);
+                               file && file.destroy();
+                               file = elmContainer = onDownCallback = onEditorCallback = onViewerCallback = onActionCallback = viewerList = editorList = null;
+                               FINDER_ICON_POOL.push( instansce);
+                       }
+               }
+       }
+       function updateIconPosition( _style, _w, _index, _elm){
+               
+       }
+       var BreadcrumbClass = function(){
+               var elmContainer,
+                       ELM_WRAPPER = ELM_ORIGIN_FINDER_LOCATION_ITEM.cloneNode( true),
+                       ELM_FILENAME = ELM_WRAPPER.getElementsByTagName( 'a')[0],
+                       file, w, index, instansce,
+                       callback;
+               ELM_WRAPPER.onclick = onClick;
+               function draw(){
+                       ELM_FILENAME.className = 'file-icon-' +file.getType();
+                       ELM_FILENAME.innerHTML = file.getName();
+               }
+               function resize( index){
+                       ELM_WRAPPER.style.left = (index * 90) +'px';
+               }
+               function onClick(){
+                       callback( index);
+                       return false;
+               }
+
+               return {
+                       init: function( _file, _elmContainer, _index, _callback ){
+                               instansce = this;
+                               if( elmContainer !== _elmContainer ){
+                                       _elmContainer.appendChild( ELM_WRAPPER);
+                                       elmContainer = _elmContainer;
+                               }
+                               if( file !== _file){
+                                       file = _file;
+                                       draw();
+                               }
+                               if( index !== _index){
+                                       index = _index;
+                                       resize( index);
+                               }
+                               callback = _callback;
+                       },
+                       elm: ELM_WRAPPER,
+                       index: function( _index){
+                               
+                               return index;
+                       },
+                       onResize: function( w){
+                               
+                       },
+                       destroy: function(){
+                               elmContainer.removeChild( ELM_WRAPPER);
+                               file = elmContainer = null;
+                               BREAD_OBJECT_POOL.push( this );
+                       }
+               }
+       }
+       
+       var FinderClass = function( ELM_CONTAINER, tree, header, footer ){
+               var ICON_ARRAY = [],
+                       BREAD_ARRAY = [],
+                       elmContainer = ELM_ORIGIN_CONTAINER.cloneNode( true ),
+                       elmLocation = elmContainer.getElementsByTagName( 'ul' )[0],
+                       nodesDiv = elmContainer.getElementsByTagName( 'div' ),
+                       elmSidebarButton = nodesDiv[1],
+                       elmStyleButton = nodesDiv[2],
+                       elmActionButton = nodesDiv[3],
+                       elmBody = nodesDiv[ nodesDiv.length -1 ],
+                       //tree = pettanr.file.createTree( TREE_TYPE),
+                       headX,
+                       headY,
+                       headH = pettanr.util.getElementSize( nodesDiv[0] ).height,
+                       bodyY,
+                       currentFile = null,
+                       breadW = 90,
+                       size = pettanr.util.getElementSize( ELM_ORIGIN_FINDER_ICON ),
+                       iconW = size.width,
+                       iconH = size.height,
+                       style = 0,
+                       w, h, bodyH,
+                       instance = this;
+                       
+               tree.addTreeEventListener( pettanr.file.TREE_EVENT.UPDATE, draw );
+               
+               function draw( _w, _h ){
+                       w = Type.isFinite( _w ) === true ? _w : w;
+                       h = Type.isFinite( _h ) === true ? _h : h;
+                       bodyH = h - headH;
+                       var     l = tree.hierarchy() +1,
+                               m = BREAD_ARRAY.length,
+                               _file, _bread;
+                       for(var i=0; i<l; ++i){
+                               _file = i !== l-1 ? tree.getParentFileAt( i) : tree.getCurrentFile();
+                               if( i < m){
+                                       BREAD_ARRAY[ i].init( _file, elmLocation, i, onHeadClick);
+                               } else {
+                                       BREAD_ARRAY.push( getBreadcrumb( _file, elmLocation, i, onHeadClick ));
+                               }
+                       }
+                       while( l < BREAD_ARRAY.length){
+                               BREAD_ARRAY.pop().destroy();
+                       }
+                       
+                       l = _file.getChildFileLength();
+                       m = ICON_ARRAY.length;
+
+                       for( i=0; i<l; ++i){
+                               if( i < m){
+                                       ICON_ARRAY[ i ].init( _file.getChildFileByIndex( i), elmBody, w, i, style, onDown, onEditor, onViwer, onAction );
+                               } else {
+                                       ICON_ARRAY.push( getFinderIcon( _file.getChildFileByIndex( i), elmBody, _w, i, style, onDown, onEditor, onViwer, onAction ));
+                               }
+                       }
+                       if( _file.getState() === pettanr.file.FILE_STATE.LOADING ){
+                               elmBody.className = 'finder-body loading';
+                       } else {
+                               elmBody.className = 'finder-body';
+                       }
+                       elmBody.style.height = bodyH + 'px';
+                       
+                       while( l < ICON_ARRAY.length){
+                               ICON_ARRAY.pop().destroy();
+                       }
+               }
+               
+               function onHeadClick( i){
+                       var l = BREAD_ARRAY.length -1;
+                       if( i < l){
+                               var _file = tree.getParentFileAt( i);
+                               if( _file !== null){
+                                       tree.up( i);
+                                       draw( w, h );
+                               }
+                       }
+               }
+               function onDown( i ){
+                       if( i < ICON_ARRAY.length ){
+                               var _file = tree.getCurrentFile().getChildFileByIndex( i );
+                               if( _file !== null && ( _file.getChildFileLength() !== -1 || _file.getType() === pettanr.file.FILE_TYPE.FOLDER)){
+                                       tree.down( i );
+                                       draw( w, h );
+                               }
+                       }
+               }
+               function onEditor( _file, _app ){
+                       _app.boot( _file );
+               }
+               function onViwer( _file, _app ){
+                       _app.bootInOverlay( _file );
+               }
+               function onAction( _file ){
+
+               }
+               this.rootElement = elmContainer;
+               this.parentElement = ELM_CONTAINER;
+               this.displayName = 'finder';
+               this.ID = 'finder';
+               this.MIN_WIDTH = 240;
+               this.MIN_HEIGHT = 240;
+               this.init = function(){
+                       //$( elmLocation).click( onHeadClick);
+                       //$( elmContainer).click( onBodyClick);
+                       var position = pettanr.util.getAbsolutePosition( elmLocation);
+                       headX = position.x;
+                       headY = position.y;
+                       bodyY = pettanr.util.getAbsolutePosition( elmBody ).y;
+                       delete instance.init;
+               }
+               this.onOpen = function( _w, _h, _option ){
+                       instance.init && instance.init();
+                       draw( _w, _h );
+               }
+               this.onClose = function(){
+                       return true;
+               }
+               this.onPaneResize = function( _w, _h ){
+                       w = _w;
+                       h = _h;
+                       elmBody.style.height = ( _h - headH ) + 'px';
+                       
+                       for(var i=0, l=ICON_ARRAY.length; i<l; ++i){
+                               ICON_ARRAY[ i].onResize( _w );
+                       }
+               }
+       }
+       FinderClass.prototype = pettanr.view._getAbstractApplication();
+       
+       function getFinderIcon( _file, _elmContainer, w, index, style, onDown, onEditor, onViwer, onAction){
+               var _icon;
+               if( FINDER_ICON_POOL.length > 0){
+                       _icon = FINDER_ICON_POOL.shift();
+               } else {
+                       _icon = new FinderIconClass();
+               }
+               _icon.init( _file, _elmContainer, w, index, style, onDown, onEditor, onViwer, onAction );
+               return _icon;
+       }
+       
+       function getBreadcrumb( _file, _elmContainer, index, callback){
+               var _bread;
+               if( BREAD_OBJECT_POOL.length > 0){
+                       _bread = BREAD_OBJECT_POOL.shift();
+               } else {
+                       _bread = new BreadcrumbClass();
+               }
+               _bread.init( _file, _elmContainer, index, callback);
+               return _bread;
+       }
+
+       return {
+               init: function(){
+                       
+               },
+               createFinder: function( _elmTarget, _tree, _header, _footer ){
+                       var _finder = new FinderClass( _elmTarget, _tree, _header, _footer );
+                       FINDER_ARRAY.push( _finder );
+                       return _finder;
+               },
+               registerFinderHead: function(){
+                       
+               },
+               registerFinderPane: function( _finderPane){
+                       
+               },
+               isFinderInstance: function( _finder){
+                       return _finder instanceof FinderClass;
+               },
+               isFinderPaneInstance: function(){
+                       
+               },
+               isFinderHeadInstance: function(){
+               }
+       }
+})();
+
+
+pettanr.driver = ( function(){
+       var MyAuthorID = 'current_author' in window ? current_author.id : ( pettanr.DEBUG ? 1 : -1 ),
+               MyArtistID = 'current_artist' in window ? current_artist.id : ( pettanr.DEBUG ? 1 : -1 ),
+               Driver = {
+                       getSeqentialFiles: function( _file){
+                               var _data = FileAPI.getFileData( _file),
+                                       _json = _data !== null ? _data.json : null;
+                               if( _json === true && _data.type === pettanr.driver.FILE_TYPE.COMIC ){
+                                       if( pettanr.LOCAL === true ){
+                                               _json = [ 'json\/comics_', _data.id, '.json' ].join( '' );
+                                       } else {
+                                               _json = [ pettanr.CONST.PETTANR_ROOT_PATH, 'comics\/', _data.id, '.json\/play\/' ].join( '' );
+                                       }
+                               }
+                               if( typeof _json === 'string'){
+                                       FileAPI.getJson( _file, _json, onLoadJson, onErrorJson);
+                                       _data.state = pettanr.file.FILE_STATE.LOADING;
+                                       _data.json = null;
+                                       return;
+                               }
+                       },
+                       getName: function( _file){
+                               var _data = FileAPI.getFileData( _file),
+                                       _type = _data !== null ? _data.type : null;
+                               if( _type === pettanr.driver.FILE_TYPE.PICTURE ){
+                                       return [ _data.id, _data.ext ].join( '.');
+                               } else
+                               if( _type === pettanr.driver.FILE_TYPE.PANEL ){
+                                       return [ _data.t, ':', _data.comic.title ].join( '');
+                               } else
+                               if( _type === pettanr.driver.FILE_TYPE.COMIC ){
+                                       return _data.title;
+                               } else
+                               if( _type === pettanr.driver.FILE_TYPE.ARTIST ){
+                                       return [ _data.id , ':', _data.name, '画伯' ].join( '');
+                               } else
+                               if( _type === pettanr.driver.FILE_TYPE.AUTHOR ){
+                                       return [ _data.id , ':', _data.name, '先生' ].join( '');
+                               }
+                               return _data.name;
+                       },
+                       getThumbnail: function( _file){
+                               var _data = FileAPI.getFileData( _file),
+                                       _type = _data !== null ? _data.type : null;
+                               if( _type === pettanr.driver.FILE_TYPE.PICTURE){
+                                       return { image: [ pettanr.CONST.RESOURCE_PICTURE_PATH, 'thumbnail/', _data.id, '.', _data.ext ].join( '')};
+                               }
+                               if( _data === FILE_DATA_COMICS_ROOT){
+                                       return { className: 'file-type-cabinet'};
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.COMIC){
+                                       return { className: 'file-type-comic'};
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.PANEL){
+                                       return { className: 'file-type-panel'};
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.AUTHOR){
+                                       return { className: 'file-type-author'};
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.ARTIST){
+                                       return { className: 'file-type-artist'};
+                               }
+                               if( _type === pettanr.file.FILE_TYPE.FOLDER){
+                                       return { className: 'file-type-folder'};
+                               }
+                               return { className: 'file-type-broken'};
+                       },
+                       getSummary: function( _file ){
+                               var _data = FileAPI.getFileData( _file),
+                                       _type = _data !== null ? _data.type : null;
+                               if( _type === pettanr.driver.FILE_TYPE.PICTURE){
+                                       return [ _data.width, 'x', _data.height, ', filesize:', _data.filesize, ', lisence:', _data.license ].join( '' );
+                               }
+                               if( _data === FILE_DATA_COMICS_ROOT){
+                                       return 'cabinet file';
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.COMIC){
+                                       return 'comic file';
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.PANEL){
+                                       return [ _data.width, 'x', _data.height ].join( '' );
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.AUTHOR){
+                                       return 'author file';
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.ARTIST){
+                                       return [ 'Email:', _data.email || 'empty' , ', HP:', _data.homepage_url || 'empty' ].join( '' );
+                               }
+                               if( _type === pettanr.file.FILE_TYPE.FOLDER){
+                                       return 'pettanR folder';
+                               }
+                               return 'pettanR unknown file';
+                       },
+                       write: function( _file, _newData, _onUpdateFunction ){
+                               var _data = FileAPI.getFileData( _file ),
+                                       _type = _data !== null ? _data.type : null;
+                               if( _type === pettanr.driver.FILE_TYPE.COMIC ){
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.PANEL ){
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.PANEL_PICTURE ){
+                                       
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.BALLOON ){
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.PICTURE ){
+                               }                               
+                       },
+                       viewerApplicationList: function( _file ){
+                               var _data = FileAPI.getFileData( _file ),
+                                       _type = _data !== null ? _data.type : null;
+                                       
+                               if( _data === FILE_DATA_MY_PICTURES_ROOT ){
+                                       return [ pettanr.premiumSatge ];
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.ARTIST ){
+                                       return [ pettanr.premiumSatge ];
+                               }
+                               return [];
+                       },
+                       editorApplicationList: function( _file ){
+                               var _data = FileAPI.getFileData( _file ),
+                                       _type = _data !== null ? _data.type : null;
+                               if( _type === pettanr.driver.FILE_TYPE.PANEL ){
+                                       return [ pettanr.editor ];
+                               }
+                               if( _type === pettanr.driver.FILE_TYPE.COMIC ){
+                                       return [ pettanr.editor, pettanr.comicConsole ];
+                               }
+                               return [];
+                       }
+               },
+               FileAPI = pettanr.file.registerDriver( Driver ),
+               FILE_DATA_SERVICE_ROOT = {
+                       name:           'PettanR root',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       []
+               },
+               FILE_DATA_COMICS_ROOT = {
+                       name:           'Comics',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       [],
+                       driver:         Driver,
+                       json:           pettanr.CONST.URL_COMICS_JSON
+               },
+               FILE_DATA_PANELS_ROOT = {
+                       name:           'Panels',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       [],
+                       driver:         Driver,
+                       json:           pettanr.CONST.URL_PANELS_JSON
+               },
+               FILE_DATA_PICTURE_ROOT = {
+                       name:           'Picutures',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       [],
+                       driver:         Driver,
+                       json:           pettanr.CONST.URL_RESOURCE_PICTURES_JSON
+               },
+               FILE_DATA_MY_COMICS_ROOT = {
+                       name:           'My Comics',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       [],
+                       driver:         Driver
+               },
+               FILE_DATA_LATEST_COMICS = {
+                       name:           'Latest Comics',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       []
+               },
+               FILE_DATA_MY_PICTURES_ROOT = {
+                       name:           'My Pictures',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       [],
+                       driver:         Driver,
+                       json:           pettanr.CONST.URL_ORIGINAL_PICTURES_JSON
+               },
+               FILE_DATA_AUTHOR_ROOT = {
+                       name:           'Authors',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       []
+               },
+               FILE_DATA_ARTIST_ROOT = {
+                       name:           'Artists',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       []
+               },
+               FILE_DATA_LISENCE_ROOT = {
+                       name:           'Original Lisences',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       []
+               },
+               FILE_DATA_BALLOON_ROOT = {
+                       name:           'Balloon templetes',
+                       type:           pettanr.file.FILE_TYPE.FOLDER,
+                       children:       []
+               },
+               AUTHOR_ARRAY = [],
+               ARTIST_ARRAY = [],
+               PANEL_ARRAY = [],
+               COMIC_ARRAY = [],
+               RESOURCE_PICTURE_ARRAY = [],
+               BALLOON_TEMPLETE_ARRAY = [],
+               ORIGINAL_LICENSE_ARRAY = [],
+               BASIC_LICENSES = 'cc_by,cc_nc,cc_nd,cc_sa,keep_aspect_ratio,no_convert,no_flip,no_resize'.split( ',');
+       FILE_DATA_SERVICE_ROOT.children.push( FILE_DATA_COMICS_ROOT, FILE_DATA_PICTURE_ROOT, FILE_DATA_PANELS_ROOT, FILE_DATA_LISENCE_ROOT, FILE_DATA_BALLOON_ROOT);
+       FILE_DATA_COMICS_ROOT.children.push( FILE_DATA_MY_COMICS_ROOT, FILE_DATA_LATEST_COMICS, FILE_DATA_AUTHOR_ROOT);
+       FILE_DATA_PICTURE_ROOT.children.push( FILE_DATA_MY_PICTURES_ROOT, FILE_DATA_ARTIST_ROOT);
+       
+       FileAPI.createFolderUnderRoot( FILE_DATA_SERVICE_ROOT);
+
+       function onLoadJson( _file, _json ){
+               var _access = FileAPI.getFileDataAccess( _file),
+                       _data = _access !== null ? _access.DATA : null,
+                       l;
+               if( _data === null){
+                       onErrorJson( _file);
+                       return;
+               }
+               _data.state = pettanr.file.FILE_STATE.OK;
+               
+               if( Type.isArray( _json ) === true ){
+                       l = _json.length;
+                       if( l === 0) return;
+                       for( var i=0; i<l; ++i ){
+                               buildFileData( _json[ i], _data);
+                       }                       
+               } else
+               if( _json.id ){
+                       buildFileData( _json, _data );
+               }
+               _access.dispatchFileEvent( FileAPI.createFileEvent( pettanr.file.FILE_EVENT.GET_SEQENTIAL_FILES, _file, 'children', null));
+       }
+       function onErrorJson( _file ){ 
+               var _data = FileAPI.getFileData( _file);
+               if( _data !== null){
+                       _data.state = pettanr.file.FILE_STATE.ERROR;
+               }
+       }
+       function buildFileData( _data, _parent ){
+               var _array, i, l;
+               // Panel
+               if( _parent === FILE_DATA_PANELS_ROOT ){
+                       _data.type = pettanr.driver.FILE_TYPE.PANEL;
+                       _array = PANEL_ARRAY;
+               } else
+               // Comic
+               if( _parent === FILE_DATA_COMICS_ROOT ){
+                       _data.type = pettanr.driver.FILE_TYPE.COMIC;
+                       _array = COMIC_ARRAY;
+               } else
+               if( _parent.type === pettanr.driver.FILE_TYPE.COMIC ){
+                       _array = COMIC_ARRAY;
+               } else
+               // Lisence
+               if( _parent === FILE_DATA_LISENCE_ROOT ){
+                       _data.type = pettanr.driver.FILE_TYPE.LICENSE;
+                       _array = ORIGINAL_LICENSE_ARRAY;
+               } else
+               // Author
+               if( _parent === FILE_DATA_AUTHOR_ROOT ){
+                       _data.type = pettanr.driver.FILE_TYPE.AUTHOR;
+                       _array = AUTHOR_ARRAY;
+               } else
+               // Artist
+               if( _parent === FILE_DATA_ARTIST_ROOT ){
+                       _data.type = pettanr.driver.FILE_TYPE.ARTIST;
+                       _array = ARTIST_ARRAY;
+               } else          
+               // Picture
+               if( _parent === FILE_DATA_PICTURE_ROOT || _parent === FILE_DATA_MY_PICTURES_ROOT ){
+                       _data.type = pettanr.driver.FILE_TYPE.PICTURE;
+                       _array = RESOURCE_PICTURE_ARRAY;
+                       // original_license を含まなければ、license object を削除して ビットデータ で保持
+                       // original_license なら ファイルを作る buildFileData( _license, FILE_DATA_LISENCE_ROOT)
+                       var _license = _data.license,
+                               _rule,
+                               _Math_pow = Math.pow,
+                               _bits = 0;
+                       if( typeof _license === 'object'){
+                               for( i=0, l=BASIC_LICENSES.length; i<l; ++i){
+                                       _rule = _license[ BASIC_LICENSES[ i]]
+                                       if( typeof _rule === 'number' && _rule === 1 ){
+                                               _bits += _Math_pow( 2, i);
+                                       }
+                               }
+                               _data.license = _bits;
+                       }
+               } else {
+                       alert( 'error' );
+               }
+               
+               _data.driver = Driver;
+               
+               // _array に _data を格納 または 上書き
+               if( typeof _data.id === 'number' && _data.id > 0 ){
+                       var _id = _data.id - 1,
+                               __data = _array[ _id ],
+                               _reserved = pettanr.file.FILE_DATA_PROPERTY_RESERVED.join( ', ' );
+                       if( __data ){
+                               for( var key in _data){
+                                       if( _reserved.indexOf( key ) === -1 ){
+                                               __data[ key ] = _data[ key ];
+                                       }
+                               }
+                               _data = __data; // このタイミングで参照が切れるので注意!!
+                       } else {
+                               _array[ _id ] = _data;
+                       }
+               } else {
+                       alert( 'error' );
+               }
+
+               // Author
+               // Artist
+               if( _parent === FILE_DATA_AUTHOR_ROOT || _parent === FILE_DATA_ARTIST_ROOT ){
+                       addChildData( _parent, _data );
+               } else
+               // Comic + Panels
+               if( _parent.type === pettanr.driver.FILE_TYPE.COMIC || _parent === FILE_DATA_COMICS_ROOT ){
+                       var _panels = _data.panels,
+                               _panel;
+                       if( _panels && Type.isArray( _panels ) === true ){
+                               
+                               for( i=0, l=_panels.length; i<l; ++i){
+                                       _panel = buildFileData( _panels[ i ], FILE_DATA_PANELS_ROOT );
+                                       /*
+                                        * 間違い! t 順に格納
+                                        */
+                                       addChildData( _data, _panel );
+                               }
+                               delete _data.panels;
+                       } else {
+                               if( _data.json !== null ){
+                                       _data.json = true;
+                               }
+                               if( Type.isArray( _data.children ) === false ){
+                                       _data.children = [];
+                               }                               
+                       }
+                       var _author = _data.author || getResource( AUTHOR_ARRAY, _data.author_id );
+                       if( _author ){
+                               _data.author = _author = buildFileData( _author, FILE_DATA_AUTHOR_ROOT );
+                               addChildData( _author, _data );
+                               _author.id === MyAuthorID && addChildData( FILE_DATA_MY_COMICS_ROOT, _data );
+                       }
+                       if( _parent === FILE_DATA_COMICS_ROOT ){
+                               addChildData( FILE_DATA_LATEST_COMICS, _data);
+                       }
+               } else
+               // Panel
+               if( _parent === FILE_DATA_PANELS_ROOT ){
+                       _data.comic = getResource( COMIC_ARRAY, _data.comic_id );
+                       _data.author = getResource( AUTHOR_ARRAY, _data.author_id );
+
+                       // picture data をファイルに取り出し
+                       var _elements = _data.panel_elements,
+                               _elm;
+                       if( Type.isArray( _elements ) === true ){
+                               for( i=0, l=_elements.length; i<l; ++i){
+                                       _elm = _elements[ i];
+                                       if( _elm.resource_picture ){
+                                               _elm.resource_picture = buildFileData( _elm.resource_picture, FILE_DATA_PICTURE_ROOT ); // 上記参照切れに備えてここで上書き
+                                       } else {
+                                               _elm.resource_picture = getResource( RESOURCE_PICTURE_ARRAY, _elm.resource_picture_id );
+                                       }
+                               }                               
+                       }
+               } else
+               // Picture
+               if( _data.type == pettanr.driver.FILE_TYPE.PICTURE ){
+                       var _artist = _data.artist || getResource( ARTIST_ARRAY, _data.artist_id );
+                       if( _artist){
+                               _data.artist = _artist = buildFileData( _artist, FILE_DATA_ARTIST_ROOT );
+                               addChildData( _artist, _data );
+                               _artist.id === MyArtistID && addChildData( FILE_DATA_MY_PICTURES_ROOT, _data );
+                       }
+               }
+               return _data;
+       }
+       function addChildData( _parent, _child ){
+               if( Type.isArray( _parent.children ) === false){
+                       _parent.children = [];
+               }
+               pettanr.util.getIndex( _parent.children, _child ) === -1 && _parent.children.push( _child );
+       }
+       function getResource( _array, _id ){
+               if( Type.isArray( _array ) === false || Type.isNumber( _id ) === false || _id < 1 ) return null;
+               var _data = _array[ _id - 1 ];
+               if( !_data ){
+                       _data = _array[ _id - 1 ] = {};
+               }
+               return _data;
+       }
+
+       return {
+               createComicTree: function(){
+                       return pettanr.file.createTree( FILE_DATA_SERVICE_ROOT ); //FILE_DATA_COMICS_ROOT);
+               },
+               createPictureTree: function(){
+                       return pettanr.file.createTree( FILE_DATA_PICTURE_ROOT );
+               },
+               createArtistTree: function(){
+                       return pettanr.file.createTree( FILE_DATA_ARTIST_ROOT );
+               },
+               createServiceTree: function(){
+                       return pettanr.file.createTree( FILE_DATA_SERVICE_ROOT );
+               },
+               isPettanrFileInstance: function( _file ){
+                       if( pettanr.file.isFileInstance( _file ) === true){
+                               var _data = FileAPI.getFileData( _file);
+                               return _data !== null && _data.driver === Driver;
+                       }
+                       return false;
+               },
+               _getAPI: function(){
+                       return FileAPI;
+               },
+               FILE_TYPE: {
+                       COMIC:                          FileAPI.createFileTypeID(),
+                       PANEL:                          FileAPI.createFileTypeID(),
+                       PICTURE:                        FileAPI.createFileTypeID(),
+                       PANEL_PICTURE:          FileAPI.createFileTypeID(),
+                       BALLOON:                        FileAPI.createFileTypeID(),
+                       AUTHOR:                         FileAPI.createFileTypeID(),
+                       ARTIST:                         FileAPI.createFileTypeID(),
+                       LICENSE:                        FileAPI.createFileTypeID()
+               }
+       }
+})();
+
+pettanr.entrance = pettanr.view.registerApplication( function(){
+       this.displayName = 'Home';
+       this.ID          = 'Home';
+       this.rootElement = document.getElementById('entrance');
+       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){
+               this.onOpen( _w, _h );
+       }
+});
+pettanr.entrance.addToLancher();
+
+pettanr.cabinet = pettanr.view.registerApplication( function(){
+       var finder,
+               elmContainer = document.getElementById( 'cabinet'),
+               option,
+               pageHeaderH = pettanr.util.getElementSize( document.getElementById( 'header' ) ).height;
+               
+       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});
+                       
+                       onEnterInterval !== null && window.clearTimeout( onEnterInterval );
+                       onEnterInterval = window.setTimeout( onEnterShowImage, 500);
+               }
+               //e.stopPropagation();
+               return false;                   
+       }
+       
+       /* grobal method */
+       // this.rootElement = elmWrap;
+       this.displayName = 'premiumStage';
+       this.ID          = 'premiumStage';
+       this.rootElement = elmWrap;
+       this.MIN_WIDTH   = 320;
+       this.MIN_HEIGHT  = 320;
+       this.init = function(){
+               jqContainer = $( elmContainer ).mousewheel( onMouseWheel );
+               delete instance.init;
+       }
+       this.onOpen = function( _windowW, _windowH, _ARTISTIDorFILE, _onUpdateFunction ){
+               instance.init && instance.init();
+               
+               var _data, _artistID = -1;
+               
+               if( pettanr.driver.isPettanrFileInstance( _ARTISTIDorFILE ) === true ){
+                       if( _ARTISTIDorFILE.getType() === pettanr.driver.FILE_TYPE.ARTIST ){
+                               _data = pettanr.driver._getAPI().getFileData( _ARTISTIDorFILE );
+                               _artistID = _data !== null ? _data.id || 0 : -1;
+                       }
+               } else
+               if( Type.isNumber( _ARTISTIDorFILE ) === true ){
+                       _artistID = _ARTISTIDorFILE;
+               }
+               
+               //onUpdateFunction = _onUpdateFunction;
+               if( _onUpdateFunction ){
+                       _g_onUpdateFunction = pettanr.util.createGlobalFunction( _onUpdateFunction);
+               } else {
+                       _g_onUpdateFunction = null;
+               }
+               
+               var _index = ARTIST_ROOT_FILE.search( {
+                               id:   _artistID,
+                               type: pettanr.driver.FILE_TYPE.ARTIST
+                       } )[ 0 ],
+                       _artistFile = ARTIST_ROOT_FILE.getChildFileByIndex( _index ),
+                       i, l = 0;
+               if( _artistFile !== null ){
+                       for( i=0, l=_artistFile.getChildFileLength(); i<l; ++i ){
+                               ICON_ARRAY.push( new ImageGroupIconClass( i, _artistFile.getChildFileByIndex( i ) ));
+                       }
+                       elmName.firstChild.data = _artistFile.getName() + l;
+                       _artistFile.destroy();
+               }
+               
+               wrapX = 0;
+               containerW = l * itemW;
+               
+               winW = _windowW;
+               winH = _windowH;
+               var w = winW > containerW ? winW : containerW,
+                       h = _windowH > containerH ? containerH : _windowH,
+                       MATH_FLOOR = Math.floor;
+               
+               onEnterShowImage();
+               
+               jqContainer.css( {
+                       width:          w,
+                       height:         0,
+                       left:           0,
+                       top:            MATH_FLOOR( _windowH /2)
+               }).stop().animate( {
+                       height:         h,
+                       top:            MATH_FLOOR( _windowH /2 -h /2)
+               });
+               
+               elmButton.style.cssText = [
+                       'left:', MATH_FLOOR( winW /2 - buttonW /2), 'px;',
+                       'top:', MATH_FLOOR( _windowH /2 + containerH /2 +10), 'px'
+               ].join('');
+       }
+       this.onPaneResize = function( _windowW, _windowH ){
+               var w = _windowW > containerW ? _windowW : containerW,
+                       h = _windowH > containerH ? containerH : _windowH,
+                       MATH_FLOOR = Math.floor,
+                       offsetW = MATH_FLOOR( _windowW /2 -winW /2);
+                       
+               winW = _windowW;
+               winH = _windowH;
+               if( offsetW <= 0){ // smaller
+                       jqContainer.css( {
+                               left:                           offsetW,
+                               width:                          w
+                       }).animate( {
+                               left:                           0,
+                               top:                            MATH_FLOOR( _windowH /2 -h /2)
+                       });                                     
+               } else {
+                       jqContainer.css( { // bigger
+                               left:                           0,
+                               width:                          w,
+                               borderLeftWidth:        offsetW
+                       }).animate( {
+                               top:                            MATH_FLOOR( _windowH /2 -h /2),
+                               borderLeftWidth:        0
+                       });
+               }
+               elmButton.style.cssText = [
+                       'left:', MATH_FLOOR( _windowW /2 -buttonW /2), 'px;',
+                       'top:', MATH_FLOOR( _windowH /2 +containerH /2 +10), 'px'
+               ].join('');
+               onEnterShowImage();
+       }
+       this.onClose = function(){
+               jqContainer.stop().animate( {
+                               height: 0,
+                               top:    Math.floor( winH /2 )
+                       });
+               while( ICON_ARRAY.length > 0 ){
+                       ICON_ARRAY.shift().destroy();
+               }
+               onEnterInterval !== null && window.clearTimeout( onEnterInterval );
+               onEnterInterval = _g_onUpdateFunction = null;
+       }
+});
+
+
+/* ----------------------------------------
+ * Text Editor
+ *  - overlay
+ */
+pettanr.textEditor = pettanr.view.registerApplication( function(){
+       var jqWrap, jqTextarea, jqButton,
+               textElement, onUpdateFunction,
+               ID = 'textEditor',
+               panelX, panelY,
+               instance = this;
+       //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);
+       
+       function clickOK(){
+               textElement && textElement.text( jqTextarea.val() );
+               onUpdateFunction && onUpdateFunction( textElement );
+               pettanr.textEditor.shutdown();
+       }
+       
+       function keyCancel( e ){
+               if( e.keyCode === 69 && e.shiftKey === false && e.ctrlKey === true){
+                       clickOK();
+                       e.preventDefault();
+               e.keyCode = 0;
+               e.cancelBubble = true;
+               e.returnValue = false;
+                       return false;
+               }       
+       }
+       
+       /* grobal method */
+       // this.rootElement = elmWrap;
+       this.displayName = 'textEditor';
+       this.ID          = 'textEditor';
+       this.rootElement = document.getElementById( 'speach-editor-wrapper' );
+       this.MIN_WIDTH   = 320;
+       this.MIN_HEIGHT  = 320;
+       this.init = function(){
+               instance.jqWrap = jqWrap = $( '#speach-editor-wrapper' ).hide();
+               jqTextarea = $( '#speach-editor' ).keydown( keyCancel );
+               jqButton = $( '#speach-edit-complete-button').click( clickOK );
+               delete instance.init;
+       }
+       this.jqWrap = null;
+       this.onOpen = function( _w, _h, _panelX, _panelY, _textElement, _onUpdateFunction ){
+               instance.init && instance.init();
+               
+               panelX = _panelX;
+               panelY = _panelY;
+               textElement = _textElement;
+               onUpdateFunction = _onUpdateFunction || null;
+               
+               var h = _textElement.h;
+               
+               instance.onPaneResize( _w, _h );
+               jqTextarea.val( _textElement.text() ).focus();
+               
+               /*
+                * ie6,7は、textarea { width:100%}でも高さが変わらない。rowsを設定。
+                */
+               pettanr.ua.isIE === true && pettanr.ua.ieVersion <= 7 && setTimeout( function(){
+                       var rows = 0;
+                       while( jqTextarea.height() < h){
+                               rows++;
+                               jqTextarea.attr( 'rows', rows);
+                       }
+                       rows > 1 && jqTextarea.attr( 'rows', rows -1 );
+               }, 0);
+       }
+       this.onPaneResize = function( _w, _h ){
+               jqWrap.show().css( {
+                       left:                   textElement.x + panelX,
+                       top:                    textElement.y + panelY,
+                       width:                  textElement.w,
+                       height:                 textElement.h
+               });
+       }
+       this.onClose = function(){
+               jqWrap.hide();
+               textElement = onUpdateFunction = null;          
+       }
+});
+
+// i18n
+// login
+// lib
+
+pettanr.fn( pettanr.view);
+pettanr.fn( pettanr.overlay);
+pettanr.fn( pettanr.key);
+pettanr.fn( pettanr.balloon);
+
+pettanr.fn( pettanr.editor);
+
+pettanr.fn( pettanr.file);
+pettanr.fn( pettanr.finder);
+pettanr.fn( pettanr.gallery);
+pettanr.fn( pettanr.cabinet);
+
+$(window).ready( pettanr.init);
diff --git a/app/assets/javascripts/work.js b/app/assets/javascripts/work.js
new file mode 100644 (file)
index 0000000..84e4a21
--- /dev/null
@@ -0,0 +1,3723 @@
+/*\r
+ * pettanR work.js\r
+ *   version 0.4.19\r
+ *   \r
+ * author:\r
+ *   itozyun\r
+ * licence:\r
+ *   3-clause BSD\r
+ *\r
+ * \r
+ * ----------------------------------------\r
+ * naming rules\r
+ * \r
+ *  Class\r
+ *    ThisIsClass\r
+ *  \r
+ *  const\r
+ *    THIS_IS_CONST = 'this is const';\r
+ *  \r
+ *  var\r
+ *    thisIsVar\r
+ *   \r
+ *  value of jquery\r
+ *    jqWrapper, JQ_WRAPPER\r
+ *  \r
+ *  value of dom element\r
+ *    elmWrapper, ELM_WRAP\r
+ * \r
+ *     value of vml element\r
+ *    vmlImg, VML_SHAPE\r
+ * \r
+ */\r
+\r
+\r
+/* ----------------------------------------\r
+ *   pettanr.editor\r
+ *    - MENU_BAR_CONTROL\r
+ *    - HISTORY_CONTROL\r
+ *    - SAVE_CONTROL\r
+ *    - WINDOW_CONTROL\r
+ *       - WindowClass\r
+ *    - INFOMATION_WINDOW\r
+ *    - TOOL_BOX_WINDOW\r
+ *    - HELP_DOCUMENTS_WINDOW\r
+ *    - PANEL_CONTROL\r
+ *    - GRID_CONTROL\r
+ *    - WHITE_GLASS_CONTROL\r
+ *    - PANEL_CONTROL\r
+ *    \r
+ * \r
+ *    - PanelResizerClass\r
+ *    - PANEL_RESIZER_TOP\r
+ *    - PANEL_RESIZER_BOTTOM\r
+ *    - CONSOLE_CONTROLER\r
+ * \r
+ *    - TAIL_OPERATOR\r
+ *    - RESIZE_OPERATOR\r
+ *    - POSITION_OPERATOR\r
+ *    - COMIC_ELEMENT_OPERATION_MANAGER\r
+ *      \r
+ *    - ImageElementClass\r
+ *    - TextElementClass\r
+ * \r
+ *    - COMIC_ELEMENT_CONTROL\r
+ * \r
+ * \r
+ */\r
+pettanr.editor = pettanr.view.registerApplication( function(){\r
+\r
+       var PANEL_ELEMENT_TYPE_IMAGE = 0,\r
+               PANEL_ELEMENT_TYPE_TEXT = 1,\r
+               MOUSE_LISTENER_ARRAY = [],\r
+               COMIC_ELEMENT_ARRAY = [],\r
+               ELM_MOUSE_EVENT_CHATCHER = document.getElementById( 'mouse-operation-catcher'),\r
+               MIN_PANEL_HEIGHT = 20,\r
+               MIN_ELEMENT_SIZE = 19,\r
+               MOUSE_HIT_AREA = 10,\r
+               jqMouseEventChacher,\r
+               jqEditor,\r
+               windowW, windowH,\r
+               currentListener = null,\r
+               currentCursor = '',\r
+               instance = this,\r
+               option,\r
+               log;\r
+\r
+/* ----------------------------------------\r
+ * MENU BAR\r
+ *  - mouseEventListener\r
+ *  - controler\r
+ * \r
+ * div\r
+ *   div.title\r
+ *   ul\r
+ *     li\r
+ *        a\r
+ *          span\r
+ *          kbd shortcut\r
+ */\r
+       var MENU_BAR_CONTROL = ( function(){\r
+               var ELM_BAR = document.getElementById( 'menu-bar'),\r
+                       ELM_ITEM_CLASSNAME = 'menu-bar-item',\r
+                       ELM_ITEM_ORIGN = ( function(){\r
+                               var ret = document.createElement( 'div'),\r
+                                       div = document.createElement( 'div'),\r
+                                       ul = document.createElement( 'ul');\r
+                               ret.className = ELM_ITEM_CLASSNAME;\r
+                               ret.appendChild( div);\r
+                               ret.appendChild( ul);\r
+                               return ret;\r
+                       })(),\r
+                       ELM_SELECTION_ORIGN = ( function(){\r
+                               var ret = document.createElement( 'li'),\r
+                                       a = document.createElement( 'a'),\r
+                                       span = document.createElement( 'span'),\r
+                                       key = document.createElement( 'kbd');\r
+                               a.appendChild( span);\r
+                               a.appendChild( key);\r
+                               ret.appendChild( a);\r
+                               a.href = '#';\r
+                               return ret;\r
+                       })(),\r
+                       ITEM_ARRAY = [],\r
+                       barH = pettanr.util.getElementSize( ELM_BAR).height,\r
+                       itemW = pettanr.util.getElementSize( ELM_ITEM_ORIGN).width,\r
+                       selectionW = pettanr.util.getElementSize( ELM_ITEM_ORIGN.getElementsByTagName( 'ul')[ 0]).width,\r
+                       jqStage, jqBar;\r
+               ELM_BAR.style.top = ( -barH) +'px';\r
+\r
+               var MenubarSelectionClass = function( container, title, shortcut, visible, separateAfter){\r
+                       var ELM_WRAPPER = ELM_SELECTION_ORIGN.cloneNode( true),\r
+                               ELM_TITLE = ELM_WRAPPER.getElementsByTagName( 'span')[ 0],\r
+                               elmShortcut = ELM_WRAPPER.getElementsByTagName( 'kbd')[ 0];\r
+                               \r
+                       if( shortcut){\r
+                               elmShortcut.innerHTML = shortcut;\r
+                       } else {\r
+                               elmShortcut.parentNode.removeChild( elmShortcut);\r
+                       }\r
+                       elmShortcut = null;\r
+                       \r
+                       container.appendChild( ELM_WRAPPER);\r
+                       \r
+                       updateTitle( title);\r
+                       updateVisible( visible);\r
+                       \r
+                       function updateTitle( _title){\r
+                               ELM_TITLE.innerHTML = title = _title;\r
+                       }\r
+                       function updateVisible( _visible){\r
+                               if( _visible !== undefined){\r
+                                       visible = !!_visible;\r
+                                       ELM_WRAPPER.className = visible === true ? '' : 'disabled';\r
+                               };\r
+                       }\r
+                       return {\r
+                               elm: ELM_WRAPPER,\r
+                               title: function( _title){\r
+                                       _title !== undefined && updateTitle( _title);\r
+                                       return title;\r
+                               },\r
+                               visible: function( _visible){\r
+                                       visible !== !!_visible && updateVisible( _visible);\r
+                                       return visible;\r
+                               },\r
+                               separateAfter: separateAfter\r
+                       }\r
+               }\r
+\r
+               var MenuBarItemClass = function( title){\r
+                       var ELM_WRAPPER = ELM_ITEM_ORIGN.cloneNode( true),\r
+                               ELM_TITLE = ELM_WRAPPER.getElementsByTagName( 'div')[ 0],\r
+                               ELM_SELECTION = ELM_WRAPPER.getElementsByTagName( 'ul')[ 0],\r
+                               INDEX = ITEM_ARRAY.length,\r
+                               SELECTION_CALLBACK_ARRAY = [],\r
+                               numSelection = 0,\r
+                               visible = false;\r
+                       ELM_TITLE.innerHTML = title;\r
+                       \r
+                       ELM_WRAPPER.style.left = ( itemW * INDEX) +'px';\r
+                       ELM_BAR.appendChild( ELM_WRAPPER);\r
+                       \r
+                       function onClick( e){\r
+                               var that = this,\r
+                                       i = pettanr.util.getChildIndex( this.parentNode, this);\r
+                               i !== -1 && this.className !== 'disabled' && SELECTION_CALLBACK_ARRAY[ i]( i);\r
+                               e.stopPropagation();\r
+                               return false;\r
+                       }\r
+                       return {\r
+                               elm: ELM_WRAPPER,\r
+                               onClick: onClick,\r
+                               init: function(){\r
+                                       $( ELM_SELECTION).children( 'li').click( onClick);\r
+                                       delete this.init;\r
+                               },\r
+                               show: function(){\r
+                                       if( visible === true) return;\r
+                                       jqStage.append( ELM_WRAPPER);\r
+                                       ELM_WRAPPER.className = ELM_ITEM_CLASSNAME +'-focus';\r
+                                       this.onShow && setTimeout( this.onShow, 0);\r
+                                       visible = true;\r
+                               },\r
+                               hide: function(){\r
+                                       if( visible === false) return;\r
+                                       ELM_BAR.appendChild( ELM_WRAPPER);\r
+                                       ELM_WRAPPER.className = ELM_ITEM_CLASSNAME;\r
+                                       this.onHide && setTimeout( this.onHide, 0);\r
+                                       visible = false;\r
+                               },\r
+                               createSelection: function( title, shortcut, callback, visible, separateBefore, separateAfter){\r
+                                       var ret = MenubarSelectionClass.apply( {}, [ ELM_SELECTION, title, shortcut, visible, separateAfter]),\r
+                                               before = SELECTION_CALLBACK_ARRAY.length > 0 ? SELECTION_CALLBACK_ARRAY[ SELECTION_CALLBACK_ARRAY.length -1] : null;\r
+                                       SELECTION_CALLBACK_ARRAY.push( callback);\r
+                                       if( before !== null && ( separateBefore === true || before.separateAfter === true)){\r
+                                               ret.elm.style.borderTop = '1px solid #ccc';\r
+                                       }\r
+                                       return ret;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               \r
+               function createMenubarItem( title){\r
+                       var _item = new MenuBarItemClass( title);\r
+                       ITEM_ARRAY.push( _item);\r
+                       return _item;\r
+               }\r
+               return {\r
+                       init: function(){\r
+                               jqStage = jqEditor;\r
+                               jqBar = $( ELM_BAR).animate( { top: 0});\r
+\r
+                               var l = ITEM_ARRAY.length;\r
+                               for( var i=0; i<l; ++i){\r
+                                       ITEM_ARRAY[ i].init();\r
+                               }\r
+\r
+                               delete MENU_BAR_CONTROL.init;\r
+                       },\r
+                       open: function(){\r
+                               MENU_BAR_CONTROL.init && MENU_BAR_CONTROL.init();\r
+                               // ELM_BAR.style.top = ( -barH) +'px';\r
+                               // anime\r
+                       },\r
+                       close: function(){\r
+                               var l = ITEM_ARRAY.length;\r
+                               for( var i=0; i<l; ++i){\r
+                                       ITEM_ARRAY[ i].hide();\r
+                               }\r
+                       },\r
+                       h: barH,\r
+                       onMouseMove: function( _mouseX, _mouseY){\r
+                               if( barH >= _mouseY){\r
+                                       return true;\r
+                               }\r
+                               var l = ITEM_ARRAY.length;\r
+                               for( var i=0; i<l; ++i){\r
+                                       ITEM_ARRAY[ i].hide();\r
+                               }\r
+                               return false;\r
+                       },\r
+                       onMouseUp: function( _mouseX, _mouseY){\r
+                               return false;\r
+                       },\r
+                       onMouseDown: function( _mouseX, _mouseY){\r
+                               var l = ITEM_ARRAY.length;\r
+                               if( barH < _mouseY || itemW * l < _mouseX) return false;\r
+                               for( var i=0; i<l; ++i){\r
+                                       if( i * itemW <= _mouseX && _mouseX < ( i +1) * itemW){\r
+                                               ITEM_ARRAY[ i].show();\r
+                                       } else {\r
+                                               ITEM_ARRAY[ i].hide();\r
+                                       }\r
+                               }\r
+                               return true;\r
+                       },\r
+                       busy: function( _busy){\r
+                               return false;\r
+                       },\r
+                       onWindowResize: function( _windowW, _windowH){\r
+                               \r
+                       },\r
+                       QUIT: createMenubarItem( 'Quit'),\r
+                       EDIT: createMenubarItem( 'Edit'),\r
+                       WINDOW: createMenubarItem( 'Window'),\r
+                       HELP: pettanr.util.extend( createMenubarItem( 'Help'), {\r
+                                       createAjaxSelection: function( callback){\r
+                                               var elmLoading = document.createElement( 'li'),\r
+                                                       that = this,\r
+                                                       elmSelection = this.elm.getElementsByTagName( 'ul')[ 0];\r
+                                               elmSelection.appendChild( elmLoading);\r
+                                               elmLoading.className = 'loading';\r
+                                               elmLoading.style.height = '90px';                                                       \r
+\r
+                                               this.onShow = callback;\r
+                                               callback = null;\r
+                                               \r
+                                               delete this.createAjaxSelection;\r
+                                               return function(){\r
+                                                       elmSelection.removeChild( elmLoading);\r
+                                                       $( elmSelection).children( 'li').click( that.onClick);\r
+                                                       elmLoading = elmSelection = null;\r
+                                                       delete that.onShow;\r
+                                                       that = null;\r
+                                               }\r
+                                       }\r
+                               })\r
+               }\r
+       })();\r
+\r
+\r
+/* ----------------------------------------\r
+ * HISTORY_CONTROL\r
+ *  - controler\r
+ */\r
+       var HISTORY_CONTROL = ( function() {\r
+               var     STACK_BACK = [],\r
+                       STACK_FORWARD = [],\r
+                       MENUBAR_BACK = MENU_BAR_CONTROL.EDIT.createSelection( 'back', 'ctrl + z', back, false),\r
+                       MENUBAR_FORWARD = MENU_BAR_CONTROL.EDIT.createSelection( 'forward', 'ctrl + y', forward, false, false, true),\r
+                       log;\r
+                       \r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 90, false, true, back);       // ctrl + Z\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 90, true, true, forward);     // ctrl + shift + Z\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 89, false, true, forward); // ctrl + Y\r
+\r
+               function back(){\r
+                       /*\r
+                        * currentを控えてSTACK_FORWARD.push(current)\r
+                        * STACK_BACK.pop()を実行してcurrentに\r
+                        */\r
+                       if( STACK_BACK.length === 0) return;\r
+\r
+                       var state = STACK_BACK.pop();\r
+                       state && state.fn( state.argBack);\r
+                       MENUBAR_BACK.visible( STACK_BACK.length !== 0);\r
+                       SAVE_CONTROL.panelUpdated( STACK_BACK.length !== 0);\r
+                       \r
+                       STACK_FORWARD.push( state);\r
+                       MENUBAR_FORWARD.visible( true);\r
+               }\r
+               function forward(){\r
+                       if( STACK_FORWARD.length === 0) return;\r
+                       \r
+                       var state = STACK_FORWARD.pop();\r
+                       state.fn( state.argForword);\r
+                       MENUBAR_FORWARD.visible( STACK_FORWARD.length !== 0);\r
+                       \r
+                       STACK_BACK.push( state);\r
+                       MENUBAR_BACK.visible( true);\r
+                       SAVE_CONTROL.panelUpdated( true);\r
+               }\r
+               function destroyStack( _stack, _destroy){\r
+                       _stack.fn = null;\r
+                       \r
+                       var     _argBack = _stack.argBack,\r
+                               _argForword = _stack.argForword,\r
+                               _value;\r
+                       if( Type.isArray( _argBack ) === true ){ // isArray\r
+                               while( _argBack.length > 0){\r
+                                       _value = _argBack.shift();\r
+                                       _destroy === true && typeof _value.destroy === 'function' && _value.destroy();\r
+                               }\r
+                       }\r
+                       if( Type.isArray( _argForword ) === true ){\r
+                               while( _argForword.length > 0){\r
+                                       _value = _argForword.shift();\r
+                                       _destroy === true && typeof _value.destroy === 'function' && _value.destroy();\r
+                               }                                               \r
+                       }                       \r
+               }\r
+               return {\r
+                       init: function(){\r
+                               log = $( '#history-log');\r
+                               delete HISTORY_CONTROL.init;\r
+                       },\r
+                       open: function(){\r
+                               HISTORY_CONTROL.init && HISTORY_CONTROL.init();\r
+                       },\r
+                       close: function(){\r
+                               MENUBAR_BACK.visible( false);\r
+                               MENUBAR_FORWARD.visible( false);\r
+                       while( STACK_BACK.length > 0){\r
+                                       destroyStack( STACK_BACK.shift(), true);\r
+                               }\r
+                       while( STACK_FORWARD.length > 0){\r
+                                       destroyStack( STACK_FORWARD.shift(), true);\r
+                               }\r
+                       },\r
+                   saveState: function( _function, _argBack, _argForword, _destroy) {\r
+                       STACK_BACK.push( {\r
+                               fn:                     _function,\r
+                               argBack:        _argBack,\r
+                                       argForword:     _argForword,\r
+                                       destroy:        _destroy\r
+                       });\r
+                       MENUBAR_BACK.visible( true);\r
+                               SAVE_CONTROL.panelUpdated( true);\r
+                               \r
+                               var _stack;\r
+                       while( STACK_FORWARD.length > 0){\r
+                                       _stack = STACK_FORWARD.shift();\r
+                                       destroyStack( _stack, _stack.destroy);\r
+                               }\r
+                               MENUBAR_FORWARD.visible( false);\r
+                   }           \r
+               }\r
+       })();\r
+\r
+/* ----------------------------------------\r
+ * SAVE_CONTROL\r
+ *  - controler\r
+ */\r
+       var SAVE_CONTROL = ( function(){\r
+               var SAVE = MENU_BAR_CONTROL.QUIT.createSelection( 'save', 'ctrl + S', quit, false),\r
+                       SAVE_AND_QUIT = MENU_BAR_CONTROL.QUIT.createSelection( 'save & quit', null, quit, false, false, true),\r
+                       SAVE_AS_HTML = MENU_BAR_CONTROL.QUIT.createSelection( 'get as html', null, outputAsHtml, true, false, true),\r
+                       SAVE_AS_JSON_STRING = MENU_BAR_CONTROL.QUIT.createSelection( 'get JsonStr', null, outputAsJsonString, true, false, true),\r
+                       QUIT = MENU_BAR_CONTROL.QUIT.createSelection( 'quit', null, quit, true, true),\r
+                       updated = false;\r
+               \r
+               function quit(){\r
+                       // 本来は os.application.close();\r
+                       pettanr.editor.shutdown();\r
+               }\r
+               \r
+               function outputAsHtml(){\r
+                       pettanr.outputConsole.bootInOverlay( COMIC_ELEMENT_CONTROL.getAsHTML( true, false));\r
+               }\r
+               function outputAsJsonString(){\r
+                       pettanr.outputConsole.bootInOverlay( COMIC_ELEMENT_CONTROL.getAsJsonString());\r
+               }\r
+               return {\r
+                       open: function(){},\r
+                       close: function(){},\r
+                       quit: quit,\r
+                       panelUpdated: function( _updated){\r
+                               if( _updated !== undefined && updated !== _updated ){\r
+                                       SAVE.visible( !!_updated );\r
+                                       SAVE_AND_QUIT.visible( !!_updated );\r
+                                       updated = !!_updated;\r
+                               }\r
+                               return updated;\r
+                       },\r
+                       save: function(){\r
+                               \r
+                       }\r
+               }\r
+       })();\r
+\r
+/* ----------------------------------------\r
+ * WINDOWS_CONTROL\r
+ *  - contloler\r
+ *  - mouseEventListener\r
+ */    \r
+       var WINDOWS_CONTROL = ( function(){\r
+               /*\r
+                *  表示上手前にあるwindowは、WINDOW_ARRAYの先頭にあり、htmlでは後ろにある。\r
+                */\r
+               var DEFAULT_MIN_WINDOW_WIDTH = 200,\r
+                       DEFAULT_MIN_WINDOW_HEIGHT = 200,\r
+                       WINDOW_ARRAY = [],\r
+                       WINDOW_BODY_BODER_SIZE = 1,\r
+                       jqContainer,\r
+                       currentWindow,\r
+                       currentWindowIndex = -1,\r
+                       log;\r
+\r
+               var jqWindowOrigin,\r
+                       closeButtonWidth;\r
+               var WindowClass = function( bodyTempleteID, title, x, y, w, h, visible, CLOSE_BUTTON_ENABLED, RESIZE_BUTTON_ENABLED, minWindowW, minWindowH){\r
+                       var MOUSE_CURSOR = updateMouseCursor,\r
+                               MENUBAR_SELWCTION = MENU_BAR_CONTROL.WINDOW.createSelection( \r
+                                       ( visible !== true ? 'show ' : 'hide ') +title,\r
+                                       null, onMenuClick, true\r
+                               ),\r
+                               jqStage,\r
+                               jqWrapper, jqHeader, jqFooter = null,\r
+                               elmBody, elmBodyStyle,\r
+                               startX, startY, startW, startH,\r
+                               offsetX, offsetY,\r
+                               headerH, bodyH, footerH = 0,\r
+                               isDragging = false,\r
+                               isResizing = false,\r
+                               bodyIsTachable = false,\r
+                               instance;\r
+\r
+                       function onMenuClick(){\r
+                               visible === true ? instance.close() : instance.open();\r
+                       }\r
+                       function update( _x, _y, _w, _h){\r
+                               _x = _x !== undefined ? _x : x;\r
+                               _y = _y !== undefined ? _y : y;\r
+                               _y = _y > MENU_BAR_CONTROL.h ? _y : MENU_BAR_CONTROL.h;\r
+                               _w = _w !== undefined ? _w : w;\r
+                               _h = _h !== undefined ? _h : h;\r
+                               jqWrapper.css( {\r
+                                       left:           _x,\r
+                                       top:            _y,\r
+                                       width:          _w,\r
+                                       height:         _h\r
+                               });\r
+                               bodyH = _h -headerH -footerH;\r
+                               elmBodyStyle.height = bodyH +'px';\r
+                               ( w !== _w || h !== _h) && instance.onResize && instance.onResize( _w, bodyH);\r
+                               x = _x;\r
+                               y = _y;\r
+                               w = _w;\r
+                               h = _h;\r
+                       }\r
+                       function bodyBackOrForward( isBack){\r
+                               if( !instance) return;\r
+                               if( bodyIsTachable === !isBack) return;\r
+                               elmBodyStyle.position = isBack === true ? 'relative' : 'absolute';\r
+                               elmBodyStyle.left =             isBack === true ? 0  : x +'px';\r
+                               elmBodyStyle.top =              isBack === true ? 0  : y +headerH +'px';\r
+                               elmBodyStyle.width =    isBack === true ? '' : ( w -WINDOW_BODY_BODER_SIZE *2) +'px';\r
+                               bodyIsTachable === isBack && isBack === true ? jqHeader.after( elmBody) : jqStage.append( elmBody);\r
+                               bodyIsTachable = !isBack;\r
+                       }\r
+                       function onWindowResize( e){\r
+                               bodyBackOrForward( true);\r
+                               isResizing = true;\r
+                               startX = x;\r
+                               startY = y;\r
+                               startW = w;\r
+                               startH = h;\r
+                               offsetX = e.pageX;\r
+                               offsetY = e.pageY;\r
+                               MOUSE_CURSOR( 'nw-resize');\r
+                               e.stopPropagation();\r
+                               return false;\r
+                       }\r
+                       return {\r
+                               init: function( jqContainer){\r
+                                       /*\r
+                                        * setTimeout で呼ばれるグローバルメソッド内では、this でなく instance を使う.\r
+                                        */\r
+                                       instance = this;\r
+                                       \r
+                                       jqWindowOrigin = jqWindowOrigin || ( function(){\r
+                                               return $( $( '#windowTemplete').remove().html());\r
+                                       })();\r
+                                       closeButtonWidth = closeButtonWidth || ( function(){\r
+                                               return pettanr.util.getElementSize( jqWindowOrigin.clone( true).find( '.window-close-button').get( 0)).width;\r
+                                       })();\r
+                                       \r
+                                       jqStage = jqEditor;\r
+                                       this.$ = jqWrapper = jqWindowOrigin.clone( true);\r
+                                       jqHeader = jqWrapper.children( '.window-header').eq( 0).html( title);\r
+                                       headerH = pettanr.util.getElementSize( jqHeader.get( 0)).height;\r
+                                       elmBody = jqWrapper.children( '.window-body').get( 0);\r
+                                       elmBodyStyle = elmBody.style;\r
+                                       \r
+                                       if( bodyTempleteID) {\r
+                                               jqWrapper.find( '.window-body-insert-position').replaceWith( $( $( '#' +bodyTempleteID).remove().html()));\r
+                                       } else {\r
+                                               jqWrapper.find( '.window-body-insert-position').remove();\r
+                                       }\r
+                                       CLOSE_BUTTON_ENABLED !== true && jqWrapper.find( '.window-close-button').remove();\r
+                                       \r
+                                       this.onInit && this.onInit();\r
+                                       delete this.init;\r
+                               },\r
+                               x: function(){ return x;},\r
+                               y: function(){ return y;},\r
+                               w: function(){ return w;},\r
+                               h: function(){ return h;},\r
+                               $: null,\r
+                               title: function( _title){\r
+                                       typeof _title === 'string' && jqHeader.html( _title);\r
+                                       title = typeof _title === 'string' ? _title : title;\r
+                                       return title;\r
+                               },\r
+                               visible: visible,\r
+                               firstOpen: function(){\r
+                                       if( RESIZE_BUTTON_ENABLED === true){\r
+                                               footerH = pettanr.util.getElementSize( jqWrapper.find( '.window-footer').get( 0)).height;\r
+                                               //jqWrapper.find( '.window-resize-button').eq( 0).mousedown( onWindowResize);\r
+                                       } else {\r
+                                               jqWrapper.find( '.window-footer').remove();\r
+                                       }\r
+                                       this.onFirstOpen && this.onFirstOpen( w, h -headerH -footerH);\r
+                                       \r
+                                       update( x, y, w, h);\r
+                                       \r
+                                       delete this.firstOpen;\r
+                               },\r
+                               open: function(){\r
+                                       if( visible === true) return;\r
+                                       instance.visible = visible = true;\r
+                                       openWindow( instance);\r
+                                       MENUBAR_SELWCTION.title( 'hide ' +title);\r
+                                       \r
+                                       for( var i=0, l = WINDOW_ARRAY.length; i<l; ++i){\r
+                                               if( WINDOW_ARRAY[ i] === instance){\r
+                                                       WINDOW_ARRAY.splice( i, 1);\r
+                                                       WINDOW_ARRAY.unshift( instance);\r
+                                                       currentWindow = null;\r
+                                                       currentWindowIndex = -1;\r
+                                               }\r
+                                       }\r
+                               },\r
+                               onFadeIn: function(){\r
+                                       instance.firstOpen && instance.firstOpen();\r
+                                       instance.onOpen && setTimeout( callOnOpen, 0);\r
+                                       function callOnOpen(){\r
+                                               instance.onOpen( w, bodyH);\r
+                                       }\r
+                               },\r
+                               onFadeOut: function(){\r
+                                       var elmWrapper = jqWrapper.get(0);\r
+                                       elmWrapper.parentNode.removeChild( elmWrapper);\r
+                                       instance.onClose && setTimeout( instance.onClose, 0);\r
+                               },\r
+                               close: function(){\r
+                                       if( visible === false) return;\r
+                                       instance.visible = visible = false;\r
+                                       jqWrapper.fadeOut( instance.onFadeOut);\r
+                                       MENUBAR_SELWCTION.title( 'show ' +title);\r
+                               },\r
+                               bodyBackOrForward: bodyBackOrForward,\r
+                               onMouseDown: function( _mouseX, _mouseY){\r
+                                       if( RESIZE_BUTTON_ENABLED === true && x +w -20 <= _mouseX && _mouseX < x +w && y +headerH +bodyH < _mouseY && _mouseY <= y +h){\r
+                                               bodyBackOrForward( true);\r
+                                               isResizing = true;\r
+                                               startX = x;\r
+                                               startY = y;\r
+                                               startW = w;\r
+                                               startH = h;\r
+                                               offsetX = _mouseX;\r
+                                               offsetY = _mouseY;\r
+                                               MOUSE_CURSOR( 'nw-resize');\r
+                                               return;\r
+                                       }\r
+                                       \r
+                                       if( x > _mouseX || y > _mouseY || x +w < _mouseX || y +headerH < _mouseY ) return;\r
+                                       if( CLOSE_BUTTON_ENABLED === true && x +w -closeButtonWidth < _mouseX){\r
+                                               instance.close();\r
+                                               return;\r
+                                       }\r
+                                       \r
+                                       isDragging = true;\r
+                                       MOUSE_CURSOR( 'move');                          \r
+                                       startX = x;\r
+                                       startY = y;\r
+                                       startW = w;\r
+                                       startH = h;\r
+                                       offsetX = _mouseX;\r
+                                       offsetY = _mouseY;\r
+                               },\r
+                               onMouseUp: function( _mouseX, _mouseY){\r
+                                       isDragging = isResizing = false;\r
+                                       MOUSE_CURSOR( '');\r
+                               },\r
+                               onMouseMove: function( _mouseX, _mouseY){\r
+                                       var _updateX = _mouseX -offsetX,\r
+                                               _updateY = _mouseY -offsetY;\r
+                                       \r
+                                       if( isResizing === true){\r
+                                               var _w = startW +_updateX,\r
+                                                       _h = startH +_updateY;\r
+                                               update( startX, startY, _w < minWindowW ? minWindowW : _w, _h < minWindowH ? minWindowH : _h);\r
+                                               return;\r
+                                       } else\r
+                                       if( isDragging === true) {\r
+                                               update( startX +_updateX, startY +_updateY);\r
+                                               return;\r
+                                       } else\r
+                                       if( x > _mouseX || x +w < _mouseX ) return;\r
+       \r
+                                       ( y <= _mouseY && y +headerH >= _mouseY ) ?\r
+                                               MOUSE_CURSOR( 'pointer') :      // hit to header\r
+                                               MOUSE_CURSOR( '');\r
+                                       bodyBackOrForward( y +headerH > _mouseY || y +headerH +bodyH < _mouseY);\r
+                               },\r
+                               onMouseOut: function( _mouseX, _mouseY){\r
+                                       bodyIsTachable === true && bodyBackOrForward( true);\r
+                                       isDragging = false;\r
+                                       MOUSE_CURSOR( '');\r
+                               },\r
+                               busy: function(){\r
+                                       return isDragging === true || isResizing === true;\r
+                               },\r
+                               bodyHeight: function(){\r
+                                       return  bodyH;\r
+                               }\r
+                       }\r
+               };\r
+               \r
+               function getCurrentIndex( _mouseX, _mouseY){\r
+                       if( currentWindow && currentWindow.busy() === true) return currentWindowIndex;\r
+                       var l = WINDOW_ARRAY.length,\r
+                               _currentWindow = null,\r
+                               _win, _x, _y;\r
+                       currentWindowIndex = -1;\r
+                       for( var i=0; i<l; i++){\r
+                               _win = WINDOW_ARRAY[ i];\r
+                               if( _win.visible !== true) continue;\r
+                               _x = _win.x();\r
+                               _y = _win.y();\r
+                               if( _x <= _mouseX && _y <= _mouseY && _x +_win.w() >= _mouseX && _y +_win.h() >= _mouseY){\r
+                                       _currentWindow = _win;\r
+                                       currentWindowIndex = i;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       currentWindow && currentWindow !== _currentWindow && currentWindow.onMouseOut( _mouseX, _mouseY);\r
+                       currentWindow = _currentWindow;\r
+                       return currentWindowIndex;\r
+               }\r
+               function openWindow( _window){\r
+                       if( _window.visible !== true) return;\r
+                       var _jqWindow = _window.$;\r
+                       jqContainer.append( _jqWindow);// appendした後に fadeIn() しないと ie で filterが適用されない.\r
+                       _jqWindow.fadeIn( _window.onFadeIn);\r
+                       return;\r
+               }\r
+               \r
+               return {\r
+                       init: function(){\r
+                               jqContainer = $( '#window-container');\r
+                               \r
+                               var l = WINDOW_ARRAY.length,\r
+                                       _window;\r
+                               for( var i=l-1; i >= 0; --i){\r
+                                       _window = WINDOW_ARRAY[ i];\r
+                                       _window.init && _window.init( jqContainer);\r
+                                       _window.visible === true && openWindow( _window);\r
+                               }\r
+                               log = $( '#window-log');\r
+                               \r
+                               delete WINDOWS_CONTROL.init;\r
+                       },\r
+                       open: function(){\r
+                               WINDOWS_CONTROL.init && WINDOWS_CONTROL.init();\r
+                       },\r
+                       close: function(){\r
+                               \r
+                       },\r
+                       onMouseMove: function( _mouseX, _mouseY){\r
+                               var _index = getCurrentIndex( _mouseX, _mouseY);\r
+                               if( _index === 0){\r
+                                       currentWindow.onMouseMove( _mouseX, _mouseY);\r
+                                       return true;\r
+                               } else\r
+                               if( _index > 0){ // 先頭のクリックでない場合\r
+                               // Array を前に\r
+                                       WINDOW_ARRAY.splice( currentWindowIndex, 1);\r
+                                       WINDOW_ARRAY.unshift( currentWindow);\r
+                               // Domを最後に\r
+                                       jqContainer.append( currentWindow.$);\r
+                                       currentWindowIndex = 0;\r
+                                       return true;\r
+                               }\r
+                               return false;\r
+                       },\r
+                       onMouseUp: function( _mouseX, _mouseY){\r
+                               if( getCurrentIndex( _mouseX, _mouseY) === 0){\r
+                                       currentWindow.onMouseUp( _mouseX, _mouseY);\r
+                                       return true;\r
+                               }\r
+                               return false;\r
+                       },\r
+                       onMouseDown: function( _mouseX, _mouseY){\r
+                               if( getCurrentIndex( _mouseX, _mouseY) === 0){\r
+                                       currentWindow.onMouseDown( _mouseX, _mouseY);\r
+                                       return true;\r
+                               }\r
+                               return false;\r
+                       },\r
+                       busy: function(){\r
+                               return currentWindow !== null;\r
+                       },\r
+                       onWindowResize: function( _windowW, _windowH){\r
+                               /*\r
+                                * 画面外に出るwindowの移動\r
+                                */\r
+                       },\r
+                       createWindow: function( EXTENDS, bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeButtonEnabled, opt_resizeButtonEnabled, opt_minWindowW, opt_minWindowH){\r
+                               opt_visible = opt_visible !== false;\r
+                               opt_closeButtonEnabled = opt_closeButtonEnabled === true;\r
+                               opt_resizeButtonEnabled = opt_resizeButtonEnabled === true;\r
+                               opt_minWindowW = opt_minWindowW || ( w < DEFAULT_MIN_WINDOW_WIDTH) ? w : DEFAULT_MIN_WINDOW_WIDTH;\r
+                               opt_minWindowH = opt_minWindowH || ( h < DEFAULT_MIN_WINDOW_HEIGHT) ? h : DEFAULT_MIN_WINDOW_HEIGHT;\r
+                               \r
+                               var _window = pettanr.util.extend(\r
+                                       new WindowClass(\r
+                                               bodyTempleteID, title, x, y, w, h, opt_visible, opt_closeButtonEnabled, opt_resizeButtonEnabled, opt_minWindowW, opt_minWindowH\r
+                                       ),\r
+                                       EXTENDS\r
+                               );\r
+                               WINDOW_ARRAY.unshift( _window);\r
+                               WINDOWS_CONTROL.init === undefined && _window.init( jqContainer);\r
+                               WINDOWS_CONTROL.init === undefined && openWindow( _window);\r
+                               return _window;\r
+                       }\r
+               }\r
+       })();\r
+\r
+/* ----------------------------------------\r
+ * TOOL_BOX_WINDOW\r
+ * - window\r
+ */\r
+       var TOOL_BOX_WINDOW = ( function(){\r
+               var addImageButton, addTextButton, editBgButton, switchGridButton, popupHelpButton, postButton,\r
+                       instance;\r
+                       \r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 73, false, true, addImage);\r
+               MENU_BAR_CONTROL.EDIT.createSelection( 'Add Image', 'ctrl + I', addImage, true, true, false);\r
+               \r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 84, false, true, addText);\r
+               MENU_BAR_CONTROL.EDIT.createSelection( 'Add Text', 'ctrl + T', addText, true, false, true);\r
+\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 71, false, true, switchGrid);\r
+               MENU_BAR_CONTROL.EDIT.createSelection( 'show Grid', 'ctrl + G', switchGrid, true, true, true);\r
+\r
+               function addImage( e){\r
+                       setTimeout( COMIC_ELEMENT_CONTROL.createImageElement, 0);\r
+                       e && e.preventDefault && e.preventDefault();\r
+                       return false;\r
+               }\r
+               function addText( e){\r
+                       setTimeout( COMIC_ELEMENT_CONTROL.createTextElement, 0);\r
+                       e && e.preventDefault && e.preventDefault();\r
+                       return false;\r
+               }\r
+               function switchGrid( e){\r
+                       setTimeout( GRID_CONTROL.update, 0);\r
+                       e && e.preventDefault && e.preventDefault();\r
+                       return false;\r
+               }\r
+               function popupHelp( e){\r
+                       instance.bodyBackOrForward( true);\r
+                       setTimeout( HELP_DOCUMENTS_WINDOW.open, 0);\r
+                       e && e.preventDefault && e.preventDefault();\r
+                       return false;\r
+               }\r
+               function editBG( e){\r
+                       instance.bodyBackOrForward( true);\r
+                       setTimeout( INFOMATION_WINDOW.open, 0); \r
+                       e && e.preventDefault && e.preventDefault();\r
+                       return false;\r
+               }\r
+               \r
+               return WINDOWS_CONTROL.createWindow(\r
+                       {\r
+                               onInit: function(){\r
+                                       instance = this;\r
+                                       delete this.onInit;\r
+                               },\r
+                               onFirstOpen: function(){\r
+                                       addImageButton = $( '#toolbox-add-image-button').click( addImage);\r
+                                       addTextButton = $( '#toolbox-add-text-button').click( addText);\r
+                                       editBgButton = $( '#toolbox-edit-bg-button').click( editBG);\r
+                                       switchGridButton = $( '#toolbox-switch-grid').click( switchGrid);\r
+                                       popupHelpButton = $( '#toolbox-popup-help-button').click( popupHelp);\r
+                                       \r
+                                       postButton = $( '#toolbox-post-button');\r
+                                       \r
+                                       delete this.onFirstOpen;\r
+                               }\r
+                       },\r
+                       'toolbox-window', 'Tool box', 0, 215, 110, 290, true\r
+               );\r
+       })();\r
+       \r
+       \r
+/* ----------------------------------------\r
+ * IMAGE_EXPROLER\r
+ *  - window\r
+ */\r
+       var IMAGE_EXPLORER_WINDOW = ( function(){\r
+               var instance, finder;\r
+               \r
+               return WINDOWS_CONTROL.createWindow(\r
+                       {\r
+                               onInit: function(){\r
+                                       instance = this;\r
+                                       delete this.onInit;\r
+                               },\r
+                               onOpen: function( _w, _h){\r
+                                       finder = finder || pettanr.finder.createFinder( document.getElementById( 'image-exproler-container'), pettanr.driver.createPictureTree());\r
+                                       finder.open( _w, _h );\r
+                               },\r
+                               onResize: function( _w, _h ){\r
+                                       finder.resize( _w, _h );\r
+                               }\r
+                       },\r
+                       'image-exproler', 'Album', 0, 215, 400, 350, false, true, true, 300, 300\r
+               );\r
+       })();\r
+       \r
+       \r
+/* ----------------------------------------\r
+ * INFOMATION_WINDOW\r
+ *  - window\r
+ */                    \r
+       var INFOMATION_WINDOW = ( function(){\r
+               var FADE_EFFECT_ENABLED = true, //pettanr.ua.isIE === false || pettanr.ua.ieVersion >= 8,\r
+                       FADE_IN_EFFECT = FADE_EFFECT_ENABLED === true ? 'fadeIn' : 'show',\r
+                       FADE_OUT_EFFECT = FADE_EFFECT_ENABLED === true ? 'fadeOut' : 'hide',\r
+                       backgroundInfomationElm,\r
+                       jqComicElementInformation,\r
+                       inputX, inputY, inputZ, inputA, inputW, inputH, inputAspectRatio,\r
+                       inputPercentW, inputPercentH,\r
+                       currentComicElement = null,\r
+                       currentElementType = -1,\r
+                       currentLock = false;\r
+\r
+               return WINDOWS_CONTROL.createWindow(\r
+                       {\r
+                               onFirstOpen: function( _w, _h){\r
+                                       backgroundInfomationElm = $( '#panel-background-information');\r
+                                       \r
+                                       jqComicElementInformation = $( '#comic-element-infomation').hide().css( {\r
+                                               height:         _h\r
+                                       });\r
+                                       var TAB_GROUP_ID = 'comic-element-attribute';\r
+                                       var CREATER = pettanr.form.createInputText;//pettanr.key.createEditableText;\r
+                                       inputX = CREATER( document.getElementById( 'comic-element-x'), null, TAB_GROUP_ID);\r
+                                       inputY = CREATER( document.getElementById( 'comic-element-y'), null, TAB_GROUP_ID);\r
+                                       inputZ = CREATER( document.getElementById( 'comic-element-z'), null, TAB_GROUP_ID);\r
+                                       inputA = CREATER( document.getElementById( 'comic-element-a'), null, TAB_GROUP_ID);\r
+                                       inputW = CREATER( document.getElementById( 'comic-element-w'), null, TAB_GROUP_ID);\r
+                                       inputH = CREATER( document.getElementById( 'comic-element-h'), null, TAB_GROUP_ID);\r
+                                       inputPercentW = CREATER( document.getElementById( 'comic-element-w-percent'), null, TAB_GROUP_ID);\r
+                                       inputPercentH = CREATER( document.getElementById( 'comic-element-h-percent'), null, TAB_GROUP_ID);\r
+                                       inputAspectRatio = $( '#comic-element-keep-aspect');\r
+                                       delete this.onFirstOpen;\r
+                               },\r
+                               onResize: function(  _w, _h){\r
+                                       jqComicElementInformation.css( {\r
+                                               height: _h\r
+                                       });\r
+                               },\r
+                               update: function( currentElement){\r
+                                       \r
+                                       if( currentLock === true && currentElement === null) return;\r
+                                       \r
+                                       var _elementType = currentElement === null ? -1 : currentElement.type,\r
+                                               x = currentElement !== null ? currentElement.x : 0,\r
+                                               y = currentElement !== null ? currentElement.y : 0,\r
+                                               z = currentElement !== null ? currentElement.z : 0,\r
+                                               a = _elementType === PANEL_ELEMENT_TYPE_TEXT ? Math.floor( currentElement.angle()) : 0,\r
+                                               w = currentElement !== null ? currentElement.w : 0,\r
+                                               h = currentElement !== null ? currentElement.h : 0,\r
+                                               actualW = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualW() : 1,\r
+                                               actualH = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? currentElement.actualH() : 1,\r
+                                               wPercent = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( w / actualW *100) : 0,\r
+                                               hPercent = _elementType === PANEL_ELEMENT_TYPE_IMAGE ? Math.floor( h / actualH *100) : 0,\r
+                                               keepAspect = currentElement !== null && currentElement.keepAspect === true;\r
+                                       \r
+                                       if( currentElementType !== _elementType){\r
+                                               if( _elementType !== -1){\r
+                                                       if( _elementType === 1){\r
+                                                               inputA.visible( true);\r
+                                                               inputPercentW.visible( false);\r
+                                                               inputPercentH.visible( false);\r
+                                                               inputAspectRatio.hide();\r
+                                                       } else {\r
+                                                               inputA.visible( false);\r
+                                                               inputPercentW.visible( true);\r
+                                                               inputPercentH.visible( true);\r
+                                                               inputAspectRatio.show();\r
+                                                       }\r
+                                                       currentElementType === -1 && jqComicElementInformation.stop().css( {\r
+                                                               filter:         '',\r
+                                                               opacity:        ''\r
+                                                       })[ FADE_IN_EFFECT]();\r
+                                               } else {\r
+                                                       currentElementType !== -1 && jqComicElementInformation.stop().css({\r
+                                                               filter:         '',\r
+                                                               opacity:        ''\r
+                                                       })[ FADE_OUT_EFFECT]();\r
+                                               }\r
+                                               currentElementType = _elementType;\r
+                                       }\r
+                                       if( currentElementType !== -1){\r
+                                               inputX.value( x);\r
+                                               inputY.value( y);\r
+                                               inputZ.value( z);\r
+                                               _elementType === 1 && inputA.value( a);\r
+                                               inputW.value( w);\r
+                                               inputH.value( h);\r
+                                               _elementType === 0 && inputPercentW.value( wPercent);\r
+                                               _elementType === 0 && inputPercentH.value( hPercent);                                   \r
+                                       } else {\r
+                                               \r
+                                       }\r
+                               },\r
+                               lock: function( _currentLock){\r
+                                       currentLock = !!_currentLock;\r
+                                       this.bodyBackOrForward( !currentLock);\r
+                               }\r
+                       },\r
+                       'infomation-window', 'Infomation', 0, 30, 200, 180, true\r
+               );\r
+       })();\r
+\r
+/* ----------------------------------------\r
+ * HELP_WINDOW\r
+ *  - window\r
+ */\r
+       var HELP_DOCUMENTS_WINDOW = ( function(){\r
+               var visible = true,\r
+                       jqAjaxContents,\r
+                       jqNaviItems,\r
+                       jqPages,\r
+                       currentPageIndex = 0,\r
+                       numPage = 0,\r
+                       HELP = MENU_BAR_CONTROL.HELP,\r
+                       onLoadFunction = HELP.createAjaxSelection( onAjaxStart),\r
+                       instance;\r
+\r
+               function onAjaxStart( _pageIndex){\r
+                       currentPageIndex = _pageIndex || currentPageIndex;\r
+                       if( onHelpLoad !== null){\r
+                               $.ajax({\r
+                                       url:            'help/jp.xml',\r
+                                       dataType:       'xml',\r
+                                       success:        onHelpLoad\r
+                               });\r
+                               onHelpLoad = null;\r
+                       }\r
+                       onAjaxStart = new Function;\r
+               }\r
+               var onHelpLoad = function( _xml){\r
+                       var jqXML = $( _xml),\r
+                               helpTitle = jqXML.find( 'pages').eq( 0).attr( 'title'),\r
+                               elmNavi = document.createElement( 'div'),\r
+                               elmItemOrigin = document.createElement( 'a'),\r
+                               elmPages = document.createElement( 'div'),\r
+                               elmPageOrigin = document.createElement( 'div'),\r
+                               elmTitleOrigin = document.createElement( 'h2'),\r
+                               elmPage;\r
+                       elmNavi.className = 'sidenavi';\r
+                       elmItemOrigin.className = 'sidenavi-item';\r
+                       elmItemOrigin.href = '#';\r
+                       elmPages.className = 'page-contents';\r
+                       elmPageOrigin.className = 'page-content main';\r
+                       elmPageOrigin.appendChild( elmTitleOrigin);\r
+                       \r
+                       //helpTitle && instance.title( helpTitle);\r
+                       \r
+                       jqXML.find( 'page').each( function(){\r
+                               var xmlPage = $( this),\r
+                                       title = xmlPage.attr( 'title'),\r
+                                       content = xmlPage.text();\r
+                               \r
+                               elmItemOrigin.innerHTML = title;\r
+                               elmNavi.appendChild( elmItemOrigin.cloneNode( true));\r
+                               \r
+                               elmTitleOrigin.innerHTML = title;\r
+                               \r
+                               elmPage = elmPageOrigin.cloneNode( true);\r
+                               elmPage.innerHTML = content;\r
+                               \r
+                               pettanr.util.cleanElement( elmPage);\r
+                               \r
+                               if( elmPage.childNodes.length > 0){\r
+                                       elmPage.insertBefore( elmTitleOrigin.cloneNode( true), elmPage.childNodes[0]);\r
+                               } else {\r
+                                       elmPage.appendChild( elmTitleOrigin.cloneNode( true));\r
+                               }\r
+                               elmPages.appendChild( elmPage);\r
+                               \r
+                               HELP.createSelection( title, null, onSelectionClick, true);\r
+                               ++numPage;\r
+                       });\r
+                       onLoadFunction();\r
+                       onLoadFunction = null;\r
+                       \r
+                       jqAjaxContents.removeClass( 'loading').append( elmNavi, elmPages);\r
+                       \r
+                       jqNaviItems = jqAjaxContents.find( 'a.' +elmItemOrigin.className).click( onNaviClick);\r
+                       jqPages = jqAjaxContents.find( '.page-content');\r
+                       jqPages.find( 'a').click( onInnerLinkClick);\r
+                       \r
+                       setTimeout( jumpPage, 0);\r
+               }\r
+               function onSelectionClick( _pageIndex){\r
+                       HELP_DOCUMENTS_WINDOW.open();\r
+                       jumpPage( _pageIndex);\r
+               }\r
+               function jumpPage( _index){\r
+                       if( typeof _index === 'number' && 0 <= _index && _index < numPage && currentPageIndex !== _index){\r
+                               currentPageIndex = _index;\r
+                       }\r
+                       jqNaviItems.removeClass( 'current').eq( currentPageIndex).addClass( 'current');\r
+                       jqPages.hide().eq( currentPageIndex).show();\r
+               }\r
+               function onNaviClick( e){\r
+                       // this は <a>\r
+                       jumpPage( pettanr.util.getChildIndex( this.parentNode, this));\r
+                       e.stopPropagation();\r
+                       return false;\r
+               }\r
+               function onInnerLinkClick( e){\r
+                       var jump = ( this.href || '').split( '#jump'),\r
+                               n = jump[1];\r
+                       if( !n) return;\r
+                       jumpPage( '' + parseFloat( n) === n ? parseFloat( n) : -1);\r
+                       e.stopPropagation();\r
+                       return false;                           \r
+               }\r
+               return WINDOWS_CONTROL.createWindow(\r
+                       {\r
+                               onInit: function(){\r
+                                       instance = this;\r
+                                       jqAjaxContents = this.$.find( '.window-body').addClass( 'loading');\r
+                                       delete this.onInit;\r
+                               },\r
+                               onFirstOpen: function( _w, _h){\r
+                                       jqAjaxContents.css( { height: _h});\r
+                                       onAjaxStart();\r
+                                       delete this.onFirstOpen;\r
+                               },\r
+                               onResize: function( _w, _h){\r
+                                       jqAjaxContents && jqAjaxContents.css( { height: _h});\r
+                               }\r
+                       },\r
+                       null, 'Help', 0, 215, 400, 350, false, true, true, 300, 300\r
+               );\r
+       })();\r
+\r
+/* ----------------------------------------\r
+ * GRID_CONTROL\r
+ *  - control\r
+ *  - panelResizeListener\r
+ */\r
+       var GRID_CONTROL = ( function(){\r
+               var ELM_GRID = document.getElementById( 'grid'),\r
+                       BG_URL = "url('images/grid.gif')",\r
+                       jqGrid,\r
+                       visible = false;\r
+\r
+               return {\r
+                       init: function(){\r
+                               jqGrid = $( ELM_GRID);\r
+                               delete GRID_CONTROL.init;\r
+                       },\r
+                       open: function(){\r
+                               GRID_CONTROL.init && GRID_CONTROL.init();\r
+                       },\r
+                       close: function(){\r
+                               \r
+                       },\r
+                       onPanelResize: function( _panelX, _panelY){\r
+                               ELM_GRID.style.backgroundPosition = [ _panelX % 10, 'px ', _panelY % 10, 'px'].join( '');\r
+                               ELM_GRID.style.height = windowH +'px';\r
+                       },\r
+                       enabled: function(){\r
+                               return visible;\r
+                       },\r
+                       update: function(){\r
+                               jqGrid.css( {\r
+                                       opacity:        '',\r
+                                       fliter:         ''\r
+                               }).stop()[ visible === true ? 'fadeOut' : 'fadeIn']();\r
+                               \r
+                               visible = !visible;\r
+                               \r
+                               if( visible === true && BG_URL !== null){\r
+                                       ELM_GRID.style.backgroundImage = BG_URL;\r
+                                       BG_URL = null;\r
+                               }\r
+                               return visible;                         \r
+                       }\r
+               }\r
+       })();\r
+               \r
+/* ----------------------------------------\r
+ * WHITE_GLASS_CONTROL\r
+ *  - panelResizeListener\r
+ */\r
+       var WHITE_GLASS_CONTROL = ( function(){\r
+               var styleTop = document.getElementById( 'whiteGlass-top').style,\r
+                       styleLeft = document.getElementById( 'whiteGlass-left').style,\r
+                       styleRight = document.getElementById( 'whiteGlass-right').style,\r
+                       styleBottom = document.getElementById( 'whiteGlass-bottom').style;\r
+\r
+               return {\r
+                       onPanelResize: function( _panelX, _panelY, _panelW, _panelH){\r
+                               var     _w = _panelW,\r
+                                       _h = _panelH,\r
+                                       marginTop = _panelY,\r
+                                       marginBottom = windowH -_h -marginTop,\r
+                                       marginX = _panelX,\r
+                                       rightWidth = windowW -_w -marginX;\r
+                               \r
+                               styleTop.height = ( marginTop < 0 ? 0 : marginTop) +'px';\r
+                               \r
+                               styleLeft.top = marginTop +'px';\r
+                               styleLeft.width = ( marginX < 0 ? 0 : marginX) +'px';\r
+                               styleLeft.height = ( _h + marginBottom) +'px';\r
+                               \r
+                               styleRight.top = marginTop +'px';\r
+                               styleRight.left = _w +marginX +'px';\r
+                               styleRight.width = ( rightWidth < 0 ? 0 : rightWidth) +'px';\r
+                               styleRight.height = ( _h + marginBottom) +'px';\r
+                               \r
+                               styleBottom.top = ( _h +marginTop) +'px';\r
+                               styleBottom.left = marginX +'px';\r
+                               styleBottom.width = _w +'px';\r
+                               styleBottom.height = ( marginBottom < 0 ? 0 : marginBottom) +'px';\r
+                       }\r
+               }\r
+       })();\r
+\r
+\r
+/* ----------------------------------------\r
+ * PANEL_CONTROL\r
+ *  - controler\r
+ *  - mouseEventListener\r
+ * \r
+ * panel-border の表示と onPanelResize の通知.\r
+ * panel drag.\r
+ * \r
+ */\r
+       var PANEL_CONTROL = ( function(){\r
+               var ELM_PANEL = document.getElementById('panel-tools-container'),\r
+                       ELM_PANEL_STYLE = ELM_PANEL.style,\r
+                       DEFAULT_PANEL_WIDTH = 400,\r
+                       DEFAULT_PANEL_HEIGHT = 300,\r
+                       borderSize = 2,\r
+                       panelW, panelH, panelX, panelY,\r
+                       offsetX, offsetY, startX, startY,\r
+                       isDragging = false,\r
+                       isDraggable = false;\r
+               \r
+               pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 32, false, false, onSpaceUpdate);\r
+               \r
+               function onSpaceUpdate(e){\r
+                       if( e.type === 'keyup'){\r
+                               currentListener === null && updateMouseCursor( '');\r
+                               isDraggable = false;\r
+                       } else {\r
+                               currentListener === null && updateMouseCursor( 'move');\r
+                               isDraggable = true;\r
+                       }\r
+               }\r
+               \r
+               return {\r
+                       open: function( _panelW, _panelH, _borderSize ){\r
+                               panelW = Type.isFinite( _panelW ) === true ? _panelW : DEFAULT_PANEL_WIDTH;\r
+                               panelH = Type.isFinite( _panelH ) === true ? _panelH : DEFAULT_PANEL_HEIGHT;\r
+                               //panelX = Math.floor( ( windowW -panelW) /2);\r
+                               //panelY = Math.floor( ( windowH -panelH) /2);\r
+                               borderSize = Type.isFinite( _borderSize ) === true ? _borderSize : borderSize;\r
+                               \r
+                               //setTimeout( PANEL_CONTROL.resize, 0);\r
+                       },\r
+                       close: function(){\r
+                               \r
+                       },\r
+                       x: function(){\r
+                               return panelX;\r
+                       },\r
+                       y: function(){\r
+                               return panelY;\r
+                       },\r
+                       resize: function( isResizerTopAction, _x, _y, _w, _h){\r
+                               panelX = _x !== undefined ? _x : panelX;\r
+                               panelY = _y !== undefined ? _y : panelY;\r
+                               panelW = _w !== undefined ? _w : panelW;\r
+                               panelH = _h !== undefined ? _h : panelH;\r
+                               \r
+                               ELM_PANEL_STYLE.left    = ( panelX -borderSize) +'px';\r
+                               ELM_PANEL_STYLE.top             = ( panelY -borderSize) +'px';\r
+                               ELM_PANEL_STYLE.width   = panelW +'px';\r
+                               ELM_PANEL_STYLE.height  = panelH +'px';\r
+                               \r
+                               PANEL_RESIZER_TOP.onPanelResize( panelX, panelY, panelW, panelH);\r
+                               PANEL_RESIZER_BOTTOM.onPanelResize( panelX, panelY, panelW, panelH);\r
+                               GRID_CONTROL.onPanelResize( panelX, panelY);\r
+                               WHITE_GLASS_CONTROL.onPanelResize( panelX, panelY, panelW, panelH);\r
+                               COMIC_ELEMENT_CONTROL.onPanelResize( panelX, panelY, panelW, panelH, isResizerTopAction === true);\r
+                       },\r
+                       onWindowResize: function( _windowW, _windowH){\r
+                               panelX = Math.floor(( _windowW - panelW) / 2);\r
+                               panelY = Math.floor(( _windowH - panelH) / 2);\r
+                               PANEL_CONTROL.resize();\r
+                       },\r
+                       onMouseMove: function( _mouseX, _mouseY){\r
+                               if( isDraggable === true && isDragging === true){\r
+                                       PANEL_CONTROL.resize( false, startX +_mouseX -offsetX, startY +_mouseY -offsetY);\r
+                               }\r
+                       },\r
+                       onMouseUp: function( _mouseX, _mouseY){\r
+                               if( isDraggable === true){\r
+                                       isDragging = false;\r
+                                       updateMouseCursor( '');\r
+                               }\r
+                       },\r
+                       onMouseDown: function( _mouseX, _mouseY){\r
+                               if( isDraggable === true){\r
+                                       offsetX = _mouseX;\r
+                                       offsetY = _mouseY;\r
+                                       startX = panelX;\r
+                                       startY = panelY;\r
+                                       isDragging = true;\r
+                                       updateMouseCursor( 'move');\r
+                                       return true;\r
+                               }\r
+                       },\r
+                       busy: function(){\r
+                               return isDragging === true;\r
+                       }                               \r
+               }\r
+       })();\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * PanelResizerClass\r
+ *  - mouseEventListener\r
+ */\r
+       var PanelResizerClass = function( ID, isTop){\r
+               var ELM = document.getElementById( ID),\r
+                       BORDER_WIDTH = 2,\r
+                       RESIZER_HEIGHT = 30,\r
+                       x = -BORDER_WIDTH /2,\r
+                       y = isTop === true ? ( -5 -RESIZER_HEIGHT -BORDER_WIDTH) : 0,\r
+                       w,\r
+                       h = RESIZER_HEIGHT,\r
+                       panelX, panelY, panelW, panelH,\r
+                       offsetY, startY, startH,\r
+                       isDragging = false,\r
+                       MOUSE_CURSOR = updateMouseCursor;\r
+                       \r
+               function restoreState( arg){\r
+                       if( arg && arg.length > 3){\r
+                               PANEL_CONTROL.resize( isTop, arg[ 0] || panelX, arg[ 1] || panelY, arg[ 2] || panelW, arg[ 3] || panelH);\r
+                       }\r
+               }\r
+                       \r
+               this.onMouseDown = function( _mouseX, _mouseY){\r
+                       var _x = _mouseX -panelX,\r
+                               _y = _mouseY -panelY;\r
+                       if( _x < x || x + w < _x || _y < y || y + h < _y) return false;\r
+                       offsetY = _y;\r
+                       startY = panelY;\r
+                       startH = panelH;\r
+                       isDragging = true;\r
+                       MOUSE_CURSOR( 'n-resize');\r
+                       return true;\r
+               }\r
+               this.onMouseMove = function( _mouseX, _mouseY){\r
+                       var _x = _mouseX -panelX,\r
+                               _y = _mouseY -panelY;\r
+                       if( isDragging !== true){\r
+                               if( _x < x || x + w < _x || _y < y || y + h < _y) return false;\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.hide();\r
+                               MOUSE_CURSOR( 'pointer');\r
+                               return true;\r
+                       } else {\r
+                               var move = _y -offsetY;\r
+                               if( isTop === true){\r
+                                       if( panelH - move < MIN_PANEL_HEIGHT){\r
+                                               move = panelH -MIN_PANEL_HEIGHT;\r
+                                       }\r
+                                       PANEL_CONTROL.resize( true, panelX, panelY + move, panelW, panelH - move);\r
+                               } else {\r
+                                       var _h = startH +move;\r
+                                       if( 0 < _h && _h < windowH -panelY -RESIZER_HEIGHT -5 -BORDER_WIDTH){\r
+                                               PANEL_CONTROL.resize( false, panelX, panelY, panelW, _h < MIN_PANEL_HEIGHT ? MIN_PANEL_HEIGHT : _h);\r
+                                       }\r
+                               }\r
+                       }\r
+                       return true;\r
+               }\r
+               this.onMouseUp = function( _mouseX, _mouseY){\r
+                       if( isDragging !== true) return;\r
+                       ( startY !== panelY || startH !== panelH) && HISTORY_CONTROL.saveState( restoreState, [ NaN, startY, NaN, startH], [ NaN, panelY, NaN, panelH]);\r
+                       isDragging = false;\r
+                       MOUSE_CURSOR( '');\r
+               }\r
+               this.busy = function(){\r
+                       return isDragging\r
+               }\r
+               this.onPanelResize = function( _x, _y, _w, _h){\r
+                       panelX = _x;\r
+                       panelY = _y;\r
+                       if( panelW !== _w){\r
+                               ELM.style.width = ( _w +2) +'px';\r
+                               panelW = _w;\r
+                       }\r
+                       panelH = _h;\r
+                       y = isTop === true ? y : ( panelH +5 +BORDER_WIDTH);\r
+                       w = panelW +2;\r
+               }\r
+       };\r
+       var     PANEL_RESIZER_TOP = new PanelResizerClass( 'panel-resizer-top', true ),\r
+               PANEL_RESIZER_BOTTOM = new PanelResizerClass( 'panel-resizer-bottom', false );\r
+               \r
+       PanelResizerClass = undefined;\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * CONSOLE_CONTROLER\r
+ */\r
+       var CONSOLE_CONTROLER = ( function(){\r
+               var LAYER_BACK_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'layer back', 'ctrl + B', layerBack, false, true, false),\r
+                       LAYER_FORWARD_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'layer forward', 'ctrl + F', layerForward, false, false, false),\r
+                       DELETE_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'delete', 'ctrl + D', del, false, true, true),\r
+                       EDIT_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'Edit Text', 'ctrl + E', edit, false, true, false),\r
+                       CHANGE_BUTTON = MENU_BAR_CONTROL.EDIT.createSelection( 'change', 'ctrl + U', change, false, false, true),\r
+                       SAVE = HISTORY_CONTROL.saveState,\r
+                       jqStage,\r
+                       jqConsoleParent,\r
+                       jqConsoleWrapper,\r
+                       jqConsoleTail,\r
+                       jqImgConsole, jqTextConsole,\r
+                       currentElement = null,\r
+                       currentType = -1,\r
+                       visible = false,\r
+                       imgConsoleWidth, imgConsoleHeight,\r
+                       textConsoleWidth, textConsoleHeight,\r
+                       consoleWidth, consoleHeight,\r
+                       consoleX, consoleY,\r
+                       tailSize = 10,\r
+                       buttonClickable = false;\r
+               \r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 66, false, true, layerBack);\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 70, false, true, layerForward);\r
+               \r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 68, false, true, del);\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 69, false, true, edit);\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 85, false, true, change);\r
+               \r
+               function buttonBackOrForward( isBack){\r
+                       var     offest = jqConsoleWrapper.offset();\r
+                       jqConsoleWrapper.css( {\r
+                               position:       isBack === true ? '' : 'absolute',\r
+                               left:           isBack === true ? consoleX  : offest.left,\r
+                               top:            isBack === true ? consoleY  : offest.top\r
+                       });\r
+                       buttonClickable === isBack && ( isBack === true ? jqConsoleParent : jqStage).append( jqConsoleWrapper);\r
+                       buttonClickable = !isBack;\r
+               }\r
+               function layerBack(){\r
+                       if( currentElement === null) return;\r
+                       if( COMIC_ELEMENT_CONTROL.replace( currentElement, false) === false) return;\r
+                       INFOMATION_WINDOW.update( currentElement);\r
+                       SAVE( COMIC_ELEMENT_CONTROL.restoreReplace, [ currentElement, true], [ currentElement, false]);\r
+                       var _z = currentElement.z;\r
+                       LAYER_BACK_BUTTON.visible( _z > 0);\r
+                       LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1);\r
+               }\r
+               function layerForward(){\r
+                       if( currentElement === null) return;\r
+                       if( COMIC_ELEMENT_CONTROL.replace( currentElement, true) === false) return;\r
+                       INFOMATION_WINDOW.update( currentElement);\r
+                       SAVE( COMIC_ELEMENT_CONTROL.restoreReplace, [ currentElement, false], [ currentElement, true]);\r
+                       var _z = currentElement.z;\r
+                       LAYER_BACK_BUTTON.visible( _z > 0);\r
+                       LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1);\r
+               }\r
+               function del(){\r
+                       if( currentElement === null) return;\r
+                       buttonBackOrForward( true);\r
+                       COMIC_ELEMENT_CONTROL.remove( currentElement);\r
+                       SAVE( COMIC_ELEMENT_CONTROL.restore, [ true, currentElement], [ false, currentElement], true);\r
+                       COMIC_ELEMENT_OPERATION_MANAGER.hide();\r
+               }\r
+               function edit(){\r
+                       if( currentElement === null || currentElement.type !== PANEL_ELEMENT_TYPE_TEXT) return;\r
+                       pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), currentElement );\r
+                       buttonBackOrForward( true);\r
+               }\r
+               function change(){\r
+                       if( currentElement === null) return;\r
+                       buttonBackOrForward( true);\r
+                       pettanr.premiumSatge.bootInOverlay( currentElement.getArtistID(), currentElement.resourcePicture );\r
+               }\r
+               function onImageSelect( resourcePicture ){\r
+                       currentElement.resourcePicture( resourcePicture );\r
+               }\r
+               return {\r
+                       init: function(){\r
+                               jqStage = jqEditor;\r
+                               jqConsoleTail = $( '#comic-element-consol-tail');\r
+                               jqImgConsole = $( '#image-element-consol').hide();\r
+                               var imgConsoleSize = pettanr.util.getElementSize( jqImgConsole.get( 0));\r
+                               imgConsoleWidth = imgConsoleSize.width;\r
+                               imgConsoleHeight = imgConsoleSize.height;\r
+                               \r
+                               jqTextConsole = $( '#text-element-consol').hide();\r
+                               var textConsoleSize = pettanr.util.getElementSize( jqTextConsole.get( 0));\r
+                               textConsoleWidth = textConsoleSize.width;\r
+                               textConsoleHeight = textConsoleSize.height;\r
+                               \r
+                               jqConsoleWrapper = $( '#comic-element-consol-wrapper').hide();\r
+                               jqConsoleParent = jqConsoleWrapper.parent();\r
+                               \r
+                               $( '#edit-text-button').click( edit);\r
+                               $( '#delete-image-button, #delete-text-button').click( del);\r
+                               $( '#change-image-button').click( change);\r
+                               $( '#layer-forward-button, #forward-text-button').click( layerForward);\r
+                               $( '#layer-back-button, #back-text-button').click( layerBack);\r
+                                                                                       \r
+                               delete CONSOLE_CONTROLER.init;\r
+                       },\r
+                       show: function( _currentElement, _w, _h ){\r
+                               CONSOLE_CONTROLER.init && CONSOLE_CONTROLER.init();\r
+                               \r
+                               visible === false && jqConsoleWrapper.show();\r
+                               visible = true;\r
+                               currentElement = _currentElement;\r
+                               var _currentType = _currentElement.type,\r
+                                       _z = _currentElement.z;\r
+                               if( currentType !== _currentType){\r
+                                       currentType = _currentType;\r
+                                       jqImgConsole.toggle( _currentType === PANEL_ELEMENT_TYPE_IMAGE);\r
+                                       jqTextConsole.toggle( _currentType === PANEL_ELEMENT_TYPE_TEXT);\r
+                                       consoleWidth = _currentType === PANEL_ELEMENT_TYPE_IMAGE ? imgConsoleWidth : textConsoleWidth;\r
+                                       consoleHeight = _currentType === PANEL_ELEMENT_TYPE_IMAGE ? imgConsoleHeight : textConsoleHeight;\r
+                               }\r
+                               consoleX = Math.floor( ( _w -consoleWidth) /2);\r
+                               \r
+                               LAYER_BACK_BUTTON.visible( _z > 0);\r
+                               LAYER_FORWARD_BUTTON.visible( _z < COMIC_ELEMENT_ARRAY.length -1);\r
+                               DELETE_BUTTON.visible( true);\r
+                               EDIT_BUTTON.visible( _currentType === PANEL_ELEMENT_TYPE_TEXT);\r
+                               CHANGE_BUTTON.visible( false);\r
+                               \r
+                               if( _w > consoleWidth * 1.5 && _h > consoleHeight * 1.5){\r
+                                       consoleY = Math.floor( ( _h -consoleHeight) /2);\r
+                                       jqConsoleWrapper.css( {\r
+                                               left:                   consoleX,\r
+                                               top:                    consoleY\r
+                                       }).removeClass( 'console-out');\r
+                               } else {\r
+                                       consoleY = _h +tailSize;\r
+                                       jqConsoleWrapper.css( {\r
+                                               left:                   consoleX,\r
+                                               top:                    consoleY\r
+                                       }).addClass( 'console-out');\r
+                               }\r
+                       },\r
+                       hide: function (){\r
+                               visible === true && jqConsoleWrapper.hide();\r
+                               visible = false;\r
+                               currentElement = null;\r
+                               LAYER_BACK_BUTTON.visible( false);\r
+                               LAYER_FORWARD_BUTTON.visible( false);\r
+                               DELETE_BUTTON.visible( false);\r
+                               EDIT_BUTTON.visible( false);\r
+                               CHANGE_BUTTON.visible( false);\r
+                       },\r
+                       x: function(){ return consoleX;},\r
+                       y: function(){ return consoleY;},\r
+                       w: function(){ return consoleWidth;},\r
+                       h: function(){ return consoleHeight;},\r
+                       onMouseMove: function( _mouseX, _mouseY){\r
+                               if( consoleX > _mouseX || consoleY > _mouseY || consoleX +consoleWidth < _mouseX || consoleY +consoleHeight < _mouseY){\r
+                                       buttonClickable === true && buttonBackOrForward( true);\r
+                                       return false;\r
+                               }\r
+                               buttonClickable === false && buttonBackOrForward( false);\r
+                               return true;\r
+                       },\r
+                       onMouseOut: function( _mouseX, _mouseY){\r
+                               buttonClickable === true && buttonBackOrForward( true);\r
+                       }\r
+               }\r
+       })();\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * TAIL_OPERATOR\r
+ *  - comicElementOperator\r
+ */\r
+       var TAIL_OPERATOR = ( function(){\r
+               var     MOUSE_CURSOR = updateMouseCursor,\r
+                       ELM_MOVER = document.getElementById( 'balloon-tail-mover'),\r
+                       SIZE = pettanr.util.getElementSize( ELM_MOVER).width,\r
+                       SIN = Math.sin,\r
+                       COS = Math.cos,\r
+                       ATAN = Math.atan,\r
+                       FLOOR = Math.floor,\r
+                       DEG_TO_RAD = Math.PI / 180,\r
+                       RAD_TO_DEG = 1 /DEG_TO_RAD,\r
+                       currentText = null,\r
+                       tailX, tailY,\r
+                       x, y, w, h,\r
+                       balloonW, balloonH, balloonA, radA,\r
+                       visible = false,\r
+                       startA;\r
+               \r
+               return {\r
+                       update: function ( _w, _h, _a){\r
+                               balloonW = _w !== undefined ? _w : balloonW;\r
+                               balloonH = _h !== undefined ? _h : balloonH;\r
+                               balloonA = _a !== undefined ? _a : balloonA;\r
+                               radA = balloonA *DEG_TO_RAD;\r
+                               tailX = FLOOR( ( ( COS( radA) /2 +0.5) *( balloonW +SIZE)) -SIZE /2);\r
+                               tailY = FLOOR( ( ( SIN( radA) /2 +0.5) *( balloonH +SIZE)) -SIZE /2);\r
+                               ELM_MOVER.style.left = tailX +'px';\r
+                               ELM_MOVER.style.top = tailY +'px';\r
+                               //log.html( [ balloonW, balloonH, balloonA].join());\r
+                       },\r
+                       show: function( _currentText){\r
+                               /*\r
+                                * visibilityのほうがいい, display:none だと ie で描画が狂う\r
+                                */\r
+                               ELM_MOVER.style.visibility = '';\r
+                               this.update( _currentText.w, _currentText.h, _currentText.angle());\r
+                               currentText = _currentText;\r
+                       },\r
+                       hitTest: function( _mouseX, _mouseY){\r
+                               var _x = tailX -SIZE /2,\r
+                                       _y = tailY -SIZE /2;\r
+                                       ret = _x <= _mouseX && _y <= _mouseY && _x +SIZE >= _mouseX && _y +SIZE >= _mouseY;\r
+                               ret === true && MOUSE_CURSOR( 'move');\r
+                               return ret;\r
+                       },\r
+                       hide: function(){\r
+                               ELM_MOVER.style.visibility = 'hidden';\r
+                               currentText = null;\r
+                       },\r
+                       onStart: function( _currentText, _mouseX, _mouseY){\r
+                               if( _currentText.type !== PANEL_ELEMENT_TYPE_TEXT) return false;\r
+                               x = _currentText.x;\r
+                               y = _currentText.y;\r
+                               if( this.hitTest( _mouseX -x, _mouseY -y) === true){\r
+                                       w = _currentText.w;\r
+                                       h = _currentText.h;\r
+                                       currentText = _currentText;\r
+                                       startA = _currentText.angle();\r
+                                       return true;\r
+                               }\r
+                               return false;\r
+                       },\r
+                       onDrag: function( _mouseX, _mouseY){\r
+                               _mouseX = _mouseX -x -w /2;\r
+                               _mouseY = _mouseY -y -h /2; //Balloonの中心を0,0とする座標系に変換\r
+                               \r
+                               this.update( w, h,\r
+                                       _mouseX !== 0 ?\r
+                                               ATAN( _mouseY /_mouseX) *RAD_TO_DEG +( _mouseX < 0 ? 180 : 0) :\r
+                                               _mouseY > 0 ? 90 : -90\r
+                               );\r
+                               currentText && currentText.angle( balloonA);\r
+                               INFOMATION_WINDOW.update( currentText);\r
+                       },\r
+                       onFinish: function(){\r
+                               startA !== currentText.angle() && COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( x, y, w, h, startA);\r
+                               startA !== currentText.angle() && COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h, currentText.angle());\r
+                               currentText = null;\r
+                       },\r
+                       onCancel: function(){\r
+                               currentText.angle( startA);\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h, startA);\r
+                               currentText = null;\r
+                       }\r
+               }\r
+       })();\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * RESIZE_OPERATOR\r
+ *  - comicElementOperator\r
+ */\r
+       var RESIZE_OPERATOR = ( function(){\r
+               var     MOUSE_CURSOR = updateMouseCursor,\r
+                       GRID_ENABLED = GRID_CONTROL.enabled;\r
+               \r
+               var     HIT_AREA = MOUSE_HIT_AREA,\r
+                       POSITION_ARRAY = [],\r
+                       FLOOR = Math.floor,\r
+                       CURSOR_AND_FLIP = [\r
+                               { cursor:       'n-resize',             v: 3},\r
+                               { cursor:       'e-resize',             h: 2},\r
+                               { cursor:       'e-resize',             h: 1},\r
+                               { cursor:       'n-resize',             v: 0},\r
+                               { cursor:       'nw-resize',    h: 5, v: 6, vh: 7},\r
+                               { cursor:       'ne-resize',    h: 4, v: 7, vh: 6},\r
+                               { cursor:       'ne-resize',    h: 7, v: 4, vh: 5},\r
+                               { cursor:       'nw-resize',    h: 6, v: 5, vh: 4}\r
+                       ],\r
+                       elmResizerContainer = document.getElementById( 'comic-element-resizer-container'),\r
+                       elmResizerContainerStyle = elmResizerContainer.style,\r
+                       elmResizerTopStyle = document.getElementById( 'comic-element-resizer-top').style,\r
+                       elmResizerLeftStyle = document.getElementById( 'comic-element-resizer-left').style,\r
+                       elmResizerRightStyle = document.getElementById( 'comic-element-resizer-right').style,\r
+                       elmResizerBottomStyle = document.getElementById( 'comic-element-resizer-bottom').style,\r
+                       x, y, w, h,\r
+                       currentIndex = -1,\r
+                       currentElement,\r
+                       currentIsTextElement = false;\r
+               \r
+               elmResizerContainerStyle.display = 'none';\r
+               \r
+               var RESIZE_WORK_ARRAY = [\r
+                               { x:    0, w:    0, y:  1, h:   -1}, //top\r
+                               { x:    1, w:   -1, y:  0, h:    0}, //left\r
+                               { x:    0, w:    1, y:  0, h:    0}, //right\r
+                               { x:    0, w:    0, y:  0, h:    1}, //bottom\r
+                               { x:    1, w:   -1, y:  1, h:   -1}, //top-left\r
+                               { x:    0, w:    1, y:  1, h:   -1}, //top-right\r
+                               { x:    1, w:   -1, y:  0, h:    1}, //bottom-left\r
+                               { x:    0, w:    1, y:  0, h:    1}  //bottom-right\r
+                       ],\r
+                       startX, startY, startW, startH, startFilpV, startFilpH, startAspect,\r
+                       baseX, baseY, baseW, baseH,\r
+                       currentX, currentY, currentW, currentH,\r
+                       offsetX, offsetY,\r
+                       lock = false,\r
+                       error = 0;\r
+               \r
+               function draw( _x, _y, _w, _h){\r
+                       x = _x !== undefined ? _x : x;\r
+                       y = _y !== undefined ? _y : y;\r
+                       w = _w !== undefined ? _w : w;\r
+                       h = _h !== undefined ? _h : h;\r
+                       try {\r
+                               elmResizerContainerStyle.left = x +'px';\r
+                               elmResizerContainerStyle.top = y +'px';\r
+                               elmResizerContainerStyle.width = w +'px';\r
+                               elmResizerContainerStyle.height = h +'px';\r
+                               elmResizerTopStyle.left = FLOOR( w /2 -10 /2) +'px';\r
+                               elmResizerLeftStyle.top = FLOOR( h /2 -10 /2) +'px';\r
+                               elmResizerRightStyle.top = FLOOR( h /2 -10 /2) +'px';\r
+                               elmResizerBottomStyle.left = FLOOR( w /2 -10 /2) +'px';                         \r
+                       } catch(e){\r
+                               alert( [x, y, w, h].join( ','));\r
+                               return;\r
+                       }\r
+\r
+                       \r
+                       POSITION_ARRAY.splice( 0, POSITION_ARRAY.length);\r
+                       POSITION_ARRAY.push(\r
+                               {x:     x +5,                                   y:      y -HIT_AREA,            w:      w -5 *2,                h:      HIT_AREA +5},\r
+                               {x: x -HIT_AREA,                        y:      y +HIT_AREA +5,         w:      HIT_AREA +5,    h:      h -5 *2},\r
+                               {x: x +w -5,                            y:      y +HIT_AREA +5,         w:      HIT_AREA +5,    h:      h -5 *2},\r
+                               {x:     x +5,                                   y:      y +h -5,                        w:      w -5 *2,                h:      HIT_AREA +5},\r
+                               {x:     x -HIT_AREA,                    y:      y -HIT_AREA,            w:      HIT_AREA +5,    h:      HIT_AREA +5},\r
+                               {x: x +w -HIT_AREA,                     y:      y -HIT_AREA,            w:      HIT_AREA +5,    h:      HIT_AREA +5},\r
+                               {x:     x -HIT_AREA,                    y:      y +h -5,                        w:      HIT_AREA +5,    h:      HIT_AREA +5},\r
+                               {x:     x +w -5,                                y:      y +h -5,                        w:      HIT_AREA +5,    h:      HIT_AREA +5}\r
+                       );\r
+               }\r
+               \r
+               function update( _x, _y, _w, _h){\r
+                       x = _x !== undefined ? _x : currentX;\r
+                       y = _y !== undefined ? _y : currentY;\r
+                       w = _w !== undefined ? _w : currentW;\r
+                       h = _h !== undefined ? _h : currentH;\r
+                       \r
+                       if( currentIsTextElement === false && currentIndex > 3 && pettanr.key.shiftEnabled() === true){\r
+                               if( startAspect >= 1){\r
+                                       _w = w;\r
+                                       w = Math.floor( startAspect * h);\r
+                                       x = x +( currentIndex % 2 === 0 ? _w -w : 0);\r
+                               } else {\r
+                                       _h = h;\r
+                                       h = Math.floor( w / startAspect);\r
+                                       y = y + ( currentIndex <= 5 ? _h -h : 0);\r
+                               }\r
+                       }\r
+                       draw( x, y, w, h);\r
+                       currentElement.resize( x, y, w, h);\r
+                       currentIsTextElement === true && TAIL_OPERATOR.update( w, h);\r
+                       CONSOLE_CONTROLER.show( currentElement, w, h);\r
+                       INFOMATION_WINDOW.update( currentElement);\r
+               }\r
+               \r
+               function flip( _flipH, _flipV){\r
+                       var p = CURSOR_AND_FLIP[ currentIndex];\r
+                       currentIndex = _flipH === true || _flipV === true ? p[\r
+                                       _flipH === true && _flipV === true ? 'vh' : ( _flipH === true ? 'h' : 'v')\r
+                               ] : currentIndex;\r
+                       MOUSE_CURSOR( CURSOR_AND_FLIP[ currentIndex].cursor);\r
+                       elmResizerContainer.className = 'current-resizer-is-' +currentIndex;\r
+                       currentElement.flip( _flipH, _flipV);\r
+               }\r
+               return {\r
+                       update: draw,\r
+                       index: function( _mouseX, _mouseY){\r
+                               var     p, i;\r
+                               for( i=4; i<8; i++){\r
+                                       p = POSITION_ARRAY[ i];\r
+                                       if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){\r
+                                               MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);\r
+                                               elmResizerContainer.className = 'current-resizer-is-' +i;\r
+                                               return currentIndex = i;\r
+                                       }\r
+                               }\r
+                               for( i=0; i<4; i++){\r
+                                       p = POSITION_ARRAY[ i];\r
+                                       if( p.x <= _mouseX && p.y <= _mouseY && p.x + p.w >= _mouseX && p.y +p.h >= _mouseY){\r
+                                               MOUSE_CURSOR( CURSOR_AND_FLIP[ i].cursor);\r
+                                               elmResizerContainer.className = 'current-resizer-is-' +i;\r
+                                               return currentIndex = i;\r
+                                       }\r
+                               }\r
+                               MOUSE_CURSOR( '');\r
+                               elmResizerContainer.className = '';\r
+                               return -1;\r
+                       },\r
+                       show: function( _currentElement){\r
+                               currentElement = _currentElement;\r
+                               currentIsTextElement = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT;\r
+                               elmResizerContainerStyle.display = '';\r
+                       },\r
+                       hide: function(){\r
+                               currentElement = null;\r
+                               elmResizerContainerStyle.display = 'none';\r
+                       },\r
+                       onStart: function( _currentElement, _mouseX, _mouseY){\r
+                               currentElement = _currentElement;\r
+                               currentIsTextElement = _currentElement.type === PANEL_ELEMENT_TYPE_TEXT;\r
+                               if( _currentElement.keepSize === true) return false;\r
+                               currentIndex = this.index( _mouseX, _mouseY);\r
+                               if( currentIndex === -1) return false;\r
+                               offsetX = _mouseX;\r
+                               offsetY = _mouseY;\r
+                               startX = baseX = _currentElement.x;\r
+                               startY = baseY = _currentElement.y;\r
+                               startW = baseW = _currentElement.w;\r
+                               startH = baseH = _currentElement.h;\r
+                               if( _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE){\r
+                                       startFilpV = _currentElement.flipV();\r
+                                       startFilpH = _currentElement.flipH();                                                   \r
+                               }\r
+                               startAspect = startW /startH;\r
+                               return true;\r
+                       },\r
+                       onDrag: function( _mouseX, _mouseY){\r
+                               var com = RESIZE_WORK_ARRAY[ currentIndex],\r
+                                       moveX = _mouseX -offsetX,\r
+                                       moveY = _mouseY -offsetY,\r
+                                       _updated = moveX !== 0 || moveY !== 0,\r
+                                       _x, _y, _w, _h,\r
+                                       _thisError = 0;\r
+                                       \r
+                               var _memoryX = 0,\r
+                                       _memoryY = 0,\r
+                                       _momoryW = 0,\r
+                                       _momoryH = 0;\r
+                               /*\r
+                                * Opera 11+ often forget values, why ??\r
+                                */\r
+                               while( _x === undefined || _y === undefined || _w === undefined || _h === undefined){\r
+                                       _x = _x !== undefined ? _x : baseX +moveX *com.x;\r
+                                       _y = _y !== undefined ? _y : baseY +moveY *com.y;\r
+                                       _w = _w !== undefined ? _w : baseW +moveX *com.w;\r
+                                       _h = _h !== undefined ? _h : baseH +moveY *com.h;\r
+                                       error += _thisError === 0 ? 0 : 1;\r
+                                       ++_thisError;\r
+                                       if( _thisError > 9999){\r
+                                               ++error\r
+                                               //alert( 'opera error' +error);\r
+                                               this.onCancel;\r
+                                               return;\r
+                                       }\r
+                               }\r
+                               \r
+                               if( _w >= MIN_ELEMENT_SIZE && _h >= MIN_ELEMENT_SIZE){\r
+                                       \r
+                               } else \r
+                               if( _w >= -MIN_ELEMENT_SIZE && _h >= -MIN_ELEMENT_SIZE){\r
+                                       //return;\r
+                                       if( _w < MIN_ELEMENT_SIZE){\r
+                                               //_x += Math.abs( MIN_ELEMENT_SIZE -_w);\r
+                                               _x = currentX;\r
+                                               _w = MIN_ELEMENT_SIZE;\r
+                                       }\r
+                                       if( _h < MIN_ELEMENT_SIZE){\r
+                                               //_y += Math.abs( MIN_ELEMENT_SIZE -_h);\r
+                                               _y = currentY;\r
+                                               _h = MIN_ELEMENT_SIZE;\r
+                                       }\r
+                               } else \r
+                               if( currentElement.type === PANEL_ELEMENT_TYPE_TEXT){\r
+                                       return;\r
+                               } else \r
+                               if( _w < -MIN_ELEMENT_SIZE || _h < -MIN_ELEMENT_SIZE){\r
+\r
+                                       if( _w < -MIN_ELEMENT_SIZE && _h > MIN_ELEMENT_SIZE){\r
+                                       // flipH\r
+                                               _memoryX = _x;\r
+                                               baseX = _x = _x +_w;\r
+                                               baseY = _y;\r
+                                               baseW = _w = _memoryX -_x;\r
+                                               baseH = _h;\r
+                                               flip( true, false);\r
+                                               flipV = currentElement.flipV();\r
+                                       } else \r
+                                       if( _w > MIN_ELEMENT_SIZE && _h < -MIN_ELEMENT_SIZE){\r
+                                       // flipV\r
+                                               _memoryY = _y;\r
+                                               baseX = _x;\r
+                                               baseY = _y = _y +_h;\r
+                                               baseW = _w;\r
+                                               baseH = _h = _memoryY -_y;\r
+                                               flip( false, true);\r
+                                               flipH = currentElement.flipH();\r
+                                       } else {\r
+                                       // flipVH\r
+                                               _memoryX = _x;\r
+                                               _memoryY = _y;\r
+                                               baseX = _x = _x +_w;\r
+                                               baseY = _y = _y +_h;\r
+                                               baseW = _w = _memoryX -_x;\r
+                                               baseH = _h = _memoryY -_y;\r
+                                               flip( true, true);\r
+                                               flipV = currentElement.flipV();\r
+                                               flipH = currentElement.flipH();\r
+                                       }\r
+                                       _updated = true;\r
+                                       offsetX = _mouseX;\r
+                                       offsetY = _mouseY;      \r
+                               }\r
+                               currentX = _x;\r
+                               currentY = _y;\r
+                               currentW = _w;\r
+                               currentH = _h;\r
+                               _updated === true && update( _x, _y, _w, _h);\r
+                               \r
+                               log.html( [\r
+                                               'currentIndex:', currentIndex, \r
+                                               'baseW', baseW, 'baseH', baseH,'<br>',\r
+                                               'mouse', _mouseX, _mouseY,'<br>',\r
+                                               'move', moveX, moveY,'<br>',\r
+                                               'xy', _x, _y, 'wh',_w, _h,'<br>',\r
+                                               'com.w', com.w, 'com.h', com.h,'<br>',\r
+                                               'current',currentW, currentH,'<br>',\r
+                                               'result', y, h,\r
+                                               'err', error\r
+                               ].join( ' , '));\r
+                       },\r
+                       onFinish: function(){\r
+                               MOUSE_CURSOR( '');\r
+                               if( w === startW && h === startH && x === startX && y === startY) return;\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y, w, h);\r
+                               currentElement.resize( x, y, w, h);\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( startX, startY, startW, startH, undefined, startFilpV, startFilpH);\r
+                       },\r
+                       onCancel: function(){\r
+                               MOUSE_CURSOR( '');\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY, startW, startH);\r
+                               currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ?\r
+                                       currentElement.animate( startX, startY, startW, startH, startFilpV, startFilpH) :\r
+                                       currentElement.animate( startX, startY, startW, startH, angle);\r
+                       },\r
+                       lock: function( _lock){\r
+                               if( _lock !== undefined){\r
+                                       elmResizerContainerStyle.borderColor = _lock === true ? 'blue' : '';\r
+                                       lock = _lock;\r
+                               }\r
+                               return lock;\r
+                       },\r
+                       onShiftUpdate: update,\r
+                       onCtrlUpdate: update\r
+               }\r
+       })();\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * POSITION_OPERATOR\r
+ *  - comicElementOperator\r
+ */\r
+       var POSITION_OPERATOR = ( function(){\r
+               var     MOUSE_CURSOR = updateMouseCursor,\r
+                       GRID_ENABLED = GRID_CONTROL.enabled;\r
+               \r
+               var currentElement,\r
+                       startX, startY,\r
+                       x, y,\r
+                       offsetX, offsetY,\r
+                       isCopy = false;\r
+               \r
+               function update( _x, _y){\r
+                       x = _x !== undefined ? _x : x;\r
+                       y = _y !== undefined ? _y : y;\r
+                       RESIZE_OPERATOR.update( x, y);\r
+                       currentElement.resize( x, y);\r
+                       INFOMATION_WINDOW.update( currentElement);\r
+               }\r
+               \r
+               return {\r
+                       onStart: function( _currentElement, _mouseX, _mouseY){\r
+                               currentElement = _currentElement;\r
+                               offsetX = _mouseX;\r
+                               offsetY = _mouseY;\r
+                               startX = x = _currentElement.x;\r
+                               startY = y = _currentElement.y;\r
+                               MOUSE_CURSOR( 'move');\r
+                       },\r
+                       onDrag: function( _mouseX, _mouseY){\r
+                               var moveX = _mouseX -offsetX,\r
+                                       moveY = _mouseY -offsetY,\r
+                                       _x = startX +moveX,\r
+                                       _y = startY +moveY;\r
+                               if( GRID_ENABLED() === true){\r
+                                       _x = Math.floor( _x / 10) * 10;\r
+                                       _y = Math.floor( _y / 10) * 10;\r
+                               }\r
+                               update( _x, _y);\r
+                       },\r
+                       onFinish: function(){\r
+                               MOUSE_CURSOR( '');\r
+                               if( x === startX && y === startY) return;\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.resize( x, y);\r
+                               currentElement.resize( x, y);\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.saveStatus( startX, startY);\r
+                       },\r
+                       onCancel: function(){\r
+                               MOUSE_CURSOR( '');\r
+                               COMIC_ELEMENT_OPERATION_MANAGER.resize( startX, startY);\r
+                               currentElement.animate( startX, startY);\r
+                       },\r
+                       onShiftUpdate: update,\r
+                       onCtrlUpdate: update\r
+               }\r
+       })();\r
+\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * COMIC_ELEMENT_OPERATION_MANAGER\r
+ */\r
+       var COMIC_ELEMENT_OPERATION_MANAGER = ( function(){\r
+               var     MOUSE_CURSOR = updateMouseCursor,\r
+                       SAVE = HISTORY_CONTROL.saveState,\r
+                       GRID_ENABLED = GRID_CONTROL.enabled,\r
+                       HIT_AREA = MOUSE_HIT_AREA,\r
+                       currentIsTextElement = false,\r
+                       currentOperator = null,\r
+                       currentElement = null,\r
+                       currentx, currenty, currentw, currenth, angle, flipV, flipH;\r
+\r
+                       function resize( _x, _y, _w, _h, _angle){\r
+                               currentx = _x !== undefined ? _x : currentx;\r
+                               currenty = _y !== undefined ? _y : currenty;\r
+                               currentw = _w !== undefined ? _w : currentw;\r
+                               currenth = _h !== undefined ? _h : currenth;\r
+                               angle = _angle !== undefined ? _angle : angle;\r
+\r
+                               RESIZE_OPERATOR.update( currentx, currenty, currentw, currenth);\r
+                               currentIsTextElement === true && TAIL_OPERATOR.update( currentw, currenth, angle);\r
+                               CONSOLE_CONTROLER.show( currentElement, currentw, currenth);\r
+                               INFOMATION_WINDOW.update( currentElement);\r
+                       }\r
+                       function show( _currentElement){\r
+                               currentElement === null && RESIZE_OPERATOR.show( _currentElement);\r
+                               if( currentElement !== _currentElement){\r
+                                       currentElement = _currentElement;\r
+                                       \r
+                                       currentIsTextElement = ( _currentElement.type === PANEL_ELEMENT_TYPE_TEXT);\r
+                                       currentIsTextElement === true ? TAIL_OPERATOR.show( _currentElement) : TAIL_OPERATOR.hide();\r
+                                       \r
+                                       flipV = currentIsTextElement === false ? _currentElement.flipV() : 0;\r
+                                       flipH = currentIsTextElement === false ? _currentElement.flipH() : 0;\r
+                                       \r
+                                       resize(\r
+                                               _currentElement.x, _currentElement.y, _currentElement.w, _currentElement.h,\r
+                                               currentIsTextElement === true ? _currentElement.angle() : 0\r
+                                       );\r
+                               }\r
+                       }\r
+\r
+                       pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 16, undefined, undefined, function( e){\r
+                               currentOperator !== null && currentOperator.onShiftUpdate && currentOperator.onShiftUpdate();\r
+                       });\r
+                       pettanr.key.addKeyUpdateEvent( pettanr.view.EDITOR, 17, undefined, undefined, function( e){\r
+                               currentOperator !== null && currentOperator.onCtrlUpdate && currentOperator.onCtrlUpdate();\r
+                       });\r
+                       pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 27, false, false, function( e){\r
+                               currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();\r
+                               currentOperator = null;\r
+                       });\r
+               return {\r
+                       open: function(){\r
+                               this.hide();\r
+                       },\r
+                       close: function(){\r
+                               \r
+                       },\r
+                       hide: function(){\r
+                               currentElement !== null && RESIZE_OPERATOR.hide();\r
+                               currentElement = null;\r
+                               MOUSE_CURSOR( '');\r
+                               TAIL_OPERATOR.hide();\r
+                               CONSOLE_CONTROLER.hide();\r
+                               INFOMATION_WINDOW.update( null);\r
+                       },\r
+                       resize: resize,\r
+                       restoreState: function( arg){\r
+                               if( arg && arg.length !== 8) return;\r
+                               var _currentElement = arg[ 0],\r
+                                       _x = arg[ 1], _y = arg[ 2], _w = arg[ 3], _h = arg[ 4],\r
+                                       _a = arg[ 5],\r
+                                       _flipV = arg[ 6], _flipH = arg[ 7];\r
+                               if( !_currentElement && !currentOperator) return;\r
+                               _currentElement.type === PANEL_ELEMENT_TYPE_IMAGE ?\r
+                                       _currentElement.animate( _x, _y, _w, _h, _flipV, _flipH) :\r
+                                       _currentElement.animate( _x, _y, _w, _h, _a);\r
+                               currentOperator !== null && currentOperator.onCancel && currentOperator.onCancel();\r
+                               currentOperator = null;\r
+                               currentElement === _currentElement ? resize( _x, _y, _w, _h, _a) : show( _currentElement);\r
+                       },\r
+                       saveStatus: function( startX, startY, startW, startH, startA, startFilpV, startFilpH){\r
+                               startX = startX !== undefined ? startX : currentx;\r
+                               startY = startY !== undefined ? startY : currenty;\r
+                               startW = startW !== undefined ? startW : currentw;\r
+                               startH = startH !== undefined ? startH : currenth;\r
+                               startA = startA !== undefined ? startA : angle;\r
+                               startFilpV = startFilpV !== undefined ? startFilpV : flipV;\r
+                               startFilpH = startFilpH !== undefined ? startFilpH : flipH;\r
+                               currentElement && SAVE( COMIC_ELEMENT_OPERATION_MANAGER.restoreState,\r
+                                       [ currentElement, startX, startY, startW, startH, startA, startFilpV, startFilpH],\r
+                                       [ currentElement, currentx, currenty, currentw, currenth, angle, flipV, flipH]\r
+                               );\r
+                       },\r
+                       busy: function(){\r
+                               return currentOperator !== null;\r
+                       },\r
+                       hitTest: function( _mouseX, _mouseY, _comicElement ){\r
+                               var _x, _y, _w, _h;\r
+                               if( _comicElement === currentElement){\r
+                                       var _consoleX = CONSOLE_CONTROLER.x();\r
+                                       _x = currentx +( _consoleX < 0 ? _consoleX : 0) -HIT_AREA;\r
+                                       _y = currenty -HIT_AREA;\r
+                                       var _consoleW = CONSOLE_CONTROLER.w();\r
+                                       _w = ( _consoleW < currentw ? currentw : _consoleW) +HIT_AREA *2;\r
+                                       var _consoleY = CONSOLE_CONTROLER.y();\r
+                                       _h = ( _consoleY < currenth ? currenth : _consoleY +CONSOLE_CONTROLER.h()) +HIT_AREA *2;\r
+                               } else {\r
+                                       _x = _comicElement.x -HIT_AREA;\r
+                                       _y = _comicElement.y -HIT_AREA;\r
+                                       _w = _comicElement.w +HIT_AREA *2;\r
+                                       _h = _comicElement.h +HIT_AREA *2;\r
+                               }\r
+                               log.html( [ _x, _y, _w, _h ].join( ' ') );\r
+                               return _x <= _mouseX && _mouseX <= _x + _w && _y <= _mouseY && _mouseY <= _y + _h;\r
+                       },\r
+                       onMouseDown: function( _currentElement, _mouseX, _mouseY){\r
+                               //show( _currentElement);\r
+                               if( currentIsTextElement === true && TAIL_OPERATOR.onStart( _currentElement, _mouseX, _mouseY) === true){\r
+                                       currentOperator = TAIL_OPERATOR;\r
+                               } else\r
+                               if( RESIZE_OPERATOR.onStart( _currentElement, _mouseX, _mouseY) === true){\r
+                                       currentOperator = RESIZE_OPERATOR;\r
+                               } else {\r
+                                       POSITION_OPERATOR.onStart( _currentElement, _mouseX, _mouseY)\r
+                                       currentOperator = POSITION_OPERATOR;\r
+                               }\r
+                       },\r
+                       onMouseMove: function( _currentElement, _mouseX, _mouseY){\r
+                               show( _currentElement);\r
+                               if( currentOperator !== null){\r
+                                       currentOperator.onDrag( _mouseX, _mouseY);                                              \r
+                               } else\r
+                               if( currentElement !== null){\r
+                                       CONSOLE_CONTROLER.onMouseMove( _mouseX -currentx, _mouseY -currenty);\r
+                                       if( currentIsTextElement === false || TAIL_OPERATOR.hitTest( _mouseX -currentx, _mouseY -currenty) === false){\r
+                                               RESIZE_OPERATOR.index( _mouseX, _mouseY);\r
+                                       }\r
+                               }\r
+                       },\r
+                       onMouseUp: function( _currentElement, _mouseX, _mouseY){\r
+                               currentOperator !== null && currentOperator.onFinish();\r
+                               currentOperator = null;\r
+                       }\r
+               }\r
+       })();\r
+       /*\r
+        *  // COMIC_ELEMENT_OPERATION_MANAGER\r
+        */\r
+\r
+       var AbstractComicElement = function( COMIC_ELM_TYPE ){\r
+               this.type = COMIC_ELM_TYPE;\r
+               this.hitTest = function( _mouseX, _mouseY ){\r
+                       return COMIC_ELEMENT_OPERATION_MANAGER.hitTest( _mouseX, _mouseY, this );\r
+               }\r
+               this.shift = function( _shiftX, _shiftY ){\r
+                       this.resize( this.x + _shiftX, this.y + _shiftY);\r
+               }\r
+               this.busy = function(){\r
+                       return COMIC_ELEMENT_OPERATION_MANAGER.busy();\r
+               }\r
+               this.onMouseMove = function( _mouseX, _mouseY ){\r
+                       COMIC_ELEMENT_OPERATION_MANAGER.onMouseMove( this, _mouseX, _mouseY );\r
+               }\r
+               this.onMouseUp = function( _mouseX, _mouseY ){\r
+                       COMIC_ELEMENT_OPERATION_MANAGER.onMouseUp( this, _mouseX, _mouseY );\r
+               }\r
+               this.onMouseDown = function( _mouseX, _mouseY ){\r
+                       COMIC_ELEMENT_OPERATION_MANAGER.onMouseDown( this, _mouseX, _mouseY );\r
+               }\r
+       };\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * ImageElementClass\r
+ */\r
+       var     jqImageElementOrigin;\r
+       var ImageElementClass = function( data ){\r
+               jqImageElementOrigin = jqImageElementOrigin || $( $( '#imgElementTemplete').remove().html());\r
+               \r
+               var JQ_WRAPPER = jqImageElementOrigin.clone( true ),\r
+                       SAVE = HISTORY_CONTROL.saveState,\r
+                       HIT_AREA = MOUSE_HIT_AREA,\r
+                       w = data.width,\r
+                       h = data.height,\r
+                       x, y, z, timing,\r
+                       flipH = w < 0 ? -1 : 1,\r
+                       flipV = h < 0 ? -1 : 1,\r
+                       resourcePicture,\r
+                       actualW,\r
+                       actualH,\r
+                       reversibleImage = null,\r
+                       instance = this;\r
+               w = Math.floor( w );\r
+               h = Math.floor( h );\r
+\r
+               function onAnimeComplete(){\r
+                       reversibleImage.resize( flipH * w, flipV * h );\r
+               }\r
+               function updateResourcePicture( _resourcePicture ){\r
+                       resourcePicture = _resourcePicture;\r
+                       \r
+                       actualW = _resourcePicture.width;\r
+                       actualH = _resourcePicture.height;\r
+                       \r
+                       var _reversibleImage = pettanr.image.createReversibleImage( \r
+                               [ pettanr.CONST.RESOURCE_PICTURE_PATH, _resourcePicture.id, '.', _resourcePicture.ext ].join(''),\r
+                               flipH * w, flipV * h\r
+                       );\r
+                       if( reversibleImage !== null){\r
+                               JQ_WRAPPER.children( reversibleImage.elm ).replaceWith( _reversibleImage.elm );\r
+                               reversibleImage.destroy();\r
+                       } else {\r
+                               JQ_WRAPPER.append( _reversibleImage.elm );\r
+                       }\r
+                       reversibleImage = _reversibleImage;\r
+               }\r
+               /* global methods */\r
+               this.$ = JQ_WRAPPER;\r
+               //this.x = x;\r
+               //this.y = y;\r
+               //this.w = w;\r
+               //this.h = h;                                   \r
+               this.z = data.z;\r
+               this.timing = timing;\r
+               this.init = function(){\r
+                       updateResourcePicture( data.resource_picture );\r
+                       instance.resize( data.x, data.y, data.width, data.height );\r
+                       delete instance.init;\r
+               }\r
+               this.flip = function( _updateH, _updateV ){\r
+                       if( _updateH !== true && _updateV !== true ) return;\r
+                       flipH = _updateH === true ? -flipH : flipH;\r
+                       flipV = _updateV === true ? -flipV : flipV;\r
+                       reversibleImage.resize( flipH * w, flipV * h );\r
+               }\r
+               this.flipV = function(){\r
+                       return flipV;\r
+               }\r
+               this.flipH = function(){\r
+                       return flipH;\r
+               }\r
+               this.resourcePicture = function( _resourcePicture ){\r
+                       if( _resourcePicture && _resourcePicture !== resourcePicture ){\r
+                               SAVE( updateResourcePicture, resourcePicture, _resourcePicture );\r
+                               updateResourcePicture( _resourcePicture );\r
+                       }\r
+                       return resourcePicture;\r
+               }\r
+               this.getArtistID = function(){\r
+                       return resourcePicture.artist_id || resourcePicture.artist.id || -1;\r
+               }\r
+               this.actualW = function(){ return actualW;}\r
+               this.actualH = function(){ return actualH;}\r
+               this.keepSize = false;\r
+               this.resize = function( _x, _y, _w, _h, animate ){\r
+                       instance.x = x = _x !== undefined ? _x : x;\r
+                       instance.y = y = _y !== undefined ? _y : y;\r
+                       instance.w = w = _w !== undefined ? _w : w;\r
+                       instance.h = h = _h !== undefined ? _h : h;\r
+                       JQ_WRAPPER[ animate === true ? 'animate' : 'css' ]( { \r
+                               left:   x,\r
+                               top:    y,\r
+                               width:  w,\r
+                               height: h\r
+                       }, 250, onAnimeComplete );\r
+                       animate !== true && onAnimeComplete();\r
+               }\r
+               this.animate = function ( _x, _y, _w, _h, _flipH, _flipV ){\r
+                       flipH = _flipH !== undefined ? _flipH : flipH;\r
+                       flipV = _flipV !== undefined ? _flipV : flipV;\r
+                       instance.resize( _x, _y, _w, _h, true);\r
+               }\r
+               this.getAsHTML = function( isAbsoluteUrl, isXHTML ){\r
+                       return [\r
+                               '<img ',\r
+                                       'src="', isAbsoluteUrl !== true ? url : pettanr.util.getAbsolutePath( url), '" ',\r
+                                       'width="', w, '" ',\r
+                                       'height="', h, '" ',\r
+                                       'style="',                                                                      \r
+                                               'left:', x, 'px;',\r
+                                               'top:', y, 'px;',\r
+                                               'z-index:', this.z, ';',\r
+                                       '"',\r
+                               isXHTML !== true ? '>' : ' \/>'\r
+                       ].join( '');\r
+               }\r
+               this.getAsJsonString = function(){\r
+                       var cr = pettanr.LINE_FEED_CODE_TEXTAREA;\r
+                       return [\r
+                               '"new', this.timing, '": {', cr,\r
+                                       '"resource_picture_id": 1,', cr,\r
+                                       '"x": ', x, ',', cr,\r
+                                       '"y": ', y, ',', cr,\r
+                                       '"z": ', this.z, ',', cr,\r
+                                       '"width": ', w, ',', cr,\r
+                                       '"height": ', h, ',', cr,\r
+                                       '"flipv": ', flipV === true ? 1 : 0, ',', cr,\r
+                                       '"fliph": ', flipH === true ? 1 : 0, ',', cr,\r
+                                       '"t": ', this.timing, cr,\r
+                               '}'\r
+                       ].join( '');\r
+               }\r
+               this.destroy = function(){\r
+                       reversibleImage.destroy();\r
+                       JQ_WRAPPER.remove();\r
+                       JQ_WRAPPER = reversibleImage = resourcePicture = data = instance = SAVE = null;\r
+                       delete this.destroy;\r
+               }\r
+       }\r
+       ImageElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_IMAGE );\r
+/*\r
+ * / ImageElementClass\r
+ * --------------------------------------------------------------------------------------------\r
+ */\r
+\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * TextElementClass\r
+ * \r
+ * type\r
+ * 0.none\r
+ * 1.speach balloon\r
+ * 2.think\r
+ * 3.bom\r
+ * 4.black-box( dq style)\r
+ * 5.blue-box( ff style)\r
+ * \r
+ */\r
+       var jqTextElementOrigin;\r
+       var TextElementClass = function( data ){\r
+               jqTextElementOrigin = jqTextElementOrigin || ( function(){\r
+                       var _OLD_IE = $( $( '#textElementTempleteForOldIE').remove().html()),\r
+                               _MODERN = $( $( '#textElementTemplete').remove().html());\r
+                       return pettanr.ua.isIE === true && pettanr.ua.ieRenderingVersion < 8 ? _OLD_IE : _MODERN;\r
+               })();\r
+               \r
+               var JQ_WRAPPER = jqTextElementOrigin.clone( true ),\r
+                       TEXT_ELM = JQ_WRAPPER.find( 'td,.speach-inner').eq( 0),\r
+                       HIT_AREA = MOUSE_HIT_AREA,\r
+                       SAVE     = HISTORY_CONTROL.saveState,\r
+                       type     = data.balloon_template_id,\r
+                       text     = ( function(){\r
+                               var _speachs = data.speaches_attributes;\r
+                               for( var k in _speachs ){\r
+                                       return _speachs[ k ].content || '';\r
+                               }\r
+                               return '';\r
+                       }),\r
+                       balloon = pettanr.balloon.createBalloon( data.width, data.height, data.tail, type ),\r
+                       x, y, w, h, a,\r
+                       instance = this;\r
+               \r
+               JQ_WRAPPER.find( 'img').eq( 0).replaceWith( balloon.elm );\r
+               \r
+               function updateType( _type ){\r
+                       if( type !== _type ){\r
+                               type = _type || type;\r
+                               balloon.type( type );\r
+                       }\r
+               }\r
+               function updateAngle( _a){\r
+                       if( _a !== undefined && a !== _a ){\r
+                               a = _a !== undefined ? _a : a;\r
+                               balloon.angle( a );\r
+                       }\r
+               }\r
+               function updateText( _text){\r
+                       text = _text || text || '';\r
+                       TEXT_ELM.html( text );\r
+               }\r
+               \r
+               /* global methods */\r
+               this.$ = JQ_WRAPPER;\r
+               //this.x = x;\r
+               //this.y = y;\r
+               //this.w = w;\r
+               //this.h = h;\r
+               this.z = data.z;\r
+               this.timing = data.t;\r
+               this.init = function(){\r
+                       updateText();\r
+                       instance.resize( data.x, data.y, data.width, data.height, data.tail );\r
+                       delete instance.init;\r
+               }\r
+               this.angle = function( _a){\r
+                       _a !== undefined && instance.resize( undefined, undefined, undefined, undefined, _a);\r
+                       return a;\r
+               }\r
+               this.text = function( _text){\r
+                       if( _text && text !== _text) {\r
+                               SAVE( updateText, text || '', _text);\r
+                               updateText( _text);\r
+                       }\r
+                       return text;\r
+               }\r
+               this.resize = function( _x, _y, _w, _h, _a, animate ){\r
+                       instance.x = x = _x !== undefined ? _x : x;\r
+                       instance.y = y = _y !== undefined ? _y : y;\r
+                       instance.w = w = _w !== undefined ? _w : w;\r
+                       instance.h = h = _h !== undefined ? _h : h;\r
+                       a = _a !== undefined ? _a : a;\r
+                       \r
+                       JQ_WRAPPER[ animate === true ? 'animate' : 'css']( {\r
+                                       left:           x,\r
+                                       top:            y,\r
+                                       width:          w,\r
+                                       height:         h\r
+                               }, 250,\r
+                               function(){\r
+                                       balloon.resize( a, w, h);\r
+                               }\r
+                       );              \r
+                       animate !== true && balloon.resize( a, w, h);\r
+               }\r
+               this.animate = function ( _x, _y, _w, _h, _a ){\r
+                       instance.resize( _x, _y, _w, _h, _a, true);\r
+               }\r
+               this.destroy = function(){\r
+                       JQ_WRAPPER.remove();\r
+                       balloon.destroy();\r
+                       balloon = null;\r
+                       delete instance.destroy;\r
+               }\r
+               this.getAsJSON = function(){\r
+                       \r
+               }\r
+               this.getAsJsonString = function(){\r
+                       var cr = pettanr.LINE_FEED_CODE_TEXTAREA;\r
+                       return [\r
+                               '"new', this.timing, '": {', cr,\r
+                                       '"balloon_template_id": ', 1, ',', cr,\r
+                                       '"system_picture_id": ', 1, ',', cr,\r
+                                       '"size": ', 1, ',', cr,\r
+                                       '"tail": ', a, ',', cr,\r
+                                       '"x": ', x, ',', cr,\r
+                                       '"y": ', y, ',', cr,\r
+                                       '"z": ', this.z, ',', cr,\r
+                                       '"t": ', this.timing, ',', cr,\r
+                                       '"width": ', w, ',', cr,\r
+                                       '"height": ', h, ',', cr,\r
+                                       '"speaches_attributes": {', cr,\r
+                                               '"newf', this.timing, '": {', cr,\r
+                                               '"content": "', text, '",', cr,\r
+                                                       '"x": ', x, ',', cr,\r
+                                                       '"y": ', y, ',', cr,\r
+                                                       '"t": ', 0, ',', cr,\r
+                                                       '"width": ', w, ',', cr,\r
+                                                       '"height": ', h, cr,\r
+                                               '}', cr,\r
+                                       '}', cr,\r
+                               '}'\r
+                       ].join( '');\r
+               }\r
+               this.getAsHTML = function( isAbsoluteUrl, isXHTML){\r
+                       var url = balloon.getURL();\r
+                       return [\r
+                               '<img ',\r
+                                       'src="', isAbsoluteUrl !== true ? url : pettanr.util.getAbsolutePath( url), '" ',\r
+                                       'width="', w, '" ',\r
+                                       'height="', h, '" ',\r
+                                       'style="',                                                                      \r
+                                               'left:', x, 'px;',\r
+                                               'top:', y, 'px;',\r
+                                               'z-index:', this.z, ';',\r
+                                       '"',\r
+                               isXHTML !== true ? '>' : ' \/>',\r
+                               pettanr.LINE_FEED_CODE_TEXTAREA,\r
+                               '<div class="balloon" style="',\r
+                                       'left:', x, 'px;',\r
+                                       'top:', y, 'px;',\r
+                                       'width:', w, 'px;',\r
+                                       'height:', h, 'px;',\r
+                                       'z-index:', this.z,\r
+                               '"><span>', text, '<\/span>', '<\/div>'\r
+                                       \r
+                       ].join( '');\r
+               }\r
+               this.getAsXML = function(){}\r
+       }\r
+       TextElementClass.prototype = new AbstractComicElement( PANEL_ELEMENT_TYPE_TEXT );\r
+\r
+/* --------------------------------------------------------------------------------------------\r
+ * COMIC_ELEMENT_CONTROL\r
+ *  - mouseEventListener\r
+ */\r
+       var COMIC_ELEMENT_CONTROL = ( function(){\r
+               var     SAVE = HISTORY_CONTROL.saveState,\r
+                       ELM_CONTAINER = document.getElementById( 'comic-element-container'),\r
+                       currentElement = null,\r
+                       currentLockTest = false,\r
+                       currentLock = false,\r
+                       panelX, panelY, panelW, panelH,\r
+                       startX, startY;\r
+       /*\r
+        * append, remove, replace\r
+        * \r
+        * comicElement には、z-position と dom-index がある。\r
+        *   z-position は 表示上の位置。大きいほど前に表示される( z-index)\r
+        *   dom-index は 意味上の順番。htmlタグの登場順で、検索結果や音声読み上げブラウザで正しく意味が取れる順番。\r
+        * \r
+        * editerでは、実際には z-index は使わず、htmlの順序で前後を表現する。\r
+        * dom-index は、数値のみ保持して、投稿時にcomicElementを適宜に並び替える。\r
+        * \r
+        * append comicElement\r
+        * 1. 新しい comicElement の z-position を得る\r
+        * 2. z の同じ comicElementを見つけ、その前に加える。または一番先頭へ。(COMIC_ELEMENT_ARRAY)\r
+        *    zが大きいほど、COMIC_ELEMENT_ARRAYの先頭へ。\r
+        * 3. dom位置は、COMIC_ELEMENT_ARRAY とは反対に、前のものほど後ろへ。\r
+        * \r
+        * \r
+        * remove comicElement\r
+        * 1. remove\r
+        * 2. renumber z\r
+        */\r
+               function appendComicElement( _comicElement ) {\r
+                       var z = _comicElement.z,\r
+                               l = COMIC_ELEMENT_ARRAY.length,\r
+                               _jqElm = _comicElement.$.stop().css( {\r
+                                       filter:         '',\r
+                                       opacity:        ''\r
+                               });\r
+                       if( typeof z !== 'number' || z < 0 || z >= l ){\r
+                               COMIC_ELEMENT_ARRAY.unshift( _comicElement );\r
+                               ELM_CONTAINER.appendChild( _jqElm.get( 0 ));\r
+                               _jqElm.fadeIn();\r
+                       } else {\r
+                               var insertIndex = 0;\r
+                               for( var i = 0; i < l; ++i ){\r
+                                       if( COMIC_ELEMENT_ARRAY[ i ].z <= z ){\r
+                                               insertIndex = i;\r
+                                               break;\r
+                                       }\r
+                               }\r
+                               COMIC_ELEMENT_ARRAY[ insertIndex ].$.before( _jqElm.fadeIn() );\r
+                               COMIC_ELEMENT_ARRAY.splice( insertIndex, 0, _comicElement );\r
+                       }\r
+                       renumber();\r
+               }\r
+               function removeComicElement( _comicElement ) {\r
+                       var l = COMIC_ELEMENT_ARRAY.length;\r
+                       for( var i=0; i<l; ++i){\r
+                               if( COMIC_ELEMENT_ARRAY[ i ] === _comicElement ){\r
+                                       COMIC_ELEMENT_ARRAY.splice( i, 1 );\r
+                                       renumber();\r
+                                       _comicElement.$.stop().css( {\r
+                                               filter:         '',\r
+                                               opacity:        ''\r
+                                       }).fadeOut( onFadeOut );\r
+                                       currentElement = currentElement === _comicElement ? null : currentElement;\r
+                                       return;\r
+                               }\r
+                       }\r
+                       function onFadeOut(){\r
+                               this.parentNode.removeChild( this );\r
+                       }\r
+               }\r
+               function restoreComicElement( arg ){\r
+                       var isAppend = arg[ 0 ],\r
+                               comicElement = arg[ 1 ];\r
+                       isAppend === true ? appendComicElement( comicElement ) : removeComicElement( comicElement );\r
+               }\r
+               /*\r
+                * COMIC_ELEMENT_ARRAY の順番を基準に、zの再計算\r
+                * jqElmの並び替え。\r
+                */\r
+               function renumber(){\r
+                       var l = COMIC_ELEMENT_ARRAY.length,\r
+                               _comicElement, jqElm, jqNext;\r
+                       for( var i=0; i < l; ++i){\r
+                               _comicElement = COMIC_ELEMENT_ARRAY[ i ];\r
+                               jqElm = _comicElement.$;\r
+                               jqNext && jqNext.before( jqElm );\r
+                               _comicElement.z = l -i -1;\r
+                               jqNext = jqElm;\r
+                       }\r
+               }\r
+               function replaceComicElement( _comicElement, goForward ){\r
+                       // COMIC_ELEMENT_ARRAYの再構築\r
+                       var l = COMIC_ELEMENT_ARRAY.length,\r
+                               i = ( function(){\r
+                                       for( var ret = 0; ret < l; ++ret ){\r
+                                               if( COMIC_ELEMENT_ARRAY[ ret] === _comicElement ) return ret;\r
+                                       }\r
+                                       return -1;\r
+                               })();\r
+                       if( i === -1) return false;\r
+                       if( goForward === true){\r
+                               if( i === 0) return false;\r
+                               COMIC_ELEMENT_ARRAY.splice( i, 1);\r
+                               COMIC_ELEMENT_ARRAY.splice( i -1, 0, _comicElement);\r
+                       } else {\r
+                               if( i === l -1) return false;\r
+                               COMIC_ELEMENT_ARRAY.splice( i, 1);\r
+                               COMIC_ELEMENT_ARRAY.splice( i +1, 0, _comicElement);\r
+                       }\r
+                       renumber();\r
+                       return true;\r
+               }\r
+               function restoreReplaceElement( arg){\r
+                       replaceComicElement( arg[ 0], arg[ 1]);\r
+               }\r
+               \r
+               return {\r
+                       init: function(){\r
+                               log = $( '#operation-catcher-log');\r
+                               \r
+                               delete COMIC_ELEMENT_CONTROL.init;\r
+                       },\r
+                       open: function(){\r
+                               COMIC_ELEMENT_CONTROL.init && COMIC_ELEMENT_CONTROL.init();\r
+                       },\r
+                       close: function(){\r
+                               var _comicElm;\r
+                               while( COMIC_ELEMENT_ARRAY.length > 0){\r
+                                       _comicElm = COMIC_ELEMENT_ARRAY.shift();\r
+                                       _comicElm.destroy && _comicElm.destroy();\r
+                               }\r
+                       },\r
+                       remove: removeComicElement,\r
+                       restore: restoreComicElement,\r
+                       replace: replaceComicElement,\r
+                       restoreReplace: restoreReplaceElement,\r
+                       onPanelResize : function ( _panelX, _panelY, _panelW, _panelH, isResizerTopAction ){\r
+                       /*\r
+                        * リサイズが、ResizerTopによって行われた場合、comicElementのyを動かして見かけ上動かないようにする。\r
+                        */                                     \r
+                               if( isResizerTopAction === true){\r
+                                       var     _shiftX = _panelW -panelW,\r
+                                               _shiftY = _panelH -panelH,\r
+                                               l = COMIC_ELEMENT_ARRAY.length;\r
+                                       for( var i = 0; i < l; i++){\r
+                                               COMIC_ELEMENT_ARRAY[ i].shift( _shiftX, _shiftY);\r
+                                       }\r
+                               }\r
+                               panelX = _panelX;\r
+                               panelY = _panelY;\r
+                               panelW = _panelW;\r
+                               panelH = _panelH;\r
+                               \r
+                               ELM_CONTAINER.style.width       = _panelW +'px';\r
+                               ELM_CONTAINER.style.height      = _panelH +'px';\r
+                               ELM_CONTAINER.style.left        = _panelX +'px';\r
+                               ELM_CONTAINER.style.top         = _panelY +'px';\r
+                       },\r
+                       onMouseMove: function( _mouseX, _mouseY ){\r
+                               var l = COMIC_ELEMENT_ARRAY.length,\r
+                                       _x = _mouseX -panelX,\r
+                                       _y = _mouseY -panelY,\r
+                                       _elm = currentElement;\r
+                                       \r
+                               if( _elm !== null){\r
+                                       currentLockTest = currentLockTest === true && _x === 0 && _y === 0;\r
+                                       if( _elm.busy() === true ){\r
+                                               _elm.onMouseMove( _x, _y);\r
+                                               return true;\r
+                                       }\r
+                                       if( _elm.hitTest( _x, _y) === true ){\r
+                                               _elm.onMouseMove( _x, _y ); // cursor\r
+                                               return true;\r
+                                       }\r
+                                       if( currentLock === true){\r
+                                               currentLockTest = true;\r
+                                               return true;\r
+                                       }\r
+                               }\r
+                               for( var i=0; i<l; i++){\r
+                                       _elm = COMIC_ELEMENT_ARRAY[ i ];\r
+                                       // hitTest\r
+                                       if( _elm.hitTest( _x, _y ) === true ){\r
+                                               _elm.onMouseMove( _x, _y ); // cursor\r
+                                               log.html( [ _x, _y, i].join( ','));\r
+                                               currentElement = _elm;\r
+                                               return true;\r
+                                       } else {\r
+                                               log.html( [ _elm.x, _elm.y, i].join( ','));\r
+                                       }\r
+                               }\r
+                               currentElement = null;                                                  \r
+                               COMIC_ELEMENT_OPERATION_MANAGER.hide();\r
+                               return false;\r
+                       },\r
+                       onMouseUp: function( _mouseX, _mouseY){\r
+                               var ret = currentElement !== null && currentElement.busy() === true;\r
+                               ret === true && currentElement.onMouseUp( _mouseX -startX || panelX, _mouseY -startY || panelY);\r
+                               currentLock = currentLockTest === true && currentElement.hitTest( _mouseX -panelX, _mouseY -panelY) === true;\r
+                               RESIZE_OPERATOR.lock( currentLock);\r
+                               INFOMATION_WINDOW.lock( currentLock);\r
+                               return ret;\r
+                       },\r
+                       onMouseDown: function( _mouseX, _mouseY){\r
+                               startX = panelX;\r
+                               startY = panelY;\r
+                               if( currentElement === null) return false\r
+                               currentElement.onMouseDown( _mouseX -startX, _mouseY -startY);\r
+                               currentLockTest = true;\r
+                               return true;\r
+                       },\r
+                       busy: function(){\r
+                               return currentElement !== null;\r
+                       },\r
+                       createImageElement: function( data ){\r
+                               if( Type.isObject( data ) === false ){\r
+                                       pettanr.premiumSatge.bootInOverlay( 1, onImageSelect );\r
+                               } else {\r
+                                       onImageSelect( data, true );\r
+                               }\r
+                               function onImageSelect( data, isPanelPictureData ){\r
+                                       if( isPanelPictureData !== true ){\r
+                                               data = {\r
+                                                       resource_picture:data,\r
+                                                       x:               Math.floor( panelW /2 - data.width /2 ),\r
+                                                       y:               Math.floor( panelH /2 - data.height /2 ),\r
+                                                       z:               -1,\r
+                                                       t:               COMIC_ELEMENT_ARRAY.length,\r
+                                                       width:           data.width,\r
+                                                       height:          data.height\r
+                                               }\r
+                                       }\r
+                                       var _comicElement = new ImageElementClass( data );\r
+                                       _comicElement.init && _comicElement.init();\r
+                                       appendComicElement( _comicElement );\r
+                                       _comicElement.animate( undefined, undefined, data.width, data.height );\r
+                                       SAVE( restoreComicElement, [ false, _comicElement], [ true, _comicElement], true );\r
+                               }\r
+                       },\r
+                       createTextElement: function( data ){\r
+                               var _comicElement;\r
+                               if( Type.isObject( data ) === false ){\r
+                                       data = {\r
+                                               balloon_template_id:1,\r
+                                               size:               1,\r
+                                               tail:               0,\r
+                                               x:                                      Math.floor( panelW /2 - 100 +Math.random() *10 ),\r
+                                               y:                  Math.floor( panelH /2 - 100 +Math.random() *10 ),\r
+                                               z:                  -1,\r
+                                               t:                  COMIC_ELEMENT_ARRAY.length,\r
+                                               width:              200,\r
+                                               height:             200,\r
+                                               speaches_attributes: {\r
+                                                       text1: {\r
+                                                               content:    'Hello'\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                                       _comicElement = new TextElementClass( data );\r
+                                       _comicElement.init();\r
+                                       pettanr.textEditor.bootInOverlay( PANEL_CONTROL.x(), PANEL_CONTROL.y(), _comicElement, onTextInput );\r
+                               } else {\r
+                                       _comicElement = new TextElementClass( data );\r
+                                       _comicElement.init();\r
+                                       onTextInput( _comicElement );\r
+                               }\r
+                               function onTextInput( _comicElement ){\r
+                                       appendComicElement( _comicElement );\r
+                                       SAVE( restoreComicElement, [ false, _comicElement ], [ true, _comicElement ], true );\r
+                               }\r
+                       },\r
+                       getAsHTML: function( isAbsoluteUrl, isXHTML){\r
+                               var HTML_ARRAY = [],\r
+                                       l = COMIC_ELEMENT_ARRAY.length,\r
+                                       _timing = 0,\r
+                                       _comicElement;\r
+\r
+                               while( HTML_ARRAY.length < l){\r
+                                       _comicElement = getComicElementByTiming();\r
+                                       if( _comicElement === null) break;\r
+                                       HTML_ARRAY.push( _comicElement.getAsHTML( isAbsoluteUrl, isXHTML));\r
+                               }\r
+                               function getComicElementByTiming(){\r
+                                       while( _timing < l *2){\r
+                                               for(var i=0; i<l; ++i){\r
+                                                       if( _timing === COMIC_ELEMENT_ARRAY[ i].timing){\r
+                                                               ++_timing;\r
+                                                               return COMIC_ELEMENT_ARRAY[ i];\r
+                                                       }\r
+                                               }\r
+                                               ++_timing;\r
+                                       }\r
+                                       return null;\r
+                               }\r
+                               HTML_ARRAY.unshift(\r
+                                       [\r
+                                               '<div class="panel" ',\r
+                                                       'style="',\r
+                                                               'height:', panelH, 'px;',\r
+                                                               'background-color:', ';',\r
+                                                       '"',\r
+                                               '>'\r
+                                       ].join( '')\r
+                               );              \r
+                               HTML_ARRAY.push( '</div>');\r
+                               \r
+                               return HTML_ARRAY.join( pettanr.LINE_FEED_CODE_TEXTAREA);\r
+                       },\r
+                       getAsJsonString: function(){\r
+                               var JSON_STRING_ARRAY = [],\r
+                                       IMAGE_ARRAY = [],\r
+                                       BALLOON_ARRAY = [],\r
+                                       l = COMIC_ELEMENT_ARRAY.length,\r
+                                       _timing = 0,\r
+                                       _comicElement,\r
+                                       cr = pettanr.LINE_FEED_CODE_TEXTAREA;\r
+                                       \r
+                               while( IMAGE_ARRAY.length + BALLOON_ARRAY.length < l){\r
+                                       _comicElement = getComicElementByTiming();\r
+                                       if( _comicElement === null) break;\r
+                                       _comicElement.type === PANEL_ELEMENT_TYPE_IMAGE ? \r
+                                               IMAGE_ARRAY.push( _comicElement.getAsJsonString()) :\r
+                                               BALLOON_ARRAY.push( _comicElement.getAsJsonString());\r
+                               }\r
+                               function getComicElementByTiming(){\r
+                                       while( _timing < l *2){\r
+                                               for(var i=0; i<l; ++i){\r
+                                                       if( _timing === COMIC_ELEMENT_ARRAY[ i].timing){\r
+                                                               ++_timing;\r
+                                                               return COMIC_ELEMENT_ARRAY[ i];\r
+                                                       }\r
+                                               }\r
+                                               ++_timing;\r
+                                       }\r
+                                       return null;\r
+                               }\r
+                               return [\r
+                                       '{', cr,\r
+                                               '"panel": {', cr,\r
+                                                   '"border": 1,', cr,\r
+                                                   '"comic_id": 5,', cr,\r
+                                                   '"resource_picture_id": 1,', cr,\r
+                                                       '"x": ', 0, ',', cr,\r
+                                                       '"y": ', 0, ',', cr,\r
+                                                       '"z": ', 0, ',', cr,\r
+                                                       '"t": ', 0, ',', cr,\r
+                                                   '"width": ', panelW, ',', cr,\r
+                                                   '"height": ', panelH, ',', cr,\r
+                                                   '"panel_pictures_attributes": {', cr,\r
+                                                       IMAGE_ARRAY.join( ',' +cr), cr,\r
+                                                   '},', cr,\r
+                                                   '"balloons_attributes": {', cr,\r
+                                                       BALLOON_ARRAY.join( ',' +cr), cr,\r
+                                                   '}', cr,\r
+                                               '}', cr,\r
+                                       '}'\r
+                               ].join( '');\r
+                       }\r
+               }\r
+       })();\r
+       \r
+       /*\r
+        * end of COMIC_ELEMENT_CONTROL\r
+        */\r
+\r
+\r
+\r
+       function updateMouseCursor( _cursor){\r
+               if( currentCursor !== _cursor){\r
+                       currentCursor = _cursor;\r
+                       setTimeout( update, 0);\r
+               }\r
+               function update(){\r
+                       ELM_MOUSE_EVENT_CHATCHER.style.cursor = currentCursor;\r
+               }\r
+       }\r
+       function centering(){\r
+               instance.onPaneResize( windowW, windowH);\r
+       }       \r
+       function mouseEventRellay( e){\r
+               var _mouseX = e.pageX,\r
+                       _mouseY = e.pageY,\r
+                       rellayMethod = e.type === 'mousedown' ?\r
+                                       'onMouseDown' :\r
+                                       ( e.type === 'mousemove' ? 'onMouseMove' : 'onMouseUp');\r
+               if( currentListener !== null && currentListener.busy() === true){\r
+                       currentListener[ rellayMethod]( _mouseX, _mouseY);\r
+               } else {\r
+                       currentListener = null;\r
+                       var l = MOUSE_LISTENER_ARRAY.length,\r
+                               _listener;\r
+                       for( var i=0; i<l; ++i){\r
+                               _listener = MOUSE_LISTENER_ARRAY[ i];\r
+                               if( _listener[ rellayMethod]( _mouseX, _mouseY) === true){\r
+                                       currentListener = _listener;\r
+                                       break;\r
+                               }\r
+                       }\r
+               }\r
+               // 文字選択の禁止\r
+               //!document.selection && window.getSelection().removeAllRanges();\r
+               e.stopPropagation();\r
+               return false;\r
+       }\r
+\r
+       /* grobal method */\r
+       this.rootElement = document.getElementById( 'editor' );\r
+       this.displayName = pettanr.view.EDITOR;\r
+       this.ID          = pettanr.view.EDITOR;\r
+       this.MIN_WIDTH   = 320;\r
+       this.MIN_HEIGHT  = 320;\r
+       this.firstOpen = function(){\r
+       /*\r
+        * MOUSE_LISTENER_ARRAY は、表示順に格納.手前の要素が最初\r
+        * MENU_BAR_CONTROL,\r
+        * WINDOW_CONTROL,\r
+        * COMIC_ELEMENT_CONTROL,\r
+        * PANEL_CONTROL\r
+        * .busy() === true なら、そのままonMouseMove()にイベントを流す.\r
+        * onMouseMove()に流してみて、false が帰れば、次にリスナーにも流す.\r
+        */\r
+               MOUSE_LISTENER_ARRAY.push( MENU_BAR_CONTROL, WINDOWS_CONTROL, PANEL_RESIZER_TOP, PANEL_RESIZER_BOTTOM, COMIC_ELEMENT_CONTROL, PANEL_CONTROL);\r
+       /*\r
+        * centering\r
+        */\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 96, false, true, centering);  // ctrl + 0\r
+               pettanr.key.addKeyDownEvent( pettanr.view.EDITOR, 48, false, true, centering);  // ctrl + 0\r
+               MENU_BAR_CONTROL.EDIT.createSelection( 'centering', 'ctrl + 0', centering, true, true, true);\r
+       /*\r
+        * jqMouseEventChacher は透明な要素で、\r
+        * マウスイベントをcurrentElement(currentElement)に伝えるのが仕事\r
+        * このような実装になるのは、ここの表示オブジェクトにイベントを設定した場合、表示が追いつかずマウスカーソルが外れたタイミングでイベントが終わってしまうため。\r
+        */                     \r
+               jqMouseEventChacher = $( ELM_MOUSE_EVENT_CHATCHER)\r
+                       .mousemove( mouseEventRellay)\r
+                       .mousedown( mouseEventRellay)\r
+                       .mouseup( mouseEventRellay)\r
+                       .mouseout( mouseEventRellay);\r
+               \r
+               delete instance.firstOpen;\r
+       }\r
+       this.onOpen = function( _w, _h, _file ){\r
+               var panelW, panelH,\r
+                       borderSize,\r
+                       fileData, panelElements, panelElm;\r
+               \r
+               \r
+               if( pettanr.file.isFileInstance( _file ) === true ){\r
+                       if( pettanr.driver.isPettanrFileInstance( _file ) === true ){\r
+                               if( _file.getType() === pettanr.driver.FILE_TYPE.COMIC ){\r
+                                       fileData = _file.read();\r
+                                       panelW = fileData.width;\r
+                                       panelH = fileData.height;\r
+                               } else\r
+                               if( _file.getType() === pettanr.driver.FILE_TYPE.PANEL ){\r
+                                       fileData = _file.read();\r
+                                       panelW = fileData.width;\r
+                                       panelH = fileData.height;\r
+                                       borderSize = fileData.border;\r
+                                       panelElements = fileData.panel_elements;\r
+                                       \r
+                                       if( Type.isArray( panelElements ) === true ){\r
+                                               for( var i=0; i<panelElements.length; ++i){\r
+                                                       panelElm = panelElements[ i ];\r
+                                                       if( panelElm.resource_picture ){\r
+                                                               COMIC_ELEMENT_CONTROL.createImageElement( panelElm );\r
+                                                       } else\r
+                                                       if( panelElm.balloon_template_id ){\r
+                                                               COMIC_ELEMENT_CONTROL.createTextElement( panelElm );\r
+                                                       }\r
+                                               }                                               \r
+                                       }\r
+                               }\r
+                       } else {\r
+                               \r
+                       }\r
+               }\r
+               jqEditor = jqEditor || $( '#editor');\r
+               \r
+               HISTORY_CONTROL.open();\r
+               \r
+               WINDOWS_CONTROL.open();\r
+               \r
+               GRID_CONTROL.open();\r
+               PANEL_CONTROL.open( panelW, panelH, borderSize );\r
+               \r
+               COMIC_ELEMENT_OPERATION_MANAGER.open();\r
+               COMIC_ELEMENT_CONTROL.open();\r
+               \r
+               instance.firstOpen !== undefined && instance.firstOpen();\r
+               \r
+               // last\r
+               MENU_BAR_CONTROL.open();\r
+               \r
+               windowW = _w;\r
+               windowH = _h;\r
+               instance.onPaneResize( _w, _h );\r
+       }\r
+       this.onClose = function(){\r
+               HISTORY_CONTROL.close();\r
+               \r
+               WINDOWS_CONTROL.close();\r
+               \r
+               GRID_CONTROL.close();\r
+               PANEL_CONTROL.close();\r
+               \r
+               COMIC_ELEMENT_OPERATION_MANAGER.close();\r
+               COMIC_ELEMENT_CONTROL.close();\r
+               \r
+               // last\r
+               MENU_BAR_CONTROL.open();\r
+       }\r
+       this.onPaneResize = function( _windowW, _windowH){\r
+               windowW = _windowW || windowW;\r
+               windowH = _windowH || windowH;\r
+               if( instance.firstOpen) return;\r
+               /*\r
+                * ieは +'px'が不要みたい\r
+                */\r
+               jqEditor.get( 0).style.height = _windowH +'px';\r
+               ELM_MOUSE_EVENT_CHATCHER.style.height = _windowH +'px';\r
+               \r
+               WINDOWS_CONTROL.onWindowResize( _windowW, _windowH);\r
+               MENU_BAR_CONTROL.onWindowResize( _windowW, _windowH);\r
+               PANEL_CONTROL.onWindowResize( _windowW, _windowH);\r
+       }\r
+});\r
+\r
+\r
+pettanr.comicConsole = pettanr.view.registerApplication( function(){\r
+       var jqWrap,\r
+               ID = 'comicConsole',\r
+               elmWrap = document.getElementById( 'comic-console-wrapper' ),\r
+               elmHeader = document.getElementById( 'comic-console-header' ),\r
+               elmProgress = document.getElementById( 'comic-console-progress' ),\r
+               inputTitle, inputW, inputH, inputVisible, inputEditable,\r
+               elmUploader = null,\r
+               elmScript = null,\r
+               elmIframe = null,\r
+               elmForm = null,\r
+               timer = null,\r
+               isUploading = false,\r
+               instance = this;\r
+       //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);\r
+       \r
+       function clickOK(){\r
+               if( !elmForm || !elmIframe || isUploading === true ) return false;\r
+               // validate\r
+               isUploading = true;\r
+               elmProgress.innerHTML = '■';\r
+               copyAndSubmit();\r
+       }\r
+\r
+               function copyAndSubmit(){\r
+                       var _inputList = elmForm.getElementsByTagName( 'input' ),\r
+                               _input, _name;\r
+                       for( var i=0, l= _inputList.length; i<l; ++i){\r
+                               _input = _inputList[ i ];\r
+                               _name = _input.name;\r
+                               if( _name === 'comic[title]'){\r
+                                       _input.value = inputTitle.value();\r
+                               } else\r
+                               if( _name === 'comic[width]'){\r
+                                       _input.value = inputW.value();\r
+                               } else\r
+                               if( _name === 'comic[height]'){\r
+                                       _input.value = inputH.value();\r
+                               }\r
+                       }\r
+                       var _selectList = elmForm.getElementsByTagName( 'select' ),\r
+                               _select, _optionList;\r
+                       for( i=0, l= _selectList.length; i<l; ++i){\r
+                               _select = _selectList[ i ];\r
+                               _name = _select.name;\r
+                               _optionList = _select.getElementsByTagName( 'option' )\r
+                               if( _name === 'comic[visible]'){\r
+                                       _select.selectedIndex = 1;\r
+                               } else\r
+                               if( _name === 'comic[editable]'){\r
+                                       _select.selectedIndex = 0;\r
+                               }\r
+                       }\r
+                       try {\r
+                               elmForm.submit();\r
+                       } catch( e){\r
+                               elmProgress.innerHTML = 'submit() err..';\r
+                               isUploading = false;\r
+                               setTimeout( clickCancel , 3000);\r
+                               return;\r
+                       }\r
+                       if( pettanr.ua.isIE){\r
+                               elmIframe.onreadystatechange = detectIframe;\r
+                       } else {\r
+                               elmIframe.onload = onIframeUpdate;\r
+                       }\r
+                       elmProgress.innerHTML = 'uploading..';\r
+               }\r
+       /*\r
+        * ie の 場合、readyState をチェック.\r
+        */\r
+                       function detectIframe(){\r
+                   if ( elmIframe.readyState === 'complete') {\r
+                       elmIframe.onreadystatechange = new Function();\r
+                       elmIframe.onreadystatechange = null;\r
+                       onIframeUpdate();\r
+                   }\r
+                       }\r
+                               function onIframeUpdate(){\r
+                                       elmIframe.onload = null;\r
+                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();\r
+                                       elmIframe = null;\r
+                                       elmProgress.innerHTML = 'success!';\r
+                                       setTimeout( clickCancel , 1000);\r
+                                       isUploading = false;\r
+                               }\r
+                       \r
+       function clickCancel(){\r
+               if( isUploading === true) return false;\r
+               pettanr.comicConsole.shutdown();\r
+       }\r
+       function detectForm(){\r
+               elmForm = elmUploader.getElementsByTagName( 'form' )[ 0 ];\r
+               if( elmForm){\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+                       pettanr.util.createIframe( 'targetFrameCreateComic', onCreateIframe );\r
+                       elmProgress.innerHTML = 'create iframe';\r
+               }\r
+       }\r
+       function onCreateIframe( _iframe ){\r
+               elmUploader.appendChild( _iframe );\r
+               elmIframe = _iframe;\r
+               elmForm.target = _iframe.name;\r
+               elmProgress.innerHTML = '';\r
+       }\r
+\r
+       /* grobal method */\r
+       this.rootElement = document.getElementById( 'comic-console-wrapper' );\r
+       this.displayName = ID;\r
+       this.ID          = ID;\r
+       this.MIN_WIDTH   = 320;\r
+       this.MIN_HEIGHT  = 320;\r
+       this.init = function(){\r
+               instance.jqWrap = jqWrap = $( '#comic-console-wrapper').hide();\r
+               $( '#comic-console-post-button').click( clickOK );\r
+               $( '#comic-console-cancel-button').click( clickCancel );\r
+               \r
+               var CREATER = pettanr.form.createInputText;//pettanr.key.createEditableText;\r
+               inputTitle    = CREATER( document.getElementById( 'comic-console-title'), null, ID);\r
+               inputW        = CREATER( document.getElementById( 'comic-console-width'), null, ID);\r
+               inputH        = CREATER( document.getElementById( 'comic-console-height'), null, ID);\r
+               inputVisible  = CREATER( document.getElementById( 'comic-console-visible'), null, ID);\r
+               inputEditable = CREATER( document.getElementById( 'comic-console-editable'), null, ID);\r
+               \r
+               delete instance.init;\r
+       }\r
+       this.jqWrap = null;\r
+       this.onOpen = function( w, h ){\r
+               instance.init && instance.init();\r
+               \r
+               jqWrap.show();\r
+               \r
+               inputTitle.start();\r
+               \r
+               elmUploader = document.createElement( 'div' );\r
+               elmUploader.id = 'newcomic';\r
+               elmUploader.style.cssText = 'height:1px;line-height:1px;visibility:hidden;overflow:hidden;';\r
+               elmWrap.appendChild( elmUploader);\r
+               \r
+               var elmScript = document.createElement( 'script');\r
+               elmScript.type = 'text\/javascript';\r
+               elmScript.src = pettanr.CONST.CREATE_COMIC_JS;\r
+               elmWrap.appendChild( elmScript);\r
+               \r
+               elmProgress.innerHTML = 'loading form.';\r
+               \r
+               if( timer === null){\r
+                       timer = window.setInterval( detectForm, 250);\r
+               }\r
+               \r
+               instance.onPaneResize( w, h );\r
+       }\r
+       this.onPaneResize = function( _windowW, _windowH){\r
+               jqWrap.css(\r
+                       {\r
+                               left:   Math.floor( ( _windowW -jqWrap.width()) /2),\r
+                               top:    Math.floor( ( _windowH -jqWrap.height()) /2)\r
+                       }\r
+               );\r
+       }\r
+       this.onClose = function(){\r
+               elmForm !== null && $( elmUploader ).remove();\r
+               elmForm  = null;\r
+               isUploading = false;\r
+               \r
+               if( elmScript !== null ){\r
+                       document.body.removeChild( elmScript);\r
+                       elmScript = null;                                       \r
+               }\r
+               if( timer !== null){\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+               }\r
+               \r
+               jqWrap.hide();\r
+       }\r
+});\r
+\r
+pettanr.uploadConsole = pettanr.view.registerApplication( function(){\r
+       var jqWrap, windowW, windowH,\r
+               ID = 'uploadConsole',\r
+               TARGET_FRAME_NAME = 'targetFrame',\r
+               elmContainer = document.getElementById( 'uploader'),\r
+               elmProgress = document.getElementById( 'upload-console-progress'),\r
+               timer = null,\r
+               elmScript = null,\r
+               elmForm = null,\r
+               elmFile = null,\r
+               elmIframe = null,\r
+               isUploading = false,\r
+               instance = this;\r
+       /*\r
+        * upload ボタンが押されたらまず iframe をつくる.
+        */\r
+       function clickOK(){\r
+               if( !elmForm || !elmIframe || isUploading === true ) return false;\r
+               if( elmFile.value.length === 0) return false;\r
+               elmProgress.innerHTML = 'uploading.';\r
+               isUploading = true;\r
+               submit();\r
+               return false;\r
+       }\r
+       /*\r
+        * form の target に iframe を指定したのち submit();
+        */\r
+               function submit(){\r
+                       try {\r
+                               elmForm.submit();\r
+                       } catch( e){\r
+                               elmProgress.innerHTML = 'submit() err..';\r
+                               isUploading = false;\r
+                               setTimeout( clickCancel , 3000);\r
+                               return;\r
+                       }\r
+                       \r
+                       if( pettanr.ua.isIE){\r
+                               elmIframe.onreadystatechange = detectIframe;\r
+                       } else {\r
+                               elmIframe.onload = onLoad;\r
+                       }\r
+                       elmProgress.innerHTML = 'uploading..';\r
+               }\r
+       /*\r
+        * ie の 場合、readyState をチェック.
+        */\r
+                       function detectIframe(){\r
+                   if ( elmIframe.readyState === 'complete') {\r
+                       elmIframe.onreadystatechange = new Function();\r
+                       elmIframe.onreadystatechange = null;\r
+                       onLoad();\r
+                   }\r
+                       }\r
+                               function onLoad(){\r
+                                       elmIframe.onload = null;\r
+                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();\r
+                                       elmProgress.innerHTML = 'success!';\r
+                                       setTimeout( clickCancel , 1000);\r
+                                       isUploading = false;\r
+                               }\r
+       \r
+       function detectForm(){\r
+               elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];\r
+               if( elmForm){\r
+                       var _inputList = elmForm.getElementsByTagName( 'input' ),\r
+                               _input;\r
+                       for( var i=0, l= _inputList.length; i<l; ++i){\r
+                               _input = _inputList[ i ];\r
+                               if( _input.type === 'file'){\r
+                                       elmFile = _input;\r
+                               }\r
+                               if( _input.type === 'submit'){\r
+                                       _input.style.display = 'none';\r
+                               }\r
+                       }\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+                       pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe);\r
+                       elmProgress.innerHTML = 'create iframe';\r
+               }\r
+       }\r
+       function onCreateIframe( _iframe ){\r
+               elmContainer.appendChild( _iframe );\r
+               elmIframe = _iframe;\r
+               elmForm.target = _iframe.name;\r
+               elmProgress.innerHTML = '';\r
+               instance.onPaneResize( windowW, windowH );\r
+       }\r
+       /*\r
+        * 
+        */\r
+       function clickCancel(){\r
+               if( isUploading === true) return false;\r
+               pettanr.uploadConsole.shutdown();\r
+               return false;\r
+       }\r
+\r
+       /* grobal method */\r
+       this.rootElement = document.getElementById( 'upload-console-wrapper' );\r
+       this.displayName = ID;\r
+       this.ID          = ID;\r
+       this.MIN_WIDTH   = 320;\r
+       this.MIN_HEIGHT  = 320;\r
+       this.init = function(){\r
+               instance.jqWrap = jqWrap = $( '#upload-console-wrapper').hide();\r
+               $( '#upload-console-post-button').click( clickOK );\r
+               $( '#upload-console-cancel-button').click( clickCancel );\r
+\r
+               delete instance.init;\r
+       }\r
+       this.jqWrap = null;\r
+       this.onOpen = function( w, h){\r
+               instance.init && instance.init();\r
+               /*\r
+                * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.
+                */                             \r
+               elmScript = document.createElement( 'script');\r
+               elmScript.type = 'text\/javascript';\r
+               elmScript.src = pettanr.CONST.UPLOAD_PICTURE_JS;\r
+               document.body.appendChild( elmScript);\r
+               \r
+               jqWrap.show();\r
+\r
+               if( timer === null){\r
+                       timer = window.setInterval( detectForm, 250);\r
+               }\r
+               \r
+               elmProgress.innerHTML = 'loading form.';\r
+               \r
+               instance.onPaneResize( w, h);\r
+       }\r
+       this.onPaneResize = function( _windowW, _windowH){\r
+               windowW = _windowW;\r
+               windowH = _windowH;\r
+               jqWrap.css(\r
+                       {\r
+                               left:   Math.floor( ( _windowW -jqWrap.width()) /2),\r
+                               top:    Math.floor( ( _windowH -jqWrap.height()) /2)\r
+                       }\r
+               );\r
+       }\r
+       this.onClose = function(){\r
+               elmForm !== null && $( elmContainer.children ).remove();\r
+               elmForm = elmFile = elmIframe = null;\r
+               isUploading = false;\r
+               \r
+               if( elmScript !== null ){\r
+                       document.body.removeChild( elmScript);\r
+                       elmScript = null;                                       \r
+               }\r
+               if( timer !== null){\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+               }\r
+               jqWrap.hide();\r
+       }\r
+});\r
+\r
+pettanr.panelConsole = pettanr.view.registerApplication( function(){\r
+       var jqWrap, windowW, windowH,\r
+               ID = 'panelConsole',\r
+               TARGET_FRAME_NAME = 'targetFrameCreateNewPanel',\r
+               elmContainer = document.getElementById( 'newpanel'),\r
+               elmProgress = document.getElementById( 'panel-console-progress'),\r
+               timer = null,\r
+               elmScript = null,\r
+               elmForm = null,\r
+               elmIframe = null,\r
+               isUploading = false,\r
+               instance = this;\r
+       /*\r
+        * upload ボタンが押されたらまず iframe をつくる.\r
+        */\r
+       function clickOK(){\r
+               if( !elmForm || !elmIframe || isUploading === true ) return false;\r
+               elmProgress.innerHTML = 'uploading.';\r
+               isUploading = true;\r
+               submit();\r
+               return false;\r
+       }\r
+       /*\r
+        * form の target に iframe を指定したのち submit();\r
+        */\r
+               function submit(){\r
+                       try {\r
+                               elmForm.submit();\r
+                       } catch( e){\r
+                               elmProgress.innerHTML = 'submit() err..';\r
+                               isUploading = false;\r
+                               setTimeout( clickCancel , 3000);\r
+                               return;\r
+                       }\r
+                       \r
+                       if( pettanr.ua.isIE){\r
+                               elmIframe.onreadystatechange = detectIframe;\r
+                       } else {\r
+                               elmIframe.onload = onLoad;\r
+                       }\r
+                       elmProgress.innerHTML = 'uploading..';\r
+               }\r
+       /*\r
+        * ie の 場合、readyState をチェック.\r
+        */\r
+                       function detectIframe(){\r
+                   if ( elmIframe.readyState === 'complete') {\r
+                       elmIframe.onreadystatechange = new Function();\r
+                       elmIframe.onreadystatechange = null;\r
+                       onLoad();\r
+                   }\r
+                       }\r
+                               function onLoad(){\r
+                                       elmIframe.onload = null;\r
+                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();\r
+                                       elmProgress.innerHTML = 'success!';\r
+                                       setTimeout( clickCancel , 1000);\r
+                                       isUploading = false;\r
+                               }\r
+       \r
+       function detectForm(){\r
+               elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];\r
+               if( elmForm){\r
+                       var _inputList = elmForm.getElementsByTagName( 'input' ),\r
+                               _input;\r
+                       for( var i=0, l= _inputList.length; i<l; ++i){\r
+                               _input = _inputList[ i ];\r
+                               if( _input.type === 'submit'){\r
+                                       _input.style.display = 'none';\r
+                               }\r
+                       }\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+                       pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe);\r
+                       elmProgress.innerHTML = 'create iframe';\r
+               }\r
+       }\r
+       function onCreateIframe( _iframe ){\r
+               elmContainer.appendChild( _iframe );\r
+               elmIframe = _iframe;\r
+               elmForm.target = _iframe.name;\r
+               elmProgress.innerHTML = '';\r
+               instance.onPaneResize( windowW, windowH );\r
+       }\r
+       /*\r
+        * \r
+        */\r
+       function clickCancel(){\r
+               if( isUploading === true) return false;\r
+               pettanr.panelConsole.shutdown();\r
+               return false;\r
+       }\r
+\r
+       /* grobal method */\r
+       this.rootElement = document.getElementById( 'panel-console-wrapper' );\r
+       this.displayName = ID;\r
+       this.ID          = ID;\r
+       this.MIN_WIDTH   = 320;\r
+       this.MIN_HEIGHT  = 320;\r
+       this.init = function(){\r
+               instance.jqWrap = jqWrap = $( '#panel-console-wrapper').hide();\r
+               $( '#panel-console-post-button').click( clickOK );\r
+               $( '#panel-console-cancel-button').click( clickCancel );\r
+\r
+               delete instance.init;\r
+       }\r
+       this.jqWrap = null;\r
+       this.onOpen = function( w, h ){\r
+               instance.init && instance.init();\r
+               /*\r
+                * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.\r
+                */                             \r
+               elmScript = document.createElement( 'script');\r
+               elmScript.type = 'text\/javascript';\r
+               elmScript.src = pettanr.CONST.CREATE_PANEL_JS;\r
+               document.body.appendChild( elmScript);\r
+               \r
+               jqWrap.show();\r
+\r
+               if( timer === null){\r
+                       timer = window.setInterval( detectForm, 250 );\r
+               }\r
+               \r
+               elmProgress.innerHTML = 'loading form.';\r
+               \r
+               instance.onPaneResize( w, h );\r
+       }\r
+       this.onPaneResize = function( _windowW, _windowH ){\r
+               windowW = _windowW;\r
+               windowH = _windowH;\r
+               jqWrap.css(\r
+                       {\r
+                               left:   Math.floor( ( _windowW -jqWrap.width()) /2),\r
+                               top:    Math.floor( ( _windowH -jqWrap.height()) /2)\r
+                       }\r
+               );\r
+       }\r
+       this.onClose = function(){\r
+               elmForm !== null && $( elmContainer.children ).remove();\r
+               elmForm = elmIframe = null;\r
+               isUploading = false;\r
+               \r
+               if( elmScript !== null ){\r
+                       document.body.removeChild( elmScript);\r
+                       elmScript = null;                                       \r
+               }\r
+               if( timer !== null){\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+               }\r
+               jqWrap.hide();\r
+       }\r
+});\r
+\r
+pettanr.artistConsole = pettanr.view.registerApplication( function(){\r
+       var jqWrap, windowW, windowH,\r
+               ID = 'artistConsole',\r
+               TARGET_FRAME_NAME = 'targetFrameRegisterArtist',\r
+               elmContainer = document.getElementById( 'register'),\r
+               elmProgress = document.getElementById( 'artist-console-progress'),\r
+               timer = null,\r
+               elmScript = null,\r
+               elmForm = null,\r
+               elmIframe = null,\r
+               isUploading = false,\r
+               instance = this;\r
+       /*\r
+        * upload ボタンが押されたらまず iframe をつくる.\r
+        */\r
+       function clickOK(){\r
+               if( !elmForm || !elmIframe || isUploading === true ) return false;\r
+               elmProgress.innerHTML = 'uploading.';\r
+               isUploading = true;\r
+               submit();\r
+               return false;\r
+       }\r
+       /*\r
+        * form の target に iframe を指定したのち submit();\r
+        */\r
+               function submit(){\r
+                       try {\r
+                               elmForm.submit();\r
+                       } catch( e){\r
+                               elmProgress.innerHTML = 'submit() err..';\r
+                               isUploading = false;\r
+                               setTimeout( clickCancel , 3000);\r
+                               return;\r
+                       }\r
+                       \r
+                       if( pettanr.ua.isIE){\r
+                               elmIframe.onreadystatechange = detectIframe;\r
+                       } else {\r
+                               elmIframe.onload = onLoad;\r
+                       }\r
+                       elmProgress.innerHTML = 'uploading..';\r
+               }\r
+       /*\r
+        * ie の 場合、readyState をチェック.\r
+        */\r
+                       function detectIframe(){\r
+                   if ( elmIframe.readyState === 'complete') {\r
+                       elmIframe.onreadystatechange = new Function();\r
+                       elmIframe.onreadystatechange = null;\r
+                       onLoad();\r
+                   }\r
+                       }\r
+                               function onLoad(){\r
+                                       elmIframe.onload = null;\r
+                                       ( elmIframe.contentWindow || elmIframe.contentDocument.parentWindow ).close();\r
+                                       elmProgress.innerHTML = 'success!';\r
+                                       setTimeout( clickCancel , 1000);\r
+                                       isUploading = false;\r
+                               }\r
+       \r
+       function detectForm(){\r
+               elmForm = elmContainer.getElementsByTagName( 'form' )[ 0 ];\r
+               if( elmForm){\r
+                       var _inputList = elmForm.getElementsByTagName( 'input' ),\r
+                               _input;\r
+                       for( var i=0, l= _inputList.length; i<l; ++i){\r
+                               _input = _inputList[ i ];\r
+                               if( _input.type === 'submit'){\r
+                                       _input.style.display = 'none';\r
+                               }\r
+                       }\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+                       pettanr.util.createIframe( TARGET_FRAME_NAME, onCreateIframe);\r
+                       elmProgress.innerHTML = 'create iframe';\r
+               }\r
+       }\r
+       function onCreateIframe( _iframe ){\r
+               elmContainer.appendChild( _iframe );\r
+               elmIframe = _iframe;\r
+               elmForm.target = _iframe.name;\r
+               elmProgress.innerHTML = '';\r
+               instance.onPaneResize( windowW, windowH );\r
+       }\r
+       /*\r
+        * \r
+        */\r
+       function clickCancel(){\r
+               if( isUploading === true) return false;\r
+               pettanr.artistConsole.shutdown();\r
+               return false;\r
+       }\r
+\r
+       /* grobal method */\r
+       this.rootElement = document.getElementById( 'artist-console-wrapper' );\r
+       this.displayName = ID;\r
+       this.ID          = ID;\r
+       this.MIN_WIDTH   = 320;\r
+       this.MIN_HEIGHT  = 320;\r
+       this.init = function(){\r
+               instance.jqWrap = jqWrap = $( '#artist-console-wrapper').hide();\r
+               $( '#artist-console-post-button').click( clickOK );\r
+               $( '#artist-console-cancel-button').click( clickCancel );\r
+\r
+               delete instance.init;\r
+       }\r
+       this.jqWrap = null;\r
+       this.onOpen = function( w, h ){\r
+               instance.init && instance.init();\r
+               /*\r
+                * ie 6, 7 で fadeIn 中の要素に appendChild すると クラッシュするので、document.body に追加.\r
+                */                             \r
+               elmScript = document.createElement( 'script' );\r
+               elmScript.type = 'text\/javascript';\r
+               elmScript.src = pettanr.CONST.REGISTER_ARTIST_JS;\r
+               document.body.appendChild( elmScript );\r
+               \r
+               jqWrap.show();\r
+\r
+               if( timer === null){\r
+                       timer = window.setInterval( detectForm, 250 );\r
+               }\r
+               \r
+               elmProgress.innerHTML = 'loading form.';\r
+               \r
+               instance.onPaneResize( w, h );\r
+       }\r
+       this.onPaneResize = function( _windowW, _windowH ){\r
+               windowW = _windowW;\r
+               windowH = _windowH;\r
+               jqWrap.css(\r
+                       {\r
+                               left:   Math.floor( ( _windowW -jqWrap.width()) /2),\r
+                               top:    Math.floor( ( _windowH -jqWrap.height()) /2)\r
+                       }\r
+               );\r
+       }\r
+       this.onClose = function(){\r
+               elmForm !== null && $( elmContainer.children ).remove();\r
+               elmForm = elmIframe = null;\r
+               isUploading = false;\r
+               \r
+               if( elmScript !== null ){\r
+                       document.body.removeChild( elmScript);\r
+                       elmScript = null;                                       \r
+               }\r
+               if( timer !== null){\r
+                       window.clearInterval( timer);\r
+                       timer = null;\r
+               }\r
+               jqWrap.hide();\r
+       }\r
+});\r
+\r
+pettanr.outputConsole = pettanr.view.registerApplication( function(){\r
+       var jqWrap, jqOutputArea,\r
+               ID = 'outputConsole',\r
+               instance = this;\r
+       //pettanr.key.addKeyDownEvent( ID, 69, false, false, clickOK);\r
+       \r
+       function clickOK(){\r
+               pettanr.overlay.hide();\r
+               pettanr.outputConsole.shutdown();\r
+       }\r
+       \r
+       /* grobal method */\r
+       this.rootElement = document.getElementById( 'output-console-wrapper' );\r
+       this.displayName = ID;\r
+       this.ID          = ID;\r
+       \r
+       this.MIN_WIDTH   = 320;\r
+       this.MIN_HEIGHT  = 320;\r
+       this.init = function(){\r
+               instance.jqWrap = jqWrap = $( '#output-console-wrapper').hide();\r
+               jqOutputArea = $( '#output-area');\r
+               delete instance.init;\r
+       }\r
+       this.jqWrap = null;\r
+       this.onOpen = function( _w, _h, _text ){\r
+               instance.init && instance.init();\r
+               \r
+               jqWrap.show();\r
+               instance.onWindowResize( _w, _h );\r
+               jqOutputArea.val( _text).focus();\r
+       }\r
+       this.onWindowResize = function( _w, _h){\r
+               jqWrap.css(\r
+                       {\r
+                               left:   Math.floor( ( _w -jqWrap.width()) /2),\r
+                               top:    Math.floor( ( _h -jqWrap.height()) /2)\r
+                       }\r
+               );\r
+       }\r
+       this.onClose = function(){\r
+               jqWrap.hide();\r
+               jqOutputArea.val('');\r
+       }\r
+});\r
index 50f45f6..24359c3 100644 (file)
@@ -27,7 +27,7 @@ class PanelsController < ApplicationController
   # GET /panels/1
   # GET /panels/1.json
   def show
-    @panel = Panel.find(params[:id], include: [:comic, :panel_pictures => :resource_picture, :balloons => :speaches])# only: [:width, :height])
+    @panel = Panel.find(params[:id], include: [:comic, :panel_pictures => :resource_picture, :balloons => :speeches])# only: [:width, :height])
 
     respond_to do |format|
       format.html # show.html.erb
diff --git a/app/controllers/speach_balloon_templates_controller.rb b/app/controllers/speach_balloon_templates_controller.rb
deleted file mode 100644 (file)
index cb05991..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-class SpeachBalloonTemplatesController < ApplicationController
-  before_filter :authenticate_user!, :only => [:index, :show]
-  before_filter :authenticate_admin!, :only => [:list, :browse, :import, :destroy]
-
-  private
-  
-  def validate_param(ft)
-    res = nil
-    bl = ft[:size_count].to_i
-    tl = ft[:tail_count].to_i
-    if bl * tl == ft[:balloon_templates_attributes].size
-      flag = []
-      bl.times do |i|
-        flag[i] = []
-        tl.times do |j|
-          flag[i][j] = true
-        end
-      end
-      ft[:balloon_templates_attributes].each do |k, t|
-        flag[t[:size].to_i - 1][t[:tail].to_i - 1] = nil
-      end
-      if flag.flatten.compact.size == 0
-      else
-        res = "invalid variation"
-      end
-    else
-      res = "invalid template size"
-    end
-    res
-  end
-  
-  public
-  # GET /speach_balloon_templates
-  # GET /speach_balloon_templates.json
-  def index
-    @speach_balloon_templates = SpeachBalloon.all
-
-    respond_to do |format|
-      format.html # index.html.erb
-      format.json { render json: @speach_balloon_templates }
-    end
-  end
-
-  # GET /speach_balloon_templates/1
-  # GET /speach_balloon_templates/1.json
-  def show
-    @speach_balloon_template = SpeachBalloon.find(params[:id], include: {:balloon_templates => :speach_templates})
-
-    respond_to do |format|
-      format.html # show.html.erb
-      format.json {
-        render :json => @speach_balloon_template.to_json(include: {
-          :balloon_templates => {:include => :speach_templates}
-        })
-      }
-      format.jsonp {
-        render :json => "callback(" + @speach_balloon_template.to_json(include: {
-          :balloon_templates => {:include => :speach_templates}
-        }) + ")"
-      }
-    end
-  end
-
-  def list
-    @speach_balloon_templates = SpeachBalloon.all
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @speach_balloon_templates }
-    end
-  end
-
-  def browse
-    @speach_balloon_template = SpeachBalloon.find(params[:id])
-
-    respond_to do |format|
-      format.html { render layout: 'system' }
-      format.json { render json: @speach_balloon_template }
-    end
-  end
-
-  # POST /speach_balloon_templates
-  # POST /speach_balloon_templates.json
-  def create
-    @speach_balloon_template = SpeachBalloon.new(params[:speach_balloon_template])
-    if em = validate_param(params[:speach_balloon_template])
-      respond_to do |format|
-        format.json { render json: em, status: :unprocessable_entity }
-      end
-    else
-      respond_to do |format|
-        if @speach_balloon_template.save
-          format.html { redirect_to @speach_balloon_template, notice: 'Speach balloon was successfully created.' }
-          format.json { render json: @speach_balloon_template, status: :created, location: @speach_balloon_template }
-        else
-          format.html { render action: "new" }
-          format.json { render json: @speach_balloon_template.errors, status: :unprocessable_entity }
-        end
-      end
-    end
-  end
-
-  # DELETE /speach_balloon_templates/1
-  # DELETE /speach_balloon_templates/1.json
-  def destroy
-    @speach_balloon_template = SpeachBalloon.find(params[:id])
-    @speach_balloon_template.destroy
-
-    respond_to do |format|
-      format.html { redirect_to speach_balloon_templates_url }
-      format.json { head :ok }
-    end
-  end
-end
diff --git a/app/controllers/speech_balloon_templates_controller.rb b/app/controllers/speech_balloon_templates_controller.rb
new file mode 100644 (file)
index 0000000..d17ff32
--- /dev/null
@@ -0,0 +1,114 @@
+class SpeechBalloonTemplatesController < ApplicationController
+  before_filter :authenticate_user!, :only => [:index, :show]
+  before_filter :authenticate_admin!, :only => [:list, :browse, :import, :destroy]
+
+  private
+  
+  def validate_param(ft)
+    res = nil
+    bl = ft[:size_count].to_i
+    tl = ft[:tail_count].to_i
+    if bl * tl == ft[:balloon_templates_attributes].size
+      flag = []
+      bl.times do |i|
+        flag[i] = []
+        tl.times do |j|
+          flag[i][j] = true
+        end
+      end
+      ft[:balloon_templates_attributes].each do |k, t|
+        flag[t[:size].to_i - 1][t[:tail].to_i - 1] = nil
+      end
+      if flag.flatten.compact.size == 0
+      else
+        res = "invalid variation"
+      end
+    else
+      res = "invalid template size"
+    end
+    res
+  end
+  
+  public
+  # GET /speech_balloon_templates
+  # GET /speech_balloon_templates.json
+  def index
+    @speech_balloon_templates = SpeechBalloon.all
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @speech_balloon_templates }
+    end
+  end
+
+  # GET /speech_balloon_templates/1
+  # GET /speech_balloon_templates/1.json
+  def show
+    @speech_balloon_template = SpeechBalloon.find(params[:id], include: {:balloon_templates => :speech_templates})
+
+    respond_to do |format|
+      format.html # show.html.erb
+      format.json {
+        render :json => @speech_balloon_template.to_json(include: {
+          :balloon_templates => {:include => :speech_templates}
+        })
+      }
+      format.jsonp {
+        render :json => "callback(" + @speech_balloon_template.to_json(include: {
+          :balloon_templates => {:include => :speech_templates}
+        }) + ")"
+      }
+    end
+  end
+
+  def list
+    @speech_balloon_templates = SpeechBalloon.all
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @speech_balloon_templates }
+    end
+  end
+
+  def browse
+    @speech_balloon_template = SpeechBalloon.find(params[:id])
+
+    respond_to do |format|
+      format.html { render layout: 'system' }
+      format.json { render json: @speech_balloon_template }
+    end
+  end
+
+  # POST /speech_balloon_templates
+  # POST /speech_balloon_templates.json
+  def create
+    @speech_balloon_template = SpeechBalloon.new(params[:speech_balloon_template])
+    if em = validate_param(params[:speech_balloon_template])
+      respond_to do |format|
+        format.json { render json: em, status: :unprocessable_entity }
+      end
+    else
+      respond_to do |format|
+        if @speech_balloon_template.save
+          format.html { redirect_to @speech_balloon_template, notice: 'Speech balloon was successfully created.' }
+          format.json { render json: @speech_balloon_template, status: :created, location: @speech_balloon_template }
+        else
+          format.html { render action: "new" }
+          format.json { render json: @speech_balloon_template.errors, status: :unprocessable_entity }
+        end
+      end
+    end
+  end
+
+  # DELETE /speech_balloon_templates/1
+  # DELETE /speech_balloon_templates/1.json
+  def destroy
+    @speech_balloon_template = SpeechBalloon.find(params[:id])
+    @speech_balloon_template.destroy
+
+    respond_to do |format|
+      format.html { redirect_to speech_balloon_templates_url }
+      format.json { head :ok }
+    end
+  end
+end
@@ -1,4 +1,4 @@
-class SpeachBalloonsController < ApplicationController
+class SpeechBalloonsController < ApplicationController
   before_filter :authenticate_user!, :only => [:index, :show]
   before_filter :authenticate_admin!, :only => [:list, :browse, :create, :update, :destroy]
 
@@ -30,100 +30,100 @@ class SpeachBalloonsController < ApplicationController
   end
   
   public
-  # GET /speach_balloons
-  # GET /speach_balloons.json
+  # GET /speech_balloons
+  # GET /speech_balloons.json
   def index
-    @speach_balloons = SpeachBalloon.all
+    @speech_balloons = SpeechBalloon.all
 
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: @speach_balloons }
+      format.json { render json: @speech_balloons }
     end
   end
 
-  # GET /speach_balloons/1
-  # GET /speach_balloons/1.json
+  # GET /speech_balloons/1
+  # GET /speech_balloons/1.json
   def show
-    @speach_balloon = SpeachBalloon.find(params[:id], include: {:balloon_templates => :speach_templates})
+    @speech_balloon = SpeechBalloon.find(params[:id], include: {:balloon_templates => :speech_templates})
 
     respond_to do |format|
       format.html # show.html.erb
       format.json {
-        render :json => @speach_balloon.to_json(include: {
-          :balloon_templates => {:include => :speach_templates}
+        render :json => @speech_balloon.to_json(include: {
+          :balloon_templates => {:include => :speech_templates}
         })
       }
       format.jsonp {
-        render :json => "callback(" + @speach_balloon.to_json(include: {
-          :balloon_templates => {:include => :speach_templates}
+        render :json => "callback(" + @speech_balloon.to_json(include: {
+          :balloon_templates => {:include => :speech_templates}
         }) + ")"
       }
     end
   end
 
   def list
-    @speach_balloons = SpeachBalloon.all
+    @speech_balloons = SpeechBalloon.all
 
     respond_to do |format|
       format.html { render layout: 'system' }
-      format.json { render json: @speach_balloons }
+      format.json { render json: @speech_balloons }
     end
   end
 
   def browse
-    @speach_balloon = SpeachBalloon.find(params[:id])
+    @speech_balloon = SpeechBalloon.find(params[:id])
 
     respond_to do |format|
       format.html { render layout: 'system' }
-      format.json { render json: @speach_balloon }
+      format.json { render json: @speech_balloon }
     end
   end
 
-  # POST /speach_balloons
-  # POST /speach_balloons.json
+  # POST /speech_balloons
+  # POST /speech_balloons.json
   def create
-    @speach_balloon = SpeachBalloon.new(params[:speach_balloon])
-    if em = validate_param(params[:speach_balloon])
+    @speech_balloon = SpeechBalloon.new(params[:speech_balloon])
+    if em = validate_param(params[:speech_balloon])
       respond_to do |format|
         format.json { render json: em, status: :unprocessable_entity }
       end
     else
       respond_to do |format|
-        if @speach_balloon.save
-          format.html { redirect_to @speach_balloon, notice: 'Speach balloon was successfully created.' }
-          format.json { render json: @speach_balloon, status: :created, location: @speach_balloon }
+        if @speech_balloon.save
+          format.html { redirect_to @speech_balloon, notice: 'Speech balloon was successfully created.' }
+          format.json { render json: @speech_balloon, status: :created, location: @speech_balloon }
         else
           format.html { render action: "new" }
-          format.json { render json: @speach_balloon.errors, status: :unprocessable_entity }
+          format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
         end
       end
     end
   end
 
-  # PUT /speach_balloons/1
-  # PUT /speach_balloons/1.json
+  # PUT /speech_balloons/1
+  # PUT /speech_balloons/1.json
   def update
-    @speach_balloon = SpeachBalloon.find(params[:id])
+    @speech_balloon = SpeechBalloon.find(params[:id])
 
     respond_to do |format|
-      if @speach_balloon.update_attributes(params[:speach_balloon])
-        format.html { redirect_to @speach_balloon, notice: 'Speach balloon was successfully updated.' }
+      if @speech_balloon.update_attributes(params[:speech_balloon])
+        format.html { redirect_to @speech_balloon, notice: 'Speech balloon was successfully updated.' }
         format.json { head :ok }
       else
         format.html { render action: "edit" }
-        format.json { render json: @speach_balloon.errors, status: :unprocessable_entity }
+        format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
       end
     end
   end
 
-  # DELETE /speach_balloons/1
-  # DELETE /speach_balloons/1.json
+  # DELETE /speech_balloons/1
+  # DELETE /speech_balloons/1.json
   def destroy
-    @speach_balloon = SpeachBalloon.find(params[:id])
-    @speach_balloon.destroy
+    @speech_balloon = SpeechBalloon.find(params[:id])
+    @speech_balloon.destroy
 
     respond_to do |format|
-      format.html { redirect_to speach_balloons_url }
+      format.html { redirect_to speech_balloons_url }
       format.json { head :ok }
     end
   end
@@ -1,24 +1,24 @@
-class SpeachTemplatesController < ApplicationController
+class SpeechTemplatesController < ApplicationController
   before_filter :authenticate_user!, :only => [:index, :show]
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
-  # GET /speach_templates
-  # GET /speach_templates.json
+  # GET /speech_templates
+  # GET /speech_templates.json
   def index
-    @speach_templates = SpeachTemplate.all
+    @speech_templates = SpeechTemplate.all
 
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: @speach_templates }
+      format.json { render json: @speech_templates }
     end
   end
 
   def list
-    @speach_templates = SpeachTemplate.all
+    @speech_templates = SpeechTemplate.all
 
     respond_to do |format|
       format.html { render layout: 'system' }
-      format.json { render json: @speach_templates }
+      format.json { render json: @speech_templates }
     end
   end
 
similarity index 57%
rename from app/controllers/speaches_controller.rb
rename to app/controllers/speeches_controller.rb
index 35a5595..7e53b73 100644 (file)
@@ -1,24 +1,24 @@
-class SpeachesController < ApplicationController
+class SpeechesController < ApplicationController
   before_filter :authenticate_user!, :only => [:index, :show]
   before_filter :authenticate_admin!, :only => [:list, :browse]
 
-  # GET /speaches
-  # GET /speaches.json
+  # GET /speeches
+  # GET /speeches.json
   def index
-    @speaches = Speach.all
+    @speeches = Speech.all
 
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: @speaches }
+      format.json { render json: @speeches }
     end
   end
 
   def list
-    @speaches = Speach.all
+    @speeches = Speech.all
 
     respond_to do |format|
       format.html { render layout: 'system' }
-      format.json { render json: @speaches }
+      format.json { render json: @speeches }
     end
   end
 end
diff --git a/app/helpers/speach_balloon_templates_helper.rb b/app/helpers/speach_balloon_templates_helper.rb
deleted file mode 100644 (file)
index 9ba0508..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-module SpeachBalloonTemplatesHelper
-end
diff --git a/app/helpers/speach_balloons_helper.rb b/app/helpers/speach_balloons_helper.rb
deleted file mode 100644 (file)
index ca42158..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-module SpeachBalloonsHelper
-end
diff --git a/app/helpers/speach_templates_helper.rb b/app/helpers/speach_templates_helper.rb
deleted file mode 100644 (file)
index 51b4580..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-module SpeachTemplatesHelper
-end
diff --git a/app/helpers/speaches_helper.rb b/app/helpers/speaches_helper.rb
deleted file mode 100644 (file)
index c4b52bb..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-module SpeachesHelper
-end
diff --git a/app/helpers/speech_balloon_templates_helper.rb b/app/helpers/speech_balloon_templates_helper.rb
new file mode 100644 (file)
index 0000000..992ab1e
--- /dev/null
@@ -0,0 +1,2 @@
+module SpeechBalloonTemplatesHelper
+end
diff --git a/app/helpers/speech_balloons_helper.rb b/app/helpers/speech_balloons_helper.rb
new file mode 100644 (file)
index 0000000..03c3d67
--- /dev/null
@@ -0,0 +1,2 @@
+module SpeechBalloonsHelper
+end
diff --git a/app/helpers/speech_templates_helper.rb b/app/helpers/speech_templates_helper.rb
new file mode 100644 (file)
index 0000000..3091a5d
--- /dev/null
@@ -0,0 +1,2 @@
+module SpeechTemplatesHelper
+end
diff --git a/app/helpers/speeches_helper.rb b/app/helpers/speeches_helper.rb
new file mode 100644 (file)
index 0000000..0f79a3b
--- /dev/null
@@ -0,0 +1,2 @@
+module SpeechesHelper
+end
index ee183cc..391b933 100644 (file)
@@ -1,8 +1,8 @@
 class Balloon < ActiveRecord::Base
-  has_many :speaches
+  has_many :speeches
   belongs_to :panel
   belongs_to :system_picture
-  accepts_nested_attributes_for :speaches
+  accepts_nested_attributes_for :speeches
   
   def url
     '/system_pictures/' + self.system_picture.filename
index 7f32278..c050ed9 100644 (file)
@@ -1,6 +1,6 @@
 class BalloonTemplate < ActiveRecord::Base
-  belongs_to :speach_balloon
-  has_many :speach_templates, :dependent => :destroy
+  belongs_to :speech_balloon
+  has_many :speech_templates, :dependent => :destroy
   belongs_to :system_picture
-  accepts_nested_attributes_for :speach_templates
+  accepts_nested_attributes_for :speech_templates
 end
index 3dc6bae..6db937d 100644 (file)
@@ -113,9 +113,9 @@ class Comic < ActiveRecord::Base
       :author, 
       :panels => [
         :panel_pictures => :resource_picture, 
-        :balloons => :speaches
+        :balloons => :speeches
       ]
-    ], order: 'panels.t, speaches.t')
+    ], order: 'panels.t, speeches.t')
   end
   
   def to_json_play
index 2d7de5b..45090ea 100644 (file)
@@ -116,7 +116,7 @@ class Panel < ActiveRecord::Base
       :panel_pictures => {
         :resource_picture => {:artist => {}, :license => {}}
       }, 
-      :balloons => {:speaches => {}},
+      :balloons => {:speeches => {}},
       :author => {}
     }}
   end
@@ -127,7 +127,7 @@ class Panel < ActiveRecord::Base
       :panel_pictures => {
         :resource_picture => {:artist => {}, :license => {}}
       }, 
-      :balloons => {:speaches => {}},
+      :balloons => {:speeches => {}},
       :author => {}
     }}
   end
@@ -144,7 +144,7 @@ class Panel < ActiveRecord::Base
       :panel_pictures => {
         :resource_picture => {:artist => {}, :license => {}}
       }, 
-      :balloons => {:speaches => {}},
+      :balloons => {:speeches => {}},
       :author => {}
     }
     res.merge!(opt[:include]) if opt[:include]
@@ -157,7 +157,7 @@ class Panel < ActiveRecord::Base
       :panel_pictures => {
         :resource_picture => {:artist => {}, :license => {}}
       }, 
-      :balloons => {:speaches => {}},
+      :balloons => {:speeches => {}},
       :author => {}
     }}
   end
@@ -197,7 +197,7 @@ class Panel < ActiveRecord::Base
         res[elm.t] = elm.to_json({:include => :resource_picture})
       end
       if elm.kind_of?(Balloon)
-        res[elm.t] = elm.to_json({:include => :speaches})
+        res[elm.t] = elm.to_json({:include => :speeches})
       end
     end
     res
diff --git a/app/models/speach.rb b/app/models/speach.rb
deleted file mode 100644 (file)
index 2346626..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-class Speach < ActiveRecord::Base
-  belongs_to :balloon
-end
diff --git a/app/models/speach_balloon_template.rb b/app/models/speach_balloon_template.rb
deleted file mode 100644 (file)
index 3af508b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-class SpeachBalloonTemplate < ActiveRecord::Base
-  has_many :balloon_templates, :dependent => :destroy
-  has_many :speach_templates, :dependent => :destroy
-  accepts_nested_attributes_for :balloon_templates
-  accepts_nested_attributes_for :speach_templates
-  before_create :supply_t
-  
-  def supply_t
-    self.t = SpeachBalloon.maximum(:t).to_i + 1
-  end
-  
-end
diff --git a/app/models/speach_template.rb b/app/models/speach_template.rb
deleted file mode 100644 (file)
index b44ebed..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-class SpeachTemplate < ActiveRecord::Base
-  belongs_to :balloon_template
-end
diff --git a/app/models/speech.rb b/app/models/speech.rb
new file mode 100644 (file)
index 0000000..fc1ff5b
--- /dev/null
@@ -0,0 +1,3 @@
+class Speech < ActiveRecord::Base
+  belongs_to :balloon
+end
similarity index 64%
rename from app/models/speach_balloon.rb
rename to app/models/speech_balloon.rb
index 5858562..89e3454 100644 (file)
@@ -1,10 +1,10 @@
-class SpeachBalloon < ActiveRecord::Base
+class SpeechBalloon < ActiveRecord::Base
   has_many :balloon_templates, :dependent => :destroy
   accepts_nested_attributes_for :balloon_templates
   before_create :supply_t
   
   def supply_t
-    self.t = SpeachBalloon.maximum(:t).to_i + 1
+    self.t = SpeechBalloon.maximum(:t).to_i + 1
   end
   
 end
diff --git a/app/models/speech_balloon_template.rb b/app/models/speech_balloon_template.rb
new file mode 100644 (file)
index 0000000..de6d053
--- /dev/null
@@ -0,0 +1,12 @@
+class SpeechBalloonTemplate < ActiveRecord::Base
+  has_many :balloon_templates, :dependent => :destroy
+  has_many :speech_templates, :dependent => :destroy
+  accepts_nested_attributes_for :balloon_templates
+  accepts_nested_attributes_for :speech_templates
+  before_create :supply_t
+  
+  def supply_t
+    self.t = SpeechBalloon.maximum(:t).to_i + 1
+  end
+  
+end
diff --git a/app/models/speech_template.rb b/app/models/speech_template.rb
new file mode 100644 (file)
index 0000000..d0871b3
--- /dev/null
@@ -0,0 +1,3 @@
+class SpeechTemplate < ActiveRecord::Base
+  belongs_to :balloon_template
+end
index 7e59e7d..93b1b81 100644 (file)
@@ -2,7 +2,7 @@
 
 <table>
   <tr>
-    <th>speach balloon</th>
+    <th>speech balloon</th>
     <th>system_picture</th>
     <th>Tail</th>
     <th>size</th>
@@ -14,7 +14,7 @@
 
 <% @balloon_templates.each do |balloon_template| %>
   <tr>
-    <td><%= balloon_template.speach_balloon_id %></td>
+    <td><%= balloon_template.speech_balloon_id %></td>
     <td><%= balloon_template.system_picture_id %></td>
     <td><%= balloon_template.tail %></td>
     <td><%= balloon_template.size %></td>
index 2091351..7a83614 100644 (file)
@@ -3,7 +3,7 @@
 <table>
   <tr>
     <th>id</th>
-    <th>speach balloon</th>
+    <th>speech balloon</th>
     <th>system_picture</th>
     <th>Tail</th>
     <th>size</th>
@@ -18,7 +18,7 @@
 <% @balloon_templates.each do |balloon_template| %>
   <tr>
     <td><%= link_to balloon_template.id, :action => :browse, :id => balloon_template.id %></td>
-    <td><%= link_to balloon_template.speach_balloon_id, :controller => 'speach_balloons', :action => :browse, :id => balloon_template.speach_balloon_id %></td>
+    <td><%= link_to balloon_template.speech_balloon_id, :controller => 'speech_balloons', :action => :browse, :id => balloon_template.speech_balloon_id %></td>
     <td><%= link_to balloon_template.system_picture_id, :controller => 'system_pictures', :action => :browse, :id => balloon_template.system_picture_id %></td>
     <td><%= balloon_template.tail %></td>
     <td><%= balloon_template.size %></td>
index b78281b..1b97e71 100644 (file)
                        <script id="textElementTemplete" type="text/x-jquery-tmpl">\r
                                <div class="comic-element-wrapper text-element">\r
                                        <img>\r
-                                       <div class="speach">\r
-                                               <div class="speach-inner">&nbsp;</div>\r
+                                       <div class="speech">\r
+                                               <div class="speech-inner">&nbsp;</div>\r
                                        </div>\r
                                </div>\r
                        </script>\r
                        <script id="textElementTempleteForOldIE" type="text/x-jquery-tmpl">\r
                                <div class="comic-element-wrapper text-element">\r
                                        <img>\r
-                                       <div class="speach">\r
+                                       <div class="speech">\r
                                                <table><tr><td>&nbsp;</td></tr></table>\r
                                        </div>\r
                                </div>\r
                </div>\r
                \r
        <!-- テキスト エディタ -->\r
-               <div id="speach-editor-wrapper">\r
-                       <textarea id="speach-editor"></textarea>\r
-                       <div id="speach-edit-complete-button" class="button">OK</div>\r
+               <div id="speech-editor-wrapper">\r
+                       <textarea id="speech-editor"></textarea>\r
+                       <div id="speech-edit-complete-button" class="button">OK</div>\r
                </div>\r
 \r
        <!-- 画像グループから画像を選択 -->\r
index cb9df27..905f1f1 100644 (file)
 <%= link_to 'resource_pictures', resource_pictures_path %>\r
 <%= link_to 'panel_pictures', panel_pictures_path %>\r
 <%= link_to 'balloons', balloons_path %>\r
-<%= link_to 'speaches', speaches_path %>\r
+<%= link_to 'speeches', speeches_path %>\r
  : \r
-<%= link_to 'speach_balloons', speach_balloons_path %>\r
+<%= link_to 'speech_balloons', speech_balloons_path %>\r
 <%= link_to 'balloon_templates', balloon_templates_path %>\r
-<%= link_to 'speach_templates', speach_templates_path %>\r
+<%= link_to 'speech_templates', speech_templates_path %>\r
  : \r
 <%= link_to 'artists', artists_path %>\r
 <%= link_to 'system_pictures', system_pictures_path %>\r
index aada79d..e1ae5ad 100644 (file)
@@ -11,9 +11,9 @@ t:<%= @panel.t %>
     <% if elm.kind_of?(Balloon) %>
       <div id="vballoon<%= elm.id -%>" class="balloon" style="position:relative;  top:<%= elm.y -%>px; left:<%= elm.x -%>px; z-index:<%= elm.z -%>; ">
         <img style=" position:absolute; width:<%= elm.width -%>px; height:<%= elm.height -%>px; " src="<%= elm.system_picture.url -%>">
-        <% elm.speaches.each do |speach| %>
-          <div style="position:relative; top:<%= speach.y -%>px; left:<%= speach.x -%>px;width:<%= speach.width -%>px; height:<%= speach.height -%>px; top:1px; left:1px; z-index:1; ">
-            <%= h speach.content -%>
+        <% elm.speeches.each do |speech| %>
+          <div style="position:relative; top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px; top:1px; left:1px; z-index:1; ">
+            <%= h speech.content -%>
           </div>
         <% end %>
       </div>
index 8736037..3783fd3 100644 (file)
@@ -11,9 +11,9 @@
   <% panel.balloons.each do |balloon| %>
     <div id="vballoon<%= balloon.id -%>" class="balloon" style="position:relative;  top:<%= balloon.y -%>px; left:<%= balloon.x -%>px; z-index:<%= balloon.z -%>; ">
       <img style=" position:absolute; width:<%= balloon.width -%>px; height:<%= balloon.height -%>px; " src="<%= balloon.system_picture.url -%>">
-      <% balloon.speaches.each do |speach| %>
-        <div style="position:relative; top:<%= speach.y -%>px; left:<%= speach.x -%>px;width:<%= speach.width -%>px; height:<%= speach.height -%>px; top:1px; left:1px; z-index:1; ">
-          <%= h speach.content -%>
+      <% balloon.speeches.each do |speech| %>
+        <div style="position:relative; top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px; top:1px; left:1px; z-index:1; ">
+          <%= h speech.content -%>
         </div>
       <% end %>
     </div>
diff --git a/app/views/speach_balloon_templates/_form.html.erb b/app/views/speach_balloon_templates/_form.html.erb
deleted file mode 100644 (file)
index 3a61fdb..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<%= form_for(@speach_balloon_template) do |f| %>
-  <% if @speach_balloon_template.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@speach_balloon_template.errors.count, "error") %> prohibited this speach_balloon_template from being saved:</h2>
-
-      <ul>
-      <% @speach_balloon_template.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
-
-  <div class="actions">
-    <%= f.submit %>
-  </div>
-<% end %>
diff --git a/app/views/speach_balloon_templates/index.html.erb b/app/views/speach_balloon_templates/index.html.erb
deleted file mode 100644 (file)
index d9aa256..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<h1>Listing speach_balloons</h1>
-<table>
-  <tr>
-    <th>Name</th>
-    <th>Tail count</th>
-    <th>size count</th>
-    <th>t</th>
-    <th></th>
-    <th></th>
-  </tr>
-
-<% @speach_balloons.each do |speach_balloon| %>
-  <tr>
-    <td><%= h speach_balloon.name %></td>
-    <td><%= speach_balloon.tail_count %></td>
-    <td><%= speach_balloon.size_count %></td>
-    <td><%= speach_balloon.t %></td>
-    <td><%= link_to 'show', speach_balloon %></td>
-    <td>
-      <% if admin_signed_in? -%>
-        <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
-      <% end -%>
-    </td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speach_balloon_templates/list.html.erb b/app/views/speach_balloon_templates/list.html.erb
deleted file mode 100644 (file)
index d3e2e48..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<h1>Listing speach_balloons</h1>
-<table>
-  <tr>
-    <th>id</th>
-    <th>Name</th>
-    <th>Tail count</th>
-    <th>size count</th>
-    <th>t</th>
-    <th>created_at</th>
-    <th>updated_at</th>
-    <th></th>
-  </tr>
-
-<% @speach_balloons.each do |speach_balloon| %>
-  <tr>
-    <td><%= link_to speach_balloon.id, :action => :browse, :id => speach_balloon.id %></td>
-    <td><%= h speach_balloon.name %></td>
-    <td><%= speach_balloon.tail_count %></td>
-    <td><%= speach_balloon.size_count %></td>
-    <td><%= speach_balloon.t %></td>
-    <td><%= speach_balloon.created_at %></td>
-    <td><%= speach_balloon.updated_at %></td>
-    <td>
-      <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
-    </td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speach_balloons/index.html.erb b/app/views/speach_balloons/index.html.erb
deleted file mode 100644 (file)
index d9aa256..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<h1>Listing speach_balloons</h1>
-<table>
-  <tr>
-    <th>Name</th>
-    <th>Tail count</th>
-    <th>size count</th>
-    <th>t</th>
-    <th></th>
-    <th></th>
-  </tr>
-
-<% @speach_balloons.each do |speach_balloon| %>
-  <tr>
-    <td><%= h speach_balloon.name %></td>
-    <td><%= speach_balloon.tail_count %></td>
-    <td><%= speach_balloon.size_count %></td>
-    <td><%= speach_balloon.t %></td>
-    <td><%= link_to 'show', speach_balloon %></td>
-    <td>
-      <% if admin_signed_in? -%>
-        <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
-      <% end -%>
-    </td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speach_balloons/list.html.erb b/app/views/speach_balloons/list.html.erb
deleted file mode 100644 (file)
index d3e2e48..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<h1>Listing speach_balloons</h1>
-<table>
-  <tr>
-    <th>id</th>
-    <th>Name</th>
-    <th>Tail count</th>
-    <th>size count</th>
-    <th>t</th>
-    <th>created_at</th>
-    <th>updated_at</th>
-    <th></th>
-  </tr>
-
-<% @speach_balloons.each do |speach_balloon| %>
-  <tr>
-    <td><%= link_to speach_balloon.id, :action => :browse, :id => speach_balloon.id %></td>
-    <td><%= h speach_balloon.name %></td>
-    <td><%= speach_balloon.tail_count %></td>
-    <td><%= speach_balloon.size_count %></td>
-    <td><%= speach_balloon.t %></td>
-    <td><%= speach_balloon.created_at %></td>
-    <td><%= speach_balloon.updated_at %></td>
-    <td>
-      <%= link_to 'Destroy', speach_balloon, confirm: 'Are you sure?', method: :delete %>
-    </td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speach_templates/index.html.erb b/app/views/speach_templates/index.html.erb
deleted file mode 100644 (file)
index e1b1972..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<h1>Listing speach_templates</h1>
-
-<table>
-  <tr>
-    <th>balloon template</th>
-    <th>x</th>
-    <th>y</th>
-    <th>Width</th>
-    <th>Height</th>
-  </tr>
-
-<% @speach_templates.each do |speach_template| %>
-  <tr>
-    <td><%= speach_template.balloon_template_id %></td>
-    <td><%= speach_template.x %></td>
-    <td><%= speach_template.y %></td>
-    <td><%= speach_template.width %></td>
-    <td><%= speach_template.height %></td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speach_templates/list.html.erb b/app/views/speach_templates/list.html.erb
deleted file mode 100644 (file)
index 4577d04..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<h1>Listing speach_templates</h1>
-
-<table>
-  <tr>
-    <th>id</th>
-    <th>balloon template</th>
-    <th>x</th>
-    <th>y</th>
-    <th>Width</th>
-    <th>Height</th>
-    <th>created_at</th>
-    <th>updated_at</th>
-  </tr>
-
-<% @speach_templates.each do |speach_template| %>
-  <tr>
-    <td><%= link_to speach_template.id, :action => :browse, :id => speach_template.id %></td>
-    <td><%= link_to speach_template.balloon_template_id, :controller => 'balloon_templates', :action => :browse, :id => speach_template.balloon_template_id %></td>
-    <td><%= speach_template.x %></td>
-    <td><%= speach_template.y %></td>
-    <td><%= speach_template.width %></td>
-    <td><%= speach_template.height %></td>
-    <td><%= speach_template.created_at %></td>
-    <td><%= speach_template.updated_at %></td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speaches/index.html.erb b/app/views/speaches/index.html.erb
deleted file mode 100644 (file)
index 3eb59d8..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<h1>Listing speaches</h1>
-
-<table>
-  <tr>
-    <th>balloon</th>
-    <th>content</th>
-    <th>x</th>
-    <th>y</th>
-    <th>t</th>
-    <th>Width</th>
-    <th>Height</th>
-  </tr>
-
-<% @speaches.each do |speach| %>
-  <tr>
-    <td><%= speach.balloon_id %></td>
-    <td><%= h speach.content %></td>
-    <td><%= speach.x %></td>
-    <td><%= speach.y %></td>
-    <td><%= speach.t %></td>
-    <td><%= speach.width %></td>
-    <td><%= speach.height %></td>
-  </tr>
-<% end %>
-</table>
-
diff --git a/app/views/speaches/list.html.erb b/app/views/speaches/list.html.erb
deleted file mode 100644 (file)
index 928b135..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<h1>Listing speaches</h1>
-
-<table>
-  <tr>
-    <th>id</th>
-    <th>balloon</th>
-    <th>content</th>
-    <th>x</th>
-    <th>y</th>
-    <th>t</th>
-    <th>Width</th>
-    <th>Height</th>
-    <th>created_at</th>
-    <th>updated_at</th>
-  </tr>
-
-<% @speaches.each do |speach| %>
-  <tr>
-    <td><%= speach.id %></td>
-    <td><%= link_to speach.balloon_id, :controller => 'balloons', :action => :browse, :id => speach.balloon_id %></td>
-    <td><%= h speach.content %></td>
-    <td><%= speach.x %></td>
-    <td><%= speach.y %></td>
-    <td><%= speach.t %></td>
-    <td><%= speach.width %></td>
-    <td><%= speach.height %></td>
-    <td><%= speach.created_at %></td>
-    <td><%= speach.updated_at %></td>
-  </tr>
-<% end %>
-</table>
diff --git a/app/views/speech_balloon_templates/_form.html.erb b/app/views/speech_balloon_templates/_form.html.erb
new file mode 100644 (file)
index 0000000..cfe0195
--- /dev/null
@@ -0,0 +1,17 @@
+<%= form_for(@speech_balloon_template) do |f| %>
+  <% if @speech_balloon_template.errors.any? %>
+    <div id="error_explanation">
+      <h2><%= pluralize(@speech_balloon_template.errors.count, "error") %> prohibited this speech_balloon_template from being saved:</h2>
+
+      <ul>
+      <% @speech_balloon_template.errors.full_messages.each do |msg| %>
+        <li><%= msg %></li>
+      <% end %>
+      </ul>
+    </div>
+  <% end %>
+
+  <div class="actions">
+    <%= f.submit %>
+  </div>
+<% end %>
@@ -2,24 +2,24 @@
 
 <p>
   <b>Name:</b>
-  <%= h @speach_balloon.name %>
+  <%= h @speech_balloon.name %>
 </p>
 
 <p>
   <b>Tail count:</b>
-  <%= @speach_balloon.tail_count %>
+  <%= @speech_balloon.tail_count %>
 </p>
 
 <p>
   <b>size count:</b>
-  <%= @speach_balloon.size_count %>
+  <%= @speech_balloon.size_count %>
 </p>
 
 <p>
   <b>t:</b>
-  <%= @speach_balloon.t %>
+  <%= @speech_balloon.t %>
 </p>
-<% @speach_balloon.balloon_templates.each do |balloon_template| -%>\r
+<% @speech_balloon.balloon_templates.each do |balloon_template| -%>\r
   <div>\r
     <p>\r
       Tail:<%= balloon_template.tail -%>\r
diff --git a/app/views/speech_balloon_templates/index.html.erb b/app/views/speech_balloon_templates/index.html.erb
new file mode 100644 (file)
index 0000000..3ea04e5
--- /dev/null
@@ -0,0 +1,26 @@
+<h1>Listing speech_balloons</h1>
+<table>
+  <tr>
+    <th>Name</th>
+    <th>Tail count</th>
+    <th>size count</th>
+    <th>t</th>
+    <th></th>
+    <th></th>
+  </tr>
+
+<% @speech_balloons.each do |speech_balloon| %>
+  <tr>
+    <td><%= h speech_balloon.name %></td>
+    <td><%= speech_balloon.tail_count %></td>
+    <td><%= speech_balloon.size_count %></td>
+    <td><%= speech_balloon.t %></td>
+    <td><%= link_to 'show', speech_balloon %></td>
+    <td>
+      <% if admin_signed_in? -%>
+        <%= link_to 'Destroy', speech_balloon, confirm: 'Are you sure?', method: :delete %>
+      <% end -%>
+    </td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/speech_balloon_templates/list.html.erb b/app/views/speech_balloon_templates/list.html.erb
new file mode 100644 (file)
index 0000000..d9e7471
--- /dev/null
@@ -0,0 +1,28 @@
+<h1>Listing speech_balloons</h1>
+<table>
+  <tr>
+    <th>id</th>
+    <th>Name</th>
+    <th>Tail count</th>
+    <th>size count</th>
+    <th>t</th>
+    <th>created_at</th>
+    <th>updated_at</th>
+    <th></th>
+  </tr>
+
+<% @speech_balloons.each do |speech_balloon| %>
+  <tr>
+    <td><%= link_to speech_balloon.id, :action => :browse, :id => speech_balloon.id %></td>
+    <td><%= h speech_balloon.name %></td>
+    <td><%= speech_balloon.tail_count %></td>
+    <td><%= speech_balloon.size_count %></td>
+    <td><%= speech_balloon.t %></td>
+    <td><%= speech_balloon.created_at %></td>
+    <td><%= speech_balloon.updated_at %></td>
+    <td>
+      <%= link_to 'Destroy', speech_balloon, confirm: 'Are you sure?', method: :delete %>
+    </td>
+  </tr>
+<% end %>
+</table>
@@ -2,24 +2,24 @@
 
 <p>
   <b>Name:</b>
-  <%= h @speach_balloon.name %>
+  <%= h @speech_balloon.name %>
 </p>
 
 <p>
   <b>Tail count:</b>
-  <%= @speach_balloon.tail_count %>
+  <%= @speech_balloon.tail_count %>
 </p>
 
 <p>
   <b>size count:</b>
-  <%= @speach_balloon.size_count %>
+  <%= @speech_balloon.size_count %>
 </p>
 
 <p>
   <b>t:</b>
-  <%= @speach_balloon.t %>
+  <%= @speech_balloon.t %>
 </p>
-<% @speach_balloon.balloon_templates.each do |balloon_template| -%>\r
+<% @speech_balloon.balloon_templates.each do |balloon_template| -%>\r
   <div>\r
     <p>\r
       Tail:<%= balloon_template.tail -%>\r
@@ -28,4 +28,4 @@
     <img src="<%= balloon_template.system_picture.url -%>" />\r
   </div>\r
 <% end -%>\r
-<%= link_to 'Back', speach_balloons_path %>
+<%= link_to 'Back', speech_balloons_path %>
@@ -2,24 +2,24 @@
 
 <p>
   <b>Name:</b>
-  <%= h @speach_balloon.name %>
+  <%= h @speech_balloon.name %>
 </p>
 
 <p>
   <b>Tail count:</b>
-  <%= @speach_balloon.tail_count %>
+  <%= @speech_balloon.tail_count %>
 </p>
 
 <p>
   <b>size count:</b>
-  <%= @speach_balloon.size_count %>
+  <%= @speech_balloon.size_count %>
 </p>
 
 <p>
   <b>t:</b>
-  <%= @speach_balloon.t %>
+  <%= @speech_balloon.t %>
 </p>
-<% @speach_balloon.balloon_templates.each do |balloon_template| -%>\r
+<% @speech_balloon.balloon_templates.each do |balloon_template| -%>\r
   <div>\r
     <p>\r
       Tail:<%= balloon_template.tail -%>\r
diff --git a/app/views/speech_balloons/index.html.erb b/app/views/speech_balloons/index.html.erb
new file mode 100644 (file)
index 0000000..3ea04e5
--- /dev/null
@@ -0,0 +1,26 @@
+<h1>Listing speech_balloons</h1>
+<table>
+  <tr>
+    <th>Name</th>
+    <th>Tail count</th>
+    <th>size count</th>
+    <th>t</th>
+    <th></th>
+    <th></th>
+  </tr>
+
+<% @speech_balloons.each do |speech_balloon| %>
+  <tr>
+    <td><%= h speech_balloon.name %></td>
+    <td><%= speech_balloon.tail_count %></td>
+    <td><%= speech_balloon.size_count %></td>
+    <td><%= speech_balloon.t %></td>
+    <td><%= link_to 'show', speech_balloon %></td>
+    <td>
+      <% if admin_signed_in? -%>
+        <%= link_to 'Destroy', speech_balloon, confirm: 'Are you sure?', method: :delete %>
+      <% end -%>
+    </td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/speech_balloons/list.html.erb b/app/views/speech_balloons/list.html.erb
new file mode 100644 (file)
index 0000000..d9e7471
--- /dev/null
@@ -0,0 +1,28 @@
+<h1>Listing speech_balloons</h1>
+<table>
+  <tr>
+    <th>id</th>
+    <th>Name</th>
+    <th>Tail count</th>
+    <th>size count</th>
+    <th>t</th>
+    <th>created_at</th>
+    <th>updated_at</th>
+    <th></th>
+  </tr>
+
+<% @speech_balloons.each do |speech_balloon| %>
+  <tr>
+    <td><%= link_to speech_balloon.id, :action => :browse, :id => speech_balloon.id %></td>
+    <td><%= h speech_balloon.name %></td>
+    <td><%= speech_balloon.tail_count %></td>
+    <td><%= speech_balloon.size_count %></td>
+    <td><%= speech_balloon.t %></td>
+    <td><%= speech_balloon.created_at %></td>
+    <td><%= speech_balloon.updated_at %></td>
+    <td>
+      <%= link_to 'Destroy', speech_balloon, confirm: 'Are you sure?', method: :delete %>
+    </td>
+  </tr>
+<% end %>
+</table>
similarity index 57%
rename from app/views/speach_balloons/show.html.erb
rename to app/views/speech_balloons/show.html.erb
index 12b2e8e..6ef4812 100644 (file)
@@ -2,24 +2,24 @@
 
 <p>
   <b>Name:</b>
-  <%= h @speach_balloon.name %>
+  <%= h @speech_balloon.name %>
 </p>
 
 <p>
   <b>Tail count:</b>
-  <%= @speach_balloon.tail_count %>
+  <%= @speech_balloon.tail_count %>
 </p>
 
 <p>
   <b>size count:</b>
-  <%= @speach_balloon.size_count %>
+  <%= @speech_balloon.size_count %>
 </p>
 
 <p>
   <b>t:</b>
-  <%= @speach_balloon.t %>
+  <%= @speech_balloon.t %>
 </p>
-<% @speach_balloon.balloon_templates.each do |balloon_template| -%>\r
+<% @speech_balloon.balloon_templates.each do |balloon_template| -%>\r
   <div>\r
     <p>\r
       Tail:<%= balloon_template.tail -%>\r
@@ -28,4 +28,4 @@
     <img src="<%= balloon_template.system_picture.url -%>" />\r
   </div>\r
 <% end -%>\r
-<%= link_to 'Back', speach_balloons_path %>
+<%= link_to 'Back', speech_balloons_path %>
diff --git a/app/views/speech_templates/index.html.erb b/app/views/speech_templates/index.html.erb
new file mode 100644 (file)
index 0000000..470ad0f
--- /dev/null
@@ -0,0 +1,21 @@
+<h1>Listing speech_templates</h1>
+
+<table>
+  <tr>
+    <th>balloon template</th>
+    <th>x</th>
+    <th>y</th>
+    <th>Width</th>
+    <th>Height</th>
+  </tr>
+
+<% @speech_templates.each do |speech_template| %>
+  <tr>
+    <td><%= speech_template.balloon_template_id %></td>
+    <td><%= speech_template.x %></td>
+    <td><%= speech_template.y %></td>
+    <td><%= speech_template.width %></td>
+    <td><%= speech_template.height %></td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/speech_templates/list.html.erb b/app/views/speech_templates/list.html.erb
new file mode 100644 (file)
index 0000000..8a7718d
--- /dev/null
@@ -0,0 +1,27 @@
+<h1>Listing speech_templates</h1>
+
+<table>
+  <tr>
+    <th>id</th>
+    <th>balloon template</th>
+    <th>x</th>
+    <th>y</th>
+    <th>Width</th>
+    <th>Height</th>
+    <th>created_at</th>
+    <th>updated_at</th>
+  </tr>
+
+<% @speech_templates.each do |speech_template| %>
+  <tr>
+    <td><%= link_to speech_template.id, :action => :browse, :id => speech_template.id %></td>
+    <td><%= link_to speech_template.balloon_template_id, :controller => 'balloon_templates', :action => :browse, :id => speech_template.balloon_template_id %></td>
+    <td><%= speech_template.x %></td>
+    <td><%= speech_template.y %></td>
+    <td><%= speech_template.width %></td>
+    <td><%= speech_template.height %></td>
+    <td><%= speech_template.created_at %></td>
+    <td><%= speech_template.updated_at %></td>
+  </tr>
+<% end %>
+</table>
diff --git a/app/views/speeches/index.html.erb b/app/views/speeches/index.html.erb
new file mode 100644 (file)
index 0000000..d481a0e
--- /dev/null
@@ -0,0 +1,26 @@
+<h1>Listing speeches</h1>
+
+<table>
+  <tr>
+    <th>balloon</th>
+    <th>content</th>
+    <th>x</th>
+    <th>y</th>
+    <th>t</th>
+    <th>Width</th>
+    <th>Height</th>
+  </tr>
+
+<% @speeches.each do |speech| %>
+  <tr>
+    <td><%= speech.balloon_id %></td>
+    <td><%= h speech.content %></td>
+    <td><%= speech.x %></td>
+    <td><%= speech.y %></td>
+    <td><%= speech.t %></td>
+    <td><%= speech.width %></td>
+    <td><%= speech.height %></td>
+  </tr>
+<% end %>
+</table>
+
diff --git a/app/views/speeches/list.html.erb b/app/views/speeches/list.html.erb
new file mode 100644 (file)
index 0000000..8417d57
--- /dev/null
@@ -0,0 +1,31 @@
+<h1>Listing speeches</h1>
+
+<table>
+  <tr>
+    <th>id</th>
+    <th>balloon</th>
+    <th>content</th>
+    <th>x</th>
+    <th>y</th>
+    <th>t</th>
+    <th>Width</th>
+    <th>Height</th>
+    <th>created_at</th>
+    <th>updated_at</th>
+  </tr>
+
+<% @speeches.each do |speech| %>
+  <tr>
+    <td><%= speech.id %></td>
+    <td><%= link_to speech.balloon_id, :controller => 'balloons', :action => :browse, :id => speech.balloon_id %></td>
+    <td><%= h speech.content %></td>
+    <td><%= speech.x %></td>
+    <td><%= speech.y %></td>
+    <td><%= speech.t %></td>
+    <td><%= speech.width %></td>
+    <td><%= speech.height %></td>
+    <td><%= speech.created_at %></td>
+    <td><%= speech.updated_at %></td>
+  </tr>
+<% end %>
+</table>
index b7eb7fa..e6d7f83 100644 (file)
@@ -35,7 +35,7 @@
   </tr>
   <tr>
     <td>
-      <%= link_to 'speaches', :controller => 'speaches', :action => :list %>
+      <%= link_to 'speeches', :controller => 'speeches', :action => :list %>
     </td>
   </tr>
 </table>
@@ -43,7 +43,7 @@
 <table>
   <tr>
     <td>
-      <%= link_to 'speach_balloons', :controller => 'speach_balloons', :action => :list %>
+      <%= link_to 'speech_balloons', :controller => 'speech_balloons', :action => :list %>
     </td>
   </tr>
   <tr>
@@ -53,7 +53,7 @@
   </tr>
   <tr>
     <td>
-      <%= link_to 'speach_templates', :controller => 'speach_templates', :action => :list %>
+      <%= link_to 'speech_templates', :controller => 'speech_templates', :action => :list %>
     </td>
   </tr>
 </table>
index a86668e..0bb58ae 100644 (file)
@@ -33,7 +33,7 @@ Pettanr::Application.routes.draw do
       delete :destroy
     end
   end
-  resources :speach_balloon_templates do
+  resources :speech_balloon_templates do
     collection do
       get :index
       get :show
@@ -44,7 +44,7 @@ Pettanr::Application.routes.draw do
       delete :destroy
     end
   end
-  resources :speach_templates do
+  resources :speech_templates do
     collection do
       get :index
       get :show
@@ -64,7 +64,7 @@ Pettanr::Application.routes.draw do
     member do
     end
   end
-  resources :speaches do
+  resources :speeches do
     collection do
       get :list
       get :browse
@@ -80,7 +80,7 @@ Pettanr::Application.routes.draw do
     member do
     end
   end
-  resources :speach_balloons do
+  resources :speech_balloons do
     collection do
       get :list
       get :browse
index 9f1f761..f5a1e93 100644 (file)
@@ -1,7 +1,7 @@
 class CreateBalloonTemplates < ActiveRecord::Migration
   def change
     create_table :balloon_templates do |t|
-      t.integer :speach_balloon_id, :null => false
+      t.integer :speech_balloon_id, :null => false
       t.integer :system_picture_id, :null => false
       t.integer :tail, :null => false, :default => 1
       t.integer :size, :null => false, :default => 1
@@ -12,7 +12,7 @@ class CreateBalloonTemplates < ActiveRecord::Migration
 
       t.timestamps
     end
-    add_index :balloon_templates, [:speach_balloon_id]
-    add_index :balloon_templates, [:speach_balloon_id, :tail, :size], :unique => true, :name => 'balloon_templates_idts'
+    add_index :balloon_templates, [:speech_balloon_id]
+    add_index :balloon_templates, [:speech_balloon_id, :tail, :size], :unique => true, :name => 'balloon_templates_idts'
   end
 end
@@ -1,6 +1,6 @@
-class CreateSpeachTemplates < ActiveRecord::Migration
+class CreateSpeechTemplates < ActiveRecord::Migration
   def change
-    create_table :speach_templates do |t|
+    create_table :speech_templates do |t|
       t.integer :balloon_template_id, :null => false
       t.integer :x, :null => false
       t.integer :y, :null => false
@@ -10,6 +10,6 @@ class CreateSpeachTemplates < ActiveRecord::Migration
 
       t.timestamps
     end
-    add_index :speach_templates, [:balloon_template_id, :t], :unique => true, :name => 'speach_templates_idt'
+    add_index :speech_templates, [:balloon_template_id, :t], :unique => true, :name => 'speech_templates_idt'
   end
 end
similarity index 55%
rename from db/migrate/20111206130635_create_speaches.rb
rename to db/migrate/20111206130635_create_speeches.rb
index b852831..9d9d174 100644 (file)
@@ -1,8 +1,8 @@
-class CreateSpeaches < ActiveRecord::Migration
+class CreateSpeeches < ActiveRecord::Migration
   def change
-    create_table :speaches do |t|
+    create_table :speeches do |t|
       t.integer :balloon_id, :null => false
-      t.integer :speach_template_id, :null => false
+      t.integer :speech_template_id, :null => false
       t.string :content
       t.integer :x, :null => false
       t.integer :y, :null => false
@@ -12,7 +12,7 @@ class CreateSpeaches < ActiveRecord::Migration
 
       t.timestamps
     end
-    add_index :speaches, [:balloon_id]
-    add_index :speaches, [:balloon_id, :t], :unique => true, :name => 'speaches_bt'
+    add_index :speeches, [:balloon_id]
+    add_index :speeches, [:balloon_id, :t], :unique => true, :name => 'speeches_bt'
   end
 end
@@ -1,6 +1,6 @@
-class CreateSpeachBalloons < ActiveRecord::Migration
+class CreateSpeechBalloons < ActiveRecord::Migration
   def change
-    create_table :speach_balloons do |t|
+    create_table :speech_balloons do |t|
       t.string :name, :null => false
       t.integer :tail_count, :null => false, :default => 1
       t.integer :size_count, :null => false, :default => 1
@@ -8,6 +8,6 @@ class CreateSpeachBalloons < ActiveRecord::Migration
 
       t.timestamps
     end
-    add_index :speach_balloons, [:t], :unique => true, :name => 'speach_balloons_t'
+    add_index :speech_balloons, [:t], :unique => true, :name => 'speech_balloons_t'
   end
 end
diff --git a/db/migrate/20120424100555_create_speach_balloon_templates.rb b/db/migrate/20120424100555_create_speach_balloon_templates.rb
deleted file mode 100644 (file)
index 9071ee2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-class CreateSpeachBalloonTemplates < ActiveRecord::Migration
-  def change
-    create_table :speach_balloon_templates do |t|
-
-      t.timestamps
-    end
-  end
-end
diff --git a/db/migrate/20120424100555_create_speech_balloon_templates.rb b/db/migrate/20120424100555_create_speech_balloon_templates.rb
new file mode 100644 (file)
index 0000000..66e05d6
--- /dev/null
@@ -0,0 +1,8 @@
+class CreateSpeechBalloonTemplates < ActiveRecord::Migration
+  def change
+    create_table :speech_balloon_templates do |t|
+
+      t.timestamps
+    end
+  end
+end
index 937d0d3..7d8a12f 100644 (file)
@@ -60,7 +60,7 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
   add_index "authors", ["user_id"], :name => "index_authors_on_user_id", :unique => true\r
 \r
   create_table "balloon_templates", :force => true do |t|\r
-    t.integer  "speach_balloon_id",                :null => false\r
+    t.integer  "speech_balloon_id",                :null => false\r
     t.integer  "system_picture_id",                :null => false\r
     t.integer  "tail",              :default => 1, :null => false\r
     t.integer  "size",              :default => 1, :null => false\r
@@ -72,8 +72,8 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
     t.datetime "updated_at"\r
   end\r
 \r
-  add_index "balloon_templates", ["speach_balloon_id", "tail", "size"], :name => "balloon_templates_idts", :unique => true\r
-  add_index "balloon_templates", ["speach_balloon_id"], :name => "index_balloon_templates_on_speach_balloon_id"\r
+  add_index "balloon_templates", ["speech_balloon_id", "tail", "size"], :name => "balloon_templates_idts", :unique => true\r
+  add_index "balloon_templates", ["speech_balloon_id"], :name => "index_balloon_templates_on_speech_balloon_id"\r
 \r
   create_table "balloons", :force => true do |t|\r
     t.integer  "panel_id",                           :null => false\r
@@ -141,7 +141,6 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
   add_index "licenses", ["url"], :name => "index_licenses_on_url", :unique => true\r
 \r
   create_table "original_licenses", :force => true do |t|\r
-    t.integer  "artist_id",                        :null => false\r
     t.integer  "license_id",                       :null => false\r
     t.string   "name",                             :null => false\r
     t.string   "url",                              :null => false\r
@@ -192,11 +191,11 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
     t.integer  "width",               :default => 200, :null => false\r
     t.integer  "height",              :default => 80,  :null => false\r
     t.integer  "border",              :default => 1,   :null => false\r
-    t.integer  "x",                                    :null => false\r
-    t.integer  "y",                                    :null => false\r
-    t.integer  "z",                                    :null => false\r
-    t.integer  "t",                   :default => 1,   :null => false\r
-    t.integer  "author_id"\r
+    t.integer  "x"\r
+    t.integer  "y"\r
+    t.integer  "z"\r
+    t.integer  "t",                                    :null => false\r
+    t.integer  "author_id",                            :null => false\r
     t.datetime "created_at"\r
     t.datetime "updated_at"\r
   end\r
@@ -216,12 +215,12 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
     t.datetime "updated_at"\r
   end\r
 \r
-  create_table "speach_balloon_templates", :force => true do |t|\r
+  create_table "speech_balloon_templates", :force => true do |t|\r
     t.datetime "created_at"\r
     t.datetime "updated_at"\r
   end\r
 \r
-  create_table "speach_balloons", :force => true do |t|\r
+  create_table "speech_balloons", :force => true do |t|\r
     t.string   "name",                      :null => false\r
     t.integer  "tail_count", :default => 1, :null => false\r
     t.integer  "size_count", :default => 1, :null => false\r
@@ -230,9 +229,9 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
     t.datetime "updated_at"\r
   end\r
 \r
-  add_index "speach_balloons", ["t"], :name => "speach_balloons_t", :unique => true\r
+  add_index "speech_balloons", ["t"], :name => "speech_balloons_t", :unique => true\r
 \r
-  create_table "speach_templates", :force => true do |t|\r
+  create_table "speech_templates", :force => true do |t|\r
     t.integer  "balloon_template_id",                :null => false\r
     t.integer  "x",                                  :null => false\r
     t.integer  "y",                                  :null => false\r
@@ -243,11 +242,11 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
     t.datetime "updated_at"\r
   end\r
 \r
-  add_index "speach_templates", ["balloon_template_id", "t"], :name => "speach_templates_idt", :unique => true\r
+  add_index "speech_templates", ["balloon_template_id", "t"], :name => "speech_templates_idt", :unique => true\r
 \r
-  create_table "speaches", :force => true do |t|\r
+  create_table "speeches", :force => true do |t|\r
     t.integer  "balloon_id",                        :null => false\r
-    t.integer  "speach_template_id",                :null => false\r
+    t.integer  "speech_template_id",                :null => false\r
     t.string   "content"\r
     t.integer  "x",                                 :null => false\r
     t.integer  "y",                                 :null => false\r
@@ -258,8 +257,8 @@ ActiveRecord::Schema.define(:version => 20120424100555) do
     t.datetime "updated_at"\r
   end\r
 \r
-  add_index "speaches", ["balloon_id", "t"], :name => "speaches_bt", :unique => true\r
-  add_index "speaches", ["balloon_id"], :name => "index_speaches_on_balloon_id"\r
+  add_index "speeches", ["balloon_id", "t"], :name => "speeches_bt", :unique => true\r
+  add_index "speeches", ["balloon_id"], :name => "index_speeches_on_balloon_id"\r
 \r
   create_table "system_pictures", :force => true do |t|\r
     t.string   "ext",        :null => false\r
index 930a3e5..87fb414 100644 (file)
@@ -3,5 +3,5 @@
 require 'spec_helper'
 
 describe BalloonTemplatesController do
-  #データはすべてSpeachBalloonsControllerから管理するので、ここから何かを要求することはない。 
+  #データはすべてSpeechBalloonsControllerから管理するので、ここから何かを要求することはない。 
 end
diff --git a/spec/controllers/speach_balloon_templates_controller_spec.rb b/spec/controllers/speach_balloon_templates_controller_spec.rb
deleted file mode 100644 (file)
index 96aac18..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-require 'spec_helper'
-
-# This spec was generated by rspec-rails when you ran the scaffold generator.
-# It demonstrates how one might use RSpec to specify the controller code that
-# was generated by Rails when you ran the scaffold generator.
-#
-# It assumes that the implementation code is generated by the rails scaffold
-# generator.  If you are using any extension libraries to generate different
-# controller code, this generated spec may or may not pass.
-#
-# It only uses APIs available in rails and/or rspec-rails.  There are a number
-# of tools you can use to make these specs even more expressive, but we're
-# sticking to rails and rspec-rails APIs to keep things simple and stable.
-#
-# Compared to earlier versions of this generator, there is very limited use of
-# stubs and message expectations in this spec.  Stubs are only used when there
-# is no simpler way to get a handle on the object needed for the example.
-# Message expectations are only used when there is no simpler way to specify
-# that an instance is receiving a specific message.
-
-describe SpeachBalloonTemplatesController do
-
-  # This should return the minimal set of attributes required to create a valid
-  # SpeachBalloonTemplate. As you add validations to SpeachBalloonTemplate, be sure to
-  # update the return value of this method accordingly.
-  def valid_attributes
-    {}
-  end
-
-  describe "GET index" do
-    it "assigns all speach_balloon_templates as @speach_balloon_templates" do
-      speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-      get :index
-      assigns(:speach_balloon_templates).should eq([speach_balloon_template])
-    end
-  end
-
-  describe "GET show" do
-    it "assigns the requested speach_balloon_template as @speach_balloon_template" do
-      speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-      get :show, :id => speach_balloon_template.id
-      assigns(:speach_balloon_template).should eq(speach_balloon_template)
-    end
-  end
-
-  describe "GET new" do
-    it "assigns a new speach_balloon_template as @speach_balloon_template" do
-      get :new
-      assigns(:speach_balloon_template).should be_a_new(SpeachBalloonTemplate)
-    end
-  end
-
-  describe "GET edit" do
-    it "assigns the requested speach_balloon_template as @speach_balloon_template" do
-      speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-      get :edit, :id => speach_balloon_template.id
-      assigns(:speach_balloon_template).should eq(speach_balloon_template)
-    end
-  end
-
-  describe "POST create" do
-    describe "with valid params" do
-      it "creates a new SpeachBalloonTemplate" do
-        expect {
-          post :create, :speach_balloon_template => valid_attributes
-        }.to change(SpeachBalloonTemplate, :count).by(1)
-      end
-
-      it "assigns a newly created speach_balloon_template as @speach_balloon_template" do
-        post :create, :speach_balloon_template => valid_attributes
-        assigns(:speach_balloon_template).should be_a(SpeachBalloonTemplate)
-        assigns(:speach_balloon_template).should be_persisted
-      end
-
-      it "redirects to the created speach_balloon_template" do
-        post :create, :speach_balloon_template => valid_attributes
-        response.should redirect_to(SpeachBalloonTemplate.last)
-      end
-    end
-
-    describe "with invalid params" do
-      it "assigns a newly created but unsaved speach_balloon_template as @speach_balloon_template" do
-        # Trigger the behavior that occurs when invalid params are submitted
-        SpeachBalloonTemplate.any_instance.stub(:save).and_return(false)
-        post :create, :speach_balloon_template => {}
-        assigns(:speach_balloon_template).should be_a_new(SpeachBalloonTemplate)
-      end
-
-      it "re-renders the 'new' template" do
-        # Trigger the behavior that occurs when invalid params are submitted
-        SpeachBalloonTemplate.any_instance.stub(:save).and_return(false)
-        post :create, :speach_balloon_template => {}
-        response.should render_template("new")
-      end
-    end
-  end
-
-  describe "PUT update" do
-    describe "with valid params" do
-      it "updates the requested speach_balloon_template" do
-        speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-        # Assuming there are no other speach_balloon_templates in the database, this
-        # specifies that the SpeachBalloonTemplate created on the previous line
-        # receives the :update_attributes message with whatever params are
-        # submitted in the request.
-        SpeachBalloonTemplate.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
-        put :update, :id => speach_balloon_template.id, :speach_balloon_template => {'these' => 'params'}
-      end
-
-      it "assigns the requested speach_balloon_template as @speach_balloon_template" do
-        speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-        put :update, :id => speach_balloon_template.id, :speach_balloon_template => valid_attributes
-        assigns(:speach_balloon_template).should eq(speach_balloon_template)
-      end
-
-      it "redirects to the speach_balloon_template" do
-        speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-        put :update, :id => speach_balloon_template.id, :speach_balloon_template => valid_attributes
-        response.should redirect_to(speach_balloon_template)
-      end
-    end
-
-    describe "with invalid params" do
-      it "assigns the speach_balloon_template as @speach_balloon_template" do
-        speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-        # Trigger the behavior that occurs when invalid params are submitted
-        SpeachBalloonTemplate.any_instance.stub(:save).and_return(false)
-        put :update, :id => speach_balloon_template.id, :speach_balloon_template => {}
-        assigns(:speach_balloon_template).should eq(speach_balloon_template)
-      end
-
-      it "re-renders the 'edit' template" do
-        speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-        # Trigger the behavior that occurs when invalid params are submitted
-        SpeachBalloonTemplate.any_instance.stub(:save).and_return(false)
-        put :update, :id => speach_balloon_template.id, :speach_balloon_template => {}
-        response.should render_template("edit")
-      end
-    end
-  end
-
-  describe "DELETE destroy" do
-    it "destroys the requested speach_balloon_template" do
-      speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-      expect {
-        delete :destroy, :id => speach_balloon_template.id
-      }.to change(SpeachBalloonTemplate, :count).by(-1)
-    end
-
-    it "redirects to the speach_balloon_templates list" do
-      speach_balloon_template = SpeachBalloonTemplate.create! valid_attributes
-      delete :destroy, :id => speach_balloon_template.id
-      response.should redirect_to(speach_balloon_templates_url)
-    end
-  end
-
-end
diff --git a/spec/controllers/speach_balloons_controller_spec.rb b/spec/controllers/speach_balloons_controller_spec.rb
deleted file mode 100644 (file)
index 613161d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# -*- encoding: utf-8 -*-
-#フキダシ
-require 'spec_helper'
-describe SpeachBalloonsController do
-  describe "GET index" do
-    it "assigns all speach_baloons as @speach_baloons" do
-      speach_baloon = SpeachBaloon.create! valid_attributes
-      get :index
-      assigns(:speach_baloons).should eq([speach_baloon])
-    end
-  end
-end
diff --git a/spec/controllers/speaches_controller_spec.rb b/spec/controllers/speaches_controller_spec.rb
deleted file mode 100644 (file)
index 2d07acc..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- encoding: utf-8 -*-
-#セリフ
-require 'spec_helper'
-
-describe SpeachesController do
-
-  describe "GET index" do
-    it "assigns all speaches as @speaches" do
-      speach = Speach.create! valid_attributes
-      get :index
-      assigns(:speaches).should eq([speach])
-    end
-  end
-end
diff --git a/spec/controllers/speech_balloon_templates_controller_spec.rb b/spec/controllers/speech_balloon_templates_controller_spec.rb
new file mode 100644 (file)
index 0000000..153f490
--- /dev/null
@@ -0,0 +1,157 @@
+require 'spec_helper'
+
+# This spec was generated by rspec-rails when you ran the scaffold generator.
+# It demonstrates how one might use RSpec to specify the controller code that
+# was generated by Rails when you ran the scaffold generator.
+#
+# It assumes that the implementation code is generated by the rails scaffold
+# generator.  If you are using any extension libraries to generate different
+# controller code, this generated spec may or may not pass.
+#
+# It only uses APIs available in rails and/or rspec-rails.  There are a number
+# of tools you can use to make these specs even more expressive, but we're
+# sticking to rails and rspec-rails APIs to keep things simple and stable.
+#
+# Compared to earlier versions of this generator, there is very limited use of
+# stubs and message expectations in this spec.  Stubs are only used when there
+# is no simpler way to get a handle on the object needed for the example.
+# Message expectations are only used when there is no simpler way to specify
+# that an instance is receiving a specific message.
+
+describe SpeechBalloonTemplatesController do
+
+  # This should return the minimal set of attributes required to create a valid
+  # SpeechBalloonTemplate. As you add validations to SpeechBalloonTemplate, be sure to
+  # update the return value of this method accordingly.
+  def valid_attributes
+    {}
+  end
+
+  describe "GET index" do
+    it "assigns all speech_balloon_templates as @speech_balloon_templates" do
+      speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+      get :index
+      assigns(:speech_balloon_templates).should eq([speech_balloon_template])
+    end
+  end
+
+  describe "GET show" do
+    it "assigns the requested speech_balloon_template as @speech_balloon_template" do
+      speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+      get :show, :id => speech_balloon_template.id
+      assigns(:speech_balloon_template).should eq(speech_balloon_template)
+    end
+  end
+
+  describe "GET new" do
+    it "assigns a new speech_balloon_template as @speech_balloon_template" do
+      get :new
+      assigns(:speech_balloon_template).should be_a_new(SpeechBalloonTemplate)
+    end
+  end
+
+  describe "GET edit" do
+    it "assigns the requested speech_balloon_template as @speech_balloon_template" do
+      speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+      get :edit, :id => speech_balloon_template.id
+      assigns(:speech_balloon_template).should eq(speech_balloon_template)
+    end
+  end
+
+  describe "POST create" do
+    describe "with valid params" do
+      it "creates a new SpeechBalloonTemplate" do
+        expect {
+          post :create, :speech_balloon_template => valid_attributes
+        }.to change(SpeechBalloonTemplate, :count).by(1)
+      end
+
+      it "assigns a newly created speech_balloon_template as @speech_balloon_template" do
+        post :create, :speech_balloon_template => valid_attributes
+        assigns(:speech_balloon_template).should be_a(SpeechBalloonTemplate)
+        assigns(:speech_balloon_template).should be_persisted
+      end
+
+      it "redirects to the created speech_balloon_template" do
+        post :create, :speech_balloon_template => valid_attributes
+        response.should redirect_to(SpeechBalloonTemplate.last)
+      end
+    end
+
+    describe "with invalid params" do
+      it "assigns a newly created but unsaved speech_balloon_template as @speech_balloon_template" do
+        # Trigger the behavior that occurs when invalid params are submitted
+        SpeechBalloonTemplate.any_instance.stub(:save).and_return(false)
+        post :create, :speech_balloon_template => {}
+        assigns(:speech_balloon_template).should be_a_new(SpeechBalloonTemplate)
+      end
+
+      it "re-renders the 'new' template" do
+        # Trigger the behavior that occurs when invalid params are submitted
+        SpeechBalloonTemplate.any_instance.stub(:save).and_return(false)
+        post :create, :speech_balloon_template => {}
+        response.should render_template("new")
+      end
+    end
+  end
+
+  describe "PUT update" do
+    describe "with valid params" do
+      it "updates the requested speech_balloon_template" do
+        speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+        # Assuming there are no other speech_balloon_templates in the database, this
+        # specifies that the SpeechBalloonTemplate created on the previous line
+        # receives the :update_attributes message with whatever params are
+        # submitted in the request.
+        SpeechBalloonTemplate.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
+        put :update, :id => speech_balloon_template.id, :speech_balloon_template => {'these' => 'params'}
+      end
+
+      it "assigns the requested speech_balloon_template as @speech_balloon_template" do
+        speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+        put :update, :id => speech_balloon_template.id, :speech_balloon_template => valid_attributes
+        assigns(:speech_balloon_template).should eq(speech_balloon_template)
+      end
+
+      it "redirects to the speech_balloon_template" do
+        speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+        put :update, :id => speech_balloon_template.id, :speech_balloon_template => valid_attributes
+        response.should redirect_to(speech_balloon_template)
+      end
+    end
+
+    describe "with invalid params" do
+      it "assigns the speech_balloon_template as @speech_balloon_template" do
+        speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+        # Trigger the behavior that occurs when invalid params are submitted
+        SpeechBalloonTemplate.any_instance.stub(:save).and_return(false)
+        put :update, :id => speech_balloon_template.id, :speech_balloon_template => {}
+        assigns(:speech_balloon_template).should eq(speech_balloon_template)
+      end
+
+      it "re-renders the 'edit' template" do
+        speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+        # Trigger the behavior that occurs when invalid params are submitted
+        SpeechBalloonTemplate.any_instance.stub(:save).and_return(false)
+        put :update, :id => speech_balloon_template.id, :speech_balloon_template => {}
+        response.should render_template("edit")
+      end
+    end
+  end
+
+  describe "DELETE destroy" do
+    it "destroys the requested speech_balloon_template" do
+      speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+      expect {
+        delete :destroy, :id => speech_balloon_template.id
+      }.to change(SpeechBalloonTemplate, :count).by(-1)
+    end
+
+    it "redirects to the speech_balloon_templates list" do
+      speech_balloon_template = SpeechBalloonTemplate.create! valid_attributes
+      delete :destroy, :id => speech_balloon_template.id
+      response.should redirect_to(speech_balloon_templates_url)
+    end
+  end
+
+end
diff --git a/spec/controllers/speech_balloons_controller_spec.rb b/spec/controllers/speech_balloons_controller_spec.rb
new file mode 100644 (file)
index 0000000..db5a09d
--- /dev/null
@@ -0,0 +1,12 @@
+# -*- encoding: utf-8 -*-
+#フキダシ
+require 'spec_helper'
+describe SpeechBalloonsController do
+  describe "GET index" do
+    it "assigns all speech_baloons as @speech_baloons" do
+      speech_baloon = SpeechBaloon.create! valid_attributes
+      get :index
+      assigns(:speech_baloons).should eq([speech_baloon])
+    end
+  end
+end
@@ -2,6 +2,6 @@
 #セリフテンプレート
 require 'spec_helper'
 
-describe SpeachTemplatesController do
-  #データはすべてSpeachBalloonsControllerから管理するので、ここから何かを要求することはない。 
+describe SpeechTemplatesController do
+  #データはすべてSpeechBalloonsControllerから管理するので、ここから何かを要求することはない。 
 end
diff --git a/spec/controllers/speeches_controller_spec.rb b/spec/controllers/speeches_controller_spec.rb
new file mode 100644 (file)
index 0000000..8b6000c
--- /dev/null
@@ -0,0 +1,14 @@
+# -*- encoding: utf-8 -*-
+#セリフ
+require 'spec_helper'
+
+describe SpeechesController do
+
+  describe "GET index" do
+    it "assigns all speeches as @speeches" do
+      speech = Speech.create! valid_attributes
+      get :index
+      assigns(:speeches).should eq([speech])
+    end
+  end
+end
index ee5ac25..6cb4f0a 100644 (file)
@@ -157,15 +157,15 @@ Factory.define :balloon, :class => Balloon do |balloon|
   balloon.height 333 
 end
 
-Factory.define :speach, :class => Speach do |speach|
-  speach.balloon_id 1
-  speach.speach_template_id 1
-  speach.content 'test'
-  speach.x 10
-  speach.y 100
-  speach.t 0
-  speach.width 200
-  speach.height 190
+Factory.define :speech, :class => Speech do |speech|
+  speech.balloon_id 1
+  speech.speech_template_id 1
+  speech.content 'test'
+  speech.x 10
+  speech.y 100
+  speech.t 0
+  speech.width 200
+  speech.height 190
 end
 
 Factory.define :panel_picture, :class => PanelPicture do |pp|
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
 # Specs in this file have access to a helper object that includes
-# the SpeachBalloonTemplatesHelper. For example:
+# the SpeechBalloonTemplatesHelper. For example:
 #
-# describe SpeachBalloonTemplatesHelper do
+# describe SpeechBalloonTemplatesHelper do
 #   describe "string concat" do
 #     it "concats two strings with spaces" do
 #       helper.concat_strings("this","that").should == "this that"
 #     end
 #   end
 # end
-describe SpeachBalloonTemplatesHelper do
+describe SpeechBalloonTemplatesHelper do
   pending "add some examples to (or delete) #{__FILE__}"
 end
similarity index 75%
rename from spec/helpers/speach_balloons_helper_spec.rb
rename to spec/helpers/speech_balloons_helper_spec.rb
index 14766e1..041cfcf 100644 (file)
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
 # Specs in this file have access to a helper object that includes
-# the SpeachBaloonsHelper. For example:
+# the SpeechBaloonsHelper. For example:
 #
-# describe SpeachBaloonsHelper do
+# describe SpeechBaloonsHelper do
 #   describe "string concat" do
 #     it "concats two strings with spaces" do
 #       helper.concat_strings("this","that").should == "this that"
 #     end
 #   end
 # end
-describe SpeachBalloonsHelper do
+describe SpeechBalloonsHelper do
   pending "add some examples to (or delete) #{__FILE__}"
 end
similarity index 74%
rename from spec/helpers/speach_templates_helper_spec.rb
rename to spec/helpers/speech_templates_helper_spec.rb
index 143e65e..242f9bd 100644 (file)
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
 # Specs in this file have access to a helper object that includes
-# the SpeachTemplatesHelper. For example:
+# the SpeechTemplatesHelper. For example:
 #
-# describe SpeachTemplatesHelper do
+# describe SpeechTemplatesHelper do
 #   describe "string concat" do
 #     it "concats two strings with spaces" do
 #       helper.concat_strings("this","that").should == "this that"
 #     end
 #   end
 # end
-describe SpeachTemplatesHelper do
+describe SpeechTemplatesHelper do
   pending "add some examples to (or delete) #{__FILE__}"
 end
similarity index 77%
rename from spec/helpers/speaches_helper_spec.rb
rename to spec/helpers/speeches_helper_spec.rb
index 6a4a364..0de28b6 100644 (file)
@@ -1,15 +1,15 @@
 require 'spec_helper'
 
 # Specs in this file have access to a helper object that includes
-# the SpeachesHelper. For example:
+# the SpeechesHelper. For example:
 #
-# describe SpeachesHelper do
+# describe SpeechesHelper do
 #   describe "string concat" do
 #     it "concats two strings with spaces" do
 #       helper.concat_strings("this","that").should == "this that"
 #     end
 #   end
 # end
-describe SpeachesHelper do
+describe SpeechesHelper do
   pending "add some examples to (or delete) #{__FILE__}"
 end
index 86d775e..2b07d60 100644 (file)
@@ -450,7 +450,7 @@ describe Panel do
       end
         it 'フキダシはセリフを含んでいる' do
           r = Panel.show_include_opt
-          r[:balloons].has_key?(:speaches).should be_true\r
+          r[:balloons].has_key?(:speeches).should be_true\r
         end
       it '作家を含んでいる' do
         r = Panel.show_include_opt
@@ -503,7 +503,7 @@ describe Panel do
     end
       it 'フキダシはセリフを含んでいる' do
         r = Panel.show_json_include_opt[:include]
-        r[:balloons].has_key?(:speaches).should be_true\r
+        r[:balloons].has_key?(:speeches).should be_true\r
       end
     it '作家を含んでいる' do
       r = Panel.show_json_include_opt[:include]
@@ -611,7 +611,7 @@ describe Panel do
     end
       it 'フキダシはセリフを含んでいる' do
         r = Panel.list_opt[:include]
-        r[:balloons].has_key?(:speaches).should be_true\r
+        r[:balloons].has_key?(:speeches).should be_true\r
       end
     it '作家を含んでいる' do
       r = Panel.list_opt[:include]
@@ -653,7 +653,7 @@ describe Panel do
     end
       it 'フキダシはセリフを含んでいる' do
         r = Panel.list_json_opt[:include]
-        r[:balloons].has_key?(:speaches).should be_true\r
+        r[:balloons].has_key?(:speeches).should be_true\r
       end
     it '作家を含んでいる' do
       r = Panel.list_json_opt[:include]
similarity index 76%
rename from spec/models/speach_balloon_spec.rb
rename to spec/models/speech_balloon_spec.rb
index b8a9b9a..da0a1d8 100644 (file)
@@ -1,5 +1,5 @@
 require 'spec_helper'
 
-describe SpeachBalloon do
+describe SpeechBalloon do
   pending "add some examples to (or delete) #{__FILE__}"
 end
similarity index 71%
rename from spec/models/speach_balloon_template_spec.rb
rename to spec/models/speech_balloon_template_spec.rb
index c37394b..1445421 100644 (file)
@@ -1,5 +1,5 @@
 require 'spec_helper'
 
-describe SpeachBalloonTemplate do
+describe SpeechBalloonTemplate do
   pending "add some examples to (or delete) #{__FILE__}"
 end
similarity index 53%
rename from spec/models/speach_spec.rb
rename to spec/models/speech_spec.rb
index 660be6d..1f34f00 100644 (file)
@@ -1,7 +1,7 @@
 # -*- encoding: utf-8 -*-\r
 require 'spec_helper'
 
-describe Speach do
+describe Speech do
   before do
     Factory :admin
     @license = Factory :license
@@ -16,246 +16,246 @@ describe Speach do
   
   describe '検証に於いて' do
     before do
-      @st = Factory :speach_template\r
+      @st = Factory :speech_template\r
       @comic = Factory :comic, :author_id => @author.id
       @panel = Factory :panel, :author_id => @author.id, :comic_id => @comic.id
       @balloon = Factory :balloon, :panel_id => @panel.id, :t => 0
-      @speach = Factory.build :speach, :balloon => @balloon.id, :t => 0
+      @speech = Factory.build :speech, :balloon => @balloon.id, :t => 0
     end
     
     it 'オーソドックスなデータなら通る' do
-      @speach.should be_valid
+      @speech.should be_valid
     end
     
     context 'balloon_idを検証するとき' do
       before do
       end
       it 'テストデータの確認' do
-        @speach.comic_id = @comic.id
-        @speach.should be_valid
+        @speech.comic_id = @comic.id
+        @speech.should be_valid
       end
       it 'nullなら失敗する' do
-        @speach.comic_id = nil
-        @speach.should_not be_valid
+        @speech.comic_id = nil
+        @speech.should_not be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.comic_id = 'a'
-        @speach.should_not be_valid
+        @speech.comic_id = 'a'
+        @speech.should_not be_valid
       end
       it '存在するコミックでなければ失敗する' do
-        @speach.comic_id = 0
-        @speach.should_not be_valid
+        @speech.comic_id = 0
+        @speech.should_not be_valid
       end
       it 'コミックidとtが重複していると失敗する' do
-        @speach.save\r
-        @speach2 = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
-        @speach2.should_not be_valid
+        @speech.save\r
+        @speech2 = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech2.should_not be_valid
       end
     end
     context 'resource_picture_idを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.resource_picture_id = 1
-        @speach.should be_valid
+        @speech.resource_picture_id = 1
+        @speech.should be_valid
       end
       it 'nullなら通る' do
-        @speach.resource_picture_id = nil
-        @speach.should be_valid
+        @speech.resource_picture_id = nil
+        @speech.should be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.resource_picture_id = 'a'
-        @speach.should_not be_valid
+        @speech.resource_picture_id = 'a'
+        @speech.should_not be_valid
       end
       it '存在する素材でなければ失敗する' do
-        @speach.resource_picture_id = 0
-        @speach.should_not be_valid
+        @speech.resource_picture_id = 0
+        @speech.should_not be_valid
       end
     end
     context 'widthを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.width = 1
-        @speach.should be_valid
+        @speech.width = 1
+        @speech.should be_valid
       end
       it 'nullなら失敗する' do
-        @speach.width = nil
-        @speach.should_not be_valid
+        @speech.width = nil
+        @speech.should_not be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.width = 'a'
-        @speach.should_not be_valid
+        @speech.width = 'a'
+        @speech.should_not be_valid
       end
       it '0なら失敗する' do
-        @speach.width = '0'
-        @speach.should_not be_valid
+        @speech.width = '0'
+        @speech.should_not be_valid
       end
       it '負でも失敗する' do
-        @speach.width = -1
-        @speach.should_not be_valid
+        @speech.width = -1
+        @speech.should_not be_valid
       end
     end
     context 'heightを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.height = '1'
-        @speach.should be_valid
+        @speech.height = '1'
+        @speech.should be_valid
       end
       it 'nullなら失敗する' do
-        @speach.height = nil
-        @speach.should_not be_valid
+        @speech.height = nil
+        @speech.should_not be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.height = 'a'
-        @speach.should_not be_valid
+        @speech.height = 'a'
+        @speech.should_not be_valid
       end
       it '0なら失敗する' do
-        @speach.height = '0'
-        @speach.should_not be_valid
+        @speech.height = '0'
+        @speech.should_not be_valid
       end
       it '負でも失敗する' do
-        @speach.height = -1
-        @speach.should_not be_valid
+        @speech.height = -1
+        @speech.should_not be_valid
       end
     end
     context 'borderを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.border = '1'
-        @speach.should be_valid
+        @speech.border = '1'
+        @speech.should be_valid
       end
       it 'nullなら失敗する' do
-        @speach.border = nil
-        @speach.should_not be_valid
+        @speech.border = nil
+        @speech.should_not be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.border = 'a'
-        @speach.should_not be_valid
+        @speech.border = 'a'
+        @speech.should_not be_valid
       end
       it '負なら失敗する' do
-        @speach.border = '-1'
-        @speach.should_not be_valid
+        @speech.border = '-1'
+        @speech.should_not be_valid
       end
       it '0なら通る' do
-        @speach.border = 0
-        @speach.should be_valid
+        @speech.border = 0
+        @speech.should be_valid
       end
     end
     context 'xを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.x = '1'
-        @speach.should be_valid
+        @speech.x = '1'
+        @speech.should be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.x = 'a'
-        @speach.should_not be_valid
+        @speech.x = 'a'
+        @speech.should_not be_valid
       end
       it '0なら通る' do
-        @speach.x = '0'
-        @speach.should be_valid
+        @speech.x = '0'
+        @speech.should be_valid
       end
       it '負でも通る' do
-        @speach.x = -1
-        @speach.should be_valid
+        @speech.x = -1
+        @speech.should be_valid
       end
     end
     context 'yを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.y = '1'
-        @speach.should be_valid
+        @speech.y = '1'
+        @speech.should be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.y = 'a'
-        @speach.should_not be_valid
+        @speech.y = 'a'
+        @speech.should_not be_valid
       end
       it '0なら通る' do
-        @speach.y = '0'
-        @speach.should be_valid
+        @speech.y = '0'
+        @speech.should be_valid
       end
       it '負でも通る' do
-        @speach.y = -1
-        @speach.should be_valid
+        @speech.y = -1
+        @speech.should be_valid
       end
     end
     context 'zを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.z = '1'
-        @speach.should be_valid
+        @speech.z = '1'
+        @speech.should be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.z = 'a'
-        @speach.should_not be_valid
+        @speech.z = 'a'
+        @speech.should_not be_valid
       end
       it '0なら失敗する' do
-        @speach.z = '0'
-        @speach.should_not be_valid
+        @speech.z = '0'
+        @speech.should_not be_valid
       end
       it '負なら失敗する' do
-        @speach.z = -1
-        @speach.should_not be_valid
+        @speech.z = -1
+        @speech.should_not be_valid
       end
     end
     context 'tを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.t = '1'
-        @speach.should be_valid
+        @speech.t = '1'
+        @speech.should be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.t = 'a'
-        @speach.should_not be_valid
+        @speech.t = 'a'
+        @speech.should_not be_valid
       end
       it '0なら通る' do
-        @speach.t = '0'
-        @speach.should be_valid
+        @speech.t = '0'
+        @speech.should be_valid
       end
       it '負でも失敗する' do
-        @speach.t = -1
-        @speach.should_not be_valid
+        @speech.t = -1
+        @speech.should_not be_valid
       end
     end
     context 'author_idを検証するとき' do
       before do
-        @speach = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
       end
       it 'テストデータの確認' do
-        @speach.author_id = @author.id
-        @speach.should be_valid
+        @speech.author_id = @author.id
+        @speech.should be_valid
       end
       it 'nullなら失敗する' do
-        @speach.author_id = nil
-        @speach.should_not be_valid
+        @speech.author_id = nil
+        @speech.should_not be_valid
       end
       it '数値でなければ失敗する' do
-        @speach.author_id = 'a'
-        @speach.should_not be_valid
+        @speech.author_id = 'a'
+        @speech.should_not be_valid
       end
       it '存在する絵師でなければ失敗する' do
-        @speach.author_id = 0
-        @speach.should_not be_valid
+        @speech.author_id = 0
+        @speech.should_not be_valid
       end
     end
     context '全体を検証するとき' do
       before do
-        @speach = Factory :panel, :author_id => @author.id, :comic_id => @comic.id
+        @speech = Factory :panel, :author_id => @author.id, :comic_id => @comic.id
       end
     end
   end
similarity index 75%
rename from spec/models/speach_template_spec.rb
rename to spec/models/speech_template_spec.rb
index 31d8b20..d447a0f 100644 (file)
@@ -1,5 +1,5 @@
 require 'spec_helper'
 
-describe SpeachTemplate do
+describe SpeechTemplate do
   pending "add some examples to (or delete) #{__FILE__}"
 end