'use strict'; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { ts.init = false; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var act; (function (act_1) { /** * ... * @author ferior */ var ActObj = /** @class */ (function () { function ActObj() { var _this = this; //public x0: number; //public y0: number; //public w0: number; //public h0: number; //public a0: number; //public r0: number; //public z0: number; //public rx0: number; //public ry0: number; //public rz0: number; this.x = { vector: 0 }; this.y = { vector: 0 }; this.w = { vector: 0 }; this.h = { vector: 0 }; this.a = { vector: 0 }; this.r = { vector: 0 }; this.z = { vector: 0 }; this.rx = { vector: 0 }; this.ry = { vector: 0 }; this.rz = { vector: 0 }; this.ps = { vector: 0 }; this.acc = 0; //速度係数 this.method = act_1.ActionMethod.adsorb; this.autoRemove = true; this.SetFrom = function (act) { _this.x.value = act.x.value; _this.x.zero = act.x.value; _this.y.value = act.y.value; _this.y.zero = act.y.zero; _this.w.value = act.w.value; _this.w.zero = act.w.zero; _this.h.value = act.h.value; _this.h.zero = act.h.zero; _this.a.value = act.a.value; _this.a.zero = act.a.zero; _this.r.value = act.r.value; _this.r.zero = act.r.zero; _this.z.value = act.z.value; _this.z.zero = act.z.zero; _this.rx.value = act.rx.value; _this.rx.zero = act.rx.zero; _this.ry.value = act.ry.value; _this.ry.zero = act.ry.zero; _this.rz.value = act.rz.value; _this.rz.zero = act.rz.zero; _this.ps.value = act.ps.value; _this.ps.zero = act.ps.zero; //this.x0 = this.x; //this.y0 = this.y; //this.w0 = this.w; //this.h0 = this.h; //this.r0 = this.r; //this.z0 = this.z; //this.rx0 = this.rx; //this.ry0 = this.ry; //this.rz0 = this.rz; }; if (ActObj.cnt !== 0) throw "ActObjはgetActObjにて取得してください。"; } ActObj.actPool = []; ActObj.cnt = 0; ActObj.getActObj = function () { var actObj; if (ActObj.cnt === 0) actObj = new ActObj(); else { actObj = ActObj.actPool.pop(); ActObj.cnt--; } return actObj; }; ActObj.AddChash = function (count) { for (var i = 0; i < count; i++) ActObj.actPool[i] = new ActObj(); ActObj.cnt = count; }; ActObj.removeActObj = function (actObj) { ActObj.cnt = ActObj.actPool.push(actObj); }; return ActObj; }()); act_1.ActObj = ActObj; var ActionElement = /** @class */ (function () { function ActionElement(element) { var _this = this; this.x = 0; this.y = 0; this.w = 0; this.h = 0; this.a = 0; this.r = 0; this.z = 0; this.rx = 0; this.ry = 0; this.rz = 0; this.wo = 0; this.ho = 0; this.perspective = 0; this.translateCredit = 'px'; this.getX = function () { return _this.x; }; this.getY = function () { return _this.y; }; this.getW = function () { return _this.w; }; this.getH = function () { return _this.h; }; this.getA = function () { return _this.a; }; this.getR = function () { return _this.r; }; this.getZ = function () { return _this.z; }; this.getRX = function () { return _this.rx; }; this.getRY = function () { return _this.ry; }; this.getRZ = function () { return _this.rz; }; this.getPS = function () { return _this.perspective; }; this.setX = function (value) { _this.x = value; _this.change = true; }; this.setY = function (value) { _this.y = value; _this.change = true; }; this.setW = function (value) { _this.w = value; _this.change = true; }; this.setH = function (value) { _this.h = value; _this.change = true; }; this.setA = function (value) { _this.a = value; _this.change = true; }; this.setR = function (value) { _this.r = value % 360; _this.change = true; }; this.setZ = function (value) { _this.z = value; _this.change = true; }; this.setRX = function (value) { _this.rx = value % 360; _this.change = true; }; this.setRY = function (value) { _this.ry = value % 360; _this.change = true; }; this.setRZ = function (value) { _this.rz = value % 360; _this.change = true; }; this.setPS = function (value) { _this.perspective = value; _this.change = true; }; this._change = false; this._afterNo = 0; this.reflesh = function () { _this.change = false; var style = _this.element.style; //style.left = this.x.toString() + 'px'; //style.top = this.y.toString() + 'px'; //style.width = this.w.toString() + 'px'; //style.height = this.h.toString() + 'px'; style.opacity = (isFinite(_this.a) ? _this.a : '').toString(); var tf = {}; _this.setTransformProp(tf, 'scaleX', _this.w / _this.wo); _this.setTransformProp(tf, 'scaleY', _this.h / _this.ho); _this.setTransformProp(tf, 'translateX', _this.x); _this.setTransformProp(tf, 'translateY', _this.y); _this.setTransformProp(tf, 'translateZ', _this.z); _this.setTransformProp(tf, 'rotate', _this.r); _this.setTransformProp(tf, 'rotateX', _this.rx); _this.setTransformProp(tf, 'rotateY', _this.ry); _this.setTransformProp(tf, 'rotateZ', _this.rz); var transform = "perspective(" + _this.perspective.toString() + "px) "; for (var prop in tf) { transform += prop + '(' + tf[prop] + ') '; } style.transform = transform; }; this.gotoEndPoint = function () { _this.reflesh(); }; this.setTransformProp = function (tf, key, value) { if (!value) { delete (tf[key]); return; } switch (key) { case 'scale': case 'scaleX': case 'scaleY': tf[key] = value.toString(); break; case 'rotate': case 'rotateX': case 'rotateY': case 'rotateZ': tf[key] = value.toString() + 'deg'; break; default: tf[key] = value.toString() + _this.translateCredit; } }; this.element = element; var cssStyle = getComputedStyle(this.element); var rect = this.element.getBoundingClientRect(); this.wo = parseFloat(cssStyle.width.replace('px', '')); this.wo = (isNaN(this.wo)) ? rect.width : this.wo; this.ho = parseFloat(cssStyle.height.replace('px', '')); this.ho = (isNaN(this.ho)) ? rect.height : this.ho; this.w = this.wo; this.h = this.ho; this.a = parseFloat(cssStyle.opacity); this.a = (isNaN(this.a)) ? 1 : this.a; var tf = cssStyle.transform.replace(/ */, '').split(')'); var len = tf.length; var transform = {}; if (tf[0] !== 'none' && tf[0] !== '') { for (var i = 0; i < len; i++) { var key_value = tf[i].split('('); if (!key_value[1]) continue; var values = key_value[1].split(','); var cnt = values.length; var valueNum = []; for (var j = 0; j < cnt; j++) { valueNum[j] = parseInt(values[j]); } transform[key_value[0]] = valueNum; switch (key_value[0]) { case 'scale': this.w = ((valueNum[0]) ? valueNum[0] : 1) * this.wo; this.h = ((valueNum[1]) ? valueNum[1] : 1) * this.ho; break; case 'scaleX': this.w = ((valueNum[0]) ? valueNum[0] : 1) * this.wo; break; case 'scaleY': this.h = ((valueNum[0]) ? valueNum[0] : 1) * this.ho; break; case 'translate': this.x = valueNum[0]; this.y = valueNum[1]; break; case 'translateX': this.x = valueNum[0]; break; case 'translateY': this.y = valueNum[0]; break; case 'translateZ': this.z = valueNum[0]; break; case 'rotate': this.r = valueNum[0]; break; case 'rotateZ': this.rz = valueNum[0]; break; case 'rotateX': this.rx = valueNum[0]; break; case 'rotateY': this.ry = valueNum[0]; break; case 'perspective': this.perspective = valueNum[0]; break; } } } this.tf = transform; } Object.defineProperty(ActionElement.prototype, "change", { get: function () { return this._change; }, set: function (value) { if (this._change === value) return; this._change = value; if (value) { this._afterNo = ts.ActionTimer.GetInstance().AddAfterFunction(this.reflesh); } else { ts.ActionTimer.GetInstance().RemoveAfterFunction(this._afterNo); this._afterNo = 0; } }, enumerable: true, configurable: true }); return ActionElement; }()); act_1.ActionElement = ActionElement; })(act = ts.act || (ts.act = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var ActionTimer = /** @class */ (function () { function ActionTimer() { var _this = this; this.keySec = 0; this.length = 0; this.lastTime = 0; this.startTime = 0; this.lastFrame = -1; this.afterFunc = []; this.start = function () { if (!ActionTimer.useAnimationFrame) { _this.startTime = ActionTimer.getTime(); _this.timerToken = setInterval(_this.OnTickerEventBase, ActionTimer.nmInterval); } else { _this.timerToken = requestAnimationFrame(_this.OnTickerEventBase); } }; this.stop = function () { if (!ActionTimer.useAnimationFrame) { clearTimeout(_this.timerToken); } else { cancelAnimationFrame(_this.timerToken); } _this.timerToken = NaN; }; this.Add = function (key, option) { if (!key.key) { _this.keySec++; key.key = _this.keySec; } if (_this.actionList[key.key]) return; _this.length++; _this.actionList[key.key] = { key: key, opt: option }; if (_this.length === 1) { _this.start(); } }; this.Remove = function (key) { if (!_this.actionList[key.key]) return; _this.length--; delete _this.actionList[key.key]; if (_this.length === 0) { _this.stop(); } }; this.AddAfterFunction = function (func) { return _this.afterFunc.push(func) - 1; }; this.RemoveAfterFunction = function (no) { delete _this.afterFunc[no]; }; this.OnTickerEventBase = function () { if (ActionTimer.useAnimationFrame) { _this.timerToken = requestAnimationFrame(_this.OnTickerEventBase); var lastTime = ActionTimer.getTime(); var diff = lastTime - _this.lastTime; _this.lastTime = lastTime; var frame = ts.MathBit.floor((lastTime - _this.startTime) / ActionTimer.nmInterval); if (frame === _this.lastFrame) { return; } if (frame !== 1) { ActionTimer.lastFrameDeficiency = ts.MathBit.floor(diff / ActionTimer.nmInterval * 100) * 0.01; } else { ActionTimer.lastFrameDeficiency = 0; } _this.lastFrame = frame; if (!_this.timerToken) return; } var len = _this.length; if (len === 0) { _this.stop(); return; } var list = _this.actionList; for (var key in list) { var set = _this.actionList[key]; var aobj = set.key; var option = set.opt; var index = aobj.getTickIndex(); try { if (option) { if (option.pauseCount !== 0) { option.pauseCount -= 1; if (aobj.OnTickerPauseEvent) index = aobj.OnTickerPauseEvent(index, option); if (option.pauseCount > 0) { continue; } } } index = aobj.OnTickerEvent(index, option); } finally { aobj.setTickIndex(index); } } var funcs = _this.afterFunc; for (var no in funcs) { funcs[no](); } funcs.length = 0; }; if (ActionTimer.instance !== undefined) throw new Error('ActionTimerはシングルトンクラスです。'); this.actionList = Object.create(null); } Object.defineProperty(ActionTimer, "UseAnimationFrame", { get: function () { return ActionTimer.useAnimationFrame; }, set: function (value) { if (ActionTimer.instance !== undefined) throw new Error('ActionTimerのインターバルはActionTimerを使用する前に設定してください。'); if (ActionTimer.useAnimationFrame === value) return; if (value && !requestAnimationFrame) return; ActionTimer.useAnimationFrame = value; if (value) { window.console.log('==== USE ANIMATION FRAME FOR NINESENSE ACTION TIMER ===='); } }, enumerable: true, configurable: true }); Object.defineProperty(ActionTimer, "Interval", { get: function () { return ActionTimer.nmInterval; }, set: function (value) { if (ActionTimer.instance !== undefined) throw new Error('ActionTimerのインターバルはActionTimerを使用する前に設定してください。'); ActionTimer.nmInterval = value; }, enumerable: true, configurable: true }); ActionTimer.nmInterval = 1000 / 60; ActionTimer.useAnimationFrame = false; ActionTimer.nowFunc = (window.performance && (performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow)) || new Date().getTime; ActionTimer.getTime = function () { return ActionTimer.nowFunc.call(performance); }; ActionTimer.GetInstance = function () { if (ActionTimer.instance === undefined) { ActionTimer.instance = new ActionTimer(); } return ActionTimer.instance; }; ActionTimer.lastFrameDeficiency = 0; return ActionTimer; }()); ts.ActionTimer = ActionTimer; var ActionObj = /** @class */ (function () { function ActionObj(ticker) { var _this = this; this.index = 0; this.getTickIndex = function () { return _this.index; }; this.setTickIndex = function (value) { if (_this.index === value) return; _this.index = value; if (value !== 0) { ActionTimer.GetInstance().Add(_this, _this.option); } else { ActionTimer.GetInstance().Remove(_this); } }; this.actionFromTo = function (from, to) { var index = _this.getTickIndex(); if (index === from) { _this.setTickIndex(to); return true; } return false; }; this.stopTo = function (to) { var index = _this.getTickIndex(); if (index === 0) { _this.setTickIndex(to); return true; } return false; }; this.OnTickerEvent = ticker; } return ActionObj; }()); ts.ActionObj = ActionObj; var ActionObjEx = /** @class */ (function (_super) { __extends(ActionObjEx, _super); function ActionObjEx(ticker) { return _super.call(this, ticker) || this; } return ActionObjEx; }(ActionObj)); ts.ActionObjEx = ActionObjEx; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { /** * ... * @author s.baba */ var MathBit = /** @class */ (function () { function MathBit() { } /**絶対値*/ MathBit.abs = function (value) { return (value ^ (value >> 31)) - (value >> 31); }; MathBit.maxElement = 255; MathBit.nearOne = 0.999999999999999; MathBit.nearOneM = -0.999999999999999; /**0に近い数値へ丸める*/ MathBit.floor = function (value) { return ((value << 1)) >> 1; }; /**0に遠い値へ丸める*/ MathBit.Upper = function (value) { return (((value + ((value >= 0) ? MathBit.nearOne : MathBit.nearOneM)) << 1)) >> 1; }; /**符号の一致*/ MathBit.equalSign = function (value1, value2) { return (value1 ^ value2) >= 0; }; /**符号の一致*/ MathBit.equalSignNum = function (value1, value2) { return (MathBit.Upper(value1) ^ MathBit.Upper(value2)) >= 0; }; /**符号変換*/ MathBit.changeSign = function (value) { return (~value + 1); }; /**偶数判定*/ MathBit.isEven = function (value) { return !(value & 1); }; /**左Bitシフト*/ MathBit.leftShift = function (value, i) { return value << i; //trace( 100 << 1 ) /* 出力 200 100に2の1乗を掛けてる */ //trace( 100 << 2 ) /* 出力 400 100に2の2乗を掛けてる */ //trace( 100 << 3 ) /* 出力 800 100に2の3乗を掛けてる */ //trace( 100 << 4 ) /* 出力 1600 100に2の4乗を掛けてる */ }; /**右Bitシフト*/ MathBit.rightShift = function (value, i) { return value >> i; //trace( 100 >> 1 ) /* 出力 50 100を2の1乗で割る */ //trace( 100 >> 2 ) /* 出力 25 100を2の2乗で割る */ }; MathBit.matchOut = function (value, sep) { return (value & (sep - 1)); //trace( 5 & ( 2 - 1 ) ) /* 出力 1 */ /* 5を2で割ったときの余りは、っていう意味 */ }; MathBit.valueChange = function (a, b) { a ^= b; b ^= a; a ^= b; }; // nMinからnMaxまでのランダムな整数を返す MathBit.randomInt = function (nMin, nMax) { return MathBit.floor(Math.random() * (nMax - nMin + 1)) + nMin; }; /**最大公約数計算*/ MathBit.euclid = function (a, b) { var temp; if (a < b) { temp = a; a = b; b = temp; } if (b < 1) return -1; if (a % b == 0) return b; return MathBit.euclid(b, a % b); }; return MathBit; }()); ts.MathBit = MathBit; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); /// /// var jp; /// /// (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var act; (function (act_2) { var MathBit = jp.ninesense.ts.MathBit; /** * ... * @author ferior */ var ActionMethod; (function (ActionMethod) { ActionMethod[ActionMethod["adsorb"] = 0] = "adsorb"; ActionMethod[ActionMethod["snap"] = 1] = "snap"; })(ActionMethod = act_2.ActionMethod || (act_2.ActionMethod = {})); /** * ... * @author ferior */ var ActionTween = /** @class */ (function () { function ActionTween() { } Object.defineProperty(ActionTween, "active", { get: function () { return ActionTween._active; }, set: function (value) { if (ActionTween._active === value) return; ActionTween._active = value; if (value) ts.ActionTimer.GetInstance().Add(ActionTween.actionObj, {}); else ts.ActionTimer.GetInstance().Remove(ActionTween.actionObj); }, enumerable: true, configurable: true }); ActionTween.list = Object.create(null); ActionTween.activeList = Object.create(null); ActionTween.noSeq = 0; //private static var count:uint = 0; ActionTween.activeCount = 0; ActionTween.rMax = 360; /** * 新規アクションオブジェクトの作成 * @param target アクションさせるオブジェクト * @param acc 1フレームの行動量(0~1) * @param mathod 減速方法 * @return */ ActionTween.Act = function (target, acc, mathod) { if (acc === void 0) { acc = 1; } if (mathod === void 0) { mathod = ActionMethod.adsorb; } var obj = act_2.ActObj.getActObj(); var obj0; var acts; if (target.actionTarget_uniqueKey) { acts = ActionTween.list[target.actionTarget_uniqueKey] || ActionTween.activeList[target.actionTarget_uniqueKey]; } if (!acts) { acts = ActionTween.addNewSet(target); obj0 = act_2.ActObj.getActObj(); acts.act[0] = obj0; //count++; } else obj0 = acts.act[0]; var callSets = target.actionTarget_callsets; for (var nm in callSets) { obj0[nm].value = callSets[nm].get(); obj0[nm].zero = obj0[nm].value; } //obj0.x.value = (("getX" in target) ? target.getX() : NaN) as number; //obj0.y.value = (("getY" in target) ? target.getY() : NaN) as number; //obj0.w.value = (("getW" in target) ? target.getW() : NaN) as number; //obj0.h.value = (("getH" in target) ? target.getH() : NaN) as number; //obj0.a.value = (("getA" in target) ? target.getA() : NaN) as number; //obj0.r.value = (("getR" in target) ? target.getR() : NaN) as number; //obj0.z.value = (("getZ" in target) ? target.getZ() : NaN) as number; //obj0.rx.value = (("getRX" in target) ? target.getRX() : NaN) as number; //obj0.ry.value = (("getRY" in target) ? target.getRY() : NaN) as number; //obj0.rz.value = (("getRZ" in target) ? target.getRZ() : NaN) as number; //obj0.ps.value = (("getPS" in target) ? target.getPS() : NaN) as number; //obj0.x.zero = obj0.x.value; //obj0.y.zero = obj0.y.value; //obj0.w.zero = obj0.w.value; //obj0.h.zero = obj0.h.value; //obj0.a.zero = obj0.a.value; //obj0.r.zero = obj0.r.value; //obj0.z.zero = obj0.z.value; //obj0.rx.zero = obj0.rx.value; //obj0.ry.zero = obj0.ry.value; //obj0.rz.zero = obj0.rz.value; //obj0.ps.zero = obj0.ps.value; obj.acc = acc * ((acc < 0) ? -1 : 1); obj.method = mathod; //obj.SetFrom(acts[acts.length-1]); acts.act.push(obj); return obj; }; /**sorceオブジェクトのアクションキャッシュに対してtargetがシンクロするようにする*/ ActionTween.Sync = function (target, sorce) { var actsSorce = (ActionTween.list[sorce.actionTarget_uniqueKey] || ActionTween.activeList[sorce.actionTarget_uniqueKey]).act; ActionTween.list[target.actionTarget_uniqueKey] = { target: target, act: actsSorce.concat() }; delete ActionTween.activeList[target.actionTarget_uniqueKey]; }; ActionTween.addNewSet = function (target) { if (!target.actionTarget_uniqueKey) { ActionTween.noSeq++; target.actionTarget_uniqueKey = ActionTween.noSeq; target.actionTarget_callsets = {}; if ("getX" in target) { target.actionTarget_callsets['x'] = { get: target.getX, set: target.setX }; } if ("getY" in target) { target.actionTarget_callsets['y'] = { get: target.getY, set: target.setY }; } if ("getZ" in target) { target.actionTarget_callsets['z'] = { get: target.getZ, set: target.setZ }; } if ("getA" in target) { target.actionTarget_callsets['a'] = { get: target.getA, set: target.setA }; } if ("getW" in target) { target.actionTarget_callsets['w'] = { get: target.getW, set: target.setW }; } if ("getH" in target) { target.actionTarget_callsets['h'] = { get: target.getH, set: target.setH }; } if ("getR" in target) { target.actionTarget_callsets['r'] = { get: target.getR, set: target.setR }; } if ("getRX" in target) { target.actionTarget_callsets['rx'] = { get: target.getRX, set: target.setRX }; } if ("getRY" in target) { target.actionTarget_callsets['ry'] = { get: target.getRY, set: target.setRY }; } if ("getRZ" in target) { target.actionTarget_callsets['rz'] = { get: target.getRZ, set: target.setRZ }; } if ("getPS" in target) { target.actionTarget_callsets['ps'] = { get: target.getPS, set: target.setPS }; } } var set = { target: target, act: [] }; ActionTween.list[ActionTween.noSeq] = set; return set; }; /**sorceオブジェクトのアクションをtargetへコピーする*/ ActionTween.Copy = function (target, sorce, acc, method) { if (acc === void 0) { acc = NaN; } if (method === void 0) { method = -1; } var actsSorce = ActionTween.list[sorce.actionTarget_uniqueKey] || ActionTween.activeList[sorce.actionTarget_uniqueKey]; var acts = ActionTween.list[target.actionTarget_uniqueKey] || ActionTween.activeList[target.actionTarget_uniqueKey]; if (!actsSorce) return; if (!acts) { acts = ActionTween.addNewSet(target); } if (!actsSorce) { actsSorce = ActionTween.addNewSet(sorce); } var i = 0; var source = actsSorce.act; var to = acts.act; var len = source.length; var boolAcc = !isNaN(acc); var index = acts.act.length - len; if (index < 0) index = 0; for (i = 0; i < len; i++) { var newAct; if (!(to[index + i])) { newAct = act_2.ActObj.getActObj(); to.push(newAct); } else { newAct = to[index + i]; } var sorceAct = source[i]; newAct.SetFrom(sorceAct); var callSets = target.actionTarget_callsets; for (var nm in callSets) { var nv = newAct[nm]; var sv = sorceAct[nm]; nv.vector = sv.vector; nv.min = sv.min; nv.max = sv.max; } //newAct.x.vector = sorceAct.x.vector; //newAct.y.vector = sorceAct.y.vector; //newAct.w.vector = sorceAct.w.vector; //newAct.h.vector = sorceAct.h.vector; //newAct.a.vector = sorceAct.a.vector; //newAct.r.vector = sorceAct.r.vector; //newAct.z.vector = sorceAct.z.vector; //newAct.rx.vector = sorceAct.rx.vector; //newAct.ry.vector = sorceAct.ry.vector; //newAct.rz.vector = sorceAct.rz.vector; //newAct.ps.vector = sorceAct.ps.vector; //newAct.x.min = sorceAct.x.min; //newAct.y.min = sorceAct.y.min; //newAct.w.min = sorceAct.w.min; //newAct.h.min = sorceAct.h.min; //newAct.a.min = sorceAct.a.min; //newAct.r.min = sorceAct.r.min; //newAct.z.min = sorceAct.z.min; //newAct.rx.min = sorceAct.rx.min; //newAct.ry.min = sorceAct.ry.min; //newAct.rz.min = sorceAct.rz.min; //newAct.ps.min = sorceAct.ps.min; //newAct.x.max = sorceAct.x.max; //newAct.y.max = sorceAct.y.max; //newAct.w.max = sorceAct.w.max; //newAct.h.max = sorceAct.h.max; //newAct.a.max = sorceAct.a.max; //newAct.r.max = sorceAct.r.max; //newAct.z.max = sorceAct.z.max; //newAct.rx.max = sorceAct.rx.max; //newAct.ry.max = sorceAct.ry.max; //newAct.rz.max = sorceAct.rz.max; //newAct.ps.max = sorceAct.ps.max; newAct.method = (method >= 0) ? method : sorceAct.method; newAct.acc = (boolAcc) ? acc : sorceAct.acc; } }; /**オブジェクトのアクションを開始する*/ ActionTween.Start = function (target) { var acts = ActionTween.list[target.actionTarget_uniqueKey]; if (!acts) return; delete ActionTween.list[target.actionTarget_uniqueKey]; ActionTween.activeList[target.actionTarget_uniqueKey] = acts; ActionTween.activeCount++; ActionTween.active = true; }; /**オブジェクトのアクションを止める*/ ActionTween.Stop = function (target) { var acts = ActionTween.activeList[target.actionTarget_uniqueKey]; if (!acts) return; delete ActionTween.activeList[target.actionTarget_uniqueKey]; ActionTween.list[target.actionTarget_uniqueKey] = acts; ActionTween.activeCount--; if (ActionTween.activeCount === 0) ActionTween.active = false; }; ActionTween.Remove = function (target) { ActionTween.Stop(target); var actObj = ActionTween.list[target.actionTarget_uniqueKey]; if (!actObj) return; var act = actObj.act; var len = act.length; for (var i = 0; i < len; i++) { act_2.ActObj.removeActObj(act[i]); } delete ActionTween.list[target.actionTarget_uniqueKey]; }; /**キャッシュ数を取得する*/ ActionTween.Length = function (target) { var acts = ActionTween.activeList[target.actionTarget_uniqueKey]; return acts.act.length - 1; }; /**キャッシュ上のアクションオブジェクトをインデックスを指定して取得する*/ ActionTween.Chash = function (target, no) { var acts = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); if (acts && acts.act.length > no) return acts.act[no]; else return null; }; /**キャッシュ上のアクションオブジェクトをインデックスを指定して取得する*/ ActionTween.LastChash = function (target) { var acts = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); if (acts && acts.act.length > 0) return acts.act[acts.act.length - 1]; else return null; }; /**キャッシュ上のアクションオブジェクトをインデックスを指定して取得する*/ ActionTween.Reset = function (target) { var obj0; var set = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); var acts = set.act; if (acts.length > 0) obj0 = acts[0]; if (!obj0) return; //obj0.x.value = ("getX" in target) ? target.getX() : null; //obj0.y.value = ("getY" in target) ? target.getY() : null; //obj0.w.value = ("getW" in target) ? target.getW() : null; //obj0.h.value = ("getH" in target) ? target.getH() : null; //obj0.a.value = ("getA" in target) ? target.getA() : null; //obj0.r.value = ("getR" in target) ? target.getR() : null; //obj0.z.value = ("getZ" in target) ? target.getZ() : null; //obj0.rx.value = ("getRX" in target) ? target.getRX() : null; //obj0.ry.value = ("getRY" in target) ? target.getRY() : null; //obj0.rz.value = ("getRZ" in target) ? target.getRZ() : null; //obj0.ps.value = ("getPS" in target) ? target.getPS() : null; var callSets = target.actionTarget_callsets; for (var nm in callSets) { obj0[nm].value = callSets[nm].get(); } }; /**キャッシュ上のアクションオブジェクトをインデックスを指定して取得する*/ ActionTween.Zero = function (target) { var obj0; var set = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); var acts = set.act; if (acts.length > 0) obj0 = acts[0]; if (!obj0) return; //("setX" in target) || target.setX(obj0.x.value); //("setY" in target) || target.setY(obj0.y.value); //("setW" in target) || target.setW(obj0.w.value); //("setH" in target) || target.setH(obj0.h.value); //("setA" in target) || target.setA(obj0.a.value); //("setR" in target) || target.setR(obj0.r.value); //("setZ" in target) || target.setZ(obj0.z.value); //("setRX" in target) || target.setRX(obj0.rx.value); //("setRY" in target) || target.setRY(obj0.ry.value); //("setRZ" in target) || target.setRZ(obj0.rz.value); //("setPS" in target) || target.setPS(obj0.ps.value); var callSets = target.actionTarget_callsets; for (var nm in callSets) { callSets[nm].set(obj0[nm].value); } }; /**現在のアニメーションの終点まで移動する*/ ActionTween.Fill = function (target) { var obj1; var set = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); var acts = set.act; if (acts.length > 1) obj1 = acts[1]; if (!obj1) return; //("setX" in target) ? target.setX(obj1.x.value) : null; //("setY" in target) ? target.setY(obj1.y.value) : null; //("setW" in target) ? target.setW(obj1.w.value) : null; //("setH" in target) ? target.setH(obj1.h.value) : null; //("setA" in target) ? target.setA(obj1.a.value) : null; //("setR" in target) ? target.setR(obj1.r.value) : null; //("setZ" in target) ? target.setZ(obj1.z.value) : null; //("setRX" in target) ? target.setRX(obj1.rx.value) : null; //("setRY" in target) ? target.setRY(obj1.ry.value) : null; //("setRZ" in target) ? target.setRZ(obj1.rz.value) : null; //("setPS" in target) ? target.setPS(obj1.ps.value) : null; var callSets = target.actionTarget_callsets; for (var nm in callSets) { callSets[nm].set(obj1[nm].value); } }; /**1フレーム分進める 全て目標値に達成すると true 一つでも達成してないとfalse*/ ActionTween.GoOneFrame = function (target) { var set = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); var acts = set.act; if (!acts) return true; var act = acts[0]; var act1 = acts[1]; var bool = true; var acc = act1.acc; var method = act1.method; //bool = (ActionTween.ActionXYZWH(act.x, act1.x, acc, method, target.setX)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.y, act1.y, acc, method, target.setY)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.w, act1.w, acc, method, target.setW)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.h, act1.h, acc, method, target.setH)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.a, act1.a, acc, method, target.setA, 0.05)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.r, act1.r, acc, method, target.setR)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.z, act1.z, acc, method, target.setZ)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.rx, act1.rx, acc, method, target.setRX)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.ry, act1.ry, acc, method, target.setRY)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.rz, act1.rz, acc, method, target.setRZ)) ? bool : false; //bool = (ActionTween.ActionXYZWH(act.ps, act1.ps, acc, method, target.setPS)) ? bool : false; var callSets = target.actionTarget_callsets; for (var nm in callSets) { bool = (ActionTween.ActionXYZWH(act[nm], act1[nm], acc, method, callSets[nm].set, (nm === 'a') ? 0.05 : 1)) ? bool : false; } if (bool) { if (act1.ef) { act1.ef.call(null, target, act); } } return bool; }; /**次のアクションを開始する*/ ActionTween.GoNextAction = function (target) { var set = ((ActionTween.activeList[target.actionTarget_uniqueKey]) || (ActionTween.list[target.actionTarget_uniqueKey])); var acts = set.act; if (!acts) return false; var next = acts[1]; var to; if (acts.length > 2) { to = acts[2]; } var fact = acts.reverse().pop(); try { if (next.rf) { next.rf.call(null, target, next); } next.SetFrom(fact); if (to && to.sf) { to.sf.call(null, target, to); } } finally { return (acts.reverse().length >= 2); } }; ActionTween._active = false; ActionTween.actionObj = new ts.ActionObj(function (index) { for (var key in ActionTween.activeList) { var target = ActionTween.activeList[key].target; if (ActionTween.GoOneFrame(target)) { var acts = ActionTween.activeList[target.actionTarget_uniqueKey]; if (acts && acts.act[1].autoRemove) { if (!ActionTween.GoNextAction(target)) { ActionTween.Stop(target); } } } } return 1; }); ActionTween.ActionXYZWH = function (act, next, acc, method, setFunc, limit) { if (limit === void 0) { limit = 1; } if (isNaN(next.value)) return true; if (act.value === next.value) return true; var exit = false; var v = next.value - act.value; var f = (v < 0) ? -1 : 1; var min = next.min; var max = next.max; if (min && min > (v * f)) v = min * f; var actV = MathBit.floor(v * 10000) * 0.0001 * f; if (max) actV = (max < actV) ? max : actV; if (min) actV = (min > actV) ? min : actV; var t = actV * acc * f; //if (min && min > (t * f)) { // t = min * f; //} switch (method) { case ActionMethod.adsorb: if (actV > limit) { var value = t; act.value += value; } else { act.value = next.value; exit = true; } break; case ActionMethod.snap: var before = act.value; act.value += (act.vector += t); act.vector *= acc; var over = (next.snap) && ((act.value - before) * f > v * f); if (over || (act.vector * f < 1 && (actV < 0.02 || (min && actV <= min)))) { act.value = next.value; exit = true; } break; default: } setFunc(act.value); return exit; }; return ActionTween; }()); act_2.ActionTween = ActionTween; })(act = ts.act || (ts.act = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); /// var jp; /// (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var LoaderToken = /** @class */ (function () { function LoaderToken(url, query, start, end, progress, error, jsonpCallbackName, responseType) { var _this = this; this.loading = false; this.OnLoadStart = function (ev) { _this.start(_this, ev); }; this.OnLoadEnd = function (ev) { _this.loading = false; if (_this.jsonpCallbackName) { window[_this.uniqu] = function (data) { delete window[_this.id]; _this.jsonpData = data; _this.end(_this, ev); _this.release(); }; } else { _this.end(_this, ev); _this.release(); } }; this.OnLoadProgress = function (ev) { _this.progress(_this, ev); }; this.OnLoadError = function (ev) { _this.loading = false; _this.error(_this, ev); _this.release(); }; this.getData = function () { if (_this.data) return _this.data; if (_this.request instanceof HTMLScriptElement) { _this.data = _this.jsonpData; } else { if (_this.request) { _this.data = _this.request.response; return _this.data; } return null; } return _this.data; }; this.open = function (method) { _this.loading = false; if (_this.request instanceof HTMLScriptElement) { _this.uniqu = btoa(_this.id); _this.jsonpCallbackScript.innerHTML = 'window.' + _this.jsonpCallbackName + ' = function(data){ window.setTimeout( function () { window["' + _this.uniqu + '"](data) }, 1); }'; switch (method) { case LoadMethod.GET: _this.request.src = _this.id; break; case LoadMethod.POST: _this.request.src = _this.url; break; } } else { switch (method) { case LoadMethod.GET: _this.request.open("GET", _this.id, true); break; case LoadMethod.POST: _this.request.open("POST", _this.url, true); break; } } }; this.setRequestHeader = function (header, value) { if (!(_this.request instanceof HTMLScriptElement)) { _this.request.setRequestHeader(header, value); } }; this.setResponseType = function (responseType) { if (!(_this.request instanceof HTMLScriptElement)) { _this.request.responseType = responseType; } }; this.send = function (data) { if (data === void 0) { data = null; } try { if (_this.request instanceof HTMLScriptElement) { _this.jsonpCallbackScript.parentElement.insertBefore(_this.request, _this.jsonpCallbackScript); //this.jsonpCallbackScript.parentElement.appendChild(this.request); } else { _this.request.send(data); } _this.loading = true; } catch (ex) { _this.loading = false; window.console.error(ex); } }; this.release = function () { _this.request.removeEventListener("loadend", _this.OnLoadEnd); _this.request.removeEventListener("error", _this.OnLoadError); _this.request.removeEventListener("loadstart", _this.OnLoadStart); _this.request.removeEventListener("progress", _this.OnLoadProgress); _this.request = null; _this.end = null; _this.start = null; _this.progress = null; _this.error = null; }; this.url = url; this.query = query; this.start = start; this.end = end; this.progress = progress; this.error = error; this.jsonpCallbackName = jsonpCallbackName; if (!jsonpCallbackName) { this.request = (function () { try { return new XMLHttpRequest(); } catch (e) { } try { return new ActiveXObject('MSXML2.XMLHTTP.6.0'); } catch (e) { } try { return new ActiveXObject('MSXML2.XMLHTTP.3.0'); } catch (e) { } try { return new ActiveXObject('MSXML2.XMLHTTP'); } catch (e) { } return null; })(); try { this.request.responseType = responseType; } catch (e) { //window.console.error(e.message); } this.request.addEventListener("loadend", this.OnLoadEnd); this.request.addEventListener("error", this.OnLoadError); this.request.addEventListener("loadstart", this.OnLoadStart); this.request.addEventListener("progress", this.OnLoadProgress); } else { var script = document.createElement('script'); script.async = true; script.classList.add('jp-ninesense-ts-loader-script'); script.addEventListener("load", this.OnLoadEnd); script.addEventListener("error", this.OnLoadError); script.addEventListener("loadstart", this.OnLoadStart); script.addEventListener("progress", this.OnLoadProgress); this.request = script; this.jsonpCallbackScript = document.createElement('script'); this.jsonpCallbackScript.type = 'text/javascript'; var sqripts = document.getElementsByTagName('SCRIPT'); var lastScript = sqripts[sqripts.length - 1]; lastScript.parentElement.appendChild(this.jsonpCallbackScript); } this.m_setEvent = true; } Object.defineProperty(LoaderToken.prototype, "Loading", { get: function () { return this.loading; }, enumerable: true, configurable: true }); return LoaderToken; }()); ts.LoaderToken = LoaderToken; var Loader = /** @class */ (function () { function Loader(serverUrl) { var _this = this; this.owners = Object.create(null); this.method = LoadMethod.GET; this.AddOwner = function (owner, server_url, query_filter) { if (server_url === void 0) { server_url = ''; } if (query_filter === void 0) { query_filter = {}; } if (!owner.iloadOwner_uniquekey) { owner.iloadOwner_uniquekey = Loader.noSeq; Loader.noSeq++; } if (!_this.owners[owner.iloadOwner_uniquekey]) { var filter = {}; filter[server_url] = query_filter; _this.owners[owner.iloadOwner_uniquekey] = { owner: owner, filter: filter }; } else { var setting = _this.owners[owner.iloadOwner_uniquekey]; setting.owner = owner; setting.filter[server_url] = query_filter; } }; this.RemoveOwner = function (owner, server_url) { if (server_url === void 0) { server_url = null; } if (!server_url) { delete _this.owners[owner.iloadOwner_uniquekey]; } else { delete _this.owners[owner.iloadOwner_uniquekey].filter[server_url]; } }; this.autoparse = true; this.RequestGet = function (url, query, ContentType, sendObj, autoparse, jsonpCallbackName, responseType) { if (query === void 0) { query = null; } if (ContentType === void 0) { ContentType = "application/x-www-form-urlencoded"; } if (sendObj === void 0) { sendObj = false; } if (autoparse === void 0) { autoparse = true; } if (jsonpCallbackName === void 0) { jsonpCallbackName = null; } if (responseType === void 0) { responseType = "text"; } var method = _this.method; _this.method = LoadMethod.GET; try { return _this.RequestUrl(url, query, ContentType, sendObj, autoparse, jsonpCallbackName, responseType); } finally { _this.method = method; } }; this.RequestPost = function (url, query, ContentType, sendObj, autoparse, jsonpCallbackName, responseType) { if (query === void 0) { query = null; } if (ContentType === void 0) { ContentType = "application/x-www-form-urlencoded"; } if (sendObj === void 0) { sendObj = false; } if (autoparse === void 0) { autoparse = true; } if (jsonpCallbackName === void 0) { jsonpCallbackName = null; } if (responseType === void 0) { responseType = "text"; } var method = _this.method; _this.method = LoadMethod.POST; try { return _this.RequestUrl(url, query, ContentType, sendObj, autoparse, jsonpCallbackName, responseType); } finally { _this.method = method; } }; this.RequestUrl = function (url, query, ContentType, sendObj, autoparse, jsonpCallbackName, responseType) { if (query === void 0) { query = null; } if (ContentType === void 0) { ContentType = "application/x-www-form-urlencoded"; } if (sendObj === void 0) { sendObj = false; } if (autoparse === void 0) { autoparse = true; } if (jsonpCallbackName === void 0) { jsonpCallbackName = null; } if (responseType === void 0) { responseType = "text"; } if (sessionStorage.getItem(Loader.timeName) === null) { try { sessionStorage.setItem(Loader.timeName, new Date().getMilliseconds().toString()); } catch (ex) { console.error(ex); } } var send_query = query; if (!sendObj) { if (typeof send_query === 'object') { var params = []; for (var name in send_query) { var value = send_query[name]; if (typeof value === 'object') { value = JSON.stringify(value); } var param = encodeURIComponent(name) + '=' + encodeURIComponent(value); params.push(param); } send_query = params.join('&').replace(/%20/g, '+'); } } var token; switch (_this.method) { case LoadMethod.GET: var id = url + "?loaderID=" + (sessionStorage.getItem(Loader.timeName) || 'unknown') + "&" + send_query; if (Loader.tokens[id]) { return Loader.tokens[id]; } token = new LoaderToken(url, query, _this.OnLoadStart, _this.OnLoadEnd, _this.OnLoadProgress, _this.OnLoadError, jsonpCallbackName, responseType); token.autoparse = autoparse; token.id = id; token.open(_this.method); try { token.setRequestHeader("Content-Type", ContentType); } catch (ex) { } token.send(); break; case LoadMethod.POST: token = new LoaderToken(url, query, _this.OnLoadStart, _this.OnLoadEnd, _this.OnLoadProgress, _this.OnLoadError, jsonpCallbackName, responseType); token.autoparse = autoparse; switch (ContentType) { case 'application/json': if (typeof (query) === 'string') { var send = query; } else { var send = JSON.stringify(query); } break; default: var send = "loaderID=" + (sessionStorage.getItem(Loader.timeName) || 'unknown') + '&' + send_query; } token.id = url + "?" + send; token.open(_this.method); try { token.setRequestHeader("Content-Type", ContentType); } catch (ex) { } if (!sendObj) { token.send(send); } else { token.send(send_query); } break; } Loader.tokens[token.id] = token; return token; }; this.RequestQuery = function (query, ContentType, sendObj) { if (query === void 0) { query = null; } if (ContentType === void 0) { ContentType = 'application/x-www-form-urlencoded'; } if (sendObj === void 0) { sendObj = false; } return _this.RequestUrl(_this.serverUrl, query, ContentType, sendObj, _this.autoparse); }; this.isLoading = function (id) { if (!Loader.tokens[id]) return false; Loader.tokens[id].Loading; }; //private m_setEvent: boolean = false; //private SetEvent = (token: LoaderToken, set:boolean): boolean => { // if (token.m_setEvent === set) return; // token.m_setEvent = set; // if (set) { // this.request.addEventListener("loadend", token.OnLoadEnd); // this.request.addEventListener("error", token.OnLoadError); // this.request.addEventListener("loadstart", token.OnLoadStart); // this.request.addEventListener("progress", token.OnLoadProgress); // } // else { // this.request.removeEventListener("loadend", token.OnLoadEnd); // this.request.removeEventListener("error", token.OnLoadError); // this.request.removeEventListener("loadstart", token.OnLoadStart); // this.request.removeEventListener("progress", token.OnLoadProgress); // } //} this.checkFilter = function (token, ownerKey) { var ownerInfo = _this.owners[ownerKey]; var filter = ownerInfo.filter; var query; if ((query = filter[token.url]) || filter['']) { var skip = false; for (var param in query) { var v = token.query[param]; if (!v || v !== query[param]) { skip = true; break; } } return !skip; } return false; }; this.OnLoadStart = function (token, ev) { for (var key in _this.owners) { if (_this.checkFilter(token, key)) _this.owners[key].owner.LoadStart(token); } }; this.OnLoadEnd = function (token, ev) { var request = ev.target; var data = token.getData(); var res; if (token.autoparse) { try { if (typeof (data) === 'string') { data = JSON.parse(decodeURIComponent(data)); } res = { id: data['id'], status: data['status'], data: data['data'] }; } catch (ex) { window.console.error('Loader:ParseError'); } } else { res = { data: data }; } if (!res) { res = { id: '', status: { loading: false }, data: data }; } //this.owners.forEach((value: boolean, index: iLoadOwner, owner: Map) => { for (var key in _this.owners) { if (_this.checkFilter(token, key)) { var owner = _this.owners[key].owner; owner.LoadEnd(token, res); } } }; this.OnLoadError = function (token, ev) { for (var key in _this.owners) { if (_this.checkFilter(token, key)) _this.owners[key].owner.LoadError(token, ev); } }; this.OnLoadProgress = function (token, ev) { var owner; for (var key in _this.owners) { if (_this.checkFilter(token, key)) _this.owners[key].owner.LoadProgress(token, ev); } }; this.OnFormat = function (data) { }; this.serverUrl = serverUrl; } Object.defineProperty(Loader.prototype, "serverURL", { get: function () { return this.serverUrl; }, set: function (value) { this.serverUrl = value; }, enumerable: true, configurable: true }); Loader.timeName = 'jp.ninesense.ts.Common.ajax.Loader.time'; Loader.noSeq = 0; Loader.tokens = {}; return Loader; }()); ts.Loader = Loader; var LoadMethod; (function (LoadMethod) { LoadMethod[LoadMethod["GET"] = 0] = "GET"; LoadMethod[LoadMethod["POST"] = 1] = "POST"; })(LoadMethod = ts.LoadMethod || (ts.LoadMethod = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var HistoryValues = /** @class */ (function () { function HistoryValues() { var _this = this; this.state = {}; this.targes = []; this._popStateSetting = false; this.OnPopState = function (e) { if (!e.state) return; _this._popStateSetting = true; try { var state = e.state; if (state['jp.ninesense.ts']) { _this.state = state['jp.ninesense.ts']; } var len = _this.targes.length; var s = _this.state; for (var i = 0; i < len; i++) { var set = _this.targes[i]; set.callback(set.target, s[set.id]); } } finally { _this._popStateSetting = false; } }; this.addTarget = function (id, target, defaultValue, callback) { _this.targes.push({ id: id, target: target, callback: callback }); var state = _this.state; var def = false; if (!state[id]) { state[id] = defaultValue; def = true; } var s = window.history.state; if (!s) { s = {}; } s['jp.ninesense.ts'] = state; window.history.replaceState(s, ''); if (!def) { callback(target, state[id]); } }; this.getState = function (id, key) { if (_this.state[id]) { return _this.state[id][key]; } return null; }; this.push = function (id, key, value) { var state = _this.state; if (!state[id]) { state[id] = {}; } state[id][key] = value; _this.reflesh(); }; this.reflesh = function () { if (_this.time) return; _this.time = setTimeout(function () { var state = window.history.state; if (!state) state = {}; state['jp.ninesense.ts'] = _this.state; window.history.pushState(state, '', '#' + ts.str.randomString(12)); _this.time = null; }, 1); }; if (HistoryValues.instance !== undefined) throw new Error('シングルトンクラスを複数インスタンス化出来ません。'); HistoryValues.instance = this; this.values = Object.create(null); window.addEventListener('popstate', this.OnPopState); var state = window.history.state; if (state && state['jp.ninesense.ts']) { this.state = state['jp.ninesense.ts']; } } Object.defineProperty(HistoryValues.prototype, "PopStateSetting", { get: function () { return this._popStateSetting; }, enumerable: true, configurable: true }); HistoryValues.GetInstance = function () { if (HistoryValues.instance === undefined) { HistoryValues.instance = new HistoryValues(); } return HistoryValues.instance; }; HistoryValues.useableHistory = function () { if (window.history && window.history.replaceState) { return true; } else { return false; } }; return HistoryValues; }()); ts.HistoryValues = HistoryValues; HistoryValues.GetInstance(); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var ServerValues = /** @class */ (function () { function ServerValues() { var _this = this; this.ReadValues = function (id, reviver) { if (!_this.values[id]) { var value = document.getElementById(id).getAttribute('data-jsvalues'); value = decodeURIComponent(value); _this.values[id] = JSON.parse(value, reviver); } return _this.values[id]; }; if (ServerValues.instance !== undefined) throw new Error('シングルトンクラスを複数インスタンス化出来ません。'); ServerValues.instance = this; this.values = Object.create(null); } ServerValues.GetInstance = function () { if (ServerValues.instance === undefined) { ServerValues.instance = new ServerValues(); } return ServerValues.instance; }; return ServerValues; }()); ts.ServerValues = ServerValues; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var WebStorageValue = /** @class */ (function () { function WebStorageValue() { this.state = {}; this.hash = {}; this.OnStrage = function (e) { }; if (WebStorageValue.instance !== undefined) throw new Error('シングルトンクラスを複数インスタンス化出来ません。'); WebStorageValue.instance = this; this.values = Object.create(null); var state = window.addEventListener('storage', this.OnStrage); } WebStorageValue.GetInstance = function () { if (WebStorageValue.instance === undefined) { WebStorageValue.instance = new WebStorageValue(); } return WebStorageValue.instance; }; return WebStorageValue; }()); ts.WebStorageValue = WebStorageValue; WebStorageValue.GetInstance(); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var db = /** @class */ (function () { function db(name, version) { if (version === void 0) { version = 1; } this.OnError = function (e) { }; this.OnUpgradeneeded = function (e) { }; this.request = db.indexedDB.open(name, version); this.request.onerror = this.OnError; this.request.onupgradeneeded = this.OnUpgradeneeded; } db.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; db.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction || { READ_WRITE: "readwrite" }; db.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange; return db; }()); ts.db = db; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var dom = /** @class */ (function () { function dom() { } dom.mapping = []; dom.init = function (url, func) { var under = location.pathname; if (under === url || url === '' || ((url instanceof RegExp) && url.test(under))) { if (document.readyState === "complete" || document.readyState === 'interactive') { dom.mapping.push(func); return setTimeout(dom.loaded, 1); } if (!dom.mapping[0]) { if (window.addEventListener) { window.addEventListener('DOMContentLoaded', dom.loaded, false); } else if ('attachEvent' in window) { window.attachEvent('onreadystatechange', dom.loaded); } } dom.mapping.push(func); } }; dom.loaded = function (e) { var len = dom.mapping.length; var param = ts.http.getParam(); for (var i = 0; i < len; i++) { if (dom.mapping[i](param) === true) { break; } } dom.mapping = []; }; dom.insertNext = function (target, point) { var next = point.nextSibling; if (next) { if (target === next) return; target.ownerDocument.insertBefore(target, next); } else { point.parentElement.appendChild(target); } }; dom.insertLastSameTag = function (target) { var elements = target.ownerDocument.getElementsByTagName(target.tagName); var last = elements[elements.length - 1]; dom.insertNext(last, target); }; return dom; }()); ts.dom = dom; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var elements = /** @class */ (function () { function elements() { } elements.getElementByAny = function (key) { if (key instanceof HTMLElement) { return key; } else { return document.getElementById(key); } }; return elements; }()); ts.elements = elements; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var imageLightBox = /** @class */ (function () { function imageLightBox(query) { var _this = this; this.OnClick = function (e) { var img = e.target; if (img instanceof HTMLImageElement) { e.preventDefault(); _this.lightBox.show(); var id = img.getAttribute('data-ns-gallery-id'); var current = document.getElementById('ns-gallery-' + id); current.classList.add('active'); _this.current = id; } }; this.OnClickLightBox = function (e) { if (_this.current) { var current = document.getElementById('ns-gallery-' + _this.current); current.classList.remove('active'); _this.current = null; } return true; }; var galleries = document.querySelectorAll(query); var len = galleries.length; if (len === 0) return; var images = []; for (var i = 0; i < len; i++) { galleries[i].addEventListener('click', this.OnClick); var gs = galleries[i].getElementsByTagName('img'); var cnt = gs.length; for (var j = 0; j < cnt; j++) { images.push(gs[j]); } } var lightBox = new jp.ninesense.ts.lightBox('gallery-lightbox', this.OnClickLightBox); var ul = document.createElement('ul'); len = images.length; for (var i_1 = 0; i_1 < len; i_1++) { var org = images[i_1]; var url = org.getAttribute('data-ns-big-image'); if (!url) { url = org.src; } if (!url) continue; var img = document.createElement("img"); img.src = url; img.alt = org.alt; img.setAttribute('data-ns-gallery-id', i_1.toString()); org.setAttribute('data-ns-gallery-id', i_1.toString()); var li = document.createElement('li'); li.id = 'ns-gallery-' + i_1.toString(); var div = document.createElement('div'); div.appendChild(img); li.appendChild(div); ul.appendChild(li); } lightBox.Dom.appendChild(ul); this.lightBox = lightBox; } imageLightBox.init = function (targetBlockQuery) { if (targetBlockQuery === void 0) { targetBlockQuery = '.gallery'; } jp.ninesense.ts.imageLightBox.instance = new imageLightBox(targetBlockQuery); }; return imageLightBox; }()); ts.imageLightBox = imageLightBox; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var imageResource = /** @class */ (function () { function imageResource() { } Object.defineProperty(imageResource, "Canvas", { get: function () { if (!imageResource.canvas) { imageResource.canvas = document.createElement('canvas'); } return imageResource.canvas; }, enumerable: true, configurable: true }); imageResource.blankImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////AAAAVcLTfgAAAAF0Uk5TAEDm2GYAAAAMSURBVHjaYmAACDAAAAIAAU9tWeEAAAAASUVORK5CYII='; imageResource.createFillImage = function (width, height, color, alpha) { if (color === void 0) { color = 'white'; } if (alpha === void 0) { alpha = false; } var canvas = imageResource.Canvas; var context = canvas.getContext("2d", { alpha: alpha }); try { canvas.width = width; canvas.height = height; context.fillStyle = color; context.fillRect(0, 0, width, height); return canvas.toDataURL('image/png'); } finally { context.clearRect(0, 0, width, height); } }; return imageResource; }()); ts.imageResource = imageResource; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var imageSlider = /** @class */ (function () { function imageSlider(selector, visualSelector, overlaySelector, mouseEventListenerSelector, repeat, writeImageSize, wrapElement, dummyClass) { var _this = this; if (overlaySelector === void 0) { overlaySelector = null; } if (mouseEventListenerSelector === void 0) { mouseEventListenerSelector = ''; } if (repeat === void 0) { repeat = true; } if (writeImageSize === void 0) { writeImageSize = true; } if (wrapElement === void 0) { wrapElement = document; } if (dummyClass === void 0) { dummyClass = null; } this.contents = []; this.current = 0; this.showDumyS = false; this.showDumyE = false; this.maxX = 0; this.slidePauseCount = 500; this.overlayOutAcc = 0.08; this.overlayInAcc = 0.02; this.backgroundMoveAcc = 0.1; this.backgroundMoveMin = 1; this.backgroundMoveMax = null; this._autoSlide = true; this._sliding = false; this.mouseMovied = false; this.repeat = true; this.writeImageSize = false; this.getChild = function (index) { var c = _this.contents[index]; if (c) { return c.picture; } else { return null; } }; this.getChildX = function (index) { var c = _this.contents[index]; if (c) { return c.x; } else { return null; } }; this.addClass = function (slideContents, className) { if (slideContents.button) slideContents.button.classList.add(className); if (slideContents.text) slideContents.text.classList.add(className); if (slideContents.picture) slideContents.picture.classList.add(className); }; this.removeClass = function (slideContents, className) { if (slideContents.button) slideContents.button.classList.remove(className); if (slideContents.text) slideContents.text.classList.remove(className); if (slideContents.picture) slideContents.picture.classList.remove(className); }; this._refreshChildWait = false; this.refreshChildren = function (sync, sizeRefresh) { if (sync === void 0) { sync = false; } if (sizeRefresh === void 0) { sizeRefresh = true; } if (!sync && (_this._sliding || _this._mouseDown)) { _this._refreshChildWait = true; return; } var len = _this.frame.children.length; var cnt = 0; var current = _this.current; var wrapElement = _this.wrapElement; for (var i = 0; i < len; i++) { var child = _this.frame.children[i]; var id = child.getAttribute(imageSlider.attr); if (!id) continue; if (!_this.contents[cnt]) { var button_1 = document.createElement('button'); button_1.setAttribute('data-ns-slide-index', cnt.toString()); _this.contents[cnt] = { picture: child, img: child.querySelector("img"), video: child.querySelector("video"), x: 0, text: ((id) ? wrapElement.querySelector('.overlay_contents[data-ns-slide="' + id.toString() + '"]') : null), button: button_1 }; var li = document.createElement('li'); li.appendChild(button_1); _this.buttonArea.appendChild(li); } else { var content = _this.contents[cnt]; content.picture = child; content.img = child.querySelector("img"); content.video = child.querySelector("video"); content.text = ((id) ? wrapElement.querySelector('.overlay_contents[data-ns-slide="' + id.toString() + '"]') : null); switch (cnt) { case current: _this.addClass(content, 'active'); _this.removeClass(content, 'previous'); _this.removeClass(content, 'next'); break; case current - 1: _this.removeClass(content, 'active'); _this.addClass(content, 'previous'); _this.removeClass(content, 'next'); break; case current + 1: _this.removeClass(content, 'active'); _this.removeClass(content, 'previous'); _this.addClass(content, 'next'); break; default: _this.removeClass(content, 'active'); _this.removeClass(content, 'previous'); _this.removeClass(content, 'next'); } } cnt++; } var cLen = _this.contents.length; if (cnt < cLen) { for (var i = len; i < cLen; i++) { var button = _this.contents[i].button; button.parentElement.parentElement.removeChild(button.parentElement); } _this.contents.length = cnt; } if (_this.repeat) { _this.dummyS.picture.innerHTML = _this.contents[cnt - 1].picture.innerHTML; _this.dummyE.picture.innerHTML = _this.contents[0].picture.innerHTML; _this.dummyS.img = _this.dummyS.picture.querySelector('img'); _this.dummyE.img = _this.dummyE.picture.querySelector('img'); _this.dummyS.video = _this.dummyS.picture.querySelector('video'); _this.dummyE.video = _this.dummyE.picture.querySelector('video'); _this.frame.insertBefore(_this.dummyS.picture, _this.contents[0].picture); _this.dummyS.picture.style.position = 'absolute'; _this.dummyS.picture.style.left = '-100%'; _this.frame.appendChild(_this.dummyE.picture); } if (sizeRefresh) { //this.OnResize(); _this.refreshPosition(); } }; this.OnAction = function (index, option) { switch (index) { case 1: //リサイズ //this.OnResize(); if (_this.refreshPosition()) { _this.slideImage(false, false); } break; case 2: //カレントへスライド _this.slideImage(); break; case 3: //オートスライド if (!_this.resizing) { _this.showImage(_this.current + 1, true); } return 2; case 4: //スライド完了 //this.OnResize(); _this.refreshPosition(); _this.settingClass(); if (_this.onSlided) { _this.onSlided(); } return 0; } return 0; }; this.ButtonClick = function (e) { e.preventDefault(); var target = e.target; var id = parseInt(target.getAttribute('data-ns-slide-index')); if (isNaN(id)) return; _this.showImage(id); }; this.SetupVisual = function (visual, overlay, mouseEventListener) { _this.visual = visual; _this.overlay = overlay; if (mouseEventListener) { _this.eventListener = mouseEventListener; } else { _this.eventListener = _this.visual.parentElement; } _this.eventListener.addEventListener(jp.ninesense.ts.devise.pointerEvents.start, _this.OnMouseStart); var pictuers = visual.getElementsByTagName('div'); var rect; _this.actionVisual = new jp.ninesense.ts.act.ActionElement(visual); var act = jp.ninesense.ts.act.ActionTween.Act(_this.actionVisual, _this.backgroundMoveAcc, jp.ninesense.ts.act.ActionMethod.snap); act.autoRemove = false; act.x.snap = true; act.x.value = 0; act.x.min = _this.backgroundMoveMin; act.x.max = _this.backgroundMoveMax; jp.ninesense.ts.act.ActionTween.Start(_this.actionVisual); if (overlay) { _this.actionOverlay = new jp.ninesense.ts.act.ActionElement(overlay); var act = jp.ninesense.ts.act.ActionTween.Act(_this.actionOverlay, _this.overlayInAcc, jp.ninesense.ts.act.ActionMethod.adsorb); act.autoRemove = false; act.a.snap = true; act.a.value = 0; jp.ninesense.ts.act.ActionTween.Start(_this.actionOverlay); } }; this.MoveEndFunction = function () { }; this.next = function (animate) { if (animate === void 0) { animate = true; } _this.showImage(_this.current + 1, animate); }; this.previous = function (animate) { if (animate === void 0) { animate = true; } _this.showImage(_this.current - 1, animate); }; this.showImage = function (index, animate, doEvents) { if (animate === void 0) { animate = true; } if (doEvents === void 0) { doEvents = true; } if (_this.repeat) { if (index < -1) index = _this.contents.length - 1; if (_this.contents.length < index) index = 0; } else { if (_this.contents.length <= index) index = _this.contents.length - 1; if (index <= -1) index = 0; } var current = _this.contents[_this.current]; if (current) { _this.removeClass(current, 'active'); var next = _this.nextElement; if (next) { _this.removeClass(next, 'next'); } if (_this.repeat) { current.picture.nextElementSibling.classList.remove('next'); } var previous = _this.previousElement; if (previous) { _this.removeClass(previous, 'previous'); } if (_this.repeat) { current.picture.previousElementSibling.classList.remove('previous'); } //current.button.classList.remove('active'); //current.picture.classList.remove('active'); //if (current.text) current.text.classList.remove('active'); if (current.video) { current.video.pause(); if (_this.repeat) { if (_this.current === 0) { _this.dummyE.video.pause(); } else if (_this.current === _this.contents.length - 1) { _this.dummyS.video.pause(); } } } } _this.current = index; current = _this.contents[_this.current]; if (animate) { _this.action.option.pauseCount = 0; var actVisual = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionVisual); actVisual.ef = null; if (_this.downPoints) { _this.action.setTickIndex(2); } else { var action = _this.action; action.actionFromTo(3, 2); action.actionFromTo(4, 2); action.stopTo(2); } } else { _this.slideImage(false, doEvents); } }; this.setEndPoint = function (x, resetX) { //window.console.log(x, this.maxX); if (resetX === void 0) { resetX = null; } if (!_this.actionVisual) return; var actVisual = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionVisual); if (!resetX && resetX !== 0) { actVisual.x.value = x; } else { _this.actionVisual.setX(resetX); _this.actionVisual.gotoEndPoint(); jp.ninesense.ts.act.ActionTween.Reset(_this.actionVisual); actVisual.x.value = x; } actVisual.x.min = _this.backgroundMoveMin; actVisual.x.max = _this.backgroundMoveMax; actVisual.acc = _this.backgroundMoveAcc; if (_this.onVisualActSetting) { _this.onVisualActSetting("slide", actVisual); } }; this.settingClass = function () { var content = _this.contents[_this.current]; _this.addClass(content, 'active'); var next = _this.nextElement; if (next) { _this.addClass(next, 'next'); } if (_this.repeat) { content.picture.nextElementSibling.classList.add('next'); } var previous = _this.previousElement; if (previous) { _this.addClass(previous, 'previous'); } if (_this.repeat) { content.picture.previousElementSibling.classList.add('previous'); } }; this.slideImage = function (animate, doEvents) { if (animate === void 0) { animate = true; } if (doEvents === void 0) { doEvents = true; } var showDummy = false; var slideX; var content; var len = _this.contents.length; if (len === 0) return; if (_this.current >= len) { if (_this.repeat) { _this.current = 0; content = _this.contents[0]; slideX = _this.dummyE.x; _this.showDumyE = true; showDummy = true; } else { _this.current = len - 1; content = _this.contents[_this.current]; slideX = content.x; } } else if (_this.current <= -1) { if (_this.repeat) { _this.current = len - 1; content = _this.contents[_this.current]; slideX = _this.dummyS.x; _this.showDumyS = true; showDummy = true; } else { _this.current = 0; content = _this.contents[_this.current]; slideX = content.x; } } else { content = _this.contents[_this.current]; slideX = content.x; } var actVisual = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionVisual); if (!animate) { _this.setEndPoint(slideX, slideX); } else { //actVisual.x.value = slideX; _this.setEndPoint(slideX); } if (_this.actionOverlay) { var actOverlay = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionOverlay); _this.actionOverlay.setA(-1); jp.ninesense.ts.act.ActionTween.Reset(_this.actionOverlay); actOverlay.a.value = 1; actOverlay.acc = _this.overlayInAcc; if (_this.onOverlayActSetting) { _this.onOverlayActSetting("fade-in", actOverlay); } } //if (content.text) { // content.text.classList.add('active'); //} //content.button.classList.add('active'); //content.picture.classList.add('active'); _this.settingClass(); if (content.video) { content.video.play(); if (_this.showDumyS) { if (_this.dummyS.video) { _this.dummyS.video.currentTime = content.video.currentTime; _this.dummyS.video.play(); } } else if (_this.showDumyE) { if (_this.dummyE.video) { _this.dummyE.video.currentTime = content.video.currentTime; _this.dummyE.video.play(); } } } if (!_this._sliding) { _this._sliding = true; } if (doEvents) { if (_this.onSliding) { _this.onSliding(); } } if (!showDummy) { actVisual.ef = function () { actVisual.ef = null; if (actOverlay) actOverlay.a.value = 1; _this.showDumyE = false; _this.showDumyS = false; _this.waitAutoSlide(); _this._sliding = false; if (_this._refreshChildWait) { _this._refreshChildWait = false; _this.refreshChildren(); } //if (this.onSliding) { if (doEvents) { var action = _this.action; action.actionFromTo(2, 4); //action.actionFromTo(3, 4); } //} }; } else { actVisual.ef = function () { actVisual.ef = null; if (!_this.downPoints) { _this.DummyReset(0); _this.waitAutoSlide(); } _this._sliding = false; if (_this._refreshChildWait) { _this._refreshChildWait = false; _this.refreshChildren(); } //if (this.onSliding) { if (doEvents) { var action = _this.action; action.actionFromTo(2, 4); //action.actionFromTo(3, 4); } //} }; } }; this.waitAutoSlide = function () { if (_this.autoSlide) { if (_this.action.getTickIndex() === 0) { _this.action.option.pauseCount = _this.slidePauseCount; _this.action.setTickIndex(3); } } }; this.OnMouseStart = function (e) { try { _this._mouseDown = true; if (e instanceof MouseEvent) { _this.MouseStart({ x: e.pageX, y: e.pageY }); } else { var touch = e.touches[0]; _this.MouseStart({ x: touch.pageX, y: touch.pageY }); } } finally { _this.mouseMovied = false; _this.mouseMoveEnabled = true; _this.mouseEndEnabled = true; } }; this._mouseDown = false; this._mouseMoveEnabled = false; this._mouseEndEnabled = false; this.mouseSlideEnabled = true; this.OnMouseMove = function (e) { if (!_this.mouseSlideEnabled) { e.preventDefault(); return; } _this.mouseMovied = true; var point; if (e instanceof MouseEvent) { point = { x: e.pageX, y: e.pageY }; _this.MouseMove(point); } else if (e.touches[0]) { var touch = e.touches[0]; point = { x: touch.pageX, y: touch.pageY }; _this.MouseMove(point); } if (jp.ninesense.ts.MathBit.abs(point.y - _this.downPoints.mouse.y) < 1) { e.preventDefault(); } }; this.OnMouseEnd = function (e) { try { if (e instanceof MouseEvent) { _this.MouseEnd({ x: e.pageX, y: e.pageY }); } else if (e.touches[0]) { var touch = e.touches[0]; _this.MouseEnd({ x: touch.pageX, y: touch.pageY }); } else if (_this.movePoints) { _this.MouseEnd({ x: _this.movePoints.x, y: _this.movePoints.y }); } } finally { _this.mouseMoveEnabled = false; _this.mouseEndEnabled = false; _this.mouseMovied = false; _this._mouseDown = false; if (_this._refreshChildWait) { _this._refreshChildWait = false; _this.refreshChildren(); } } }; this.MouseStart = function (point) { //window.console.log(point.x); _this.action.setTickIndex(0); _this.action.option.pauseCount = 0; var act = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionVisual); //window.console.log(this.showDumyS, this.showDumyE); _this.downPoints = { mouse: point, client: { x: act.x.value, y: act.y.value } }; //this.movePoints = point; _this.DummyReset(point.x); }; this.DummyReset = function (downPointX) { if (_this.showDumyE) { _this.showDumyE = false; var x = _this.actionVisual.getX(); var dummyX = _this.dummyE.x; var resetX = x - dummyX; if (_this.downPoints) { _this.downPoints.client.x = resetX; _this.setEndPoint(downPointX - (_this.downPoints.mouse.x - resetX), resetX); } else { _this.setEndPoint(0, 0); } } else if (_this.showDumyS) { _this.showDumyS = false; var x = _this.actionVisual.getX(); var dummyX = _this.maxX - _this.dummyS.x; var resetX = x - dummyX; if (_this.downPoints) { _this.downPoints.client.x = resetX; _this.setEndPoint(downPointX - (_this.downPoints.mouse.x - resetX), resetX); } else { var lastContent = _this.contents[_this.contents.length - 1]; _this.setEndPoint(lastContent.x, lastContent.x); } } }; this.MouseMove = function (point) { //window.console.log(point.x); if (_this.downPoints) { if (!_this.movePoints) { if (jp.ninesense.ts.MathBit.abs(_this.downPoints.mouse.x - point.x) < 30) { return; } } _this._sliding = true; _this.movePoints = point; var act = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionVisual); act.x.value = point.x - (_this.downPoints.mouse.x - _this.downPoints.client.x); if (_this.onVisualActSetting) { _this.onVisualActSetting("mouse", act); } if (_this.actionOverlay) { var act = jp.ninesense.ts.act.ActionTween.LastChash(_this.actionOverlay); act.a.value = -1; act.acc = _this.overlayOutAcc; if (_this.onOverlayActSetting) { _this.onOverlayActSetting("fade-out", act); } } if (_this.onSliding) { _this.onSliding(); } } }; this.MouseEnd = function (point) { //window.console.log(point.x); try { if (!_this.mouseMovied) return; if (!_this.downPoints || !_this.movePoints) { _this.showImage(_this.current); return; } if (_this.movePoints.x === _this.downPoints.mouse.x) { _this.showImage(_this.current); return; } var diff = point.x - _this.downPoints.mouse.x; if (diff > 50) _this.showImage(_this.current - 1); else if (diff < -50) _this.showImage(_this.current + 1); else _this.showImage(_this.current); } finally { _this.downPoints = null; _this.movePoints = null; _this.waitAutoSlide(); } }; this.resizing = false; this.OnResize = function (e) { if (e === void 0) { e = null; } if (_this.refreshPosition()) { if (!_this._mouseDown) { _this.slideImage(false, false); } } }; this.refreshPosition = function () { var len = _this.contents.length; var rect = jp.ninesense.ts.Rects.Catch(); var frameSize = _this.frame.getBoundingClientRect(); var fw = frameSize.width; var fh = frameSize.height; var isMobileSize = window.innerWidth < 864; var sumX = 0; _this.resizing = true; var retry = false; var firstContents = _this.contents[0]; var offset = 0; if (firstContents) { offset = firstContents.picture.getBoundingClientRect().left - _this.frame.getBoundingClientRect().left; } try { for (var i = 0; i < len; i++) { var content = _this.contents[i]; var img = content.img; if (i === 0) { if (img && !img.complete) { content.img.addEventListener("load", function () { //this.refreshPosition(); if (_this.refreshPosition()) { _this.slideImage(false, false); } }); retry = true; return false; } else { _this.waitAutoSlide(); } } if (isMobileSize) { if (img) { rect.width = img.naturalWidth; rect.height = img.naturalHeight; } else { rect.width = fw; rect.height = fh; } var scale = rect.AsOverSize(fw, fh).toString(); var x = (fw - rect.width) * 0.5; //content.img.style.transform = 'translateX(' + x.toString() + 'px ) scale3d(' + scale + ',' + scale + ',1)'; if (img) { if (rect.width !== fw) { img.style.width = ''; if (_this.writeImageSize) { img.style.height = fh.toString() + 'px'; } img.style.left = x.toString() + 'px'; } else { if (_this.writeImageSize) { img.style.width = fw.toString() + 'px'; } img.style.height = ''; img.style.left = x.toString() + 'px'; } if (_this.repeat) { if (i === 0) { _this.dummyE.img.style.width = content.img.style.width; _this.dummyE.img.style.height = content.img.style.height; _this.dummyE.img.style.left = content.img.style.left; } else if (i === len - 1) { _this.dummyS.img.style.width = content.img.style.width; _this.dummyS.img.style.height = content.img.style.height; _this.dummyS.img.style.left = content.img.style.left; } } } //content.img.style.left = x.toString() + 'px'; } else { if (img) { img.style.transform = ''; img.style.width = ''; img.style.height = ''; } } content.x = sumX - offset; sumX -= fw; } if (!isMobileSize) { if (_this.repeat) { _this.dummyE.img.style.width = ''; _this.dummyE.img.style.height = ''; _this.dummyS.img.style.width = ''; _this.dummyS.img.style.height = ''; } } if (_this.repeat) { _this.dummyE.x = sumX; _this.dummyS.x = fw; } if (!_this._mouseDown) { _this.resizing = false; //this.action.stopTo(1); } _this.maxX = -sumX + fw; return true; } finally { if (!retry) { if (_this.onResized) _this.onResized(); _this.resizing = false; } } }; if (!wrapElement) return; this.wrapElement = wrapElement; if (typeof (selector) === 'string') { this.frame = wrapElement.querySelector(selector); } else { this.frame = selector; } this.action = new jp.ninesense.ts.ActionObj(this.OnAction); this.action.option = { data: null, pauseCount: 5 }; this.repeat = repeat; this.writeImageSize = writeImageSize; var tagName = 'div'; var visual; if (typeof (visualSelector) === 'string') { visual = wrapElement.querySelector(visualSelector); } else { visual = visualSelector; } if (visual.tagName === 'UL') { tagName = 'li'; } this.dummyS = { picture: document.createElement(tagName), x: 0, img: null, video: null }; this.dummyE = { picture: document.createElement(tagName), x: 0, img: null, video: null }; if (dummyClass) { this.dummyS.picture.className = dummyClass.s; this.dummyE.picture.className = dummyClass.e; } this.buttonArea = document.createElement('ul'); this.buttonArea.classList.add('button-area'); this.refreshChildren(false, false); window.addEventListener("resize", function () { _this.action.option.pauseCount = 0; _this.action.setTickIndex(1); }); this.buttonArea.addEventListener("click", this.ButtonClick); var overlay; if (overlaySelector) { if (typeof (overlaySelector) === 'string') { overlay = wrapElement.querySelector(overlaySelector); } else { overlay = overlaySelector; } } var mouseEventListener; if (mouseEventListenerSelector) { if (typeof (mouseEventListenerSelector) === 'string') { mouseEventListener = wrapElement.querySelector(mouseEventListenerSelector); } else { mouseEventListener = mouseEventListenerSelector; } } this.SetupVisual(visual, overlay, mouseEventListener); this.OnResize(); if (this.overlay) { this.overlay.parentElement.appendChild(this.buttonArea); } } Object.defineProperty(imageSlider.prototype, "slideFrame", { get: function () { return this.frame; }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "currentIndex", { get: function () { return this.current; }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "currentElement", { get: function () { var c = this.contents[this.current]; if (c) { return c; } else { return null; } }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "previousElement", { get: function () { var index = this.current - 1; if (index === -1 && this.repeat) { index = this.contents.length - 1; } var c = this.contents[index]; if (c) { return c; } else { return null; } }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "nextElement", { get: function () { var index = this.current + 1; if (index === this.contents.length && this.repeat) { index = 0; } var c = this.contents[index]; if (c) { return c; } else { return null; } }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "length", { get: function () { return this.contents.length; }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "sliding", { get: function () { return this._sliding; }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "autoSlide", { get: function () { return this._autoSlide; }, set: function (value) { if (this._autoSlide === value) return; this._autoSlide = value; if (value) { this.frame.parentElement.classList.remove('slide-stop'); this.action.option.pauseCount = 0; this.showImage(this.current, true); } else { this.frame.parentElement.classList.add('slide-stop'); this.action.option.pauseCount = 0; this.showImage(this.current, false); this.action.setTickIndex(0); } }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "mouseDown", { get: function () { return this._mouseDown; }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "mouseMoveEnabled", { get: function () { return this._mouseMoveEnabled; }, set: function (value) { if (this._mouseMoveEnabled === value) return; this._mouseMoveEnabled = value; if (value) { this.eventListener.addEventListener(jp.ninesense.ts.devise.pointerEvents.move, this.OnMouseMove); } else { this.eventListener.removeEventListener(jp.ninesense.ts.devise.pointerEvents.move, this.OnMouseMove); } }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "mouseEndEnabled", { get: function () { return this._mouseEndEnabled; }, set: function (value) { if (this._mouseEndEnabled === value) return; this._mouseEndEnabled = value; if (value) { if (jp.ninesense.ts.devise.isMobile) { this.eventListener.addEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnMouseEnd); } else { document.addEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnMouseEnd); } } else { this.eventListener.removeEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnMouseEnd); document.removeEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnMouseEnd); } }, enumerable: true, configurable: true }); Object.defineProperty(imageSlider.prototype, "isLastIndex", { get: function () { return this.currentIndex + 1 >= this.length; }, enumerable: true, configurable: true }); imageSlider.attr = 'data-ns-slide'; return imageSlider; }()); ts.imageSlider = imageSlider; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); /*

...

...

...

*/ var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var imageThrobber = /** @class */ (function () { function imageThrobber(query, waitTime, loadingClass) { var _this = this; if (waitTime === void 0) { waitTime = 200; } if (loadingClass === void 0) { loadingClass = 'imageloading-throbber'; } this.images = {}; this.OnLoad = function (e) { if (e === void 0) { e = null; } var image = e.currentTarget; var id = image.getAttribute(imageThrobber.attr); _this.ShowImage(id); }; this.ShowImage = function (id) { var loadingImages = _this.images[id]; var image = loadingImages.img; var dumy = loadingImages.dummy; image.onload = null; image.style.display = loadingImages.display; dumy.parentElement.removeChild(dumy); if (_this.loadingClass) { image.parentElement.classList.remove(_this.loadingClass); } }; var images = document.querySelectorAll(query); var len = images.length; var cnt = 0; var loadingImages = this.images; this.loadingClass = loadingClass; for (var i = 0; i < len; i++) { var image = images[i]; if (!image.complete) { cnt++; var id = imageThrobber.attr + '_' + i.toString(); var w = image.width; var h = image.height; var dummy = document.createElement('canvas'); loadingImages[id] = { img: image, display: image.style.display, dummy: dummy, src: image.src }; image.style.display = 'none'; image.setAttribute(imageThrobber.attr, id); dummy.className = image.className; dummy.width = image.width; dummy.height = image.height; dummy.id = id; dummy.style.maxWidth = '100%'; dummy.style.maxHeight = '100%'; dummy.style.width = 'auto'; dummy.style.height = 'auto'; if (loadingClass) { image.parentElement.classList.add(loadingClass); } image.src = jp.ninesense.ts.imageResource.blankImage; image.parentElement.insertBefore(dummy, image); image.parentElement.removeChild(image); } } setTimeout(function () { for (var id in loadingImages) { var img = loadingImages[id].img; var dummy = loadingImages[id].dummy; dummy.parentElement.insertBefore(img, dummy); img.src = loadingImages[id].src; if (!img.complete) { img.onload = _this.OnLoad; } else { _this.ShowImage(id); } } }, waitTime); } imageThrobber.attr = 'data-ns-image-throbber-id'; imageThrobber.init = function (query, waitTime) { imageThrobber.instance = new imageThrobber(query, waitTime); }; return imageThrobber; }()); ts.imageThrobber = imageThrobber; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var lightBox = /** @class */ (function () { function lightBox(className, click) { var _this = this; this.scroll = 0; this.show = function () { document.body.appendChild(_this.dom); _this.scroll = (window.pageYOffset !== undefined) ? window.pageYOffset : window.scrollY; if (_this.body_inner) { var style = _this.body_inner.style; style.top = '-' + _this.scroll.toString() + 'px'; style.position = 'fixed'; style.overflow = 'hidden'; style.width = '100vw'; } document.getElementsByTagName('html')[0].style.overflow = 'hidden'; }; this.hide = function () { if (_this.dom.parentElement) { _this.dom.parentElement.removeChild(_this.dom); } if (_this.body_inner) { var style = _this.body_inner.style; style.top = ''; style.position = ''; style.width = ''; window.scrollTo(0, _this.scroll); } document.getElementsByTagName('html')[0].style.overflow = ''; }; this.visible = function () { if (_this.dom.parentElement) { return true; } else { return false; } }; this.OnMouseDown = function (e) { if (e instanceof TouchEvent) { _this.mousedownTarget = e.touches[0].target; } else { _this.mousedownTarget = e.target; } }; this.OnClickLightBox = function (e) { try { if (!_this.click || _this.click(e)) { _this.hide(); } } finally { _this.mousedownTarget = null; } }; var lightBox = document.createElement("div"); var style = lightBox.style; style.position = 'fixed'; style.top = '0px'; style.left = '0px'; style.width = '100vw'; style.height = '100vh'; lightBox.classList.add(className); lightBox.addEventListener(jp.ninesense.ts.devise.pointerEvents.start, this.OnMouseDown); lightBox.addEventListener('click', this.OnClickLightBox); this.click = click; this.body_inner = document.getElementsByClassName('body-inner')[0]; this.dom = lightBox; } Object.defineProperty(lightBox.prototype, "Dom", { get: function () { return this.dom; }, enumerable: true, configurable: true }); Object.defineProperty(lightBox.prototype, "MouseDownTarget", { get: function () { return this.mousedownTarget; }, enumerable: true, configurable: true }); return lightBox; }()); ts.lightBox = lightBox; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var loadingLightBox = /** @class */ (function (_super) { __extends(loadingLightBox, _super); function loadingLightBox() { var _this = _super.call(this, 'ns-loading-lightbox', function () { return false; }) || this; _this.OnLightBoxClick = function (e) { return false; }; var wrap = document.createElement('div'); var throbberW = document.createElement('div'); throbberW.classList.add('throbber'); for (var i = 0; i < 12; i++) { throbberW.appendChild(document.createElement('span')); } wrap.appendChild(throbberW); var message = document.createElement('p'); wrap.appendChild(message); var style = _this.Dom.style; style.zIndex = '999999'; style.backgroundColor = 'rgba(0,0,0,0.7)'; _this.Dom.appendChild(wrap); return _this; } loadingLightBox.getInstance = function () { if (!loadingLightBox.instance) { loadingLightBox.instance = new loadingLightBox(); } return loadingLightBox.instance; }; return loadingLightBox; }(ts.lightBox)); ts.loadingLightBox = loadingLightBox; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var photoSlider = /** @class */ (function () { function photoSlider(selector) { var _this = this; this.cashTags = {}; this.loaderTags = []; this.current = -1; this.loaded = -1; this.currentPage = -1; this.pages = []; this.currentSize = 'full'; this.clickOnNextPage = true; this.clickOnNextIndex = true; this.clickOnPreviousPage = true; this.clickOnPreviousIndex = true; this._useToolSet = true; this.beforeEntry = { page: -1, index: -1 }; this.OnSlided = function () { var index = _this.slider.currentIndex; var pIndex = _this.currentPage; _this.refreshClass(); var entry = (index !== _this.beforeEntry.index || pIndex !== _this.beforeEntry.page); if (entry) { _this.beforeEntry.index = index; _this.beforeEntry.page = pIndex; } if (_this.onEnter) { _this.onEnter(pIndex, index, entry, !_this.slider.sliding); } }; this.refreshClass = function () { if (!_this.slider) return; var max = _this.slider.length - 1; var index = _this.slider.currentIndex; var p = (max === 0) ? 0 : index / max; var current = _this.bar.querySelector(".current"); current.style.transform = 'scaleX(' + p + ')'; var pMax = _this.pages.length - 1; var pIndex = _this.currentPage; var frameClass = _this.frame.classList; if (index !== max) { frameClass.remove('index-max'); } else { frameClass.add('index-max'); } if (index !== 0) { frameClass.remove('index-min'); } else { frameClass.add('index-min'); } if (pIndex !== 0) { frameClass.remove('page-min'); } else { frameClass.add('page-min'); } if (pIndex !== pMax) { frameClass.remove('page-max'); } else { frameClass.add('page-max'); } }; this.setup = function () { var slider = document.createElement("div"); slider.classList.add('photo-slider'); _this.sliderTag = slider; var photo = document.createElement('div'); var controles = document.createElement('div'); _this.photo = photo; photo.classList.add('photo'); controles.classList.add('controles'); photo.appendChild(slider); var left = document.createElement('button'); var right = document.createElement('button'); var left_button = document.createElement('span'); var right_button = document.createElement('span'); left.type = 'button'; right.type = 'button'; left.appendChild(left_button); right.appendChild(right_button); left.classList.add('left'); right.classList.add('right'); var bar = document.createElement('div'); var loading = document.createElement("div"); loading.style.position = "absolute"; loading.style.width = '100%'; loading.style.transform = 'scaleX(0)'; loading.classList.add('loading'); var current = document.createElement("div"); current.style.position = "absolute"; current.style.width = '100%'; current.classList.add('current'); var barset = document.createElement('div'); barset.classList.add('barset'); bar.style.position = "relative"; //bar.style.width = "100%"; bar.appendChild(loading); bar.appendChild(current); bar.classList.add('bar'); bar.addEventListener(jp.ninesense.ts.devise.pointerEvents.start, _this.OnBarMousedown); _this.left = left; _this.right = right; _this.bar = bar; barset.appendChild(left); barset.appendChild(bar); barset.appendChild(right); controles.appendChild(barset); var controlUnder = document.createElement('div'); _this.scaleButton = document.createElement('button'); _this.scaleButton.innerHTML = ''; _this.scaleButton.classList.add('scale'); _this.scaleButton.addEventListener('click', function (e) { var htmlClassList = document.documentElement.classList; var classList = _this.scaleButton.classList; if (!classList.contains('clicked')) { classList.add('clicked'); htmlClassList.add('image-fixed'); } else { classList.remove('clicked'); htmlClassList.remove('image-fixed'); } }); controlUnder.classList.add('toolset'); controlUnder.appendChild(_this.scaleButton); controlUnder.style.width = '100%'; controles.appendChild(controlUnder); _this.toolSet = controlUnder; _this.constols = controles; _this.frame.appendChild(photo); _this.frame.appendChild(controles); //this.show(0); _this.frame.addEventListener("click", _this.OnClick); //if (!jp.ninesense.ts.devise.isSafari) { // this.wheelEnabled = true; //} window.addEventListener("keydown", _this.OnKeydown); _this.createMenu(); _this.setupPage(); _this.photo.addEventListener(jp.ninesense.ts.devise.pointerEvents.start, _this.OnPhotoMouseDown); _this.photo.addEventListener("contextmenu", function (e) { e.preventDefault(); }); //this.photo.addEventListener('click', (e) => { // if (this.isMobile || this.isMiddle) { // if (window.innerWidth < window.innerHeight) { // this.next(true); // } // else { // if (e.pageX < window.innerWidth * 0.5) { // this.previous(true); // } // else { // this.next(true); // } // } // } // else { // this.next(true); // } //}); }; this.photoMouseDown = false; this.photoMouseDownPointX = 0; this.photoMouseMovied = false; this.OnPhotoMouseDown = function (e) { _this.photoMouseMovied = false; var pageX = 0; if (e instanceof MouseEvent) { switch (e.button) { case 0: break; default: return; } pageX = e.pageX; } else { pageX = e.touches[0].pageX; } _this.photoMouseDownPointX = pageX; if (!_this.photoMouseDown) { _this.photoMouseDown = true; window.addEventListener(jp.ninesense.ts.devise.pointerEvents.move, _this.OnPhotoMouseMove); window.addEventListener(jp.ninesense.ts.devise.pointerEvents.end, _this.OnPhotoMouseUp); } }; this.OnPhotoMouseMove = function (e) { var pageX = 0; if (e instanceof MouseEvent) { pageX = e.pageX; } else { pageX = e.touches[0].pageX; } if (Math.abs(_this.photoMouseDownPointX - pageX) > 10) { _this.photoMouseMovied = true; } }; this.OnPhotoMouseUp = function (e) { window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.move, _this.OnPhotoMouseMove); window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.end, _this.OnPhotoMouseUp); try { if (!_this.photoMouseMovied) { var pageIndex = _this.pageIndex; var current = _this.slider.currentIndex; var isLast = _this.slider.isLastIndex; var isStart = _this.slider.currentIndex === 0; var enabledNext = (!isLast && _this.clickOnNextIndex) || (isLast && _this.clickOnNextPage); var enabledPrebious = (!isStart && _this.clickOnPreviousIndex) || (isStart && _this.clickOnPreviousPage); if (_this.isMobile || _this.isMiddle) { if (window.innerWidth < window.innerHeight) { if (enabledNext) { _this.next(true); } } else { if (_this.photoMouseDownPointX < window.innerWidth * 0.5) { if (enabledPrebious) { _this.previous(true); } } else { if (enabledNext) { _this.next(true); } } } } else { if (!e.shiftKey) { if (enabledNext) { _this.next(true); } } else { if (enabledPrebious) { _this.previous(true); } } } if (_this.onClicked) { _this.onClicked(pageIndex, current); } } } finally { _this.photoMouseDown = false; _this.photoMouseMovied = false; } }; this.getImages = function () { var page = _this.pages[_this.currentPage]; var images = _this.images[page]; var isMobile = _this.isMobile; var isMiddle = _this.isMiddle; if (_this.isMobile && images['mobile']) { images = images['mobile']; _this.currentSize = 'mobile'; } else if (_this.isMiddle && images['middle']) { images = images['middle']; _this.currentSize = 'mobile'; } else { images = images['full']; } return images; }; this.getDir = function () { var page = _this.pages[_this.currentPage]; var path; switch (_this.currentSize) { case 'middle': path = _this.folder + page + '/middle/'; break; case 'mobile': path = _this.folder + page + '/mobile/'; break; default: path = _this.folder + page + '/'; } return path; }; this.setupPage = function (page, last) { if (page === void 0) { page = 0; } if (last === void 0) { last = false; } if (page < 0) page = 0; if (_this.pages.length - 1 < page) page = _this.pages.length - 1; if (_this.currentPage === page) return; _this.currentPage = page; _this.frame.classList.remove('show'); _this.loadorder = (last) ? 1 : 0; if (!_this.createBlankImages()) { _this.createLoadImage(_this.getImages()); } if (_this.slider) { if (!last) { _this.slider.showImage(0, false); } else { _this.slider.showImage(_this.slider.length - 1, false); } } setTimeout(function () { _this.frame.classList.add('show'); }, 500); }; this.createMenu = function () { //var menu = document.createElement('div'); //var link_list = document.createElement('ul'); var images = _this.images; var no = -1; for (var index in images) { no++; _this.pages[no] = index; //var link = document.createElement('li'); //link.id = 'menu-link-' + index; //var button = document.createElement('button'); //button.classList.add('menu-link-button'); //button.setAttribute(photoSlider.pageAttr, no.toString()); //button.type = 'button'; //link.appendChild(button); //link_list.appendChild(link); } //menu.appendChild(link_list); ////this.frame.appendChild(menu); }; this.addPage = function (pageIndex, images) { if (images === void 0) { images = []; } if (_this.images[pageIndex]) return false; _this.pages[_this.pages.length] = pageIndex; _this.images[pageIndex] = { full: images }; return true; }; this.createBlankImages = function () { var images = _this.getImages(); var isMobile = _this.isMobile; var isMiddle = _this.isMiddle; if (isMiddle) { w = 768; h = 768; } else if (isMobile) { w = 566; h = 566; } else { w = 1045; h = 1045; } var len = images.length; var w; var h; if (!photoSlider.blankImage) { photoSlider.blankImage = jp.ninesense.ts.imageResource.createFillImage(w, h, 'white', false); } var blank = photoSlider.blankImage; var isCash = false; var cash; if (_this.cashTags[_this.currentPage]) { cash = _this.cashTags[_this.currentPage]; _this.sliderTag.innerHTML = ''; for (var i = 0; i < len; i++) { _this.sliderTag.appendChild(cash[i]); } isCash = true; _this.loaded = len; } else { //cash = []; //this.cashTags[this.currentPage] = cash; //this.sliderTag.innerHTML = ''; var slider = _this.sliderTag; for (var i = 0; i < len; i++) { //if (!this.images[this.loaded + 1]) break; if (!_this.loaderTags[i]) { var load = document.createElement('img'); load.classList.add('load-image'); load.src = blank; load.id = 'load-image-' + (i + 1).toString(); load.width = w; load.height = h; var imgDiv = document.createElement('div'); imgDiv.classList.add('blank'); imgDiv.appendChild(load); imgDiv.classList.add('current-image'); imgDiv.setAttribute(jp.ninesense.ts.imageSlider.attr, (i + 1).toString()); slider.appendChild(imgDiv); _this.loaderTags[i] = imgDiv; } else { var imgDiv = _this.loaderTags[i]; imgDiv.classList.add('blank'); var load = imgDiv.firstChild; load.src = blank; if (!imgDiv.parentElement) { slider.appendChild(imgDiv); } } //cash.push(imgDiv); } var cLen = _this.loaderTags.length; for (var i = len; i < cLen; i++) { var imgDiv = _this.loaderTags[i]; if (imgDiv.parentElement) { var load = imgDiv.firstChild; load.src = blank; slider.removeChild(imgDiv); } } _this.loaded = -1; } if (!_this.slider) { _this.slider = new jp.ninesense.ts.imageSlider('.photo-slider', '.photo-slider', null, null, false, false); _this.slider.backgroundMoveAcc = 0.1; _this.slider.backgroundMoveMin = 0; _this.slider.autoSlide = false; _this.slider.onSliding = _this.OnSlided; _this.slider.onSlided = _this.OnSlided; } else { _this.slider.refreshChildren(); } return isCash; }; this.loadorder = loadorder.asc; this.createLoadImage = function (images) { var path = _this.getDir(); var load; while (!load || load.complete) { if (!images[_this.loaded + 1]) break; var target; switch (_this.loadorder) { case loadorder.desc: target = images.length - 1 - _this.loaded; if (!images[target - 1]) break; target--; break; default: target = _this.loaded; if (!images[target + 1]) break; target++; } _this.loaded++; var imgDiv = _this.loaderTags[target]; if (_this.loaded === 0) { imgDiv.classList.add('active'); } var load = imgDiv.firstChild; load.addEventListener("load", _this.OnImageLoad); var set = images[target]; load.width = set.width; load.height = set.height; load.src = path + set.url; _this.refreshSizeMethod(target); } if (_this.onCreatedLoadImages) { _this.onCreatedLoadImages(_this.currentPage); } }; this.refreshSizeMethod = function (no) { var imgDiv = _this.loaderTags[no]; if (!imgDiv) return; var set = _this.getImages()[no]; if (!set) return; var ph = window.innerHeight / window.innerWidth; if (set.width < set.height) { imgDiv.classList.add('size-portrait'); imgDiv.classList.remove('size-landscape'); } else { imgDiv.classList.remove('size-portrait'); imgDiv.classList.add('size-landscape'); } if (set.height / set.width > ph) { imgDiv.classList.add('scale-y'); imgDiv.classList.remove('scale-x'); } else { imgDiv.classList.add('scale-x'); imgDiv.classList.remove('scale-y'); } }; this.OnImageLoad = function (e) { var img = e.currentTarget; var len = _this.slider.length; var load; img.parentElement.classList.remove('blank'); e.currentTarget.removeEventListener('load', _this.OnImageLoad); _this.createLoadImage(_this.getImages()); var p = (_this.loaded + 1) / len; var loading = _this.bar.querySelector(".loading"); loading.style.transform = 'scaleX(' + p + ')'; }; this.ShowFromXPoint = function (x) { if (_this.slider) { var rect = _this.bar.getBoundingClientRect(); var index = Math.floor(_this.slider.length * (x - rect.left) / rect.width); _this.slider.showImage(index, false); } }; this.OnBarMousedown = function (e) { e.preventDefault(); if (_this.bar.contains(e.target)) { var pageX = 0; if (e instanceof MouseEvent) { pageX = e.pageX; } else { pageX = e.touches[0].pageX; } _this.ShowFromXPoint(pageX); if (!_this.mousedown) { _this.mousedown = true; window.addEventListener(jp.ninesense.ts.devise.pointerEvents.move, _this.OnBarMouseMove); window.addEventListener(jp.ninesense.ts.devise.pointerEvents.end, _this.OnBarMouseup); } } }; this.OnBarMouseup = function (e) { window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.move, _this.OnBarMouseMove); window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.end, _this.OnBarMouseup); _this.mousedown = false; //var pageX = 0; //if (e instanceof TouchEvent) { // pageX = e.touches[0].pageX; //} //else { // pageX = e.pageX; //} //this.ShowFromXPoint(pageX); }; this.OnBarMouseMove = function (e) { var pageX = 0; if (e instanceof MouseEvent) { pageX = e.pageX; } else { pageX = e.touches[0].pageX; } _this.ShowFromXPoint(pageX); }; this._wheelEnabled = false; this.onWheel = 0; this.OnMouseWheel = function (e) { e.preventDefault(); //if (this.onWheel) return; //this.WheelCount(e, e.wheelDelta); if (e.deltaY < 0) { _this.previous(); } else { _this.next(); } }; //private wheelIndex = 0; //private wheelDelay = 1000; //private wheelTimer; //private WheelCount = (eo:MouseEvent, delta:number) => { // if (delta === -1) { // this.wheelEnabled = false; // console.log('下'); // this.wheelIndex++; // if (this.wheelIndex >= boxes.length - 1) { // this.wheelIndex = boxes.length - 1 // } // changeBox(this.wheelIndex); // this.wheelTimer = setInterval(allowCount, this.wheelDelay); // } // if (delta === 1) { // this.wheelEnabled = false; // console.log('上'); // this.wheelIndex--; // if (this.wheelIndex < 0) { // this.wheelIndex = 0 // } // changeBox(this.wheelIndex); // this.wheelTimer = setInterval(allowCount, this.wheelDelay); // } // function allowCount() { // console.log('go!'); // //ホイールを検知の再登録 // $(document).on("mousewheel", function (eo, delta, deltaX, deltaY) { // console.log('mousewheel'); // count(eo, delta) // }) // clearInterval(timer) // } //} this.OnKeydown = function (e) { switch (e.keyCode) { case 33: //PAGEUP _this.setupPage(_this.currentPage - 1, true); break; case 34: //PAGEDOWN _this.setupPage(_this.currentPage + 1); break; case 35: //END _this.slider.showImage(_this.loaded, true); //this.OnSlided(); break; case 36: //HOME _this.slider.showImage(0, true); //this.OnSlided(); break; case 37: //← case 38: //↑ _this.previous(); break; case 13: //Enter case 39: //→ case 40: //↓ if (!e.shiftKey) { _this.next(); } else { _this.previous(); } break; } }; this.OnClick = function (e) { var target = e.target; switch (true) { case _this.left === target || _this.left.contains(target): _this.previous(true); break; case _this.right === target || _this.right.contains(target): _this.next(true); break; default: //if (this.list.contains(target)) { // var index = parseInt(target.getAttribute(photoSlider.indexAttr)); // if (!isNaN(index)) { // this.show(index); // } //} } }; this.next = function (page) { if (page === void 0) { page = false; } if (_this.slider) { if (!_this.slider.isLastIndex) { _this.slider.next(true); //this.OnSlided(); } else if (page) { _this.setupPage(_this.currentPage + 1); } } }; this.previous = function (page) { if (page === void 0) { page = false; } if (_this.slider) { if (_this.slider.currentIndex > 0) { _this.slider.previous(true); //this.OnSlided(); } else if (page) { _this.setupPage(_this.currentPage - 1, true); } } }; var frame = document.querySelector(selector); if (!frame) return; this.isMobile = jp.ninesense.ts.devise.isMobile; this.isMiddle = jp.ninesense.ts.devise.isiPad || jp.ninesense.ts.devise.isAndroidTablet; var displayRotate = function () { if (window.innerWidth <= window.innerHeight) { document.documentElement.classList.remove('landscape'); document.documentElement.classList.add('portrait'); } else { document.documentElement.classList.remove('portrai'); document.documentElement.classList.add('landscape'); } if (_this.slider) { var cnt = _this.slider.length; for (var i = 0; i < cnt; i++) { _this.refreshSizeMethod(i); } } }; displayRotate(); window.addEventListener('resize', displayRotate); this.mousedown = false; this.frame = frame; var folder = decodeURIComponent(frame.getAttribute(photoSlider.folderAttr)); var sorce = decodeURIComponent(frame.getAttribute(photoSlider.imagesAttr)); var images = JSON.parse(sorce); var cnt = images.length; this.images = images; this.folder = folder; this.setup(); frame.removeAttribute(photoSlider.folderAttr); frame.removeAttribute(photoSlider.imagesAttr); if (this.isMobile) { document.documentElement.classList.add('mobile'); } if (this.isMiddle) { document.documentElement.classList.add('middle'); } this.OnSlided(); } Object.defineProperty(photoSlider.prototype, "imageSlider", { get: function () { return this.slider; }, enumerable: true, configurable: true }); Object.defineProperty(photoSlider.prototype, "index", { get: function () { return this.current; }, enumerable: true, configurable: true }); Object.defineProperty(photoSlider.prototype, "pageLength", { get: function () { return this.pages.length; }, enumerable: true, configurable: true }); Object.defineProperty(photoSlider.prototype, "pageIndex", { get: function () { return this.currentPage; }, enumerable: true, configurable: true }); photoSlider.prototype.getImageInfo = function (page, index, size) { if (size === void 0) { size = "full"; } var p = this.pages[page]; var imgs = this.images[p]; var images = imgs[size]; if (!images) { size = 'full'; images = imgs['full']; } var info = images[index]; if (info) { var dir = '/'; switch (size) { case 'middle': case 'mobile': dir = '/' + size + '/'; } return { url: this.folder + p + dir + info.url, width: info.width, height: info.height }; } }; Object.defineProperty(photoSlider.prototype, "useToolSet", { get: function () { return this._useToolSet; }, set: function (value) { if (this._useToolSet === value) return; this._useToolSet = value; if (value) { this.constols.appendChild(this.toolSet); } else { this.constols.removeChild(this.toolSet); } }, enumerable: true, configurable: true }); Object.defineProperty(photoSlider.prototype, "wheelEnabled", { get: function () { return this._wheelEnabled; }, set: function (value) { if (this._wheelEnabled === value) return; this._wheelEnabled = value; if (value) { this.frame.addEventListener("mousewheel", this.OnMouseWheel); } else { this.frame.removeEventListener("mousewheel", this.OnMouseWheel); } }, enumerable: true, configurable: true }); photoSlider.folderAttr = 'data-ns-photopanel-folder'; photoSlider.imagesAttr = 'data-ns-photopanel-files'; photoSlider.indexAttr = 'data-ns-photopanel-index'; photoSlider.pageAttr = 'data-ns-photopanel-page'; return photoSlider; }()); ts.photoSlider = photoSlider; var loadorder; (function (loadorder) { loadorder[loadorder["asc"] = 0] = "asc"; loadorder[loadorder["desc"] = 1] = "desc"; })(loadorder || (loadorder = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var popupBox = /** @class */ (function () { function popupBox() { var _this = this; this.scroll = 0; this.stack = []; this.lock = false; //public get Dom():HTMLDivElement { // return this.dom; //} this.OnMouseMove = function (e) { _this.crearTimeout(); }; this.showMessageBox = function (key, message, error, autocloseTime, click) { if (error === void 0) { error = false; } if (autocloseTime === void 0) { autocloseTime = -1; } if (click === void 0) { click = null; } var content = ''; _this.show(key, content, 'popup-message-box' + ((error) ? ' error-message' : ''), false, function (e) { var target = e.target; if (target.id === 'close-popup-message') return true; if (click) { return click(e); } return false; }, autocloseTime); }; this.show = function (key, content, className, lock, click, autocloseTime) { if (click === void 0) { click = null; } if (autocloseTime === void 0) { autocloseTime = -1; } if (_this.dom.parentElement) { if (key !== _this.currentID) { _this.stack.push({ id: key, content: content, className: className, lock: lock, click: click, autocloseTime: autocloseTime }); return false; } else { content = _this.inner.innerHTML + content; } } _this.dom.className = className; _this.dom.classList.add('wrap'); var style = _this.dom.style; _this.lock = lock; if (lock) { style.top = '0px'; style.left = '0px'; style.right = '0px'; style.bottom = '0px'; style.width = '100vw'; style.height = '100vh'; _this.scroll = (window.pageYOffset !== undefined) ? window.pageYOffset : window.scrollY; if (_this.body_inner) { var style_1 = _this.body_inner.style; style_1.top = '-' + _this.scroll.toString() + 'px'; style_1.position = 'fixed'; style_1.overflow = 'hidden'; style_1.width = '100vw'; } document.getElementsByTagName('html')[0].style.overflow = 'hidden'; } else { style.top = 'auto'; style.left = 'auto'; style.right = '0px'; style.bottom = '0px'; style.width = 'auto'; style.height = 'auto'; } _this.click = click; _this.inner.innerHTML = content; document.body.appendChild(_this.dom); _this.currentID = key; if (autocloseTime > 0) { if (!isNaN(_this.timeout)) clearTimeout(_this.timeout); _this.entryTimeout(function () { if (_this.currentID === key) { _this.dom.classList.add('hide'); _this.entryTimeout(function () { if (_this.currentID === key) { _this.next(); } }, 300); } }, autocloseTime - 300); } else { _this.crearTimeout(); } return true; }; this.hide = function () { if (_this.dom.parentElement) { _this.dom.parentElement.removeChild(_this.dom); } if (_this.lock) { if (_this.body_inner) { var style = _this.body_inner.style; style.top = ''; style.position = ''; style.width = ''; window.scrollTo(0, _this.scroll); } document.getElementsByTagName('html')[0].style.overflow = ''; } }; this.next = function () { _this.hide(); var dt = _this.stack.shift(); if (dt) { _this.entryTimeout(function () { var clickCallback; while (_this.stack[0] && _this.stack[0].id === dt.id && _this.stack[0].className === dt.className && _this.stack[0].lock === dt.lock) { var ndt = _this.stack.shift(); dt.content += ndt.content; if (dt.autocloseTime > 0 && ndt.autocloseTime > 0) { dt.autocloseTime += ndt.autocloseTime; } else { dt.autocloseTime = -1; } if (!clickCallback) { clickCallback = [dt.click]; } clickCallback.push(ndt.click); } if (dt.autocloseTime > 10000) dt.autocloseTime = 10000; dt.click = function (e) { if (clickCallback) { var len = clickCallback.length; for (var i = 0; i < len; i++) { if (!clickCallback[i](e)) { return false; } } } return true; }; _this.show(dt.id, dt.content, dt.className, dt.lock, dt.click, dt.autocloseTime); }, 1); } }; this.timeout = NaN; this.entryTimeout = function (callStack, timeout) { if (!isNaN(_this.timeout)) clearTimeout(_this.timeout); _this.timeout = setTimeout(function () { _this.timeout = NaN; callStack(); }, timeout); }; this.crearTimeout = function () { if (!isNaN(_this.timeout)) clearTimeout(_this.timeout); _this.timeout = NaN; }; this.visible = function () { if (_this.dom.parentElement) { return true; } else { return false; } }; this.OnClickPopupBox = function (e) { if (!_this.click || _this.click(e)) { _this.next(); } }; var popupBox = document.createElement("div"); var style = popupBox.style; style.position = 'fixed'; style.minWidth = '100px'; style.minHeight = '70px'; style.zIndex = '999999'; var view = document.createElement('div'); view.classList.add('view'); var inner = document.createElement('div'); inner.classList.add('inner'); view.appendChild(inner); popupBox.appendChild(view); view.addEventListener("click", this.OnClickPopupBox); view.addEventListener("mousemove", this.OnMouseMove); this.body_inner = document.getElementsByClassName('body-inner')[0]; this.dom = popupBox; this.inner = inner; } popupBox.getInstance = function () { if (!popupBox.instance) { popupBox.instance = new popupBox(); } return popupBox.instance; }; return popupBox; }()); ts.popupBox = popupBox; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var scrollBox = /** @class */ (function () { /** * 指定コンテンツを囲うデザイン可能なスクロールバーを有するスクロールボックスを作成します * @param content コンテンツ * @param classPrefix スクロールボックス各要素に付くカスタムクラス名の先頭に付くプレフィックスを指定します。 * @param boxHeight ボックスの高さを指定します。指定しない場合はCSSで.ns-scrollbox-scrollTargetに高さを指定します */ function scrollBox(content, classPrefix, boxHeight) { var _this = this; if (classPrefix === void 0) { classPrefix = 'ns'; } if (boxHeight === void 0) { boxHeight = null; } this._mouseMoveEnabled = false; this._mouseEndEnabled = false; this.OnMouseMove = function (e) { e.preventDefault(); var my = 0; if (e instanceof TouchEvent) { my = e.touches[0].pageY; } else { my = e.pageY; } //this.scrollBarTo(y); var barWrapRect = _this.scrollBox.getBoundingClientRect(); _this.mousedownY = my - barWrapRect.top - window.scrollY; _this.reflesh(); }; this.OnMouseEnd = function (e) { _this.mouseMoveEnabled = false; _this.mouseEndEnabled = false; }; this.scrollBarTo = function (boxY) { var h_WP = _this.scrollTarget.getBoundingClientRect().height; var h_UL = _this.scrollContents.getBoundingClientRect().height; var rect_SC = _this.scrollBox.getBoundingClientRect(); boxY -= rect_SC.top + window.scrollY; var h_SC = rect_SC.height; var p = (h_UL - h_WP) * boxY / h_SC; _this.scrollTarget.scrollTo({ top: p }); }; this.mousedownY = 0; this.bardownPositionY = 0; this.scroll = function (scrollOption) { _this.scrollTarget.scroll(scrollOption); }; this.scrollShowRect = function (rect, method) { if (method === void 0) { method = 'nearly'; } var listRect = _this.scrollWrap.getBoundingClientRect(); switch (method) { case 'nearly': if (listRect.bottom < rect.bottom) { _this.scroll({ top: (rect.top - (listRect.top - _this.scrollTarget.scrollTop)) - (listRect.height - rect.height) }); } else if (listRect.top > rect.top) { _this.scroll({ top: rect.top - (listRect.top - _this.scrollTarget.scrollTop) }); } break; case 'center': _this.scroll({ top: (rect.top - (listRect.top - _this.scrollTarget.scrollTop)) - (listRect.height - rect.height) * 0.5 }); break; } }; this.reflesh = function () { var wrap = _this.scrollTarget; var ul = _this.scrollContents; var bar = _this.scrollBox; var scrollBar = _this.scrollBar; var boxRect = wrap.getBoundingClientRect(); var contentRect = ul.getBoundingClientRect(); var barRect = bar.getBoundingClientRect(); var mRect = _this.scrollBoxmjur.getBoundingClientRect(); var barWidth = boxRect.width - mRect.width; if (barWidth < 0) barWidth = 0; wrap.style.width = 'calc(100% + ' + barWidth.toString() + 'px)'; var max = contentRect.height - boxRect.height; if (max <= 0 || barWidth === 0) { bar.style.opacity = '0'; } else { bar.style.opacity = '1'; var barHeight = barRect.height * boxRect.height / wrap.scrollHeight; scrollBar.style.height = barHeight.toString() + 'px'; if (!_this.mouseMoveEnabled) { scrollBar.style.transform = 'translateY(' + (wrap.scrollTop * (barRect.height - barHeight) / (wrap.scrollHeight - boxRect.height)).toString() + 'px)'; } else { var bardownPositionY = _this.bardownPositionY; var barPos = _this.mousedownY - bardownPositionY * barHeight; if (barPos < 0) barPos = 0; if (barRect.height - barHeight < barPos) barPos = barRect.height - barHeight; scrollBar.style.transform = 'translateY(' + barPos.toString() + 'px)'; wrap.scrollTo({ top: (wrap.scrollHeight - boxRect.height) * barPos / (barRect.height - barHeight) }); } } }; var parent = content.parentElement; var wrap = document.createElement('div'); var mjur = document.createElement('div'); var scrollBox = document.createElement('div'); var scrollTarget = document.createElement('div'); mjur.style.display = 'block'; mjur.style.width = '100%'; scrollTarget.appendChild(mjur); scrollTarget.appendChild(content); scrollBox.appendChild(scrollTarget); wrap.appendChild(scrollBox); wrap.classList.add('ns-scrollbox-list'); scrollBox.classList.add('ns-scrollbox-scrollBox'); scrollTarget.classList.add('ns-scrollbox-scrollTarget'); wrap.classList.add(classPrefix + '-list'); scrollBox.classList.add(classPrefix + '-scrollBox'); scrollTarget.classList.add(classPrefix + '-scrollTarget'); var scrollWrap = document.createElement('div'); var scrollBox = document.createElement('div'); var scrollBar = document.createElement('div'); scrollWrap.className = 'ns-scrollbox-list-scroll-wrap ' + classPrefix + '-list-scroll-wrap'; scrollBox.className = 'ns-scrollbox-list-scroll-box ' + classPrefix + '-list-scroll-box'; scrollBar.className = 'ns-scrollbox-list-scroll-bar ' + classPrefix + '-list-scroll-bar'; scrollWrap.appendChild(scrollBox); scrollBox.appendChild(scrollBar); wrap.appendChild(scrollWrap); scrollTarget.addEventListener('scroll', function () { if (_this.mouseMoveEnabled) return; _this.reflesh(); }); scrollWrap.addEventListener('wheel', function (e) { e.preventDefault(); scrollTarget.scrollTo({ top: scrollTarget.scrollTop + e.deltaY }); }); scrollWrap.addEventListener(jp.ninesense.ts.devise.pointerEvents.start, function (e) { e.preventDefault(); var my = 0; if (e instanceof TouchEvent) { my = e.touches[0].pageY; } else { my = e.pageY; } var barWrapRect = scrollBox.getBoundingClientRect(); var barRect = scrollBar.getBoundingClientRect(); var barDownPosY = my - barRect.top - window.scrollY; if (barDownPosY < 0 || barRect.height < barDownPosY) { var rect_SB = _this.scrollBar.getBoundingClientRect(); var h_SC = rect_SB.height; _this.scrollBarTo(my); barDownPosY = my - barRect.top - window.scrollY; } _this.bardownPositionY = ts.MathBit.floor(barDownPosY / barRect.height * 100) * 0.01; _this.mousedownY = my - barWrapRect.top - window.scrollY; _this.mouseMoveEnabled = true; _this.mouseEndEnabled = true; }); this.scrollTarget = scrollTarget; this.scrollBoxmjur = mjur; this.scrollContents = content; this.scrollBox = scrollBox; this.scrollBar = scrollBar; this.scrollWrap = wrap; if (parent) { parent.appendChild(wrap); } this.reflesh(); } Object.defineProperty(scrollBox.prototype, "mouseMoveEnabled", { get: function () { return this._mouseMoveEnabled; }, set: function (value) { if (this._mouseMoveEnabled === value) return; this._mouseMoveEnabled = value; if (value) { window.addEventListener(jp.ninesense.ts.devise.pointerEvents.move, this.OnMouseMove); } else { window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.move, this.OnMouseMove); } }, enumerable: true, configurable: true }); Object.defineProperty(scrollBox.prototype, "mouseEndEnabled", { get: function () { return this._mouseEndEnabled; }, set: function (value) { if (this._mouseEndEnabled === value) return; this._mouseEndEnabled = value; if (value) { window.addEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnMouseEnd); } else { window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnMouseEnd); } }, enumerable: true, configurable: true }); Object.defineProperty(scrollBox.prototype, "dom", { //public scrollBarLocal = (y: number) => { // var h_WP = this.scrollTarget.getBoundingClientRect().height; // var h_UL = this.scrollContents.getBoundingClientRect().height; // var rect_SW = this.scrollBox.getBoundingClientRect(); // localY -= rect_SW.top; // var p = localY // this.scrollTarget.scrollTo({ top: p }); //} get: function () { return this.scrollWrap; }, enumerable: true, configurable: true }); scrollBox.instance = []; /** * コンテンツをクエリで指定してデザイン可能なスクロールバーを有するスクロールボックスを作成します * @param content コンテンツを指定するためのCSSクエリ * @param classPrefix スクロールボックス各要素に付くカスタムクラス名の先頭に付くプレフィックスを指定します。 * @param boxHeight ボックスの高さを指定します。指定しない場合はCSSで.ns-scrollbox-scrollTargetに高さを指定します */ scrollBox.init = function (selector, classPrefix, boxHeight) { if (classPrefix === void 0) { classPrefix = 'ns'; } if (boxHeight === void 0) { boxHeight = null; } var contents = document.querySelectorAll(selector); var len = contents.length; for (var i = 0; i < len; i++) { new scrollBox(contents[i], classPrefix, boxHeight); } }; return scrollBox; }()); ts.scrollBox = scrollBox; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var switchBox = /** @class */ (function () { function switchBox(selector) { var _this = this; this.switchGroup = {}; this._length = 0; this.Setup = function () { var switchElements = document.querySelectorAll(_this.selector); var len = switchElements.length; _this._length = len; for (var i = 0; i < len; i++) { var element = switchElements[i]; var group = element.getAttribute(switchBox.GROUP_ID); if (_this.switchGroup[group]) { _this.switchGroup[group].push(element); } else { _this.switchGroup[group] = [element]; } element.draggable = true; element.addEventListener('dragstart', _this.OnDragStert); element.addEventListener('dragend', _this.OnDragEnd); element.addEventListener('dragenter', _this.OnDragEnter); element.addEventListener('dragleave', _this.OnDragLeave); element.addEventListener('dragover', _this.OnDragOver); element.addEventListener('drop', _this.OnDrop); element.setAttribute(switchBox.STYLE_ID, element.style.border); element.style.cursor = 'move'; } }; this.Clear = function () { var oldGroupList = _this.switchGroup; for (var group in oldGroupList) { var elements = oldGroupList[group]; var len = elements.length; for (var i = 0; i < len; i++) { var element = elements[i]; if (_this.switchGroup[group]) { _this.switchGroup[group].push(element); } else { _this.switchGroup[group] = [element]; } element.draggable = false; element.removeEventListener('dragstart', _this.OnDragStert); element.removeEventListener('dragend', _this.OnDragEnd); element.removeEventListener('dragenter', _this.OnDragEnter); element.removeEventListener('dragleave', _this.OnDragLeave); element.removeEventListener('dragover', _this.OnDragOver); element.removeEventListener('drop', _this.OnDrop); element.setAttribute(switchBox.STYLE_ID, ''); element.style.cursor = 'auto'; } } _this.switchGroup = {}; _this._length = 0; }; this.Refresh = function () { _this.Clear(); _this.Setup(); }; this.OnDragStert = function (e) { var element = e.currentTarget; element.style.border = '1px dashed rgba(0,0,0,0.3)'; _this.current = element; _this.currentGroupID = element.getAttribute(switchBox.GROUP_ID); _this.dispatchEvent(new DragEvent(e.type, { dataTransfer: e.dataTransfer })); }; this.OnDrop = function (e) { var element = e.currentTarget; element.style.border = element.getAttribute(switchBox.STYLE_ID); var current = _this.current; current.style.border = _this.current.getAttribute(switchBox.STYLE_ID); var en = element.nextElementSibling; var ep = element.parentElement; var cn = current.nextElementSibling; var cp = current.parentElement; if (en) ep.insertBefore(_this.current, en); else ep.appendChild(_this.current); if (cn) cp.insertBefore(element, cn); else cp.appendChild(element); var eno = element.getAttribute(switchBox.ELEMENT_NO); var cno = current.getAttribute(switchBox.ELEMENT_NO); current.setAttribute(switchBox.ELEMENT_NO, eno); element.setAttribute(switchBox.ELEMENT_NO, cno); _this.droptarget = element; _this.dispatchEvent(new DragEvent(e.type, { dataTransfer: e.dataTransfer })); _this.droptarget = null; _this.current = null; }; this.OnDragEnd = function (e) { var element = e.currentTarget; element.style.border = element.getAttribute(switchBox.STYLE_ID); _this.dispatchEvent(new DragEvent(e.type, { dataTransfer: e.dataTransfer })); }; this.OnDragEnter = function (e) { var element = e.currentTarget; var related = _this.current; if (!related || !element) return; if (_this.current === element) return; //window.console.log(e.currentTarget); if (related.getAttribute(switchBox.GROUP_ID) !== element.getAttribute(switchBox.GROUP_ID)) { e.preventDefault(); return; } element.style.border = '1px dashed rgba(255,0,0,0.3)'; _this.dispatchEvent(new DragEvent(e.type, { dataTransfer: e.dataTransfer })); }; this.OnDragLeave = function (e) { var element = e.currentTarget; if (element === _this.current) return; element.style.border = element.getAttribute(switchBox.STYLE_ID); _this.dispatchEvent(new DragEvent(e.type, { dataTransfer: e.dataTransfer })); }; this.OnDragOver = function (e) { if (e.preventDefault) { e.preventDefault(); // Necessary. Allows us to drop. } var element = e.currentTarget; e.dataTransfer.dropEffect = 'none'; // See the section on the DataTransfer object. if (!_this.current || !element) return; if (_this.current === element) return; if (_this.current.getAttribute(switchBox.GROUP_ID) !== element.getAttribute(switchBox.GROUP_ID)) { e.preventDefault(); return; } e.dataTransfer.dropEffect = 'move'; // See the section on the DataTransfer object. _this.dispatchEvent(new DragEvent(e.type, { dataTransfer: e.dataTransfer })); return false; }; this.selector = selector; try { this.target = new EventTarget(); } catch (ex) { window.console.log('switchBox : EventTargetのコンストラクタを実装していません。'); this.target = window; } this.Setup(); } Object.defineProperty(switchBox.prototype, "length", { get: function () { return this._length; }, enumerable: true, configurable: true }); Object.defineProperty(switchBox.prototype, "DragTarget", { get: function () { return this.current; }, enumerable: true, configurable: true }); Object.defineProperty(switchBox.prototype, "DropTarget", { get: function () { return this.droptarget; }, enumerable: true, configurable: true }); Object.defineProperty(switchBox.prototype, "CurrentTargets", { get: function () { return this.switchGroup[this.currentGroupID]; }, enumerable: true, configurable: true }); Object.defineProperty(switchBox.prototype, "CurrentGroupID", { get: function () { return this.currentGroupID; }, enumerable: true, configurable: true }); switchBox.prototype.addEventListener = function (type, listener, options) { this.target.addEventListener(type, listener, options); }; switchBox.prototype.dispatchEvent = function (evt) { return this.target.dispatchEvent(evt); }; switchBox.prototype.removeEventListener = function (type, listener, options) { this.target.removeEventListener(type, listener, options); }; switchBox.GROUP_ID = 'data-ns-switchbox'; switchBox.ELEMENT_NO = 'data-ns-switchbox-no'; switchBox.STYLE_ID = 'data-ns-switchbox-style'; return switchBox; }()); ts.switchBox = switchBox; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var headAttr; var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var template; (function (template_1) { var dom = /** @class */ (function () { function dom() { } dom.createTableExFrame = function (title, inner, toggle, dismiss, editorPrefix) { if (toggle === void 0) { toggle = true; } if (dismiss === void 0) { dismiss = true; } if (editorPrefix === void 0) { editorPrefix = 'card'; } var dom = document.createElement('section'); dom.classList.add('ns-table-frame'); dom.classList.add(editorPrefix); var header = document.createElement('header'); header.classList.add(editorPrefix + '-header'); var action = document.createElement('div'); action.classList.add(editorPrefix + '-actions'); header.appendChild(action); if (dismiss) { var action_a = document.createElement('a'); action_a.href = '#'; action_a.className = editorPrefix + '-action ' + editorPrefix + '-action-dismiss'; action_a.setAttribute('data-' + editorPrefix + '-toggle', ''); action.appendChild(action_a); } if (toggle) { var action_a = document.createElement('a'); action_a.href = '#'; action_a.className = editorPrefix + '-action ' + editorPrefix + '-action-toggle'; action_a.setAttribute('data-' + editorPrefix + '-toggle', ''); action.appendChild(action_a); } var h2 = document.createElement('h2'); h2.className = editorPrefix + '-title'; h2.innerHTML = title; header.appendChild(h2); var body = document.createElement('div'); body.className = editorPrefix + "-body advanced"; var caption = document.createElement('div'); caption.className = "row " + editorPrefix + "-caption"; body.appendChild(caption); inner.classList.add(editorPrefix + "-body-inner"); body.appendChild(inner); dom.appendChild(header); dom.appendChild(body); return dom; }; dom.createTableExBase = function (tableID, header, data) { var wrap = document.createElement('div'); wrap.className = "table-advanced"; var table = document.createElement('table'); table.className = "table table-bordered table-striped mb-none"; table.id = tableID; var thead = document.createElement('thead'); var len = header.length; if (len > 0) { for (var i = 0; i < len; i++) { var headData = header[i]; var recode = document.createElement('tr'); for (var field in headData) { var text = headData[field]; var th = document.createElement('th'); th.classList.add('h-' + field); th.classList.add('h-title'); if (typeof (text) === 'string') { th.innerHTML = text; } else { th.innerHTML = text.title; if (text.rspan) th.rowSpan = text.rspan; if (text.cspan) th.colSpan = text.cspan; if (text.class) th.classList.add(text.class); } recode.appendChild(th); } thead.appendChild(recode); } } table.appendChild(thead); var recodeWrap; if (len === 1) { recodeWrap = document.createElement('tbody'); table.appendChild(recodeWrap); } else { recodeWrap = table; } if (!data['{temp}']) { data['{temp}'] = {}; } for (var id in data) { var recodeData = data[id]; var recode_1 = void 0; if (len === 1) { recode_1 = document.createElement('tr'); } else { recode_1 = document.createElement('tbody'); } recode_1.id = "id-" + id; recode_1.classList.add('ns-recode'); for (var i = 0; i < len; i++) { var headData = header[i]; var row; if (len === 1) { row = recode_1; } else { row = document.createElement('tr'); recode_1.appendChild(row); } for (var field in headData) { var text_1 = recodeData[field]; if (!text_1) { text_1 = ' '; } var td = document.createElement('td'); td.classList.add('c-' + field); td.setAttribute('data-ns-search', text_1); var c_title = document.createElement('span'); var c_body = document.createElement('div'); var c_ui = document.createElement('span'); c_title.className = 'c-title'; var template = headData[field]; if (typeof (template) === 'string') { c_title.innerHTML = template; } else { c_title.innerHTML = template.title; if (template.rspan) td.rowSpan = template.rspan; if (template.cspan) td.colSpan = template.cspan; if (template.class) td.classList.add(template.class); } c_body.className = 'c-body'; c_body.innerHTML = text_1; c_ui.className = 'c-ui'; td.appendChild(c_title); td.appendChild(c_body); td.appendChild(c_ui); row.appendChild(td); } } if (id !== '{temp}') { recodeWrap.appendChild(recode_1); } else { var tmpTBody = document.createElement('tbody'); tmpTBody.appendChild(recode_1); thead.setAttribute('data-ns-row-temp', tmpTBody.innerHTML); } } wrap.appendChild(table); return wrap; }; dom.createSVG = function (viewBox, attr) { if (viewBox === void 0) { viewBox = '0 0 100 100'; } if (attr === void 0) { attr = { x: "0px", y: "0px" }; } var mySvg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); // mySvg.setAttribute("version", "1.1"); mySvg.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); mySvg.setAttribute("x", "0px"); mySvg.setAttribute("y", "0px"); mySvg.setAttribute("viewBox", viewBox); mySvg.setAttribute("style", "enable-background:new " + viewBox + ";"); mySvg.setAttribute("xml:space", "preserve"); for (var param in attr) { mySvg.setAttribute(param, attr[param]); } return mySvg; }; dom.addViewInner = function (target, viewTag, innerTag) { if (viewTag === void 0) { viewTag = 'div'; } if (innerTag === void 0) { innerTag = 'div'; } var view = document.createElement(viewTag); view.classList.add('view'); var inner = document.createElement(innerTag); inner.classList.add('inner'); view.appendChild(inner); target.appendChild(view); target.classList.add('wrap'); return { view: view, inner: inner }; }; return dom; }()); template_1.dom = dom; })(template = ts.template || (ts.template = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var customInputs = /** @class */ (function () { function customInputs(input) { var id = input.id; if (id === '') { customInputs.autoNo++; id = customInputs.autoNo.toString(); } customInputs.instanceList[id] = this; this._input = input; input.setAttribute('data-ns-custominputs-id', id); } customInputs.prototype.id = function () { return this._input.getAttribute('data-ns-custominputs-id'); }; customInputs.prototype.input = function () { return this._input; }; customInputs.getInstance = function (input) { return customInputs.instanceList[input.getAttribute('data-ns-custominputs-id')]; }; customInputs.instanceList = {}; customInputs.autoNo = 0; return customInputs; }()); ts.customInputs = customInputs; var customInputsEx = /** @class */ (function (_super) { __extends(customInputsEx, _super); function customInputsEx() { return _super !== null && _super.apply(this, arguments) || this; } customInputsEx.prototype.input = function () { return _super.prototype.input.call(this); }; return customInputsEx; }(customInputs)); ts.customInputsEx = customInputsEx; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); /// var jp; /// (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var autoComplete = /** @class */ (function (_super) { __extends(autoComplete, _super); function autoComplete(element, listMode) { if (listMode === void 0) { listMode = 'ovarlay'; } var _this = _super.call(this, element) || this; _this._inTheList = false; _this.maskTarget = 'label'; _this.focusShowAll = false; _this.setOnSelected = function (callback) { _this.onSelected = callback; }; _this.setListResource = function (resource) { }; _this.setValueList = function (list) { _this.valueList = list; }; _this.getValueList = function () { if (_this._valueUrl) { if (!_this.valueList) return null; } else if (!_this.valueList) { var data = decodeURIComponent(_this.input().getAttribute('data-ns-autocomplete-list')); if (data) { var json = JSON.parse(data); _this.valueList = json; } if (!json) { _this.valueList = []; } } return _this.valueList; //var url = this.wrap.getAttribute('data-ns-autocomplete-url'); }; _this.onListLoaded = function (list) { _this.setValueList(list); }; _this.setValue = function (value) { var input = _this.input(); var newValue = (value.display ? value.display : value.value); if (_this.entryValue === newValue) return; input.value = newValue; if (_this.onChangedCallback) { _this.onChangedCallback(_this, value); } }; _this.listState = function (open, showAll) { if (open === void 0) { open = null; } if (showAll === void 0) { showAll = false; } if (open === true) { if (ts.dropdownList.OpenTarget !== _this) { _this.entryValue = _this.inputElement.value; } ts.dropdownList.entry(_this, open, _this.getMaskValue(), showAll); } else { ts.dropdownList.entry(null, open); } }; _this.validate = function () { if (ts.dropdownList.OpenTarget === _this) { return ts.dropdownList.inTheList({ value: _this.input().value }); } return true; }; _this.update = function () { var value; if (ts.dropdownList.OpenTarget === _this) { value = ts.dropdownList.enter(); } if (value && value.index === -1) { if (_this.onChangedCallback) { if (!value || value.index === -1) { if (!_this._inTheList) { var text = _this.input().value; value = { index: -1, display: text, value: text }; } } _this.onChangedCallback(_this, value); } } }; _this.OnInput = function (e) { if (ts.dropdownList.OpenTarget !== _this) { _this.listState(true); } else { ts.dropdownList.setMask(_this.getMaskValue()); } }; _this._backClickClose = true; _this._backClickEditCancel = true; _this.getMaskValue = function () { var data = _this.input().value; switch (_this.maskTarget) { case 'value': return { value: data }; case 'label': return { label: data }; default: return { label: data, value: data }; } }; _this.onNonSelected = function () { _this.inputElement.value = _this.entryValue; }; _this.OnKeyDown = function (e) { switch (e.keyCode) { case 8: //Backspace case 46: //delete case 115: //f4 if (ts.dropdownList.OpenTarget !== _this) { var value = _this.input().value; if (e.keyCode === 115) { _this.listState(true, _this.focusShowAll); if (_this.focusShowAll) { _this.input().value = ''; } } else { _this.listState(true); } } break; case 9: //Tab case 27: //Esc if (ts.dropdownList.OpenTarget === _this) { if (ts.dropdownList.ChildLength === 0) { _this.listState(false); } else { _this.listState(false); e.preventDefault(); } if (e.keyCode === 27) { _this.onNonSelected(); } } break; case 38: //up if (ts.dropdownList.OpenTarget !== _this) { var value = _this.input().value; _this.listState(true); e.preventDefault(); } else { if (ts.dropdownList.ChildLength !== 0) { ts.dropdownList.previous(); e.preventDefault(); } } break; case 40: //down if (ts.dropdownList.OpenTarget !== _this) { var value = _this.input().value; _this.listState(true); } else { if (ts.dropdownList.ChildLength !== 0) { ts.dropdownList.next(); e.preventDefault(); } } break; } }; _this.OnKeyPress = function (e) { switch (e.keyCode) { case 13: //Enter if (e.shiftKey || e.altKey || e.ctrlKey) return; e.preventDefault(); if (ts.dropdownList.OpenTarget === _this) { if (ts.dropdownList.enter().index === -1) { _this.listState(false); } return; } default: } if (ts.dropdownList.OpenTarget !== _this) { _this.listState(true); } }; ts.dropdownList.addTarget(_this); var wrap = document.createElement('div'); _this.wrap = wrap; var textWrap = document.createElement('div'); var textView = document.createElement('div'); var textInner = document.createElement('div'); var selectListWrap = document.createElement('div'); var selectListView = document.createElement('div'); var selectListInner = document.createElement('div'); _this.selectListInner = selectListInner; _this.selectListWrap = selectListWrap; textWrap.classList.add('ns-custom-input'); textWrap.classList.add('wrap'); textView.classList.add('view'); textInner.classList.add('inner'); textInner.id = 'ns-' + element.id + '-text'; wrap.classList.add('ns-select-ex'); wrap.classList.add('wrap'); selectListWrap.classList.add('ns-select-ex-text'); selectListWrap.classList.add('wrap'); selectListView.classList.add('view'); selectListInner.classList.add('inner'); if (listMode === 'ovarlay') { selectListWrap.style.position = 'absolute'; selectListWrap.style.height = '0'; } else { selectListWrap.style.position = 'relative'; selectListWrap.style.height = 'auto'; } selectListWrap.style.width = '100%'; selectListWrap.style.top = 'auto'; selectListWrap.style.left = '0'; selectListWrap.style.right = 'auto'; selectListWrap.style.bottom = '0px'; selectListView.appendChild(selectListInner); selectListWrap.appendChild(selectListView); textView.appendChild(textInner); textWrap.appendChild(textView); wrap.appendChild(textWrap); wrap.appendChild(selectListWrap); wrap.addEventListener('keydown', _this.OnKeyDown); wrap.addEventListener('keypress', _this.OnKeyPress); //wrap.addEventListener('keyup', this.OnChange); if (element.nextElementSibling) { element.parentElement.insertBefore(wrap, element.nextElementSibling); } else { element.parentElement.appendChild(wrap); } textInner.appendChild(element); element.addEventListener('input', _this.OnInput); element.addEventListener('focus', function (e) { if (ts.dropdownList.OpenTarget !== _this) { _this.listState(true, _this.focusShowAll); if (_this.focusShowAll) { _this.input().value = ''; } } }); element.addEventListener('blur', function (e) { //if (dropdownList.OpenTarget === this) { // var value = this.input().value; // if (this.inTheList && !dropdownList.inTheList({ label: value })) { // this.input().value = ''; // } // dropdownList.entry(null, false); //} }); return _this; } autoComplete.getInstance = function (input) { return _super.getInstance.call(this, input); }; Object.defineProperty(autoComplete.prototype, "classTarget", { get: function () { return this.wrap; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "listSetTarget", { get: function () { return this.selectListInner; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "inputElement", { get: function () { return this.input(); }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "valueUrl", { get: function () { return this._valueUrl; }, set: function (url) { if (this._valueUrl === url) return; this._valueUrl = url; if (url) { this.valueList = null; } }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "inTheList", { get: function () { return this._inTheList; }, set: function (value) { this._inTheList = value; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "value", { get: function () { return this.input().value; }, set: function (v) { this.input().value = v; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "backClickClose", { get: function () { return this._backClickClose; }, set: function (value) { this._backClickClose = value; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "backClickEditCancel", { get: function () { return this._backClickEditCancel; }, set: function (value) { this._backClickEditCancel = value; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "isEditted", { get: function () { return this.inputElement.value !== this.entryValue; }, enumerable: true, configurable: true }); Object.defineProperty(autoComplete.prototype, "Dom", { get: function () { return this.wrap; }, enumerable: true, configurable: true }); autoComplete.init = function (query, listMode) { if (listMode === void 0) { listMode = 'ovarlay'; } ts.dropdownList.init(); if (typeof (query) === 'string') { var inputs = document.querySelectorAll(query); var len = inputs.length; for (var i = 0; i < len; i++) { var ex = new autoComplete(inputs[i], listMode); } } else { var ex = new autoComplete(query, listMode); } }; return autoComplete; }(ts.customInputsEx)); ts.autoComplete = autoComplete; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var dropdownListTarget = /** @class */ (function () { function dropdownListTarget() { } return dropdownListTarget; }()); ts.dropdownListTarget = dropdownListTarget; var dropdownList = /** @class */ (function () { function dropdownList() { this.LoadEnd = function (token, data) { var list = dropdownList.dropdownList; var dropdownID = list.getAttribute('data-ns-dropdown-ex-id'); var id = token.query['dropdown_list_id']; var target = dropdownList.targets[id]; var items = JSON.parse(data.data.dropdownList); if (target) { if (target.onListLoaded) { if (typeof (target.valueUrl) === 'string') { if (target.valueUrl === token.url) { target.onListLoaded(items); } } else { if (target.valueUrl.url === token.url) { var param = target.valueUrl.param; var query = token.query; var el = false; for (var p in param) { if (param[p] !== query[p]) { el = true; break; } } if (!el) { target.onListLoaded(items); } } } } } if (dropdownID !== id) return; dropdownList.setOptions(items); dropdownList.opened(target); }; this.LoadStart = function (token) { var list = dropdownList.dropdownList; var dropdownID = list.getAttribute('data-ns-dropdown-ex-id'); var id = token.query['dropdown_list_id']; if (dropdownID !== id) return; dropdownList.openTarget.classTarget.classList.add('loading'); }; this.LoadError = function (token, ev) { window.console.debug(ev); var list = dropdownList.dropdownList; var dropdownID = list.getAttribute('data-ns-dropdown-ex-id'); var id = token.query['dropdown_list_id']; if (dropdownID !== id) return; dropdownList.openTarget.classTarget.classList.add('error'); }; this.LoadProgress = function (token, ev) { }; } Object.defineProperty(dropdownList, "ChildLength", { get: function () { return dropdownList.childLength; }, enumerable: true, configurable: true }); Object.defineProperty(dropdownList, "OpenTarget", { get: function () { return dropdownList.openTarget; }, enumerable: true, configurable: true }); Object.defineProperty(dropdownList, "Current", { get: function () { return dropdownList.current; }, enumerable: true, configurable: true }); Object.defineProperty(dropdownList, "loadingMask", { get: function () { return dropdownList._loadingMask; }, set: function (value) { if (dropdownList._loadingMask === value) return; if (dropdownList.opening) { dropdownList._loadingMask = value; } }, enumerable: true, configurable: true }); Object.defineProperty(dropdownList, "isOpening", { get: function () { return dropdownList.opening; }, set: function (value) { if (dropdownList.opening === value) return; dropdownList.opening = value; }, enumerable: true, configurable: true }); dropdownList.targets = {}; dropdownList.opening = false; dropdownList.current = -1; dropdownList.mask = ''; dropdownList.childLength = 0; dropdownList.setCurrent = function (value, scroll) { if (scroll === void 0) { scroll = true; } if (dropdownList.current === value) return; if (value < -1) value = -1; var before = dropdownList.current; var list = dropdownList.dropdownList; var current = list.querySelector('.current'); if (current) { current.classList.remove('current'); } dropdownList.current = value; if (value === -1) return; var li = list.children[value]; if (!li) { value = 0; li = list.children[value]; if (!li) { value = -1; } } if (li) { li.classList.add('current'); if (scroll) { var func = function (target, index, li, scrollMethod) { if (dropdownList.openTarget === target && dropdownList.current === index) { var scrollBox = dropdownList.scrollBox; var rect = li.getBoundingClientRect(); if (rect.width === 0 || rect.height === 0) { setTimeout(function () { func(target, index, li, scrollMethod); }, 1); return; } scrollBox.scrollShowRect(rect, scrollMethod); } }; func(dropdownList.openTarget, value, li, (before === -1) ? 'center' : 'nearly'); } } }; dropdownList.setMask = function (current, showAll) { if (showAll === void 0) { showAll = false; } if (dropdownList.opening) { if (dropdownList.loadingMask) { dropdownList.loadingMask.mask = current; } return; } var children = dropdownList.dropdownList.children; var options = dropdownList.options; var len = children.length; var cnt = 0; var list = dropdownList.dropdownList; var equal = -1; for (var i = 0; i < len; i++) { var li = children[i]; var option = options[i]; var ret = false; for (var prop in current) { var value = current[prop].toString(); if (value === '') { ret = true; break; } var str = option[prop].toString(); if (str === value) { equal = i; } if (str.indexOf(value) >= 0) { ret = true; break; } } if (showAll) { ret = true; } if (!ret) { li.classList.add('mask'); } else { li.classList.remove('mask'); cnt++; } } dropdownList.childLength = cnt; dropdownList.setCurrent(equal); dropdownList.scrollBox.reflesh(); }; dropdownList.inTheList = function (test) { var children = dropdownList.dropdownList.children; var options = dropdownList.options; var len = children.length; var cnt = 0; for (var i = 0; i < len; i++) { var li = children[i]; var option = options[i]; var ret = true; for (var prop in test) { if (option[prop].toString() !== test[prop].toString()) { ret = false; break; } } if (ret) return true; } return false; }; dropdownList.addTarget = function (instance) { dropdownList.targets[instance.inputElement.id] = instance; }; dropdownList.setOpenTarget = function (dropdown) { var loading = false; if (dropdownList.loadingMask) { if (dropdownList.loadingMask.target !== dropdown) { dropdownList.loadingMask = null; } } try { if (dropdownList.openTarget === dropdown) return; var before = dropdownList.openTarget; if (before) { before.classTarget.classList.remove('opened'); before.classTarget.classList.remove('opening'); before.classTarget.classList.remove('loading'); before.classTarget.classList.remove('error'); } dropdownList.childLength = 0; dropdownList.openTarget = dropdown; var wrap = dropdownList.scrollBox.dom; if (dropdown) { try { var id = dropdown.inputElement.id; var ex = dropdownList.targets[id]; dropdown.classTarget.classList.add('opening'); dropdownList.dropdownList.setAttribute('data-ns-dropdown-ex-id', id); var options = dropdown.getValueList(); if (!options) { var url = dropdown.valueUrl; if (typeof (url) === 'string') { dropdownList.loader.RequestUrl(url, { dropdown_list_id: id }, 'application/json'); } else { if (Object.assign) { var param = Object.assign({}, url.param); } else { var param = JSON.parse(JSON.stringify(url.param)); } if (!param.dropdown_list_id) { param.dropdown_list_id = id; } dropdownList.loader.RequestUrl(url.url, param, 'application/json'); if (wrap.parentElement) { wrap.parentElement.removeChild(wrap); } loading = true; } } else { dropdownList.setOptions(options); } setTimeout(function () { if (dropdownList.opening) return; if (dropdownList.openTarget !== dropdown) return; dropdownList.opened(ex); }, 0.1); } finally { if (!before) { window.addEventListener('click', dropdownList.OnBackClick); } } } else { window.removeEventListener('click', dropdownList.OnBackClick); if (wrap.parentElement) { wrap.parentElement.removeChild(wrap); } } } finally { if (!loading) { dropdownList.opening = false; } } return !dropdownList.opening; }; dropdownList.setOptions = function (options) { var list = dropdownList.dropdownList; var len = options.length; var preCnt = list.children.length; dropdownList.options = options; for (var i = 0; i < len; i++) { var option = options[i]; var li = list.children[i]; if (!li) { li = document.createElement('li'); list.appendChild(li); } li.innerHTML = option.label; li.setAttribute('data-ns-dropdown-ex-index', i.toString()); var op = null; if (option instanceof HTMLOptionElement) { op = option.getAttribute('data-ns-dropdown-ex-option'); } else { op = option.option; } if (op) { li.setAttribute('data-ns-dropdown-ex-option', op); } li.className = (option.className) ? option.className : ''; } for (var i = len; i < preCnt; i++) { list.removeChild(list.lastElementChild); } dropdownList.childLength = len; }; dropdownList.OpenElement = function () { var list = dropdownList.dropdownList; var dropdownID = list.getAttribute('data-ns-dropdown-ex-id'); if (dropdownID) { return document.getElementById(dropdownID); } return null; }; dropdownList.entry = function (target, open, mask, showAll) { if (open === void 0) { open = null; } if (mask === void 0) { mask = null; } if (showAll === void 0) { showAll = false; } if (dropdownList.opening) return; dropdownList.setCurrent(-1); dropdownList.opening = true; dropdownList.loadingMask = null; if (target) { dropdownList.loadingMask = { target: target, mask: mask, showAll: showAll }; } if (dropdownList.openTarget === target) return; setTimeout(function () { if (open === true) { dropdownList.setOpenTarget(target); if (dropdownList.loadingMask && dropdownList.loadingMask.target === target) dropdownList.setMask(dropdownList.loadingMask.mask, dropdownList.loadingMask.showAll); return; } if (open === false) { dropdownList.setOpenTarget(null); return; } if (dropdownList.openTarget !== target) { dropdownList.setOpenTarget(target); if (dropdownList.loadingMask && dropdownList.loadingMask.target === target) dropdownList.setMask(dropdownList.loadingMask.mask, dropdownList.loadingMask.showAll); } else { dropdownList.setOpenTarget(null); } }, 1); }; dropdownList.enter = function () { var list = dropdownList.dropdownList; var li = list.querySelector('.current'); if (!li || !list.contains(li)) { return { index: -1, display: '', value: '' }; } var index = parseInt(li.getAttribute('data-ns-dropdown-ex-index')); var options = parseInt(li.getAttribute('data-ns-dropdown-ex-option')); var option = dropdownList.options[index]; var dropdown = dropdownList.openTarget; var values = { index: index, display: option.label, value: option.value, option: options }; dropdown.setValue(values); if (dropdown.onSelected) { dropdown.onSelected(values); } dropdownList.setOpenTarget(null); return { index: index, display: option.label, value: option.value }; }; dropdownList.next = function () { var len = dropdownList.dropdownList.children.length; var next = dropdownList.current + 1; if (len <= next) { next = len - 1; } var list = dropdownList.dropdownList; var nextLi = list.children[next]; while (nextLi && nextLi.classList.contains('mask')) { next++; nextLi = list.children[next]; } if (!nextLi) { nextLi = list.children[len - 1]; while (nextLi && nextLi.classList.contains('mask')) { next--; nextLi = list.children[next]; } } dropdownList.setCurrent(next); }; dropdownList.previous = function () { var previous = dropdownList.current - 1; if (previous < 0) { previous = 0; } var list = dropdownList.dropdownList; var previousLi = list.children[previous]; while (previousLi && previousLi.classList.contains('mask')) { previous--; previousLi = list.children[previous]; } if (!previousLi) { previousLi = list.children[list.children.length - 1]; while (previousLi && previousLi.classList.contains('mask')) { previous--; previousLi = list.children[previous]; } } dropdownList.setCurrent(previous); }; dropdownList.OnBackClick = function (e) { if (dropdownList.opening) return; if (dropdownList.openTarget.classTarget.contains(e.target)) return; if (!dropdownList.openTarget.backClickClose) return; var target = dropdownList.openTarget; dropdownList.setOpenTarget(null); if (!dropdownList.openTarget.backClickEditCancel) return; target.onNonSelected(); }; dropdownList.OnListClick = function (e) { dropdownList.enter(); }; dropdownList.OnListMouseMove = function (e) { var target = e.target; if (target.tagName !== 'LI') return; var index = parseInt(target.getAttribute('data-ns-dropdown-ex-index')); dropdownList.setCurrent(index, false); }; dropdownList.init = function () { if (dropdownList.dropdownList) return; var dropdownUl = document.createElement('ul'); dropdownUl.addEventListener('click', dropdownList.OnListClick); dropdownUl.addEventListener('mousedown', function (e) { e.preventDefault(); }); dropdownUl.addEventListener('mousemove', dropdownList.OnListMouseMove); dropdownList.scrollBox = new ts.scrollBox(dropdownUl, 'ns-dropdown-ex'); dropdownList.dropdownList = dropdownUl; dropdownList.loader = new ts.Loader(''); dropdownList.instance = new dropdownList(); dropdownList.loader.AddOwner(dropdownList.instance); dropdownList.loader.method = ts.LoadMethod.POST; dropdownList.loader.autoparse = true; }; dropdownList.opened = function (target) { dropdownList.opening = false; if (dropdownList.loadingMask) { if (dropdownList.loadingMask.target === target) { dropdownList.setMask(dropdownList.loadingMask.mask, dropdownList.loadingMask.showAll); } dropdownList.loadingMask = null; } dropdownList.openTarget.classTarget.classList.remove('loading'); var classTarget = dropdownList.openTarget.classTarget; classTarget.classList.remove('opening'); classTarget.classList.add('opened'); target.listSetTarget.appendChild(dropdownList.scrollBox.dom); dropdownList.scrollBox.reflesh(); }; return dropdownList; }()); ts.dropdownList = dropdownList; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var formControls = /** @class */ (function () { function formControls() { var _this = this; this.controls = []; this.clear = function (parent) { var no = parent.getAttribute('data-ns-iFormControl-id'); if (!no) return; var controls = _this.controls[no]; var len = controls.length; for (var i = 0; i < len; i++) { var control = controls[i]; control.clear(); } }; this.getValues = function (parent) { var no = parent.getAttribute('data-ns-iFormControl-id'); if (!no) return; var controls = _this.controls[no]; var len = controls.length; var values = {}; for (var i = 0; i < len; i++) { var control = controls[i]; values[control.key] = control.values(); } return values; }; this.setValues = function (parent, values) { var no = parent.getAttribute('data-ns-iFormControl-id'); if (!no) return; var controls = _this.controls[no]; var len = controls.length; for (var i = 0; i < len; i++) { var control = controls[i]; control.setValues(values[control.key]); } }; this.getCheckFunc = function (parent) { var no = parent.getAttribute('data-ns-iFormControl-id'); if (!no) return; var controls = _this.controls[no]; var len = controls.length; var fields = {}; var funcs = {}; var ret = false; for (var i = 0; i < len; i++) { var control = controls[i]; var field = control.field; var func = control.getCheckFunc(); if (func) { if (typeof field === 'string') { if (!funcs[field]) { fields[field] = field; funcs[field] = [func]; } else { funcs[field].push(func); } } else { var key = control.key; if (!funcs[key]) { fields[key] = field; funcs[key] = [func]; } else { funcs[key].push(func); } } ret = true; } } if (!ret) return null; return { fields: fields, check: function (field, values) { var fs = funcs[field]; var len = fs.length; for (var i = 0; i < len; i++) { if (!fs[i](values)) { return false; } } return true; } }; }; var parents = document.querySelectorAll('.filter_set'); var len = parents.length; for (var i = 0; i < len; i++) { var parent = parents[i]; var list = []; for (var control in ts.controls) { if (ts.controls[control].init) { var set = ts.controls[control].init(parent); list = list.concat(set); } } //list = list.concat( // controls.checkequal.init(parent) // , controls.daterange.init(parent) // , controls.tagsinput.init(parent) // , controls.multiselect.init(parent) //); parent.setAttribute('data-ns-iFormControl-id', i.toString()); this.controls[i] = list; } } Object.defineProperty(formControls, "instance", { get: function () { return formControls._instance; }, enumerable: true, configurable: true }); formControls.init = function () { formControls._instance = new formControls(); }; return formControls; }()); ts.formControls = formControls; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var controls; (function (controls) { var identifier; (function (identifier) { identifier[identifier["between"] = 0] = "between"; identifier[identifier["in"] = 1] = "in"; identifier[identifier["like"] = 2] = "like"; identifier[identifier["equal"] = 3] = "equal"; })(identifier = controls.identifier || (controls.identifier = {})); })(controls = ts.controls || (ts.controls = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var select = /** @class */ (function (_super) { __extends(select, _super); function select(element) { var _this = _super.call(this, element) || this; _this.setOnSelected = function (callback) { _this.onSelected = callback; }; _this.setting = function () { var select = _this.input(); var wrap = document.createElement('div'); _this.wrap = wrap; var textWrap = document.createElement('div'); var textView = document.createElement('div'); var text = document.createElement('p'); var selectListWrap = document.createElement('div'); var selectListView = document.createElement('div'); var selectListInner = document.createElement('div'); _this.selectListInner = selectListInner; _this.selectListWrap = selectListWrap; _this.text = text; textWrap.classList.add('ns-custom-input'); textWrap.classList.add('wrap'); textView.classList.add('view'); text.classList.add('inner'); text.id = 'ns-' + select.id + '-text'; wrap.classList.add('ns-select-ex'); wrap.classList.add('wrap'); selectListWrap.classList.add('ns-select-ex-text'); selectListWrap.classList.add('wrap'); selectListView.classList.add('view'); selectListInner.classList.add('inner'); selectListWrap.style.position = 'absolute'; selectListWrap.style.width = '100%'; selectListWrap.style.height = '0'; selectListWrap.style.top = 'auto'; selectListWrap.style.left = '0'; selectListWrap.style.right = 'auto'; selectListWrap.style.bottom = '0px'; selectListView.appendChild(selectListInner); selectListWrap.appendChild(selectListView); textView.appendChild(text); textWrap.appendChild(textView); wrap.appendChild(textWrap); wrap.appendChild(selectListWrap); select.style.display = 'none'; var caption = select.selectedOptions[select.selectedIndex]; if (caption) { text.innerHTML = caption.label; } else { caption = select.selectedOptions[0]; if (caption) { text.innerHTML = caption.label; } } wrap.addEventListener('click', _this.OnOpenClick); select.parentElement.insertBefore(wrap, select); }; _this._backClickClose = true; _this._backClickEditCancel = true; _this.getValueList = function () { return _this.input().options; }; _this.onNonSelected = function () { _this.inputElement.selectedIndex = _this.entryValue; }; _this.OnOpenClick = function (e) { var target = e.target; if (!_this.wrap.contains(target) || _this.selectListWrap.contains(target)) { return; } e.preventDefault(); ts.dropdownList.entry(_this); _this.entryValue = _this.inputElement.selectedIndex; }; _this.setValue = function (value) { _this.text.innerHTML = value.display; _this.input().selectedIndex = value.index; if (_this.onChangedCallback) { _this.onChangedCallback(_this, value); } }; _this.getValue = function () { var select = _this.input(); return { display: _this.text.innerHTML, value: select.selectedOptions[0].value, index: select.selectedIndex }; }; _this.setIndex = function (value) { var select = _this.input(); if (typeof (value) === 'number') { if (select.selectedIndex === value) return; select.selectedIndex = value; var op = select.selectedOptions[0]; _this.text.innerHTML = op.label; } else { var op = select.querySelector('option[value="' + value + '"]'); if (op) { if (op.selected) return; _this.text.innerHTML = op.label; select.selectedIndex = op.index; } } }; ts.dropdownList.addTarget(_this); _this.setting(); return _this; } select.getInstance = function (input) { return _super.getInstance.call(this, input); }; Object.defineProperty(select.prototype, "classTarget", { get: function () { return this.wrap; }, enumerable: true, configurable: true }); Object.defineProperty(select.prototype, "listSetTarget", { get: function () { return this.selectListInner; }, enumerable: true, configurable: true }); Object.defineProperty(select.prototype, "inputElement", { get: function () { return this.input(); }, enumerable: true, configurable: true }); Object.defineProperty(select.prototype, "backClickClose", { get: function () { return this._backClickClose; }, set: function (value) { this._backClickClose = value; }, enumerable: true, configurable: true }); Object.defineProperty(select.prototype, "backClickEditCancel", { get: function () { return this._backClickEditCancel; }, set: function (value) { this._backClickEditCancel = value; }, enumerable: true, configurable: true }); Object.defineProperty(select.prototype, "Dom", { get: function () { return this.wrap; }, enumerable: true, configurable: true }); select.init = function (query) { ts.dropdownList.init(); if (!(query instanceof HTMLSelectElement)) { var elements = document.querySelectorAll(query); var len = elements.length; for (var i = 0; i < len; i++) { var ex = new select(elements[i]); } } else { var ex = new select(query); } }; return select; }(ts.customInputsEx)); ts.select = select; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var recode; var recodes; var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var tableEx = /** @class */ (function () { function tableEx(card, recodeTag) { var _this = this; if (recodeTag === void 0) { recodeTag = null; } this.recodes = []; this.pagenateItems = []; this.historySetting = false; this.spanMapper = []; this.fieldMapper = {}; this.recodeColumnCount = 1; this.recodeInRowCount = 1; this.max = 10; this.pageIndex = 0; this.paged = 0; this.max_item = 9; this.search_detail = {}; this.recodeTag = 'TR'; this.fieldQueryPrefixe = '.c-'; this.createFloatingUI = function () { if (_this.floatingUi) return; var table = _this.table; var floating = table.nextElementSibling; if (!floating) { floating = document.createElement('div'); table.parentElement.appendChild(floating); } else { var new_next = document.createElement('div'); table.parentElement.insertBefore(new_next, floating); floating = new_next; } floating.classList.add('ns-table-floating-ui'); _this.floatingUi = floating; var dragSet = document.createElement('span'); dragSet.className = 'ui-drag-set'; dragSet.style.cursor = 'pointer'; var drag = document.createElement('span'); drag.className = 'ui-drag'; var up = document.createElement('span'); up.className = 'ui-up'; var down = document.createElement('span'); down.className = 'ui-down'; var upIcon = ts.template.dom.createSVG('0 0 10.759 13.504'); // upIcon.innerHTML = ''; var downIcon = upIcon.cloneNode(true); up.appendChild(upIcon); down.appendChild(downIcon); dragSet.appendChild(up); dragSet.appendChild(drag); dragSet.appendChild(down); drag.addEventListener('dragstart', _this.OnDragStart); table.addEventListener('dragenter', _this.OnDragEnter); table.addEventListener('dragover', _this.OnDragOver); drag.addEventListener('dragleave', _this.OnDragLeave); table.addEventListener('drop', _this.OnDrop); drag.addEventListener('dragend', _this.OnDragEnd); floating.appendChild(dragSet); dragSet.addEventListener('click', _this.OnOrderClick); _this.dragUi = dragSet; _this.dragUiPoint = drag; }; this.OnOrderClick = function (e) { var target = e.target; if (target.classList.contains('ui-up')) { var recode = _this.getRecodeFromChild(_this.currentCell); var index = _this.getRecodeIndex(recode, false) - 1; if (index < 0) return; var targetRecode = _this.getFilterringRecodes()[index]; if (_this.OnOrderChangeClick('up', recode, targetRecode)) { if (_this.insertTableRecode(recode, targetRecode, true)) { _this.OnOrderChanged('up', recode, targetRecode); } } } else if (target.classList.contains('ui-down')) { var recode = _this.getRecodeFromChild(_this.currentCell); var index = _this.getRecodeIndex(recode, false) + 1; var recodes = _this.getFilterringRecodes(); if (!recodes[index]) return; var targetRecode = recodes[index]; if (_this.OnOrderChangeClick('down', recode, targetRecode)) { if (_this.insertTableRecode(recode, targetRecode, true)) { _this.OnOrderChanged('down', recode, targetRecode); } } } }; this._editable = false; this._insertable = false; this.getNewRecodeRender = function () { if (!_this._tbodyRender) { var render; if (_this.recodeTag == 'TR') { render = document.createElement('tbody'); } else { render = document.createElement('table'); } var temp = _this.header.getAttribute('data-ns-row-temp'); if (!temp) return null; render.innerHTML = temp; if (_this.recodeTag == 'TR') { _this._tbodyRender = render; } else { _this._tbodyRender = render.tBodies[0]; _this._tbodyRender.parentElement.removeChild(_this._tbodyRender); } } return _this._tbodyRender; }; this.createNewRecode = function (count) { if (count === void 0) { count = 0; } var render = _this.getNewRecodeRender(); if (!render) return null; var newRecodes = []; switch (_this.recodeTag) { case 'TBODY': while (count--) { var newRecode = render.cloneNode(true); newRecode.id = 'new-' + tableEx.newRowCounter.toString(); newRecodes.push(newRecode); tableEx.newRowCounter++; } break; default: while (count--) { var newRecode = render.firstChild.cloneNode(true); newRecode.id = 'new-' + tableEx.newRowCounter.toString(); newRecodes.push(newRecode); tableEx.newRowCounter++; } } return newRecodes; }; this.addRecode = function (cnt, focus) { if (cnt === void 0) { cnt = 1; } if (focus === void 0) { focus = false; } if (cnt <= 0) return; var body = _this.recodeContener; var newRecodes = _this.createNewRecode(cnt); if (!newRecodes) return; var len = _this._filteringRecodes.length; var page = _this.getPageLength() - 1; var map = _this.getMapData(_this.currentCell); for (var i = 0; i < cnt; i++) { body.classList.add('ns-add-recode'); body.appendChild(newRecodes[i]); } _this.domElementReflesh(true); _this.refresh(false); if (focus) { if (map) { _this.setCurrentCellIndex(_this.getRecodeIndex(newRecodes[0]), map.toCell.row, map.toCell.cell, page); } else { _this.setCurrentCellIndex(_this.getRecodeIndex(newRecodes[0]), 0, 0, page); } } if (_this.onCreateNewRowCallback) { _this.onCreateNewRowCallback(_this.getEventObj(len, 0, 0, newRecodes, page)); } }; this.insertRecode = function (tr, cnt, focus) { if (cnt === void 0) { cnt = 1; } if (focus === void 0) { focus = false; } if (cnt <= 0) return; var body = _this.recodeContener; var newRecodes = _this.createNewRecode(cnt); if (!newRecodes) return; if (!tr) tr = _this.getRecodeFromChild(_this.currentCell); var index = _this.getRecodeIndex(tr); var page = _this.getRecodePageIndex(tr); var map = _this.getMapData(_this.currentCell); for (var i = 0; i < cnt; i++) { body.classList.add('ns-insert-recode'); body.insertBefore(newRecodes[i], tr); } _this.domElementReflesh(true); _this.refresh(false); if (focus) { if (map) { _this.setCurrentCellIndex(index, map.toCell.row, map.toCell.cell, page); } else { _this.setCurrentCellIndex(index, 0, 0, page); } } if (_this.onCreateNewRowCallback) { _this.onCreateNewRowCallback(_this.getEventObj(index, 0, 0, newRecodes, page)); } }; this.insertTableRecode = function (target, tr, focus) { if (focus === void 0) { focus = false; } var body = _this.recodeContener; if (!tr) tr = _this.getRecodeFromChild(_this.currentCell); if (!_this.table.contains(target) || !_this.table.contains(tr)) return false; try { var index = _this.getRecodeIndex(tr, false); var t_index = _this.getRecodeIndex(target, false); var targetPage = _this.getRecodePageIndex(target); var trPage = _this.getRecodePageIndex(tr); var map = _this.getMapData(_this.currentCell); var focusIndex = _this.getRecodeIndex(tr, true); var offset = 0; if (targetPage < trPage || t_index < index) { body.insertBefore(target, tr.nextElementSibling); } else { body.insertBefore(target, tr); offset = 1; } _this.domElementReflesh(true); _this.refresh(false); if (focus) { if (map) { _this.setCurrentCellIndex(focusIndex, map.toCell.row, map.toCell.cell, trPage); } else { _this.setCurrentCellIndex(focusIndex, 0, 0, trPage); } } return true; } catch (ex) { console.error(ex); } return false; }; this.setRecodeLength = function (cnt) { var body = _this.recodeContener; if (cnt < 0) cnt = 0; if (_this.recodeTag === 'TR') { var counter = cnt - body.rows.length; } else { var counter = cnt - body.tBodies.length; } if (counter > 0) { var newRecodes = _this.createNewRecode(counter); if (!newRecodes) return; for (var i = 0; i < counter; i++) { body.appendChild(newRecodes[i]); } } else { for (var i = counter; i < 0; i++) { body.removeChild(body.lastChild); } } _this.domElementReflesh(true); _this.refresh(false); }; this.removeRecode = function (row) { var body = _this.recodeContener; if (row instanceof HTMLTableRowElement) { if (row.parentElement === body) { body.removeChild(row); } } else { var len = row.length; for (var i = 0; i < len; i++) { var r = row[i]; if (r.parentElement === body) { body.removeChild(r); } } } _this.domElementReflesh(true); _this.refresh(false); }; this.removeCheckedRecode = function (confirm) { if (confirm === void 0) { confirm = null; } var checked = _this.recodeContener.getElementsByClassName('checked'); if (checked.length === 0) return false; var array = Array.prototype.slice.call(checked); if (confirm) { if (!confirm(array)) return false; } var index = _this.currentCellIndexInfo; _this.removeRecode(array); _this.setCurrentCellIndex(index.recode, index.row, index.column, _this.pageIndex); return true; }; this.domElementReflesh = function (rowChange) { if (rowChange === void 0) { rowChange = false; } var len = 0; var table = _this.table; _this.header = table.tHead; if (!_this.recodeTag) { var render = _this.getNewRecodeRender(); if (render && render.rows.length > 1) { _this.recodeTag = 'TBODY'; } else { if (_this.table.tHead.children.length === 1) { _this.recodeTag = 'TR'; } else { _this.recodeTag = 'TBODY'; } } } if (table.hasAttribute('data-ns-table-draggable')) { _this.draggable = true; } else { _this.draggable = false; } if (table.hasAttribute('data-ns-table-checkable')) { table.classList.add('row-checkable'); } if (rowChange) { if (_this.recodes !== _this._filteringRecodes) { _this.filterClear(false); } _this.recodeInRowCount = 1; _this.recodeColumnCount = 1; _this.spanMapper = []; _this.fieldMapper = {}; var rList; switch (_this.recodeTag) { case 'TBODY': rList = table.tBodies; break; default: rList = table.rows; } var len = rList.length; var rows = []; var header = table.tHead; var footer = table.tFoot; for (var i = 0; i < len; i++) { var r = rList[i]; switch (r.parentElement) { case header: case footer: break; default: r.classList.add('ns-recode'); var td = r.querySelector('td:first-child'); if (td) { var ui = td.getElementsByClassName('r-ui')[0]; if (!ui) { ui = document.createElement('span'); ui.className = 'r-ui'; var check = document.createElement('span'); check.className = 'ui-check'; check.style.cursor = 'pointer'; ui.appendChild(check); //var dragSet = document.createElement('span'); //dragSet.className = 'ui-drag-set'; //dragSet.style.cursor = 'pointer'; //var drag = document.createElement('span'); //drag.className = 'ui-drag'; //var up = document.createElement('span'); //up.className = 'ui-up'; //var down = document.createElement('span'); //down.className = 'ui-down'; //dragSet.appendChild(up); //dragSet.appendChild(drag); //dragSet.appendChild(down); //ui.appendChild(dragSet); td.appendChild(ui); } } rows.push(r); } } _this.recodes = rows; _this._filteringRecodes = rows; } else { len = _this.recodes.length; } switch (_this.recodeTag) { case 'TBODY': _this.recodeContener = table; if (_this.recodes[0]) { _this.makeSpanMap(Array.prototype.slice.call(_this.recodes[0].rows)); } else { _this.makeSpanMap(Array.prototype.slice.call(_this.header.rows)); } break; default: _this.recodeContener = table.tBodies[0]; if (_this.recodes[0]) { _this.makeSpanMap([_this.recodes[0]]); } else { _this.makeSpanMap([_this.header.rows[0]]); } break; } if (table.hasAttribute('data-ns-table-editable')) { _this.editable = true; } var pageNate = _this.pagenate; if (pageNate) { if (len <= 10) { if (pageNate.parentElement) { pageNate.parentElement.removeChild(_this.pagenate); } } else { if (table && table.parentElement) { table.parentElement.insertBefore(pageNate, table); } } } }; this.makeSpanMap = function (rows) { var len = rows.length; _this.recodeInRowCount = len; var maps = []; var cnt = rows[0].cells.length; _this.recodeColumnCount = cnt; for (var i = 0; i < len; i++) { var map = []; for (var j = 0; j < cnt; j++) { map[j] = { col: 0, row: 0, class: '', toCell: { row: i, cell: j }, position: { row: i, cell: j }, field: null }; } maps[i] = map; } var fieldRegex = /(c|h)-[^ ]*/; for (var i = 0; i < len; i++) { var cells = rows[i].cells; var map = maps[i]; var colSpan = 0; var rowSpan = 0; var lastCellIndex = 0; var cellIndex = 0; for (var j = 0; j < cnt; j++) { var m = map[j]; var cell = cells[cellIndex]; if (cell) { var a = fieldRegex.exec(cell.className); if (a && a[0]) { m.class = a[0].replace(/^h-/, 'c-'); } } if (m.col === 0) { colSpan = (cell) ? cell.colSpan : 1; if (colSpan > 1) { m.col = 1; for (var h = 1; h < colSpan; h++) { if (j + h >= cnt) break; map[j + h].col = h + 1; } } } else { } if (m.row === 0) { m.toCell.cell = cellIndex; rowSpan = (cell) ? cell.rowSpan : 1; if (rowSpan > 1) { m.row = 1; for (var h = 1; h < rowSpan; h++) { if (i + h >= len) break; maps[i + h][j].row = h + 1; } } cellIndex++; } else { m.toCell.row = i - (m.row - 1); } } } for (var i = 0; i < len; i++) { var map = maps[i]; var cells = rows[i].cells; var length = cells.length; for (var j = 0; j < cnt; j++) { var m = map[j]; if (m.row === 0 && m.col === 0) { var setMapR = maps[m.toCell.row]; if (setMapR && setMapR[m.toCell.cell]) { var setMap = setMapR[m.toCell.cell]; setMap.position.row = i; setMap.position.cell = j; } } if (length <= j) { m.position.row = -1; m.position.cell = -1; } else { var field = m.class.replace(/^c-/, ''); _this.fieldMapper[field] = m; m.field = field; } } } _this.spanMapper = maps; }; this._tableMouseMoveEnabled = false; this._tableMouseEndEnabled = false; this.currentCellMouseDown = false; this.mouseMoved = false; this.OnTableMouseDown = function (e) { try { if (e instanceof MouseEvent) { var otherEvents = _this.MouseStart(e, { x: e.pageX, y: e.pageY }); } else { var touch = e.touches[0]; var otherEvents = _this.MouseStart(e, { x: touch.pageX, y: touch.pageY }); } } finally { _this.mouseMoved = false; if (otherEvents) { _this.tableMouseMoveEnabled = true; _this.tableMouseEndEnabled = true; } } }; this.editorOpened = false; this.dragRecode = null; this.dropTarget = null; this.MouseStart = function (e, point) { var target = e.target; tableEx._currentTable = _this; _this.table.classList.add('ns-tableEx-focus'); _this.downPoints = { mouse: point }; if (target instanceof HTMLAnchorElement) { return false; } if (target instanceof HTMLButtonElement) { return false; } var td = _this.getCellFromChild(target); if (!e.shiftKey && !e.ctrlKey) { if (!td) return true; var before = _this._currentCell; if (_this._currentCell === td) { if (tableExEditor.currentEditor && tableExEditor.currentEditor.isEditor(target)) { return false; } _this.currentCellMouseDown = true; _this.editorOpened = _this.isEditing(); } else { if (_this.isEditing()) { if (tableExEditor.currentEditor.isEditted && tableExEditor.currentEditor.warningID !== 'q-editcancel') { tableExEditor.currentEditor.setWarning('q-editcancel', '再度クリックで編集キャンセル or 編集確定はEnter'); tableExEditor.currentEditor.focus(); e.preventDefault(); return false; } } } var map = _this.getMapData(td); if (map.position.cell === 0) { if (target.classList.contains('ui-check')) { _this.currentCellMouseDown = false; _this.setCheckedRecode(_this.getRecodeFromChild(td), true, false); e.preventDefault(); return true; } //if (target.classList.contains('ui-drag')) { // var recode = this.getRecodeFromChild(td); // recode.draggable = true; // this.DragRecode = recode; // this.dropTarget = null; // return; //} } if (_this._currentCell !== td) { if (!_this.setCurrentCell(td)) { e.preventDefault(); } } } else { _this.setCheckedRecode(_this.getRecodeFromChild(td), e.ctrlKey, e.shiftKey); e.preventDefault(); } return true; }; this.OnTableMouseMove = function (e) { var point; if (e instanceof TouchEvent) { var touch = e.touches[0]; point = { x: touch.pageX, y: touch.pageY }; _this.TableMouseMove(e, point); } else { point = { x: e.pageX, y: e.pageY }; _this.TableMouseMove(e, point); } if (_this.dragRecode) { _this.mouseMoved = true; return; } if (jp.ninesense.ts.MathBit.abs(point.y - _this.downPoints.mouse.y) > 2) { _this.mouseMoved = true; if (!(e instanceof TouchEvent)) { e.preventDefault(); } } }; this.TableMouseMove = function (e, point) { var target = e.target; _this.movePoints = point; }; this.OnDragStart = function (e) { _this.DragRecode = _this.getRecodeFromChild(_this.currentCell); }; this.OnDragEnter = function (e) { var target = e.target; if (!_this.table.contains(target)) return; var recode = _this.getRecodeFromChild(target); if (!recode) return; if (_this.dragRecode) { _this.DropTarget = recode; //console.log('target:',this.DropTarget.id); //console.log('drag:',this.DragRecode.id); e.preventDefault(); } }; this.OnDragOver = function (e) { var target = e.target; if (!_this.table.contains(target)) return; var recode = _this.getRecodeFromChild(target); if (!recode) return; if (_this.dragRecode) { _this.DropTarget = recode; //console.log('target:', this.DropTarget.id); //console.log('drag:', this.DragRecode.id); e.preventDefault(); } }; this.OnDragLeave = function (e) { if (_this.dragRecode) { _this.DropTarget = null; } }; this.OnDrop = function (e) { if (_this.dragRecode !== _this.dropTarget) { if (!_this.OnRecodeDrop(e, _this.dragRecode, _this.dropTarget)) { return; } if (_this.insertTableRecode(_this.dragRecode, _this.dropTarget, true)) { _this.OnRecodeDropped(e, _this.dragRecode, _this.dropTarget); } return; } }; this.OnDragEnd = function (e) { _this.DropTarget = null; _this.DragRecode = null; }; this.OnTableMouseEnd = function (e) { var point; try { if (e instanceof TouchEvent) { //let touch = e.touches[0]; point = _this.movePoints; _this.TableMouseEnd(e, point); } else { point = { x: e.pageX, y: e.pageY }; _this.TableMouseEnd(e, point); } } finally { _this.tableMouseMoveEnabled = false; _this.tableMouseEndEnabled = false; _this.currentCellMouseDown = false; _this.editorOpened = false; //this.DragRecode = null; //this.DropTarget = null; } }; this.TableMouseEnd = function (e, point) { var target = e.target; if (target instanceof HTMLAnchorElement) { var href = target.href; var url = window.location.href.split('#')[0]; if (href.indexOf(url) === 0) { var locate = href.replace(url, ''); if (_this.jumpTargetRecode(locate)) { return false; } else { alert('対象のデータが見つかりませんでした。'); } } return; } if (_this.dragRecode) { return; } if (_this.currentCellMouseDown) { if (!_this.mouseMoved) { if (!e.shiftKey && !e.ctrlKey) { if (e instanceof MouseEvent) { //マウスの場合左クリック以外エディター表示しない。 if (e.button !== 0) return; } var td = _this.getCellFromChild(target); if (!td) return; if (_this.editable) { if (td === _this.currentCell) { if (!tableExEditor.currentEditor || !tableExEditor.currentEditor.isEditor(target)) { if (!_this.editorOpened) { _this.showEditer(); if (tableExEditor.currentEditor) tableExEditor.currentEditor.focus(); } else { _this.hideEditer(); } } } } } } } }; this.setCurrentCellIndex = function (recode, row, column, page) { if (page === void 0) { page = null; } var recodes = _this.getPagedRecodes(page); if (row >= 0) { var r = recodes[recode]; } else { var r = recodes[recodes.length + recode]; } if (!r) { return false; } var cell; if (r instanceof HTMLTableRowElement) { if (column >= 0) { cell = r.cells[column]; } else { cell = r.cells[r.children.length + column]; } } else { if (row < 0) { row = r.rows.length + row; } var eElem = r.rows[row]; if (column >= 0) { cell = eElem.cells[column]; } else { cell = eElem.cells[r.children.length + column]; } } return _this.setCurrentCell(cell); }; this._eventObj = { recode: 0, column: 0, row: 0, target: null, page: 0 }; this.getEventObj = function (recode, column, row, target, page) { var e = _this._eventObj; e.recode = recode; e.column = column; e.row = row; e.target = target; e.page = page; return e; }; this._editEventObj = { recode: 0, column: 0, row: 0, target: null, page: 0, index: 0, value: null, input: true }; this.getEditEventObj = function (recode, column, row, td, page, index, value, input) { var e = _this._editEventObj; e.recode = recode; e.column = column; e.row = row; e.target = td; e.page = page; e.index = index; e.value = value; e.input = input; return e; }; this.getCellIndexInfo = function (cell, info) { if (info === void 0) { info = null; } var map = _this.getMapData(cell); var recodeIndex = _this.getCellRecodeIndex(cell); if (info) { info.column = map.toCell.cell; info.recode = recodeIndex; info.row = map.toCell.row; var pos = info.position; pos.colSpan = map.col; pos.rowSpan = map.row; pos.row = map.position.row; pos.cell = map.position.cell; } else { info = { recode: recodeIndex, row: map.toCell.row, column: map.toCell.cell, position: { colSpan: map.col, rowSpan: map.row, row: map.position.row, cell: map.position.cell } }; } return info; }; this.isFocusable = function (td) { if (!td) return false; var focus = !td.classList.contains('actions'); if (_this.checkFocusableCallback) { var index = _this.getCellRecodeIndex(td, true); var map = _this.getMapData(td); var page = _this.getCellPageIndex(td); if (!_this.checkFocusableCallback(_this.getEventObj(index, map.position.cell, map.position.row, td, page))) { focus = false; } } return focus; }; this._currentCellIndexInfo = { recode: -1, column: -1, row: -1, position: { rowSpan: 1, colSpan: 1, cell: -1, row: -1 } }; this.setCurrentCell = function (td) { if (!_this.table.contains(td)) return false; var page = _this.getCellPageIndex(td); if (_this.pageIndex !== page) { _this.setPageIndex(page, true); } var recodeIndex = _this.getCellRecodeIndex(td); var map = _this.getMapData(td); if (!_this.isFocusable(td)) return false; var className = 'ns-tableEx-editable'; if (!_this._editable) { className = 'ns-tableEx-readonly'; } else { if (_this.checkEditableCallback) { if (!_this.checkEditableCallback(_this.getEventObj(recodeIndex, map.position.cell, map.position.row, td, page))) { className = 'ns-tableEx-readonly'; } } } tableExEditor.hideEditor(); var currentCell = _this._currentCell; if (currentCell) { currentCell.classList.remove('ns-tableEx-current'); currentCell.classList.remove('ns-tableEx-editable'); currentCell.classList.remove('ns-tableEx-readonly'); var currentRow = _this.getRecodeFromChild(currentCell); if (currentRow) { currentRow.classList.remove('ns-tableEx-current-recode'); } } _this._currentCell = td; var currentRow = _this.getRecodeFromChild(td); var info = _this._currentCellIndexInfo; info.recode = recodeIndex; info.row = map.toCell.row; info.column = map.toCell.cell; info.position.colSpan = map.col; info.position.rowSpan = map.row; info.position.row = map.position.row; info.position.cell = map.position.cell; td.classList.add('ns-tableEx-current'); td.classList.add(className); currentRow.classList.add('ns-tableEx-current-recode'); var rect = currentRow.getBoundingClientRect(); var tableRect = _this.table.getBoundingClientRect(); var uiRect = _this.dragUi.getBoundingClientRect(); var top = -tableRect.height + (rect.top - tableRect.top) + ((rect.height - uiRect.height) * 0.5); _this.dragUi.style.transform = 'translateY(' + top.toString() + 'px)'; _this.dragUi.classList.add('drag-ui-active'); _this.setCheckedRecode(_this.getRecodeFromChild(td), false, false); return true; }; this.showEditer = function () { if (!_this.editable) return; var td = _this._currentCell; if (!td) return; var position = _this.getPosition(td); if (_this.checkEditableCallback) { if (!_this.checkEditableCallback(_this.getEventObj(_this.currentRecodeIndex, position.cell, position.row, td, _this.pageIndex))) return; } var value = _this.getCellValue(td); var type = 'text'; var recode = _this.getRecodeFromChild(td); var recodeIndex = _this.getRecodeIndex(recode); if (_this.typeSelectCallback) { type = _this.typeSelectCallback(_this.getEventObj(recodeIndex, position.cell, position.row, td, _this.pageIndex)); } if (!type) { type = 'text'; } if (_this.onEditStartCallback) { value.display = _this.onEditStartCallback(value.display, _this.getEventObj(recodeIndex, position.cell, position.row, td, _this.pageIndex)); } tableExEditor.getInstance(type).setEditor(td, value.display, _this.OnChanged.bind(_this)); }; this.isEditing = function () { return _this.table.contains(tableExEditor.Dom); }; this.hideEditer = function () { tableExEditor.hideEditor(); }; this.getHeaderFromPosition = function (row, column) { var map = _this.getMapDataFromIndex(row, column); if (!map) return null; if (_this.recodeTag === 'TR') { return _this.header.rows[0].cells[map.toCell.cell]; } else { return _this.header.rows[map.toCell.row].cells[map.toCell.cell]; } }; this.getHeader = function (td) { var map = _this.getMapData(td); return _this.getHeaderFromPosition(map.row, map.col); }; this.getMapData = function (td) { if (!td) return null; if (_this.recodeTag === 'TR') { return _this.spanMapper[0][td.cellIndex]; } else { return _this.spanMapper[td.parentElement.sectionRowIndex][td.cellIndex]; } }; this.getMapDataFromIndex = function (row, column) { if (_this.recodeTag === 'TR') { return _this.spanMapper[0][column]; } else { if (!_this.spanMapper[row]) return null; return _this.spanMapper[row][column]; } }; this.getCellFromPosition = function (recode, row, column, page) { if (page === void 0) { page = null; } var recodes = _this.getPagedRecodes(page); var r = recodes[recode]; if (!r) return null; var map = _this.getMapDataFromIndex(row, column); if (!map) return null; if (_this.recodeTag === 'TR') { return r.cells[map.toCell.cell]; } else { return r.rows[map.toCell.row].cells[map.toCell.cell]; } }; this.getCellFromRecodePosition = function (recodeElement, row, column) { var map = _this.getMapDataFromIndex(row, column); if (!map) return null; if (_this.recodeTag === 'TR') { return recodeElement.cells[map.toCell.cell]; } else { return recodeElement.rows[map.toCell.row].cells[map.toCell.cell]; } }; this.getPosition = function (td) { if (!td) return null; return _this.getMapData(td).position; }; this.getOffsetCell = function (recode, column, row, cell, page) { if (cell === void 0) { cell = null; } if (page === void 0) { page = null; } if (!cell) { cell = _this._currentCell; if (!cell) return null; } var parentRow = cell.parentElement; if (!parentRow) return null; var zeroPosition = _this.getPosition(cell); var isMobile = _this.isMobileLayout; var columnIndex = ((!isMobile) ? zeroPosition.cell : cell.cellIndex) + column; var toRecode = true; var recodes = _this.getPagedRecodes(page); var recodeElement = _this.getRecodeFromChild(parentRow); var inRowIndex = zeroPosition.row; var recodeIndex = recodes.indexOf(recodeElement); if (columnIndex === -1) return null; if (recodeIndex === -1) return null; if (recode !== 0) { recodeIndex += recode; recodeElement = recodes[recodeIndex]; if (!recodeElement) return null; cell = _this.getCellFromRecodePosition(recodeElement, zeroPosition.row, zeroPosition.cell); parentRow = cell.parentElement; } if (row !== 0) { if (_this.recodeTag === 'TR') { return _this.getCellFromPosition(recodeIndex + row, 0, columnIndex, page); } else { var inCount = _this.recodeInRowCount; var rowIndex = (recodeIndex * inCount) + zeroPosition.row + row; inRowIndex = rowIndex % inCount; recodeIndex = ts.MathBit.floor(rowIndex / inCount); if (!isMobile) { return _this.getCellFromPosition(recodeIndex, inRowIndex, columnIndex, page); } else { return _this.getPageCell(recodeIndex, columnIndex, inRowIndex, page); } } } if (!isMobile) { return _this.getCellFromRecodePosition(recodeElement, inRowIndex, columnIndex); } else { return _this.getPageCell(recodeIndex, columnIndex, inRowIndex); } }; this.toRightCell = function (nextRecode) { if (nextRecode === void 0) { nextRecode = false; } var cell = _this.getOffsetCell(0, 1, 0); if (nextRecode && !cell) { var rIndex = _this.currentRecodeIndex; if (rIndex === -1) return; return _this.setCurrentCellIndex(rIndex + 1, 0, 0); } else if (cell) { return _this.setCurrentCell(cell); } return false; }; this.toLeftCell = function (previousRecode) { if (previousRecode === void 0) { previousRecode = false; } var cell = _this.getOffsetCell(0, -1, 0); if (previousRecode && !cell) { var rIndex = _this.currentRecodeIndex; if (rIndex === -1) return; return _this.setCurrentCellIndex(rIndex - 1, -1, -1); } else if (cell) { return _this.setCurrentCell(cell); } return false; }; this.toTopCell = function () { var current = _this.currentCell; var cell = _this.getOffsetCell(0, 0, -1); var i = -2; while (cell && cell === current) { cell = _this.getOffsetCell(0, 0, i); i--; } if (cell) { return _this.setCurrentCell(cell); } return false; }; this.toBottomCell = function () { var current = _this.currentCell; var cell = _this.getOffsetCell(0, 0, 1); var i = 2; while (cell && cell === current) { cell = _this.getOffsetCell(0, 0, i); i++; } if (cell) { return _this.setCurrentCell(cell); } return false; }; this.toNextRecodeCell = function () { var cell = _this.getOffsetCell(1, 0, 0); if (cell) { return _this.setCurrentCell(cell); } return false; }; this.toPreviousRecodeCell = function () { var cell = _this.getOffsetCell(-1, 0, 0); if (cell) { return _this.setCurrentCell(cell); } return false; }; this.getCellRecodeIndex = function (cell, inPage) { if (inPage === void 0) { inPage = true; } return _this.getRecodeIndex(cell.parentElement, inPage); }; this.getRowInRecode = function (recodeElement, index) { if (_this.recodeTag === 'TBODY') { return recodeElement.children[index]; } else { if (index === 0) return recode; return null; } }; this.getRecodeIndex = function (row, inPage) { if (inPage === void 0) { inPage = true; } var target = _this.getRecodeFromChild(row); if (!inPage) { return _this._filteringRecodes.indexOf(target); } else { return _this._filteringRecodes.indexOf(target) % _this.max; } }; this.getRecodeInRowIndex = function (tr) { if (_this.recodeTag === 'TR') { return 0; } else { return tr.sectionRowIndex; } }; this.getRecodePageIndex = function (row) { var index = _this.getRecodeIndex(row, false); return Math.floor(index / _this.max); }; this.getCellPageIndex = function (cell) { return _this.getRecodePageIndex(_this.getRecodeFromChild(cell)); }; this.nextCell = function (nextRecode, nextPage, cell) { if (nextRecode === void 0) { nextRecode = false; } if (nextPage === void 0) { nextPage = false; } if (cell === void 0) { cell = null; } if (!cell) cell = _this.currentCell; var recodeIndex = _this.getCellRecodeIndex(cell, true); var pageIndex = _this.getCellPageIndex(cell); var mobile = _this.isMobileLayout; if (!mobile) { if (_this.recodeTag === 'TBODY') { var parent = _this.getRecodeFromChild(cell); var ncell = _this.getOffsetCell(0, 0, 1, cell, pageIndex); var i = 2; while (ncell && ncell === cell) { ncell = _this.getOffsetCell(0, 0, i, cell, pageIndex); i++; } if (ncell && ncell !== cell) { var nparent = _this.getRecodeFromChild(ncell); if (parent === nparent) { return ncell; } } } var pos = _this.getPosition(cell); cell = _this.getOffsetCell(0, 1, -pos.row, cell, pageIndex); if (nextRecode && !cell) { cell = _this.getPageCell(recodeIndex + 1, 0, 0, pageIndex); if (nextPage && !cell) { cell = _this.getPageCell(0, 0, 0, pageIndex + 1); } } } else { var ncell = _this.getOffsetCell(0, 1, 0, cell, pageIndex); if (ncell) return ncell; if (_this.recodeTag === 'TBODY') { var pos = _this.getPosition(cell); ncell = _this.getPageCell(recodeIndex, 0, pos.row + 1, pageIndex); if (ncell) return ncell; } if (nextRecode) { ncell = _this.getPageCell(recodeIndex + 1, 0, 0, pageIndex); if (ncell) return ncell; if (nextPage) { ncell = _this.getPageCell(0, 0, 0, pageIndex + 1); if (ncell) return ncell; } } cell = ncell; } return cell; }; this.previousCell = function (previousRecode, previousPage, cell) { if (previousRecode === void 0) { previousRecode = false; } if (previousPage === void 0) { previousPage = false; } if (cell === void 0) { cell = null; } if (!cell) cell = _this.currentCell; var recodeIndex = _this.getCellRecodeIndex(cell, true); var pageIndex = _this.getCellPageIndex(cell); var mobile = _this.isMobileLayout; if (!mobile) { if (_this.recodeTag === 'TBODY') { var parent = _this.getRecodeFromChild(cell); var ncell = _this.getOffsetCell(0, 0, -1, cell, pageIndex); var i = -2; while (ncell && ncell === cell) { ncell = _this.getOffsetCell(0, 0, i, cell, pageIndex); i--; } if (ncell && ncell !== cell) { var nparent = _this.getRecodeFromChild(ncell); if (parent === nparent) { return ncell; } } } cell = _this.getOffsetCell(0, -1, _this.recodeInRowCount - 1, cell, pageIndex); if (previousRecode && !cell) { if (recodeIndex > 0) { cell = _this.getPageCell(recodeIndex - 1, -1, -1, pageIndex); } if (previousPage && !cell && pageIndex > 0) { cell = _this.getPageCell(-1, -1, 0, pageIndex - 1); } } } else { var ncell = _this.getOffsetCell(0, -1, 0, cell, pageIndex); if (ncell) return ncell; if (_this.recodeTag === 'TBODY') { var pos = _this.getPosition(cell); if (pos.row > 0) { ncell = _this.getPageCell(recodeIndex, -1, pos.row - 1, pageIndex); } if (ncell) return ncell; } if (previousRecode) { if (recodeIndex > 0) { ncell = _this.getPageCell(recodeIndex - 1, -1, -1, pageIndex); if (ncell) return ncell; } if (previousPage) { if (pageIndex > 0) { ncell = _this.getPageCell(-1, -1, 0, pageIndex - 1); if (ncell) return ncell; } } } cell = ncell; } return cell; }; this.CopyAndInsert = function () { var currentRecode = _this.getRecodeFromChild(_this.currentCell); _this.insertRecode(null, 1, true); var newRecode = _this.getRecodeFromChild(_this.currentCell); var values = _this.getRecodeValues(currentRecode); if (values !== true) { _this.setRecodeValues(newRecode, values); } }; this.getRecodeTexts = function (recodeElement) { var values = _this.getRecodeValues(recodeElement); var copyText = []; if (typeof (values) !== 'boolean') { for (var field in values) { var v = values[field]; if (typeof (v) === 'string') { copyText.push(v); } else { copyText.push(v.display); } } } return copyText; }; this.getCellFromMap = function (recodeElement, map) { if (_this.recodeTag === 'TR') { return recodeElement.cells[map.toCell.cell]; } else { return recodeElement.rows[map.toCell.row].cells[map.toCell.cell]; } }; this.getCellTextElement = function (recodeIndex, columnIndex, rowIndex, page) { if (page === void 0) { page = null; } return _this.getCellTextElementFromCell(_this.getPageCell(recodeIndex, columnIndex, rowIndex, page)); }; this.getCellTextElementFromCell = function (cell) { if (!cell) return null; return cell.getElementsByClassName('c-body')[0]; }; this.getRecodeField = function (recodeElement, field) { var cell; if (_this.fieldMapper[field]) { var map = _this.fieldMapper[field]; cell = _this.getCellFromMap(recodeElement, map); } if (!cell) return null; return cell; }; this.getRecodeFieldQuery = function (recodeElement, query) { var cell; cell = recodeElement.querySelector(query); if (!cell) return null; return cell; }; this.getField = function (recode, field, page) { if (page === void 0) { page = null; } var r = _this.getPagedRecodes(page)[recode]; if (!r) return null; return _this.getRecodeField(r, field); }; this.getValue = function (recodeIndex, columnIndex, rowIndex, page) { if (page === void 0) { page = null; } return _this.getCellValue(_this.getPageCell(recodeIndex, columnIndex, rowIndex, page)); }; this.getCellValue = function (cell) { if (!cell) return null; var textElement = _this.getCellTextElementFromCell(cell); var disp; if (textElement) { disp = textElement.innerHTML; } var valueAttr = cell.getAttribute('data-ns-value'); var searchAttr = cell.getAttribute('data-ns-search'); if (disp === ' ') disp = ''; if (valueAttr === ' ') valueAttr = ''; if (searchAttr === ' ') searchAttr = ''; if (valueAttr && searchAttr) { return { value: valueAttr, display: disp, search: searchAttr }; } else if (valueAttr) { return { value: valueAttr, display: disp, search: disp }; } else if (searchAttr) { return { value: disp, display: disp, search: searchAttr }; } else { return { value: disp, display: disp, search: disp }; } }; this.setValue = function (recodeIndex, columnIndex, rowIndex, value, page) { if (page === void 0) { page = null; } return _this.setCellValue(_this.getPageCell(recodeIndex, columnIndex, rowIndex, page), value); }; this.setCellValue = function (cell, value) { var textElement = _this.getCellTextElementFromCell(cell); if (!textElement) { textElement = document.createElement('div'); textElement.classList.add('c-body'); cell.appendChild(textElement); } var disp = textElement.innerHTML; var valueAttr = cell.getAttribute('data-ns-value'); var searchAttr = cell.getAttribute('data-ns-search'); if (typeof (value) !== 'object') { switch (typeof (value)) { case 'number': value = value.toString(); case 'string': if (!valueAttr && !searchAttr && value === disp) return false; cell.setAttribute('data-ns-value', value); cell.setAttribute('data-ns-search', value); textElement.innerHTML = value; } return true; } var newDisp = value.display; var newValue = value.value; var newSearch = value.search; newValue = (newValue) ? newValue : newDisp; newSearch = (newSearch) ? newSearch : newDisp; var change = false; if (valueAttr !== newValue) { cell.setAttribute('data-ns-value', newValue); change = true; } if (searchAttr !== newSearch) { cell.setAttribute('data-ns-search', newSearch); change = true; } if (disp !== newDisp) { textElement.innerHTML = newDisp.replace(/(< ?script )||(< ?style )||(< ?iframe )/, ''); change = true; } return change; }; this.setFieldValue = function (value, recode, field, page) { if (page === void 0) { page = null; } var r = _this.getPagedRecodes(page)[recode]; if (!r) return null; return _this.setRecodeFieldValue(value, r, field); }; this.getRecodeFieldValue = function (recodeElement, field) { return _this.getCellValue(_this.getRecodeField(recodeElement, field)); }; this.getFieldValue = function (recode, field, page) { if (page === void 0) { page = null; } return _this.getCellValue(_this.getField(recode, field, page)); }; this.setRecodeFieldValue = function (value, recodeElement, field) { var cell = _this.getRecodeField(recodeElement, field); return _this.setCellValue(cell, value); }; this.getRecodeValues = function (row, queries, valueType) { if (queries === void 0) { queries = null; } if (valueType === void 0) { valueType = null; } var i = _this.getRecodeIndex(row, false); var validate = _this.onGetValuesValidate; var fields = _this.fieldMapper; if (queries === null) { var values = {}; for (var field in fields) { var v = _this.getRecodeFieldValue(row, field); if (valueType === null) values[field] = v; else if (valueType === 'value-and-display') { values[field] = { value: v['value'], display: v['display'] }; } else { values[field] = v[valueType]; } } if (validate) { values = validate(i, values); if (values === false) return null; if (!values) return null; } return values; } else { var values = {}; for (var field in queries) { var v = _this.getRecodeFieldValue(row, queries[field]); if (valueType === null) values[field] = v; else if (valueType === 'value-and-display') { values[field] = { value: v['value'], display: v['display'] }; } else { values[field] = v[valueType]; } } if (validate) { values = validate(i, values); if (values === false) return null; if (!values) return null; } return values; } return null; }; this.getValues = function (queries, valueType) { if (queries === void 0) { queries = null; } if (valueType === void 0) { valueType = null; } var rows = _this.recodes; var len = rows.length; var valueList = []; var validate = _this.onGetValuesValidate; var fields = _this.fieldMapper; if (queries === null) { for (var i = 0; i < len; i++) { var row = rows[i]; var values = {}; for (var field in fields) { var v = _this.getRecodeFieldValue(row, field); if (valueType === null) values[field] = v; else if (valueType === 'value-and-display') { values[field] = { value: v['value'], display: v['display'] }; } else { values[field] = v[valueType]; } } if (validate) { values = validate(i, values); if (values === false) return null; if (!values) continue; } valueList.push(values); } } else { for (var i = 0; i < len; i++) { var values = {}; var row = rows[i]; for (var field in queries) { var v = _this.getRecodeFieldValue(row, queries[field]); if (valueType === null) values[field] = v; else if (valueType === 'value-and-display') { values[field] = { value: v['value'], display: v['display'] }; } else { values[field] = v[valueType]; } } if (validate) { values = validate(i, values); if (values === false) return null; if (!values) continue; } valueList.push(values); } } return valueList; }; this.setRecodeValues = function (row, values) { var prefix = _this.fieldQueryPrefixe; for (var field in values) { var cell = _this.getRecodeField(row, field); if (cell) { var value = values[field]; _this.OnChanged(cell, -1, value, false); } } }; this.setValues = function (valueList) { var len = valueList.length; var rLen = _this.recodes.length; if (rLen < len) { _this.addRecode(len - rLen); } var rows = _this.recodes; for (var i = 0; i < len; i++) { var values = valueList[i]; var row = rows[i]; _this.setRecodeValues(row, values); } }; //public getSearch = (recodeIndex: number, columnIndex: number, rowIndex: number, page = null) => { // return this.getCellSearch(this.getPageCell(recodeIndex, columnIndex, rowIndex, page)); //} //public getCellSearch = (cell: HTMLTableCellElement) => { // var search = cell.getAttribute('data-ns-search'); // if (!search) { // search = this.getCellText(cell); // if (!search) { // search = null; // } // } // return search; //} //public setCellSearch = (cell: HTMLTableCellElement, search: string) => { // if (cell.getAttribute('data-ns-search') === search) return false; // cell.setAttribute('data-ns-search', search); // return true; //} //public setRecodeFieldText = (value: string, recodeElement: typeof recode, field: string) => { // var cell = this.getRecodeField(recodeElement, field); // return this.setCellText(cell, value); //} //public setFieldText = (value: string, recode: number, field: string, page: number = null) => { // var r = this.getPagedRecodes(page)[recode]; // if (!r) return null; // return this.setRecodeFieldText(value, r, field); //} //public getRecodeFieldText = (recodeElement: typeof recode, field: string) => { // return this.getCellText(this.getRecodeField(recodeElement, field)); //} //public getFieldText = (recode: number, field: string, page: number = null) => { // return this.getCellText(this.getField(recode, field, page)); //} //public getText = (recodeIndex: number, columnIndex: number, rowIndex:number, page = null) => { // return this.getCellText(this.getPageCell(recodeIndex, columnIndex, rowIndex, page)); //} //public setText = (recodeIndex: number, columnIndex: number, rowIndex: number, text: string, page = null) => { // return this.setCellText(this.getPageCell(recodeIndex, columnIndex, rowIndex, page), text); //} //public getCellText = (cell: HTMLTableCellElement) => { // var value = ''; // var textElement = this.getCellTextElementFromCell(cell); // if (textElement) { // value = textElement.innerHTML; // } // return value; //} //public setCellText = (cell: HTMLTableCellElement, text:string) => { // var value = ''; // var textElement = this.getCellTextElementFromCell(cell); // if (!textElement) { // textElement = document.createElement('p'); // textElement.classList.add('c-body'); // textElement.innerHTML = text; // cell.appendChild(textElement); // } // else { // if (textElement.innerHTML === text) return false; // textElement.innerHTML = text; // } // return true; //} this._pagedRecodes = []; this.getPagedRecodes = function (page) { if (page === void 0) { page = null; } var trs = _this._filteringRecodes; var total = trs.length; if (total === 0) return []; var max = _this.max; if (page === null) { page = _this.pageIndex; if (page < 0) return []; } else if (page < 0) { page = ts.MathBit.floor(total / max) + page; } if (_this._pagedRecodes[page]) return _this._pagedRecodes[page]; var start = page * max; var len = start + max; if (total < len) len = total; var list = []; for (var i = start; i < len; i++) { list.push(trs[i]); } _this._pagedRecodes[page] = list; return list; }; this.eachRecode = function (flg, callback) { var list; switch (flg) { case 'all': list = _this.recodes; break; case 'filtering': list = _this._filteringRecodes; break; case 'checked': list = _this.getCheckdRecodes(); break; default: list = _this.getPagedRecodes(flg); } var len = list.length; for (var i = 0; i < len; i++) { if (!callback(list[i])) { break; } } }; this.getPageLength = function () { return ts.MathBit.floor(_this._filteringRecodes.length / _this.max + 0.9); }; this.getRecodeFromChild = function (child) { var tag = _this.recodeTag; if (child.tagName === tag) { return child; } else { var tr = child.parentElement; var tagName; while (!((tagName = tr.tagName) === tag)) { if (tagName === 'TABLE') return null; tr = tr.parentElement; } return tr; } }; this.getCellFromChild = function (child) { if (child.tagName === 'TD') { return child; } var td = child.parentElement; var tagName; if (!td) return null; while (!((tagName = td.tagName) === 'TD')) { if (tagName === 'TABLE') return null; td = td.parentElement; } return td; }; this.getFilteringCell = function (rowIndex, columnIndex) { var rows = _this._filteringRecodes; if (rowIndex < 0) { rowIndex = rows.length + rowIndex; } if (!rows[rowIndex]) return null; var row = rows[rowIndex]; if (columnIndex < 0) { columnIndex = row.cells.length + columnIndex; } var cell = row.cells[columnIndex]; if (!cell) return null; return cell; }; this.getPageCell = function (recodeIndex, columnIndex, rowIndex, page) { if (rowIndex === void 0) { rowIndex = 0; } if (page === void 0) { page = null; } var redodes = _this.getPagedRecodes(page); if (recodeIndex < 0) { recodeIndex = redodes.length + recodeIndex; } if (!redodes[recodeIndex]) return null; var recode = redodes[recodeIndex]; if (rowIndex < 0) { rowIndex = _this.recodeInRowCount + rowIndex; } if (!_this.isMobileLayout) { if (columnIndex < 0) { columnIndex = _this.recodeColumnCount + columnIndex; } var map = _this.getMapDataFromIndex(rowIndex, columnIndex); var cell = map.toCell; if (_this.recodeTag === 'TBODY') { recode = recode.rows[cell.row]; } var c = recode.cells[cell.cell]; if (!c) return null; return c; } else { if (!recode) return null; if (_this.recodeTag === 'TBODY') { recode = recode.rows[rowIndex]; } if (!recode) return null; if (columnIndex < 0) { columnIndex = recode.cells.length + columnIndex; } var c = recode.cells[columnIndex]; if (!c) return null; return c; } }; this.setCheckedRecode = function (item, add, range) { if (add === void 0) { add = false; } if (range === void 0) { range = false; } //if (this._checkedItem === item) return; var remove = true; if (item) { remove = item.classList.contains('checked'); } if (!add) { tableEx.checkClearAll(); } var selection = window.getSelection(); if (selection) { if (selection.empty) { selection.empty(); } else { selection.removeAllRanges(); } } if (item) { if (!range) { if (!add) { item.classList.add('checked'); _this._checkedRow = item; } else { if (!item.classList.contains('checked')) { item.classList.add('checked'); _this._checkedRow = item; } else { item.classList.remove('checked'); } } } else { var shown = _this.getPagedRecodes(); var from = _this.getRecodeIndex(_this._checkedRow); var to = _this.getRecodeIndex(item); if (to < from) { var buffa = to; to = from; from = buffa; } for (var i = from; i <= to; i++) { if (add || !shown[i].classList.contains('checked')) { shown[i].classList.add('checked'); } else { shown[i].classList.remove('checked'); } } } if (!_this.isEditing() && !_this.isMobileLayout) { item.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" }); } } }; this.getCheckdRecodes = function () { if (_this.recodeTag === 'TR') { return Array.prototype.slice.call(_this.table.querySelectorAll('tr.checked')); } else { return Array.prototype.slice.call(_this.table.querySelectorAll('tbody.checked')); } }; this.getFilterringRecodes = function () { return _this._filteringRecodes.concat(); }; this.geRecodes = function () { return _this.recodes.concat(); }; this.recodesCheck = function (recods) { var len = recods.length; for (var i = 0; i < len; i++) { recods[i].classList.add('checked'); } }; this.recodesUnCheck = function (recods) { var len = recods.length; for (var i = 0; i < len; i++) { recods[i].classList.remove('checked'); } }; this.recodesCheckTgl = function (recods) { var len = recods.length; for (var i = 0; i < len; i++) { var c = recods[i].classList; if (c.contains('checked')) { recods[i].classList.remove('checked'); } else { recods[i].classList.add('checked'); } } }; this.checkClear = function () { var checked = _this.getCheckdRecodes(); var len = checked.length; //this._checkedItem.classList.remove('checked'); for (var i = 0; i < len; i++) { checked[i].classList.remove('checked'); } }; this.jumpTargetRecode = function (query) { var target = _this.table.querySelector(query); if (!target) return false; var cnt = 0; var pr = target.previousSibling; while (pr) { cnt++; pr = pr.previousSibling; } var page = Math.floor(cnt / _this.max); _this.setPageIndex(page); var y = target.getBoundingClientRect().top + window.scrollY; window.scroll({ left: 0, top: y - (window.innerHeight * 0.5), behavior: 'smooth' }); _this.setCheckedRecode(target); return true; }; this.OnTicker = function (index, option) { switch (index) { case 1: _this.refresh(false); option.pauseCount = 30; index = 0; break; case 2: _this.filterRefresh(false); index = 0; break; case 3: _this.clear(false); _this.pageNavigationReflesh(false); index = 0; break; } return index; }; this.createToolbox = function () { var toolbox = document.createElement('div'); var subTool = document.createElement('div'); var primaryTool = document.createElement('div'); _this._toolBoxPrimary = primaryTool; _this._toolBoxSub = subTool; toolbox.classList.add('ns-table-toolbox'); subTool.classList.add('ns-table-toolbox-sub'); primaryTool.classList.add('ns-table-toolbox-primary'); var s_cut = document.createElement('button'); s_cut.classList.add('s_cut'); s_cut.innerHTML = '操作キー'; s_cut.addEventListener('click', function (e) { _this.showHelp(); }); var r_dd = document.createElement('button'); r_dd.classList.add('r_dd'); r_dd.innerHTML = '順序変更'; r_dd.addEventListener('click', function (e) { var help = '行の順序変更'; if (_this.draggable) { help += ''; help += ''; help += '位置を変えたい行の何れかのセルを選択してください。'; help += '行先頭にスライドする左のようなアイコンを操作すると行の入れ替えが可能です。'; help += 'ドラッグ&ドロップで移動する際は中心のドットをドラッグして、割り込ませたい行にドロップしてください。'; help += 'また矢印をクリックすると、矢印の方向の行と入れ替わります(ページも跨ぎます)。'; help += ''; } else { help += 'このテーブルは行の入れ替えを許可していません。'; } jp.ninesense.ts.popupBox.getInstance().hide(); jp.ninesense.ts.popupBox.getInstance().showMessageBox('tableEx', help, false); }); subTool.appendChild(s_cut); subTool.appendChild(r_dd); toolbox.appendChild(subTool); toolbox.appendChild(primaryTool); _this.table.parentElement.appendChild(toolbox); }; this.showHelp = function () { var helpList = [ { title: "セルの移動", list: [ { key: "↑", discription: "上のセルへ移動" }, { key: "←", discription: "左のセルへ移動" }, { key: "↓", discription: "下のセルへ移動" }, { key: "→", discription: "右のセルへ移動" }, { key: "Ctrl + ↑", discription: "上のデータへ移動(1データ複数行構成の場合のみ)" }, { key: "Ctrl + ↓", discription: "下のデータへ移動(1データ複数行構成の場合のみ)" }, ] }, { title: "ページの移動", list: [ { key: "Shift + PageUp", discription: "前のページへ移動" }, { key: "Shift + PageDown", discription: "次のページへ移動" }, { key: "Shift + Home", discription: "最初のページへ移動" }, { key: "Shift + End", discription: "最後のページへ移動" }, ] } ]; if (_this.checkable) { helpList.push({ title: "行の選択", list: [ { key: "Ctrl + a", discription: "全選択" }, { key: "Shift + クリック", discription: "範囲選択" }, { key: "Ctrl + 複数選択", discription: "範囲選択" }, ] }); } if (_this.editable) { helpList.push({ title: "セルの編集", list: [ { key: "Enter/Tab", discription: "編集できる次のセルへ移動" }, { key: "Shift + Enter/Tab", discription: "編集できる前のセルへ移動" }, { key: "space/F2", discription: "編集開始" }, ] }, { title: "セルの編集中", list: [ { key: "Enter", discription: "編集の完了" }, { key: "Esc", discription: "編集のキャンセル" }, { key: "選択肢表示中 ↑↓", discription: "編集のキャンセル" }, ] }); } if (_this.insertable) { helpList.push({ title: "行の編集", list: [ { key: "Insert / Ctrl+i", discription: "新規行を挿入" }, { key: "Ctrl + Insert / Shift+Ctrl+i", discription: "選択行を複製して挿入" }, { key: "ドラッグ&ドロップ", discription: "行の順序変更(詳細は順序変更ボタンをクリック)" }, ] }); } helpList.push({ title: "その他", list: [ { key: "F1", discription: "ショートカットキー一覧表示" }, { key: "Ctrl + c", discription: "セルの値をクリップボードへコピー" }, ] }, { title: "未実装", list: [ { key: "--", discription: "行の削除" }, { key: "--", discription: "終端に追加" }, { key: "--", discription: "行をクリップボードにコピー" }, ] }); var help = 'テーブルショートカットキー一覧'; help += ''; for (var i in helpList) { var h = helpList[i]; help += ''; help += '【' + h.title + '】'; var list = h.list; for (var j in list) { var s = list[j]; help += ''; help += '' + s.key + ''; help += '' + s.discription + ''; help += ''; } help += ''; } help += ''; jp.ninesense.ts.popupBox.getInstance().hide(); jp.ninesense.ts.popupBox.getInstance().showMessageBox('tableEx', help, false); }; this.createPagenation = function () { var max_select = document.createElement('select'); var option_10 = document.createElement('option'); option_10.value = '10'; option_10.label = '10'; var option_25 = document.createElement('option'); option_25.value = '25'; option_25.label = '25'; var option_50 = document.createElement('option'); option_50.value = '50'; option_50.label = '50'; var option_100 = document.createElement('option'); option_100.value = '100'; option_100.label = '100'; max_select.appendChild(option_10); max_select.appendChild(option_25); max_select.appendChild(option_50); max_select.appendChild(option_100); max_select.className = 'dataTables_length'; max_select.name = "datatable-tabletools_length"; max_select.addEventListener("change", function (e) { var max_select = e.currentTarget; var value = parseInt(max_select.selectedOptions[0].value); _this.setMaxCount(value); }); var select_label = document.createElement('label'); var title = document.createElement('span'); title.innerHTML = ' records per page'; select_label.classList.add('recods_per_page'); select_label.appendChild(max_select); select_label.appendChild(title); var pageNate = document.createElement('div'); pageNate.className = 'paging_simple_numbers'; pageNate.appendChild(select_label); var pagenation = document.createElement('ul'); pagenation.className = 'ns-pagination'; pagenation.title = 'ShortCut : Shift + PageUp(前)/PageDown(次)/Home(最初)/End(最後)'; var previous = document.createElement('li'); previous.className = 'ns-paginate_button page-item previous disabled'; var item = document.createElement('a'); item.className = 'page-link'; item.href = '#'; item.tabIndex = 0; item.setAttribute('data-ns-dt-idx', 'previous'); item.innerHTML = 'Previous'; previous.appendChild(item); var next = document.createElement('li'); next.className = 'ns-paginate_button page-item next'; var item = document.createElement('a'); item.className = 'page-link'; item.href = '#'; item.tabIndex = 0; item.setAttribute('data-ns-dt-idx', 'next'); item.innerHTML = 'Next'; next.appendChild(item); pagenation.appendChild(previous); pagenation.appendChild(next); pageNate.appendChild(pagenation); var target = _this.table; var parent = target.parentElement; while (!parent.classList.contains('card-body')) { target = parent; parent = target.parentElement; } //if (!target.nextElementSibling) { // parent.appendChild(pageNate); //} //else { // parent.insertBefore(pageNate, target.nextElementSibling); //} _this.domElementReflesh(); pagenation.addEventListener('click', _this.OnClickPagenate); _this.pagenation = pagenation; _this.pagenate = pageNate; _this.nextButton = next; _this.previousButton = previous; _this.max_select = max_select; _this.refreshPagenation(); }; this.setMaxCount = function (value) { if (_this.max === value) return; _this.max = value; var option = _this.max_select.querySelector('option[value="' + value.toString() + '"]'); if (option) { option.selected = true; } _this.refresh(); }; this.setupFilterSet = function () { var set = _this.filterControls; if (!set) return; var reflesh = set.getElementsByClassName('refresh')[0]; var reset = set.getElementsByClassName('reset')[0]; reflesh.addEventListener('click', _this.OnRefreshFilterClick); reset.addEventListener('click', _this.OnClearFilterClick); }; this.OnClearFilterClick = function (e) { _this.filterClear(); }; this.OnRefreshFilterClick = function (e) { _this.filterRefresh(true); }; this.filterClear = function (async) { if (async === void 0) { async = true; } if (ts.formControls.instance && _this.filterControls) { ts.formControls.instance.clear(_this.filterControls); _this.search_detail = {}; _this.filterRefresh(async); } }; this.filterRefresh = function (async) { if (async === void 0) { async = true; } ninesense.ts.loadingLightBox.getInstance().show(); if (async) { _this.actObj.option.pauseCount = 30; _this.actObj.setTickIndex(2); return; } var rows = _this.recodes; var len = rows.length; if (ts.formControls.instance) { var checkSet = ts.formControls.instance.getCheckFunc(_this.filterControls); } var tbody = _this.recodeContener; //tbody.innerHTML = ''; try { var filterRows = _this._filteringRecodes; var cnt = filterRows.length; while (cnt--) { tbody.removeChild(filterRows[cnt]); } var targets; if (!checkSet) { targets = rows; return; } targets = []; var fields = checkSet.fields; var check = checkSet.check; for (var i = 0; i < len; i++) { var row = rows[i]; var ret = true; for (var index in fields) { var field = fields[index]; var values = null; if (typeof field === 'string') { var v = _this.getRecodeFieldValue(row, field); if (v) { values = v.search; } else { var cell = _this.getRecodeFieldQuery(row, '.c-' + field); if (cell) values = cell.getAttribute('data-ns-search'); } //var target = row.querySelector('.c-' + field) as HTMLTableCellElement; //if (target) { // values = target.getAttribute('data-ns-search'); //} //else { // values = null; //} } else { var cnt = field.length; values = []; for (var j = 0; j < cnt; j++) { var f = field[j]; var v = _this.getRecodeFieldValue(row, f); if (v) { values.push(v.search); } else { var cell = _this.getRecodeFieldQuery(row, '.c-' + field); if (cell) values.push(cell.getAttribute('data-ns-search')); } //var target = row.querySelector('.c-' + f) as HTMLTableCellElement; //if (target) { // values.push(target.getAttribute('data-ns-search')); //} } } if (!check(index, values)) { ret = false; break; } } if (ret) { targets.push(row); } } } finally { var len = targets.length; for (var i = 0; i < len; i++) { tbody.appendChild(targets[i]); } _this._filteringRecodes = targets; if (_this.filterControls) { var searchCount = _this.filterControls.querySelector('.search-count .value'); if (searchCount) { searchCount.innerHTML = len.toString(); } } if (jp.ninesense.ts.formControls.instance) { _this.search_detail = jp.ninesense.ts.formControls.instance.getValues(_this.filterControls); } _this.refresh(false); } }; this.refreshPagenation = function () { var trs = _this._filteringRecodes; var total = trs.length; var len = Math.ceil(trs.length / _this.max); _this.paged = len; var items = _this.pagenateItems; var pagenation = _this.pagenation; pagenation.removeChild(_this.nextButton); for (var i = 0; i < len; i++) { if (!items[i]) { var page = document.createElement('li'); page.className = 'ns-paginate_button page-item'; var item = document.createElement('a'); item.className = 'page-link page-' + i.toString(); item.href = '#'; item.tabIndex = 0; item.setAttribute('data-ns-dt-idx', i.toString()); item.innerHTML = (i + 1).toString(); page.appendChild(item); pagenation.appendChild(page); items[i] = page; } else { if (!items[i].parentElement) { pagenation.appendChild(items[i]); } } } var max = pagenation.children.length - 1; for (var i = len; i < max; i++) { pagenation.removeChild(items[i]); } pagenation.appendChild(_this.nextButton); }; this.OnClickPagenate = function (e) { var item = e.target; var idx = item.getAttribute('data-ns-dt-idx'); if (!idx) return; e.preventDefault(); switch (idx) { case 'previous': _this.previousPage(); break; case 'next': _this.nextPage(); break; default: _this.setPageIndex(parseInt(idx)); break; } }; this.previousPage = function () { _this.setPageIndex(_this.pageIndex - 1); }; this.nextPage = function () { _this.setPageIndex(_this.pageIndex + 1); }; this.setPageIndex = function (value, pushHistory) { if (pushHistory === void 0) { pushHistory = true; } if (value === null) return false; if (value < 0) value = _this.paged + value; if (_this.paged - 1 < value) value = _this.paged - 1; if (_this.pageIndex === value) return false; _this.clear(); _this.pageIndex = value; _this.pageNavigationReflesh(pushHistory); return true; }; this.pageNavigationReflesh = function (pushHistory) { if (pushHistory === void 0) { pushHistory = true; } if (_this._filteringRecodes.length === 0) return; var trs = _this.getPagedRecodes(); var len = trs.length; for (var i = 0; i < len; i++) { trs[i].classList.add('active'); } var pagenate = _this.pagenate; var item = pagenate.getElementsByClassName('page-' + _this.pageIndex.toString())[0]; if (item) { var current_page = item.parentElement; current_page.classList.add('active'); var next = _this.nextButton; var previous = _this.previousButton; var maxItem = _this.max_item; if (_this.isMobileLayout) { try { current_page.classList.add('show'); var pWidth = _this.previousButton.getBoundingClientRect().width; var nWidth = _this.nextButton.getBoundingClientRect().width; var wWidth = (pagenate.parentElement) ? (pagenate.parentElement.getBoundingClientRect().width - pWidth - nWidth) : 0; var cWidth = current_page.getBoundingClientRect().width; maxItem = ts.MathBit.floor(wWidth / cWidth) - 1; if (maxItem < 3) { maxItem = 3; } } finally { current_page.classList.remove('show'); } } var bafore = Math.floor(maxItem * 0.5); var after = maxItem - bafore; var previousSib = current_page; while (previousSib && 0 < bafore) { if (previousSib === next || previousSib === previous) break; previousSib.classList.add('show'); previousSib = previousSib.previousElementSibling; bafore--; } after += bafore; var nextSib = current_page.nextElementSibling; while (nextSib && 0 < after) { if (nextSib === next || nextSib === previous) break; nextSib.classList.add('show'); nextSib = nextSib.nextElementSibling; after--; } var nextSibOver = nextSib.nextElementSibling; if (nextSibOver) { var more = nextSib.previousElementSibling; more.classList.add('more'); more.previousElementSibling.classList.remove('show'); next.previousElementSibling.classList.add('show'); after--; } bafore += after; while (previousSib && 0 < bafore) { if (previousSib === next || previousSib === previous) break; previousSib.classList.add('show'); previousSib = previousSib.previousElementSibling; bafore--; } //var previousSibOver = previousSib.previousElementSibling; //if (previousSibOver) { // if (previousSib !== previous && previousSibOver !== previous) { // previousSib.nextElementSibling.classList.remove('show'); // previousSib.nextElementSibling.nextElementSibling.classList.remove('show'); // previousSib.classList.add('more'); // previous.nextElementSibling.classList.add('show'); // } //} } switch (_this.pageIndex) { case 0: previous.classList.add('disabled'); break; case _this.paged - 1: next.classList.add('disabled'); break; } if (_this.historySetting) { _this.historySetting = false; return; } if (pushHistory && jp.ninesense.ts.HistoryValues.useableHistory() && _this.table.id) { var his = { index: _this.pageIndex, max: _this.max, search: _this.search_detail }; jp.ninesense.ts.HistoryValues.GetInstance().push(window.location.host, 'tableEx:' + _this.table.id, his); } }; this.clear = function (clearRecodes) { if (clearRecodes === void 0) { clearRecodes = true; } if (clearRecodes) { _this._tbodyRender = null; _this.setCheckedRecode(null); var trs_active = _this.getPagedRecodes(); var len_active = trs_active.length; for (var i = 0; i < len_active; i++) { trs_active[i].classList.remove('active'); } _this._pagedRecodes = []; } var pagenate = _this.pagenate; _this.removeClassList('active', pagenate); _this.removeClassList('disabled', pagenate); _this.removeClassList('show', pagenate); _this.removeClassList('more', pagenate); }; this.removeClassList = function (className, parent) { if (parent === void 0) { parent = document.body; } var targets = parent.getElementsByClassName(className); var len = targets.length; for (var i = 0; i < len; i++) { targets[0].classList.remove(className); } }; this.refresh = function (tick) { if (tick === void 0) { tick = true; } if (tick) { ninesense.ts.loadingLightBox.getInstance().show(); _this.actObj.setTickIndex(1); return; } try { _this.clear(); _this.refreshPagenation(); if (!_this.setPageIndex(_this.pageIndex)) { _this.pageNavigationReflesh(); } } finally { ninesense.ts.loadingLightBox.getInstance().hide(); } }; this.getIDList = function (method) { var recodeList; switch (method) { case 'all': recodeList = _this.recodes; break; case 'checked': recodeList = _this.getCheckdRecodes(); break; default: recodeList = _this.getFilterringRecodes(); break; } var cnt = recodeList.length; var tableData = []; for (var j = 0; j < cnt; j++) { tableData[j] = recodeList[j].id; } return tableData; }; this.recodeTag = recodeTag; var action = card.querySelector('.card-actions'); var table = card.querySelector('.card-body.advanced table'); if (!table) return; table.classList.add('ns-tableEx'); var filters = card.querySelector('.card-body.advanced .filter_set'); this.card = card; this.action = action; this.table = table; this.filterControls = filters; this.createFloatingUI(); if (!this.card) return; this.domElementReflesh(true); this.createToolbox(); this.createPagenation(); this.setupFilterSet(); this.domElementReflesh(false); this.pageNavigationReflesh(false); this.actObj = new ninesense.ts.ActionObj(this.OnTicker); this.actObj.option = { pauseCount: 30 }; table.addEventListener(jp.ninesense.ts.devise.pointerEvents.start, this.OnTableMouseDown); window.addEventListener("resize", function () { _this._ismobileLayout = null; _this.actObj.stopTo(3); }); if (this.filterControls) { setTimeout(function () { var defValue = {}; defValue['tableEx:' + _this.table.id] = { index: 0, max: _this.max, search: {} }; jp.ninesense.ts.HistoryValues.GetInstance().addTarget(window.location.host, _this, defValue, function (target, state) { _this.historySetting = true; var no = state['tableEx:' + _this.table.id]; if (!no) { no = { index: 0, max: 10, search: {} }; } jp.ninesense.ts.formControls.instance.setValues(_this.filterControls, no.search); _this.filterRefresh(); _this.setMaxCount(no.max); _this.setPageIndex(no.index, false); }); }, 1); } } Object.defineProperty(tableEx.prototype, "tableElement", { get: function () { return this.table; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "id", { get: function () { return this.table.id; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "editable", { get: function () { return this._editable; }, set: function (value) { if (this._editable === value) return; this._editable = value; if (this.recodeContener) { if (value) { this.recodeContener.classList.add('ns-table-advanced-editable'); } else { this.recodeContener.classList.remove('ns-table-advanced-editable'); } } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "insertable", { get: function () { return this._insertable; }, set: function (value) { if (this._insertable === value) return; this._insertable = value; if (this.recodeContener) { if (value) { this.recodeContener.classList.add('ns-table-advanced-insertable'); } else { this.recodeContener.classList.remove('ns-table-advanced-insertable'); } } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "isMobileLayout", { get: function () { if (!this._ismobileLayout) { if (this.table.getBoundingClientRect().height === 0) return 'd'; this._ismobileLayout = (this.header.getBoundingClientRect().height !== 0) ? 'd' : 'm'; } return this._ismobileLayout === 'm'; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "length", { get: function () { return this._filteringRecodes.length; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "checkable", { get: function () { return this.table.hasAttribute('data-ns-table-checkable'); }, set: function (value) { var table = this.table; if (value) { table.removeAttribute('data-ns-table-checkable'); } else { table.setAttribute('data-ns-table-checkable', 'true'); } if (value) { table.classList.add('row-checkable'); } else { table.classList.remove('row-checkable'); } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "draggable", { get: function () { return this.dragUiPoint.draggable; }, set: function (value) { var table = this.table; if (value) { this.dragUiPoint.draggable = true; table.classList.add('row-draggable'); if (!table.hasAttribute('data-ns-table-draggable')) { table.setAttribute('data-ns-table-draggable', "1"); } this.dragUi.style.display = ''; } else { this.dragUiPoint.draggable = false; table.classList.remove('row-draggable'); if (table.hasAttribute('data-ns-table-draggable')) { table.removeAttribute('data-ns-table-draggable'); } this.dragUi.style.display = 'none'; } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "tableMouseMoveEnabled", { get: function () { return this._tableMouseMoveEnabled; }, set: function (value) { if (this._tableMouseMoveEnabled === value) return; this._tableMouseMoveEnabled = value; if (value) { window.addEventListener(jp.ninesense.ts.devise.pointerEvents.move, this.OnTableMouseMove); } else { window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.move, this.OnTableMouseMove); } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "tableMouseEndEnabled", { get: function () { return this._tableMouseEndEnabled; }, set: function (value) { if (this._tableMouseEndEnabled === value) return; this._tableMouseEndEnabled = value; if (value) { window.addEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnTableMouseEnd); } else { window.removeEventListener(jp.ninesense.ts.devise.pointerEvents.end, this.OnTableMouseEnd); } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "DragRecode", { get: function () { return this.dragRecode; }, set: function (value) { var recode = this.dragRecode; if (recode === value) return; if (recode) { recode.classList.remove('drag-recode'); //recode.removeEventListener('dragstart', this.OnDragStart); //this.table.removeEventListener('dragenter', this.OnDragEnter); //this.table.removeEventListener('dragover', this.OnDragOver); //recode.removeEventListener('dragleave', this.OnDragLeave); //this.table.removeEventListener('drop', this.OnDrop); //recode.removeEventListener('dragend', this.OnDragEnd); } this.dragRecode = value; if (value) { value.classList.add('drag-recode'); } }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "DropTarget", { get: function () { return this.dropTarget; }, set: function (value) { if (this.dropTarget === value) return; if (this.dropTarget) { this.dropTarget.classList.remove('drop-target'); } this.dropTarget = value; if (this.dragRecode === value) return; if (value) { value.classList.add('drop-target'); } }, enumerable: true, configurable: true }); tableEx.prototype.OnRecodeDrop = function (e, dragRecode, dropTarget) { return this.dragRecode !== this.dropTarget; }; tableEx.prototype.OnRecodeDropped = function (e, dragRecode, dropTarget) { }; tableEx.prototype.OnOrderChangeClick = function (method, dragRecode, dropTarget) { return dragRecode !== dropTarget; }; tableEx.prototype.OnOrderChanged = function (method, dragRecode, dropTarget) { }; Object.defineProperty(tableEx.prototype, "currentCellIndexInfo", { get: function () { return this._currentCellIndexInfo; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "currentRecodeIndex", { get: function () { var cell = this._currentCell; var parentRow = this.getRecodeFromChild(cell); var rows = this.getPagedRecodes(); return rows.indexOf(parentRow); }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "currentCell", { get: function () { return this._currentCell; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "currentCellIndex", { get: function () { return this.getMapData(this._currentCell).toCell; }, enumerable: true, configurable: true }); tableEx.prototype.nextEditableCell = function (nextRecode, nextPage) { if (nextRecode === void 0) { nextRecode = false; } if (nextPage === void 0) { nextPage = false; } var cell = this.nextCell(nextRecode, nextPage); var editable = this.editable; if (this.isFocusable(cell) && (!this.checkEditableCallback)) { return cell; } var position = this.getPosition(cell); while (cell && (!this.isFocusable(cell) || (this.checkEditableCallback && !this.checkEditableCallback(this.getEventObj(this.getCellRecodeIndex(cell), position.cell, position.row, cell, this.getCellPageIndex(cell)))))) { var nextCell = this.nextCell(nextRecode, nextPage, cell); if (nextCell === cell) return null; cell = nextCell; position = this.getPosition(cell); } return cell; }; tableEx.prototype.previousEditableCell = function (previousRow, previousPage) { if (previousRow === void 0) { previousRow = false; } if (previousPage === void 0) { previousPage = false; } var cell = this.previousCell(previousRow, previousPage); if (this.isFocusable(cell) && !this.checkEditableCallback) { return cell; } var position = this.getPosition(cell); while (cell && (!this.isFocusable(cell) || (this.checkEditableCallback && !this.checkEditableCallback(this.getEventObj(this.getCellRecodeIndex(cell), position.cell, position.row, cell, this.getCellPageIndex(cell)))))) { cell = this.previousCell(previousRow, previousPage, cell); position = this.getPosition(cell); } return cell; }; tableEx.prototype.OnChanged = function (cell, index, value, input) { var changed = this.setCellValue(cell, value); if (this.onChangedCallback) { if (changed) { var position = this.getPosition(cell); this.onChangedCallback(this.getEditEventObj(this.getCellRecodeIndex(cell), position.cell, position.row, cell, this.getCellPageIndex(cell), index, this.getCellValue(cell), input)); } } }; Object.defineProperty(tableEx.prototype, "toolBoxPrimary", { get: function () { return this._toolBoxPrimary; }, enumerable: true, configurable: true }); Object.defineProperty(tableEx.prototype, "toolBoxSub", { get: function () { return this._toolBoxSub; }, enumerable: true, configurable: true }); tableEx.create = function (card, subClass) { if (subClass === void 0) { subClass = null; } if (!subClass) subClass = tableEx; var ex = new subClass(card); if (!ex.table) return; if (!tableEx.instances) { tableEx.instances = {}; window.addEventListener('keydown', tableEx.OnKeyDown); window.addEventListener('click', tableEx.OnWindowClick); var svgStyle = document.createElement('style'); // svgStyle.innerHTML = '\ .drag-ui-icons{ fill:none;stroke:#666666;stroke-width:0.75;stroke-miterlimit:10; }\ '; var mySvg = ts.template.dom.createSVG('0 0 10.759 13.504'); // mySvg.innerHTML = '\ \ \ \ \ \ \ '; document.head.append(svgStyle); document.head.append(mySvg); } var hookForm = ex.table.getAttribute('data-hook-form'); if (!tableEx.hookForms[hookForm]) { var form = document.getElementById(hookForm); if (form) { tableEx.hookForms[hookForm] = form; form.addEventListener('submit', tableEx.OnHookSubmit); tableEx.hookTargets[hookForm] = []; } } if (!tableEx.hookTargets[hookForm]) { tableEx.hookTargets[hookForm] = []; } tableEx.hookTargets[hookForm].push(ex); if (!ex.table.id) { tableEx.idInc++; ex.table.id = 'tableEx-' + tableEx.idInc.toString(); } tableEx.instances[ex.table.id] = ex; return ex; }; tableEx.init = function () { var cards = document.querySelectorAll('.card'); var len = cards.length; for (var i = 0; i < len; i++) { var card = cards[i]; this.create(card); } }; tableEx.getInstance = function (id) { if (!tableEx.instances[id]) return null; return tableEx.instances[id]; }; tableEx.newRowCounter = 0; tableEx.OnWindowClick = function (e) { if (tableEx._currentTable && !tableEx._currentTable.table.contains(e.target)) { tableEx._currentTable.table.classList.remove('ns-tableEx-focus'); tableEx._currentTable = null; } }; tableEx.OnKeyDown = function (e) { if (!tableEx._currentTable) return; var current = tableEx._currentTable; switch (e.keyCode) { case 9: //tab case 13: //Enter if (current.isEditing()) { if (!e.ctrlKey && !e.shiftKey && !e.altKey) { tableExEditor.currentEditor.update(); current.hideEditer(); } else { return; } } var move = false; if (!e.ctrlKey && !e.shiftKey) { var cell = current.nextEditableCell(true, true); if (cell) move = current.setCurrentCell(cell); } else { if (!e.ctrlKey) { var cell = current.previousEditableCell(true, true); if (cell) move = current.setCurrentCell(cell); } else { if (!e.shiftKey) { move = current.toNextRecodeCell(); } else { move = current.toPreviousRecodeCell(); } } } if (move) { e.preventDefault(); } else { if (e.keyCode !== 9) { e.preventDefault(); } } break; case 27: //ESC if (current.isEditing()) { if (tableExEditor.currentEditor.InputControl === ts.dropdownList.OpenTarget) { e.preventDefault(); return; } } current.hideEditer(); e.preventDefault(); break; case 32: //space if (current.isEditing()) return; if (current.onCellActionKeyDown) { var info = current.currentCellIndexInfo; current.onCellActionKeyDown(e, current.getEventObj(info.recode, info.column, info.row, current.currentCell, current.pageIndex)); } case 113: //F2 if (current.isEditing()) return; current.showEditer(); e.preventDefault(); break; case 37: //← if (current.isEditing()) return; if (!current.isMobileLayout) { current.toLeftCell(false); } else { cell = current.previousCell(); if (cell) move = current.setCurrentCell(cell); } e.preventDefault(); break; case 38: //↑ if (current.isEditing()) return; if (!current.isMobileLayout) { if (!e.ctrlKey) { move = current.toTopCell(); } else { current.toPreviousRecodeCell(); } } else { cell = current.previousCell(); if (cell) move = current.setCurrentCell(cell); } if (move) { e.preventDefault(); } break; case 39: //→ if (current.isEditing()) return; if (!current.isMobileLayout) { current.toRightCell(false); } else { cell = current.nextCell(); if (cell) move = current.setCurrentCell(cell); } e.preventDefault(); break; case 40: //↓ if (current.isEditing()) return; if (!current.isMobileLayout) { if (!e.ctrlKey) { move = current.toBottomCell(); } else { current.toNextRecodeCell(); } } else { cell = current.nextCell(); if (cell) move = current.setCurrentCell(cell); } if (move) { e.preventDefault(); } break; case 65: // a if (current.isEditing()) return; if (e.ctrlKey) { if (current.getCheckdRecodes().length !== current.getPagedRecodes().length) { current.recodesCheck(current.getPagedRecodes()); } else { current.checkClear(); } e.preventDefault(); } break; case 67: //c if (current.isEditing()) return; if (e.ctrlKey) { e.preventDefault(); var selection = window.getSelection(); selection.removeAllRanges(); if (!e.altKey) { var textElement = current.getCellTextElementFromCell(current.currentCell); if (textElement) { var userSelect = textElement.style.userSelect; try { textElement.style.userSelect = 'all'; selection.selectAllChildren(textElement); document.execCommand('copy'); selection.removeAllRanges(); } finally { textElement.style.userSelect = userSelect; } } } else { var textElement = document.createElement('div'); if (!e.shiftKey) { var recode = current.getRecodeFromChild(current.currentCell); var copyText = current.getRecodeTexts(recode); textElement.innerHTML = copyText.join(','); } else { var recods = current.getFilterringRecodes(); var len = recods.length; var copyText = []; for (var i = 0; i < len; i++) { var lineTexts = current.getRecodeTexts(recods[i]).join(','); copyText.push(lineTexts); } textElement.innerHTML = copyText.join('\r\n'); } textElement.style.userSelect = 'all'; document.body.appendChild(textElement); selection.selectAllChildren(textElement); document.execCommand('copy'); selection.removeAllRanges(); } } break; case 33: //pageup if (current.isEditing()) return; if (e.shiftKey) { if (current.pageIndex === 0) return; e.preventDefault(); current.previousPage(); } break; case 34: //pagedown if (current.isEditing()) return; if (e.shiftKey) { if (current.pageIndex + 1 === current.paged) return; e.preventDefault(); current.nextPage(); } break; case 35: //end if (current.isEditing()) return; if (e.shiftKey) { e.preventDefault(); current.setPageIndex(-1); } else if (e.ctrlKey) { e.preventDefault(); current.setCurrentCell(current.getPageCell(-1, -1)); } break; case 36: //home if (current.isEditing()) return; if (e.shiftKey) { e.preventDefault(); current.setPageIndex(0); } else if (e.ctrlKey) { e.preventDefault(); current.setCurrentCell(current.getPageCell(0, 0)); } break; case 45: //insert if (!current.insertable) return; if (current.isEditing()) return; if (!e.ctrlKey) { current.insertRecode(null, 1, true); } else { current.CopyAndInsert(); } e.preventDefault(); break; case 73: //i if (!current.insertable) return; if (current.isEditing()) return; if (e.ctrlKey) { if (!e.shiftKey) { current.insertRecode(null, 1, true); } else { current.CopyAndInsert(); } } e.preventDefault(); break; case 112: //F1 e.preventDefault(); current.showHelp(); break; } }; tableEx.getTableExFromChild = function (child) { var p = child.parentElement; while (p && !(p instanceof HTMLTableElement)) { p = p.parentElement; } if (!p) return; return jp.ninesense.ts.tableEx.getInstance(p.id); }; tableEx.getCheckdRecodesAll = function () { return Array.prototype.slice.call(document.querySelectorAll('table.ns-tableEx tr.checked, table.ns-tableEx tbody.checked')); }; tableEx.checkClearAll = function () { var checked = tableEx.getCheckdRecodesAll(); var len = checked.length; //this._checkedItem.classList.remove('checked'); for (var i = 0; i < len; i++) { checked[i].classList.remove('checked'); } }; tableEx.hookForms = {}; tableEx.hookTargets = {}; tableEx.OnHookSubmit = function (e) { var form = e.currentTarget; var targets = tableEx.hookTargets[form.id]; var hookData = form.querySelector('input[name="ns-tableEx-hook"]'); if (!hookData) { hookData = document.createElement('input'); hookData.setAttribute('type', 'hidden'); hookData.name = 'ns-tableEx-hook'; form.appendChild(hookData); } var len = targets.length; var recodeData = []; for (var i = 0; i < len; i++) { var target = targets[i]; var hookMethod = target.table.getAttribute('data-hook-method-input'); var clicked = document.activeElement; var method = 'checked'; if ((clicked instanceof HTMLButtonElement || clicked instanceof HTMLInputElement) && clicked.name === hookMethod) { method = clicked.value; } recodeData[i] = target.getIDList(method); } hookData.value = JSON.stringify(recodeData); }; tableEx.idInc = 0; return tableEx; }()); ts.tableEx = tableEx; var tableExEditor = /** @class */ (function () { function tableExEditor(type) { var _this = this; if (type === void 0) { type = 'text'; } this.setWarning = function (id, warning) { _this.warning.innerHTML = warning; _this.warning.setAttribute('data-warning-id', id); _this.warningWrap.appendChild(_this.warning); }; this.isEditor = function (element) { return (_this.editor === element || _this.view.contains(element)); }; this.focus = function () { var input = _this.editor; input.focus(); if (input instanceof HTMLTextAreaElement || input.type === 'text') { var value = input.value; var len = value.length; input.setSelectionRange(len, len); } }; this.update = function () { _this.autoComp.update(); }; this.hideWarning = function () { if (_this.warning.parentElement) { _this.warning.parentElement.removeChild(_this.warning); _this.warning.removeAttribute('data-warning-id'); } }; this.setEditor = function (parent, value, callBack) { if (value === void 0) { value = ''; } if (callBack === void 0) { callBack = null; } if (tableExEditor.parent === parent) return; _this.onchanged = null; if (tableExEditor.parent) { tableExEditor.parent.classList.remove('ns-tableEx-edit'); } tableExEditor.parent = parent; var wrap = tableExEditor.wrap; if (!parent) { if (wrap && wrap.parentElement) { wrap.parentElement.removeChild(wrap); } return; } parent.appendChild(wrap); parent.classList.add('ns-tableEx-edit'); //tableExEditor.wrap.innerHTML = ''; while (wrap.firstChild) { wrap.removeChild(wrap.firstChild); } wrap.appendChild(_this.view); _this.hideWarning(); _this.settingEditor(value, parent, callBack); _this.entryValue = _this.editor.value; tableExEditor._currentEditor = _this; }; this.settingEditor = function (value, parent, callBack) { if (callBack === void 0) { callBack = null; } var input = _this.editor; if (value === ' ') value = ''; input.value = value; _this.onchanged = callBack; var style = window.getComputedStyle(parent); var editor = _this.editor; editor.style.textAlign = style.textAlign; editor.style.fontFamily = style.fontFamily; editor.style.fontSize = style.fontSize; editor.style.fontWeight = style.fontWeight; editor.style.letterSpacing = style.letterSpacing; editor.style.lineHeight = style.lineHeight; editor.style.minWidth = 'calc(' + style.width + ' - ' + style.paddingLeft + ' - ' + style.paddingRight + ')'; editor.style.width = ''; editor.style.height = ''; var h = editor.scrollHeight; if (h > 400) h = 400; editor.style.height = h.toString() + 'px'; editor.scrollIntoView({ block: "center" }); setTimeout(function () { input.focus(); var len = value.length; if (input instanceof HTMLTextAreaElement || input.type === 'text') { input.setSelectionRange(len, len); } }, 1); }; if (tableExEditor.instance[type]) throw 'tableExEditorのインスタンスを同じタイプで生成出来ません。'; tableExEditor.instance[type] = this; this._inputType = type; if (!tableExEditor.wrap) { var wrap = document.createElement('div'); wrap.classList.add('ns-table-advanced-editor-box'); wrap.classList.add('wrap'); tableExEditor.wrap = wrap; window.addEventListener('click', tableExEditor.OnWindowClick); } var view = document.createElement('div'); view.classList.add('view'); this.view = view; var inner = document.createElement('div'); inner.classList.add('inner'); var warningWrap = document.createElement('div'); this.warningWrap = warningWrap; warningWrap.classList.add('warning-wrap'); inner.appendChild(warningWrap); view.appendChild(inner); var warning = document.createElement('p'); warning.classList.add('editor-warning'); this.warning = warning; this.createEditor(inner); warning.addEventListener('click', tableExEditor.OnWarningClick); } tableExEditor.init = function (newType) { if (newType === void 0) { newType = null; } if (newType) { tableExEditor.instance[newType.inputType] = newType; } }; Object.defineProperty(tableExEditor, "currentEditor", { get: function () { return tableExEditor._currentEditor; }, enumerable: true, configurable: true }); Object.defineProperty(tableExEditor.prototype, "warningID", { get: function () { return this.warning.getAttribute('data-warning-id'); }, enumerable: true, configurable: true }); Object.defineProperty(tableExEditor.prototype, "isEditted", { get: function () { return this.entryValue !== this.editor.value; }, enumerable: true, configurable: true }); tableExEditor.prototype.createEditor = function (block, type) { var _this = this; if (type === void 0) { type = 'textarea'; } var editor = document.createElement(type); editor.classList.add('ns-table-advanced-editor'); editor.id = 'ns-table-advanced-editor-' + this._inputType; this.editor = editor; block.appendChild(editor); jp.ninesense.ts.autoComplete.init(editor, 'inline'); this.autoComp = jp.ninesense.ts.autoComplete.getInstance(editor); this.autoComp.backClickClose = false; this.autoComp.backClickEditCancel = false; this.autoComp.onChangedCallback = function (target, value) { _this.onChanged(target, value); }; return this.autoComp; }; Object.defineProperty(tableExEditor, "Dom", { get: function () { return tableExEditor.wrap; }, enumerable: true, configurable: true }); Object.defineProperty(tableExEditor, "Parent", { get: function () { return tableExEditor.parent; }, enumerable: true, configurable: true }); Object.defineProperty(tableExEditor.prototype, "inputType", { get: function () { return this._inputType; }, enumerable: true, configurable: true }); Object.defineProperty(tableExEditor.prototype, "InputControl", { get: function () { return this.autoComp; }, enumerable: true, configurable: true }); Object.defineProperty(tableExEditor.prototype, "value", { get: function () { return this.editor.value; }, enumerable: true, configurable: true }); tableExEditor.prototype.onChanged = function (target, value) { this.hideWarning(); if (this.onchanged && tableExEditor.parent) { this.onchanged(tableExEditor.parent, value.index, { value: value.value, display: value.display, search: value.display }, true); } }; tableExEditor.instance = {}; tableExEditor.OnWarningClick = function (e) { var warning = e.currentTarget; if (warning.parentElement) warning.parentElement.removeChild(warning); warning.removeAttribute('data-warning-id'); //warning.innerHTML = ''; while (warning.firstChild) { warning.removeChild(warning.firstChild); } }; tableExEditor.OnWindowClick = function (e) { var p = tableExEditor.parent; while (p) { p = p.parentElement; if (p.tagName === 'TABLE') break; } if (!p || !p.contains(e.target)) { if (tableExEditor._currentEditor) { tableExEditor._currentEditor.setEditor(null); } } }; tableExEditor.getInstance = function (type) { if (type === void 0) { type = 'text'; } if (!tableExEditor.instance[type] && type === 'text') { return new tableExEditor(); } return tableExEditor.instance[type]; }; tableExEditor.hideEditor = function () { if (tableExEditor.parent) { tableExEditor.parent.classList.remove('ns-tableEx-edit'); } tableExEditor.parent = null; if (tableExEditor.wrap && tableExEditor.wrap.parentElement) { tableExEditor.wrap.parentElement.removeChild(tableExEditor.wrap); } }; return tableExEditor; }()); ts.tableExEditor = tableExEditor; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var tableExWithLoader = /** @class */ (function (_super) { __extends(tableExWithLoader, _super); function tableExWithLoader(card, recodeTag) { if (recodeTag === void 0) { recodeTag = null; } var _this = _super.call(this, card, recodeTag) || this; _this.updatingCells = {}; _this.updatingRecodes = {}; _this.StartUpdate = function (cell, before, rollback) { if (rollback === void 0) { rollback = false; } var url = _this.onRemoteUpdateUrl(cell, before); if (!url) { return false; } var updateToken = _this.onCreateRemoteUpdateToken(cell, before); if (!rollback) { var rv = _this.onCreateRemoteUpdateValue(cell, before); if (!rv) { return false; } } var loader = tableExWithLoader.loader; cell.classList.add('ns-cell-updating'); cell.classList.remove('ns-cell-updated'); cell.classList.remove('ns-cell-update-error'); if (!rollback) { var token = loader.RequestUrl(url, { type: 'changed', id: _this.id, data: rv, before: before, token: updateToken }, "application/json", false, true, null, "json"); } else { var token = loader.RequestUrl(url, { type: 'rollback', id: _this.id, token: updateToken, rollback: '1' }, "application/json", false, true, null, "json"); } _this.updatingCells[token.id] = cell; return true; }; _this.StartDragUpdate = function (drag, drop, rollback) { if (rollback === void 0) { rollback = false; } var url = _this.onRemoteUpdateUrlDrag(drag, drop); if (!url) { return false; } var updateToken = _this.onCreateRemoteUpdateTokenDrag(drag, drop); var rv = _this.onCreateRemoteUpdateValueDrag(drag, drop); if (!rv) { return false; } var loader = tableExWithLoader.loader; drag.classList.add('ns-drag-updating'); drag.classList.remove('ns-drag-updated'); drag.classList.remove('ns-drag-update-error'); //if (!rollback) { var token = loader.RequestUrl(url, { type: 'drag', id: _this.id, data: rv, token: updateToken }, "application/json", false, true, null, "json"); //} //else { // var token = loader.RequestUrl(url, { id: this.id, token: updateToken, rollback: '1' }, "application/json", false, true, null, "json"); //} _this.updatingRecodes[token.id] = drag; return true; }; _this.LoadEnd = function (token, data) { var table = tableExWithLoader.getInstance(token.query.id); switch (token.query.type) { case 'changed': case 'rollback': var cell = table.updatingCells[token.id]; var beforeData = token.query.before; switch (data.data.status) { case 'success': table.setCellValue(cell, data.data.value); cell.classList.add('ns-cell-updated'); ts.popupBox.getInstance().showMessageBox('table-update' + token.id, '' + data.data.message + '', false, 5000, function (e) { return tableExWithLoader.rollBack(token, cell, e); }); break; case 'rollback': cell.classList.add('ns-cell-updated'); table.setCellValue(cell, data.data.value); ts.popupBox.getInstance().showMessageBox('table-update' + token.id, data.data.message, false, 5000); break; default: cell.classList.add('ns-cell-update-error'); table.setCellValue(cell, beforeData); ts.popupBox.getInstance().showMessageBox('table-update' + token.id, data.data.message, true); break; } tableExWithLoader.exitUpdating(token); break; case 'drag': var rec = table.updatingRecodes[token.id]; switch (data.data.status) { case 'success': rec.classList.add('ns-drag-updated'); ts.popupBox.getInstance().showMessageBox('table-update-drag', '' + data.data.message + '', false, 5000); break; default: rec.classList.add('ns-drag-update-error'); ts.popupBox.getInstance().showMessageBox('table-update-drag', data.data.message, true); break; } tableExWithLoader.exitUpdatingDrag(token); } }; _this.LoadStart = function (token) { switch (token.query.type) { case 'drag': ts.popupBox.getInstance().showMessageBox('table-update-drag', '更新しています。', false, 3000); break; default: ts.popupBox.getInstance().showMessageBox('table-update' + token.id, '更新しています。', false, 3000); } }; _this.LoadError = function (token, ev) { switch (token.query.type) { case 'drag': ts.popupBox.getInstance().showMessageBox('table-update-drag', '更新に失敗しました。', true); break; default: ts.popupBox.getInstance().showMessageBox('table-update' + token.id, '更新に失敗しました。', true); } }; _this.LoadProgress = function (token, ev) { }; if (!tableExWithLoader.loader) { var loader = new ts.Loader(''); tableExWithLoader.loader = loader; loader.method = ts.LoadMethod.POST; loader.AddOwner(_this); loader.autoparse = true; } return _this; } tableExWithLoader.getInstance = function (id) { return _super.getInstance.call(this, id); }; tableExWithLoader.prototype.OnChanged = function (cell, index, value, input) { var before = this.getCellValue(cell); _super.prototype.OnChanged.call(this, cell, index, value, input); if (input) { this.StartUpdate(cell, before); } }; tableExWithLoader.prototype.onCreateRemoteUpdateToken = function (cell, before) { return null; }; tableExWithLoader.prototype.onCreateRemoteUpdateValue = function (cell, before) { return null; }; tableExWithLoader.prototype.onRemoteUpdateUrl = function (cell, before) { return null; }; tableExWithLoader.prototype.onRemoteUpdated = function (cell, res) { }; tableExWithLoader.prototype.onRemoteUpdateUrlDrag = function (drag, drop) { return null; }; tableExWithLoader.prototype.onRemoteUpdatedDrag = function (drag, res) { }; tableExWithLoader.prototype.onCreateRemoteUpdateValueDrag = function (drag, drop) { return null; }; tableExWithLoader.prototype.onCreateRemoteUpdateTokenDrag = function (drag, drop) { return null; }; tableExWithLoader.prototype.OnRecodeDrop = function (e, dragRecode, dropTarget) { return true; }; tableExWithLoader.prototype.OnRecodeDropped = function (e, dragRecode, dropTarget) { _super.prototype.OnRecodeDropped.call(this, e, dragRecode, dropTarget); this.StartDragUpdate(dragRecode, dropTarget); }; tableExWithLoader.prototype.OnOrderChangeClick = function (method, dragRecode, dropTarget) { return _super.prototype.OnOrderChangeClick.call(this, method, dragRecode, dropTarget); }; tableExWithLoader.prototype.OnOrderChanged = function (method, dragRecode, dropTarget) { _super.prototype.OnOrderChanged.call(this, method, dragRecode, dropTarget); this.StartDragUpdate(dragRecode, dropTarget); }; tableExWithLoader.exitUpdating = function (token) { var table = tableExWithLoader.getInstance(token.query.id); var cell = table.updatingCells[token.id]; cell.classList.remove('ns-cell-updating'); delete (table.updatingCells[token.id]); table.onRemoteUpdated(cell, token.getData().data); }; tableExWithLoader.rollBack = function (token, cell, e) { if (e.target.classList.contains('cansel')) { var table = tableExWithLoader.getInstance(token.query.id); var newData = table.getCellValue(cell); //var beforeData = (token.query as any).before as cellValue; if (table.StartUpdate(cell, newData, true)) { return true; } } return false; }; tableExWithLoader.exitUpdatingDrag = function (token) { var table = tableExWithLoader.getInstance(token.query.id); var recode = table.updatingRecodes[token.id]; recode.classList.remove('ns-drag-updating'); delete (table.updatingRecodes[token.id]); table.onRemoteUpdatedDrag(recode, token.getData().data); }; return tableExWithLoader; }(ts.tableEx)); ts.tableExWithLoader = tableExWithLoader; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var devise = /** @class */ (function () { function devise() { } devise.userAgent = navigator.userAgent.toLowerCase(); // iPhone devise.isiPhone = (devise.userAgent.indexOf('iphone') > -1); // iPad devise.isiPad = (devise.userAgent.indexOf('ipad') > -1); // Android devise.isAndroid = (devise.userAgent.indexOf('android') > -1) && (devise.userAgent.indexOf('mobile') > -1); // Android Tablet devise.isAndroidTablet = (devise.userAgent.indexOf('android') > -1) && (devise.userAgent.indexOf('mobile') == -1); devise.isMobile = (devise.userAgent.indexOf('mobile') > -1) || (devise.userAgent.indexOf('Opera Mini') > -1); devise.isIE = (devise.userAgent.indexOf('MSIE') > -1) || (devise.userAgent.indexOf('trident') > -1); devise.isMac = (devise.userAgent.indexOf('Mac OS X') > -1); devise.isSafari = (devise.userAgent.indexOf('safari') !== -1 && devise.userAgent.indexOf('chrome') === -1 && devise.userAgent.indexOf('edge') === -1); devise.supportTouch = 'ontouchend' in document; devise.pointerEvents = (!devise.supportTouch) ? { start: 'mousedown', move: 'mousemove', end: 'mouseup' } : { start: 'touchstart', move: 'touchmove', end: 'touchend' }; return devise; }()); ts.devise = devise; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var http = /** @class */ (function () { function http() { } http.httpRegex = (function () { var regex = new RegExp('https?:\/\/[^\/]*'); return regex; })(); http.httpUnderRegex = (function () { var regex = new RegExp('https?:\/\/[^\/]*'); return regex; })(); http.href = decodeURI(location.href); http.mapping = []; // iPhone http.isHttps = (http.href.indexOf('https://') > -1); http.getDomain = function () { if (!http.domain) { http.domain = location.host; } return http.domain; }; http.getUnderDomain = function () { if (!http.underDomain) { http.underDomain = location.pathname; } return http.underDomain; }; http.getParam = function () { if (!http.param) { var param = decodeURI(location.search.substring(1)).split('&'); var vars = {}; var len = param.length; for (var i = 0; i < len; i++) { var keySearch = param[i].indexOf('='); var key = ''; if (keySearch != -1) key = param[i].slice(0, keySearch); var val = param[i].slice(param[i].indexOf('=', 0) + 1); if (key != '') vars[key] = val; } http.param = vars; } return http.param; }; http.getParamToQuery = function () { var param = http.getParam(); var cnt = 0; var query = ''; for (var key in param) { var value = param[key]; if (cnt !== 0) { query += '&'; } query += encodeURIComponent(key) + '=' + encodeURIComponent(value); cnt++; } return query; }; http.setting = function (url, func) { var under = location.pathname; if (under === url) { func(); } }; http.init = function (url, func) { var under = location.pathname; if (under === url || url === '' || ((url instanceof RegExp) && url.test(under))) { if (!http.mapping[0]) { var loaded = function (e) { var len = http.mapping.length; var param = http.getParam(); for (var i = 0; i < len; i++) { http.mapping[i](param); } }; if (window.addEventListener) { window.addEventListener('load', loaded, false); } else if ('attachEvent' in window) { window.attachEvent('onload', loaded); } else { window.onload = loaded; } } http.mapping.push(func); } }; return http; }()); ts.http = http; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var Enum = /** @class */ (function () { function Enum() { } Enum.GetValues = function (enumType) { var values = []; var e; for (e in enumType) { if (!isNaN(e)) { values.push(e); } } return values; }; Enum.GetNames = function (enumType) { var values = []; var e; for (e in enumType) { if (isNaN(e)) { values.push(e); } } return values; }; Enum.CnvName = function (enumType, value) { if (isNaN(value)) return value.toString(); return enumType[value]; }; /** * 全列挙体の値を利用したループコールバックを実行できる * enumType 列挙体型 * callback 実行関数(戻り値をtrueにすると強制終了) */ Enum.ForEach = function (enumType, callback) { var values = []; var e; for (e in enumType) { if (!isNaN(e)) { if (callback(e, enumType[e])) break; } } }; return Enum; }()); ts.Enum = Enum; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { /**整数表現の色をARGBに分解するクラス * ... * @author s.baba */ var ColorReport = /** @class */ (function () { //public static SetColorRGB = (sorce:Vector.>, export:BitmapData) => { //var len:number = sorce.length - 1; //for (var i:number = 0; i < len; i++ ) { //var data:Vector. = sorce[i]; //var len2:number = data.length - 1; //for (var j:number = 0; j < len2; j++) export.setPixel(j, i, sorce[j][i]); //} //} // //public static SetColorARGB = (sorce:Vector.>, export:BitmapData) => { //var len:number = sorce.length - 1; //for (var i:number = 0; i < len; i++ ) { //var data:Vector. = sorce[i]; //var len2:number = data.length - 1; //for (var j:number = 0; j < len2; j++) export.setPixel32(j, i, sorce[j][i]); //} //} function ColorReport(color) { var _this = this; this._boolAlpha = true; /**ARGBの値を加算して、色を返す(色の値は保持される) * @param addAlpha * @param addRed * @param addGreen * @param addBlue * @return */ this.AddARGB = function (addAlpha, addRed, addGreen, addBlue) { _this.alpha += addAlpha; _this.red += addRed; _this.green += addGreen; _this.blue += addBlue; var maxElement = ColorReport.maxElement; _this.alpha = (_this.alpha > maxElement) ? maxElement : (_this.alpha < 0) ? 0 : _this.alpha; _this.red = (_this.red > maxElement) ? maxElement : (_this.red < 0) ? 0 : _this.red; _this.green = (_this.green > maxElement) ? maxElement : (_this.green < 0) ? 0 : _this.green; _this.blue = (_this.blue > maxElement) ? maxElement : (_this.blue < 0) ? 0 : _this.blue; if (_this._boolAlpha) return _this.alpha << 24 | _this.red << 16 | _this.green << 8 | _this.blue << 0; else return _this.red << 16 | _this.green << 8 | _this.blue << 0; }; this.Average = function (color) { var a; var colorMask = ColorReport.colorMask; var r = color >> ColorReport.redLocation & colorMask; var g = color >> ColorReport.greenLocation & colorMask; var b = color >> ColorReport.blueLocation & colorMask; var maxRGB = ColorReport.maxRGB; if (color > maxRGB) a = (color >> ColorReport.alphaLocation & colorMask); else a = 0xFF; if (_this._boolAlpha) return ((_this.alpha + a) * 0.5) << 24 | ((_this.red + r) * 0.5) << 16 | ((_this.green + g) * 0.5) << 8 | ((_this.blue + b) * 0.5) << 0; else return ((_this.red + r) * 0.5) << 16 | ((_this.green + g) * 0.5) << 8 | ((_this.blue + b) * 0.5) << 0; }; this.Gradiation = function (toColor, length, gra) { if (gra === void 0) { gra = null; } var a; var colorMask = ColorReport.colorMask; var r = toColor >> ColorReport.redLocation & colorMask; var g = toColor >> ColorReport.greenLocation & colorMask; var b = toColor >> ColorReport.blueLocation & colorMask; if (toColor > ColorReport.maxRGB) a = (toColor >> ColorReport.alphaLocation & colorMask); else { a = 0xFF; } length -= 1; var ta = (a - _this.alpha); // / length; var tr = (r - _this.red); // / length; var tg = (g - _this.green); // / length; var tb = (b - _this.blue); // / length; if (gra !== null) { gra.length = length + 1; } else gra = []; a = _this.alpha; r = _this.red; g = _this.green; b = _this.blue; //length += 1; for (var i = 0; i <= length; i++) { if (_this._boolAlpha) gra[i] = a << 24 | r << 16 | g << 8 | b << 0; else gra[i] = r << 16 | g << 8 | b << 0; a = _this.alpha + ta * (i + 1) / length; r = _this.red + tr * (i + 1) / length; g = _this.green + tg * (i + 1) / length; b = _this.blue + tb * (i + 1) / length; } return gra; }; this.HSV = function (hsv) { if (hsv === void 0) { hsv = null; } if (hsv === null) hsv = ColorReport.hsv; var vr = _this.red; var vg = _this.green; var vb = _this.blue; var max = (vr > vg) ? vr : vg; max = (max > vb) ? max : vb; var h = 0; var min = (vr < vg) ? vr : vg; min = (min < vb) ? min : vb; switch (max) { case vr: h = 60 * ((vg - vb)) / (max - min); break; case vg: h = (60 * ((vb - vr)) / (max - min)) + 120; break; default: h = (60 * ((vr - vg)) / (max - min)) + 240; break; } hsv[0] = h; hsv[1] = (max - min) / max; hsv[2] = max; return hsv; }; this.setHSV = function (h, s, v) { if (h === void 0) { h = 359; } if (s === void 0) { s = 1; } if (v === void 0) { v = 0xff; } if (s === 0) { _this.red = v; _this.green = v; _this.blue = v; return _this; } while (h < 0) { h += 360; } while (h >= 360) { h -= 360; } s = (s < 0) ? 0 : ((1 < s) ? 1 : s); v = (v < 0) ? 0 : ((0xff < v) ? 0xff : v); var hh = ts.MathBit.floor(h / 60) % 6; var f = h / 60 - hh; var p = v * (1 - s); var q = v * (1 - (f * s)); var t = v * (1 - ((1 - f) * s)); switch (hh) { case 0: _this.red = v; _this.green = t; _this.blue = p; break; case 1: _this.red = q; _this.green = v; _this.blue = p; break; case 2: _this.red = p; _this.green = v; _this.blue = t; break; case 3: _this.red = p; _this.green = q; _this.blue = v; break; case 4: _this.red = t; _this.green = p; _this.blue = v; break; case 5: _this.red = v; _this.green = p; _this.blue = q; break; } //if (red > 0xff || green > 0xff || blue > 0xff) { //trace("aaaaaaaaaa"); //} return _this; }; this._boolAlpha = color > ColorReport.maxRGB; if (this._boolAlpha) this.alpha = (color >> ColorReport.alphaLocation & ColorReport.colorMask); else this.alpha = 0xFF; this.red = color >> ColorReport.redLocation & ColorReport.colorMask; this.green = color >> ColorReport.greenLocation & ColorReport.colorMask; this.blue = color >> ColorReport.blueLocation & ColorReport.colorMask; } Object.defineProperty(ColorReport.prototype, "color32", { /**プロパティ:カラー*/ get: function () { return this.alpha << 24 | this.red << 16 | this.green << 8 | this.blue << 0; }, set: function (value) { this._boolAlpha = value > ColorReport.maxRGB; if (this._boolAlpha) this.alpha = (value >> ColorReport.alphaLocation & ColorReport.colorMask); else this.alpha = 0xFF; var colorMask = ColorReport.colorMask; this.red = value >> ColorReport.redLocation & colorMask; this.green = value >> ColorReport.greenLocation & colorMask; this.blue = value >> ColorReport.blueLocation & colorMask; }, enumerable: true, configurable: true }); Object.defineProperty(ColorReport.prototype, "color", { /**プロパティ:カラー*/ get: function () { return this.red << 16 | this.green << 8 | this.blue << 0; }, set: function (value) { this._boolAlpha = false; var colorMask = ColorReport.colorMask; this.red = value >> ColorReport.redLocation & colorMask; this.green = value >> ColorReport.greenLocation & colorMask; this.blue = value >> ColorReport.blueLocation & colorMask; }, enumerable: true, configurable: true }); ColorReport.colorMask = 0xFF; ColorReport.alphaLocation = 24; ColorReport.redLocation = 16; ColorReport.greenLocation = 8; ColorReport.blueLocation = 0; ColorReport.maxRGB = 0xFFFFFF; ColorReport.maxElement = 255; ColorReport.PublicInstance = function (color) { if (!ColorReport.m_PublicInstance) ColorReport.m_PublicInstance = new ColorReport(color); else ColorReport.m_PublicInstance.color32 = color; return ColorReport.m_PublicInstance; }; ColorReport.GetRGB = function (color) { return 0xFFFFFF & color; }; ColorReport.GetAlpha32 = function (color) { return 0xFF000000 & color; }; ColorReport.GetAlpha = function (color) { return color >> ColorReport.alphaLocation & ColorReport.colorMask; }; ColorReport.GetRedfromARGB32 = function (color) { return 0xFF0000 & color; }; ColorReport.GetGleenfromARGB32 = function (color) { return 0xFF00 & color; }; ColorReport.GetBluefromARGB32 = function (color) { return 0xFF & color; }; ColorReport.GetRed = function (color) { return color >> ColorReport.redLocation & ColorReport.colorMask; }; ColorReport.GetGleen = function (color) { return color >> ColorReport.greenLocation & ColorReport.colorMask; }; ColorReport.GetBlue = function (color) { return color >> ColorReport.blueLocation & ColorReport.colorMask; }; ColorReport.GetColorRGB = function (bitmapdata, data) { if (data === void 0) { data = null; } if (data === null) data = []; var w = bitmapdata.canvas.width; var h = bitmapdata.canvas.height; var bitmapData = bitmapdata.getImageData(0, 0, w, h); var cnt = 0; var pub = ColorReport.PublicInstance(0); for (var i = 0; i < h; i++) { var dit = []; for (var j = 0; j < w; j++) { pub.red = bitmapData.data[cnt]; pub.green = bitmapData.data[cnt + 1]; pub.blue = bitmapData.data[cnt + 2]; pub.alpha = bitmapData.data[cnt + 3]; dit[j] = pub.color; cnt += 4; } data[i] = dit; } return data; }; /* public DrawGradiation = (bitmapData: CanvasRenderingContext2D, toColor: number, start: number, end: number, vartical: Boolean = true) => { var a: number; let colorMask = ColorReport.colorMask; var r: number = toColor >> ColorReport.redLocation & colorMask; var g: number = toColor >> ColorReport.greenLocation & colorMask; var b: number = toColor >> ColorReport.blueLocation & colorMask; if (toColor > ColorReport.maxRGB) a = (toColor >> ColorReport.alphaLocation & colorMask); else { a = 0xFF; } var ta: number = (a - this.alpha);// / length; var tr: number = (r - this.red);// / length; var tg: number = (g - this.green);// / length; var tb: number = (b - this.blue);// / length; a = this.alpha; r = this.red; g = this.green; b = this.blue; //length += 1; var rect: Rects = Rects.Catch(); try { if (vartical) { rect.width = bitmapData.canvas.width; rect.height = 1; } else { rect.width = 1; rect.height = bitmapData.canvas.height; } var c: number = 0; var length: number = end - start; for (var i: number = 0; i <= length; i++) { if (this._boolAlpha) c = a << 24 | r << 16 | g << 8 | b << 0; else c = colorMask << 24 | r << 16 | g << 8 | b << 0; if (vartical) rect.y = i + start; else rect.x = i + start; bitmapData.fillRect(rect.x, rect.y, rect.width, rect.height, c); a = this.alpha + ta * (i + 1) / length; r = this.red + tr * (i + 1) / length; g = this.green + tg * (i + 1) / length; b = this.blue + tb * (i + 1) / length; } } finally { Rects.Release(rect); } } */ ColorReport.colorSpectol = function (scale) { if (scale === void 0) { scale = 360; } var spectol = []; var pi = Math.PI; var rep = ColorReport.PublicInstance(0); var r = 0xff; var g = 0; var b = 0; rep.red = r; rep.green = g; rep.blue = b; spectol.push(0xff0000); var ret = scale / 6; var i = 0; //R-Y while ((i = i + 1) <= ret) { rep.green = ts.MathBit.floor((0xff * i / ret) + .4); spectol[spectol.length] = rep.color; } i = ret; //Y-G while ((i--) > 0) { rep.red = ts.MathBit.floor((0xff * i / ret) + .4); spectol[spectol.length] = rep.color; } i = 0; //G-GB while ((i = i + 1) <= ret) { rep.blue = ts.MathBit.floor((0xff * i / ret) + .4); spectol[spectol.length] = rep.color; } i = ret; //GB-B while ((i--) > 0) { rep.green = ts.MathBit.floor((0xff * i / ret) + .4); spectol[spectol.length] = rep.color; } i = 0; //B-P while ((i = i + 1) <= ret) { rep.red = ts.MathBit.floor((0xff * i / ret) + .4); spectol[spectol.length] = rep.color; } i = ret; //P-R while ((i--) > 0) { rep.blue = ts.MathBit.floor((0xff * i / ret) + .4); spectol[spectol.length] = rep.color; } return spectol; }; ColorReport.hsv = []; return ColorReport; }()); ts.ColorReport = ColorReport; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var Locale; (function (Locale) { Locale[Locale["empty"] = 0] = "empty"; Locale[Locale["jp"] = 1] = "jp"; Locale[Locale["en"] = 2] = "en"; Locale[Locale["cn"] = 3] = "cn"; Locale[Locale["tw"] = 4] = "tw"; })(Locale = ts.Locale || (ts.Locale = {})); /** * lang short summary. * * lang description. * * @version 1.0 * @author baba */ var Lang = /** @class */ (function () { function Lang() { } Lang._lang = Locale.empty; Lang.GetLangFromURL = function () { if (Lang._lang !== Locale.empty) return Lang._lang; var href = location.href; var loc = Locale.empty; var langs = []; ts.Enum.ForEach(Locale, function (value, name) { if (href.indexOf('lang=' + name) !== -1) { loc = value; return true; } langs.push(name); }); if (loc !== Locale.empty) return Lang._lang = loc; Lang._regExS = new RegExp('\/(' + langs.join('|') + ')(?:\/|$)', ''); var ret = Lang._regExS.exec(href); if (ret === null || ret.length === 0) return Locale.empty; var locName = ret[0].replace(/\//g, ''); return Lang._lang = Locale[locName]; }; return Lang; }()); ts.Lang = Lang; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var alignH; (function (alignH) { alignH[alignH["left"] = 0] = "left"; alignH[alignH["center"] = 1] = "center"; alignH[alignH["right"] = 2] = "right"; })(alignH = ts.alignH || (ts.alignH = {})); var alignV; (function (alignV) { alignV[alignV["top"] = 0] = "top"; alignV[alignV["center"] = 1] = "center"; alignV[alignV["bottom"] = 2] = "bottom"; })(alignV = ts.alignV || (ts.alignV = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var LPoint; (function (LPoint) { LPoint[LPoint["INNER"] = 0] = "INNER"; LPoint[LPoint["TOP"] = 1] = "TOP"; LPoint[LPoint["LEFT"] = 2] = "LEFT"; LPoint[LPoint["RIGHT"] = 8] = "RIGHT"; LPoint[LPoint["BOTTOM"] = 4] = "BOTTOM"; LPoint[LPoint["TOP_LEFT"] = 3] = "TOP_LEFT"; LPoint[LPoint["TOP_RIGHT"] = 9] = "TOP_RIGHT"; LPoint[LPoint["BOTTOM_LEFT"] = 6] = "BOTTOM_LEFT"; LPoint[LPoint["BOTTOM_RIGHT"] = 12] = "BOTTOM_RIGHT"; LPoint[LPoint["ALL"] = 4294967295] = "ALL"; LPoint[LPoint["TOP_ROUND"] = 11] = "TOP_ROUND"; LPoint[LPoint["BOTTOM_ROWND"] = 4294967040] = "BOTTOM_ROWND"; LPoint[LPoint["LEFT_ROWND"] = 16777215] = "LEFT_ROWND"; LPoint[LPoint["RIGHT_ROWND"] = 4294902015] = "RIGHT_ROWND"; })(LPoint = ts.LPoint || (ts.LPoint = {})); /** * ... * @author DefaultUser (Tools -> Custom Arguments...) */ var Locate = /** @class */ (function () { function Locate(str, no) { this.toString = function () { return name; }; this.name = str; this.no = no; } /**矩形を指定し、指定ポイントが矩形内にあるか判別する。 * @param x 指定座標X * @param y 指定座標Y * @param mainRect 矩形 * @return */ Locate.InLocation = function (x, y, mainRect) { var left; var right; var top; var bottom; if (0 < mainRect.width) { left = mainRect.x; right = left + mainRect.width; } else { right = mainRect.x; left = right + mainRect.width; } if (0 < mainRect.height) { top = mainRect.y; bottom = top + mainRect.height; } else { bottom = mainRect.y; top = bottom + mainRect.height; } return (left <= x && x <= right && top <= y && y <= bottom); }; /**矩形を2つ指定し、一方がもう一方の矩形に重なるか判定する。 * @param rect 判定矩形 * @param mainRect 矩形 * @return */ Locate.OverRect = function (smallRect, largeRect) { var right = smallRect.x + smallRect.width; var rightL = largeRect.x + largeRect.width; var bottom = smallRect.y + smallRect.height; var bottomL = largeRect.y + largeRect.height; return ((largeRect.x <= smallRect.x && smallRect.x <= rightL) || (largeRect.x <= right && right <= rightL)) && ((largeRect.y <= smallRect.y && smallRect.y <= bottomL) || (largeRect.y <= bottom && bottom <= bottomL)); }; /**矩形を2つ指定し、一方がもう一方の矩形内にあるか判別する。 * @param x 指定座標X * @param y 指定座標Y * @param mainRect 矩形 * @return */ Locate.OverRectDisp = function (smallRect, largeRect) { var right = smallRect.right; var rightL = largeRect.x + largeRect.width; var bottom = smallRect.bottom; var bottomL = largeRect.y + largeRect.height; return ((largeRect.x <= smallRect.left && smallRect.left <= rightL) || (largeRect.x <= right && right <= rightL)) && ((largeRect.y <= smallRect.top && smallRect.top <= bottomL) || (largeRect.y <= bottom && bottom <= bottomL)); }; /**矩形を指定し、指定ポイントが矩形外部上どの位置に存在するか判断する。 * 矩形の内側であった場合、0を返す。 * @param point 指定座標 * @param mainRect 矩形 * @param inWidth 矩形の左右の線の幅 * @param inHeight 矩形の上下の線の幅 * @return */ Locate.OutLocation = function (x, y, mainRect) { var left; var right; var top; var bottom; if (0 < mainRect.width) { left = mainRect.x; right = left + mainRect.width; } else { right = mainRect.x; left = right + mainRect.width; } if (0 < mainRect.height) { top = mainRect.y; bottom = top + mainRect.height; } else { bottom = mainRect.y; top = bottom + mainRect.height; } var INT = 0; if (x < left) INT += LPoint.LEFT; else if (right < x) INT += LPoint.RIGHT; if (y < top) INT += LPoint.TOP; else if (bottom < y) INT += LPoint.BOTTOM; return INT; }; Locate.ZeroPointLocation = function (zero, target) { return Locate.ZeroLocation(zero.x, zero.y, target.x, target.y); }; Locate.ZeroLocation = function (zx, zy, tx, ty) { var topOrBottom = (zy > ty) ? LPoint.TOP : ((zy < ty) ? LPoint.BOTTOM : 0); var leftOrRight = (zx > tx) ? LPoint.LEFT : ((zx < tx) ? LPoint.RIGHT : 0); return topOrBottom + leftOrRight; }; /** pointの配列を全て交差しない全ての座標を繋げた閉じた線形を結べる順番にソートする * index=0になるpointはy座標が最も小さい座標 * Yの下方向を正とした場合、線形は必ず時計の反時計周りに引かれるものとする * @param {point[]}points 対象となるx,y座標を持つオブジェクト * @return ソートされた、新しい配列 閉じた線を結ぶ際は{0-1,1-2...X-0}の順に線を描画する */ Locate.SortPointToUncrossLine = function (points) { var sortArc = []; var map; var len = points.length; var first; for (var i = 0; i < len; i++) { var point = points[i]; if (first === undefined) first = point; else if (first.y > point.y) first = point; map[point.x.toString() + ':' + point.y.toString()] = { index: i, point: point }; } for (var i = 0; i < len; i++) { var point = points[i]; sortArc.push(Math.atan2(point.y - first.y, point.x - first.x)); } if (first === undefined) return; return points.sort(function (a, b) { var arc1 = sortArc[a.x.toString() + ':' + a.y.toString()]; var arc2 = sortArc[b.x.toString() + ':' + b.y.toString()]; return (arc1 === arc2) ? 0 : ((arc1 < arc2) ? -1 : 1); }); }; /**矩形と、その矩形の内側へ幅を指定し、指定ポイントがsの幅のある矩形上、もしくは矩形外部上に存在するかを判断する。 * また線形上に存在した場合、どの位置に指定ポイントが存在するかのLocationを返す。 * @param point 指定座標 * @param mainRect 矩形 * @param inWidth 矩形の左右の線の幅 * @param inHeight 矩形の上下の線の幅 * @return */ Locate.HitLocation = function (x, y, mainRect, inWidth, inHeight) { //var left:number = mainRect.x; //var right:number = left + mainRect.w + mainRect.x; //var top:number = mainRect.y; //var bottom:number = top + mainRect.h + mainRect.y; if (inWidth === void 0) { inWidth = 0; } if (inHeight === void 0) { inHeight = 0; } var left; var right; var top; var bottom; if (0 < mainRect.width) { left = mainRect.x; right = left + mainRect.width; } else { right = mainRect.x; left = right + mainRect.width; } if (0 < mainRect.height) { top = mainRect.y; bottom = top + mainRect.height; } else { bottom = mainRect.y; top = bottom + mainRect.height; } var INT = 0; if (left <= x && x <= left + inWidth) INT += LPoint.LEFT; else if (right - inWidth <= x && x <= right) INT += LPoint.RIGHT; if (top <= y && y <= top + inHeight) INT += LPoint.TOP; else if (bottom - inHeight <= y && y <= bottom) INT += LPoint.BOTTOM; else if (top + inHeight <= y && y <= bottom - inHeight) INT = 0; return INT; }; /**矩形と、その線形の内側の幅を指定し、指定ポイントが矩形上、もしくは矩形外部上に存在するかを判断する。 * また線形上に存在した場合、どの位置に指定ポイントが存在するかのLocationを返す。 * @param point 指定座標 * @param mainRect 矩形 * @param inWidth 矩形の左右の線の幅 * @param inHeight 矩形の上下の線の幅 * @return */ Locate.HitpointLocation = function (point, mainRect, inWidth, inHeight) { if (inWidth === void 0) { inWidth = 0; } if (inHeight === void 0) { inHeight = 0; } var x = point.x; var y = point.y; var left; var right; var top; var bottom; if (0 < mainRect.width) { left = mainRect.x; right = left + mainRect.width; } else { right = mainRect.x; left = right + mainRect.width; } if (0 < mainRect.height) { top = mainRect.y; bottom = top + mainRect.height; } else { bottom = mainRect.y; top = bottom + mainRect.height; } var INT = 0; if (left <= x && x <= left + inWidth) INT += LPoint.LEFT; else if (right - inWidth <= x && x <= right) INT += LPoint.RIGHT; if (top <= y && y <= top + inHeight) INT += LPoint.TOP; else if (bottom - inHeight <= y && y <= bottom) INT += LPoint.BOTTOM; else if (top + inHeight <= y && y <= bottom - inHeight) INT = 0; return INT; }; /**二つの矩形の位置関係を調べる。 * 面積を 矩形A < 矩形B とし矩形Bのどの位置に矩形Aが存在するかを調べる * * @param mainRect * @param objectRect * @return */ Locate.OverLocationRect = function (smallRect, bigRect) { var topOrButton = (bigRect.y > smallRect.y) ? LPoint.TOP : ((bigRect.y + bigRect.height < smallRect.y + smallRect.height) ? LPoint.BOTTOM : 0); var leftOrRight = (bigRect.x > smallRect.x) ? LPoint.LEFT : ((bigRect.x + bigRect.width < smallRect.x + smallRect.width) ? LPoint.RIGHT : 0); return topOrButton + leftOrRight; //const locationArray:/*Location*/Array = [topOrButton, leftOrRight]; //var i:number; //var locationStr:string = ""; //var cnt:number; //for (i = 0; i < 4; i++ ) { //if (locationArray[i]) { //if (cnt > 0) locationStr += "_"; //locationStr += string(locationArray[i]); //cnt++; //} //} // //switch (locationStr) { //case(locationPoint[locationPoint.TOP]): //return TOP; //break; //case(locationPoint[locationPoint.LEFT]): //return LEFT; //break; //case(locationPoint[locationPoint.RIGHT]): //return RIGHT; //break; //case(locationPoint[locationPoint.BOTTOM]): //return BOTTOM; //break; //case(TOP_locationPoint[locationPoint.LEFT]): //return TOP_LEFT; //break; //case(TOP_locationPoint[locationPoint.RIGHT]): //return TOP_RIGHT; //break; //case(BOTTOM_locationPoint[locationPoint.LEFT]): //return BOTTOM_LEFT; //break; //case(BOTTOM_locationPoint[locationPoint.RIGHT]): //return BOTTOM_RIGHT; //break; //default: //return null; //break; //} }; return Locate; }()); ts.Locate = Locate; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var Rects = /** @class */ (function () { function Rects(x, y, width, height) { var _this = this; if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } if (width === void 0) { width = 0; } if (height === void 0) { height = 0; } this.x = 0; this.width = 0; this.y = 0; this.height = 0; /**変更する幅を指定し、等倍で高さも変更する。実際何倍されたかを返す*/ this.AsWidth = function (width) { var b = width / _this.width; _this.height = _this.height * b; _this.width = width; return b; }; /**変更する高さを指定し、等倍で幅も変更する。実際何倍されたかを返す*/ this.AsHeight = function (height) { var b = height / _this.height; _this.width = _this.width * b; _this.height = height; return b; }; /**中心座標を変えずに幅と高さに加算する*/ this.CenterPinAdd = function (width, height) { _this.x -= width * 0.5; _this.width += width; _this.y -= height * 0.5; _this.height += height; return _this; }; /**中心座標を指定して移動する*/ this.CenterTo = function (x, y) { _this.x = x - _this.width * 0.5; _this.y = y - _this.height * 0.5; return _this; }; /**指定サイズに隣接するように等倍で拡大縮小する*/ this.AsInSize = function (w, h) { if (h / _this.height < w / _this.width) { return _this.AsHeight(h); } else { return _this.AsWidth(w); } }; /**指定サイズに隣接するように等倍で拡大縮小する*/ this.AsOverSize = function (w, h) { if (h / _this.height > w / _this.width) { return _this.AsHeight(h); } else { return _this.AsWidth(w); } }; /**変更する幅を指定し、等倍で高さも変更する。実際何倍されたかを返す*/ this.AsWidthInt = function (width) { var b = ts.MathBit.floor(width / _this.width); _this.height *= b; _this.width *= b; return b; }; /**変更する高さを指定し、等倍で幅も変更する。実際何倍されたかを返す*/ this.AsHeightInt = function (height) { var b = ts.MathBit.floor(height / _this.height); _this.width *= b; _this.height *= b; return b; }; /**指定サイズに隣接するように等倍で拡大縮小する*/ this.AsInSizeInt = function (w, h) { if (h / _this.height < w / _this.width) { return _this.AsHeightInt(h); } else { return _this.AsWidthInt(w); } }; /**全体を内側へ縮小する*/ //public Inflat = (offset:number):void { //x += offset; //y += offset; //width -= offset*2; //height -= offset * 2; // //} /**其々の値に加算*/ this.OffsetP = function (offsetX, offsetY, offsetW, offsetH) { _this.x += offsetX; _this.y += offsetY; _this.width += offsetW; _this.height += offsetH; return _this; }; /**其々の値に減算*/ this.OffsetM = function (offsetX, offsetY, offsetW, offsetH) { _this.x -= offsetX; _this.y -= offsetY; _this.width -= offsetW; _this.height -= offsetH; return _this; }; /**横長*/ this.isLandscape = function () { return _this.width >= _this.height; }; this.Equal = function (target) { return (_this.width === target.width && _this.height === target.height && _this.x === target.x && _this.y === target.y); }; this.EqualDis = function (target) { return (_this.width === target.width && _this.height === target.height && _this.x === target.left && _this.y === target.top); }; this.EqualSizeDis = function (target) { return (_this.width === target.width && _this.height === target.height); }; this.EqualSizeBitmap = function (target) { return (_this.width === target.width && _this.height === target.height); }; this.EqualSize = function (width, height) { return (_this.width === width && _this.height === height); }; this.toString = function () { return "Rects:(x = " + _this.x.toString() + " y = " + _this.y.toString() + " width = " + _this.width.toString() + " height = " + _this.height.toString() + ")"; }; this.x = x; this.y = y; this.width = width; this.height = height; } Rects.m_pool = []; Rects.Catch = function (x, y, w, h) { if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } if (w === void 0) { w = 0; } if (h === void 0) { h = 0; } var rect; var m_pool = Rects.m_pool; if (m_pool.length !== 0) { rect = m_pool[m_pool.length - 1]; m_pool.length -= 1; rect.x = x; rect.y = y; rect.width = w; rect.height = h; } else { rect = new Rects(x, y, w, h); } return rect; }; Rects.Release = function (rect) { if (rect === null) return; var m_pool = Rects.m_pool; if (m_pool.indexOf(rect) >= 0) return; rect.x = NaN; rect.y = NaN; rect.width = NaN; rect.height = NaN; m_pool[m_pool.length] = rect; }; Rects.SetRects = function (x, y, w, h, rect) { if (x === void 0) { x = 0; } if (y === void 0) { y = 0; } if (w === void 0) { w = 0; } if (h === void 0) { h = 0; } if (rect === void 0) { rect = null; } if (rect === null) rect = Rects.Catch(x, y, w, h); else { rect.x = x; rect.y = y; rect.width = w; rect.height = h; } return rect; }; Rects.copyTo = function (from, to) { to.x = from.x; to.y = from.y; to.width = from.width; to.height = from.height; }; /** 二つの矩形を完全に含む大きな矩形を作成 */ Rects.Union = function (rect1, rect2, unionRects) { if (unionRects === void 0) { unionRects = null; } if (unionRects === null) { unionRects = Rects.Catch(0, 0, 0, 0); } var l1; var r1; var t1; var b1; if (0 < rect1.width) { l1 = rect1.x; r1 = l1 + rect1.width; } else { r1 = rect1.x; l1 = r1 + rect1.width; } if (0 < rect1.height) { t1 = rect1.y; b1 = t1 + rect1.height; } else { b1 = rect1.y; t1 = b1 + rect1.height; } var l2; var r2; var t2; var b2; if (0 < rect2.width) { l2 = rect2.x; r2 = l2 + rect2.width; } else { r2 = rect2.x; l2 = r2 + rect2.width; } if (0 < rect2.height) { t2 = rect2.y; b2 = t2 + rect2.height; } else { b2 = rect2.y; t2 = b2 + rect2.height; } unionRects.x = (l1 < l2) ? l1 : l2; unionRects.y = (t1 < t2) ? t1 : t2; unionRects.width = ((r1 < r2) ? r2 : r1) - unionRects.x; unionRects.height = ((b1 < b2) ? b2 : b1) - unionRects.y; return unionRects; }; /** 二つの矩形の重なる部分の矩形を返す */ Rects.Intersection = function (rect1, rect2, interRects) { if (interRects === void 0) { interRects = null; } if (interRects === null) { interRects = Rects.Catch(0, 0, 0, 0); } var l1; var r1; var t1; var b1; if (0 < rect1.width) { l1 = rect1.x; r1 = l1 + rect1.width; } else { r1 = rect1.x; l1 = r1 + rect1.width; } if (0 < rect1.height) { t1 = rect1.y; b1 = t1 + rect1.height; } else { b1 = rect1.y; t1 = b1 + rect1.height; } var l2; var r2; var t2; var b2; if (0 < rect2.width) { l2 = rect2.x; r2 = l2 + rect2.width; } else { r2 = rect2.x; l2 = r2 + rect2.width; } if (0 < rect2.height) { t2 = rect2.y; b2 = t2 + rect2.height; } else { b2 = rect2.y; t2 = b2 + rect2.height; } interRects.x = (l1 < l2) ? l2 : l1; interRects.y = (t1 < t2) ? t2 : t1; interRects.width = ((r1 < r2) ? r1 : r2) - interRects.x; interRects.height = ((b1 < b2) ? b1 : b2) - interRects.y; return interRects; }; Rects.Difference = function (main, diff, differenceRects, temporarily) { if (differenceRects === void 0) { differenceRects = null; } if (temporarily === void 0) { temporarily = false; } if (differenceRects === null) { differenceRects = Rects.Catch(0, 0, 0, 0); } differenceRects.x = main.x; differenceRects.y = main.y; differenceRects.width = main.width; differenceRects.height = main.height; var l1; var r1; var t1; var b1; if (0 < main.width) { l1 = main.x; r1 = l1 + main.width; } else { r1 = main.x; l1 = r1 + main.width; } if (0 < main.height) { t1 = main.y; b1 = t1 + main.height; } else { b1 = main.y; t1 = b1 + main.height; } var l2; var r2; var t2; var b2; if (0 < diff.width) { l2 = diff.x; r2 = l2 + diff.width; } else { r2 = diff.x; l2 = r2 + diff.width; } if (0 < diff.height) { t2 = diff.y; b2 = t2 + diff.height; } else { b2 = diff.y; t2 = b2 + diff.height; } if (l1 < l2 && l2 < r1) { differenceRects.width = r1 - l2; } else if (l2 < l1 && l1 < r2) { differenceRects.x = r2; differenceRects.width = r1 - r2; } else if (l1 === l2 && r1 === r2) { differenceRects.width = 0; } if (t1 < t2 && t2 < b1) { differenceRects.height = b1 - t2; } else if (t2 < t1 && t1 < b2) { differenceRects.y = b2; differenceRects.height = b1 - b2; } else if (t1 === t2 && b1 === b2) { differenceRects.height = 0; } if (((r1 < r2) ? r1 : r2) - ((l1 < l2) ? l2 : l1) <= 0) { differenceRects.width = 0; } if (((b1 < b2) ? b1 : b2) - ((t1 < t2) ? t2 : t1) <= 0) { differenceRects.height = 0; } return differenceRects; }; /** stageRectsに対し、内側に整列方法を指定して配置される矩形を返す */ Rects.ConvertInner = function (main, stageRects, align, valign, convertRects, temporarily) { if (align === void 0) { align = null; } if (valign === void 0) { valign = null; } if (convertRects === void 0) { convertRects = null; } if (temporarily === void 0) { temporarily = false; } if (convertRects === null) { convertRects = Rects.Catch(0, 0, 0, 0); } var x = main.x; var y = main.y; var w = main.width; var h = main.height; if (stageRects.width < w) { w = stageRects.width; } switch (align) { case ts.alignH.center: if (w < stageRects.width) { x = stageRects.x + ((stageRects.width - w) * .5); } else { x = stageRects.x; } break; case ts.alignH.right: x = stageRects.x + (stageRects.width - w); break; default: x = stageRects.x; } if (stageRects.height < h) { h = stageRects.height; } switch (valign) { case ts.alignV.center: if (h < stageRects.height) { y = stageRects.y + ((stageRects.height - h) * .5); } else { y = stageRects.y; } break; case ts.alignV.bottom: y = stageRects.y + (stageRects.height - h); break; default: y = stageRects.y; } convertRects.x = x; convertRects.y = y; convertRects.width = w; convertRects.height = h; return convertRects; }; Rects.CopyToRects = function (rect, toRects) { if (toRects === void 0) { toRects = null; } if (toRects === null) toRects = Rects.Catch(rect.x, rect.y, rect.width, rect.height); else { toRects.x = rect.x; toRects.y = rect.y; toRects.width = rect.width; toRects.height = rect.height; } return toRects; }; Rects.fromrect = function (rectangle, rect) { if (rect === void 0) { rect = null; } if (rect === null) rect = Rects.Catch(rectangle.x, rectangle.y, rectangle.width, rectangle.height); else { rect.x = rectangle.x; rect.y = rectangle.y; rect.width = rectangle.width; rect.height = rectangle.height; } return rect; }; Rects.torect = function (rect, rectangle) { if (rectangle === void 0) { rectangle = null; } if (rectangle === null) rectangle = { x: rect.x, y: rect.y, width: rect.width, height: rect.height }; else { rectangle.x = rect.x; rectangle.y = rect.y; rectangle.width = rect.width; rectangle.height = rect.height; } return rectangle; }; Rects.CopySizeAny = function (object, rect) { if (rect === void 0) { rect = null; } if (rect === null) { rect = Rects.Catch(0, 0, object.width, object.height); } else { rect.width = object.width; rect.height = object.height; } return rect; }; Rects.CopySizeBitmap = function (bitmap, rect) { if (rect === void 0) { rect = null; } if (rect === null) { rect = Rects.Catch(0, 0, bitmap.width, bitmap.height); } else { rect.width = bitmap.width; rect.height = bitmap.height; } return rect; }; Rects.IsInnerSizeBitmap = function (bitmap, rect) { return (rect.width >= bitmap.width && rect.height >= bitmap.height); }; Rects.CopySizeDisplayObject = function (disp, rect) { if (rect === void 0) { rect = null; } if (rect === null) { rect = Rects.Catch(disp.left, disp.top, disp.width, disp.height); } else { rect.x = disp.left; rect.y = disp.top; rect.width = disp.width; rect.height = disp.height; } return rect; }; return Rects; }()); ts.Rects = Rects; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var dateFormat; (function (dateFormat) { dateFormat[dateFormat["empty"] = 0] = "empty"; dateFormat[dateFormat["YYYY"] = 1] = "YYYY"; dateFormat[dateFormat["YYYY_MM"] = 2] = "YYYY_MM"; dateFormat[dateFormat["YYYY_MM_DD"] = 3] = "YYYY_MM_DD"; dateFormat[dateFormat["MM_DD"] = 4] = "MM_DD"; })(dateFormat = ts.dateFormat || (ts.dateFormat = {})); var timeFormat; (function (timeFormat) { timeFormat[timeFormat["empty"] = 0] = "empty"; timeFormat[timeFormat["HH_MM_SS"] = 1] = "HH_MM_SS"; timeFormat[timeFormat["HH_MM"] = 2] = "HH_MM"; timeFormat[timeFormat["HH"] = 3] = "HH"; })(timeFormat = ts.timeFormat || (ts.timeFormat = {})); var cnv = /** @class */ (function () { function cnv() { } cnv.regexNotNo = (function () { var regex = /[^0-9 ]/; return regex; })(); cnv.regexAlpha = (function () { var regex = /[a-zA-Z]/; return regex; })(); /** * 日付型を文字列に変換する * @param date 日付 * @param dtFormat 日付のフォーマット * @param tmFormat 時間のフォーマット * @param sep dt:日付 tm:時間のセパレータ */ cnv.dateToString = function (date, dtFormat, tmFormat, sep) { if (dtFormat === void 0) { dtFormat = dateFormat.YYYY_MM_DD; } if (tmFormat === void 0) { tmFormat = timeFormat.HH_MM_SS; } if (sep === void 0) { sep = { dt: "/", tm: ":" }; } var dt = ""; switch (dtFormat) { case dateFormat.YYYY: dt = date.getFullYear().toString(); break; case dateFormat.YYYY_MM: var m = cnv.toTowLength((date.getMonth() + 1).toString()); dt = date.getFullYear().toString() + sep.dt + m; break; case dateFormat.YYYY_MM_DD: var m = cnv.toTowLength((date.getMonth() + 1).toString()); var d = cnv.toTowLength(date.getDate().toString()); dt = date.getFullYear().toString() + sep.dt + m + sep.dt + d; break; case dateFormat.MM_DD: var m = cnv.toTowLength((date.getMonth() + 1).toString()); var d = cnv.toTowLength(date.getDate().toString()); dt = m + sep.dt + d; break; } switch (tmFormat) { case timeFormat.HH: var h = cnv.toTowLength(date.getHours().toString()); dt += ' ' + h; break; case timeFormat.HH_MM: var h = cnv.toTowLength(date.getHours().toString()); var m = cnv.toTowLength(date.getMinutes().toString()); dt += ' ' + h + sep.tm + date.getMinutes().toString(); break; case timeFormat.HH_MM_SS: var h = cnv.toTowLength(date.getHours().toString()); var m = cnv.toTowLength(date.getMinutes().toString()); var s = cnv.toTowLength(date.getSeconds().toString()); dt += ' ' + h + sep.tm + m + sep.tm + s; break; } return dt; }; cnv.toTowLength = function (str, del) { if (del === void 0) { del = '0'; } if (str[1] === undefined) str = del + str; return str; }; /** * 連続した、もしくは特定の記号でセパレートされた日付を表す文字列を日付に変換する。連続した文字列の場合の結果->3:MDD 4:MMDD 6:YYMMDD その他:先4文字が年、次の2文字が月、次の2文字が日、それ以降は時間として処理される。欠落した場合は日付であれば日、月、年、時間の順に今年の、今月の、0時0分0秒という形で保管される。 * @param strDate */ cnv.strToDate = function (strDate) { var len = strDate.length; var inDelimitter = cnv.regexNotNo.test(strDate); var inAlpha = cnv.regexAlpha.test(strDate); if (inAlpha) { var dt = new Date(strDate); if (!isNaN(dt)) { return dt; } else { return null; } } var dt = new Date(); var setFunc = [dt.setFullYear, function (no) { dt.setFullYear(dt.getFullYear(), no - 1); }, dt.setDate, dt.setHours, dt.setMinutes, dt.setSeconds]; if (inDelimitter) { var dateP = strDate.split(cnv.regexNotNo); var len = setFunc.length; var index = 0; for (var i = 0; i < len; i++) { var p = parseInt(dateP[i]); if (!isNaN(p)) { //setFunc[index].call(dt, p); dateP[i] = p; index++; } else { //setFunc[index].call(dt, ((i <= 2) ? 1 : 0)); dateP[i] = ((i <= 2) ? 1 : 0); index++; } } dt = new Date(dateP[0], dateP[1] - 1, dateP[2], dateP[3], dateP[4], dateP[5]); return dt; } else { var dt_tm = strDate.split(' '); strDate = dt_tm[0]; var values; if (len >= 3) { switch (len) { case (3): //MDD values = [dt.getFullYear(), strDate[0], strDate[1] + strDate[2], 0, 0, 0]; break; case (4): //MMDD values = [dt.getFullYear(), strDate[0] + strDate[1], strDate[2] + strDate[3], 0, 0, 0]; break; case (6): //YYMMDD values = [dt.getFullYear().toString().substring(0, 2) + strDate[0] + strDate[1], strDate[2] + strDate[3], strDate[4] + strDate[5]]; break; default: values = [strDate.substr(0, 4), strDate.substr(4, 2), strDate.substr(7, 2)]; if (dt_tm[1] !== undefined) { strDate = dt_tm[1]; len = strDate.length; for (var i = 0; i < len; i += 2) { values.push(strDate.substr(i, 2)); } } break; } len = values.length; for (var i = 0; i < len; i++) { var v = values[i]; var p; if (typeof (v) === 'string') { p = parseInt(v); } else { p = v; } if (!isNaN(p)) { //setFunc[i].call(dt, p); values[i] = p; } } dt = new Date(values[0], values[1] - 1, values[2], values[3], values[4], values[5]); return dt; } } return null; }; /** * 配列の指定プロパティの文字列表現を繋げて返す。 * @param sep セパレーター * @param datas 対象の配列 * @param property 変換対象のプロパティ(定義されてなければ空文字) */ cnv.aryPToStr = function (sep, datas, property) { var result = ''; if (datas && datas.length > 0) { var len = datas.length; for (var i = 0; i < len; i++) { if (i !== 0) { result += ','; } var dt = datas[i]; if (dt[property]) { result += dt[property]; } } } return result; }; /** * 配列を関数を用いて文字列に変換する。 * @param sep セパレーター * @param datas 対象の配列 * @param returnProperty 変換関数(falseを返すとそこでストップ) */ cnv.aryEachToStr = function (sep, datas, returnProperty) { var result = ''; if (datas && datas.length > 0) { var len = datas.length; for (var i = 0; i < len; i++) { if (i !== 0) { result += ','; } var dt = datas[i]; var p = returnProperty(dt, i); if (p === false) break; result += p; } } return result; }; return cnv; }()); ts.cnv = cnv; })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); var jp; (function (jp) { var ninesense; (function (ninesense) { var ts; (function (ts) { var str; (function (str_1) { str_1.left = function (str, len, empty) { if (empty === void 0) { empty = ''; } var s; if (empty.repeat) { s = empty.repeat(len); } else { s = empty; for (var i = 1; i < len; i++) { s += empty; } } return (str + s).substr(0, len); }; str_1.right = function (str, len, empty) { if (empty === void 0) { empty = ''; } var s; if (empty.repeat) { s = empty.repeat(len) + str; } else { s = empty; for (var i = 1; i < len; i++) { s += empty; } s += str; } return s.substr((len - s.length) * -1); }; str_1.concatAfter = function (base, concat, beforeStr) { if (!concat) return base; return base.concat(beforeStr, concat); }; str_1.atByte = function (str, index) { var r = 0; var c = str.charCodeAt(index); // Shift_JIS: 0x0 ~ 0x80, 0xa0 , 0xa1 ~ 0xdf , 0xfd ~ 0xff // Unicode : 0x0 ~ 0x80, 0xf8f0, 0xff61 ~ 0xff9f, 0xf8f1 ~ 0xf8f3 if ((c >= 0x0 && c < 0x81) || (c == 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) { return 1; } else { return 2; } }; str_1.legthB = function (str) { var r = 0; for (var i = 0; i < str.length; i++) { r += str_1.atByte(str, i); } return r; }; var repeat = function (str, len, empty) { if (empty === void 0) { empty = ''; } }; str_1.leftB = function (str, len, empty) { if (empty === void 0) { empty = ''; } var s; if (empty.repeat) { s = empty.repeat(len); } else { s = empty; for (var i = 1; i < len; i++) { s += empty; } } str += s; var byte = 0; if (len === 0) { return ''; } var cnt = str.length; for (var i = 0; i < cnt; i++) { byte += str_1.atByte(str, i); if (byte > len) { return str.substr(0, i); } } return str; }; str_1.rightB = function (str, len, empty) { if (empty === void 0) { empty = ''; } var s; if (empty.repeat) { s = empty.repeat(len) + str; } else { s = empty; for (var i = 1; i < len; i++) { s += empty; } s += str; } str = s; var byte = 0; if (len === 0) { return ''; } var cnt = str.length; for (var i = cnt - 1; 0 <= i; i--) { byte += str_1.atByte(str, i); if (byte > len) { return str.substr(i + 1); } } return str; }; str_1.randomString = function (l) { if (l === void 0) { l = 8; } // 生成する文字列に含める文字セット var c = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var cl = c.length; var r = ""; for (var i = 0; i < l; i++) { r += c[Math.floor(Math.random() * cl)]; } return r; }; })(str = ts.str || (ts.str = {})); })(ts = ninesense.ts || (ninesense.ts = {})); })(ninesense = jp.ninesense || (jp.ninesense = {})); })(jp || (jp = {})); //# sourceMappingURL=jp.ninesense.ts.Common.js.map jp.ninesense.ts.init=true; window.dispatchEvent(new CustomEvent('nsLibInit', { imports: ["Common"] }));