1 2var debug = new debug(); 3function debug() { 4this.html = ""; 5this.hWin = null; 6this.bDebug = true; 7this.now_bgcolor = ""; 8this.bgcolor1 = "#FAF5D4"; 9this.bgcolor2 = "#EBCC67"; 10this.level = 0; 11this.maxLevel = 10; 12this.setDebug = function(flag) { 13this.bDebug = flag; 14} 15this.clear = function() { 16this.html = ""; 17this.flush(); 18} 19this.flush = function() { 20if (false == this.bDebug) return; 21if (null == this.hWin || this.hWin.closed) { 22this.hWin = window.open("", "debug", 23"height=200,width=400,menubar=yes,scrollbars=yes,resizable=yes"); 24} 25this.hWin.document.open("text/html", "replace"); 26this.hWin.document.write(this.html); 27this.hWin.document.close(); 28this.hWin.focus(); 29} 30this.print = function(html) { 31function parseHtml(str){ 32str = str.replace(/&/g, "&"); 33str = str.replace(/</g, "<"); 34str = str.replace(/>/g, ">"); 35str = str.replace(/\"/g, """); 36str = str.replace(/\n/g, "<br>\n"); 37return str; 38} 39this.now_bgcolor = (this.now_bgcolor == this.bgcolor1) ? this.bgcolor2 : this.bgcolor1; 40this.html += ("<div style='background-color:"+this.now_bgcolor+"'>" + parseHtml(html) + "</div>\n"); 41} 42this.inspect = function(obj) { 43if (typeof obj == "number") { 44return ""+obj; 45} else if (typeof obj == "string") { 46return "\""+obj+"\""; 47} else if (typeof obj == "function") { 48return ""+obj; 49} else if (typeof obj == "object" && obj != null) { 50if(!obj.tagName) { 51var str = this.to_s(obj, ""); 52} else { 53return "<"+(typeof obj)+":"+obj.tagName+">"; 54} 55return "{"+str+"}"; 56} else { 57return "<"+(typeof obj)+":"+obj+">"; 58} 59} 60this.to_s = function(obj, indent){ 61var delimiter = ", \n"; 62var inner_indent = "ãã"; 63this.level += 1; 64if(this.maxLevel < this.level){ 65return ""+this.maxLevel+"é層以ä¸ã¯çç¥ãã¾ã"; 66} 67var str = ""; 68for (key in obj) { 69if (str != "") str += delimiter; 70str += indent; 71var value = obj[key]; 72if (!value) { 73str += ""+key+"=>undefined"; 74continue; 75} 76if (typeof value == "number") { 77str += ""+key+"=>"+value+""; 78} else if (typeof value == "string") { 79str += ""+key+'=>"'+value+'"'; 80} else if (typeof value == "function") { 81str += ""+key+"()"; 82} else if (typeof value == "object") { 83value = "\n" + this.to_s(value, indent+inner_indent); 84str += ""+key+"=>"+value+""; 85} else { 86str += ""+key+"=><"+(typeof value)+":"+value+">"; 87} 88} 89if (str == ""){ 90str += ""+obj; 91} 92this.level -= 1; 93return str; 94} 95this.p = function(elem) { 96this.print(this.inspect(elem)); 97this.flush(); 98} 99} 100 101 102var Prototype = { 103Version: '1.5.0', 104BrowserFeatures: { 105XPath: !!document.evaluate 106}, 107ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 108emptyFunction: function() {}, 109K: function(x) { return x } 110} 111var Class = { 112create: function() { 113return function() { 114this.initialize.apply(this, arguments); 115} 116} 117} 118var Abstract = new Object(); 119Object.extend = function(destination, source) { 120for (var property in source) { 121destination[property] = source[property]; 122} 123return destination; 124} 125Object.extend(Object, { 126inspect: function(object) { 127try { 128if (object === undefined) return 'undefined'; 129if (object === null) return 'null'; 130return object.inspect ? object.inspect() : object.toString(); 131} catch (e) { 132if (e instanceof RangeError) return '...'; 133throw e; 134} 135}, 136keys: function(object) { 137var keys = []; 138for (var property in object) 139keys.push(property); 140return keys; 141}, 142values: function(object) { 143var values = []; 144for (var property in object) 145values.push(object[property]); 146return values; 147}, 148clone: function(object) { 149return Object.extend({}, object); 150} 151}); 152Function.prototype.bind = function() { 153var __method = this, args = $A(arguments), object = args.shift(); 154return function() { 155return __method.apply(object, args.concat($A(arguments))); 156} 157} 158Function.prototype.bindAsEventListener = function(object) { 159var __method = this, args = $A(arguments), object = args.shift(); 160return function(event) { 161return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 162} 163} 164Object.extend(Number.prototype, { 165toColorPart: function() { 166var digits = this.toString(16); 167if (this < 16) return '0' + digits; 168return digits; 169}, 170succ: function() { 171return this + 1; 172}, 173times: function(iterator) { 174$R(0, this, true).each(iterator); 175return this; 176} 177}); 178var Try = { 179these: function() { 180var returnValue; 181for (var i = 0, length = arguments.length; i < length; i++) { 182var lambda = arguments[i]; 183try { 184returnValue = lambda(); 185break; 186} catch (e) {} 187} 188return returnValue; 189} 190} 191var PeriodicalExecuter = Class.create(); 192PeriodicalExecuter.prototype = { 193initialize: function(callback, frequency) { 194this.callback = callback; 195this.frequency = frequency; 196this.currentlyExecuting = false;
197this.registerCallback(); 198}, 199registerCallback: function() { 200this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 201}, 202stop: function() { 203if (!this.timer) return; 204clearInterval(this.timer); 205this.timer = null; 206}, 207onTimerEvent: function() { 208if (!this.currentlyExecuting) { 209try { 210this.currentlyExecuting = true; 211this.callback(this); 212} finally { 213this.currentlyExecuting = false; 214} 215} 216} 217} 218String.interpret = function(value){ 219return value == null ? '' : String(value); 220} 221Object.extend(String.prototype, { 222gsub: function(pattern, replacement) { 223var result = '', source = this, match; 224replacement = arguments.callee.prepareReplacement(replacement); 225while (source.length > 0) { 226if (match = source.match(pattern)) { 227result += source.slice(0, match.index); 228result += String.interpret(replacement(match)); 229source = source.slice(match.index + match[0].length); 230} else { 231result += source, source = ''; 232} 233} 234return result; 235}, 236sub: function(pattern, replacement, count) { 237replacement = this.gsub.prepareReplacement(replacement); 238count = count === undefined ? 1 : count; 239return this.gsub(pattern, function(match) { 240if (--count < 0) return match[0]; 241return replacement(match); 242}); 243}, 244scan: function(pattern, iterator) { 245this.gsub(pattern, iterator); 246return this; 247}, 248truncate: function(length, truncation) { 249length = length || 30; 250truncation = truncation === undefined ? '...' : truncation; 251return this.length > length ? 252this.slice(0, length - truncation.length) + truncation : this; 253}, 254strip: function() { 255return this.replace(/^\s+/, '').replace(/\s+$/, ''); 256}, 257trim: function() { 258return this.strip(); 259}, 260stripTags: function() { 261return this.replace(/<\/?[^>]+>/gi, ''); 262}, 263stripScripts: function() { 264return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); 265}, 266extractScripts: function() { 267var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); 268var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); 269return (this.match(matchAll) || []).map(function(scriptTag) { 270return (scriptTag.match(matchOne) || ['', ''])[1]; 271}); 272}, 273evalScripts: function() { 274return this.extractScripts().map(function(script) { return eval(script) }); 275}, 276escapeHTML: function() { 277return this.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/ /g, " "); 278}, 279unescapeHTML: function() { 280return this.replace(/"/g,'"').replace(/</g,'<').replace(/>/g,'>').replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(/ /g, " ").replace(/&/g,'&'); 281}, 282toQueryParams: function(separator) { 283var match = this.strip().match(/([^?#]*)(#.*)?$/); 284if (!match) return {}; 285return match[1].split(separator || '&').inject({}, function(hash, pair) { 286if ((pair = pair.split('='))[0]) { 287var name = decodeURIComponent(pair[0]); 288var value = pair[1] ? decodeURIComponent(pair[1]) : ""; 289if (hash[name] !== undefined) { 290if (hash[name].constructor != Array) 291hash[name] = [hash[name]]; 292if (value) hash[name].push(value); 293} 294else hash[name] = value; 295} 296return hash; 297}); 298}, 299toArray: function() { 300return this.split(''); 301}, 302succ: function() { 303return this.slice(0, this.length - 1) + 304String.fromCharCode(this.charCodeAt(this.length - 1) + 1); 305}, 306camelize: function() { 307var parts = this.split('-'), len = parts.length; 308if (len == 1) return parts[0]; 309var camelized = this.charAt(0) == '-' 310? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) 311: parts[0]; 312for (var i = 1; i < len; i++) 313camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); 314return camelized; 315}, 316capitalize: function(){ 317return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 318}, 319underscore: function() { 320return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); 321}, 322dasherize: function() { 323return this.gsub(/_/,'-'); 324}, 325inspect: function(useDoubleQuotes) { 326var escapedString = this.replace(/\\/g, '\\\\'); 327if (useDoubleQuotes) 328return '"' + escapedString.replace(/"/g, '\\"') + '"'; 329else 330return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 331} 332}); 333String.prototype.gsub.prepareReplacement = function(replacement) { 334if (typeof replacement == 'function') return replacement; 335var template = new Template(replacement); 336return function(match) { return template.evaluate(match) }; 337} 338String.prototype.parseQuery = String.prototype.toQueryParams; 339var Template = Class.create(); 340Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; 341Template.prototype = { 342initialize: function(template, pattern) { 343this.template = template.toString(); 344this.pattern = pattern || Template.Pattern; 345}, 346evaluate: function(object) { 347return this.template.gsub(this.pattern, function(match) { 348var before = match[1]; 349if (before == '\\') return match[2]; 350return before + String.interpret(object[match[3]]); 351}); 352} 353} 354var $break = new Object(); 355var $continue = new Object(); 356var Enumerable = { 357each: function(iterator) { 358var index = 0; 359try { 360this._each(function(value) { 361try { 362iterator(value, index++); 363} catch (e) { 364if (e != $continue) throw e; 365} 366}); 367} catch (e) { 368if (e != $break) throw e; 369} 370return this; 371}, 372eachSlice: function(number, iterator) {
373var index = -number, slices = [], array = this.toArray(); 374while ((index += number) < array.length) 375slices.push(array.slice(index, index+number)); 376return slices.map(iterator); 377}, 378all: function(iterator) { 379var result = true; 380this.each(function(value, index) { 381result = result && !!(iterator || Prototype.K)(value, index); 382if (!result) throw $break; 383}); 384return result; 385}, 386any: function(iterator) { 387var result = false; 388this.each(function(value, index) { 389if (result = !!(iterator || Prototype.K)(value, index)) 390throw $break; 391}); 392return result; 393}, 394collect: function(iterator) { 395var results = []; 396this.each(function(value, index) { 397results.push((iterator || Prototype.K)(value, index)); 398}); 399return results; 400}, 401detect: function(iterator) { 402var result; 403this.each(function(value, index) { 404if (iterator(value, index)) { 405result = value; 406throw $break; 407} 408}); 409return result; 410}, 411findAll: function(iterator) { 412var results = []; 413this.each(function(value, index) { 414if (iterator(value, index)) 415results.push(value); 416}); 417return results; 418}, 419grep: function(pattern, iterator) { 420var results = []; 421this.each(function(value, index) { 422var stringValue = value.toString(); 423if (stringValue.match(pattern)) 424results.push((iterator || Prototype.K)(value, index)); 425}) 426return results; 427}, 428include: function(object) { 429var found = false; 430this.each(function(value) { 431if (value == object) { 432found = true; 433throw $break; 434} 435}); 436return found; 437}, 438inGroupsOf: function(number, fillWith) { 439fillWith = fillWith === undefined ? null : fillWith; 440return this.eachSlice(number, function(slice) { 441while(slice.length < number) slice.push(fillWith); 442return slice; 443}); 444}, 445inject: function(memo, iterator) { 446this.each(function(value, index) { 447memo = iterator(memo, value, index); 448}); 449return memo; 450}, 451invoke: function(method) { 452var args = $A(arguments).slice(1); 453return this.map(function(value) { 454return value[method].apply(value, args); 455}); 456}, 457max: function(iterator) { 458var result; 459this.each(function(value, index) { 460value = (iterator || Prototype.K)(value, index); 461if (result == undefined || value >= result) 462result = value; 463}); 464return result; 465}, 466min: function(iterator) { 467var result; 468this.each(function(value, index) { 469value = (iterator || Prototype.K)(value, index); 470if (result == undefined || value < result) 471result = value; 472}); 473return result; 474}, 475partition: function(iterator) { 476var trues = [], falses = []; 477this.each(function(value, index) { 478((iterator || Prototype.K)(value, index) ? 479trues : falses).push(value); 480}); 481return [trues, falses]; 482}, 483pluck: function(property) { 484var results = []; 485this.each(function(value, index) { 486results.push(value[property]); 487}); 488return results; 489}, 490reject: function(iterator) { 491var results = []; 492this.each(function(value, index) { 493if (!iterator(value, index)) 494results.push(value); 495}); 496return results; 497}, 498sortBy: function(iterator) { 499return this.map(function(value, index) { 500return {value: value, criteria: iterator(value, index)}; 501}).sort(function(left, right) { 502var a = left.criteria, b = right.criteria; 503return a < b ? -1 : a > b ? 1 : 0; 504}).pluck('value'); 505}, 506toArray: function() { 507return this.map(); 508}, 509zip: function() { 510var iterator = Prototype.K, args = $A(arguments); 511if (typeof args.last() == 'function') 512iterator = args.pop(); 513var collections = [this].concat(args).map($A); 514return this.map(function(value, index) { 515return iterator(collections.pluck(index)); 516}); 517}, 518size: function() { 519return this.toArray().length; 520}, 521inspect: function() { 522return '#<Enumerable:' + this.toArray().inspect() + '>'; 523} 524} 525Object.extend(Enumerable, { 526map: Enumerable.collect, 527find: Enumerable.detect, 528select: Enumerable.findAll, 529member: Enumerable.include, 530entries: Enumerable.toArray 531}); 532var $A = Array.from = function(iterable) { 533if (!iterable) return []; 534if (iterable.toArray) { 535return iterable.toArray(); 536} else { 537var results = []; 538for (var i = 0, length = iterable.length; i < length; i++) 539results.push(iterable[i]); 540return results; 541} 542} 543Object.extend(Array.prototype, Enumerable); 544if (!Array.prototype._reverse) 545Array.prototype._reverse = Array.prototype.reverse; 546Object.extend(Array.prototype, { 547_each: function(iterator) { 548for (var i = 0, length = this.length; i < length; i++) 549iterator(this[i]); 550}, 551clear: function() { 552this.length = 0; 553return this; 554}, 555first: function() { 556return this[0]; 557}, 558last: function() { 559return this[this.length - 1]; 560}, 561compact: function() { 562return this.select(function(value) { 563return value != null; 564}); 565}, 566flatten: function() { 567return this.inject([], function(array, value) { 568return array.concat(value && value.constructor == Array ? 569value.flatten() : [value]); 570}); 571}, 572without: function() { 573var values = $A(arguments); 574return this.select(function(value) { 575return !values.include(value); 576}); 577}, 578indexOf: function(object) { 579for (var i = 0, length = this.length; i < length; i++) 580if (this[i] == object) return i; 581return -1; 582}, 583reverse: function(inline) { 584return (inline !== false ? this : this.toArray())._reverse(); 585}, 586reduce: function() { 587return this.length >
587 1 ? this : this[0]; 588}, 589uniq: function() { 590return this.inject([], function(array, value) { 591return array.include(value) ? array : array.concat([value]); 592}); 593}, 594clone: function() { 595return [].concat(this); 596}, 597size: function() { 598return this.length; 599}, 600inspect: function() { 601return '[' + this.map(Object.inspect).join(', ') + ']'; 602} 603}); 604Array.prototype.toArray = Array.prototype.clone; 605function $w(string){ 606string = string.strip(); 607return string ? string.split(/\s+/) : []; 608} 609if(window.opera){ 610Array.prototype.concat = function(){ 611var array = []; 612for(var i = 0, length = this.length; i < length; i++) array.push(this[i]); 613for(var i = 0, length = arguments.length; i < length; i++) { 614if(arguments[i].constructor == Array) { 615for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) 616array.push(arguments[i][j]); 617} else { 618array.push(arguments[i]); 619} 620} 621return array; 622} 623} 624var Hash = function(obj) { 625Object.extend(this, obj || {}); 626}; 627Object.extend(Hash, { 628toQueryString: function(obj) { 629var parts = []; 630this.prototype._each.call(obj, function(pair) { 631if (!pair.key) return; 632if (pair.value && pair.value.constructor == Array) { 633var values = pair.value.compact(); 634if (values.length < 2) pair.value = values.reduce(); 635else { 636key = encodeURIComponent(pair.key); 637values.each(function(value) { 638value = value != undefined ? encodeURIComponent(value) : ''; 639parts.push(key + '=' + value); 640}); 641return; 642} 643} 644if (pair.value == undefined) pair[1] = ''; 645parts.push(pair.map(encodeURIComponent).join('=')); 646}); 647return parts.join('&'); 648} 649}); 650Object.extend(Hash.prototype, Enumerable); 651Object.extend(Hash.prototype, { 652_each: function(iterator) { 653for (var key in this) { 654var value = this[key]; 655if (value && value == Hash.prototype[key]) continue; 656var pair = [key, value]; 657pair.key = key; 658pair.value = value; 659iterator(pair); 660} 661}, 662keys: function() { 663return this.pluck('key'); 664}, 665values: function() { 666return this.pluck('value'); 667}, 668merge: function(hash) { 669return $H(hash).inject(this, function(mergedHash, pair) { 670mergedHash[pair.key] = pair.value; 671return mergedHash; 672}); 673}, 674remove: function() { 675var result; 676for(var i = 0, length = arguments.length; i < length; i++) { 677var value = this[arguments[i]]; 678if (value !== undefined){ 679if (result === undefined) result = value; 680else { 681if (result.constructor != Array) result = [result]; 682result.push(value) 683} 684} 685delete this[arguments[i]]; 686} 687return result; 688}, 689toQueryString: function() { 690return Hash.toQueryString(this); 691}, 692inspect: function() { 693return '#<Hash:{' + this.map(function(pair) { 694return pair.map(Object.inspect).join(': '); 695}).join(', ') + '}>'; 696} 697}); 698function $H(object) { 699if (object && object.constructor == Hash) return object; 700return new Hash(object); 701}; 702ObjectRange = Class.create(); 703Object.extend(ObjectRange.prototype, Enumerable); 704Object.extend(ObjectRange.prototype, { 705initialize: function(start, end, exclusive) { 706this.start = start; 707this.end = end; 708this.exclusive = exclusive; 709}, 710_each: function(iterator) { 711var value = this.start; 712while (this.include(value)) { 713iterator(value); 714value = value.succ(); 715} 716}, 717include: function(value) { 718if (value < this.start) 719return false; 720if (this.exclusive) 721return value < this.end; 722return value <= this.end; 723} 724}); 725var $R = function(start, end, exclusive) { 726return new ObjectRange(start, end, exclusive); 727} 728var Ajax = { 729getTransport: function() { 730return Try.these( 731function() {return new XMLHttpRequest()}, 732function() {return new ActiveXObject('Msxml2.XMLHTTP')}, 733function() {return new ActiveXObject('Microsoft.XMLHTTP')} 734) || false; 735}, 736activeRequestCount: 0 737} 738Ajax.Responders = { 739responders: [], 740_each: function(iterator) { 741this.responders._each(iterator); 742}, 743register: function(responder) { 744if (!this.include(responder)) 745this.responders.push(responder); 746}, 747unregister: function(responder) { 748this.responders = this.responders.without(responder); 749}, 750dispatch: function(callback, request, transport, json) { 751this.each(function(responder) { 752if (typeof responder[callback] == 'function') { 753try { 754responder[callback].apply(responder, [request, transport, json]); 755} catch (e) {} 756} 757}); 758} 759}; 760Object.extend(Ajax.Responders, Enumerable); 761Ajax.Responders.register({ 762onCreate: function() { 763Ajax.activeRequestCount++; 764}, 765onComplete: function() { 766Ajax.activeRequestCount--; 767} 768}); 769Ajax.Base = function() {}; 770Ajax.Base.prototype = { 771setOptions: function(options) { 772this.options = { 773method: 'post', 774asynchronous: true, 775contentType: 'application/x-www-form-urlencoded', 776encoding: 'UTF-8', 777parameters: '' 778} 779Object.extend(this.options, options || {}); 780this.options.method = this.options.method.toLowerCase(); 781if (typeof this.options.parameters == 'string') 782this.options.parameters = this.options.parameters.toQueryParams(); 783} 784} 785Ajax.Request = Class.create(); 786Ajax.Request.Events = 787['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; 788Ajax.Request.prototype = Object.extend(new Ajax.Base(), { 789_complete: false, 790initialize: function(url, options) { 791this.transport = Ajax.getTransport(); 792this.setOptions(options); 793this.request(url); 794}, 795request: function(url) { 796this.url = url; 797this.method = this.options.method; 798var params = this.options.parameters; 799if (!['get', 'post'].include(this.method)) { 800params['_method'] = this.method; 801this.method = 'post'; 802} 803params = Hash.toQueryString(params); 804if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='; 805if (this.method == 'get' && params) 806this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params; 807try { 808Ajax.Responders.dispatch('onCreate', this, this.transport); 809this.transport.open(this.method.toUpperCase(), this.url, 810this.options.asynchronous); 811if (this.options.asynchronous) 812setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); 813this.transport.onreadystatechange = this.onStateChange.bind(this); 814this.setRequestHeaders(); 815var body = this.method == 'post' ? (this.options.postBody || params) : null; 816this.transport.send(body); 817if (!this.options.asynchronous && this.transport.overrideMimeType) 818this.onStateChange(); 819} 820catch (e) { 821this.dispatchException(e); 822} 823}, 824onStateChange: function() { 825var readyState = this.transport.readyState; 826if (readyState > 1 && !((readyState == 4) && this._complete)) 827this.respondToReadyState(this.transport.readyState); 828}, 829setRequestHeaders: function() { 830var headers = { 831'X-Requested-With': 'XMLHttpRequest', 832'X-Prototype-Version': Prototype.Version, 833'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' 834}; 835if (this.method == 'post') { 836headers['Content-type'] = this.options.contentType + 837(this.options.encoding ? '; charset=' + this.options.encoding : ''); 838if (this.transport.overrideMimeType && 839(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) 840headers['Connection'] = 'close'; 841} 842if (typeof this.options.requestHeaders == 'object') { 843var extras = this.options.requestHeaders; 844if (typeof extras.push == 'function') 845for (var i = 0, length = extras.length; i < length; i += 2) 846headers[extras[i]] = extras[i+1]; 847else 848$H(extras).each(function(pair) { headers[pair.key] = pair.value }); 849} 850for (var name in headers) 851this.transport.setRequestHeader(name, headers[name]); 852}, 853success: function() { 854return !this.transport.status 855|| (this.transport.status >= 200 && this.transport.status < 300); 856}, 857respondToReadyState: function(readyState) { 858var state = Ajax.Request.Events[readyState]; 859var transport = this.transport, json = this.evalJSON(); 860if (state == 'Complete') { 861try { 862this._complete = true; 863(this.options['on' + this.transport.status] 864|| this.options['on' + (this.success() ? 'Success' : 'Failure')] 865|| Prototype.emptyFunction)(transport, json); 866} catch (e) { 867this.dispatchException(e); 868} 869if (! this.options['noautoeval']){ 870if ((this.getHeader('Content-type') || 'text/javascript').strip(). 871match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 872this.evalResponse(); 873} 874} 875try { 876(this.options['on' + state] || Prototype.emptyFunction)(transport, json); 877Ajax.Responders.dispatch('on' + state, this, transport, json); 878} catch (e) { 879this.dispatchException(e); 880} 881if (state == 'Complete') { 882this.transport.onreadystatechange = Prototype.emptyFunction; 883} 884}, 885getHeader: function(name) { 886try { 887return this.transport.getResponseHeader(name); 888} catch (e) { return null } 889}, 890evalJSON: function() { 891try { 892var json = this.getHeader('X-JSON'); 893return json ? eval('(' + json + ')') : null; 894} catch (e) { return null } 895}, 896evalResponse: function() { 897try { 898return eval(this.transport.responseText); 899} catch (e) { 900this.dispatchException(e); 901} 902},
903dispatchException: function(exception) { 904(this.options.onException || Prototype.emptyFunction)(this, exception); 905Ajax.Responders.dispatch('onException', this, exception); 906} 907}); 908Ajax.Updater = Class.create(); 909Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { 910initialize: function(container, url, options) { 911this.container = { 912success: (container.success || container), 913failure: (container.failure || (container.success ? null : container)) 914} 915this.transport = Ajax.getTransport(); 916this.setOptions(options); 917var onComplete = this.options.onComplete || Prototype.emptyFunction; 918this.options.onComplete = (function(transport, param) { 919this.updateContent(); 920onComplete(transport, param); 921}).bind(this); 922this.request(url); 923}, 924updateContent: function() { 925var receiver = this.container[this.success() ? 'success' : 'failure']; 926var response = this.transport.responseText; 927if (!this.options.evalScripts) response = response.stripScripts(); 928if (receiver = $(receiver)) { 929if (this.options.insertion) 930new this.options.insertion(receiver, response); 931else 932receiver.update(response); 933} 934if (this.success()) { 935if (this.onComplete) 936setTimeout(this.onComplete.bind(this), 10); 937} 938} 939}); 940Ajax.PeriodicalUpdater = Class.create(); 941Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { 942initialize: function(container, url, options) { 943this.setOptions(options); 944this.onComplete = this.options.onComplete; 945this.frequency = (this.options.frequency || 2); 946this.decay = (this.options.decay || 1); 947this.updater = {}; 948this.container = container; 949this.url = url; 950this.start(); 951}, 952start: function() { 953this.options.onComplete = this.updateComplete.bind(this); 954this.onTimerEvent(); 955}, 956stop: function() { 957this.updater.options.onComplete = undefined; 958clearTimeout(this.timer); 959(this.onComplete || Prototype.emptyFunction).apply(this, arguments); 960}, 961updateComplete: function(request) { 962if (this.options.decay) { 963this.decay = (request.responseText == this.lastText ? 964this.decay * this.options.decay : 1); 965this.lastText = request.responseText; 966} 967this.timer = setTimeout(this.onTimerEvent.bind(this), 968this.decay * this.frequency * 1000); 969}, 970onTimerEvent: function() { 971this.updater = new Ajax.Updater(this.container, this.url, this.options); 972} 973}); 974function $(element) { 975if (arguments.length > 1) { 976for (var i = 0, elements = [], length = arguments.length; i < length; i++) 977elements.push($(arguments[i])); 978return elements; 979} 980if (typeof element == 'string') 981element = document.getElementById(element); 982return Element.extend(element); 983} 984if (Prototype.BrowserFeatures.XPath) { 985document._getElementsByXPath = function(expression, parentElement) { 986var results = []; 987var query = document.evaluate(expression, $(parentElement) || document, 988null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 989for (var i = 0, length = query.snapshotLength; i < length; i++) 990results.push(query.snapshotItem(i)); 991return results; 992}; 993} 994document.getElementsByClassName = function(className, parentElement) { 995if (Prototype.BrowserFeatures.XPath) { 996var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 997return document._getElementsByXPath(q, parentElement); 998} else { 999var children = ($(parentElement) || document.body).getElementsByTagName('*'); 1000var elements = [], child; 1001for (var i = 0, length = children.length; i < length; i++) { 1002child = children[i]; 1003if (Element.hasClassName(child, className)) 1004elements.push(Element.extend(child)); 1005} 1006return elements; 1007} 1008}; 1009if (!window.Element) 1010var Element = new Object(); 1011Element.extend = function(element) { 1012if (!element || _nativeExtensions || element.nodeType == 3) return element; 1013if (!element._extended && element.tagName && element != window) { 1014var methods = Object.clone(Element.Methods), cache = Element.extend.cache; 1015if (element.tagName == 'FORM') 1016Object.extend(methods, Form.Methods); 1017if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName)) 1018Object.extend(methods, Form.Element.Methods); 1019Object.extend(methods, Element.Methods.Simulated); 1020for (var property in methods) { 1021var value = methods[property]; 1022if (typeof value == 'function' && !(property in element)) 1023element[property] = cache.findOrStore(value); 1024} 1025} 1026element._extended = true; 1027return element; 1028}; 1029Element.extend.cache = { 1030findOrStore: function(value) { 1031return this[value] = this[value] || function() {
1032return value.apply(null, [this].concat($A(arguments))); 1033} 1034} 1035}; 1036Element.Methods = { 1037visible: function(element) { 1038return $(element).style.display != 'none'; 1039}, 1040toggle: function(element) { 1041element = $(element); 1042Element[Element.visible(element) ? 'hide' : 'show'](element); 1043return element; 1044}, 1045hide: function(element) { 1046$(element).style.display = 'none'; 1047return element; 1048}, 1049show: function(element) { 1050$(element).style.display = ''; 1051return element; 1052}, 1053remove: function(element) { 1054element = $(element); 1055if(element) { 1056var formList = element.getElementsByTagName("form"); 1057for (var i = 0; i < formList.length; i++){ 1058formList[i].innerHTML = ""; 1059} 1060} 1061element.parentNode.removeChild(element); 1062return element; 1063}, 1064update: function(element, html) { 1065html = typeof html == 'undefined' ? '' : html.toString(); 1066$(element).innerHTML = html.stripScripts(); 1067setTimeout(function() {html.evalScripts()}, 10); 1068return element; 1069}, 1070replace: function(element, html) { 1071element = $(element); 1072html = typeof html == 'undefined' ? '' : html.toString(); 1073if (element.outerHTML) { 1074element.outerHTML = html.stripScripts(); 1075} else { 1076var range = element.ownerDocument.createRange(); 1077range.selectNodeContents(element); 1078element.parentNode.replaceChild( 1079range.createContextualFragment(html.stripScripts()), element); 1080} 1081setTimeout(function() {html.evalScripts()}, 10); 1082return element; 1083}, 1084inspect: function(element) { 1085element = $(element); 1086var result = '<' + element.tagName.toLowerCase(); 1087$H({'id': 'id', 'className': 'class'}).each(function(pair) { 1088var property = pair.first(), attribute = pair.last(); 1089var value = (element[property] || '').toString(); 1090if (value) result += ' ' + attribute + '=' + value.inspect(true); 1091}); 1092return result + '>'; 1093}, 1094recursivelyCollect: function(element, property) { 1095element = $(element); 1096var elements = []; 1097while (element = element[property]) 1098if (element.nodeType == 1) 1099elements.push(Element.extend(element)); 1100return elements; 1101}, 1102ancestors: function(element) { 1103return $(element).recursivelyCollect('parentNode'); 1104}, 1105descendants: function(element) { 1106return $A($(element).getElementsByTagName('*')); 1107}, 1108immediateDescendants: function(element) { 1109if (!(element = $(element).firstChild)) return []; 1110while (element && element.nodeType != 1) element = element.nextSibling; 1111if (element) return [element].concat($(element).nextSiblings()); 1112return []; 1113}, 1114previousSiblings: function(element) { 1115return $(element).recursivelyCollect('previousSibling'); 1116}, 1117nextSiblings: function(element) { 1118return $(element).recursivelyCollect('nextSibling'); 1119}, 1120siblings: function(element) { 1121element = $(element); 1122return element.previousSiblings().reverse().concat(element.nextSiblings()); 1123}, 1124match: function(element, selector) { 1125if (typeof selector == 'string') 1126selector = new Selector(selector); 1127return selector.match($(element)); 1128}, 1129up: function(element, expression, index) { 1130return Selector.findElement($(element).ancestors(), expression, index); 1131}, 1132down: function(element, expression, index) { 1133return Selector.findElement($(element).descendants(), expression, index); 1134}, 1135previous: function(element, expression, index) { 1136return Selector.findElement($(element).previousSiblings(), expression, index); 1137}, 1138next: function(element, expression, index) { 1139return Selector.findElement($(element).nextSiblings(), expression, index); 1140}, 1141getElementsBySelector: function() { 1142var args = $A(arguments), element = $(args.shift()); 1143return Selector.findChildElements(element, args); 1144}, 1145getElementsByClassName: function(element, className) { 1146return document.getElementsByClassName(className, element); 1147}, 1148readAttribute: function(element, name) { 1149if (typeof element == 'string') { 1150element = $(element); 1151} 1152if (!(browser.isIE || browser.isOpera)) { 1153var t = Element._attributeTranslations; 1154if (t.values[name]) return t.values[name](element, name); 1155if (t.names[name]) name = t.names[name]; 1156var attribute = element.attributes[name]; 1157if(attribute) return attribute.nodeValue; 1158} 1159return element.getAttribute(name); 1160}, 1161getHeight: function(element) { 1162return $(element).getDimensions().height; 1163}, 1164getWidth: function(element) { 1165return $(element).getDimensions().width; 1166}, 1167classNames: function(element) { 1168return new Element.ClassNames(element); 1169}, 1170hasClassName: function(element, className) { 1171if (!(element = $(element))) return; 1172var elementClassName = element.className; 1173if (elementClassName == undefined || elementClassName.length == 0) return false;
1174if (elementClassName == className || 1175elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 1176return true; 1177return false; 1178}, 1179addClassName: function(element, className) { 1180if (!(element = $(element))) return; 1181Element.classNames(element).add(className); 1182return element; 1183}, 1184removeClassName: function(element, className) { 1185if (!(element = $(element))) return; 1186Element.classNames(element).remove(className); 1187return element; 1188}, 1189toggleClassName: function(element, className) { 1190if (!(element = $(element))) return; 1191Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); 1192return element; 1193}, 1194observe: function() { 1195Event.observe.apply(Event, arguments); 1196return $A(arguments).first(); 1197}, 1198stopObserving: function() { 1199Event.stopObserving.apply(Event, arguments); 1200return $A(arguments).first(); 1201}, 1202cleanWhitespace: function(element) { 1203element = $(element); 1204var node = element.firstChild; 1205while (node) { 1206var nextNode = node.nextSibling; 1207if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 1208element.removeChild(node); 1209node = nextNode; 1210} 1211return element; 1212}, 1213empty: function(element) { 1214return $(element).innerHTML.match(/^\s*$/); 1215}, 1216descendantOf: function(element, ancestor) { 1217element = $(element), ancestor = $(ancestor); 1218while (element = element.parentNode) 1219if (element == ancestor) return true; 1220return false; 1221}, 1222scrollTo: function(element) { 1223element = $(element); 1224var pos = Position.cumulativeOffset(element); 1225window.scrollTo(pos[0], pos[1]); 1226return element; 1227}, 1228getStyle: function(element, style) { 1229if (typeof element == 'string') { 1230element = $(element); 1231} 1232if (['float','cssFloat'].include(style)) 1233style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 1234style = style.camelize(); 1235var value = element.style[style]; 1236if (!value) { 1237if (document.defaultView && document.defaultView.getComputedStyle) { 1238var css = document.defaultView.getComputedStyle(element, null); 1239if(css) { 1240if(css[style] == undefined) { 1241value = css.getPropertyValue(style); 1242} else { 1243value = css[style]; 1244} 1245} else { 1246value = null; 1247} 1248} else if (element.currentStyle) { 1249value = element.currentStyle[style]; 1250if(value == "thin") { 1251value = "2px"; 1252} else if(value == "medium") { 1253value = "4px"; 1254} else if(value == "thick") { 1255value = "6px"; 1256} 1257} 1258} 1259if((value == 'auto') && ['width','height'].include(style) && (Element.getStyle(element, 'display') != 'none')) 1260value = element['offset'+style.capitalize()] + 'px'; 1261if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) 1262if (Element.getStyle(element, 'position') == 'static') value = 'auto'; 1263if(style == 'opacity') { 1264if(value) return parseFloat(value); 1265if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) 1266if(value[1]) return parseFloat(value[1]) / 100; 1267return 1.0; 1268} 1269return value == 'auto' ? null : value; 1270}, 1271setStyle: function(element, style) { 1272if (typeof element == 'string') { 1273element = $(element); 1274} 1275for (var name in style) { 1276var value = style[name]; 1277if(name == 'opacity') { 1278if (value == 1) { 1279value = (/Gecko/.test(navigator.userAgent) && 1280!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0; 1281if(/MSIE/.test(navigator.userAgent) && !window.opera) 1282element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); 1283} else if(value == '') { 1284if(/MSIE/.test(navigator.userAgent) && !window.opera) 1285element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); 1286} else { 1287if(value < 0.00001) value = 0; 1288if(/MSIE/.test(navigator.userAgent) && !window.opera) 1289element.style.filter = Element.getStyle(element, 'filter').replace(/alpha\([^\)]*\)/gi,'') + 1290'alpha(opacity='+value*100+')'; 1291} 1292} else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat'; 1293element.style[name.camelize()] = value; 1294if(browser.isNS && name.camelize() == 'opacity') { 1295element.style.MozOpacity = value; 1296} 1297} 1298return element; 1299}, 1300getDimensions: function(element) { 1301element = $(element); 1302var display = $(element).getStyle('display'); 1303if (display != 'none' && display != null) 1304return {width: element.offsetWidth, height: element.offsetHeight}; 1305var els = element.style; 1306var originalVisibility = els.visibility; 1307var originalPosition = els.position; 1308var originalDisplay = els.display; 1309els.visibility = 'hidden'; 1310els.position = 'absolute'; 1311els.display = 'block'; 1312var originalWidth = element.clientWidth; 1313var originalHeight = element.clientHeight; 1314els.display = originalDisplay; 1315els.position = originalPosition; 1316els.visibility = originalVisibility; 1317return {width: originalWidth, height: originalHeight}; 1318}, 1319makePositioned: function(element) { 1320element = $(element); 1321var pos = Element.getStyle(element, 'position'); 1322if (pos == 'static' || !pos) { 1323element._madePositioned = true; 1324element.style.position = 'relative'; 1325if (window.opera) { 1326element.style.top = 0; 1327element.style.left = 0; 1328} 1329} 1330return element; 1331}, 1332undoPositioned: function(element) { 1333element = $(element); 1334if (element._madePositioned) { 1335element._madePositioned = undefined; 1336element.style.position = 1337element.style.top = 1338element.style.left = 1339element.style.bottom = 1340element.style.right = ''; 1341} 1342return element; 1343}, 1344makeClipping: function(element) { 1345element = $(element); 1346if (element._overflow) return element; 1347element._overflow = element.style.overflow || 'auto'; 1348if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') 1349element.style.overflow = 'hidden'; 1350return element; 1351}, 1352undoClipping: function(element) { 1353element = $(element); 1354if (!element._overflow) return element; 1355element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; 1356element._overflow = null; 1357return element; 1358}, 1359getParentElement: function(object,nodeNum) { 1360if(nodeNum == undefined) { 1361nodeNum = 1; 1362} 1363while(nodeNum > 0){ 1364if(object.parentNode) 1365object = object.parentNode; 1366nodeNum = nodeNum - 1; 1367} 1368return object; 1369}, 1370getChildElement: function(object,nodeNum) { 1371if(nodeNum == undefined) { 1372nodeNum = 1; 1373} 1374while(nodeNum > 0){ 1375if(object.childNodes[0]){ 1376object = object.childNodes[0]; 1377if(object && object.tagName == undefined) { 1378while(object.tagName == undefined){ 1379object = object.nextSibling; 1380if(!object) 1381return null; 1382} 1383} 1384}else 1385return null; 1386nodeNum = nodeNum - 1; 1387} 1388return object; 1389}, 1390getChildElementByClassName: function(el, className) { 1391var el = $(el); 1392if(Element.hasClassName(el, className)) { 1393return el; 1394} 1395var tmp = null; 1396for (var i = 0; i < el.childNodes.length; i++) { 1397if(el.childNodes[i].nodeType == 1) { 1398tmp = this.getChildElementByClassName(el.childNodes[i], className); 1399if (tmp != null) 1400return tmp; 1401} 1402} 1403return null; 1404}, 1405getParentElementByClassName: function(el, className) { 1406var el = $(el); 1407if(Element.hasClassName(el, className)) { 1408return el; 1409} 1410el = el.parentNode; 1411if(!el || el.tagName == "BODY") 1412return null; 1413var tmp = this.getParentElementByClassName(el, className); 1414if(tmp != null) 1415return tmp 1416return null; 1417} 1418}; 1419Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); 1420Element._attributeTranslations = {}; 1421Element._attributeTranslations.names = { 1422colspan: "colSpan", 1423rowspan: "rowSpan", 1424valign: "vAlign", 1425datetime: "dateTime", 1426accesskey: "accessKey", 1427tabindex: "tabIndex", 1428enctype: "encType", 1429maxlength: "maxLength", 1430readonly: "readOnly", 1431longdesc: "longDesc" 1432}; 1433Element._attributeTranslations.values = { 1434_getAttr: function(element, attribute) { 1435return element.getAttribute(attribute, 2); 1436}, 1437_flag: function(element, attribute) { 1438return $(element).hasAttribute(attribute) ? attribute : null; 1439}, 1440style: function(element) { 1441return element.style.cssText.toLowerCase(); 1442}, 1443title: function(element) { 1444var node = element.getAttributeNode('title'); 1445return node.specified ? node.nodeValue : null; 1446} 1447}; 1448Object.extend(Element._attributeTranslations.values, { 1449href: Element._attributeTranslations.values._getAttr, 1450src: Element._attributeTranslations.values._getAttr, 1451disabled: Element._attributeTranslations.values._flag, 1452checked: Element._attributeTranslations.values._flag,
1453readonly: Element._attributeTranslations.values._flag, 1454multiple: Element._attributeTranslations.values._flag 1455}); 1456Element.Methods.Simulated = { 1457hasAttribute: function(element, attribute) { 1458var t = Element._attributeTranslations; 1459attribute = t.names[attribute] || attribute; 1460return $(element).getAttributeNode(attribute).specified; 1461} 1462}; 1463if (document.all && !window.opera){ 1464Element.Methods.update = function(element, html) { 1465element = $(element); 1466html = typeof html == 'undefined' ? '' : html.toString(); 1467var tagName = element.tagName.toUpperCase(); 1468if (['THEAD','TBODY','TR','TD'].include(tagName)) { 1469var div = document.createElement('div'); 1470switch (tagName) { 1471case 'THEAD': 1472case 'TBODY': 1473div.innerHTML = '<table><tbody>' + html.stripScripts() + '</tbody></table>'; 1474depth = 2; 1475break; 1476case 'TR': 1477div.innerHTML = '<table><tbody><tr>' + html.stripScripts() + '</tr></tbody></table>'; 1478depth = 3; 1479break; 1480case 'TD': 1481div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>'; 1482depth = 4; 1483} 1484$A(element.childNodes).each(function(node){ 1485element.removeChild(node) 1486}); 1487depth.times(function(){ div = div.firstChild }); 1488$A(div.childNodes).each( 1489function(node){ element.appendChild(node) }); 1490} else { 1491element.innerHTML = html.stripScripts(); 1492} 1493setTimeout(function() {html.evalScripts()}, 10); 1494return element; 1495} 1496}; 1497Object.extend(Element, Element.Methods); 1498var _nativeExtensions = false; 1499if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)) 1500['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) { 1501var className = 'HTML' + tag + 'Element'; 1502if(window[className]) return; 1503var klass = window[className] = {}; 1504klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__; 1505}); 1506Element.addMethods = function(methods) { 1507Object.extend(Element.Methods, methods || {}); 1508function copy(methods, destination, onlyIfAbsent) { 1509onlyIfAbsent = onlyIfAbsent || false; 1510var cache = Element.extend.cache; 1511for (var property in methods) { 1512var value = methods[property]; 1513if (!onlyIfAbsent || !(property in destination)) 1514destination[property] = cache.findOrStore(value); 1515} 1516} 1517if (typeof HTMLElement != 'undefined') { 1518copy(Element.Methods, HTMLElement.prototype); 1519copy(Element.Methods.Simulated, HTMLElement.prototype, true); 1520copy(Form.Methods, HTMLFormElement.prototype); 1521[HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { 1522copy(Form.Element.Methods, klass.prototype); 1523}); 1524_nativeExtensions = true; 1525} 1526} 1527var Toggle = new Object(); 1528Toggle.display = Element.toggle; 1529Abstract.Insertion = function(adjacency) { 1530this.adjacency = adjacency; 1531} 1532Abstract.Insertion.prototype = { 1533initialize: function(element, content) { 1534this.element = $(element); 1535this.content = content.stripScripts(); 1536if (this.adjacency && this.element.insertAdjacentHTML) { 1537try { 1538this.element.insertAdjacentHTML(this.adjacency, this.content); 1539} catch (e) { 1540var tagName = this.element.tagName.toUpperCase(); 1541if (['TBODY', 'TR'].include(tagName)) { 1542this.insertContent(this.contentFromAnonymousTable()); 1543} else { 1544throw e; 1545} 1546} 1547} else { 1548this.range = this.element.ownerDocument.createRange(); 1549if (this.initializeRange) this.initializeRange(); 1550this.insertContent([this.range.createContextualFragment(this.content)]); 1551} 1552setTimeout(function() {content.evalScripts()}, 10); 1553}, 1554contentFromAnonymousTable: function() { 1555var div = document.createElement('div'); 1556div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>'; 1557return $A(div.childNodes[0].childNodes[0].childNodes); 1558} 1559} 1560var Insertion = new Object(); 1561Insertion.Before = Class.create(); 1562Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), { 1563initializeRange: function() { 1564this.range.setStartBefore(this.element); 1565}, 1566insertContent: function(fragments) { 1567fragments.each((function(fragment) { 1568this.element.parentNode.insertBefore(fragment, this.element); 1569}).bind(this)); 1570} 1571}); 1572Insertion.Top = Class.create(); 1573Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), { 1574initializeRange: function() { 1575this.range.selectNodeContents(this.element); 1576this.range.collapse(true); 1577}, 1578insertContent: function(fragments) { 1579fragments.reverse(false).each((function(fragment) { 1580this.element.insertBefore(fragment, this.element.firstChild); 1581}).bind(this)); 1582} 1583}); 1584Insertion.Bottom = Class.create(); 1585Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), { 1586initializeRange: function() { 1587this.range.selectNodeContents(this.element); 1588this.range.collapse(this.element); 1589}, 1590insertContent: function(fragments) { 1591fragments.each((function(fragment) { 1592this.element.appendChild(fragment); 1593}).bind(this)); 1594} 1595}); 1596Insertion.After = Class.create(); 1597Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), { 1598initializeRange: function() { 1599this.range.setStartAfter(this.element); 1600}, 1601insertContent: function(fragments) { 1602fragments.each((function(fragment) { 1603this.element.parentNode.insertBefore(fragment, 1604this.element.nextSibling); 1605}).bind(this)); 1606} 1607}); 1608Element.ClassNames = Class.create(); 1609Element.ClassNames.prototype = { 1610initialize: function(element) { 1611this.element = $(element); 1612}, 1613_each: function(iterator) { 1614this.element.className.split(/\s+/).select(function(name) { 1615return name.length > 0; 1616})._each(iterator); 1617}, 1618set: function(className) { 1619this.element.className = className; 1620}, 1621add: function(classNameToAdd) { 1622if (this.include(classNameToAdd)) return; 1623this.set($A(this).concat(classNameToAdd).join(' ')); 1624}, 1625remove: function(classNameToRemove) { 1626if (!this.include(classNameToRemove)) return; 1627this.set($A(this).without(classNameToRemove).join(' ')); 1628}, 1629toString: function() { 1630return $A(this).join(' '); 1631} 1632}; 1633Object.extend(Element.ClassNames.prototype, Enumerable); 1634var Selector = Class.create(); 1635Selector.prototype = { 1636initialize: function(expression) { 1637this.params = {classNames: []};
1638this.expression = expression.toString().strip(); 1639this.parseExpression(); 1640this.compileMatcher(); 1641}, 1642parseExpression: function() { 1643function abort(message) { throw 'Parse error in selector: ' + message; } 1644if (this.expression == '') abort('empty expression'); 1645var params = this.params, expr = this.expression, match, modifier, clause, rest; 1646while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { 1647params.attributes = params.attributes || []; 1648params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); 1649expr = match[1]; 1650} 1651if (expr == '*') return this.params.wildcard = true; 1652while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) { 1653modifier = match[1], clause = match[2], rest = match[3]; 1654switch (modifier) { 1655case '#': params.id = clause; break; 1656case '.': params.classNames.push(clause); break; 1657case '': 1658case undefined: params.tagName = clause.toUpperCase(); break; 1659default: abort(expr.inspect()); 1660} 1661expr = rest; 1662} 1663if (expr.length > 0) abort(expr.inspect()); 1664}, 1665buildMatchExpression: function() { 1666var params = this.params, conditions = [], clause; 1667if (params.wildcard) 1668conditions.push('true'); 1669if (clause = params.id) 1670conditions.push('element.readAttribute("id") == ' + clause.inspect()); 1671if (clause = params.tagName) 1672conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); 1673if ((clause = params.classNames).length > 0) 1674for (var i = 0, length = clause.length; i < length; i++) 1675conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); 1676if (clause = params.attributes) { 1677clause.each(function(attribute) { 1678var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; 1679var splitValueBy = function(delimiter) { 1680return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; 1681} 1682switch (attribute.operator) { 1683case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break; 1684case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break; 1685case '|=': conditions.push( 1686splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect() 1687); break; 1688case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; 1689case '': 1690case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; 1691default: throw 'Unknown operator ' + attribute.operator + ' in selector'; 1692} 1693}); 1694} 1695return conditions.join(' && '); 1696}, 1697compileMatcher: function() { 1698this.match = new Function('element', 'if (!element.tagName) return false; \ 1699element = $(element); \ 1700return ' + this.buildMatchExpression()); 1701}, 1702findElements: function(scope) { 1703var element; 1704if (element = $(this.params.id)) 1705if (this.match(element)) 1706if (!scope || Element.childOf(element, scope)) 1707return [element]; 1708scope = (scope || document).getElementsByTagName(this.params.tagName || '*'); 1709var results = []; 1710for (var i = 0, length = scope.length; i < length; i++) 1711if (this.match(element = scope[i])) 1712results.push(Element.extend(element)); 1713return results; 1714}, 1715toString: function() { 1716return this.expression; 1717} 1718} 1719Object.extend(Selector, { 1720matchElements: function(elements, expression) { 1721var selector = new Selector(expression); 1722return elements.select(selector.match.bind(selector)).map(Element.extend); 1723}, 1724findElement: function(elements, expression, index) { 1725if (typeof expression == 'number') index = expression, expression = false; 1726return Selector.matchElements(elements, expression || '*')[index || 0]; 1727}, 1728findChildElements: function(element, expressions) { 1729return expressions.map(function(expression) { 1730return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) { 1731var selector = new Selector(expr); 1732return results.inject([], function(elements, result) { 1733return elements.concat(selector.findElements(result || element)); 1734}); 1735}); 1736}).flatten(); 1737} 1738}); 1739function $$() { 1740return Selector.findChildElements(document, $A(arguments)); 1741} 1742var Form = { 1743reset: function(form) { 1744$(form).reset(); 1745return form; 1746}, 1747serializeElements: function(elements, getHash) { 1748var data = elements.inject({}, function(result, element) { 1749if (!element.disabled && element.name) { 1750var key = element.name, value = Form.Element.getValue($(element)); 1751if (value != undefined) { 1752if (result[key]) {
1753if (result[key].constructor != Array) result[key] = [result[key]]; 1754result[key].push(value); 1755} 1756else result[key] = value; 1757} 1758} 1759return result; 1760}); 1761return getHash ? data : Hash.toQueryString(data); 1762} 1763}; 1764Form.Methods = { 1765serialize: function(form, getHash) { 1766return Form.serializeElements(Form.getElements(form), getHash); 1767}, 1768getElements: function(form) { 1769return $A($(form).getElementsByTagName('*')).inject([], 1770function(elements, child) { 1771if (Form.Element.Serializers[child.tagName.toLowerCase()]) 1772elements.push(Element.extend(child)); 1773return elements; 1774} 1775); 1776}, 1777getInputs: function(form, typeName, name) { 1778form = $(form); 1779var inputs = form.getElementsByTagName('input'); 1780if (!typeName && !name) return $A(inputs).map(Element.extend); 1781for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { 1782var input = inputs[i]; 1783if ((typeName && input.type != typeName) || (name && input.name != name)) 1784continue; 1785matchingInputs.push(Element.extend(input)); 1786} 1787return matchingInputs; 1788}, 1789disable: function(form) { 1790form = $(form); 1791form.getElements().each(function(element) { 1792element.blur(); 1793element.disabled = 'true'; 1794}); 1795return form; 1796}, 1797enable: function(form) { 1798form = $(form); 1799form.getElements().each(function(element) { 1800element.disabled = ''; 1801}); 1802return form; 1803}, 1804findFirstElement: function(form) { 1805return Form.getElements($(form)).find(function(element) { 1806return element.type != 'hidden' && !element.disabled && 1807['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); 1808}); 1809}, 1810focusFirstElement: function(form) { 1811form = $(form); 1812var el = Form.findFirstElement(form); 1813Form.Element.Methods.activate(el); 1814return form; 1815} 1816} 1817Object.extend(Form, Form.Methods); 1818Form.Element = { 1819focus: function(element) { 1820$(element).focus(); 1821return element; 1822}, 1823select: function(element) { 1824$(element).select(); 1825return element; 1826} 1827} 1828Form.Element.Methods = { 1829serialize: function(element) { 1830element = $(element); 1831if (!element.disabled && element.name) { 1832var value = element.getValue(); 1833if (value != undefined) { 1834var pair = {}; 1835pair[element.name] = value; 1836return Hash.toQueryString(pair); 1837} 1838} 1839return ''; 1840}, 1841getValue: function(element) { 1842element = $(element); 1843var method = element.tagName.toLowerCase(); 1844return Form.Element.Serializers[method](element); 1845}, 1846clear: function(element) { 1847$(element).value = ''; 1848return element; 1849}, 1850present: function(element) { 1851return $(element).value != ''; 1852}, 1853activate: function(element) { 1854element = $(element); 1855element.focus(); 1856if (element.select && ( element.tagName.toLowerCase() != 'input' || 1857!['button', 'reset', 'submit'].include(element.type) ) ) 1858element.select(); 1859return element; 1860}, 1861disable: function(element) { 1862element = $(element); 1863element.disabled = true; 1864return element; 1865}, 1866enable: function(element) { 1867element = $(element); 1868element.blur(); 1869element.disabled = false; 1870return element; 1871} 1872} 1873Object.extend(Form.Element, Form.Element.Methods); 1874var Field = Form.Element; 1875var $F = Form.Element.getValue; 1876Form.Element.setValue = function(element,newValue) { 1877element_id = element; 1878element = $(element); 1879if (!element){element = document.getElementsByName(element_id)[0];} 1880if (!element){return false;} 1881var method = element.tagName.toLowerCase(); 1882var parameter = Form.Element.SetSerializers[method](element,newValue); 1883} 1884Form.Element.SetSerializers = { 1885input: function(element,newValue) { 1886switch (element.type.toLowerCase()) { 1887case 'submit': 1888case 'hidden': 1889case 'password': 1890case 'text': 1891return Form.Element.SetSerializers.textarea(element,newValue); 1892case 'checkbox': 1893case 'radio': 1894return Form.Element.SetSerializers.inputSelector(element,newValue); 1895} 1896return false; 1897}, 1898inputSelector: function(element,newValue) { 1899fields = document.getElementsByName(element.name); 1900for (var i=0;i<fields.length;i++){ 1901if (fields[i].value == newValue){ 1902fields[i].checked = true; 1903} 1904} 1905}, 1906textarea: function(element,newValue) { 1907element.value = newValue; 1908}, 1909select: function(element,newValue) { 1910var value = '', opt, index = element.selectedIndex; 1911for (var i=0;i< element.options.length;i++){ 1912if (element.options[i].value == newValue){ 1913element.selectedIndex = i; 1914return true; 1915} 1916} 1917} 1918} 1919Form.Element.Serializers = { 1920input: function(element) { 1921switch (element.type.toLowerCase()) { 1922case 'checkbox': 1923case 'radio': 1924return Form.Element.Serializers.inputSelector(element); 1925default: 1926return Form.Element.Serializers.textarea(element); 1927} 1928}, 1929inputSelector: function(element) { 1930return element.checked ? element.value : null; 1931}, 1932textarea: function(element) { 1933return element.value; 1934}, 1935select: function(element) { 1936return this[element.type == 'select-one' ? 1937'selectOne' : 'selectMany'](element); 1938}, 1939selectOne: function(element) { 1940var index = element.selectedIndex; 1941return index >= 0 ? this.optionValue(element.options[index]) : null; 1942}, 1943selectMany: function(element) { 1944var values, length = element.length; 1945if (!length) return null; 1946for (var i = 0, values = []; i < length; i++) { 1947var opt = element.options[i]; 1948if (opt.selected) values.push(this.optionValue(opt)); 1949} 1950return values; 1951}, 1952optionValue: function(opt) { 1953return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; 1954} 1955} 1956Abstract.TimedObserver = function() {} 1957Abstract.TimedObserver.prototype = { 1958initialize: function(element, frequency, callback) { 1959this.frequency = frequency; 1960this.element = $(element); 1961this.callback = callback; 1962this.lastValue = this.getValue(); 1963this.registerCallback(); 1964}, 1965registerCallback: function() { 1966setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 1967}, 1968onTimerEvent: function() { 1969var value = this.getValue(); 1970var changed = ('string' == typeof this.lastValue && 'string' == typeof value 1971? this.lastValue != value : String(this.lastValue) != String(value)); 1972if (changed) { 1973this.callback(this.element, value); 1974this.lastValue = value; 1975} 1976} 1977} 1978Form.Element.Observer = Class.create(); 1979Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { 1980getValue: function() { 1981return Form.Element.getValue(this.element); 1982} 1983}); 1984Form.Observer = Class.create(); 1985Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { 1986getValue: function() { 1987return Form.serialize(this.element); 1988} 1989}); 1990Abstract.EventObserver = function() {} 1991Abstract.EventObserver.prototype = { 1992initialize: function(element, callback) { 1993this.element = $(element); 1994this.callback = callback; 1995this.lastValue = this.getValue(); 1996if (this.element.tagName.toLowerCase() == 'form') 1997this.registerFormCallbacks(); 1998else 1999this.registerCallback(this.element); 2000}, 2001onElementEvent: function() { 2002var value = this.getValue(); 2003if (this.lastValue != value) { 2004this.callback(this.element, value); 2005this.lastValue = value; 2006} 2007}, 2008registerFormCallbacks: function() { 2009Form.getElements(this.element).each(this.registerCallback.bind(this)); 2010}, 2011registerCallback: function(element) { 2012if (element.type) { 2013switch (element.type.toLowerCase()) { 2014case 'checkbox': 2015case 'radio': 2016Event.observe(element, 'click', this.onElementEvent.bind(this)); 2017break; 2018default: 2019Event.observe(element, 'change', this.onElementEvent.bind(this)); 2020break; 2021} 2022} 2023} 2024} 2025Form.Element.EventObserver = Class.create(); 2026Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { 2027getValue: function() { 2028return Form.Element.getValue(this.element); 2029} 2030}); 2031Form.EventObserver = Class.create(); 2032Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { 2033getValue: function() { 2034return Form.serialize(this.element); 2035} 2036}); 2037if (!window.Event) { 2038var Event = new Object(); 2039} 2040Object.extend(Event, { 2041KEY_BACKSPACE: 8, 2042KEY_TAB: 9, 2043KEY_RETURN: 13, 2044KEY_ESC: 27, 2045KEY_LEFT: 37, 2046KEY_UP: 38, 2047KEY_RIGHT: 39, 2048KEY_DOWN: 40, 2049KEY_DELETE: 46, 2050KEY_HOME: 36, 2051KEY_END: 35, 2052KEY_PAGEUP: 33, 2053KEY_PAGEDOWN: 34, 2054element: function(event) { 2055return event.target || event.srcElement; 2056}, 2057isLeftClick: function(event) { 2058return (((event.which) && (event.which == 1)) || 2059((event.button) && (event.button == 1))); 2060}, 2061pointerX: function(event) { 2062return event.pageX || (event.clientX + 2063(document.documentElement.scrollLeft || document.body.scrollLeft)); 2064}, 2065pointerY: function(event) { 2066return event.pageY || (event.clientY + 2067(document.documentElement.scrollTop || document.body.scrollTop)); 2068}, 2069stop: function(event) { 2070if (event.preventDefault) { 2071event.preventDefault(); 2072event.stopPropagation(); 2073} else { 2074event.returnValue = false;
2075event.cancelBubble = true; 2076} 2077}, 2078findElement: function(event, tagName) { 2079var element = Event.element(event); 2080while (element.parentNode && (!element.tagName || 2081(element.tagName.toUpperCase() != tagName.toUpperCase()))) 2082element = element.parentNode; 2083return element; 2084}, 2085observers: false, 2086_observeAndCache: function(element, name, observer, useCapture, top_el) { 2087if (name == 'dblclick' && 2088navigator.appVersion.match(/Konqueror|Safari|KHTML/) && element.addEventListener) { 2089this.observers.push([element, name, observer, useCapture, top_el]); 2090element.ondblclick = observer; 2091} else { 2092if (!this.observers) this.observers = []; 2093if (element.addEventListener) { 2094this.observers.push([element, name, observer, useCapture, top_el]); 2095element.addEventListener(name, observer, useCapture); 2096} else if (element.attachEvent) { 2097this.observers.push([element, name, observer, useCapture, top_el]); 2098element.attachEvent('on' + name, observer); 2099} 2100} 2101}, 2102unloadCache: function(top_el) { 2103top_el = (top_el == undefined || top_el == null || $(top_el).nodeType == undefined) ? undefined : $(top_el); 2104if (!Event.observers) return; 2105for (var i = 0; i < Event.observers.length; i++) { 2106if(top_el == undefined || $(Event.observers[i][4]) == top_el) { 2107Event._stopObserving.apply(this, Event.observers[i]); 2108Event.observers[i][0] = null; 2109if(Event.observers[i][4]) 2110Event.observers[i][4] = null; 2111} 2112} 2113Event.observers = false; 2114}, 2115observe: function(element, name, observer, useCapture, top_el) { 2116var element = $(element); 2117useCapture = useCapture || false; 2118top_el = top_el || ""; 2119if (name == 'keypress' && 2120(navigator.appVersion.match(/Konqueror|Safari|KHTML/) 2121|| element.attachEvent)) 2122name = 'keydown'; 2123Event._observeAndCache(element, name, observer, useCapture, top_el); 2124}, 2125_stopObserving: function(element, name, observer, useCapture) { 2126element = $(element); 2127useCapture = useCapture || false; 2128if (name == 'keypress' && 2129(navigator.appVersion.match(/Konqueror|Safari|KHTML/) 2130|| element.detachEvent)) 2131name = 'keydown'; 2132if (element.removeEventListener) { 2133element.removeEventListener(name, observer, useCapture); 2134} else if (element.detachEvent) { 2135try { 2136element.detachEvent('on' + name, observer); 2137} catch (e) {} 2138} 2139}, 2140stopObserving: function(element, name, observer, useCapture) { 2141if (!Event.observers) return; 2142element = $(element); 2143if (name == 'keypress' && 2144(navigator.appVersion.match(/Konqueror|Safari|KHTML/) 2145|| element.detachEvent)) 2146name = 'keydown'; 2147var observers = this.observers.partition(function(value){ 2148return ( (!element || value[0] == element ) 2149&& (!name || value[1] == name ) 2150&& (!observer || value[2] == observer ) 2151&& (useCapture == null || value[3] == useCapture ) 2152) 2153}); 2154if(observers[0].length == 0) return; 2155observers[0].each(function(value){ 2156this._stopObserving.apply(this, value); 2157}.bind(this)); 2158this.observers = observers[1]; 2159} 2160}); 2161if (navigator.appVersion.match(/\bMSIE\b/)) 2162Event.observe(window, 'unload', Event.unloadCache, false); 2163var Position = { 2164includeScrollOffsets: false, 2165prepare: function() { 2166this.deltaX = window.pageXOffset 2167|| document.documentElement.scrollLeft 2168|| document.body.scrollLeft 2169|| 0; 2170this.deltaY = window.pageYOffset 2171|| document.documentElement.scrollTop 2172|| document.body.scrollTop 2173|| 0; 2174}, 2175realOffset: function(element) { 2176var valueT = 0, valueL = 0; 2177do { 2178valueT += element.scrollTop || 0; 2179valueL += element.scrollLeft || 0; 2180element = element.parentNode; 2181} while (element); 2182return [valueL, valueT]; 2183}, 2184cumulativeOffset: function(element) { 2185var valueT = 0, valueL = 0; 2186do { 2187valueT += element.offsetTop || 0; 2188valueL += element.offsetLeft || 0; 2189element = element.offsetParent; 2190} while (element); 2191return [valueL, valueT]; 2192}, 2193cumulativeOffsetScroll: function(element) { 2194var valueT = 0, valueL = 0; 2195var buf_element = null; 2196do { 2197var parent_el = element.parentNode; 2198if(buf_element == null || buf_element == element) { 2199valueT += element.offsetTop || 0; 2200valueL += element.offsetLeft || 0; 2201if(parent_el && parent_el.tagName) { 2202buf_element = element.offsetParent; 2203} else { 2204break; 2205} 2206} 2207if(element.tagName != undefined && element.tagName.toLowerCase() != "html" && element.tagName.toLowerCase() != "body") { 2208valueT -= element.scrollTop || 0; 2209valueL -= element.scrollLeft || 0; 2210} 2211element = parent_el; 2212} while (element); 2213return [valueL, valueT]; 2214}, 2215positionedOffsetScroll: function(element) { 2216var valueT = 0, valueL = 0; 2217var buf_element = null; 2218do { 2219if(buf_element == null || buf_element == element) { 2220valueT += element.offsetTop || 0; 2221valueL += element.offsetLeft || 0; 2222buf_element = element.offsetParent; 2223} 2224if(element.tagName != undefined && element.tagName.toLowerCase() != "html" && element.tagName.toLowerCase() != "body") { 2225valueT -= element.scrollTop || 0; 2226valueL -= element.scrollLeft || 0; 2227} 2228element = element.parentNode; 2229if (element) { 2230if(element.tagName=='BODY') break; 2231var p = Element.getStyle(element, 'position'); 2232if (p == 'relative' || p == 'absolute') break; 2233} 2234} while (element); 2235return [valueL, valueT]; 2236}, 2237positionedOffset: function(element) { 2238var valueT = 0, valueL = 0; 2239do { 2240valueT += element.offsetTop || 0; 2241valueL += element.offsetLeft || 0; 2242element = element.offsetParent; 2243if (element) { 2244if(element.tagName=='BODY') break; 2245var p = Element.getStyle(element, 'position'); 2246if (p == 'relative' || p == 'absolute') break; 2247} 2248} while (element); 2249return [valueL, valueT]; 2250}, 2251offsetParent: function(element) { 2252if (element.offsetParent) return element.offsetParent; 2253if (element == document.body) return element; 2254while ((element = element.parentNode) && element != document.body) 2255if (Element.getStyle(element, 'position') != 'static') 2256return element; 2257return document.body; 2258}, 2259within: function(element, x, y, offset) { 2260offset = (offset == undefined || offset == null) ? 0 : offset; 2261if (this.includeScrollOffsets) 2262return this.withinIncludingScrolloffsets(element, x, y); 2263this.xcomp = x; 2264this.ycomp = y; 2265this.offset = this.cumulativeOffset(element); 2266return (y >= this.offset[1] + offset && 2267y < this.offset[1] + element.offsetHeight - offset && 2268x >= this.offset[0] + offset && 2269x < this.offset[0] + element.offsetWidth - offset); 2270}, 2271within_x: function(element, x) { 2272if (this.includeScrollOffsets) 2273return this.withinIncludingScrolloffsets_x(element, x); 2274this.xcomp = x; 2275this.offset = this.cumulativeOffset(element); 2276return (x >= this.offset[0] && 2277x < this.offset[0] + element.offsetWidth); 2278}, 2279within_y: function(element, y) { 2280if (this.includeScrollOffsets) 2281return this.withinIncludingScrolloffsets_y(element, y); 2282this.ycomp = y; 2283this.offset = this.cumulativeOffset(element); 2284return (y >= this.offset[1] && 2285y < this.offset[1] + element.offsetHeight); 2286}, 2287withinIncludingScrolloffsets_x: function(element, x) { 2288var offsetcache = this.realOffset(element); 2289this.xcomp = x + offsetcache[0] - this.deltaX; 2290this.offset = this.cumulativeOffset(element); 2291return (this.xcomp >= this.offset[0] && 2292this.xcomp < this.offset[0] + element.offsetWidth); 2293}, 2294withinIncludingScrolloffsets_y: function(element, y) { 2295var offsetcache = this.realOffset(element); 2296this.ycomp = y + offsetcache[1] - this.deltaY; 2297this.offset = this.cumulativeOffset(element); 2298return (this.ycomp >= this.offset[1] && 2299this.ycomp < this.offset[1] + element.offsetHeight); 2300}, 2301getWinOuterWidth: function(){ 2302if(browser.isSafari) 2303var offset = 14; 2304else 2305var offset = 0; 2306var width = document.documentElement.clientWidth 2307|| document.body.clientWidth 2308|| 0; 2309width = width - offset; 2310return width; 2311}, 2312getWinOuterHeight: function(){ 2313if(browser.isSafari) 2314var offset = 65; 2315else 2316var offset = 0; 2317if(browser.isSafari) { 2318var height = window.outerHeight; 2319} else { 2320var height = document.documentElement.clientHeight 2321|| document.body.clientHeight 2322|| 0; 2323} 2324height = height - offset; 2325return height; 2326}, 2327getWinOffsetWidth: function(){ 2328var width = window.offsetWidth 2329|| document.documentElement.offsetWidth 2330|| document.body.offsetWidth 2331|| 0; 2332return width; 2333}, 2334getWinOffsetHeight: function(){ 2335var height = window.offsetHeight 2336|| document.documentElement.offsetHeight 2337|| document.body.offsetHeight 2338|| 0; 2339return height; 2340}, 2341withinIncludingScrolloffsets: function(element, x, y) { 2342var offsetcache = this.realOffset(element); 2343this.xcomp = x + offsetcache[0] - this.deltaX; 2344this.ycomp = y + offsetcache[1] - this.deltaY; 2345this.offset = this.cumulativeOffset(element); 2346return (this.ycomp >= this.offset[1] && 2347this.ycomp < this.offset[1] + element.offsetHeight && 2348this.xcomp >= this.offset[0] && 2349this.xcomp < this.offset[0] + element.offsetWidth); 2350}, 2351overlap: function(mode, element) { 2352if (!mode) return 0; 2353if (mode == 'vertical') 2354return ((this.offset[1] + element.offsetHeight) - this.ycomp) / 2355element.offsetHeight; 2356if (mode == 'horizontal') 2357return ((this.offset[0] + element.offsetWidth) - this.xcomp) / 2358element.offsetWidth; 2359}, 2360page: function(forElement) { 2361var valueT = 0, valueL = 0; 2362var element = forElement; 2363do { 2364valueT += element.offsetTop || 0; 2365valueL += element.offsetLeft || 0; 2366if (element.offsetParent==document.body) 2367if (Element.getStyle(element,'position')=='absolute') break; 2368} while (element = element.offsetParent); 2369element = forElement; 2370do { 2371if (!window.opera || element.tagName=='BODY') { 2372valueT -= element.scrollTop || 0; 2373valueL -= element.scrollLeft || 0; 2374} 2375} while (element = element.parentNode); 2376return [valueL, valueT]; 2377}, 2378clone: function(source, target) { 2379var options = Object.extend({ 2380setLeft: true, 2381setTop: true, 2382setWidth: true, 2383setHeight: true, 2384offsetTop: 0, 2385offsetLeft: 0 2386}, arguments[2] || {}) 2387source = $(source); 2388var p = Position.page(source); 2389target = $(target); 2390var delta = [0, 0]; 2391var parent = null; 2392if (Element.getStyle(target,'position') == 'absolute') { 2393parent = Position.offsetParent(target); 2394delta = Position.page(parent); 2395} 2396if (parent == document.body) { 2397delta[0] -= document.body.offsetLeft; 2398delta[1] -= document.body.offsetTop; 2399}
2400if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; 2401if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; 2402if(options.setWidth) target.style.width = source.offsetWidth + 'px'; 2403if(options.setHeight) target.style.height = source.offsetHeight + 'px'; 2404}, 2405absolutize: function(element) { 2406element = $(element); 2407if (element.style.position == 'absolute') return; 2408Position.prepare(); 2409var offsets = Position.positionedOffset(element); 2410var top = offsets[1]; 2411var left = offsets[0]; 2412var width = element.clientWidth; 2413var height = element.clientHeight; 2414element._originalLeft = left - parseFloat(element.style.left || 0); 2415element._originalTop = top - parseFloat(element.style.top || 0); 2416element._originalWidth = element.style.width; 2417element._originalHeight = element.style.height; 2418element.style.position = 'absolute'; 2419element.style.top = top + 'px'; 2420element.style.left = left + 'px'; 2421element.style.width = width + 'px'; 2422element.style.height = height + 'px'; 2423}, 2424relativize: function(element) { 2425element = $(element); 2426if (element.style.position == 'relative') return; 2427Position.prepare(); 2428element.style.position = 'relative'; 2429var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); 2430var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); 2431element.style.top = top + 'px'; 2432element.style.left = left + 'px'; 2433element.style.height = element._originalHeight; 2434element.style.width = element._originalWidth; 2435} 2436} 2437if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 2438Position.cumulativeOffset = function(element) { 2439var valueT = 0, valueL = 0; 2440do { 2441valueT += element.offsetTop || 0; 2442valueL += element.offsetLeft || 0; 2443if (element.offsetParent == document.body) 2444if (Element.getStyle(element, 'position') == 'absolute') break; 2445element = element.offsetParent; 2446} while (element); 2447return [valueL, valueT]; 2448} 2449} 2450Element.addMethods(); 2451document._write = document.write; 2452var _nc_global_script_write_html = ''; 2453var _nc_global_script_span = null; 2454document.write = function(s) { 2455_nc_global_script_write_html+=s; 2456if(_nc_global_script_span == null) { 2457_nc_global_script_span = document.createElement("SPAN"); 2458} 2459var dwScriptCount = parseInt(_nc_dwScriptCount); 2460var dwScriptList = _nc_dwScriptList; 2461var self = document.write.prototype; 2462if(_nc_ajaxFlag == true && dwScriptList[dwScriptCount]) { 2463var current = dwScriptList[dwScriptCount]; 2464} else { 2465var current = self.getCurrentScript(); 2466} 2467if(_nc_global_script_span.innerHTML != '') { 2468if(current){ 2469current.parentNode.insertBefore(_nc_global_script_span, current); 2470} else { 2471document.body.appendChild(_nc_global_script_span); 2472} 2473} 2474_nc_global_script_span.innerHTML = _nc_global_script_write_html; 2475} 2476document.write.prototype = { 2477'getCurrentScript' : function () { 2478return ( 2479function (el) { 2480if (el && el.nodeName.toLowerCase() == 'script') return el; 2481return arguments.callee(el.lastChild) 2482} 2483)(document); 2484} 2485} 2486function Browser() { 2487var ua, s, i; 2488this.isGecko = false; 2489this.isIE = false; 2490this.isNS = false; 2491this.isFirefox = false; 2492this.isOpera = false; 2493this.isSafari = false; 2494this.version = null; 2495ua = navigator.userAgent; 2496s = "Opera"; 2497if ((i = ua.indexOf(s)) >= 0) { 2498this.isOpera = true; 2499return; 2500} 2501s = "MSIE"; 2502if ((i = ua.indexOf(s)) >= 0) { 2503this.isIE = true; 2504this.version = parseFloat(ua.substr(i + s.length)); 2505return; 2506} 2507s = "Netscape"; 2508if ((i = ua.indexOf(s)) >= 0) { 2509this.isGecko = true; 2510this.isNS = true; 2511this.version = parseFloat(ua.substr(i + s.length)); 2512s = "Firefox"; 2513if ((i = ua.indexOf(s)) >= 0) { 2514this.isFirefox = true; 2515} 2516return; 2517} 2518s = "Gecko"; 2519if ((i = ua.indexOf(s)) >= 0) { 2520this.isGecko = true; 2521this.version = 6.1; 2522s = "Firefox"; 2523if ((i = ua.indexOf(s)) >= 0) { 2524this.isFirefox = true; 2525} 2526s = "Safari"; 2527if ((i = ua.indexOf(s)) >= 0) { 2528this.isSafari = true; 2529} 2530return; 2531} 2532} 2533function $_GET($_GETStr,$_URL){ 2534if($_URL == undefined) { 2535$_GETURL = location.search.split("&"); 2536} else { 2537$_GETURL = $_URL.split("&"); 2538} 2539$_GETURL[0] = $_GETURL[0].substr(1,$_GETURL[0].length); 2540for (var i = 0; i < $_GETURL.length; i++) { 2541if($_GETStr == $_GETURL[i].substr(0,$_GETURL[i].indexOf("="))){ 2542return decodeURIComponent( 2543$_GETURL[i].substr($_GETURL[i].indexOf("=")+1,$_GETURL[i].length) 2544); 2545} 2546} 2547} 2548var browser = new Browser(); 2549function valueParseInt(param) { 2550if(param == "" || param == undefined || param == null){ 2551return 0; 2552} 2553var ret = parseInt(param, 10); 2554return isNaN(parseInt(param, 10)) ? 0 : ret; 2555} 2556var clsCommon = Class.create(); 2557clsCommon.prototype = { 2558initialize: function() { 2559this.moduleList = new Object(); 2560this.show_x = new Object(); 2561this.show_y = new Object(); 2562this.move_div = new Object(); 2563this.pre_show_x = new Object(); 2564this.pre_show_y = new Object(); 2565this.start_x = new Object(); 2566this.start_y = new Object(); 2567this.speedx = new Object();
2568this.speedy = new Object(); 2569this.inShowLoading = Array(); 2570this.inModalEvent = Array(); 2571this.max_zIndex = 999; 2572this.hideElement = new Object(); 2573this.winMoveDragStartEvent = new Object(); 2574this.winMoveDragGoEvent = new Object(); 2575this.winMoveDragStopEvent = new Object(); 2576this.closeCallbackFuncEvent = new Object(); 2577this.inMoveDrag = new Object(); 2578this.referComp = new Object(); 2579this.referObject = null; 2580this.inAttachment = Array(); 2581this.attachmentCallBack = new Object(); 2582this.attachmentErrorCallBack = new Object(); 2583this.attachmentTarget = new Object(); 2584this.error_mes = "error_message:"; 2585this.fatal_error_mes = "^<br \/>\n<b>Fatal error<\/b>:(.|\n|\r|\t)*<\/b>"; 2586this.toolTipPopup = null; 2587this.inToolTipEvent = new Object(); 2588this.toolTipPopupTimer = null; 2589this.sess_timer = null; 2590this.timeout_time = null; 2591this.session_timeout_alert = null; 2592}, 2593commonInit: function(session_timeout_alert, timeout_time) { 2594var header_menu_el = $("header_menu"); 2595var bodyWidth = Position.getWinOuterWidth(); 2596if(header_menu_el && header_menu_el.offsetWidth > bodyWidth) { 2597var menu_right_el = Element.getChildElementByClassName(header_menu_el,"menu_right"); 2598if(menu_right_el) { 2599var header_margin = header_menu_el && header_menu_el.offsetWidth - bodyWidth; 2600Element.setStyle(menu_right_el, {"paddingRight":header_margin+"px"}); 2601} 2602} 2603this.timeout_time = timeout_time*1000 - 60*1000; 2604this.session_timeout_alert = session_timeout_alert; 2605this.setTimeoutAlert(); 2606}, 2607setTimeoutAlert: function() { 2608if(this.sess_timer != null) { 2609clearTimeout(this.sess_timer); 2610this.sess_timer = null; 2611} 2612if(_nc_user_id != '0') { 2613this.sess_timer = setTimeout(function(){commonCls.alert(this.session_timeout_alert);}.bind(this), this.timeout_time); 2614} 2615}, 2616moduleInit: function(id, chief_flag) { 2617var el = $(id); 2618var parent_el = Element.getParentElement(el); 2619var absolute_flag = false; 2620if(parent_el && !Element.hasClassName(parent_el,"cell") && parent_el.tagName != "BODY" && !Element.hasClassName(parent_el,"enlarged_display")) 2621absolute_flag = true; 2622commonCls.parentWinInit(el, absolute_flag, chief_flag); 2623}, 2624showLoading: function(id_name, parameters, show_x, show_y, loading_el) { 2625id_name = (id_name != undefined || id_name != null) ? id_name : ""; 2626parameters = (parameters != undefined || parameters != null) ? parameters : ""; 2627commonCls.hideLoading(id_name, parameters); 2628var div_parent = document.createElement("DIV"); 2629div_parent.innerHTML = "<div class=\"loading\"><img text=\"loading\" alt=\"loading\" src=\"http://www.yamatogokin.co.jp/images/common/indicator.gif\"/></div>"; 2630var div = div_parent.childNodes[0];
2631this.inShowLoading[id_name + parameters] = div_parent; 2632Element.addClassName(div,"loading"); 2633commonCls.showModal(null,div_parent); 2634if(loading_el && (show_x==undefined && show_y == undefined)) { 2635var loading_imege_offset_x = 8; 2636var loading_imege_offset_y = 8; 2637var offset = Position.cumulativeOffset(loading_el); 2638var ex1 = offset[0]; 2639var ey1 = offset[1]; 2640div.style.left = (ex1 + (loading_el.offsetWidth/2) - loading_imege_offset_x) +"px"; 2641div.style.top = (ey1 + (loading_el.offsetHeight/2) - loading_imege_offset_y) +"px"; 2642} else { 2643div.style.left = show_x +"px"; 2644div.style.top = show_y +"px"; 2645} 2646document.body.appendChild(div_parent); 2647}, 2648hideLoading: function(id_name, parameters) { 2649id_name = (id_name != undefined || id_name != null) ? id_name : ""; 2650parameters = (parameters != undefined || parameters != null) ? parameters : ""; 2651if(this.inShowLoading[id_name + parameters]) { 2652commonCls.stopModal(this.inShowLoading[id_name + parameters]); 2653Element.remove(this.inShowLoading[id_name + parameters]); 2654this.inShowLoading[id_name + parameters] = null; 2655return true; 2656} 2657return false; 2658}, 2659showModal: function(event, el, loading_flag) { 2660el = (event == undefined || event == null) ? el : this; 2661var scroll_left = (document.documentElement.scrollLeft || document.body.scrollLeft || 0); 2662var scroll_top = (document.documentElement.scrollTop || document.body.scrollTop || 0); 2663var offset = 0; 2664var w = Position.getWinOuterWidth(); 2665var h = Position.getWinOuterHeight(); 2666el.style.width = (w + scroll_left - offset) +"px"; 2667el.style.height = (h + scroll_top - offset) +"px"; 2668if(loading_flag) { 2669el.style.backgroundColor = "#cccccc"; 2670Element.setStyle(el, {"opacity":0.2}); 2671} 2672el.style.position = "absolute"; 2673el.style.left = "0px"; 2674el.style.top = "0px"; 2675if(event == undefined || (event.type != "scroll" && event.type != "resize")) { 2676commonCls.max_zIndex = commonCls.max_zIndex + 1; 2677el.style.zIndex = commonCls.max_zIndex; 2678commonCls.inModalEvent[el] = commonCls.showModal.bindAsEventListener(el); 2679Event.observe(window,"scroll",commonCls.inModalEvent[el],false); 2680Event.observe(window,"resize",commonCls.inModalEvent[el],false); 2681if(browser.isIE) { 2682var img_blank = document.createElement("img"); 2683img_blank.src = "http://www.yamatogokin.co.jp/images/common/blank.gif"; 2684el.appendChild(img_blank); 2685} 2686if(browser.isIE) { 2687if(img_blank==undefined) { 2688var img_blank = Element.getChildElement(el); 2689} 2690img_blank.style.width = el.style.width; 2691img_blank.style.height = el.style.height; 2692} 2693} 2694}, 2695stopModal: function(el) { 2696Event.stopObserving(window,"scroll", commonCls.inModalEvent[el], false); 2697Event.stopObserving(window,"resize",commonCls.inModalEvent[el],false); 2698commonCls.inModalEvent[el] = null; 2699}, 2700sendView: function(id, parameter, params, headermenu_flag) { 2701var top_el = $(id); 2702if(params == undefined) { 2703var params = new Object(); 2704} 2705params["focus_flag"] = 1; 2706if(typeof parameter == 'string') { 2707var re_action = new RegExp("^action=", 'i'); 2708if(parameter.match(re_action)) { 2709params["param"] = parameter; 2710} else { 2711params["param"] = {"action":parameter}; 2712} 2713} else { 2714params["param"] = parameter; 2715} 2716params["top_el"] = top_el; 2717var content = ""; 2718if(headermenu_flag != null && headermenu_flag != undefined) { 2719var headermenu = Element.getChildElementByClassName(top_el,"_headermenu"); 2720if(headermenu) { 2721var div_headermenu = document.createElement("DIV"); 2722div_headermenu.className = headermenu.className; 2723div_headermenu.innerHTML = headermenu.innerHTML; 2724params["headermenu"] = div_headermenu; 2725} 2726} 2727if(params["target_el"] === undefined) params["target_el"] = top_el.parentNode; 2728if(params["loading_el"] === undefined) params["loading_el"] = top_el; 2729commonCls.send(params); 2730}, 2731sendPost: function(id, parameter, post_params) { 2732var top_el = null; 2733if(id) { 2734top_el = $(id); 2735} 2736if(post_params == undefined) { 2737var post_params = new Object(); 2738} 2739if(typeof parameter == 'string') { 2740var re_action = new RegExp("^action=", 'i'); 2741if(parameter.match(re_action)) { 2742post_params["param"] = parameter; 2743} else { 2744post_params["param"] = {"action":parameter}; 2745} 2746} else { 2747post_params["param"] = parameter; 2748} 2749if(!post_params["method"]) post_params["method"] = "post"; 2750post_params["top_el"] = top_el; 2751if(post_params["loading_el"] === undefined) post_params["loading_el"] = top_el; 2752commonCls.send(post_params); 2753}, 2754sendRefresh: function(id, params) { 2755commonCls.sendView(id, commonCls.getUrl($(id)).parseQuery(), params); 2756}, 2757sendPopupView: function(event, parameter, params) { 2758if(params == undefined) { 2759var params = new Object(); 2760} 2761if(parameter != undefined && parameter != null) { 2762params["param"] = parameter; 2763} else { 2764parameter = params["param"]; 2765} 2766if(params['top_el'] != undefined || params['top_el'] != null) { 2767params['url'] = commonCls._paramEncode(params['param'], params['form_el']); 2768params = commonCls._setParam(params); 2769params['top_el_id'] = params['top_el'].id; 2770var id = commonCls._getId(params['url']); 2771} else if(parameter && parameter.tagName == undefined && typeof parameter == 'object') { 2772var param_str = ""; 2773for(key in parameter) {
2774if(param_str != "") { 2775param_str += "&"; 2776} 2777param_str += key + "=" + parameter[key]; 2778} 2779var id = commonCls._getId(param_str); 2780} else { 2781var id = commonCls._getId(parameter); 2782} 2783if(!commonCls.moduleList[id] || params['modal_flag'] == true) { 2784commonCls.moduleList[id] = "dummy"; 2785if(!params["loading_el"] && event) { 2786params["loading_el"] = Event.element(event); 2787} 2788params["create_flag"] = true; 2789if(event) { 2790params["event"] = event; 2791} 2792params["callbackfunc_error"] = function(res) {commonCls.alert(res);commonCls.moduleList[id]=null;}.bind(id); 2793commonCls.send(params); 2794} else if(commonCls.moduleList[id] == "dummy") { 2795} else { 2796var current_el = commonCls.moduleList[id]; 2797var top_el = params["top_el"] 2798if(params['center_flag']) { 2799var center_position = commonCls.getCenterPosition(current_el, top_el); 2800var x = center_position[0]; 2801var y = center_position[1]; 2802} else { 2803var x = (params['x'] != null && params['x'] != undefined) ? params['x'] : Event.pointerX(event); 2804var y = (params['y'] != null && params['y'] != undefined) ? params['y'] : Event.pointerY(event); 2805} 2806current_el.style.left = x + "px"; 2807current_el.style.top = y + "px"; 2808var move_pos = commonCls.moveAutoPosition(current_el); 2809if(move_pos != null) { 2810x = move_pos[0]; 2811y = move_pos[1]; 2812} 2813if(commonCls.moduleList[id].style.zIndex != commonCls.max_zIndex) { 2814commonCls.max_zIndex = commonCls.max_zIndex + 1; 2815current_el.style.zIndex = commonCls.max_zIndex; 2816} 2817} 2818}, 2819closeCallbackFunc: function(id, func) { 2820this.closeCallbackFuncEvent[id] = func; 2821}, 2822displayBlockChange: function(id) { 2823var block_el = $(id); 2824var content = Element.getChildElementByClassName(block_el,"content"); 2825commonCls.displayChange(content); 2826commonCls.moveVisibleHide(block_el); 2827}, 2828removeBlock: function(id) { 2829var block_el = $(id); 2830if (typeof id != 'string') { 2831id = id.id; 2832} 2833var block_el = $(id); 2834if(block_el.parentNode && block_el.parentNode.tagName.toLowerCase() == "body") { 2835return true; 2836} 2837Event.unloadCache(id); 2838if(id) { 2839var _global_modal_dialog = $("_global_modal_dialog" + id); 2840} 2841if(!_global_modal_dialog) { 2842_global_modal_dialog = $("_global_modal_dialog"); 2843} 2844if(_global_modal_dialog) { 2845Element.remove(_global_modal_dialog); 2846commonCls.stopModal(_global_modal_dialog); 2847} 2848var get_id = commonCls._getId(block_el); 2849delete commonCls.moduleList[get_id]; 2850commonCls.moduleList[get_id] = null; 2851commonCls.displayChange(block_el); 2852commonCls.moveVisibleHide(block_el); 2853var parent_el = block_el.parentNode; 2854Element.remove(block_el); 2855if(parent_el && parent_el.id == "_global_create_block") { 2856Element.remove(parent_el); 2857} 2858if(this.closeCallbackFuncEvent[id]) { 2859this.closeCallbackFuncEvent[id](); 2860delete this.closeCallbackFuncEvent[id]; 2861this.closeCallbackFuncEvent[id] = null; 2862} 2863}, 2864moveVisibleHide: function(el) { 2865el = (el && el.nodeType==1) ? el : this; 2866var offset = Position.cumulativeOffset(el); 2867var ex1 = offset[0]; 2868var ex2 = el.offsetWidth + ex1; 2869var ey1 = offset[1]; 2870var ey2 = el.offsetHeight + ey1; 2871var id_name = (el.id == "" || el.id == "_global_create_block") ? el.childNodes[0].id : el.id; 2872if(commonCls.hideElement[id_name] == null) 2873commonCls.hideElement[id_name] = Array(); 2874if(browser.isIE && browser.version < 7) { 2875var tags = new Array("applet", "iframe", "select", "object","embed"); 2876} else { 2877var tags = new Array("embed", "object"); 2878} 2879var tags_length = tags.length; 2880for (var k = tags_length; k > 0; ) { 2881var target_ar = document.getElementsByTagName(tags[--k]); 2882var target_ar_length = target_ar.length; 2883for (var i = target_ar_length; i > 0;) { 2884var target = target_ar[--i]; 2885offset = Position.cumulativeOffset(target); 2886var cx1 = offset[0]; 2887var cx2 = target.offsetWidth + cx1; 2888var cy1 = offset[1]; 2889var cy2 = target.offsetHeight + cy1; 2890if (((cx1 > ex2) || (cx2 < ex1) || (cy1 > ey2) || (cy2 < ey1))) { 2891if(Element.hasClassName(target,"visible-hide")) { 2892for (var key = 0,hide_el_length = commonCls.hideElement[id_name].length; key < hide_el_length; key++) { 2893var value = commonCls.hideElement[id_name][key]; 2894if(value) { 2895if(target == value) { 2896commonCls.hideElement[id_name][key] = null; 2897Element.removeClassName(target,"visible-hide"); 2898break; 2899} 2900} 2901} 2902} 2903} else { 2904var children = el.getElementsByTagName('*') || document.all; 2905var chk_flag = true; 2906var children_length = children.length; 2907for (var j = 0; j < children_length; j++) { 2908var child = children[j]; 2909if(child == target) { 2910chk_flag = false;
2911break; 2912} 2913} 2914if(chk_flag) { 2915if(!Element.hasClassName(target,"visible-hide")) { 2916commonCls.hideElement[id_name][commonCls.hideElement[id_name].length] = target; 2917Element.addClassName(target,"visible-hide"); 2918} 2919} else { 2920if(Element.hasClassName(target,"visible-hide")) { 2921Element.removeClassName(target,"visible-hide"); 2922for (var key = 0,hide_el_length = commonCls.hideElement[id_name].length; key < hide_el_length; key++) { 2923var value = commonCls.hideElement[id_name][key]; 2924if(value) { 2925if(target == value) 2926commonCls.hideElement[id_name][key] = null; 2927} 2928} 2929} 2930} 2931} 2932} 2933} 2934}, 2935winMoveDragStart: function(event) { 2936var page_id_name =this.id; 2937var id = commonCls._getId(this); 2938if(commonCls.inMoveDrag[id]) { 2939return false; 2940} 2941var this_el = commonCls.moduleList[id]; 2942if(this_el.style.zIndex != commonCls.max_zIndex) { 2943commonCls.max_zIndex = commonCls.max_zIndex + 1; 2944this_el.style.zIndex = commonCls.max_zIndex; 2945commonCls.moveVisibleHide(this_el); 2946} 2947commonCls.move_div[id] = this_el; 2948commonCls.start_x[id] = Event.pointerX(event); 2949commonCls.start_y[id] = Event.pointerY(event); 2950commonCls.show_x[id] = valueParseInt(commonCls.moduleList[id].style.left); 2951commonCls.show_y[id] = valueParseInt(commonCls.moduleList[id].style.top); 2952commonCls.pre_show_x[id] = valueParseInt(commonCls.moduleList[id].style.left); 2953commonCls.pre_show_y[id] = valueParseInt(commonCls.moduleList[id].style.top); 2954commonCls.winMoveDragGoEvent[id] = commonCls.winMoveDragGo.bindAsEventListener(this); 2955commonCls.winMoveDragStopEvent[id] = commonCls.winMoveDragStop.bindAsEventListener(this); 2956Event.observe(document,"mousemove",commonCls.winMoveDragGoEvent[id],true); 2957Event.observe(document,"mouseup",commonCls.winMoveDragStopEvent[id],true); 2958Event.stop(event); 2959commonCls.inMoveDrag[id] = true; 2960}, 2961winMoveDragGo: function(event) { 2962var page_id_name =this.id; 2963var id = commonCls._getId(this); 2964if(!commonCls.inMoveDrag[id]) { 2965return false; 2966} 2967var x = Event.pointerX(event); 2968var y = Event.pointerY(event); 2969var def_px = 5; 2970if(x <= commonCls.start_x[id] + def_px && x >= commonCls.start_x[id] - def_px && 2971y <= commonCls.start_y[id] + def_px && y >= commonCls.start_y[id] - def_px) { 2972return false; 2973} 2974var show_x = commonCls.show_x[id] - (commonCls.start_x[id] - x); 2975var show_y = commonCls.show_y[id] - (commonCls.start_y[id] - y); 2976if(show_x < 0) 2977show_x = 0; 2978if(show_y < 0) 2979show_y = 0; 2980commonCls.pre_show_x[id] = valueParseInt(commonCls.moduleList[id].style.left); 2981commonCls.pre_show_y[id] = valueParseInt(commonCls.moduleList[id].style.top); 2982commonCls.moduleList[id].style.left = show_x +"px"; 2983commonCls.moduleList[id].style.top = show_y +"px"; 2984commonCls.moveVisibleHide(commonCls.moduleList[id]); 2985Event.stop(event); 2986}, 2987winMoveDragStop: function(event) { 2988var page_id_name =this.id; 2989var id = commonCls._getId(this); 2990if(!commonCls.inMoveDrag[id]) { 2991commonCls.inMoveDrag[id] = false; 2992return false; 2993} 2994Event.stopObserving(document,"mousemove",commonCls.winMoveDragGoEvent[id],true); 2995Event.stopObserving(document,"mouseup",commonCls.winMoveDragStopEvent[id],true); 2996commonCls.winMoveDragGoEvent[id] = null; 2997commonCls.winMoveDragStopEvent[id] = null; 2998Event.stop(event); 2999commonCls.show_x[id] = valueParseInt(commonCls.moduleList[id].style.left); 3000commonCls.show_y[id] = valueParseInt(commonCls.moduleList[id].style.top); 3001var interval = 50; 3002commonCls.speedx[id] = (commonCls.show_x[id]-commonCls.pre_show_x[id]); 3003commonCls.speedy[id] = (commonCls.show_y[id]-commonCls.pre_show_y[id]); 3004if(commonCls.speedx[id] > 10) 3005commonCls.speedx[id] = 10; 3006else if(commonCls.speedx[id] < -10) 3007commonCls.speedx[id] = -10; 3008if(commonCls.speedy[id] > 10) 3009commonCls.speedy[id] = 10; 3010else if(commonCls.speedy[id] < -10) 3011commonCls.speedy[id] = -10; 3012setTimeout("commonCls.winMoveDragStopAfter(\""+ id +"\")", interval); 3013commonCls.inMoveDrag[id] = false; 3014}, 3015winMoveDragStopAfter: function(id) { 3016if(commonCls.speedx[id] > 0) 3017commonCls.speedx[id] = commonCls.speedx[id] - 1; 3018else if(commonCls.speedx[id] < 0) 3019commonCls.speedx[id] = commonCls.speedx[id] + 1; 3020if(commonCls.speedy[id] > 0) 3021commonCls.speedy[id] = commonCls.speedy[id] - 1; 3022else if(commonCls.speedy[id] < 0) 3023commonCls.speedy[id] = commonCls.speedy[id] + 1; 3024var show_x = valueParseInt(commonCls.move_div[id].style.left) + commonCls.speedx[id]; 3025var show_y = valueParseInt(commonCls.move_div[id].style.top) + commonCls.speedy[id]; 3026if(show_x < 0) 3027show_x = 0; 3028if(show_y < 0) 3029show_y = 0; 3030commonCls.move_div[id].style.left = show_x +"px"; 3031commonCls.move_div[id].style.top = show_y +"px"; 3032commonCls.show_x[id] = show_x; 3033commonCls.show_y[id] = show_y; 3034if(commonCls.speedx[id] != 0 || commonCls.speedy[id] != 0) { 3035var interval = 50; 3036setTimeout("commonCls.winMoveDragStopAfter(\""+ id +"\")", interval); 3037} 3038}, 3039blockNotice: function(event, el) { 3040if(typeof(Event.element) != 'undefined') { 3041var el = (el == undefined) ? Event.element(event) : el; 3042if(!Element.hasClassName(el,"highlight")) { 3043var rgbBack = commonCls.getRGBtoHex(Element.getStyle(el, "backgroundColor")); 3044if (rgbBack == "transparent") { 3045var parent_el = el; 3046while (rgbBack == "transparent") { 3047if(parent_el.tagName == "BODY") { 3048rgbBack = new Object(); 3049rgbBack.r = 255; 3050rgbBack.g = 255; 3051rgbBack.b = 255; 3052break; 3053} 3054var parent_el = parent_el.parentNode; 3055rgbBack = commonCls.getRGBtoHex(Element.getStyle(parent_el, "backgroundColor")); 3056} 3057} 3058Element.addClassName(el,"highlight"); 3059setTimeout(function(){ 3060commonCls.blockNoticeTimer(el, rgbBack); 3061}, 200); 3062} 3063} 3064}, 3065blockNoticeTimer: function(el,rgbBack) { 3066var offset = 10; 3067var rgb = commonCls.getRGBtoHex(Element.getStyle(el, "backgroundColor")); 3068if (rgb == "transparent") { 3069var parent_el = el; 3070while (rgb == "transparent") { 3071if(parent_el.tagName == "BODY") { 3072rgb = new Object(); 3073rgb.r = 255; 3074rgb.g = 255; 3075rgb.b = 255; 3076break; 3077} 3078var parent_el = parent_el.parentNode; 3079rgb = commonCls.getRGBtoHex(Element.getStyle(parent_el, "backgroundColor")); 3080} 3081} 3082if(rgb.r > rgbBack.r) rgb.r = (rgb.r - offset < rgbBack.r) ? rgbBack.r : rgb.r - offset; 3083else if(rgb.r < rgbBack.r) rgb.r = (rgb.r + offset > rgbBack.r) ? rgbBack.r : rgb.r + offset; 3084if(rgb.g > rgbBack.g) rgb.g = (rgb.g - offset < rgbBack.g) ? rgbBack.g : rgb.g - offset; 3085else if(rgb.g < rgbBack.g) rgb.g = (rgb.g + offset > rgbBack.g) ? rgbBack.g : rgb.g + offset; 3086if(rgb.b > rgbBack.b) rgb.b = (rgb.b - offset < rgbBack.b) ? rgbBack.b : rgb.b - offset; 3087else if(rgb.b < rgbBack.b) rgb.b = (rgb.b + offset > rgbBack.b) ? rgbBack.b : rgb.b + offset; 3088Element.setStyle(el, {"backgroundColor":commonCls.getHex(rgb.r,rgb.g,rgb.b)}); 3089if(rgb.r == rgbBack.r && rgb.g == rgbBack.g && rgb.b == rgbBack.b) { 3090if(Element.hasClassName(el,"highlight"))Element.removeClassName(el,"highlight"); 3091Element.setStyle(el, {"backgroundColor":""}); 3092} else { 3093setTimeout(function(){ 3094commonCls.blockNoticeTimer(el, rgbBack); 3095}, 200); 3096} 3097}, 3098getParams: function(top_el) { 3099var url = commonCls.getUrl(top_el); 3100if(url) { 3101var re_cut = new RegExp(".*\\?", "i"); 3102url = url.replace(re_cut,"").replace(/&/g,"&"); 3103var queryParams = url.parseQuery(); 3104return queryParams; 3105} else 3106return false;
3107}, 3108getUrl: function(top_el) { 3109if (typeof top_el == 'string') { 3110top_el = $(top_el); 3111} else if(top_el.tagName == "DIV" && Element.hasClassName(top_el,"cell")) { 3112top_el = Element.getChildElement(top_el); 3113} 3114var url_el = $("_url"+ top_el.id); 3115if(!url_el){url_el = Element.getChildElementByClassName(top_el,"_url");} 3116if(url_el) { 3117return url_el.value.replace(/&/g,"&"); 3118} else 3119return false; 3120}, 3121getBlockid: function(top_el) { 3122if(top_el.tagName == "DIV" && Element.hasClassName(top_el,"cell")) { 3123top_el = Element.getChildElement(top_el); 3124} 3125var id_name = top_el.id; 3126if(!id_name) { 3127return false; 3128} 3129return id_name.substr(1, id_name.length); 3130}, 3131setToken: function(id, token_value) { 3132var token_el = $(id); 3133if(token_el) token_el.value = token_value; 3134}, 3135getToken: function(top_el) { 3136if (typeof top_el == 'string') { 3137top_el = $(top_el); 3138} else if(top_el.tagName == "DIV" && Element.hasClassName(top_el,"cell")) { 3139top_el = Element.getChildElement(top_el); 3140} 3141var token_el = $("_token"+ top_el.id); 3142if(!token_el){token_el = Element.getChildElementByClassName(top_el,"_token");} 3143if(token_el) { 3144return token_el.value; 3145} else 3146return false; 3147}, 3148send: function(params_obj) { 3149if(params_obj['url'] == null || params_obj['url'] == undefined) { 3150params_obj['url'] = commonCls._paramEncode(params_obj['param'], params_obj['form_el']); 3151} 3152if(params_obj['url'] == "") { 3153var error_mes = "The parameter is illegal."; 3154if(callbackfunc_error){ 3155if(params_obj['func_error_param'] == undefined) {params_obj['callbackfunc_error'](error_mes);} 3156else{params_obj['callbackfunc_error'](params_obj['func_error_param'],error_mes);} 3157} else { 3158_debugShow(error_mes); 3159} 3160return false; 3161} 3162params_obj['method'] = (params_obj['method'] == undefined || params_obj['method'] == null) ? "get" : params_obj['method']; 3163params_obj['token'] = (params_obj['token'] == undefined || params_obj['token'] == null) ? "" : params_obj['token']; 3164params_obj['header_flag'] = (params_obj['header_flag'] == undefined || params_obj['header_flag'] == null) ? false : params_obj['header_flag']; 3165params_obj['create_flag'] = (params_obj['create_flag'] == undefined || params_obj['create_flag'] == null) ? false : params_obj['create_flag']; 3166params_obj['center_flag'] = (params_obj['center_flag'] == undefined || params_obj['center_flag'] == null) ? false : params_obj['center_flag']; 3167if(params_obj['create_flag'] && !params_obj['center_flag']) { 3168params_obj['x'] = (params_obj['x'] == undefined || params_obj['x'] == null) ? Event.pointerX(params_obj['event']) : params_obj['x']; 3169params_obj['y'] = (params_obj['y'] == undefined || params_obj['y'] == null) ? Event.pointerY(params_obj['event']) : params_obj['y']; 3170} 3171params_obj['show_main_flag'] = false; 3172if(!params_obj['create_flag'] && params_obj['center_flag']) { 3173params_obj['center_col'] = $("_centercolumn"); 3174if(params_obj['center_col']) { 3175params_obj['show_main_flag'] = true; 3176} 3177} 3178params_obj['eval_flag'] = (params_obj['eval_flag'] == undefined || params_obj['eval_flag'] == null) ? 1 : parseInt(params_obj['eval_flag']); 3179if(params_obj['top_el_id'] == undefined && (params_obj['top_el'] != undefined && params_obj['top_el'] != null)) { 3180params_obj = commonCls._setParam(params_obj); 3181} else { 3182params_obj['top_el_id'] = ""; 3183} 3184if(params_obj['token']) {params_obj['url'] = params_obj['url'] + "&_token=" + params_obj['token'];} 3185if(params_obj['header_flag']) {params_obj['url'] += "&_header=1";}else{ params_obj['url'] += "&_header=0";} 3186if(params_obj['show_main_flag']) {params_obj['url'] += "&_show_main_flag=1";} 3187if(params_obj['debug']) {commonCls._debugShow(params_obj['url']);} 3188params_obj['complete_flag'] = false; 3189new Ajax.Request(_nc_base_url + _nc_index_file_name , { 3190method: params_obj['method'], 3191noautoeval: true, 3192parameters: params_obj['url'], 3193requestHeaders: ["Referer",_nc_current_url], 3194onLoading: function() { 3195if(!this['complete_flag'] && (this['loading_el'] || (this['loading_x'] && this['loading_y']))) { 3196commonCls.showLoading(this['top_el_id'],this['url'],this['loading_x'],this['loading_y'],this['loading_el']); 3197} 3198}.bind(params_obj), 3199onComplete: function(transport) { 3200_nc_global_script_write_html = ''; 3201_nc_global_script_span = null; 3202this['complete_flag'] = true; 3203if(this['debug']) {commonCls._debugShow(transport.responseText);} 3204if(this['loading_el'] || (this['loading_x'] && this['loading_y'])){commonCls.hideLoading(this['top_el_id'],this['url']);} 3205if(this['target_el'] && this['top_el_id'] != "" && this['target_el'].id == this['top_el_id']) { 3206this['target_el'] = this['target_el'].parentNode; 3207} 3208var target_flag = false;
3209if(this['create_flag']) { 3210this['target_el'] = document.createElement("DIV"); 3211this['target_el'].id = "_global_create_block"; 3212target_flag = true; 3213} 3214if(_nc_debug) var res = commonCls.AjaxResultStr(transport.responseText); 3215else var res = transport.responseText; 3216if((this['match_str'] != null && this['match_str'] != undefined && commonCls.matchContentElement(res,this['match_str'])) || 3217((this['match_str'] == null || this['match_str'] == undefined) && !commonCls.matchErrorElement(res))) { 3218res = commonCls.cutErrorMes(res); 3219if(this['target_el'] || this['show_main_flag']) { 3220if(browser.isGecko && this['target_el']) { 3221var hidden_el = this['target_el']; 3222hidden_el.style.visibility = "hidden"; 3223} 3224if(!this['create_flag'] && this['center_flag']) { 3225if(this['center_col']) { 3226this['center_col'].innerHTML = "<div class='enlarged_display'>"+res+"</div>"; 3227} 3228} 3229if(!this['show_main_flag']) { 3230var div_write = document.createElement('div'); 3231div_write.innerHTML = res; 3232if(target_flag) { 3233if(this['modal_flag']) { 3234var div_parent = document.createElement("DIV"); 3235if(this['target_el']) { 3236var child_target_el = Element.getChildElement(div_write); 3237if(child_target_el.id) { 3238div_parent.id = "_global_modal_dialog" + child_target_el.id; 3239} 3240} 3241if(!div_parent.id) { 3242div_parent.id = "_global_modal_dialog"; 3243} 3244commonCls.showModal(null, div_parent, true); 3245document.body.appendChild(div_parent); 3246} 3247document.body.appendChild(this['target_el']); 3248} 3249_nc_dwScriptCount = 0; 3250_nc_dwScriptList = Array(); 3251var scriptList = div_write.getElementsByTagName("script"); 3252var addScriptList = Array(); 3253var addParentScriptList = Array(); 3254var count = 0; 3255for (var i = 0,scriptLen = scriptList.length; i < scriptLen; i++){ 3256if(!Element.hasClassName(scriptList[i], "nc_script")) { 3257_nc_dwScriptList[count] = scriptList[i]; 3258if((browser.isIE || browser.isSafari)) { 3259if((scriptList[i].src == undefined || scriptList[i].src == "")) { 3260addScriptList[count] = scriptList[i]; 3261} else { 3262var script_el = document.createElement('script'); 3263script_el.setAttribute('type', 'text/javascript'); 3264script_el.setAttribute('src', scriptList[i].src); 3265addScriptList[count] = script_el; 3266} 3267} else { 3268var script_el = document.createElement('script'); 3269script_el.id = "_nc_script"+ count; 3270script_el.type = "text/javascript"; 3271script_el.innerHTML = "_nc_dwScriptCount = " + count + "; Element.remove($(\"_nc_script"+ count +"\"));"; 3272addScriptList[count] = script_el; 3273} 3274addParentScriptList[count] = scriptList[count]; 3275count++; 3276} 3277} 3278if(div_el == undefined) var div_el = null; 3279_nc_ajaxFlag = true; 3280this['target_el'].innerHTML = ""; 3281if(this['target_el'] && Element.hasClassName(this['target_el'],"module_box")) { 3282Event.unloadCache(this['target_el']); 3283} 3284for (var i = 0, n = div_write.childNodes.length; i < n ; ++i) { 3285this['target_el'].appendChild(div_write.childNodes[i]); 3286n--; 3287i--; 3288} 3289for (var i = 0,scriptLen = addScriptList.length; i < scriptLen; i++){ 3290if((browser.isIE || browser.isSafari) && (addScriptList[i].src == undefined || addScriptList[i].src == "") && addScriptList[i].innerHTML != "") { 3291eval(addScriptList[i].innerHTML); 3292} else { 3293addParentScriptList[i].parentNode.insertBefore(addScriptList[i], addParentScriptList[i]); 3294} 3295} 3296_nc_ajaxFlag = false; 3297if(target_flag) { 3298this['target_el'] = Element.getChildElement(this['target_el']); 3299} 3300if(this['headermenu']) { 3301var content_el = Element.getChildElementByClassName(this['target_el'],"content"); 3302content_el.parentNode.insertBefore(this['headermenu'], content_el); 3303} 3304} 3305} 3306if(this['top_el_id'] && this['focus_flag']){ 3307var a_el = $("_href"+this['top_el_id']); 3308if(a_el) a_el.focus(); 3309} 3310if(this['eval_flag'] && (!this['target_el'] || browser.isIE || browser.isSafari || browser.isOpera)) { 3311if(browser.isSafari) { 3312setTimeout(function(){commonCls.AjaxResultScript(transport.responseText)}, 50); 3313} else { 3314commonCls.AjaxResultScript(transport.responseText); 3315} 3316} 3317if(this['create_flag'] && this['center_flag']) { 3318var center_position = commonCls.getCenterPosition(this['target_el'], this['top_el']); 3319this['x'] = center_position[0]; 3320this['y'] = center_position[1]; 3321} 3322if(this['create_flag']) { 3323var id_name = this['target_el'].id; 3324var id = commonCls._getId(this['target_el']); 3325if(id) { 3326commonCls.show_x[id] = this['x']; 3327commonCls.show_y[id] = this['y']; 3328} 3329this['target_el'].parentNode.style.left = commonCls.show_x[id] +"px"; 3330this['target_el'].parentNode.style.top = commonCls.show_y[id] +"px"; 3331var move_pos = commonCls.moveAutoPosition(this['target_el'].parentNode); 3332} 3333if(browser.isGecko && hidden_el) { 3334hidden_el.style.visibility = "visible"; 3335} 3336if(this['callbackfunc']){ 3337if (transport.getResponseHeader("Content-Type") == "text/xml" && transport.responseXML) { 3338res = transport.responseXML; 3339} 3340if(this['func_param'] == undefined) {this['callbackfunc'](res);} 3341else {this['callbackfunc'](this['func_param'],res);} 3342} 3343eval("document.write('');"); 3344return true; 3345} else { 3346res = commonCls.cutErrorMes(res); 3347if(res !== "") { 3348var re_html = new RegExp("^<!DOCTYPE html", 'i'); 3349if(!res.match(re_html)) { 3350var re_script = new RegExp('<script.*?>((.|\n|\r|\t)*?)<\/script>', 'ig'); 3351res = res.replace(re_script,""); 3352} 3353if(this['callbackfunc_error']){ 3354if(this['func_error_param'] == undefined) {this['callbackfunc_error'](res);} 3355else{this['callbackfunc_error'](this['func_error_param'],res);} 3356} else { 3357commonCls.alert(res); 3358} 3359if(this['eval_flag']) { 3360commonCls.AjaxResultScript(transport.responseText); 3361} 3362} 3363return false;
3364} 3365}.bind(params_obj) 3366}); 3367commonCls.setTimeoutAlert(); 3368}, 3369_setParam: function(params_obj) { 3370if (typeof params_obj['top_el'] == 'string') { 3371params_obj['top_el_id'] = params_obj['top_el']; 3372params_obj['top_el'] = $(params_obj['top_el']); 3373} else { 3374params_obj['top_el_id'] = params_obj['top_el'].id; 3375} 3376if(params_obj['token'] == "") { 3377var token_el = $("_token"+ params_obj['top_el_id']); 3378if(!token_el){token_el = Element.getChildElementByClassName(params_obj['top_el'],"_token");} 3379if(token_el){params_obj['token'] = token_el.value;} 3380} 3381var queryParams = commonCls.getParams(params_obj['top_el']); 3382if(queryParams) { 3383var page_id = queryParams["page_id"]; 3384var block_id = (queryParams["block_id"] == undefined) ? 0 : queryParams["block_id"]; 3385var module_id = queryParams["module_id"]; 3386var params_id = ""; 3387var queryParams = params_obj['url'].parseQuery(); 3388if(page_id && !queryParams['page_id'])params_id += "&page_id=" + page_id; 3389if(block_id && !queryParams['block_id'])params_id += "&block_id=" + block_id; 3390if(module_id && !queryParams['module_id'])params_id += "&module_id=" + module_id; 3391if(!queryParams['prefix_id_name']) { 3392if(block_id != 0) var suffix_id = block_id; 3393else var suffix_id = module_id; 3394if(suffix_id != undefined && suffix_id.length + 1 != params_obj['top_el_id'].length) { 3395var re_suffix_id = new RegExp("_"+suffix_id + "$", "i"); 3396var replace_str = params_obj['top_el_id'].replace(re_suffix_id,""); 3397if(replace_str == params_obj['top_el_id']) { 3398var re_suffix_id = new RegExp("_"+block_id + "$", "i"); 3399var replace_str = params_obj['top_el_id'].replace(re_suffix_id,""); 3400} 3401replace_str = replace_str.substr(1,replace_str.length - 1); 3402if(replace_str != "") { 3403params_id += "&prefix_id_name=" + replace_str; 3404} 3405} 3406} 3407params_obj['url'] = params_obj['url'] + params_id; 3408} 3409return params_obj; 3410}, 3411moveAutoPosition: function(target_el, move_pos_str) { 3412move_pos_str = (move_pos_str == undefined) ? "both" : move_pos_str; 3413var move_pos = new Array(); 3414var buf_left = valueParseInt(target_el.style.left); 3415var buf_top = valueParseInt(target_el.style.top); 3416if(!browser.isGecko || buf_left <= 0) move_pos[0] = target_el.offsetLeft; 3417else move_pos[0] = buf_left; 3418if(!browser.isGecko || buf_top <= 0) move_pos[1] = target_el.offsetTop; 3419else move_pos[1] = buf_top; 3420var move_pos_flag = false; 3421var popupX1 = move_pos[1] + target_el.offsetHeight; 3422var bodyX1 = Position.getWinOuterHeight() + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); 3423if(target_el.id == "_global_create_block") { 3424var popupX2 = move_pos[0] + Element.getChildElement(target_el).offsetWidth; 3425} else { 3426var popupX2 = move_pos[0] + target_el.offsetWidth; 3427} 3428var bodyX2 = Position.getWinOuterWidth() + (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft); 3429if ((move_pos_str == "both" || move_pos_str == "y") && popupX1 > bodyX1) { 3430move_pos[1] = move_pos[1] - (popupX1 - bodyX1); 3431if (move_pos[1] < 0) { 3432move_pos[1] = 0; 3433} 3434target_el.style.top = move_pos[1] +"px"; 3435move_pos_flag = true; 3436} 3437if ((move_pos_str == "both" || move_pos_str == "x") && popupX2 > bodyX2) { 3438move_pos[0] = move_pos[0] - (popupX2 - bodyX2); 3439if (move_pos[0] < 0) { 3440move_pos[0] = 0; 3441} 3442target_el.style.left = move_pos[0] +"px"; 3443move_pos_flag = true; 3444} 3445if(move_pos_flag) { 3446return move_pos; 3447} 3448return null; 3449}, 3450_debugShow: function(error_mes) { 3451if(typeof debug == 'object') {debug.p(error_mes);} else {commonCls.alert(error_mes);} 3452}, 3453getCenterPosition: function(target_el, position_el) { 3454Position.prepare(); 3455var offset_target = new Object(); 3456offset_target[0] = 0; 3457offset_target[1] = 0; 3458if(position_el == undefined) { 3459var w = Position.getWinOuterWidth() + Position.deltaX; 3460var h = Position.getWinOuterHeight() + Position.deltaY; 3461} else { 3462position_el = $(position_el); 3463var w = position_el.offsetWidth; 3464var h = position_el.offsetHeight; 3465offset_target = Position.cumulativeOffset(position_el); 3466} 3467var position = new Object(); 3468position[0] = ((w - target_el.offsetWidth) / 2) + offset_target[0]; 3469position[1] = ((h - target_el.offsetHeight) / 2) + offset_target[1]; 3470if(position[0] < 0) { 3471position[0] = 0; 3472} 3473if(position[1] < 0) { 3474position[1] = 0; 3475} 3476return position; 3477}, 3478_paramEncode: function(parameter, form_el) { 3479var return_param = ""; 3480if(parameter != undefined || parameter != null) { 3481if (typeof parameter == 'object') { 3482var queryComponents = new Array(); 3483for(var key in parameter) { 3484if (typeof parameter[key] == 'object' || typeof parameter[key] == 'array') { 3485queryComponents = createParam(parameter[key], encodeURIComponent(key),queryComponents); 3486} else { 3487var queryComponent = encodeURIComponent(key) + '=' + encodeURIComponent(parameter[key]); 3488if (queryComponent) { 3489queryComponents.push(queryComponent); 3490} 3491} 3492} 3493return_param = queryComponents.join('&'); 3494} else if(typeof parameter == 'string') { 3495parameter = parameter.unescapeHTML(); 3496var re_base_url = new RegExp("^" + _nc_base_url + _nc_index_file_name +"\\?", "i"); 3497return_param = parameter.replace(re_base_url,""); 3498if (!commonCls.matchContentElement(return_param,"action=")) { 3499return_param = "action=" + return_param; 3500} 3501} 3502} 3503if(form_el && form_el.tagName == "form") { 3504return_param = (return_param == "") ? Form.serialize(form_el) : return_param + "&" + Form.serialize(form_el); 3505} 3506function createParam(parameter, key_str,queryComponents) { 3507var ret_array = queryComponents; 3508for(var key in parameter) { 3509var key_sub_str= key_str + "["+key+"]"; 3510if (typeof parameter[key] == 'object' || typeof parameter == 'array') { 3511ret_array.push(createParam(parameter[key], key_sub_str,queryComponents)); 3512} else { 3513var str = typeof parameter[key]; 3514if (str == 'string') { 3515ret_array.push(key_sub_str + "=" + encodeURIComponent(parameter[key])); 3516} 3517} 3518} 3519return ret_array; 3520} 3521return return_param; 3522}, 3523AjaxResultStr: function(res) { 3524var re_log = new RegExp("<div class=\"logger_block\">(.|\n|\r|\t)*<\/div>", 'i'); 3525var logger_block = res.match(re_log); 3526if(logger_block) { 3527var count = 0; 3528for(var i = 0; i < logger_block.length; i++) { 3529if(logger_block[i].trim() != "") { 3530if(count == 0) { 3531var winlogger = window.open("", "", 3532"height=200,width=400,menubar=yes,scrollbars=yes,resizable=yes"); 3533winlogger.document.open("text/html", "replace"); 3534winlogger.document.write("<HTML>
3534<HEAD><link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\""+"http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_css&dir_name=/css/common.css&header=0"+"\" /></HEAD><BODY>"); 3535winlogger.document.write(logger_block[i].trim()); 3536} else { 3537winlogger.document.write(logger_block[i].trim()); 3538} 3539count++; 3540} 3541} 3542if(count != 0) { 3543var re_fatal = new RegExp(commonCls.fatal_error_mes, 'i'); 3544var fatal_mes = res.match(re_fatal); 3545if(fatal_mes) winlogger.document.write(fatal_mes[0].trim()); 3546winlogger.document.write("</BODY></HTML>"); 3547winlogger.document.close(); 3548winlogger.focus(); 3549} 3550res = res.replace(re_log,"").trim(); 3551} else { 3552var re_fatal = new RegExp(commonCls.fatal_error_mes, 'i'); 3553if(res.match(re_fatal)) { 3554var winlogger = window.open("", "", 3555"height=200,width=400,menubar=yes,scrollbars=yes,resizable=yes"); 3556winlogger.document.open("text/html", "replace"); 3557winlogger.document.write("<HTML><HEAD><link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\""+"http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_css&dir_name=/css/common.css&header=0"+"\" /></HEAD><BODY>"+res+"</BODY></HTML>"); 3558winlogger.document.close(); 3559winlogger.focus(); 3560res = commonCls.error_mes + res; 3561} 3562} 3563return res; 3564}, 3565AjaxResultScript: function(res) { 3566var re_script = new RegExp('<script class=\"nc_script\"[^>]*?>((.|\n|\r|\t)*?)<\/script>', 'ig'); 3567var re_common_global_array = res.match(re_script); 3568var re_common_global_array_eval = ""; 3569if(re_common_global_array) { 3570for(var common_global_counter = 0; common_global_counter < re_common_global_array.length; common_global_counter++) { 3571var re_common_global_array_eval = re_common_global_array[common_global_counter].replace(re_script,"$1"); 3572if(re_common_global_array_eval.trim() == "") { 3573} else { 3574eval(re_common_global_array_eval); 3575} 3576} 3577} 3578}, 3579parentWinInit: function(el,absolute_flag, chief_flag) { 3580var re_underbar = new RegExp('^_', 'i'); 3581var el = (el.id == null || el.id == "") ? Element.getChildElement(el) : el; 3582var module_id_name = el.id; 3583if(el && module_id_name && module_id_name.match(re_underbar)) { 3584var id = commonCls._getId(el); 3585if(absolute_flag) { 3586var parent_el = el.parentNode; 3587if(parent_el) { 3588parent_el.style.position = "absolute"; 3589if(parent_el.style.zIndex != commonCls.max_zIndex) { 3590commonCls.max_zIndex = commonCls.max_zIndex + 1; 3591parent_el.style.zIndex = commonCls.max_zIndex; 3592} 3593setTimeout(commonCls.moveVisibleHide.bind(el), 0); 3594commonCls.moduleList[id] = parent_el; 3595} 3596} 3597if(absolute_flag) { 3598var move_bar = Element.getChildElementByClassName(el,"_move_bar"); 3599commonCls.winMoveDragStartEvent[id] = commonCls.winMoveDragStart.bindAsEventListener(el); 3600Event.observe(move_bar,"mousedown",commonCls.winMoveDragStartEvent[id],false, el); 3601} else { 3602if(chief_flag) { 3603var _block_title = Element.getChildElementByClassName(el,"nc_block_title"); 3604var _block_title_event = Element.getChildElementByClassName(el,"_block_title_event"); 3605if(_block_title && Element.hasClassName(el,"module_grouping_box")) { 3606var buf_module_box_el = Element.getParentElementByClassName(_block_title,"module_box"); 3607if(buf_module_box_el.id != el.id) _block_title = null; 3608} 3609if(_block_title_event && Element.hasClassName(el,"module_grouping_box")) { 3610var buf_module_box_el = Element.getParentElementByClassName(_block_title_event,"module_box"); 3611if(buf_module_box_el.id != el.id) _block_title_event = null; 3612} 3613if(!_block_title_event) _block_title_event = _block_title; 3614if(_block_title_event) { 3615Event.observe(_block_title, "mouseover", commonCls.blockNotice, false, el); 3616Event.observe(_block_title_event,"dblclick",pagesCls.blockChangeName.bindAsEventListener(_block_title),false, el); 3617} 3618var theme_header_flag = true; 3619var theme_top_el = $("_theme_top" + el.id); 3620if(theme_top_el) { 3621var move_bar = Element.getChildElementByClassName(theme_top_el,"_move_bar"); 3622if(move_bar) { 3623theme_header_flag = false; 3624pagesCls.winMoveDragStartEvent[el.id] = pagesCls.winMoveDragStart.bindAsEventListener(el); 3625Event.observe(move_bar,"mousedown",pagesCls.winMoveDragStartEvent[el.id],false, el); 3626pagesCls.winGroupingEvent[el.id] = pagesCls.onGroupingEvent.bindAsEventListener(el); 3627Event.observe(move_bar,"click",pagesCls.winGroupingEvent[el.id],false, el); 3628} 3629} 3630if(theme_header_flag && _nc_layoutmode == "on") { 3631setTimeout(function() { 3632pagesCls.winMoveResizeHeader(); 3633}.bind(this), 200); 3634Event.observe(el,"mouseover",pagesCls.winMoveShowHeader.bindAsEventListener(el),false, el); 3635Event.observe(el,"mouseout",pagesCls.winMoveHideHeader.bindAsEventListener(el),false, el); 3636} 3637} 3638} 3639} 3640}, 3641matchErrorElement: function(str) { 3642var match_table = new RegExp("^(?:" + this.error_mes + "|<!DOCTYPE html){1}.+", "i"); 3643if (typeof str == 'string' && str.match(match_table)) { 3644return true; 3645} 3646return false;
3647}, 3648matchContentElement: function(str,match_str) { 3649if (match_str == "") { 3650if(str == "") { 3651return true; 3652} else { 3653return false; 3654} 3655} else { 3656var match_div = new RegExp(match_str, "i"); 3657if (str.match(match_div)) { 3658return true; 3659} else { 3660return false; 3661} 3662} 3663}, 3664cutParamByUrl: function(url) { 3665var re_cut = new RegExp(".*\\?", "i"); 3666url = "?" + url.replace(re_cut,""); 3667return url; 3668}, 3669_getId: function(top_el,name) { 3670var key = (name == undefined || name == null) ? "" : "?" + name ; 3671if (typeof top_el == 'string'){ 3672var queryParams = commonCls.cutParamByUrl(top_el).parseQuery(); 3673} else { 3674var queryParams = commonCls.getParams(top_el); 3675} 3676if(queryParams["block_id"] != null && queryParams["block_id"] != 0) { 3677key += "&block_id=" + queryParams["block_id"]; 3678} 3679if(queryParams["page_id"] != null && queryParams["page_id"] != 0) { 3680key += "&page_id=" + queryParams["page_id"]; 3681} 3682if((queryParams["block_id"] == null || queryParams["block_id"] == 0) && queryParams["action"] != "") { 3683key += "&dir_name=" + queryParams["action"].split("_")[0] 3684} 3685var prefix_id_name = queryParams["prefix_id_name"]; 3686if(prefix_id_name != null) { 3687key += "&prefix_id_name=" + prefix_id_name; 3688} 3689return key; 3690}, 3691alert: function(str) { 3692if(typeof str != 'string') return ""; 3693var re_html = new RegExp("^<!DOCTYPE html", 'i'); 3694if(str.match(re_html)) { 3695document._write(str); 3696} else { 3697str = commonCls.cutErrorMes(str); 3698str = str.unescapeHTML();
3699str = str.replace(/\\n/ig,"\n"); 3700str = str.replace(/(<br(?:.|\s|\/)*?>)/ig,"\n"); 3701if(str != "") { 3702alert(str); 3703} 3704} 3705}, 3706confirm: function(str) { 3707if(typeof str != 'string') return ""; 3708var re_html = new RegExp("^<!DOCTYPE html", 'i'); 3709if(str.match(re_html)) { 3710document.write(str); 3711} else { 3712str = str.unescapeHTML(); 3713str = str.replace(/\\n/ig,"\n"); 3714str = str.replace(/(<br(?:.|\s|\/)*?>)/ig,"\n"); 3715return confirm(str); 3716} 3717}, 3718cutErrorMes: function(str) { 3719if(typeof str != 'string') return ""; 3720var re_error = new RegExp("^" + this.error_mes, 'i'); 3721if(str.match(re_error)) { 3722str = str.substr(this.error_mes.length,str.length); 3723} 3724return str; 3725}, 3726displayChange: function(el) { 3727el = $(el); 3728var elestyle = el.style; 3729if (elestyle.display == "none" || Element.hasClassName(el,"display-none")) { 3730this.displayVisible(el); 3731} else { 3732this.displayNone(el); 3733} 3734}, 3735displayNone: function(el) { 3736var elestyle = el.style; 3737if (elestyle.display) { 3738elestyle.display = "none"; 3739} 3740Element.addClassName(el,"display-none"); 3741}, 3742displayVisible: function(el) { 3743var elestyle = el.style; 3744var display = ""; 3745if (el.tagName == "TR") display = ""; 3746else if (el.tagName == "TD") display = ""; 3747else if (el.tagName == "TABLE") display = ""; 3748elestyle.display = display; 3749if(Element.hasClassName(el,"display-none")) { 3750Element.removeClassName(el,"display-none"); 3751} 3752try { 3753if (!(browser.isIE || browser.isOpera || browser.isSafari)) { 3754var iframeList = el.getElementsByTagName("iframe"); 3755for (var i = 0; i < iframeList.length; i++){ 3756if(iframeList[i].contentWindow.document.designMode == "on") { 3757iframeList[i].contentWindow.document.designMode = "off"; 3758iframeList[i].contentWindow.document.designMode = "on"; 3759} 3760} 3761} 3762}catch(e){} 3763}, 3764visibilityChange: function(el) { 3765el = $(el); 3766if(Element.hasClassName(el,"visible-hide")) { 3767commonCls.visibilityVisible(el); 3768} else { 3769commonCls.visibilityNone(el); 3770} 3771}, 3772visibilityNone: function(el) { 3773Element.addClassName(el,"visible-hide"); 3774}, 3775visibilityVisible: function(el) { 3776if(Element.hasClassName(el,"visible-hide")) { 3777Element.removeClassName(el,"visible-hide"); 3778} else { 3779el.style.visibility = "visible"; 3780} 3781}, 3782cellIndex: function(element) { 3783if(browser.isSafari) { 3784for (var i = 0; i < element.parentNode.childNodes.length; i++) { 3785if(element.parentNode.childNodes[i] == element) { 3786return i; 3787} 3788} 3789} else { 3790return element.cellIndex; 3791} 3792return 0; 3793}, 3794showPopupImageFullScale: function(this_el) { 3795if($("_fullscall_image")) { 3796return; 3797} 3798var img_el = Element.getChildElement(this_el); 3799var div_el = document.createElement("DIV"); 3800Element.setStyle(div_el, {opacity:0.7}); 3801div_el.id = "_global_full_scale"; 3802div_el.style.backgroundColor = "#666666"; 3803document.body.appendChild(div_el); 3804commonCls.showModal(null, div_el); 3805var new_img_el = document.createElement("IMG"); 3806commonCls.max_zIndex = commonCls.max_zIndex + 1; 3807new_img_el.style.zIndex = commonCls.max_zIndex; 3808new_img_el.style.position = "absolute"; 3809new_img_el.src = img_el.src; 3810new_img_el.style.visibility = "hidden"; 3811new_img_el.id = "_fullscall_image"; 3812document.body.appendChild(new_img_el); 3813var center_position = commonCls.getCenterPosition(new_img_el, img_el); 3814new_img_el.style.left = center_position[0] + "px"; 3815new_img_el.style.top = center_position[1] + "px"; 3816new_img_el.style.visibility = "visible"; 3817commonCls.moveVisibleHide(div_el); 3818div_el.onmousedown = function() { 3819commonCls.displayChange(div_el); 3820commonCls.moveVisibleHide(div_el); 3821Element.remove(div_el); 3822Element.remove(new_img_el); 3823} 3824new_img_el.onmousedown = function() { 3825commonCls.displayChange(div_el); 3826commonCls.moveVisibleHide(div_el); 3827Element.remove(div_el); 3828Element.remove(new_img_el); 3829} 3830}, 3831addCommonLink: function (dir_name, media, document_object){ 3832document_object = (document_object == undefined || document_object == null) ? document : document_object; 3833var nLink = null; 3834var new_dir_name_arr = new Array(); 3835var del_dir_name_arr = new Array(); 3836var common_css_flag = false; 3837for(var i=0; (nLink = document_object.getElementsByTagName("LINK")[i]); i++) { 3838if(Element.hasClassName(nLink, "_common_css")) { 3839common_css_flag = true; 3840var queryParams = nLink.href.unescapeHTML().parseQuery(); 3841var dir_name_arr = queryParams["dir_name"].split("|"); 3842var current_dir_name_arr = dir_name.split("|"); 3843for (var j = 0; j < current_dir_name_arr.length; j++){ 3844var pos = dir_name_arr.indexOf(current_dir_name_arr[j]); 3845if(pos == -1) { 3846var new_pos = new_dir_name_arr.indexOf(current_dir_name_arr[j]); 3847if(new_pos != -1) break; 3848new_dir_name_arr[new_dir_name_arr.length] = current_dir_name_arr[j]; 3849} else { 3850del_dir_name_arr[del_dir_name_arr.length] = current_dir_name_arr[j]; 3851} 3852} 3853} 3854} 3855del_dir_name_arr.each(function(del_value) { 3856new_dir_name_arr = new_dir_name_arr.without(del_value); 3857}.bind(this)); 3858var new_dir_name = new_dir_name_arr.join("|"); 3859if(new_dir_name == "") { 3860if(common_css_flag) { 3861return true; 3862} else { 3863new_dir_name = dir_name 3864} 3865} 3866var css_name = "http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_css&dir_name="+new_dir_name+"&header=0"; 3867return commonCls._addLink(css_name, media, document_object, "_common_css"); 3868}, 3869addLink: function (css_name, media, document_object){ 3870document_object = (document_object == undefined || document_object == null) ? document : document_object; 3871var nLink = null; 3872for(var i=0; (nLink = document_object.getElementsByTagName("LINK")[i]); i++) { 3873if(nLink.href == css_name) { 3874return true; 3875} 3876} 3877return commonCls._addLink(css_name, media, document_object); 3878}, 3879_addLink: function (css_name, media, document_object, class_name){ 3880if(typeof document_object.createStyleSheet != 'undefined') { 3881document_object.createStyleSheet(css_name.unescapeHTML()); 3882var oLinks = document_object.getElementsByTagName('LINK'); 3883var nLink = oLinks[oLinks.length-1]; 3884} else if(document_object.styleSheets){ 3885var nLink=document_object.createElement('LINK'); 3886nLink.rel="stylesheet"; 3887nLink.type="text/css"; 3888nLink.media= (media ? media : "screen"); 3889nLink.href=css_name.unescapeHTML(); 3890var oHEAD=document_object.getElementsByTagName('HEAD').item(0); 3891oHEAD.appendChild(nLink); 3892} 3893if(class_name != undefined) { 3894Element.addClassName(nLink, class_name); 3895} 3896return true; 3897}, 3898scriptDocWrite: function (src_name, document_object){ 3899document_object = (document_object == undefined || document_object == null) ? document : document_object; 3900var nScript = null; 3901for(var i=0; (nScript = document_object.getElementsByTagName("SCRIPT")[i]); i++) { 3902if(nScript.src != "" && nScript.src == src_name) { 3903return; 3904} 3905} 3906document_object.open();
3907document_object.write('<script type="text/javascript" src= "' + src_name + '"></script>'); 3908document_object.close(); 3909}, 3910addScript: function (src_name, document_object){ 3911document_object = (document_object == undefined || document_object == null) ? document : document_object; 3912var nScript = null; 3913for(var i=0; (nScript = document_object.getElementsByTagName("SCRIPT")[i]); i++) { 3914if(nScript.src != "" && nScript.src == src_name) { 3915return true; 3916} 3917} 3918var nScript=document_object.createElement('SCRIPT'); 3919nScript.type="text/javascript"; 3920nScript.src=src_name; 3921var oHEAD=document_object.getElementsByTagName('HEAD').item(0); 3922oHEAD.appendChild(nScript); 3923return true; 3924}, 3925frmTransValue: function (frm, efrom, eto){ 3926var ef = frm.elements[efrom]; 3927var et = frm.elements[eto]; 3928while (ef.selectedIndex != -1) { 3929if(!ef.disabled) { 3930et.length = et.length + 1; 3931et.options[et.length - 1].value = ef.options[ef.selectedIndex].value; 3932et.options[et.length - 1].text = ef.options[ef.selectedIndex].text; 3933ef.options[ef.selectedIndex] = null; 3934} 3935} 3936}, 3937frmMoveListBox: function(frm, e, move) { 3938var selectindx = frm.elements[e].selectedIndex; 3939if (selectindx != -1){ 3940if (move == 1) { 3941for( i = 0; i < frm.elements[e].length; i++ ){ 3942if( frm.elements[e].options[i].selected ){ 3943if( i <= 0 ) { 3944continue; 3945} 3946var optText = frm.elements[e].options[i].text; 3947var optValue = frm.elements[e].options[i].value; 3948frm.elements[e].options[i].text = frm.elements[e].options[i-1].text; 3949frm.elements[e].options[i].value = frm.elements[e].options[i-1].value; 3950frm.elements[e].options[i-1].text = optText; 3951frm.elements[e].options[i-1].value = optValue; 3952frm.elements[e].options[i-1].selected=true; 3953frm.elements[e].options[i].selected=false; 3954} 3955} 3956} else if (move > 1) { 3957var j=0; 3958for( i = 0; i < frm.elements[e].length; i++ ){ 3959if( frm.elements[e].options[i].selected ){ 3960if( i <= 0 ) { 3961continue; 3962} 3963var optText = frm.elements[e].options[i].text; 3964var optValue = frm.elements[e].options[i].value; 3965var eleOption = document.createElement("option"); 3966eleOption.value = optValue; 3967eleOption.text = optText; 3968frm.elements[e].options[i] = null; 3969commonCls.frmAddOption(frm.elements[e], eleOption, j); 3970frm.elements[e].options[j].selected=true; 3971j++; 3972} 3973} 3974} else if (move == -1) { 3975for( i = frm.elements[e].length-1; i >= 0; i-- ){ 3976if( frm.elements[e].options[i].selected ){ 3977if( i >= frm.elements[e].length-1 ) { 3978continue; 3979} 3980var optText = frm.elements[e].options[i].text; 3981var optValue = frm.elements[e].options[i].value; 3982frm.elements[e].options[i].text = frm.elements[e].options[i+1].text; 3983frm.elements[e].options[i].value = frm.elements[e].options[i+1].value; 3984frm.elements[e].options[i+1].text = optText; 3985frm.elements[e].options[i+1].value = optValue; 3986frm.elements[e].options[i+1].selected=true; 3987frm.elements[e].options[i].selected=false; 3988} 3989} 3990} else if (move < -1) { 3991var j=frm.elements[e].length - 1; 3992for( i = frm.elements[e].length-1; i >= 0; i-- ){ 3993if( frm.elements[e].options[i].selected ){ 3994if( i >= frm.elements[e].length-1 ) { 3995continue; 3996} 3997var optText = frm.elements[e].options[i].text; 3998var optValue = frm.elements[e].options[i].value; 3999var eleOption = document.createElement("option"); 4000eleOption.value = optValue; 4001eleOption.text = optText; 4002frm.elements[e].options[i] = null; 4003commonCls.frmAddOption(frm.elements[e], eleOption, j); 4004frm.elements[e].options[j].selected=true; 4005j--; 4006} 4007} 4008} 4009} 4010}, 4011frmAddOption: function(eleSelect, eleOption, index) { 4012if (browser.isNS){ 4013eleSelect.insertBefore(eleOption, eleSelect.options[index]); 4014}else{ 4015eleSelect.options.add( eleOption, index ); 4016} 4017}, 4018frmAllReleaseList: function(frm, e) { 4019frm.elements[e].selectedIndex = -1; 4020}, 4021frmAllSelectList: function(frm, e, disabled_flag) { 4022if ( frm.elements[e] == undefined ) { 4023}else{ 4024var n = frm.elements[e].length; 4025for (var i = 0; i < n ; i++) { 4026if((disabled_flag == undefined || disabled_flag == false) || !frm.elements[e].options[i].disabled) { 4027frm.elements[e].options[i].selected = true; 4028} 4029} 4030} 4031}, 4032frmAllSelectRadio: function(frm, value, callback_checked_func) { 4033for ( i=0; i < frm.elements.length; i++ ){ 4034if ( frm.elements[i].type == 'radio' ){ 4035if(frm.elements[i].value == value && !frm.elements[i].disabled) { 4036if(callback_checked_func == undefined) { 4037frm.elements[i].checked = true; 4038} else { 4039callback_checked_func(frm.elements[i]); 4040} 4041} 4042} 4043} 4044}, 4045frmAllChecked: function(frm, e, value) { 4046if ( frm.elements[e] == undefined ) { 4047frm.elements[e].checked = value; 4048}else{ 4049var n = frm.elements[e].length; 4050if ( n == undefined ) { 4051frm.elements[e].checked = value; 4052} else { 4053for (var i = 0; i < n ; i++) { 4054frm.elements[e][i].checked = value; 4055} 4056} 4057} 4058}, 4059setLineBreak: function(str, number_char) { 4060if(number_char == undefined) number_char = 30; 4061var reg_exp_obj = new RegExp("((?:.|\s){" + number_char + "})", "g"); 4062return str.replace(reg_exp_obj, "$1<br />"); 4063}, 4064print: function(el, width, height, header_flag, window_name) { 4065width = (width == undefined) ? 600 : width; 4066height = (height == undefined) ? 600 : height; 4067header_flag = (header_flag == undefined) ? true : header_flag; 4068window_name = (window_name == undefined) ? commonLang.printTitle : window_name; 4069if(header_flag) { 4070var html = "<div class=\"print_header\"><a class=\"print_btn link\" href=\"javascript:window.close();\">"+commonLang.close+"</a>"+ 4071commonLang.separator+"<a class=\"print_btn link\" href=\"javascript:window.print();\">"+commonLang.print+"</a></div>"; 4072} else { 4073var html = ""; 4074} 4075var print_script = ""; 4076var disabled_script = "window.opener.commonCls.disableLink(document.body, \"print_btn\", true);"; 4077if(typeof el == 'string') { 4078html += "<div class=\"outerdiv\">"; 4079html += el; 4080} else { 4081if(!el.id) { 4082var print_id = "_global_print_el"; 4083el.id = print_id; 4084} else { 4085var print_id = el.id; 4086} 4087html += "<div id=\""+ el.id +"\" class=\"outerdiv"+ el.className +"\">"; 4088if(!browser.isGecko) { 4089html += el.innerHTML; 4090} else { 4091var append_el = el.cloneNode(true); 4092print_script = "document.getElementById('"+print_id+"').appendChild(print_el);"+disabled_script; 4093} 4094} 4095html += "</div>"; 4096if(print_script == "") { 4097html += "<script>"+disabled_script+"</script>"; 4098} 4099html += "<script src=\""+"http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_js&header=0"+"\"></script>"; 4100var features="location=no, menubar=no, status=yes, scrollbars=yes, resizable=yes, toolbar=no"; 4101if (width) { 4102if (window.screen.width > width)
4103features+=", left="+(window.screen.width-width)/2; 4104else width=window.screen.width; 4105features += ", width="+width; 4106} 4107if (height) { 4108if (window.screen.height > height) 4109features+=", top="+(window.screen.height-height)/2; 4110else height=window.screen.height; 4111features+=", height="+height; 4112} 4113var head = document.getElementsByTagName("head")[0]; 4114var links = head.getElementsByTagName("link"); 4115var linkText = "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\""+"http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_css&dir_name=/css/print.css&header=0"+"\" />"; 4116linkText += "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\""+"http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_css&dir_name=/css/print_preview.css&header=0"+"\" />"; 4117for (var i = 0; i < links.length; i++) { 4118var link = links[i]; 4119if (link.getAttribute("type") == "text/css") { 4120linkText += "<link "; 4121linkText += "rel=\"" + link.getAttribute("rel") + "\" "; 4122linkText += "type=\"" + link.getAttribute("type") + "\" "; 4123linkText += "media=\"" + link.getAttribute("media") + "\" "; 4124linkText += "href=\"" + link.getAttribute("href") + "\" "; 4125linkText += "/>
4125\n"; 4126} 4127} 4128var scriptText = "<script>function Init() {setTimeout(function(){"+print_script+" print();}, 500);}</script>"; 4129var winprint = window.open("", "PrintPreview", features); 4130if(append_el != undefined) { 4131winprint.print_el = append_el; 4132} 4133winprint.document.open("text/html"); 4134winprint.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><title>" + window_name + "</title><style> html,body {background-image : none !important; padding:0px !important; margin:0px !important;}</style>" + linkText + "</head>"+scriptText+"<body class=\"print_preview\" onload=\"Init();\">"+html+"</body></html>"); 4135winprint.document.close(); 4136}, 4137disableLink: function(el, enable_class, parent_flag) { 4138el = $(el); 4139var hasClassName = (parent_flag == undefined) ? function(el, class_name) {return commonCls.hasClassName(el, class_name);}.bind(this) : function(el, class_name) {return window.parent.commonCls.hasClassName(el, class_name);}.bind(this); 4140var aList = el.getElementsByTagName("A"); 4141for (var i = 0,aLen = aList.length; i < aLen; i++) { 4142if(enable_class != undefined && !hasClassName(aList[i], enable_class)) { 4143aList[i].onclick = function(){return false;}; 4144} 4145} 4146var inputList = el.getElementsByTagName("INPUT"); 4147for (var i = 0,inputLen = inputList.length; i < inputLen; i++) { 4148if(enable_class != undefined && !hasClassName(inputList[i], enable_class) && 4149inputList[i].type.toLowerCase() == "button") { 4150inputList[i].onclick = function(){return false;}; 4151} 4152} 4153}, 4154observeTooltip: function(observe_el, top_id, show_mes, show_second) { 4155if (top_id == 'string') { 4156var top_el = $(top_id); 4157} else { 4158var top_el = top_id; 4159top_id = top_id.id; 4160} 4161commonCls.inToolTipEvent["mouseover"+top_id] = function(event) { 4162commonCls.showTooltip(event, show_mes, show_second); 4163}.bindAsEventListener(this); 4164commonCls.inToolTipEvent["mouseout"+top_id] = function(event) { 4165commonCls.closeTooltip(event); 4166}.bindAsEventListener(this); 4167Event.observe(observe_el, "mouseover", commonCls.inToolTipEvent["mouseover"+top_id],false, top_el); 4168Event.observe(observe_el, "mouseout", commonCls.inToolTipEvent["mouseout"+top_id], false, top_el); 4169}, 4170showTooltip: function(event, show_mes, show_second) { 4171if(this.toolTipPopup == null) { 4172this.toolTipPopup = new compPopup(null, "popupTooltip"); 4173this.toolTipPopup.observing = false; 4174this.toolTipPopup.modal = false; 4175this.toolTipPopup.setTitle('Tooltip'); 4176this.toolTipPopup.loadObserver = function() { 4177var popupY2 = this.popupElement.offsetTop + this.popupElement.offsetHeight; 4178var bodyY2 = Position.getWinOuterHeight() + document.documentElement.scrollTop; 4179if (popupY2 > bodyY2) { 4180var new_position = new Array(); 4181new_position[0] = this.popupElement.offsetLeft; 4182if (new_position[0] < 0) { 4183new_position[0] = 0; 4184} 4185new_position[1] = this.popupElement.offsetTop - (popupY2 - bodyY2); 4186this.setPosition(new_position); 4187} 4188}.bind(this.toolTipPopup); 4189} 4190if(this.toolTipPopup.isVisible()) return; 4191var observe_el = Event.element(event); 4192if(show_second == undefined) show_second = 5000; 4193var div = document.createElement("DIV"); 4194Element.addClassName(div, "tooltipClass"); 4195div.innerHTML = show_mes; 4196var offset = 20; 4197var position = new Object; 4198position[0] = Event.pointerX(event); 4199position[1] = Event.pointerY(event) + offset; 4200this.toolTipPopup.setPosition(position); 4201this.toolTipPopup.showPopup(div); 4202if(this.toolTipPopupTimer != null) { 4203clearTimeout(this.toolTipPopupTimer); 4204this.toolTipPopupTimer = null; 4205} 4206this.toolTipPopupTimer = setTimeout(function(){this.closeTooltip(event)}.bind(this), show_second); 4207}, 4208closeTooltip: function(event) { 4209if(this.toolTipPopup == null || !this.toolTipPopup.isVisible()) return; 4210this.toolTipPopup.closePopup(); 4211}, 4212showUserDetail: function(event, user_id) { 4213if(_nc_user_id == "0") return; 4214user_id = (user_id == undefined) ? 0 : user_id; 4215var param_popup = new Object(); 4216var user_params = new Object(); 4217param_popup = { 4218"action":"userinf_view_main_init", 4219"prefix_id_name":"popup_userinf"+user_id, 4220"user_id":user_id, 4221"theme_name": "system" 4222}; 4223user_params['callbackfunc_error'] = function(res){}; 4224commonCls.sendPopupView(event, param_popup, user_params); 4225}, 4226sendAttachment: function(params_obj) { 4227if (typeof params_obj['top_el'] == 'string') { 4228var id = params_obj['top_el']; 4229var top_el = $(params_obj['top_el']); 4230} else { 4231var id = params_obj['top_el'].id; 4232var top_el = params_obj['top_el']; 4233} 4234var match_str = params_obj['match_str']; 4235var form_prefix = (params_obj['form_prefix'] != undefined && params_obj['form_prefix'] != null) ? params_obj['form_prefix'] : "attachment_form"; 4236var form_target = form_prefix + id; 4237var download_action = (params_obj['download_action'] != undefined && params_obj['download_action'] != null) ? params_obj['download_action'] : "common_download_main"; 4238var header_flag = (params_obj['header_flag'] != undefined && params_obj['header_flag'] != null) ? params_obj['header_flag'] : 0; 4239var callbackfunc = (params_obj['callbackfunc'] != undefined && params_obj['callbackfunc'] != null) ? params_obj['callbackfunc'] : null; 4240var callbackfunc_error = (params_obj['callbackfunc_error'] != undefined && params_obj['callbackfunc_error'] != null) ? params_obj['callbackfunc_error'] : null; 4241var target_el = (params_obj['target_el'] != undefined && params_obj['target_el'] != null) ? params_obj['target_el'] : null; 4242var debug_param = (params_obj['debug'] != undefined && params_obj['debug'] != null) ? params_obj['debug'] : 0; 4243var timeout_flag = (params_obj['timeout_flag'] != undefined && params_obj['timeout_flag'] != null) ? params_obj['timeout_flag'] : 1; 4244if(debug_param) {debug_param = 1;} 4245if(commonCls.inAttachment[form_target] != null) { 4246return; 4247} 4248commonCls.inAttachment[form_target] = true; 4249if (params_obj['document_obj']) { 4250var document_object = params_obj['document_obj']; 4251var formList = document_object.getElementsByTagName("form"); 4252} else { 4253var document_object = document; 4254var formList = top_el.getElementsByTagName("form"); 4255} 4256for (var i = 0; i < formList.length; i++){ 4257if(formList[i].target == form_target) { 4258if(params_obj['param'] != undefined || params_obj['param'] != null) { 4259var action_flag = false;
4260var name_arr = new Array(); 4261var value_arr = new Object(); 4262var count = 0; 4263for(var key in params_obj['param']){ 4264if(key == "action") { 4265action_flag = true; 4266} 4267name_arr[count] = key; 4268value_arr[key] = encodeURIComponent(params_obj['param'][key]); 4269count++; 4270} 4271if(!action_flag) { 4272return false; 4273} 4274var token_el = Element.getChildElementByClassName(top_el, "_token"); 4275var queryParams = commonCls.getParams(top_el); 4276var block_id = (queryParams["block_id"] == undefined) ? 0 : queryParams["block_id"]; 4277var page_id = queryParams["page_id"]; 4278var module_id = queryParams["module_id"]; 4279name_arr[count++] = "download_action_name"; 4280value_arr['download_action_name'] = download_action; 4281name_arr[count++] = "_attachment_callback"; 4282value_arr['_attachment_callback'] = "tmp_" + form_target; 4283name_arr[count++] = "_header"; 4284value_arr['_header'] = header_flag; 4285if(token_el) { 4286name_arr[count++] = "_token" 4287value_arr['_token'] = token_el.value; 4288} 4289name_arr[count++] = "block_id"; 4290value_arr['block_id'] = block_id; 4291name_arr[count++] = "page_id"; 4292value_arr['page_id'] = page_id; 4293name_arr[count++] = "module_id"; 4294value_arr['module_id'] = module_id; 4295if(!queryParams['prefix_id_name']) { 4296if(block_id != 0) var att_suffix_id = block_id; 4297else var att_suffix_id = module_id; 4298if(att_suffix_id.length + 1 != id.length) { 4299var att_re_suffix_id = new RegExp("_"+att_suffix_id + "$", "i"); 4300var att_replace_str = id.replace(att_re_suffix_id,""); 4301if(att_replace_str == id) { 4302var att_re_suffix_id = new RegExp("_"+block_id + "$", "i"); 4303var att_replace_str = id.replace(att_re_suffix_id,""); 4304} 4305att_replace_str = att_replace_str.substr(1,att_replace_str.length - 1); 4306if(att_replace_str != "") { 4307name_arr[count++] = "prefix_id_name"; 4308value_arr['prefix_id_name'] = att_replace_str; 4309} 4310} 4311} else { 4312name_arr[count++] = "prefix_id_name"; 4313value_arr['prefix_id_name'] = queryParams["prefix_id_name"]; 4314} 4315name_arr = _checkInputTag(name_arr, formList[i]); 4316this.attachmentCallBack[form_target] = callbackfunc; 4317this.attachmentErrorCallBack[form_target] = callbackfunc_error; 4318this.attachmentTarget[form_target] = target_el; 4319var div=document_object.createElement('div'); 4320div.id = "tmp_" + form_target; 4321div.style.visibility = "hidden"; 4322div.innerHTML='<iframe src="about:blank" name="' + form_target + '" style="width:0px;height:0px;"></iframe>'; 4323document_object.body.appendChild(div); 4324for (var j = 0; j < name_arr.length; j++){ 4325if(value_arr[name_arr[j]] || value_arr[name_arr[j]] == 0) { 4326if(name_arr[j] != "action") { 4327_createHiddenTag(name_arr[j],value_arr[name_arr[j]],formList[i]); 4328} else { 4329var action_name = value_arr[name_arr[j]]; 4330} 4331} 4332} 4333formList[i].action = _nc_base_url + _nc_index_file_name + '?action=' + action_name; 4334if(action_name != undefined) { 4335_createHiddenTag("action", action_name, formList[i]); 4336} 4337formList[i].method = "post"; 4338commonCls.referObject = document_object; 4339formList[i].submit(); 4340commonCls._attachmentChecker(form_target, match_str, debug_param, 0, timeout_flag); 4341var attachment_hiddenfields = Element.getElementsByClassName(formList[i], "_attachment_hidden"); 4342attachment_hiddenfields.each(function(el) { 4343Element.remove(el); 4344}.bind(this)); 4345return true; 4346} 4347} 4348} 4349return false; 4350function _checkInputTag(name_arr, form_el){ 4351var inputList = form_el.getElementsByTagName("input"); 4352for (var j = 0; j < inputList.length; j++){ 4353if(inputList[j].name) { 4354var pos = name_arr.indexOf(inputList[j].name); 4355if(pos >= 0) { 4356name_arr[pos] = null; 4357} 4358} 4359} 4360return name_arr.compact(); 4361} 4362function _createHiddenTag(key_name, value, form_el){ 4363var input=document_object.createElement('input'); 4364input.setAttribute("name",key_name,1); 4365input.setAttribute("type","hidden",1); 4366input.value = value; 4367Element.addClassName(input, "_attachment_hidden"); 4368form_el.appendChild(input); 4369} 4370}, 4371_attachmentChecker: function(form_target, match_str, debug_param, totaltime, timeout_flag) { 4372var iframe_target_el = commonCls.referObject.getElementById("tmp_" + form_target); 4373if(browser.isSafari) { 4374if(Element.getChildElement(iframe_target_el).contentWindow) { 4375if(Element.getChildElement(iframe_target_el).contentWindow.document && Element.getChildElement(iframe_target_el).contentWindow.document.body) { 4376var div = Element.getChildElementByClassName(Element.getChildElement(iframe_target_el).contentWindow.document.body, "_attachment_result"); 4377if(div) { 4378Element.addClassName(iframe_target_el, "_attachment_end") 4379} 4380} 4381} 4382} 4383if(totaltime > 30000 && timeout_flag == 1) { 4384if (!commonCls.confirm(commonLang.upload_timeout_confirm)) { 4385Element.remove(iframe_target_el); 4386commonCls.inAttachment[form_target] = null; 4387return; 4388} 4389totaltime = 0; 4390} 4391if(!Element.hasClassName(iframe_target_el, "_attachment_end")) { 4392if(match_str == null || match_str == undefined) { 4393setTimeout("commonCls._attachmentChecker('"+form_target+"',"+match_str+","+debug_param+","+(totaltime+200)+","+timeout_flag+")", 200); 4394} else { 4395setTimeout("commonCls._attachmentChecker('"+form_target+"','"+match_str+"',"+debug_param+","+(totaltime+200)+","+timeout_flag+")", 200); 4396} 4397} else { 4398iframe_target_el.innerHTML = Element.getChildElement(iframe_target_el).contentWindow.document.body.innerHTML; 4399var callback_func = commonCls.attachmentCallBack[form_target]; 4400var callbackfunc_error = commonCls.attachmentErrorCallBack[form_target]; 4401var target_el = commonCls.attachmentTarget[form_target]; 4402commonCls.attachmentCallBack[form_target] = null; 4403commonCls.attachmentErrorCallBack[form_target] = null; 4404commonCls.attachmentTarget[form_target] = null; 4405commonCls.inAttachment[form_target] = null; 4406var div = Element.getChildElementByClassName(iframe_target_el, "_attachment_result"); 4407if(div) { 4408var response = new Object(); 4409for (var i = 0; i < div.childNodes.length; i++) { 4410var file = div.childNodes[i]; 4411response[i] = new Object(); 4412for (var j = 0; j < file.childNodes.length; j++) { 4413response[i][file.childNodes[j].title] = file.childNodes[j].innerHTML; 4414} 4415} 4416Element.remove(div); 4417} 4418var res = iframe_target_el.innerHTML; 4419if(_nc_debug) var res = commonCls.AjaxResultStr(res); 4420if(debug_param) { 4421if(typeof debug == 'object') { 4422debug.p(res); 4423} else { 4424commonCls.alert(res); 4425} 4426} 4427commonCls.referObject = null; 4428if((match_str != null && match_str != undefined && commonCls.matchContentElement(res,match_str)) || 4429((match_str == null || match_str == undefined) && !commonCls.matchErrorElement(res)
4429)) { 4430if(target_el) { 4431target_el.innerHTML = res; 4432} 4433if(callback_func) { 4434callback_func(response, res); 4435} 4436} else { 4437res = commonCls.cutErrorMes(res); 4438if(callbackfunc_error) { 4439callbackfunc_error(response, res); 4440} else { 4441commonCls.alert(res); 4442} 4443} 4444Element.remove(iframe_target_el); 4445} 4446}, 4447imgChange: function(el, prev_name, change_name, alt_title_str) { 4448var img_el = (el.tagName.toLowerCase() == "img") ? el : el.getElementsByTagName("img")[0]; 4449if(img_el) { 4450prev_name=prev_name.replace(/(\!|"|'|\(|\)|\-|\=|\^|\\|\||\[|\{|\+|\:|\*|\]|\}|\,|\<|\.|\>|\/|\?)/g,"\\$1"); 4451var re = new RegExp(prev_name + "$", "i"); 4452img_el.src = img_el.src.replace(re, change_name); 4453if(alt_title_str != undefined) { 4454img_el.title = alt_title_str; 4455img_el.alt = alt_title_str; 4456} 4457} 4458}, 4459tabsetActive: function(this_el) { 4460var targetEl = this_el; 4461if(!Element.hasClassName(targetEl,"comptabset_tabset")) { 4462var targetEl = Element.getParentElementByClassName(targetEl,"comptabset_tabset"); 4463} 4464var tab_el = Element.getParentElementByClassName(targetEl,"comptabset_tabs"); 4465var tableList = tab_el.getElementsByTagName("table"); 4466var active_flag = true; 4467for (var i = 0; i < tableList.length; i++){ 4468if(Element.hasClassName(tableList[i],"comptabset_tabset")) { 4469if(targetEl == tableList[i] || targetEl.parentNode == tableList[i]) { 4470if(Element.hasClassName(tableList[i],"comptabset_active")) { 4471active_flag = false; 4472break; 4473} else { 4474Element.addClassName(tableList[i],"comptabset_active"); 4475} 4476} else { 4477Element.removeClassName(tableList[i],"comptabset_active"); 4478} 4479} 4480} 4481return active_flag; 4482}, 4483tabsetFocus: function(id) { 4484var headermenu_el = $("_headermenu"+ id); 4485var active_el = Element.getChildElementByClassName(headermenu_el,"comptabset_active"); 4486var a_el = active_el.getElementsByTagName("a")[0]; 4487commonCls.focus(a_el); 4488}, 4489focus: function(id) { 4490if (typeof id == 'string') { 4491setTimeout("commonCls.focusComp('"+id+"')", 300); 4492} else { 4493setTimeout(function(){commonCls.focusComp(this);}.bind(id), 300); 4494} 4495}, 4496focusComp: function(id, error_count) { 4497try { 4498error_count = (error_count == undefined) ? 0 : error_count; 4499if (typeof id == 'string') { 4500var top_el = $(id); 4501var form = top_el.getElementsByTagName("form")[0]; 4502if(form) { 4503var result = Form.focusFirstElement(form); 4504} 4505} else { 4506var result = false;
4507if(id.nodeType == 1) { 4508var top_el = id; 4509var name =id.tagName.toLowerCase(); 4510if(name == 'input' || name == 'select' || name == 'textarea') { 4511id.focus(); 4512id.select(); 4513result = true; 4514} else if(name == 'a') { 4515id.focus(); 4516result = true; 4517} else if(name == 'form') { 4518result = Form.focusFirstElement(id); 4519} else { 4520var inputList = id.getElementsByTagName("input"); 4521for (var i = 0; i < inputList.length; i++){ 4522if ((inputList[i].type == "text" || inputList[i].type == "select" || inputList[i].type == "textarea") 4523&& !inputList[i].disabled){ 4524inputList[i].focus(); 4525inputList[i].select(); 4526result = true; 4527break; 4528} 4529} 4530} 4531} 4532} 4533if(!result && top_el) { 4534var a_el = top_el.getElementsByTagName("a")[0]; 4535if(a_el) a_el.focus(); 4536} 4537}catch(e){ 4538if(error_count < 5) { 4539error_count++; 4540if (typeof id == 'string') { 4541setTimeout("commonCls.focusComp('"+id+"'," + error_count + ")", 300); 4542} else { 4543setTimeout(function(){commonCls.focusComp(this, error_count);}.bind(id), 300); 4544} 4545} 4546} 4547}, 4548addBlockTheme: function(theme_name) { 4549var themeStrList = theme_name.split("_"); 4550if(themeStrList.length == 1) { 4551var template_block_dir = "themes/" + theme_name + "/css/"; 4552} else { 4553theme_name = themeStrList.shift(); 4554var template_block_dir = "themes/" + theme_name + "/css/" + themeStrList.join("/") + "/"; 4555} 4556commonCls.addCommonLink("/" + template_block_dir+"style.css"); 4557}, 4558scrollMoveDrag: function(event, offset) { 4559var offset = (offset == undefined) ? 40 : offset; 4560Position.prepare(); 4561if(Event.pointerX(event) - Position.deltaX > Position.getWinOuterWidth() - offset) { 4562scrollTo(Position.deltaX + offset -10, Position.deltaY); 4563}else if(Event.pointerX(event) <= Position.deltaX + offset && Position.deltaX > 0) { 4564scrollTo(Position.deltaX - offset, Position.deltaY); 4565} 4566if(Event.pointerY(event) - Position.deltaY > Position.getWinOuterHeight() - offset) { 4567scrollTo(Position.deltaX, Position.deltaY + offset); 4568} else if(Event.pointerY(event) <= Position.deltaY + offset && Position.deltaY > 0) { 4569scrollTo(Position.deltaX, Position.deltaY - offset); 4570} 4571}, 4572getHSL : function(r, g, b) 4573{ 4574var h,s,l,v,m; 4575var r = r/255; 4576var g = g/255; 4577var b = b/255; 4578v = Math.max(r, g), v = Math.max(v, b); 4579m = Math.min(r, g), m = Math.min(m, b); 4580l = (m+v)/2; 4581if (v == m) var sl_s = 0, sl_l = Math.round(l*255),sl_h=0; 4582else 4583{ 4584if (l <= 0.5) s = (v-m)/(v+m); 4585else s = (v-m)/(2-v-m); 4586if (r == v) h = (g-b)/(v-m); 4587if (g == v) h = 2+(b-r)/(v-m); 4588if (b == v) h = 4+(r-g)/(v-m); 4589h = h*60; if (h<0) h += 360; 4590var sl_h = Math.round(h/360*255); 4591var sl_s = Math.round(s*255); 4592var sl_l = Math.round(l*255); 4593} 4594return { h : sl_h, s : sl_s , l : sl_l }; 4595}, 4596getRBG : function(h, s, l) 4597{ 4598var r, g, b, v, m, se, mid1, mid2; 4599h = h/255, s = s/255, l = l/255; 4600if (l <= 0.5) v = l*(1+s); 4601else v = l+s-l*s; 4602if (v <= 0) var sl_r = 0, sl_g = 0, sl_b = 0; 4603else 4604{ 4605var m = 2*l-v,h=h*6, se = Math.floor(h); 4606var mid1 = m+v*(v-m)/v*(h-se); 4607var mid2 = v-v*(v-m)/v*(h-se); 4608switch (se) 4609{ 4610case 0 : r = v; g = mid1; b = m; break; 4611case 1 : r = mid2; g = v; b = m; break; 4612case 2 : r = m; g = v; b = mid1; break; 4613case 3 : r = m; g = mid2; b = v; break; 4614case 4 : r = mid1; g = m; b = v; break; 4615case 5 : r = v; g = m; b = mid2; break; 4616} 4617var sl_r = Math.round(r*255); 4618var sl_g = Math.round(g*255); 4619var sl_b = Math.round(b*255); 4620} 4621return { r : sl_r, g : sl_g , b : sl_b }; 4622}, 4623getRGBtoHex : function(color) { 4624if(color.r ) return color; 4625if(color == "transparent" || color.match("^rgba")) return "transparent"; 4626if(color.match("^rgb")) { 4627color = color.replace("rgb(",""); 4628color = color.replace(")",""); 4629color_arr = color.split(","); 4630return { r : parseInt(color_arr[0]), g : parseInt(color_arr[1]) , b : parseInt(color_arr[2]) }; 4631} 4632if ( color.indexOf('#') == 0 ) 4633color = color.substring(1); 4634var red = color.substring(0,2); 4635var green = color.substring(2,4); 4636var blue = color.substring(4,6); 4637return { r : parseInt(red,16), g : parseInt(green,16) , b : parseInt(blue,16) }; 4638}, 4639getHex : function(r, g, b) 4640{ 4641var co = "#"; 4642if (r < 16) co = co+"0"; co = co+r.toString(16); 4643if (g < 16) co = co+"0"; co = co+g.toString(16); 4644if (b < 16) co = co+"0"; co = co+b.toString(16); 4645return co; 4646}, 4647getColorCode: function(el , property_name) { 4648if(property_name == "borderColor" || property_name == "border-color") { 4649property_name = "borderTopColor";
4650} 4651if(property_name == "borderTopColor" || property_name == "borderRightColor" || 4652property_name == "borderBottomColor" || property_name == "borderLeftColor") { 4653var width = Element.getStyle(el, property_name.replace("Color","")+"Width"); 4654if(width == "" || width == "0px" || width == "0") { 4655return "transparent"; 4656} 4657} 4658var rgb = Element.getStyle(el, property_name); 4659if(rgb == undefined || rgb == null) { 4660return "transparent"; 4661} else if (rgb.match("^rgb") && rgb != "transparent" && rgb.substr(0, 1) != "#") { 4662rgb = rgb.substr(4, rgb.length - 5); 4663var rgbArr = rgb.split(","); 4664rgb = commonCls.getHex(parseInt(rgbArr[0]),parseInt(rgbArr[1]),parseInt(rgbArr[2])); 4665} else if(rgb.substr(0, 1) != "#"){ 4666if(property_name == "backgroundColor") { 4667return "transparent"; 4668} 4669return ""; 4670} 4671return rgb; 4672}, 4673colorCheck: function(event) { 4674if(((event.ctrlKey && !event.altKey) || event.keyCode == 229 || event.keyCode == 46 || event.keyCode == 8 || 4675(event.keyCode >= 37 && event.keyCode <= 40) || event.keyCode == 9 || event.keyCode == 13 || 4676(event.keyCode >= 96 && event.keyCode <= 105) || 4677(event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 65 && event.keyCode <= 70))) 4678return true; 4679return false; 4680}, 4681numberCheck: function(event) { 4682if(((event.ctrlKey && !event.altKey) || event.keyCode == 229 || event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 13 || 4683(event.keyCode >= 96 && event.keyCode <= 105) || 4684(event.keyCode >= 37 && event.keyCode <= 40) || (!event.shiftKey && event.keyCode >= 48 && event.keyCode <= 57))) 4685return true; 4686return false; 4687}, 4688numberConvert: function(event) { 4689if(event.keyCode == 13 || event.type == "blur") { 4690var event_el = Event.element(event); 4691var num_value = event_el.value; 4692var en_num = "0123456789.,-+"; 4693var em_num = "ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼"; 4694var str = ""; 4695for (var i=0; i< num_value.length; i++) { 4696var c = num_value.charAt(i); 4697var n = em_num.indexOf(c,0); 4698var m = en_num.indexOf(c,0); 4699if (n >= 0) {c = en_num.charAt(n);str += c; 4700} else if (m >= 0) str += c; 4701} 4702if(num_value != str) event_el.value = str; 4703return true; 4704} 4705return false; 4706}, 4707observe: function(element, name, observer, useCapture, top_el) { 4708Event.observe(element, name, observer, useCapture, top_el); 4709}, 4710stopObserving: function(element, name, observer, useCapture) { 4711Event.stopObserving(element, name, observer, useCapture); 4712}, 4713stop: function(event) { 4714Event.stop(event); 4715}, 4716setStyle: function(el, value) { 4717Element.setStyle(el, value); 4718}, 4719hasClassName: function(el, class_name) { 4720return Element.hasClassName(el,class_name); 4721}, 4722changeAuthority: function(checkbox, id) { 4723if (checkbox.type != "checkbox" 4724|| checkbox.id.length == 0) { 4725return; 4726} 4727var name = checkbox.id.substr(0, checkbox.id.length - id.length); 4728var ahuthId = name.match(/\d+$/); 4729name = name.substr(0, name.length - ahuthId.length); 4730while (checkbox.checked) { 4731ahuthId++; 4732var element = $(name + ahuthId + id); 4733if (element == null) break; 4734element.checked = true; 4735} 4736while (!checkbox.checked) { 4737ahuthId--; 4738var element = $(name + ahuthId + id); 4739if (element == null) break; 4740element.checked = false; 4741} 4742} 4743} 4744commonCls = new clsCommon(); 4745var clsCommonOperation = Class.create(); 4746var commonOperationCls = Array(); 4747clsCommonOperation.prototype = { 4748initialize: function(id, unioncolumn_str) { 4749this.id = id; 4750this.unioncolumn_str = unioncolumn_str; 4751}, 4752init: function() { 4753commonCls.focus($("form"+this.id)); 4754}, 4755selectOnChange: function(event, el) { 4756if(el == undefined) { 4757var event_el = Event.element(event); 4758} else { 4759var event_el = el; 4760} 4761var eleOptions = event_el.getElementsByTagName("option"); 4762var option_len = eleOptions.length; 4763for (var i = option_len - 1; i >= 0 ; i--){ 4764if (Element.hasClassName(eleOptions[i],"disable_lbl") && eleOptions[i].selected == true){ 4765eleOptions[i].selected = false; 4766event_el.selectedIndex = 0; 4767} 4768} 4769this.chgDisabled(event_el, "move"); 4770this.chgDisabled(event_el, "copy"); 4771this.chgDisabled(event_el, "shortcut"); 4772}, 4773chgDisabled: function(select_el, mode) { 4774var operation_el = $(mode + this.id); 4775if(operation_el) { 4776if(select_el.selectedIndex == 0) { 4777operation_el.disabled = true; 4778} else { 4779operation_el.disabled = false;
4780} 4781} 4782}, 4783getConfirmMes: function(mes) { 4784var move_destination_el = $("move_destination"+this.id); 4785var optText = move_destination_el.options[move_destination_el.selectedIndex].text; 4786return mes + optText.trim(); 4787}, 4788compBlock: function(event, parent_id_name, main_page_id, mes, mode) { 4789var move_destination_el = $("move_destination"+this.id); 4790var value = move_destination_el.value; 4791if(mode == "move") { 4792pagesCls.deleteBlock(event, parent_id_name, null, false); 4793} 4794commonCls.alert(mes); 4795if(main_page_id == value || this.unioncolumn_str.match("/|"+value+"|/")) { 4796setTimeout(function(){location.href = decodeURIComponent(_nc_current_url).unescapeHTML();}, 300); 4797} 4798} 4799} 4800 4801var compCommonUtil = { 4802toViewportPosition: function(element) { 4803return this._toAbsolute(element,true); 4804}, 4805toDocumentPosition: function(element) { 4806return this._toAbsolute(element,false); 4807}, 4808_toAbsolute: function(element,accountForDocScroll) { 4809if ( navigator.userAgent.toLowerCase().indexOf("msie") == -1 ) 4810return this._toAbsoluteMozilla(element,accountForDocScroll); 4811var x = 0; 4812var y = 0; 4813var parent = element; 4814while ( parent ) { 4815var borderXOffset = 0; 4816var borderYOffset = 0; 4817if ( parent != element ) { 4818var borderXOffset = parseInt(this.getElementsComputedStyle(parent, "borderLeftWidth" )); 4819var borderYOffset = parseInt(this.getElementsComputedStyle(parent, "borderTopWidth" )); 4820borderXOffset = isNaN(borderXOffset) ? 0 : borderXOffset; 4821borderYOffset = isNaN(borderYOffset) ? 0 : borderYOffset; 4822} 4823x += parent.offsetLeft - parent.scrollLeft + borderXOffset; 4824y += parent.offsetTop - parent.scrollTop + borderYOffset; 4825parent = parent.offsetParent; 4826} 4827if ( accountForDocScroll ) { 4828x -= this.docScrollLeft(); 4829y -= this.docScrollTop(); 4830} 4831return { x:x, y:y }; 4832}, 4833_toAbsoluteMozilla: function(element,accountForDocScroll) { 4834var x = 0; 4835var y = 0; 4836var parent = element; 4837while ( parent ) { 4838x += parent.offsetLeft; 4839y += parent.offsetTop; 4840parent = parent.offsetParent; 4841} 4842parent = element; 4843while ( parent && 4844parent != document.body && 4845parent != document.documentElement ) { 4846if ( parent.scrollLeft ) 4847x -= parent.scrollLeft; 4848if ( parent.scrollTop ) 4849y -= parent.scrollTop; 4850parent = parent.parentNode; 4851} 4852if ( accountForDocScroll ) { 4853x -= this.docScrollLeft(); 4854y -= this.docScrollTop(); 4855} 4856return { x:x, y:y }; 4857}, 4858docScrollLeft: function() { 4859if ( window.pageXOffset ) 4860return window.pageXOffset; 4861else if ( document.documentElement && document.documentElement.scrollLeft ) 4862return document.documentElement.scrollLeft; 4863else if ( document.body ) 4864return document.body.scrollLeft; 4865else 4866return 0; 4867}, 4868docScrollTop: function() { 4869if ( window.pageYOffset ) 4870return window.pageYOffset; 4871else if ( document.documentElement && document.documentElement.scrollTop ) 4872return document.documentElement.scrollTop; 4873else if ( document.body ) 4874return document.body.scrollTop; 4875else 4876return 0; 4877} 4878}; 4879compCommonUtil.Effect = {}; 4880compCommonUtil.Effect.SizeAndPosition = Class.create(); 4881compCommonUtil.Effect.SizeAndPosition.prototype = { 4882initialize: function(element, x, y, w, h, duration, steps, options) { 4883this.element = $(element); 4884this.x = x; 4885this.y = y; 4886this.w = w; 4887this.h = h; 4888this.duration = duration; 4889this.steps = steps; 4890this.options = arguments[7] || {}; 4891this.sizeAndPosition(); 4892}, 4893sizeAndPosition: function() { 4894if (this.isFinished()) { 4895if(this.options.complete) this.options.complete(this); 4896return; 4897} 4898if (this.timer) 4899clearTimeout(this.timer); 4900var stepDuration = Math.round(this.duration/this.steps) ; 4901var currentX = this.element.offsetLeft; 4902var currentY = this.element.offsetTop; 4903var currentW = this.element.offsetWidth; 4904var currentH = this.element.offsetHeight; 4905this.x = (this.x) ? this.x : currentX; 4906this.y = (this.y) ? this.y : currentY; 4907this.w = (this.w) ? this.w : currentW; 4908this.h = (this.h) ? this.h : currentH; 4909var difX = this.steps > 0 ? (this.x - currentX)/this.steps : 0; 4910var difY = this.steps > 0 ? (this.y - currentY)/this.steps : 0; 4911var difW = this.steps > 0 ? (this.w - currentW)/this.steps : 0; 4912var difH = this.steps > 0 ? (this.h - currentH)/this.steps : 0; 4913this.moveBy(difX, difY); 4914this.resizeBy(difW, difH); 4915this.duration -= stepDuration; 4916this.steps--; 4917this.timer = setTimeout(this.sizeAndPosition.bind(this), stepDuration); 4918}, 4919isFinished: function() { 4920return this.steps <= 0; 4921}, 4922moveBy: function( difX, difY ) { 4923var currentLeft = this.element.offsetLeft; 4924var currentTop = this.element.offsetTop; 4925var intDifX = parseInt(difX); 4926var intDifY = parseInt(difY); 4927var style = this.element.style; 4928if ( intDifX != 0 ) 4929style.left = (currentLeft + intDifX) + "px"; 4930if ( intDifY != 0 ) 4931style.top = (currentTop + intDifY) + "px"; 4932}, 4933resizeBy: function( difW, difH ) { 4934var currentWidth = this.element.offsetWidth; 4935var currentHeight = this.element.offsetHeight; 4936var intDifW = parseInt(difW); 4937var intDifH = parseInt(difH); 4938var style = this.element.style; 4939if ( intDifW != 0 ) 4940style.width = (currentWidth + intDifW) + "px"; 4941if ( intDifH != 0 ) 4942style.height = (currentHeight + intDifH) + "px"; 4943} 4944} 4945compCommonUtil.Effect.Size = Class.create(); 4946compCommonUtil.Effect.Size.prototype = { 4947initialize: function(element, w, h, duration, steps, options) { 4948new compCommonUtil.Effect.SizeAndPosition(element, null, null, w, h, duration, steps, options); 4949} 4950} 4951compCommonUtil.Effect.Position = Class.create(); 4952compCommonUtil.Effect.Position.prototype = { 4953initialize: function(element, x, y, duration, steps, options) { 4954new compCommonUtil.Effect.SizeAndPosition(element, x, y, null, null, duration, steps, options); 4955} 4956} 4957compCommonUtil.Effect.Round = Class.create(); 4958compCommonUtil.Effect.Round.prototype = { 4959initialize: function(tagName, className, options) { 4960var elements = document.getElementsByTagAndClassName(tagName,className); 4961for ( var i = 0 ; i < elements.length ; i++ ) 4962compCommonUtil.Corner.round( elements[i], options ); 4963} 4964}; 4965 4966compDragAndDrop = Class.create(); 4967compDragAndDrop.prototype = { 4968initialize: function() { 4969this.dropZones = new Array(); 4970this.draggables = new Array(); 4971this.currentDragObjects = new Array(); 4972this.dragElement = null; 4973this.lastSelectedDraggable = null; 4974this.currentDragObjectVisible = false;
4975this.interestedInMotionEvents = false; 4976this._mouseDown = this._mouseDownHandler.bindAsEventListener(this); 4977this._mouseMove = this._mouseMoveHandler.bindAsEventListener(this); 4978this._mouseUp = this._mouseUpHandler.bindAsEventListener(this); 4979this.dragElementPosition = null; 4980this.add_absolute = false; 4981this.dragParentElement = null; 4982this.dummyElement = null; 4983this.dragObjectTransparent = true; 4984this.draggableRangeElement = null; 4985this.draggableRangeElementOffset = null; 4986this.origPos = null; 4987this.startx = null; 4988this.starty = null; 4989this.dragElementWidth = null; 4990this.scrollMovePx = 30; 4991}, 4992registerDropZone: function(aDropZone, dropObjectAppendChild) { 4993if (aDropZone.tagName != undefined) { 4994aDropZone = new compDropzone(aDropZone,null, dropObjectAppendChild); 4995} 4996if (dropObjectAppendChild == true || dropObjectAppendChild == false) { 4997aDropZone.setDropObjectAppendChild(dropObjectAppendChild); 4998} 4999this.dropZones[ this.dropZones.length ] = aDropZone; 5000}, 5001deregisterDropZone: function(aDropZone) { 5002var newDropZones = new Array(); 5003var j = 0; 5004for ( var i = 0 ; i < this.dropZones.length ; i++ ) { 5005if ( this.dropZones[i] != aDropZone ) 5006newDropZones[j++] = this.dropZones[i]; 5007} 5008this.dropZones = newDropZones; 5009}, 5010clearDropZones: function() { 5011this.dropZones = new Array(); 5012}, 5013registerDraggableRange: function(el) { 5014el = $(el); 5015this.draggableRangeElement = el; 5016}, 5017registerDraggable: function( aDraggable, dragObjectTransparent) { 5018if (dragObjectTransparent == true || dragObjectTransparent == false) { 5019this.dragObjectTransparent = dragObjectTransparent; 5020} 5021if (aDraggable.tagName != undefined) { 5022aDraggable = new compDraggable(aDraggable); 5023} 5024this.draggables[ this.draggables.length ] = aDraggable; 5025this._addMouseDownHandler( aDraggable ); 5026}, 5027clearSelection: function() { 5028for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) { 5029this.currentDragObjects[i].deselect(); 5030} 5031this.currentDragObjects = new Array(); 5032this.lastSelectedDraggable = null; 5033}, 5034hasSelection: function() { 5035return this.currentDragObjects.length > 0; 5036}, 5037setStartDragFromElement: function( e, mouseDownElement ) { 5038var offset = Position.cumulativeOffsetScroll(mouseDownElement); 5039this.origPos = new Object(); 5040this.draggableRangeElementOffset = new Object(); 5041this.origPos.x = offset[0]; 5042this.origPos.y = offset[1]; 5043if(Element.getStyle(mouseDownElement, "position") == "relative") { 5044this.draggableRangeElementOffset.x = valueParseInt(Element.getStyle(mouseDownElement, "left")); 5045this.draggableRangeElementOffset.y = valueParseInt(Element.getStyle(mouseDownElement, "top")) 5046this.origPos.x -= this.draggableRangeElementOffset.x; 5047this.origPos.y -= this.draggableRangeElementOffset.y; 5048} else { 5049this.draggableRangeElementOffset.x = 0; 5050this.draggableRangeElementOffset.y = 0; 5051} 5052this.startx = Event.pointerX(e) - this.origPos.x; 5053this.starty = Event.pointerY(e) - this.origPos.y; 5054this.interestedInMotionEvents = this.hasSelection(); 5055this._terminateEvent(e); 5056}, 5057updateSelection: function( draggable, extendSelection ) { 5058if ( ! extendSelection ) 5059this.clearSelection(); 5060if ( draggable.isSelected() ) { 5061this.currentDragObjects.removeItem(draggable); 5062draggable.deselect(); 5063if ( draggable == this.lastSelectedDraggable ) 5064this.lastSelectedDraggable = null; 5065} else { 5066this.currentDragObjects[ this.currentDragObjects.length ] = draggable; 5067draggable.select(); 5068this.lastSelectedDraggable = draggable; 5069} 5070}, 5071_mouseDownHandler: function(e) { 5072if ( arguments.length == 0 ) 5073e = event; 5074var nsEvent = e.which != undefined; 5075if ( (nsEvent && e.which != 1) || (!nsEvent && e.button != 1)) 5076return; 5077var eventTarget = Event.element(e); 5078var draggableObject = eventTarget.draggableObject; 5079if(typeof draggableObject != 'object') draggableObject = null; 5080var candidate = eventTarget; 5081while (draggableObject == null && candidate.parentNode) { 5082candidate = candidate.parentNode; 5083draggableObject = candidate.draggableObject; 5084} 5085if ( typeof draggableObject != 'object' ) 5086return; 5087this.updateSelection( draggableObject, e.ctrlKey ); 5088if ( this.hasSelection() ) { 5089for ( var i = 0 ; i < this.dropZones.length ; i++ ) { 5090this.dropZones[i].clearPositionCache(); 5091} 5092} 5093this.setStartDragFromElement( e, draggableObject.getMouseDownHTMLElement() ); 5094}, 5095_mouseMoveHandler: function(e) { 5096var nsEvent = e.which != undefined; 5097if ( !this.interestedInMotionEvents ) { 5098return; 5099} 5100if ( ! this.hasSelection() ) 5101return; 5102if ( ! this.currentDragObjectVisible ) { 5103this._startDrag(e); 5104} 5105if ( !this.activatedDropZones ) 5106this._activateRegisteredDropZones(); 5107this._updateDraggableLocation(e); 5108this._updateDropZonesHover(e); 5109this._terminateEvent(e); 5110}, 5111_makeDraggableObjectVisible: function(e) 5112{ 5113if ( !this.hasSelection() ) 5114return; 5115var dragElement; 5116if ( this.currentDragObjects.length > 1 ) 5117dragElement = this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects); 5118else 5119dragElement = this.currentDragObjects[0].getSingleObjectDragGUI(); 5120if(valueParseInt(dragElement.style.width) > 0) { 5121this.dragElementWidth = dragElement.style.width; 5122} else { 5123this.dragElementWidth = 0; 5124} 5125dragElement.style.width = dragElement.offsetWidth + "px"; 5126if(dragElement.tagName.toLowerCase() == 'tr') { 5127var tag_kind = "tr"; 5128} else if(dragElement.tagName.toLowerCase() == 'td') { 5129var tag_kind = "td"; 5130} else { 5131var tag_kind = "other"; 5132}
5133if(tag_kind == 'tr' || tag_kind == 'td') { 5134var table = document.createElement("table"); 5135var parentTable = dragElement.parentNode; 5136while(parentTable.tagName.toLowerCase() != "table") { 5137parentTable = parentTable.parentNode; 5138if(parentTable.tagName.toLowerCase() == "body") { 5139break; 5140} 5141} 5142table.className = parentTable.className; 5143var append_el = document.createElement("tbody"); 5144table.appendChild(append_el); 5145if(tag_kind == 'td') { 5146var append_el = document.createElement("tr"); 5147append_el.className = dragElement.parentNode.className; 5148table.appendChild(append_el); 5149new Insertion.After(dragElement, "<td />"); 5150} else { 5151new Insertion.After(dragElement, "<tr />"); 5152} 5153this.dragParentElement = table; 5154} else { 5155var append_el = document.createElement("div"); 5156new Insertion.After(dragElement, "<input type='hidden' value='' />"); 5157this.dragParentElement = append_el; 5158} 5159this.dummyElement = dragElement.nextSibling; 5160commonCls.max_zIndex = commonCls.max_zIndex + 1; 5161append_el.appendChild(dragElement); 5162if(this.dragObjectTransparent) { 5163if(browser.isIE || browser.isSafari) { 5164var buf_el = append_el.cloneNode(true); 5165var inputList = buf_el.getElementsByTagName("input"); 5166for (var i = 0; i < inputList.length; i++){ 5167var type = inputList[i].getAttribute("type"); 5168if(type == "text" || type == "hidden") { 5169inputList[i].setAttribute("value",'',0); 5170} 5171} 5172var dragHtml = buf_el.innerHTML; 5173if(browser.isIE) Element.remove(buf_el); 5174else Element.remove(buf_el.childNodes[0]); 5175buf_el = null; 5176} else { 5177var dragHtml = append_el.innerHTML; 5178} 5179new Insertion.After(this.dummyElement, dragHtml); 5180var bufEl = this.dummyElement.nextSibling; 5181if(this.dragElementWidth == null || this.dragElementWidth == 0) { 5182bufEl.style.width = ''; 5183} 5184Element.addClassName(bufEl, "_draganddrop_transparent"); 5185Element.remove(this.dummyElement); 5186this.dummyElement = bufEl; 5187} 5188if(tag_kind == 'tr' || tag_kind == 'td') { 5189var dragElementPosition = table; 5190} else { 5191var dragElementPosition = dragElement.parentNode; 5192} 5193dragElementPosition.style.zIndex = commonCls.max_zIndex; 5194this.add_absolute = false; 5195if ( Element.getStyle(dragElementPosition, "position") != "absolute" ) { 5196dragElementPosition.style.position = "absolute"; 5197this.add_absolute = true; 5198} 5199if(tag_kind == 'tr' || tag_kind == 'td') { 5200document.body.appendChild(table); 5201} else { 5202document.body.appendChild(append_el); 5203} 5204this.dragElement = dragElement; 5205this.dragElementPosition = dragElementPosition; 5206this._updateDraggableLocation(e); 5207this.currentDragObjectVisible = true; 5208}, 5209_leftOffset: function(e) { 5210return e.offsetX ? (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) : 0 5211}, 5212_topOffset: function(e) { 5213return e.offsetY ? (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) :0 5214}, 5215_updateDraggableLocation: function(e) { 5216var dragObjectStyle = this.dragElementPosition.style; 5217if(this.draggableRangeElement != null) { 5218var drop_offset = Position.cumulativeOffset(this.draggableRangeElement); 5219drop_offset[0] -= this.draggableRangeElementOffset.x; 5220drop_offset[1] -= this.draggableRangeElementOffset.y; 5221var drop_el_left = drop_offset[0]; 5222var drop_el_right = drop_offset[0] + this.draggableRangeElement.offsetWidth; 5223var drop_el_top = drop_offset[1]; 5224var drop_el_bottom = drop_offset[1] + this.draggableRangeElement.offsetHeight; 5225var offset = Position.cumulativeOffset(this.dragElementPosition); 5226var el_left = offset[0]; 5227var el_right = offset[0] + this.dragElementPosition.offsetWidth; 5228var el_top = offset[1]; 5229var el_bottom = offset[1] + this.dragElementPosition.offsetHeight; 5230var buf_el_left = (Event.pointerX(e) - this.startx); 5231var buf_el_right = (Event.pointerX(e) - this.startx) + this.dragElementPosition.offsetWidth; 5232var buf_el_top = (Event.pointerY(e) - this.starty); 5233var buf_el_bottom = (Event.pointerY(e) - this.starty) + this.dragElementPosition.offsetHeight; 5234if(buf_el_left < drop_el_left) { 5235dragObjectStyle.left = valueParseInt(dragObjectStyle.left) + (drop_el_left - el_left) + "px"; 5236} else if(buf_el_right > drop_el_right){ 5237dragObjectStyle.left = valueParseInt(dragObjectStyle.left) + (drop_el_right - el_right) + "px"; 5238} else { 5239dragObjectStyle.left = buf_el_left + "px"; 5240} 5241if(buf_el_top < drop_el_top) { 5242dragObjectStyle.top = valueParseInt(dragObjectStyle.top) + (drop_el_top - el_top) + "px"; 5243} else if(buf_el_bottom > drop_el_bottom){ 5244dragObjectStyle.top = valueParseInt(dragObjectStyle.top) + (drop_el_bottom - el_bottom) + "px"; 5245} else { 5246dragObjectStyle.top = buf_el_top + "px"; 5247} 5248} else { 5249dragObjectStyle.left = (Event.pointerX(e) - this.startx) + "px"; 5250dragObjectStyle.top = (Event.pointerY(e) - this.starty) + "px"; 5251} 5252commonCls.scrollMoveDrag(e, this.scrollMovePx); 5253}, 5254_updateDropZonesHover: function(e) { 5255var n = this.dropZones.length; 5256for ( var i = 0 ; i < n ; i++ ) { 5257if ( ! this._mousePointInDropZone( e, this.dropZones[i] ) ) 5258this.dropZones[i].hideHover(e); 5259} 5260for ( var i = 0 ; i < n ; i++ ) { 5261if ( this._mousePointInDropZone( e, this.dropZones[i] ) ) { 5262if ( this.dropZones[i].canAccept(this.currentDragObjects) ) 5263this.dropZones[i].showHover(e); 5264} 5265} 5266}, 5267_startDrag: function(e) { 5268for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) { 5269this.currentDragObjects[i].prestartDrag(); 5270} 5271this._makeDraggableObjectVisible(e); 5272for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) { 5273this.currentDragObjects[i].startDrag(); 5274} 5275}, 5276_mouseUpHandler: function(e) { 5277Event.stopObserving(document, "mousemove", this._mouseMove); 5278Event.stopObserving(document, "mouseup", this._mouseUp); 5279if ( ! this.hasSelection() ){ 5280return; 5281} 5282var nsEvent = e.which != undefined; 5283if ( (nsEvent && e.which != 1) || (!nsEvent && e.button != 1)) { 5284return; 5285} 5286this.interestedInMotionEvents = false;
5287if ( this.dragElementPosition == null ) { 5288this._terminateEvent(e); 5289return; 5290} 5291if ( this._placeDraggableInDropZone(e) ) { 5292this._completeDropOperation(e); 5293} else { 5294this._terminateEvent(e); 5295new compCommonUtil.Effect.Position( this.dragElementPosition, 5296this._leftOffset(e) + this.origPos.x - valueParseInt(Element.getStyle(Element.getChildElement(this.dragElementPosition), "marginLeft")), 5297this._topOffset(e) + this.origPos.y - valueParseInt(Element.getStyle(Element.getChildElement(this.dragElementPosition), "marginTop")), 5298200, 529920, 5300{ complete : this._doCancelDragProcessing.bind(this) } ); 5301} 5302}, 5303_retTrue: function () { 5304return true; 5305}, 5306_completeDropOperation: function(e) { 5307Element.remove(this.dragParentElement); 5308Element.remove(this.dummyElement); 5309this._deactivateRegisteredDropZones(); 5310this._endDrag(); 5311this.clearSelection(); 5312this.dragElement = null; 5313this.dragElementPosition = null; 5314this.currentDragObjectVisible = false; 5315this._terminateEvent(e); 5316}, 5317_doCancelDragProcessing: function() { 5318this._cancelDrag(); 5319this.clearSelection(); 5320if(this.dragElement == null) return; 5321if(this.add_absolute) { 5322this.dragElement.style.position = ""; 5323} 5324if(this.dragElementWidth != null && this.dragElementWidth > 0) { 5325this.dragElement.style.width = this.dragElementWidth + "px"; 5326} else { 5327this.dragElement.style.width = ''; 5328} 5329this.dragElementWidth = null; 5330new Insertion.After(this.dummyElement, "<input type='hidden' value='' />"); 5331var buf_dummy_el = this.dummyElement.nextSibling; 5332Element.remove(this.dummyElement); 5333this.dummyElement = buf_dummy_el; 5334var parent_el = Element.getParentElement(this.dummyElement); 5335parent_el.insertBefore(this.dragElement, this.dummyElement); 5336Element.remove(this.dragParentElement); 5337Element.remove(this.dummyElement); 5338this._deactivateRegisteredDropZones(); 5339this.dragElement = null; 5340this.dragElementPosition = null; 5341this.currentDragObjectVisible = false; 5342}, 5343_placeDraggableInDropZone: function(e) { 5344var foundDropZone = false; 5345var n = this.dropZones.length; 5346for ( var i = 0 ; i < n ; i++ ) { 5347if ( this._mousePointInDropZone( e, this.dropZones[i] ) ) { 5348if ( this.dropZones[i].canAccept(this.currentDragObjects) ) { 5349foundDropZone = this.dropZones[i].save(this.currentDragObjects); 5350if(foundDropZone) { 5351this.dropZones[i].accept(this.currentDragObjects); 5352this.dropZones[i].hideHover(e); 5353} else { 5354this.dropZones[i].hideHover(e); 5355continue; 5356} 5357break; 5358} 5359} 5360} 5361return foundDropZone; 5362}, 5363_cancelDrag: function() { 5364for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) 5365this.currentDragObjects[i].cancelDrag(); 5366}, 5367_endDrag: function() { 5368for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) 5369this.currentDragObjects[i].endDrag(); 5370}, 5371_mousePointInDropZone: function( e, dropZone ) { 5372var absoluteRect = dropZone.getAbsoluteRect(); 5373if(this.dragElement == dropZone.getHTMLElement()) { 5374return false; 5375} 5376Position.prepare(); 5377var pointerX = Event.pointerX(e); 5378var pointerY = Event.pointerY(e); 5379if(this.draggableRangeElement != null) { 5380var drop_offset = Position.cumulativeOffset(this.draggableRangeElement); 5381var drop_el_left = drop_offset[0]; 5382var drop_el_right = drop_offset[0] + this.draggableRangeElement.offsetWidth; 5383var drop_el_top = drop_offset[1]; 5384var drop_el_bottom = drop_offset[1] + this.draggableRangeElement.offsetHeight; 5385if(pointerX < drop_el_left) { 5386pointerX = drop_el_left + 1; 5387} else if(pointerX > drop_el_right){ 5388pointerX = drop_el_right - 1; 5389} 5390if(pointerY < drop_el_top) { 5391pointerY = drop_el_top + 1; 5392} else if(pointerY > drop_el_bottom){ 5393pointerY = drop_el_bottom - 1; 5394} 5395} 5396return pointerX > absoluteRect.left && 5397pointerX < absoluteRect.right && 5398pointerY > absoluteRect.top && 5399pointerY < absoluteRect.bottom; 5400}, 5401_addMouseDownHandler: function( aDraggable ) 5402{ 5403htmlElement = aDraggable.getMouseDownHTMLElement(); 5404if ( htmlElement != null ) { 5405htmlElement.draggableObject = aDraggable; 5406Event.observe(htmlElement , "mousedown", this._onmousedown.bindAsEventListener(this)); 5407Event.observe(htmlElement, "mousedown", this._mouseDown); 5408} 5409}, 5410_activateRegisteredDropZones: function() { 5411var n = this.dropZones.length; 5412for ( var i = 0 ; i < n ; i++ ) { 5413var dropZone = this.dropZones[i]; 5414if ( dropZone.canAccept(this.currentDragObjects) ) 5415dropZone.activate(); 5416} 5417this.activatedDropZones = true; 5418}, 5419_deactivateRegisteredDropZones: function() { 5420var n = this.dropZones.length; 5421for ( var i = 0 ; i < n ; i++ ) 5422this.dropZones[i].deactivate(); 5423this.activatedDropZones = false;
5424}, 5425_onmousedown: function () { 5426Event.observe(document, "mousemove", this._mouseMove); 5427Event.observe(document, "mouseup", this._mouseUp); 5428}, 5429_terminateEvent: function(e) { 5430if ( e.stopPropagation != undefined ) 5431e.stopPropagation(); 5432else if ( e.cancelBubble != undefined ) 5433e.cancelBubble = true; 5434if ( e.preventDefault != undefined ) 5435e.preventDefault(); 5436else 5437e.returnValue = false; 5438} 5439}; 5440compDraggable = Class.create(); 5441compDraggable.prototype = { 5442initialize: function( htmlElement, dragElement, params, type ) { 5443this.type = type; 5444this.htmlElement = $(htmlElement); 5445if(dragElement == undefined || dragElement == null) { 5446this.dragElement = this.htmlElement; 5447} else { 5448this.dragElement = dragElement; 5449} 5450this.selected = false; 5451this.params = params; 5452}, 5453getMouseDownHTMLElement: function() { 5454return this.dragElement; 5455}, 5456getHTMLElement: function() { 5457return this.htmlElement; 5458}, 5459select: function() { 5460this.selected = true; 5461if ( this.showingSelected ) 5462return; 5463this.showingSelected = true; 5464}, 5465deselect: function() { 5466this.selected = false; 5467if ( !this.showingSelected ) 5468return; 5469this.showingSelected = false; 5470}, 5471isSelected: function() { 5472return this.selected; 5473}, 5474startDrag: function() { 5475var draggable = this.htmlElement; 5476Element.setStyle(draggable, {opacity:0.7}); 5477}, 5478prestartDrag: function() { 5479}, 5480cancelDrag: function() { 5481var draggable = this.htmlElement; 5482Element.setStyle(draggable, {opacity:""}); 5483}, 5484endDrag: function() { 5485var draggable = this.htmlElement; 5486Element.setStyle(draggable, {opacity:""}); 5487}, 5488getSingleObjectDragGUI: function() { 5489return this.htmlElement; 5490}, 5491getMultiObjectDragGUI: function( draggables ) { 5492return this.htmlElement; 5493}, 5494getDroppedGUI: function() { 5495return this.htmlElement; 5496}, 5497toString: function() { 5498return this.type + ":" + this.htmlElement + ":"; 5499}, 5500getParams: function() { 5501return this.params; 5502} 5503}; 5504compDropzone = Class.create(); 5505compDropzone.prototype = { 5506initialize: function( htmlElement , params, dropObjectAppendChild) { 5507this.htmlElement = $(htmlElement); 5508this.absoluteRect = null; 5509this.params = params; 5510if(dropObjectAppendChild == null || dropObjectAppendChild == undefined) 5511this.dropObjectAppendChild = false; 5512else 5513this.dropObjectAppendChild = dropObjectAppendChild; 5514this.showingHover = false; 5515this.ChgSeqHover = null; 5516this.ChgSeqPosition = null; 5517}, 5518setDropObjectAppendChild: function(dropObjectAppendChild) { 5519this.dropObjectAppendChild = dropObjectAppendChild; 5520}, 5521getParams: function() { 5522return this.params; 5523}, 5524getHTMLElement: function() { 5525return this.htmlElement; 5526}, 5527clearPositionCache: function() { 5528this.absoluteRect = null; 5529}, 5530getAbsoluteRect: function() { 5531if ( this.absoluteRect == null ) { 5532var htmlElement = this.getHTMLElement(); 5533var offset = Position.cumulativeOffsetScroll(htmlElement); 5534Position.prepare();//this.deltaY,this.deltaX 5535var pos = {"x":offset[0],"y":offset[1]}; 5536this.absoluteRect = { 5537top: pos.y, 5538left: pos.x, 5539bottom: pos.y + htmlElement.offsetHeight, 5540right: pos.x + htmlElement.offsetWidth 5541}; 5542} 5543return this.absoluteRect; 5544}, 5545activate: function() { 5546var htmlElement = this.getHTMLElement(); 5547if (htmlElement == null || this.showingActive) 5548return; 5549this.showingActive = true; 5550}, 5551deactivate: function() { 5552var htmlElement = this.getHTMLElement(); 5553if (htmlElement == null || !this.showingActive) 5554return; 5555this.showingActive = false; 5556}, 5557showHover: function(e) { 5558var htmlElement = this.getHTMLElement(); 5559if ( this._showHover(htmlElement) ) 5560return; 5561htmlElement.style.backgroundColor = "#ffff99"; 5562}, 5563_showHover: function(htmlElement) { 5564if ( htmlElement == null || this.showingHover ) 5565return false; 5566this.saveHoverBackgroundColor = htmlElement.style.backgroundColor; 5567this.saveHoverBorderWidth = htmlElement.style.borderWidth; 5568this.saveHoverBorderStyle = htmlElement.style.borderStyle; 5569this.saveHoverBorderColor = htmlElement.style.borderColor; 5570this.showingHover = true; 5571return true; 5572}, 5573hideHover: function(e) { 5574var htmlElement = this.getHTMLElement(); 5575if ( this._hideHover(htmlElement) ) 5576return; 5577}, 5578_hideHover: function(htmlElement) { 5579if ( htmlElement == null || !this.showingHover ) 5580return;
5581htmlElement.style.backgroundColor = this.saveHoverBackgroundColor; 5582if(this.saveHoverBorderWidth != "") htmlElement.style.borderWidth = this.saveHoverBorderWidth; 5583if(this.saveHoverBorderStyle != "") htmlElement.style.borderStyle = this.saveHoverBorderStyle; 5584if(this.saveHoverBorderColor != "") htmlElement.style.borderColor = this.saveHoverBorderColor; 5585this.showingHover = false; 5586}, 5587showChgSeqHover: function(event, pos) { 5588var htmlElement = this.getHTMLElement(); 5589var offset = Position.cumulativeOffset(htmlElement); 5590var ex = offset[0]; 5591var ey = offset[1]; 5592var center_y = ey + (htmlElement.offsetHeight/2); 5593var y = Event.pointerY(event); 5594if(this.ChgSeqHover == undefined || this.ChgSeqHover == null) { 5595this.ChgSeqHover = document.createElement("div"); 5596document.body.appendChild(this.ChgSeqHover); 5597} 5598this.ChgSeqHover.style.width = htmlElement.offsetWidth + "px"; 5599this.ChgSeqHover.style.height = "1px"; 5600this.ChgSeqHover.style.position = "absolute"; 5601this.ChgSeqHover.style.left = ex + "px"; 5602commonCls.max_zIndex = commonCls.max_zIndex + 1; 5603this.ChgSeqHover.style.zIndex = commonCls.max_zIndex; 5604if(pos != undefined) { 5605this.ChgSeqPosition = pos; 5606if(pos == "bottom") this.ChgSeqHover.style.top = (ey + htmlElement.offsetHeight) + "px"; 5607else this.ChgSeqHover.style.top = ey + "px"; 5608} else if(y > center_y) { 5609this.ChgSeqPosition = "bottom"; 5610this.ChgSeqHover.style.top = (ey + htmlElement.offsetHeight) + "px"; 5611} else { 5612this.ChgSeqPosition = "top"; 5613this.ChgSeqHover.style.top = ey + "px"; 5614} 5615this.ChgSeqHover.style.borderTop = "3px"; 5616this.ChgSeqHover.style.borderTopStyle = "solid"; 5617this.ChgSeqHover.style.borderTopColor = "#ffff00"; 5618}, 5619showChgSeqHoverInside: function(event) { 5620var htmlElement = this.getHTMLElement(); 5621this.ChgSeqPosition = "inside"; 5622htmlElement.style.backgroundColor = "#ffff99"; 5623}, 5624hideChgSeqHover: function(event) { 5625var htmlElement = this.getHTMLElement(); 5626if ( this._hideHover(htmlElement) ) 5627return; 5628if(this.ChgSeqHover) { 5629Element.remove(this.ChgSeqHover); 5630this.ChgSeqHover = null; 5631this.ChgSeqPosition = null; 5632} 5633}, 5634acceptChgSeq: function(draggableObjects, dropElement, pos) { 5635var htmlElement = this.getHTMLElement(); 5636if ( htmlElement == null ) 5637return; 5638var n = draggableObjects.length; 5639for ( var i = 0 ; i < n ; i++ ) { 5640var theGUI = draggableObjects[i].getDroppedGUI(); 5641if ( Element.getStyle( theGUI, "position" ) == "absolute" ) 5642{ 5643theGUI.style.position = "static"; 5644theGUI.style.top = ""; 5645theGUI.style.left = ""; 5646} 5647if(dropElement) { 5648htmlElement = dropElement; 5649} 5650if(pos) this.ChgSeqPosition = pos; 5651if(this.ChgSeqPosition == "top") { 5652htmlElement.parentNode.insertBefore(theGUI, htmlElement); 5653} else if(this.ChgSeqPosition == "bottom"){ 5654var next_el = htmlElement.nextSibling; 5655if(!next_el) { 5656if(htmlElement.parentNode.tagName.toLowerCase() == "table") { 5657var append_el = document.createElement("tbody"); 5658htmlElement.parentNode.appendChild(append_el); 5659} else { 5660var append_el = htmlElement.parentNode; 5661} 5662append_el.appendChild(theGUI); 5663} else { 5664next_el.parentNode.insertBefore(theGUI, next_el); 5665} 5666} else { 5667var next_el = htmlElement.nextSibling; 5668if(next_el.tagName.toLowerCase() == "table") { 5669var append_el = document.createElement("tbody"); 5670next_el.appendChild(append_el); 5671} else { 5672var append_el = next_el; 5673} 5674append_el.appendChild(theGUI); 5675} 5676commonCls.blockNotice(null, theGUI); 5677} 5678}, 5679canAccept: function(draggableObjects) { 5680return true; 5681}, 5682accept: function(draggableObjects) { 5683var htmlElement = this.getHTMLElement(); 5684if ( htmlElement == null ) 5685return; 5686if(this.dropObjectAppendChild) { 5687var n = draggableObjects.length; 5688for ( var i = 0 ; i < n ; i++ ) 5689{ 5690var theGUI = draggableObjects[i].getDroppedGUI(); 5691if ( Element.getStyle( theGUI, "position" ) == "absolute" ) 5692{ 5693theGUI.style.position = "static"; 5694theGUI.style.top = ""; 5695theGUI.style.left = ""; 5696} 5697htmlElement.appendChild(theGUI); 5698} 5699} 5700}, 5701save: function(draggableObjects) { 5702return true; 5703} 5704}; 5705var compTitleIcon = Class.create(); 5706compTitleIcon.prototype = { 5707initialize: function(id) { 5708this.id = id; 5709this.el = null; 5710this.hidden = null 5711this.popup = null; 5712}, 5713showDialogBox: function(el, hidden) { 5714this.el = el; 5715this.hidden = hidden; 5716commonCls.referComp["compIcon" + this.id] = this; 5717if(!this.popup) { 5718this.popup = new compPopup(this.id); 5719} 5720var params = new Object(); 5721params["param"] = { 5722"action":"comp_textarea_view_insertsmiley", 5723"prefix_id_name":"dialog_insertsmiley",
5724"parent_id_name":"compIcon" + this.id, 5725"_noscript":1}; 5726params["top_el"] = this.id; 5727params["callbackfunc"] = function(res) { 5728this.popup.showPopup(res, this.el); 5729}.bind(this); 5730commonCls.send(params); 5731}, 5732insertImage: function(params) { 5733this.el.src = params["f_url"]; 5734this.el.title = params["f_title"]; 5735this.el.alt = params["f_alt"]; 5736var arr = params["f_url"].split("/"); 5737if (arr[arr.length-1] != "blank.gif") { 5738this.hidden.value = arr[arr.length-2] + "/" + arr[arr.length-1]; 5739} else { 5740this.hidden.value = ""; 5741} 5742this.closePopup(); 5743}, 5744closePopup: function() { 5745if (this.popup) { 5746this.popup.closePopup(); 5747} 5748} 5749} 5750 5751var compLiveGrid = Class.create(); 5752compLiveGrid.prototype = { 5753initialize: function(top_el, visibleRows, totalRows, action_name ,options ) { 5754if(visibleRows > totalRows) { 5755visibleRows = totalRows; 5756} 5757this.top_el = top_el; 5758this.action_name = action_name; 5759this.limit_str = "limit"; 5760this.offset_str = "offset"; 5761this.sort_col_str = "sort_col"; 5762this.sort_dir_str = "sort_dir"; 5763if(action_name != undefined && action_name != null) var prefetchBuffer = true; 5764else var prefetchBuffer = false; 5765this.options = { 5766prefetchBuffer: prefetchBuffer, 5767tableClass: 'grid', 5768scrollerBorderRight: '1px solid #ababab', 5769bufferTimeout: 20000, 5770sort: false, 5771sort_prefix: "_sort_", 5772sortAscendImg: 'http://www.yamatogokin.co.jp/images/comp/livegrid/sort_asc.gif', 5773sortDescendImg: 'http://www.yamatogokin.co.jp/images/comp/livegrid/sort_desc.gif', 5774sortImageWidth: 9, 5775sortImageHeight: 5, 5776onSendCallback: null, 5777onRefreshComplete: null, 5778requestParameters: null 5779}; 5780Object.extend(this.options, options || {}); 5781this.table = Element.getChildElementByClassName(this.top_el,this.options.tableClass); 5782this.addLiveGridHtml(); 5783var rowCount = this.table.rows.length; 5784var columnCount = (rowCount == 0) ? 0 : this.table.rows[0].cells.length; 5785this.metaData = new compLiveGrid.LiveGridMetaData(visibleRows, totalRows, columnCount, this.options); 5786this.buffer = new compLiveGrid.LiveGridBuffer(this.metaData, visibleRows, 0, rowCount, this.table); 5787for (var i=0; i < rowCount; i++) { 5788if(this.table.rows[i]) { 5789if ( !this.options.prefetchBuffer) { 5790this.buffer.rows[i]= true; 5791} 5792this.buffer.value_el_rows[i] = this.table.rows[i]; 5793this.buffer.key_el_rows[this.table.rows[i]] = i; 5794this.buffer.initRow(this.table.rows[i]); 5795if(i > visibleRows - 1) { 5796Element.addClassName(this.table.rows[i],"display-none"); 5797} 5798} 5799} 5800this.viewPort = new compLiveGrid.GridViewPort(this.table, 5801this.table.offsetHeight/visibleRows, 5802visibleRows, 5803this.buffer, this); 5804this.scroller = new compLiveGrid.LiveGridScroller(this, this.viewPort); 5805this.options.sortHandler = this.sortHandler.bind(this); 5806this.table_header = Element.getChildElementByClassName(this.top_el,this.options.tableClass+'_header'); 5807if ( this.table_header ) { 5808if(browser.isIE) { 5809this.table_header.style.width = this.table.offsetWidth + "px"; 5810} 5811if(this.options.sort) { 5812this.sort = new compLiveGrid.LiveGridSort(this.options.tableClass+'_header', this.table_header ,this.options); 5813} 5814for (var i=0,row_len = this.table_header.rows.length; i < row_len; i++) { 5815this.buffer.initRow(this.table_header.rows[i]); 5816} 5817} 5818this.processingRequest = null; 5819if ( this.options.prefetchBuffer) { 5820var offset = 0; 5821if (this.options.offset ) { 5822offset = this.options.offset; 5823this.scroller.moveScroll(offset); 5824this.viewPort.scrollTo(this.scroller.rowToPixel(offset)); 5825} else { 5826this.viewPort.refreshContents(offset); 5827} 5828if (this.options.sortCol) { 5829this.sortCol = options.sortCol; 5830this.sortDir = options.sortDir; 5831} 5832this.requestContentRefresh(offset); 5833} 5834if(browser.isIE) { 5835this.table.style.width = this.table.offsetWidth + "px"; 5836} 5837}, 5838addLiveGridHtml: function() { 5839if (this.table.getElementsByTagName("thead").length > 0){ 5840var tableHeader = this.table.cloneNode(true); 5841tableHeader.setAttribute('class', this.options.tableClass+'_header'); 5842for( var i = 0; i < tableHeader.tBodies.length; i++ ) 5843tableHeader.removeChild(tableHeader.tBodies[i]); 5844this.table.deleteTHead(); 5845this.table.parentNode.insertBefore(tableHeader,this.table); 5846} 5847new Insertion.Before(this.table, "<div class='"+this.options.tableClass+"_container'></div>");
5848this.table.previousSibling.appendChild(this.table); 5849new Insertion.Before(this.table,"<table border='0' cellspacing='0' cellpadding='0' class='"+this.options.tableClass+"_viewport'><tr><td><div></div></td><td class='valign-top'></td></tr></table>"); 5850var table_view = Element.getChildElementByClassName(this.top_el,this.options.tableClass + "_viewport"); 5851var div_el = Element.getChildElement(table_view.rows[0].cells[0]); 5852div_el.appendChild(this.table); 5853}, 5854resetContents: function() { 5855this.scroller.moveScroll(0); 5856this.buffer.clear(); 5857this.viewPort.clearContents(); 5858}, 5859sortHandler: function(column) { 5860if(!column) return ; 5861this.sortCol = column.name; 5862this.sortDir = column.currentSort; 5863this.resetContents(); 5864this.requestContentRefresh(0); 5865}, 5866adjustRowSize: function() { 5867}, 5868setTotalRows: function( newTotalRows, reset_flag ) { 5869if(reset_flag) this.resetContents(); 5870this.totalRows = newTotalRows; 5871if(this.visibleRows > this.totalRows) { 5872this.visibleRows = this.totalRows; 5873this.viewPort.visibleRows = this.visibleRows; 5874} 5875this.metaData.setTotalRows(newTotalRows); 5876this.scroller.updateSize(); 5877}, 5878handleTimedOut: function() { 5879this.processingRequest = null; 5880}, 5881fetchBuffer: function(offset) { 5882if ( this.buffer.isInRange(offset) ) { 5883return; 5884} 5885if (this.processingRequest) { 5886setTimeout( function(){this.fetchBuffer(offset);}.bind(this), 300); 5887return; 5888} 5889var bufferStartPos = this.buffer.getFetchOffset(offset); 5890this.processingRequest = true; 5891var fetchSize = this.buffer.getFetchSize(bufferStartPos); 5892var partialLoaded = false; 5893var queryString; 5894if (this.options.requestParameters) 5895queryString = this._createQueryString(this.options.requestParameters, 0); 5896if(this.action_name == undefined) { 5897return; 5898} 5899queryString = (queryString == null) ? '' : '&'+queryString; 5900queryString = queryString+'&' + this.limit_str + '='+fetchSize+'&' + this.offset_str + '='+bufferStartPos; 5901if (this.sortCol) { 5902queryString = queryString+'&' + this.sort_col_str + '='+escape(this.sortCol)+'&' + this.sort_dir_str + '='+this.sortDir; 5903} 5904var send_params = new Object(); 5905send_params["method"] = "get"; 5906send_params["param"] = this.action_name + queryString; 5907send_params["top_el"] = this.top_el; 5908send_params["eval_flag"] = 0; 5909send_params["callbackfunc"] = function(ajaxResponse){ 5910try { 5911this.buffer.update(ajaxResponse,bufferStartPos); 5912} 5913catch(err) {} 5914finally {this.processingRequest = null;} 5915if(this.options.onSendCallback != null) { 5916this.options.onSendCallback(ajaxResponse, this.action_name + queryString); 5917} 5918}.bind(this); 5919commonCls.send(send_params); 5920},
5921setRequestParams: function() { 5922this.options.requestParameters = []; 5923for ( var i=0 ; i < arguments.length ; i++ ) 5924this.options.requestParameters[i] = arguments[i]; 5925}, 5926requestContentRefresh: function(contentOffset) { 5927this.fetchBuffer(contentOffset); 5928}, 5929_createQueryString: function( theArgs, offset ) { 5930var queryString = "" 5931if (!theArgs) 5932return queryString; 5933for ( var i = offset,theArgs_len = theArgs.length ; i < theArgs_len ; i++ ) { 5934if ( i != offset ) 5935queryString += "&"; 5936var anArg = theArgs[i]; 5937if ( anArg.name != undefined && anArg.value != undefined ) { 5938queryString += anArg.name + "=" + escape(anArg.value); 5939} 5940else { 5941var ePos = anArg.indexOf('='); 5942var argName = anArg.substring( 0, ePos ); 5943var argValue = anArg.substring( ePos + 1 ); 5944queryString += argName + "=" + escape(argValue); 5945} 5946} 5947return queryString; 5948} 5949}; 5950compLiveGrid.LiveGridMetaData = Class.create(); 5951compLiveGrid.LiveGridMetaData.prototype = { 5952initialize: function( pageSize, totalRows, columnCount, options ) { 5953this.pageSize = pageSize; 5954this.totalRows = totalRows; 5955this.setOptions(options); 5956this.ArrowHeight = 16; 5957this.columnCount = columnCount; 5958}, 5959setOptions: function(options) { 5960this.options = { 5961largeBufferSize : 2.0, 5962nearLimitFactor : 0.2 5963}; 5964Object.extend(this.options, options || {}); 5965}, 5966getPageSize: function() { 5967return this.pageSize; 5968}, 5969getTotalRows: function() { 5970return this.totalRows; 5971}, 5972setTotalRows: function(n) { 5973this.totalRows = n; 5974}, 5975getLargeBufferSize: function() { 5976return parseInt(this.options.largeBufferSize * this.pageSize); 5977}, 5978getLimitTolerance: function() { 5979return parseInt(this.getLargeBufferSize() * this.options.nearLimitFactor); 5980} 5981}; 5982compLiveGrid.LiveGridScroller = Class.create(); 5983compLiveGrid.LiveGridScroller.prototype = { 5984initialize: function(liveGrid, viewPort) { 5985this.liveGrid = liveGrid; 5986this.viewPort = viewPort; 5987this.metaData = liveGrid.metaData; 5988this.createScrollBar(); 5989this.scrollTimeout = null; 5990this.lastScrollPos = 0; 5991this.rows = new Array(); 5992this.handleScrollEvent = null; 5993}, 5994isUnPlugged: function() { 5995return this.scrollerDiv.onscroll == null; 5996}, 5997plugin: function() { 5998Event.observe(this.scrollerDiv,"scroll", this.handleScroll.bindAsEventListener(this), false, this.liveGrid.top_el); 5999}, 6000unplug: function() { 6001Event.stopObserving(this.scrollerDiv,"scroll", this.handleScroll.bindAsEventListener(this), false, this.liveGrid.top_el); 6002}, 6003sizeIEHeaderHack: function() { 6004if ( !browser.isIE ) return; 6005var headerTable = this.liveGrid.table_header; 6006if ( headerTable ) 6007headerTable.rows[0].cells[0].style.width = 6008(headerTable.rows[0].cells[0].offsetWidth + 1) + "px"; 6009}, 6010createScrollBar: function() { 6011var visibleHeight = this.liveGrid.viewPort.visibleHeight(); 6012this.scrollerDiv = document.createElement("div"); 6013var scrollerStyle = this.scrollerDiv.style; 6014if(this.viewPort.visibleRows != this.metaData.totalRows) { 6015scrollerStyle.borderRight = this.liveGrid.options.scrollerBorderRight; 6016scrollerStyle.width = "19px"; 6017} else { 6018scrollerStyle.width = "0px"; 6019} 6020scrollerStyle.height = visibleHeight + "px"; 6021scrollerStyle.overflow = "auto"; 6022this.heightDiv = document.createElement("div"); 6023this.heightDiv.style.width = "1px"; 6024var height_buf = parseInt(visibleHeight * 6025this.metaData.getTotalRows()/this.metaData.getPageSize()); 6026if(!isNaN(height_buf) && height_buf != null) this.heightDiv.style.height = height_buf + "px" ; 6027this.plugin(); 6028var table = this.liveGrid.table; 6029if(browser.isIE) { 6030scrollerStyle.overflowY = "scroll"; 6031} 6032table.parentNode.parentNode.parentNode.cells[1].appendChild(this.scrollerDiv); 6033this.scrollerDiv.appendChild(this.heightDiv); 6034if(this.viewPort.visibleRows != this.metaData.totalRows) { 6035var eventName = browser.isIE ? "mousewheel" : "DOMMouseScroll"; 6036Event.observe(table, eventName, 6037function(evt) { 6038if (evt.wheelDelta>=0 || evt.detail < 0) 6039this.scrollerDiv.scrollTop -= (2*this.viewPort.rowHeight); 6040else 6041this.scrollerDiv.scrollTop += (2*this.viewPort.rowHeight); 6042this.handleScroll(false); 6043}.bindAsEventListener(this), 6044false, this.liveGrid.top_el); 6045} 6046}, 6047updateSize: function() { 6048if(this.viewPort.visibleRows == this.metaData.totalRows) { 6049this.scrollerDiv.style.width = "0px"; 6050} 6051this.scrollerDiv.style.height = (this.viewPort.rowHeight * this.viewPort.visibleRows) + "px"; 6052var table = this.liveGrid.table; 6053var visibleHeight = this.viewPort.visibleHeight(); 6054this.heightDiv.style.height = parseInt(visibleHeight * 6055this.metaData.getTotalRows()/this.metaData.getPageSize()) + "px"; 6056}, 6057rowToPixel: function(rowOffset) { 6058return (rowOffset / this.metaData.getTotalRows()) * this.heightDiv.offsetHeight 6059}, 6060moveScroll: function(rowOffset) { 6061this.scrollerDiv.scrollTop = this.rowToPixel(rowOffset); 6062if ( this.metaData.options.onscroll ) 6063this.metaData.options.onscroll( this.liveGrid, rowOffset ); 6064}, 6065handleScroll: function() { 6066if ( this.scrollTimeout ) { 6067clearTimeout( this.scrollTimeout ); 6068} 6069if ( this.handleScrollEvent ) { 6070clearTimeout( this.handleScrollEvent ); 6071} 6072this.handleScrollEvent = setTimeout(this.handleScrollTimer.bind(this), 0 ); 6073}, 6074handleScrollTimer: function() { 6075var scrollDiff = this.lastScrollPos-this.scrollerDiv.scrollTop; 6076if (scrollDiff != 0.00) { 6077var r = this.scrollerDiv.scrollTop % this.viewPort.rowHeight; 6078if (r != 0) { 6079this.unplug(); 6080if ( scrollDiff < 0 ) { 6081this.scrollerDiv.scrollTop += (this.viewPort.rowHeight-r); 6082} else { 6083this.scrollerDiv.scrollTop -= r; 6084} 6085this.plugin(); 6086} 6087} 6088var contentOffset = Math.round(this.scrollerDiv.scrollTop / this.viewPort.rowHeight); 6089this.liveGrid.requestContentRefresh(contentOffset); 6090this.viewPort.scrollTo(this.scrollerDiv.scrollTop); 6091if ( this.metaData.options.onscroll ) 6092this.metaData.options.onscroll( this.liveGrid, contentOffset ); 6093this.scrollTimeout = setTimeout(this.scrollIdle.bind(this), 1200 ); 6094this.lastScrollPos = this.scrollerDiv.scrollTop; 6095}, 6096scrollIdle: function() { 6097if ( this.metaData.options.onscrollidle ) 6098this.metaData.options.onscrollidle(); 6099} 6100}; 6101compLiveGrid.LiveGridBuffer = Class.create(); 6102compLiveGrid.LiveGridBuffer.prototype = { 6103initialize: function(metaData, visibleRows, startPos, size, table) { 6104this.startPos = 0; 6105this.size = size; 6106this.metaData = metaData; 6107this.rows = new Array(); 6108this.value_el_rows= new Array(); 6109this.key_el_rows = new Array(); 6110this.visibleRows = visibleRows; 6111this.width_buf = new Object(); 6112this.table = table; 6113this.maxFetchSize = metaData.getLargeBufferSize(); 6114if(this.table.rows[0]) { 6115this.clone_row = this.table.rows[0].cloneNode(true); 6116var class_name = this.clone_row.className; 6117if(class_name) { 6118var class_arr = class_name.split(/\s+/); 6119var add_class_arr = new Array(); 6120class_arr.each(function(name) { 6121if(name.match(/^grid_.*/)) { 6122this.push(name); 6123} 6124}.bind(add_class_arr)); 6125this.clone_row.className = add_class_arr.join(' '); 6126} 6127this.initRow(this.clone_row, true); 6128} 6129},
6130update: function(ajaxResponse, start) { 6131var tbody = Element.getChildElement(this.table); 6132if(tbody == null || tbody.tagName.toLowerCase() != "tbody") { 6133tbody = this.table; 6134} 6135if(typeof ajaxResponse == 'string') { 6136if(ajaxResponse != "") {alert(ajaxResponse);} 6137return false; 6138} else { 6139var lists = Element.getChildElement(ajaxResponse); 6140var child_len=lists.childNodes.length; 6141for (var i = 0; i < child_len; i++) { 6142var table_row_el = this.value_el_rows[start+i]; 6143var row_el = lists.childNodes[i]; 6144var class_name = Element.readAttribute(row_el, "class"); 6145if(class_name) { 6146Element.addClassName(table_row_el, class_name); 6147} 6148var id = Element.readAttribute(row_el, "id"); 6149if(id) { 6150table_row_el.id = id; 6151} 6152if(row_el) { 6153for (var j = 0,cell_len=row_el.childNodes.length; j < cell_len; j++) { 6154var cell_el = row_el.childNodes[j]; 6155var class_name = Element.readAttribute(cell_el, "class"); 6156if(class_name) { 6157Element.addClassName(table_row_el.childNodes[j], class_name); 6158} 6159var text = ""; 6160if(cell_el.firstChild != null) {text = cell_el.firstChild.nodeValue;} 6161Element.getChildElement(table_row_el.childNodes[j]).innerHTML = cell_el.textContent || cell_el.text || text; 6162} 6163this.rows[start+i] = true; 6164} 6165} 6166} 6167this.size = start + child_len; 6168}, 6169clear: function() { 6170this.rows = new Array(); 6171this.startPos = 0; 6172this.size = 0; 6173}, 6174isInRange: function(position) { 6175var end_position = position + this.metaData.getPageSize() - 1; 6176if(end_position > this.metaData.getTotalRows() - 1) { 6177end_position = this.metaData.getTotalRows() - 1; 6178} 6179var now_pos = position; 6180while (this.rows[now_pos]) { 6181if(now_pos == end_position) return true; 6182now_pos++; 6183} 6184return false; 6185}, 6186isNearingTopLimit: function(position) { 6187return position - this.startPos < this.metaData.getLimitTolerance(); 6188}, 6189endPos: function() { 6190return this.table.rows.length; 6191}, 6192isNearingBottomLimit: function(position) { 6193return this.endPos() - (position + this.metaData.getPageSize()) < this.metaData.getLimitTolerance(); 6194}, 6195isAtTop: function() { 6196return this.startPos == 0; 6197}, 6198isAtBottom: function() { 6199return this.endPos() == this.metaData.getTotalRows(); 6200}, 6201isNearingLimit: function(position) { 6202return ( !this.isAtTop() && this.isNearingTopLimit(position)) || 6203( !this.isAtBottom() && this.isNearingBottomLimit(position) ); 6204}, 6205getFetchSize: function(offset) { 6206var adjustedOffset = offset; 6207var adjustedSize = 0; 6208var endFetchOffset = this.maxFetchSize + adjustedOffset; 6209if (endFetchOffset > this.metaData.totalRows) { 6210if(this.metaData.totalRows > 0) { 6211endFetchOffset = this.metaData.totalRows; 6212} 6213} 6214if(this.rows[endFetchOffset]) { 6215var row_num = endFetchOffset - 1; 6216while (this.rows[row_num]) { 6217row_num--; 6218if(row_num < adjustedOffset) { 6219return 1; 6220} 6221} 6222endFetchOffset = row_num + 1; 6223} 6224adjustedSize = endFetchOffset - adjustedOffset; 6225return adjustedSize; 6226}, 6227getFetchOffset: function(offset) { 6228var adjustedOffset = offset; 6229if(this.rows[adjustedOffset]) { 6230var row_num = adjustedOffset + 1; 6231while (this.rows[row_num]) { 6232row_num++; 6233if(row_num > this.metaData.getTotalRows() - 1) { 6234return offset; 6235} 6236} 6237adjustedOffset = row_num; 6238} 6239return adjustedOffset; 6240}, 6241convertSpaces: function(s) { 6242return s.split(" ").join(" "); 6243}, 6244initRow: function(htmlRow, clone_flag) { 6245for (var j=0,row_len=htmlRow.childNodes.length; j < row_len; j++) { 6246var child_el = Element.getChildElement(htmlRow.childNodes[j]); 6247if(!child_el || child_el.tagName.toLowerCase() != 'div' || Element.getStyle( child_el, "overflow" ) != "hidden") { 6248if((browser.isIE || browser.isSafari) && clone_flag) { 6249this.appendDivElement(htmlRow.childNodes[j], this.table.rows[0].childNodes[j]); 6250} else { 6251this.appendDivElement(htmlRow.childNodes[j]); 6252} 6253child_el = Element.getChildElement(htmlRow.childNodes[j]); 6254} 6255if(child_el && clone_flag) { 6256child_el.innerHTML = ""; 6257} 6258} 6259}, 6260appendDivElement: function(el, first_el) { 6261if(el.className != "") { 6262if(this.width_buf[el.className]) { 6263var width = this.width_buf[el.className]; 6264} else { 6265var width = valueParseInt(Element.getStyle( el, "width" )); 6266this.width_buf[el.className] = width; 6267} 6268} else { 6269var width = valueParseInt(Element.getStyle( el, "width" )); 6270} 6271if(width == 0 && first_el) { 6272var width = valueParseInt(Element.getStyle( first_el, "width" )); 6273this.width_buf[el.className] = width; 6274} 6275var child_el = document.createElement("div"); 6276var children_length = el.childNodes.length; 6277var el_arr = new Object; 6278for (var k = 0; k < children_length; k++) { 6279var child = el.childNodes[k]; 6280if (child.nodeType == 1) { 6281el_arr[k] = child; 6282} else if(child.nodeType == 3) { 6283el_arr[k] = document.createTextNode(child.nodeValue); 6284child.nodeValue = ""; 6285} 6286} 6287el.appendChild(child_el); 6288for (var k = 0; k < children_length; k++) {
6289child_el.appendChild(el_arr[k]); 6290} 6291this.divAddStyle(child_el, el, width); 6292}, 6293divAddStyle: function(el, parent_el, parent_width) { 6294var width = parent_width; 6295el.style.width = width + "px"; 6296el.style.overflow = "hidden"; 6297el.style.whiteSpace = "nowrap"; 6298} 6299}; 6300compLiveGrid.GridViewPort = Class.create(); 6301compLiveGrid.GridViewPort.prototype = { 6302initialize: function(table, rowHeight, visibleRows, buffer, liveGrid) { 6303rowHeight = (isNaN(rowHeight) || rowHeight == null || rowHeight == undefined) ? 0 : rowHeight; 6304this.lastDisplayedStartPos = 0; 6305this.div = table.parentNode; 6306this.table = table 6307this.rowHeight = rowHeight; 6308this.div.style.whiteSpace = "nowrap"; 6309this.buffer = buffer; 6310this.liveGrid = liveGrid; 6311this.visibleRows = visibleRows; 6312this.lastPixelOffset = 0; 6313this.startPos = 0; 6314this.lastStartPos = 0; 6315if(liveGrid.options.prefetchBuffer) { 6316this.isBlank = true; 6317} else { 6318this.isBlank = false; 6319} 6320}, 6321bufferChanged: function() { 6322var offset = Math.round(this.lastPixelOffset / this.rowHeight); 6323if(offset + this.visibleRows > this.liveGrid.metaData.getTotalRows()) { 6324offset = this.liveGrid.metaData.getTotalRows() - this.visibleRows; 6325} 6326this.refreshContents(offset); 6327}, 6328clearRows: function() { 6329for (var i = 0,child_len = this.liveGrid.table.rows.length; i < child_len; i++) { 6330var row_el = this.liveGrid.table.rows[i]; 6331if(row_el) { 6332if(Element.hasClassName(row_el,"display-none")) { 6333row_el.className = this.liveGrid.buffer.clone_row.className + " display-none"; 6334} else { 6335row_el.className = this.liveGrid.buffer.clone_row.className; 6336} 6337for (var j = 0,cell_len=row_el.childNodes.length; j < cell_len; j++) { 6338var cell_el = row_el.childNodes[j]; 6339var grid_cell_el = this.liveGrid.buffer.clone_row.childNodes[j]; 6340cell_el.className = grid_cell_el.className; 6341var child_el = Element.getChildElement(cell_el)
6342if(child_el) child_el.innerHTML = ""; 6343} 6344} 6345} 6346this.liveGrid.buffer.rows = new Array(); 6347}, 6348clearContents: function() { 6349this.clearRows(); 6350this.isBlank = true; 6351this.scrollTo(0); 6352this.startPos = 0; 6353this.lastStartPos = 0; 6354}, 6355refreshContents: function(startPos) { 6356if (startPos == this.lastStartPos && !this.isPartialBlank && !this.isBlank) { 6357return; 6358} 6359var contentStartPos = startPos; 6360var contentEndPos = startPos + this.visibleRows; 6361var rowSize = contentEndPos - contentStartPos; 6362var blankSize = this.visibleRows - rowSize; 6363var lastRowPosLen = this.lastStartPos + this.visibleRows; 6364for (var i=this.lastStartPos; i < lastRowPosLen; i++) { 6365Element.addClassName(this.buffer.value_el_rows[i],"display-none"); 6366} 6367var fetchSize = this.buffer.maxFetchSize; 6368var lastRowPosLen = startPos + fetchSize; 6369if(lastRowPosLen > this.liveGrid.metaData.getTotalRows()) { 6370lastRowPosLen = this.liveGrid.metaData.getTotalRows(); 6371} 6372var insert_row = -1; 6373for (var i=startPos; i < lastRowPosLen; i++) { 6374var insert_flag = false; 6375if(this.buffer.value_el_rows[i]) { 6376var table_row_el = this.buffer.value_el_rows[i]; 6377} else { 6378if(this.table.rows[i]) { 6379if(this.isBlank == false && this.buffer.key_el_rows[this.table.rows[i]] != i) { 6380insert_flag = true; 6381} else { 6382var table_row_el = this.table.rows[i]; 6383} 6384} else { 6385insert_flag = true; 6386} 6387if(insert_flag) { 6388if(insert_row == -1) { 6389var rows_len = this.table.rows.length; 6390if(rows_len < i) { 6391var insert_row = rows_len; 6392} else { 6393var insert_row = i; 6394} 6395while (this.buffer.key_el_rows[this.table.rows[insert_row - 1]] > i) { 6396insert_row--; 6397if(insert_row == 0) { 6398break; 6399} 6400} 6401} 6402var table_row_el = this.table.insertRow(insert_row); 6403insert_row++; 6404for (var j = 0,cells_len = this.buffer.clone_row.childNodes.length; j < cells_len; j++) { 6405var insert_td = table_row_el.insertCell(j); 6406insert_td.className = this.buffer.clone_row.childNodes[j].className; 6407insert_td.innerHTML = this.buffer.clone_row.childNodes[j].innerHTML; 6408} 6409} 6410this.buffer.value_el_rows[i] = table_row_el; 6411this.buffer.key_el_rows[table_row_el] = i; 6412} 6413if(table_row_el.className == "") { 6414table_row_el.className = this.buffer.clone_row.className; 6415} 6416if(i < startPos + this.visibleRows) { 6417Element.removeClassName(table_row_el,"display-none"); 6418} else { 6419Element.addClassName(table_row_el,"display-none"); 6420} 6421} 6422this.isBlank = false; 6423this.isPartialBlank = blankSize > 0; 6424this.lastStartPos = startPos; 6425Element.addClassName(this.liveGrid.table,this.liveGrid.options.tableClass); 6426var onRefreshComplete = this.liveGrid.options.onRefreshComplete; 6427if (onRefreshComplete != null) 6428onRefreshComplete(); 6429}, 6430scrollTo: function(pixelOffset) { 6431if (this.lastPixelOffset == pixelOffset) 6432return; 6433var offset = Math.round(pixelOffset / this.rowHeight); 6434if(offset + this.visibleRows > this.liveGrid.metaData.getTotalRows()) { 6435offset = this.liveGrid.metaData.getTotalRows() - this.visibleRows; 6436} 6437this.refreshContents(offset); 6438this.div.scrollTop = pixelOffset % this.rowHeight; 6439this.lastPixelOffset = pixelOffset; 6440}, 6441visibleHeight: function() { 6442return parseInt(Element.getStyle(this.div, 'height')); 6443} 6444}; 6445compLiveGrid.LiveGridSort = Class.create(); 6446compLiveGrid.LiveGridSort.prototype = { 6447initialize: function(headerTableId, headerTable, options) { 6448this.headerTableId = headerTableId; 6449this.headerTable = headerTable; 6450this.options = options; 6451this.setOptions(); 6452this.applySortBehavior(); 6453if ( this.options.sortCol ) { 6454this.setSortUI( this.options.sortCol, this.options.sortDir ); 6455} 6456}, 6457setSortUI: function( columnName, sortDirection ) { 6458var cols = this.options.columns; 6459for ( var i = 0 ; i < cols.length ; i++ ) { 6460if ( cols[i].name == columnName ) { 6461this.setColumnSort(i, sortDirection); 6462break; 6463} 6464} 6465}, 6466setOptions: function() { 6467new Image().src = this.options.sortAscendImg; 6468new Image().src = this.options.sortDescendImg; 6469this.sort = this.options.sortHandler; 6470if ( !this.options.columns ) 6471this.options.columns = this.introspectForColumnInfo(); 6472else { 6473this.options.columns = this.convertToTableColumns(this.options.columns); 6474} 6475}, 6476applySortBehavior: function() { 6477var tdList = this.headerTable.getElementsByTagName("th"); 6478if(tdList.length == 0) { 6479tdList = this.headerTable.getElementsByTagName("td"); 6480} 6481for (var i = 0,tdLen = tdList.length; i < tdLen; i++){ 6482this.addSortBehaviorToColumn( i, tdList[i] ); 6483} 6484}, 6485addSortBehaviorToColumn: function( n, cell ) { 6486if ( this.options.columns[n].isSortable() ) { 6487cell.id = this.headerTableId + '_' + n; 6488cell.style.cursor = 'pointer'; 6489cell.onclick = this.headerCellClicked.bindAsEventListener(this); 6490Element.addClassName(cell, "grid_sort"); 6491var child_el = Element.getChildElement(cell); 6492if(child_el) { 6493child_el.innerHTML = child_el.innerHTML + '<span class="' + this.headerTableId + '_img_' + n + '">' 6494+ ' </span>'; 6495} else { 6496cell.innerHTML = cell.innerHTML + '<span class="' + this.headerTableId + '_img_' + n + '">' 6497+ ' </span>'; 6498} 6499} 6500}, 6501headerCellClicked: function(evt) { 6502var eventTarget = evt.target ? evt.target : evt.srcElement; 6503while (eventTarget.tagName.toLowerCase() != "td" && eventTarget.tagName.toLowerCase() != "th") { 6504eventTarget = eventTarget.parentNode; 6505} 6506var cellId = eventTarget.id; 6507var columnNumber = parseInt(cellId.substring( cellId.lastIndexOf('_') + 1 ));
6508var sortedColumnIndex = this.getSortedColumnIndex(); 6509if ( sortedColumnIndex != -1 ) { 6510if ( sortedColumnIndex != columnNumber ) { 6511this.removeColumnSort(sortedColumnIndex); 6512this.setColumnSort(columnNumber, compLiveGrid.TableColumn.SORT_ASC); 6513} else { 6514this.toggleColumnSort(sortedColumnIndex); 6515} 6516} else { 6517this.setColumnSort(columnNumber, compLiveGrid.TableColumn.SORT_ASC); 6518} 6519if (this.options.sortHandler) { 6520this.options.sortHandler(this.options.columns[columnNumber]); 6521} 6522}, 6523removeColumnSort: function(n) { 6524this.options.columns[n].setUnsorted(); 6525this.setSortImage(n); 6526}, 6527setColumnSort: function(n, direction) { 6528if(isNaN(n)) return ; 6529this.options.columns[n].setSorted(direction); 6530this.setSortImage(n); 6531}, 6532toggleColumnSort: function(n) { 6533this.options.columns[n].toggleSort(); 6534this.setSortImage(n); 6535}, 6536setSortImage: function(n) { 6537var sortDirection = this.options.columns[n].getSortDirection(); 6538var sortImageSpan = Element.getChildElementByClassName(this.headerTable, this.headerTableId + '_img_' + n); 6539if ( sortDirection == compLiveGrid.TableColumn.UNSORTED ) 6540sortImageSpan.innerHTML = ' '; 6541else if ( sortDirection == compLiveGrid.TableColumn.SORT_ASC ) 6542sortImageSpan.innerHTML = ' <img width="' + this.options.sortImageWidth + '" ' + 6543'height="'+ this.options.sortImageHeight + '" ' + 6544'src="' + this.options.sortAscendImg + '"/>'; 6545else if ( sortDirection == compLiveGrid.TableColumn.SORT_DESC ) 6546sortImageSpan.innerHTML = ' <img width="' + this.options.sortImageWidth + '" ' + 6547'height="'+ this.options.sortImageHeight + '" ' + 6548'src="' + this.options.sortDescendImg + '"/>'; 6549}, 6550getSortedColumnIndex: function() { 6551var cols = this.options.columns; 6552for ( var i = 0 ; i < cols.length ; i++ ) { 6553if ( cols[i].isSorted() ) 6554return i; 6555} 6556return -1; 6557}, 6558introspectForColumnInfo: function() { 6559var columns = new Array(); 6560var tdList = this.headerTable.getElementsByTagName("th"); 6561if(tdList.length == 0) { 6562tdList = this.headerTable.getElementsByTagName("td"); 6563} 6564for (var i = 0,tdLen = tdList.length; i < tdLen; i++){ 6565cellContent = this.deriveColumnNameFromCell(tdList[i]); 6566if(cellContent) { 6567columns.push( new compLiveGrid.TableColumn( cellContent, true ) ); 6568} else { 6569columns.push( new compLiveGrid.TableColumn( cellContent, false ) ); 6570} 6571} 6572return columns; 6573}, 6574convertToTableColumns: function(cols) { 6575var columns = new Array(); 6576for ( var i = 0 ; i < cols.length ; i++ ) 6577columns.push( new compLiveGrid.TableColumn( cols[i][0], cols[i][1] ) ); 6578return columns; 6579}, 6580deriveColumnNameFromCell: function(cell) { 6581var className = cell.className.split(" ")[0]; 6582var re_cut = new RegExp("^" + this.options.sort_prefix, "i"); 6583if(className.match(re_cut)) { 6584var name = className.replace(re_cut,""); 6585if(name != "") { 6586return name.toLowerCase(); 6587} 6588} 6589return null; 6590} 6591}; 6592compLiveGrid.TableColumn = Class.create(); 6593compLiveGrid.TableColumn.UNSORTED = 0; 6594compLiveGrid.TableColumn.SORT_ASC = "ASC"; 6595compLiveGrid.TableColumn.SORT_DESC = "DESC"; 6596compLiveGrid.TableColumn.prototype = { 6597initialize: function(name, sortable) { 6598this.name = name; 6599this.sortable = sortable; 6600this.currentSort = compLiveGrid.TableColumn.UNSORTED; 6601}, 6602isSortable: function() { 6603return this.sortable; 6604}, 6605isSorted: function() { 6606return this.currentSort != compLiveGrid.TableColumn.UNSORTED; 6607}, 6608getSortDirection: function() { 6609return this.currentSort; 6610}, 6611toggleSort: function() { 6612if ( this.currentSort == compLiveGrid.TableColumn.UNSORTED || this.currentSort == compLiveGrid.TableColumn.SORT_DESC ) 6613this.currentSort = compLiveGrid.TableColumn.SORT_ASC; 6614else if ( this.currentSort == compLiveGrid.TableColumn.SORT_ASC ) 6615this.currentSort = compLiveGrid.TableColumn.SORT_DESC; 6616}, 6617setUnsorted: function(direction) { 6618this.setSorted(compLiveGrid.TableColumn.UNSORTED); 6619}, 6620setSorted: function(direction) { 6621this.currentSort = direction; 6622} 6623}; 6624compPopup = Class.create(); 6625compPopup.prototype = { 6626initialize: function(id, popupID) { 6627this.id = id; 6628this.IDPrefix = "popup"; 6629this.popupID = (popupID) ? this.IDPrefix + popupID : this.IDPrefix; 6630this.IDNone = false; 6631this.src = null; 6632this.popupElement = null; 6633if(this.popupID) { 6634var popupElement = $(this.popupID); 6635if(popupElement && popupElement.contentWindow) { 6636this.popupElement = popupElement; 6637} 6638} 6639this.classNames = new Array("popupIframe"); 6640this.iframeAttributes = { 6641marginHeight:"0px", 6642marginWidth:"0px", 6643frameBorder:"0", 6644scrolling:"no" 6645}; 6646this.posCenter = false;
6647this.position = new Array(null, null); 6648this.topOverlap = 3; 6649this.cssFiles = new Array(); 6650this.jsFiles = new Array(); 6651this.observing = true; 6652this.observer = this._closePopupObserver.bindAsEventListener(this); 6653this.loadObserver = null; 6654this.head_title = "Popup Dialog"; 6655this.popup_width = 0; 6656this.popup_height = 0; 6657this.modal = true; 6658this.allowTransparency = false; 6659this._loadEventFunc = null; 6660this.showPopupFlag = false; 6661}, 6662showPopup: function(targetElement, eventElement) { 6663if(commonCls.referComp["comp_popup"+this.id + this.popupID] == true) { 6664return; 6665} 6666commonCls.referComp["comp_popup"+this.id + this.popupID] = true; 6667if(targetElement && typeof targetElement != 'string') { 6668targetElement.style.display = (!(browser.isIE) && targetElement.tagName == "TABLE") ? "table" : "block"; 6669} 6670if (!this.popupElement) { 6671this.createPopup(); 6672} else { 6673var visible_flag = true; 6674if(this.src != null) { 6675if(this.src != this.popupElement.src) { 6676this.popupElement.src = this.src; 6677this.popupElement.contentWindow.document.body.innerHTML = ""; 6678this.popupElement.contentWindow.location.reload(); 6679} else { 6680this.popupElement.style.visibility = "visible"; 6681} 6682} 6683} 6684if(browser.isGecko) { 6685if(this.src != null && this.src != this.popupElement.src) this.popupElement.style.visibility = "hidden"; 6686this.popupElement.onload = function() { 6687this.popupElement.style.visibility = "visible"; 6688setTimeout(function() { 6689this.resize(); 6690if(this.posCenter) { 6691commonCls.popup.setPosition(commonCls.getCenterPosition(this.popupElement)); 6692} 6693}.bind(this), 300); 6694}.bind(this); 6695} 6696if(browser.isSafari) { 6697this.popupElement.style.visibility = "visible"; 6698setTimeout(function() { 6699this.resize(); 6700if(this.posCenter) { 6701commonCls.popup.setPosition(commonCls.getCenterPosition(this.popupElement)); 6702} 6703}.bind(this), 300); 6704} 6705if(this.posCenter) { 6706} else if (eventElement) { 6707this.setEventPosition(eventElement); 6708} else { 6709this.setPosition(this.position); 6710} 6711if (visible_flag && browser.isIE) { 6712this.popupElement.style.display = (!(browser.isIE) && this.popupElement.tagName == "TABLE") ? "table" : "block"; 6713this.popupElement.style.visibility = "visible"; 6714} 6715if(this.src == null) { 6716this.setHTMLText(targetElement); 6717} 6718var div = $("_global_modal_dialog"); 6719if(this.modal && !div) { 6720div = document.createElement("DIV"); 6721div.id = "_global_modal_dialog"; 6722if(this.id) { 6723var top_el = $(this.id); 6724} 6725if(top_el) { 6726if(top_el.tagName == "TABLE") { 6727Element.getChildElement(top_el, 3).appendChild(div); 6728} else { 6729top_el.appendChild(div); 6730} 6731} else { 6732document.body.appendChild(div); 6733} 6734commonCls.showModal(null, div); 6735} 6736if(this.observing) { 6737if(this.modal) { 6738Event.observe(div, "mousedown", this.observer, false, $(this.id)); 6739} else { 6740Event.observe(document, "mousedown", this.observer, false, $(this.id)); 6741} 6742} 6743commonCls.max_zIndex = commonCls.max_zIndex + 1; 6744this.popupElement.style.zIndex = commonCls.max_zIndex; 6745commonCls.referComp["comp_popup"+this.id + this.popupID] = false; 6746}, 6747showSrcPopup: function(src, eventElement) { 6748this.src = src; 6749this.showPopup(null, eventElement); 6750}, 6751createPopup: function() { 6752if (!this.IDNone) { 6753var popupElement = $(this.popupID); 6754if (popupElement) { 6755this.popupElement = popupElement; 6756return; 6757} 6758} 6759this.popupElement = document.createElement("iframe"); 6760if(browser.isIE && browser.version >= 7 || this.allowTransparency)this.popupElement.allowTransparency="true"; 6761if (!this.IDNone) { 6762this.popupElement.id = this.popupID; 6763} 6764for (var i = 0; i < this.classNames.length; i++) { 6765Element.addClassName(this.popupElement, this.classNames[i]); 6766} 6767for (var i in this.iframeAttributes) { 6768this.popupElement[i] = this.iframeAttributes[i]; 6769} 6770if(this.id) { 6771var top_el = $(this.id); 6772} 6773if(top_el) { 6774if(top_el.tagName == "TABLE") { 6775Element.getChildElement(top_el, 3).appendChild(this.popupElement); 6776} else { 6777top_el.appendChild(this.popupElement); 6778} 6779} else { 6780document.body.appendChild(this.popupElement); 6781} 6782if(this.src != null) this.popupElement.src = this.src; 6783}, 6784setHTMLText: function(targetElement) { 6785var html = document.getElementsByTagName("html")[0]; 6786var htmlAttr = "xmlns=\"" + html.getAttribute("xmlns") + "\" "; 6787htmlAttr += "xml:lang=\"" + html.getAttribute("xml:lang") + "\" "; 6788htmlAttr += "lang=\"" + html.getAttribute("lang") + "\""; 6789var head = document.getElementsByTagName("head")[0]; 6790var links = head.getElementsByTagName("link"); 6791var titleText = ""; 6792var linkText = ""; 6793if(this.head_title != "") { 6794titleText = "<title>" + this.head_title + "</title>\n" 6795} 6796for (var i = 0; i < links.length; i++) { 6797var link = links[i]; 6798if (link.getAttribute("rel") == "stylesheet") { 6799linkText += "<link "; 6800linkText += "rel=\"" + link.getAttribute("rel") + "\" "; 6801linkText += "type=\"" + "text/css" + "\" "; 6802if(link.getAttribute("media")) { 6803linkText += "media=\"" + link.getAttribute("media") + "\" "; 6804} else { 6805linkText += "media=\"screen\" "; 6806} 6807linkText += "href=\"" + link.getAttribute("href") + "\" "; 6808linkText += "/>
6808\n"; 6809} 6810} 6811for (var i = 0; i < this.cssFiles.length; i++) { 6812var link = this.cssFiles[i]; 6813linkText += "<link "; 6814linkText += "rel=\"stylesheet\" "; 6815linkText += "type=\"text/css\" "; 6816linkText += "media=\"" + link[1] + "\" "; 6817linkText += "href=\"" + link[0] + "\" "; 6818linkText += "/>\n"; 6819} 6820var text = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; 6821text += "<html " + htmlAttr + ">\n"; 6822text += "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">" + titleText + linkText + "</head>\n"; 6823text += "<body style=\"background-color:transparent;\">\n"; 6824if (typeof targetElement == 'string') { 6825text += targetElement + "\n"; 6826} else { 6827if(targetElement.nodeName.toLowerCase() != "script") { 6828text += "<" + targetElement.nodeName; 6829for (var i = 0; i < targetElement.attributes.length; i++) { 6830var attribute = targetElement.attributes[i]; 6831if (attribute.nodeName != "style") { 6832var value = attribute.nodeValue; 6833} else { 6834var value = targetElement.style.cssText; 6835} 6836if(browser.isIE) { 6837if(attribute.nodeName == "_extended" || value == null || value == "" || typeof value=="function") { 6838continue; 6839} 6840} 6841text += " " + attribute.name + "=\"" + value + "\""; 6842} 6843text += ">\n"; 6844text += targetElement.innerHTML.replace(/[\r\n\t]/g, ""); 6845text += "</" + targetElement.nodeName + ">\n"; 6846} 6847} 6848text += "</body>\n"; 6849text += "</html>"; 6850text += "<script>"; 6851text += "function popup_resize(){"; 6852text += "var targetElement = document.body.firstChild;"; 6853text += "while (targetElement.nodeType != 1) {"; 6854text += "targetElement = targetElement.nextSibling;"; 6855text += "}"; 6856text += "targetElement.style.display=(!(parent.browser.isIE) && targetElement.tagName=='TABLE')?'table':'block';"; 6857text += "window.frameElement.width = targetElement.offsetWidth + 'px';"; 6858text += "window.frameElement.height = targetElement.offsetHeight + 'px';"; 6859text += "targetElement.style.visibility = 'visible';"; 6860text += "window.frameElement.style.visibility = 'visible';"; 6861text += "}"; 6862text += "setTimeout(popup_resize, 300);"; 6863text += "</script>"; 6864this.popupElement.contentWindow.document.open(); 6865this.popupElement.contentWindow.document.write(text); 6866this.popupElement.contentWindow.document.close(); 6867this._loadEventFunc = this.loadEvent.bindAsEventListener(this); 6868if(browser.isIE || browser.isSafari) { 6869setTimeout(this._loadEventFunc, 500); 6870} else { 6871Event.observe(this.popupElement,"load",this._loadEventFunc, false, this.id); 6872} 6873}, 6874loadEvent: function(event){ 6875if(browser.isIE || browser.isSafari) { 6876try{ 6877var tmp = this.popupElement.contentWindow.document; 6878if(tmp == undefined || tmp == null) { 6879setTimeout(this._loadEventFunc, 500); 6880return; 6881} 6882} catch(e) { 6883setTimeout(this._loadEventFunc, 500); 6884return; 6885} 6886} 6887if(!this.popupElement.contentWindow || !this.popupElement.contentWindow.document || 6888this.popupElement.contentWindow.document.body.innerHTML.strip() == "") { 6889setTimeout(this._loadEventFunc, 500); 6890return; 6891} 6892if(typeof this.loadObserver == 'function') { 6893this.loadObserver(event); 6894} 6895Event.stopObserving(this.popupElement,"load", this._loadEventFunc, false); 6896}, 6897stopLoadEvent: function(event){ 6898if(this.loadObserver && !(browser.isIE || browser.isSafari)) { 6899Event.stopObserving(this.popupElement,"load", this._loadEventFunc, false); 6900} 6901this.loadObserver = null; 6902}, 6903_closePopupObserver: function(event){ 6904this.closePopupAll(event); 6905}, 6906closePopup: function(iframe){ 6907iframe = (iframe == undefined || iframe == null) ? this.popupElement : iframe; 6908if (iframe) { 6909var div = $("_global_modal_dialog"); 6910if(div) { 6911commonCls.stopModal(div); 6912Element.remove(div); 6913} 6914if(browser.isIE) iframe.style.display = "none"; 6915iframe.style.visibility = "hidden"; 6916} 6917if(this.observer != null) { 6918if(this.modal) { 6919Event.stopObserving(div, "mousedown", this.observer, false); 6920} else { 6921Event.stopObserving(document, "mousedown", this.observer, false); 6922} 6923} 6924}, 6925closePopupAll: function(event){ 6926var iframes = document.body.getElementsByTagName("iframe"); 6927for (var i = 0; i < iframes.length; i++) { 6928if (iframes[i].id.substr(0, this.IDPrefix.length) == this.IDPrefix && !Element.hasClassName(iframes[i], "visible-hide")) { 6929this.closePopup(iframes[i]); 6930} 6931} 6932}, 6933resize: function() { 6934if (!this.popupElement) { 6935return; 6936} 6937try{ 6938var targetElement = this.popupElement.contentWindow.document.body.firstChild; 6939if(!targetElement) { 6940return; 6941} 6942} catch(e) { 6943setTimeout(function() {this.resize();}.bind(this), 300); 6944return; 6945} 6946while (targetElement.nodeType != 1) { 6947targetElement = targetElement.nextSibling; 6948} 6949this.popupElement.width = targetElement.offsetWidth + 'px'; 6950this.popupElement.height = targetElement.offsetHeight + 'px'; 6951var position = new Array(); 6952var popupX2 = this.popupElement.offsetLeft + this.popupElement.offsetWidth; 6953var bodyX2 = Position.getWinOuterWidth() + document.documentElement.scrollLeft; 6954if (popupX2 > bodyX2) { 6955position[0] = this.popupElement.offsetLeft - (popupX2 - bodyX2); 6956if (position[0] < 0) { 6957position[0] = 0; 6958} 6959position[1] = this.popupElement.offsetTop; 6960this.setPosition(position); 6961} 6962}, 6963addClassNames: function(className) { 6964if (this.popupElement) { 6965Element.addClassName(this.popupElement, className); 6966} 6967this.classNames.push(className); 6968}, 6969addCSSFiles: function(cssFile, media) { 6970if (!media) { 6971media = "all"; 6972} 6973this.cssFiles.push(new Array(cssFile, media)); 6974}, 6975setIframeAttributes: function(iframeAttributes) { 6976if (this.popupElement) { 6977for (var i in iframeAttributes) { 6978this.popupElement[i] = iframeAttributes[i]; 6979} 6980} 6981Object.extend(this.iframeAttributes, iframeAttributes || {}); 6982}, 6983setIDNone: function() { 6984if (this.popupElement) { 6985this.popupElement.id = null; 6986} 6987this.IDNone = true; 6988}, 6989setObserving: function(value) { 6990this.observing = value; 6991}, 6992setPosition: function(position) { 6993if (this.popupElement) { 6994this.popupElement.style.left = position[0] + "px"; 6995this.popupElement.style.top = position[1] + "px"; 6996} 6997this.position = position; 6998}, 6999setEventPosition: function(eventElement) { 7000if(eventElement.tagName == "INPUT" && eventElement.type == "text") { 7001var offset = Position.cumulativeOffsetScroll(eventElement); 7002} else { 7003var offset = Position.positionedOffsetScroll(eventElement); 7004} 7005var position = new Array(); 7006position[0] = offset[0]; 7007position[1] = offset[1] + eventElement.offsetHeight - this.topOverlap; 7008this.setPosition(position); 7009}, 7010setParentPosition: function(parentElement) { 7011var offset = Position.cumulativeOffset(parentElement); 7012this.setPosition(offset); 7013}, 7014setLapPosition: function(eventElement, parentElement) { 7015var offset = Position.cumulativeOffset(eventElement); 7016var parentOffset = Position.cumulativeOffset(parentElement); 7017var position = new Array(); 7018position[0] = offset[0] + parentOffset[0]; 7019position[1] = offset[1] + parentOffset[1] + eventElement.offsetHeight - this.topOverlap; 7020this.setPosition(position); 7021}, 7022setCenterPosition: function(popupElement, targetElement) { 7023var target_el = $(popupElement); 7024var center_position = commonCls.getCenterPosition(target_el,targetElement); 7025this.setPosition(center_position); 7026}, 7027getPopupElementByEvent: function(eventElement) { 7028eventElement = $(eventElement) 7029targetElement = eventElement.nextSibling; 7030while (targetElement.nodeType != 1 || !Element.hasClassName(targetElement, "popupClass")) { 7031targetElement = targetElement.nextSibling; 7032} 7033return targetElement; 7034}, 7035getPopupElement: function() { 7036return this.popupElement; 7037}, 7038isVisible: function() { 7039if (this.popupElement && this.popupElement.style.visibility == "visible" && !Element.hasClassName(this.popupElement, 'visible-hide')) { 7040return true; 7041} 7042return false;
7043}, 7044setTitle: function(head_title_str) { 7045this.head_title = head_title_str; 7046} 7047} 7048 7049var compTabset = Class.create(); 7050compTabset.prototype = { 7051initialize: function(top_el) { 7052this.top_el = top_el; 7053this.tab_el = null; 7054this.tabs = new Array; 7055this._activeIndex = 0; 7056}, 7057addTabset: function(label, callbackfunc, initfunc) { 7058var tab_object = new Object; 7059tab_object.caption = label; 7060tab_object.callbackfunc = callbackfunc; 7061tab_object.initfunc = initfunc; 7062tab_object.tabLen = this.tabs.length; 7063this.tabs[tab_object.tabLen] = tab_object; 7064}, 7065render: function() { 7066var tab_el = Element.getChildElementByClassName(this.top_el,"comp_tabset"); 7067this.tab_el = tab_el; 7068if (tab_el) { 7069tab_el.innerHTML = this.renderTab(); 7070var tableList = tab_el.getElementsByTagName("table"); 7071for (var i = 0; i < tableList.length; i++){ 7072if(Element.hasClassName(tableList[i],"comptabset_tabset")) { 7073Event.observe(tableList[i],"click",this.tabClick.bindAsEventListener(this),true, this.top_el); 7074} 7075} 7076} 7077}, 7078renderTab: function() { 7079var tabset_summary = (commonLang.tabset_summary != undefined) ? commonLang.tabset_summary : "Tabset"; 7080var ret = ""; 7081ret = '<table cellspacing="0" cellpadding="0" class="comptabset_tabs" summary="'+tabset_summary+'"><tr class="comptabset_tabs_tr">'; 7082ret += '<td class="comptabset_linespace"><img src="http://www.yamatogokin.co.jp/images/common/blank.gif" alt="" title="" class="comptabset_linespace" /></td>'; 7083var content_el = this.tab_el.nextSibling; 7084for (var i = 0; i < content_el.childNodes.length; i++) { 7085var container_el = content_el.childNodes[i]; 7086if(container_el == null) { 7087continue; 7088} 7089if(!this.tabs[i] || this.tabs[i].caption == null) { 7090if(!this.tabs[i] || typeof this.tabs[i] != 'object') { 7091this.tabs[i] = new Object; 7092this.tabs[i].callbackfunc = null; 7093this.tabs[i].initfunc = null; 7094this.tabs[i].tabLen = i; 7095} 7096var label_el = Element.getChildElement(container_el); 7097if(Element.hasClassName(label_el,"comptabset_caption")) { 7098this.tabs[i].caption = label_el.innerHTML; 7099} else { 7100this.tabs[i].caption = "Tab"+ (i+1); 7101} 7102} 7103if (i == this._activeIndex) { 7104var class_name = 'comptabset_active'; 7105if(this.tabs[i].initfunc) { 7106this.tabs[i].initfunc(); 7107this.tabs[i].initfunc = null; 7108} 7109this.tabClick(null, container_el); 7110} else { 7111var class_name = ''; 7112commonCls.displayNone(container_el); 7113} 7114ret += '<td >'+ 7115'<table' + ' class="comptabset_tabset ' + class_name + '" border="0" summary="">'+ 7116'<tr>'+ 7117'<td class="comptabset_upperleft"></td>'+ 7118'<td class="comptabset_upper"></td>'+ 7119'<td class="comptabset_upperright"></td>'+ 7120'</tr>'+ 7121'<tr>'+ 7122'<td class="comptabset_left"><img src="http://www.yamatogokin.co.jp/images/common/blank.gif" alt="" title="" class="comptabset_sidespace" /></td>'+ 7123'<td class="comptabset_content"><a class="link" href="#" onclick="return false;">' + this.tabs[i].caption+ '</a></td>'+ 7124'<td class="comptabset_right"><img src="http://www.yamatogokin.co.jp/images/common/blank.gif" alt="" title="" class="comptabset_sidespace" /></td>'+ 7125'</tr>'+ 7126'</table>'+ 7127'</td><td class="comptabset_linespace"><img src="http://www.yamatogokin.co.jp/images/common/blank.gif" alt="" title="" class="comptabset_linespace" /></td>'; 7128} 7129ret += '<td class="comptabset_line"><img src="http://www.yamatogokin.co.jp/images/common/blank.gif" alt="" title="" class="comptabset_linespace" /></td></tr></table>'; 7130return ret; 7131}, 7132tabClick: function(event,el) { 7133var tableList = this.tab_el.getElementsByTagName("table"); 7134var targetEl = (event == undefined || event == null) ? el : Event.element(event); 7135if(!Element.hasClassName(targetEl,"comptabset_tabset")) { 7136targetEl = Element.getParentElementByClassName(targetEl,"comptabset_tabset"); 7137} 7138var count = 0; 7139for (var i = 0; i < tableList.length; i++){ 7140if(Element.hasClassName(tableList[i],"comptabset_tabset")) { 7141if(targetEl == tableList[i] || targetEl.parentNode == tableList[i]) { 7142Element.addClassName(tableList[i],"comptabset_active"); 7143this._activeIndex = count; 7144} else { 7145Element.removeClassName(tableList[i],"comptabset_active"); 7146} 7147count++; 7148} 7149} 7150var content_el = this.tab_el.nextSibling; 7151for (var i = 0; i < content_el.childNodes.length; i++) { 7152var container_el = content_el.childNodes[i]; 7153if (!container_el) continue; 7154if (i == this._activeIndex) { 7155if(this.tabs[i].initfunc) { 7156this.tabs[i].initfunc(); 7157this.tabs[i].initfunc = null; 7158} 7159commonCls.displayVisible(container_el); 7160if(this.tabs[i].callbackfunc) { 7161this.tabs[i].callbackfunc(); 7162} 7163} else { 7164commonCls.displayNone(container_el); 7165} 7166} 7167}, 7168setActiveIndex: function(activeIndex) { 7169this._activeIndex = activeIndex; 7170}, 7171getActiveIndex: function() { 7172return this._activeIndex; 7173}, 7174refresh: function() { 7175var tableList = this.tab_el.getElementsByTagName("table"); 7176var count = 0; 7177var activeEl = null; 7178for (var i = 0; i < tableList.length; i++){ 7179if(Element.hasClassName(tableList[i],"comptabset_tabset")) { 7180if(this._activeIndex == count) { 7181activeEl = tableList[i]; 7182break; 7183} 7184count++; 7185} 7186} 7187this.tabClick(null,activeEl); 7188} 7189} 7190 7191var compTextarea = Class.create(); 7192var textareaComp = Array(); 7193compTextarea.prototype = { 7194initialize: function() { 7195this.top_table = null; 7196this.textarea = null; 7197this.htmlarea = null; 7198this.toolbar = null; 7199this.mode = null; 7200this.focus = false;
7201this.popupPrefix = ""; 7202this.text = null; 7203this.text_style = null; 7204this.text_content = null; 7205this.resizeBox = null; 7206this.config = new Object(); 7207this.timerToolbar = null; 7208this.toolbarObjects = null; 7209this.custom_undo_redo = true; 7210this.custom_undo_redo_maxlevels = 100; 7211this.custom_undo_redo_levels = -1; 7212this.custom_undo_redo_keyboard_shortcuts = true; 7213this.setStartsBarDragGoEvent = null; 7214this.setStartsBarDragStopEvent = null; 7215this.htmlareaMinWidth = 0; 7216this.htmlareaMinHeight = 0; 7217this.htmlareaOldWidth = 0; 7218this.htmlareaOldHeight = 0; 7219this.resizeBoxSize = 0; 7220this.editMode = "edit"; 7221this.oldeditMode = "edit"; 7222this.editModeBtn = null; 7223this.htmlModeBtn = null; 7224this.previewModeBtn = null; 7225this.change_el = null; 7226this.preRange = null; 7227this.el = null; 7228this.el_array = []; 7229this.inAddEvent = false; 7230this.update_flag = false; 7231this.tableProperty = { 7232f_rows: 0, 7233f_cols: 0, 7234f_width: "200", 7235f_w_unit: "px", 7236f_height: "", 7237f_h_unit: "px", 7238f_align: "", 7239f_background: "", 7240f_border: "1", 7241f_border_style: "solid", 7242f_border_color: "#000000", 7243f_spacing: "0", 7244f_padding: "0", 7245f_horiz: "5", 7246f_vert: "5", 7247f_fixed: false, 7248f_collapse: true, 7249r_align: "", 7250r_valign: "", 7251r_width: "", 7252r_w_unit: "px", 7253r_height: "", 7254r_h_unit: "px", 7255r_background: "", 7256r_fontcolor: "", 7257c_align: "", 7258c_valign: "", 7259c_width: "", 7260c_w_unit: "px", 7261c_height: "", 7262c_h_unit: "px", 7263c_background: "", 7264c_fontcolor: "", 7265c_nowrap: false, 7266c_t_border: "1", 7267c_t_border_style: "solid", 7268c_t_border_color: "#000000", 7269c_r_border: "1", 7270c_r_border_style: "solid", 7271c_r_border_color: "#000000", 7272c_b_border: "1", 7273c_b_border_style: "solid", 7274c_b_border_color: "#000000", 7275c_l_border: "1", 7276c_l_border_style: "solid", 7277c_l_border_color: "#000000" 7278}; 7279this.linkProperty = { 7280f_href : '', 7281f_title : '', 7282f_target : '', 7283f_usetarget : true 7284}; 7285this.imageProperty = { 7286f_base : '', 7287f_url : '', 7288f_alt : '', 7289f_border : '', 7290f_align : '', 7291f_vert : '', 7292f_horiz : '' 7293}; 7294this.texProperty = { 7295f_texexp : '' 7296}; 7297this.id = null; 7298this.popup = new Object(); 7299this.uploadAction = { 7300unique_id : "0", 7301image : null, 7302file : null 7303}; 7304this.downloadAction = "common_download_main"; 7305this.topAddEventFunc = null; 7306this.preSel = null; 7307this.startNode = null; 7308this.startOffset = null; 7309this.endNode = null; 7310this.endOffset = null; 7311this.sizeElement = null; 7312this.timer = null; 7313}, 7314textareaShow: function(id, textarea_classname, mode, config) { 7315this.popupPrefix = textarea_classname; 7316var text_el = Element.getChildElementByClassName($(id),textarea_classname); 7317this.textareaEditShow(id,text_el, mode); 7318}, 7319textareaEditShow: function(id,textarea,mode,config) { 7320mode = (mode == undefined) ? "full" : mode; 7321commonCls.referComp[id + this.popupPrefix] = this; 7322this.id = id; 7323if(Element.hasClassName(textarea.parentNode,"comptextarea_textarea")) { 7324return; 7325} 7326this.textarea = textarea; 7327this.editMode = "edit"; 7328this.oldeditMode = "edit"; 7329var ta_size = { 7330w: valueParseInt(Element.getStyle(textarea, "width")), 7331h: valueParseInt(Element.getStyle(textarea, "height")) 7332}; 7333commonCls.displayNone(this.textarea); 7334var table = document.createElement("table"); 7335this.top_table = table; 7336Element.addClassName(table,"collapse_separate"); 7337var tb_body = document.createElement("tbody"); 7338table.appendChild(tb_body); 7339var tb_row = document.createElement("tr"); 7340tb_body.appendChild(tb_row); 7341var td = document.createElement("td"); 7342tb_row.appendChild(td); 7343this.htmlarea = td; 7344Element.addClassName(this.htmlarea,"comptextarea_textarea"); 7345textarea.parentNode.insertBefore(table, textarea); 7346if (typeof config == "undefined") { 7347this.getConfig(mode); 7348} else { 7349this.config = config; 7350} 7351this.undoLevels = new Array(this.custom_undo_redo_maxlevels); 7352this.toolbar = document.createElement("DIV"); 7353this.htmlarea.appendChild(this.toolbar); 7354this.createToolbar(); 7355var text = document.createElement("IFRAME"); 7356text.src='about:blank'; 7357Element.addClassName(text,"comptextarea_text"); 7358var height = (this.config.height == undefined || this.config.height == "auto" ? (ta_size.h + "px") : this.config.height); 7359height = parseInt(height); 7360var width = (this.config.width == undefined || this.config.width == "auto" ? (ta_size.w + "px") : this.config.width); 7361width = valueParseInt(width); 7362this.text_style = text.style; 7363this.setTextAreaStyle(text); 7364this.setTextAreaStyle(textarea); 7365this.text_style.width = width + 'px'; 7366this.text_style.height = height + 'px'; 7367this.htmlareaOldWidth = width; 7368this.htmlareaOldHeight = height; 7369this.htmlarea.style.width = width + valueParseInt(Element.getStyle(text,"borderRightWidth")) + valueParseInt(Element.getStyle(text,"borderLeftWidth")) + valueParseInt(Element.getStyle(text,"marginRight")) + valueParseInt(Element.getStyle(text,"marginLeft")) + 'px'; 7370this.text_style.wordWrap = 'break-word'; 7371this.topAddEventFunc = this.topAddEvent.bindAsEventListener(this); 7372Event.observe(text,"load",this.topAddEventFunc, false, this.id); 7373this.text = text; 7374if(browser.isSafari) { 7375this.timer = setInterval(this.topAddEventFunc, 500); 7376} 7377this.htmlarea.appendChild(text); 7378text.parentNode.insertBefore(this.textarea,text); 7379var statusbar = document.createElement("DIV"); 7380statusbar.className = "comptextarea_statusBar"; 7381var statusbar_btn = document.createElement("DIV"); 7382statusbar_btn.className = "comptextarea_statusBarButton"; 7383var doc = document.createDocumentFragment(); 7384var table = document.createElement("table"); 7385table.border = "0"; 7386table.cellSpacing = "0"; 7387table.cellPadding = "0"; 7388var tb_body = document.createElement("tbody"); 7389table.appendChild(tb_body); 7390var tb_row = document.createElement("tr"); 7391tb_body.appendChild(tb_row); 7392var td1 = document.createElement("td"); 7393td1.className = "comptextarea_changeMode comptextarea_editMode comptextarea_activeMode"; 7394tb_row.appendChild(td1); 7395var td2 = document.createElement("td"); 7396td2.className = "comptextarea_changeMode comptextarea_htmlMode"; 7397tb_row.appendChild(td2); 7398var td3 = document.createElement("td"); 7399td3.className = "comptextarea_changeMode comptextarea_previewMode"; 7400tb_row.appendChild(td3); 7401var a1 = document.createElement("a"); 7402var a2 = document.createElement("a"); 7403var a3 = document.createElement("a"); 7404a1.className = "widthmax display-block link"; 7405a2.className = "widthmax display-block link"; 7406a3.className = "widthmax display-block link"; 7407td1.appendChild(a1); 7408td2.appendChild(a2); 7409td3.appendChild(a3); 7410if (typeof compTextareaLang == "undefined" || typeof compTextareaLang.modetype["edit"] == "undefined") 7411var txt1 = document.createTextNode('Edit'); 7412else 7413var txt1 = document.createTextNode(compTextareaLang.modetype["edit"]); 7414if (typeof compTextareaLang == "undefined" || typeof compTextareaLang.modetype["html"] == "undefined") 7415var txt2 = document.createTextNode('Html'); 7416else 7417var txt2 = document.createTextNode(compTextareaLang.modetype["html"]); 7418if (typeof compTextareaLang == "undefined" || typeof compTextareaLang.modetype["preview"] == "undefined") 7419var txt3 = document.createTextNode('Preview'); 7420else 7421var txt3 = document.createTextNode(compTextareaLang.modetype["preview"]); 7422a1.appendChild(txt1); 7423a2.appendChild(txt2); 7424a3.appendChild(txt3); 7425this.editModeBtn = td1; 7426this.htmlModeBtn = td2; 7427this.previewModeBtn = td3; 7428Event.observe(a1, "click", function (event) { 7429this.oldeditMode = this.editMode; 7430this.editMode = "edit"; 7431this.changeEditMode(); 7432Event.stop(event); 7433return false;
7434}.bindAsEventListener(this),false, this.id); 7435Event.observe(a2, "click", function (event) { 7436this.oldeditMode = this.editMode; 7437this.editMode = "html"; 7438this.changeEditMode(); 7439Event.stop(event); 7440return false; 7441}.bindAsEventListener(this),false, this.id); 7442Event.observe(a3, "click", function (event) { 7443this.oldeditMode = this.editMode; 7444this.editMode = "preview"; 7445this.changeEditMode(); 7446Event.stop(event); 7447return false; 7448}.bindAsEventListener(this),false, this.id); 7449statusbar_btn.appendChild(table); 7450statusbar.appendChild(statusbar_btn); 7451var statusbar_resize = document.createElement("DIV"); 7452statusbar_resize.className = "comptextarea_statusBarResize"; 7453Event.observe(statusbar_resize,"mousedown",this.setStartsBarResizing.bindAsEventListener(this),false, this.id); 7454statusbar.appendChild(statusbar_resize); 7455var br = document.createElement("BR"); 7456br.style.clear = "both"; 7457statusbar.appendChild(br); 7458doc.appendChild(statusbar); 7459this.htmlarea.appendChild(doc); 7460this.htmlareaMinHeight = this.text.clientHeight; 7461this.htmlareaMinWidth = this.text.clientWidth; 7462var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_setforecolor"); 7463if(el) el.style.backgroundColor = "#ff0000"; 7464var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_sethilitecolor"); 7465if(el) el.style.backgroundColor = "#ff0000"; 7466}, 7467topAddEvent: function(event) { 7468var text = this.text; 7469if(!browser.isGecko && !browser.isSafari){ 7470Event.stopObserving(text,"load", this.topAddEventFunc, false); 7471} else if(browser.isSafari) { 7472try{ 7473var tmp = text.contentWindow.document; 7474if(tmp == undefined || tmp == null) { 7475return; 7476} 7477} catch(e) { 7478return; 7479} 7480clearInterval(this.timer); 7481} 7482if(!text.contentWindow || !text.contentWindow.document) { 7483return; 7484} 7485this.text_content = text.contentWindow.document; 7486if(this.inAddEvent == false && text.contentWindow.document.body.innerHTML.strip() == "") { 7487this.inAddEvent = true; 7488var text_content = this.text_content; 7489if(browser.isNS){ 7490text_content.designMode = "on"; 7491} 7492var htmltag = document.getElementsByTagName("html")[0]; 7493var htmlAttr = "xmlns=\"" + htmltag.getAttribute("xmlns") + "\" "; 7494if (typeof compTextareaLang != "undefined" && typeof compTextareaLang.content["title"] != "undefined") 7495var titleText = "<title>" + compTextareaLang.content["title"] + "</title>\n"; 7496else 7497var titleText = "<title>Editor</title>\n"; 7498text_content.open(); 7499var html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; 7500html += "<html " + htmlAttr + ">\n"; 7501var styleText = "<style> html,body { height : 100% !important; background-image : none !important; padding:0px !important; margin:0px !important;}\n " + 7502".comptextareat_content {background-color:#ffffff; border: 0px;font-size:80%;color: #666665;}\n" + 7503" table {font-size:small;}" + 7504"</style>\n"; 7505html += "<head>" + titleText + styleText + "</head>\n"; 7506html += "<body class=\"comptextareat_content\">\n" + "</body>\n" + "</html>"; 7507text_content.write(html); 7508text_content.close(); 7509this.writeTextAreaContent(); 7510this.chgStyleSheet(); 7511Event.observe(text_content,"keyup",this.handleEvent.bindAsEventListener(this),false, this.id); 7512Event.observe(text_content,"mouseup",this.handleEvent.bindAsEventListener(this),false, this.id); 7513Event.observe(text_content,"keydown",this.handleEvent.bindAsEventListener(this),false, this.id); 7514Event.observe(text_content, "dblclick", function (event) { 7515if(this.editMode == "edit") { 7516var el = Event.element(event); 7517if(el.tagName.toLowerCase() == 'table') { 7518this.showTableSetProperty(el); 7519}else if(el.tagName.toLowerCase() == 'img') { 7520if(el.src.indexOf("?action=common_tex_main&c=", 0) == -1) { 7521this.insertImageDialog(el); 7522}else{ 7523this.insertTexDialog(el); 7524} 7525} 7526} 7527}.bindAsEventListener(this),false, this.id); 7528if(!browser.isNS){ 7529(text_content.body.contentEditable != undefined) ? text_content.body.contentEditable = true : text_content.designMode = "on"; 7530} 7531if(this.textarea.value == "") { 7532var value = (browser.isIE || browser.isOpera) ? "<div>" : "br"; 7533this.execCommand("formatblock", false, value); 7534} 7535this.forceRedraw(); 7536if(this.focus) { 7537this.focusEditor(true); 7538} 7539this.inAddEvent = false;
7540} 7541this.borderChange(); 7542}, 7543writeTextAreaContent: function() { 7544if(this.textarea.value == "") { 7545this.textarea.value = "<br />"; 7546} 7547if(browser.isIE || browser.isSafari) { 7548this.text_content.body.innerHTML = "<br />" + this.textarea.value; 7549this.text_content.body.removeChild(this.text_content.body.firstChild); 7550} else { 7551this.text_content.body.innerHTML = this.textarea.value; 7552} 7553}, 7554chgStyleSheet: function(add_flag) { 7555add_flag = (add_flag == undefined) ? true : add_flag; 7556if(add_flag) { 7557var head = document.getElementsByTagName("head")[0]; 7558} else { 7559var head = this.text_content.getElementsByTagName("head")[0]; 7560} 7561var links = head.getElementsByTagName("link"); 7562if(add_flag == true) { 7563if(typeof this.text_content.createStyleSheet != "undefined") { 7564var createStyleSheetFlag = true; 7565} else { 7566var createStyleSheetFlag = false; 7567var insert_head = this.text_content.getElementsByTagName("head")[0]; 7568} 7569} else { 7570var remove_obj = new Object; 7571} 7572for (var i = 0,links_length = links.length; i < links_length; i++) { 7573var link = links[i]; 7574if (link.getAttribute("type") == "text/css") { 7575if(add_flag) { 7576if(createStyleSheetFlag) { 7577this.text_content.createStyleSheet(link.getAttribute("href")); 7578} else { 7579var append_link = document.createElement('LINK'); 7580append_link.rel = link.getAttribute("rel"); 7581append_link.type = link.getAttribute("type"); 7582append_link.media = link.getAttribute("media"); 7583append_link.href= link.getAttribute("href"); 7584insert_head.appendChild(append_link); 7585} 7586} else { 7587remove_obj[i] = link; 7588} 7589} 7590} 7591if(!add_flag) { 7592for (var link in remove_obj) { 7593Element.remove(remove_obj[link]); 7594} 7595this.text_content.body.style.backgroundColor = ""; 7596this.text_content.allowtransparency = false; 7597} else { 7598var el = this.textarea; 7599var color = commonCls.getColorCode(el, "backgroundColor"); 7600if (color == "transparent") { 7601var parent_el = el; 7602while (color == "transparent") { 7603if(this.textarea == parent_el) parent_el = this.htmlarea.parentNode; 7604else parent_el = parent_el.parentNode; 7605if(parent_el.tagName == "BODY") { 7606color = "#ffffff"; 7607break; 7608} 7609color = commonCls.getColorCode(parent_el, "backgroundColor"); 7610} 7611} 7612this.text_content.body.style.backgroundColor = color; 7613this.text_content.allowtransparency = true; 7614} 7615}, 7616textareaEditHide: function() { 7617(this.text_content.body.contentEditable != undefined) ? this.text_content.body.contentEditable = false : this.text_content.designMode = "off"; 7618delete(this.undoLevels); 7619this.undoLevels = new Array(this.custom_undo_redo_maxlevels); 7620this.custom_undo_redo_levels = -1; 7621}, 7622forceRedraw: function() { 7623this.text_content.body.style.display = "none"; 7624this.text_content.body.style.display = ""; 7625}, 7626toolbarVisble: function(style) { 7627if(style == undefined) 7628style = ""; 7629this.toolbar.style.display = style; 7630}, 7631setTextAreaStyle: function(el) { 7632var el_style = el.style; 7633el_style.borderTop = '1px solid #666665'; 7634el_style.borderBottom = '1px solid #cccccc'; 7635el_style.borderLeft = '1px solid #666665'; 7636el_style.borderRight = '1px solid #cccccc'; 7637el.marginHeight = "0"; 7638el.marginWidth = "0"; 7639el_style.marginTop="0px" 7640el_style.marginRight="5px" 7641el_style.marginLeft="5px" 7642}, 7643getConfig: function(mode) { 7644if(browser.isSafari && mode != "least") { 7645mode = "safari"; 7646} else if(browser.isOpera && mode == "full") { 7647mode = "medium"; 7648} 7649if(mode == "full") { 7650this.config.toolbar = [ 7651[ "fontname", "space", 7652"fontsize", "space", 7653"formatblock", "space", 7654"bold", "italic", "underline", "strikethrough", "separator", 7655"subscript", "superscript", "separator", 7656"setforecolor","forecolor", "sethilitecolor","hilitecolor", "separator", 7657"removeformat" 7658], 7659[ "undo", "redo", "separator", 7660"justifyleft", "justifycenter", "justifyright", "separator", 7661"orderedlist", "unorderedlist", "separator", 7662"outdent", "indent", "separator", 7663"inserttable","tablemenu", "separator","inserthorizontalrule","separator", 7664"insertsmiley","separator","inserttex","separator", 7665"createlink", "unablelink", "separator","savezip","space" 7666] 7667]; 7668} else if(mode == "medium") { 7669this.config.toolbar = [ 7670[ "fontname", "space", 7671"fontsize", "space", 7672"formatblock", "space", 7673"bold", "italic", "underline", "strikethrough", "separator", 7674"subscript", "superscript", "separator", 7675"setforecolor","forecolor", "sethilitecolor","hilitecolor", "separator", 7676"removeformat" 7677], 7678[ "undo", "redo", "separator", 7679"justifyleft", "justifycenter", "justifyright", "separator", 7680"orderedlist", "unorderedlist", "separator", 7681"insertsmiley","separator","inserttex","separator", 7682"createlink", "unablelink", "separator","savezip","space" 7683] 7684]; 7685} else if(mode == "least") { 7686this.config.toolbar = [ 7687[ "undo", "redo", "separator", 7688"bold", "italic", "underline", "strikethrough", "separator", 7689"setforecolor","forecolor", "sethilitecolor","hilitecolor", "separator", 7690"removeformat", "separator", 7691"createlink", "unablelink" 7692] 7693]; 7694} else if(mode == "safari") { 7695this.config.toolbar = [ 7696[ "fontsize", "space", 7697"undo", "redo", "separator", 7698"bold", "italic", "underline", "strikethrough", "separator", 7699"subscript", "superscript", "separator", 7700"setforecolor","forecolor", "sethilitecolor","hilitecolor", "separator", 7701"insertsmiley","separator","inserttex","separator", 7702"createlink", "unablelink", "separator" 7703] 7704]; 7705} else { 7706this.config.toolbar = [ 7707[ "undo", "redo", "separator", 7708"bold", "italic", "underline", "strikethrough", "separator", 7709"subscript", "superscript", "separator", 7710"setforecolor","forecolor", "sethilitecolor","hilitecolor", "separator", 7711"removeformat", "separator", "insertsmiley","separator", 7712"createlink", "unablelink", "separator" 7713] 7714]; 7715} 7716if (mode != "least" && _nc_allow_video != "0") { 7717if(this.config.toolbar[1]) { 7718this.config.toolbar[1].push("insertvideo"); 7719this.config.toolbar[1].push("separator"); 7720} else { 7721this.config.toolbar[0].push("insertvideo"); 7722this.config.toolbar[0].push("separator"); 7723} 7724} 7725if (mode != "least" && _nc_allow_attachment != "0") { 7726if(this.config.toolbar[1]) { 7727this.config.toolbar[1].push("insertimage"); 7728} else { 7729this.config.toolbar[0].push("insertimage"); 7730} 7731} 7732if (mode != "least" && _nc_allow_attachment == "2") { 7733if(this.config.toolbar[1]) { 7734this.config.toolbar[1].push("insertupload"); 7735} else { 7736this.config.toolbar[0].push("insertupload"); 7737} 7738} 7739if (typeof compTextareaLang != "undefined" && typeof compTextareaLang.fontname != "undefined") { 7740this.config.fontname = compTextareaLang.fontname; 7741} else { 7742this.config.fontname = { 7743"— font —": '', 7744"Arial": 'arial,helvetica,sans-serif', 7745"Courier New": 'courier new,courier,monospace', 7746"Georgia": 'georgia,times new roman,times,serif', 7747"Tahoma": 'tahoma,arial,helvetica,sans-serif', 7748"TimesNewRoman": 'times new roman,times,serif', 7749"Verdana": 'verdana,arial,helvetica,sans-serif', 7750"impact": 'impact', 7751"WingDings": 'wingdings' 7752}; 7753} 7754if (typeof compTextareaLang != "undefined" && typeof compTextareaLang.fontsize != "undefined") { 7755this.config.fontsize = compTextareaLang.fontsize; 7756} else { 7757this.config.fontsize = { 7758"size" : "", 7759"1 (8 pt)" : "1", 7760"2 (10 pt)": "2", 7761"3 (12 pt)": "3", 7762"4 (14 pt)": "4", 7763"5 (18 pt)": "5", 7764"6 (24 pt)": "6", 7765"7 (36 pt)": "7" 7766}; 7767} 7768this.config.customSelects = {}; 7769if (typeof compTextareaLang != "undefined" && typeof compTextareaLang.format != "undefined") { 7770this.config.formatblock = compTextareaLang.format; 7771} else { 7772this.config.formatblock = { 7773"format" : "", 7774"Heading 1": "h1", 7775"Heading 2": "h2", 7776"Heading 3": "h3", 7777"Heading 4": "h4", 7778"Heading 5": "h5", 7779"Heading 6": "h6", 7780"Normal" : "div", 7781"Address" : "address", 7782"Formatted": "pre" 7783}; 7784} 7785this.config.btnList = { 7786undo: ["Undo", "toolbar/ed_undo.gif",false, function(cmdID,UI,param) {this.execCommand("undo");}.bind(this), "comptextarea_button_l"], 7787redo: ["Redo", "toolbar/ed_redo.gif",false, function(cmdID,UI,param) {this.execCommand("redo");}.bind(this), "comptextarea_button_r"], 7788copy: ["Copy", "toolbar/ed_copy.gif", false, function(cmdID,UI,param) {this.execCommand("copy");}.bind(this), "comptextarea_button_l"], 7789cut: ["Cut", "toolbar/ed_cut.gif", false, function(cmdID,UI,param) {this.execCommand("cut");}.bind(this), "comptextarea_button_c"], 7790paste:["Paste", "toolbar/ed_paste.gif", false, function(cmdID,UI,param) {this.execCommand("paste");}.bind(this), "comptextarea_button_r"], 7791bold: [ "Bold", "toolbar/ed_format_bold.gif", false, function(cmdID,UI,param) {this.execCommand("bold");}.bind(this), "comptextarea_button_l"], 7792italic: [ "Italic", "toolbar/ed_format_italic.gif", false, function(cmdID,UI,param) {this.execCommand("italic");}.bind(this), "comptextarea_button_c"], 7793underline: [ "Underline", "toolbar/ed_format_underline.gif", false, function(cmdID,UI,param) {this.execCommand("underline");}.bind(this), "comptextarea_button_c"], 7794strikethrough: [ "Strikethrough", "toolbar/ed_format_strike.gif", false, function(cmdID,UI,param) {this.execCommand("strikethrough");}.bind(this), "comptextarea_button_r"], 7795subscript: [ "Subscript", "toolbar/ed_format_sub.gif", false, function(cmdID,UI,param) {this.execCommand("subscript");}.bind(this) , "comptextarea_button_l"], 7796superscript: [ "Superscript", "toolbar/ed_format_sup.gif", false, function(cmdID,UI,param) {this.execCommand("superscript");}.bind(this) , "comptextarea_button_r"], 7797justifyleft: [ "Justify Left", "toolbar/ed_align_left.gif", false, function(cmdID,UI,param) {this.execCommand("justifyleft");}.bind(this) , "comptextarea_button_l"], 7798justifycenter: [ "Justify Center", "toolbar/ed_align_center.gif", false, function(cmdID,UI,param) {this.execCommand("justifycenter");}.bind(this) , "comptextarea_button_c"], 7799justifyright: [ "Justify Right", "toolbar/ed_align_right.gif", false, function(cmdID,UI,param) {this.execCommand("justifyright");}.bind(this) , "comptextarea_button_r"], 7800justifyfull: [ "Justify Full", "toolbar/ed_align_justify.gif", false, function(cmdID,UI,param) {this.execCommand("justifyfull");}.bind(this) , "comptextarea_button_c"], 7801orderedlist: [ "Ordered List", "toolbar/ed_list_num.gif", false, function(cmdID,UI,param) {this.execCommand("insertorderedlist");}.bind(this) , "comptextarea_button_l"], 7802unorderedlist: [ "Bulleted List", "toolbar/ed_list_bullet.gif", false, function(cmdID,UI,param) {this.execCommand("insertunorderedlist");}.bind(this) , "comptextarea_button_r"], 7803outdent: [ "Decrease Indent", "toolbar/ed_indent_less.gif", false, function(cmdID,UI,param) {this.execCommand("outde
7803nt");}.bind(this) , "comptextarea_button_l"], 7804indent: [ "Increase Indent", "toolbar/ed_indent_more.gif", false, function(cmdID,UI,param) {this.execCommand("indent");}.bind(this) , "comptextarea_button_r"], 7805lefttoright: [ "Direction left to right", "toolbar/ed_left_to_right.gif", false, function(cmdID,UI,param) {this.execCommand("lefttoright");}.bind(this) , "comptextarea_button_l"], 7806righttoleft: [ "Direction right to left", "toolbar/ed_right_to_left.gif", false, function(cmdID,UI,param) {this.execCommand("righttoleft");}.bind(this) , "comptextarea_button_r"], 7807removeformat: [ "Remove formatting", "toolbar/ed_rmformat.gif", false, function(cmdID,UI,param) {this.execCommand("removeformat");}.bind(this) , "comptextarea_button_n"], 7808setforecolor: [ "Font Color", "toolbar/ed_color_fg.gif", false, function(cmdID,UI,param) {this.execCommand("setforecolor");}.bind(this) , "comptextarea_button_l"], 7809sethilitecolor: [ "Background Color", "toolbar/ed_color_bg.gif", false, function(cmdID,UI,param) {this.execCommand("sethilitecolor");}.bind(this) , "comptextarea_button_c"], 7810forecolor: [ "Select Font Color", "toolbar/ed_arrow.gif", false, function(cmdID,UI,param) {this.execCommand("forecolor");}.bind(this) , "comptextarea_button_a"],
7811hilitecolor: [ "Select Background Color", "toolbar/ed_arrow_right.gif", false, function(cmdID,UI,param) {this.execCommand("hilitecolor");}.bind(this) , "comptextarea_button_a"], 7812inserthorizontalrule: [ "Horizontal Rule", "toolbar/ed_hr.gif", false, function(cmdID,UI,param) {this.execCommand("inserthorizontalrule");}.bind(this) , "comptextarea_button_n"], 7813inserttable: [ "Insert Table", "toolbar/ed_insert_table.gif", false, function(cmdID,UI,param) {this.execCommand("inserttable");}.bind(this) , "comptextarea_button_l"], 7814tablemenu: [ "Table Menu", "toolbar/ed_arrow_right.gif", false, function(cmdID,UI,param) {this.execCommand("tablemenu");}.bind(this) , "comptextarea_button_a"], 7815createlink: [ "Insert Web Link", "toolbar/ed_link.gif", false, function(cmdID,UI,param) {this.execCommand("createlink", true);}.bind(this) , "comptextarea_button_l"], 7816unablelink: [ "Unable Link", "toolbar/ed_unablelink.gif", false, function(cmdID,UI,param) {this.execCommand("unlink", false);}.bind(this) , "comptextarea_button_r"], 7817insertimage: [ "Insert/Modify Image", "toolbar/ed_image.gif", false, function(cmdID,UI,param) {this.execCommand("insertimage");}.bind(this) , "comptextarea_button_l"], 7818inserttex: [ "Insert Tex", "toolbar/ed_insert_tex.gif", false, function(cmdID,UI,param) {this.execCommand("inserttex");}.bind(this) , "comptextarea_button_n"], 7819insertupload: [ "Insert Upload", "toolbar/ed_insert_upload.gif", false, function(cmdID,UI,param) {this.execCommand("insertupload");}.bind(this) , "comptextarea_button_r"], 7820insertsmiley: [ "Insert Smiley", "toolbar/ed_emotions.gif", false, function(cmdID,UI,param) {this.execCommand("insertsmiley");}.bind(this) , "comptextarea_button_n"], 7821savezip: [ "Save Zip", "toolbar/ed_savezip.gif", false, function(cmdID,UI,param) {this.execCommand("savezip");}.bind(this) , "comptextarea_button_n"], 7822insertvideo: [ "Insert Video", "toolbar/ed_video.gif", false, function(cmdID,UI,param) {this.execCommand("insertvideo");}.bind(this) , "comptextarea_button_n"] 7823}; 7824for (var i in this.config.btnList) { 7825if(this.config.btnList[i][1] != undefined) { 7826var btn = this.config.btnList[i]; 7827btn[1] = "http://www.yamatogokin.co.jp/images/comp/textarea/" + btn[1]; 7828if (typeof compTextareaLang != "undefined" && typeof compTextareaLang.icons[i] != "undefined") { 7829btn[0] = compTextareaLang.icons[i]; 7830} 7831} 7832} 7833}, 7834setButtonStatus: function(id, newval) { 7835var oldval = this[id]; 7836var el = this.element; 7837if (oldval != newval) { 7838if(Element.hasClassName(el.parentNode, "comptextarea_button_n")) var class_name = "comptextarea_button_n"; 7839else if(Element.hasClassName(el.parentNode, "comptextarea_button_l")) var class_name = "comptextarea_button_l"; 7840else if(Element.hasClassName(el.parentNode, "comptextarea_button_c")) var class_name = "comptextarea_button_c"; 7841else if(Element.hasClassName(el.parentNode, "comptextarea_button_r")) var class_name = "comptextarea_button_r"; 7842else if(Element.hasClassName(el.parentNode, "comptextarea_button_a")) var class_name = "comptextarea_button_a"; 7843switch (id) { 7844case "enabled": 7845if (newval) { 7846Element.removeClassName(el.parentNode, class_name+"Disabled"); 7847el.disabled = false; 7848} else { 7849Element.addClassName(el.parentNode, class_name+"Disabled"); 7850el.disabled = true; 7851} 7852break; 7853case "active": 7854if (newval) { 7855Element.addClassName(el.parentNode, class_name+"Pressed"); 7856} else { 7857Element.removeClassName(el.parentNode, class_name+"Pressed"); 7858} 7859break; 7860} 7861this[id] = newval; 7862} 7863}, 7864createToolbar: function() { 7865var table = null; 7866var tb_row = null; 7867var toolbar = this.toolbar; 7868var tb_objects = new Object(); 7869this.toolbarObjects = tb_objects; 7870var doc = document.createDocumentFragment(); 7871var change_el = null; 7872function newLine(doc) { 7873var table = document.createElement("table"); 7874table.border = "0px"; 7875table.cellSpacing = "0px"; 7876table.cellPadding = "0px"; 7877table.className = "comptextarea_toolbar"; 7878var tb_body = document.createElement("tbody"); 7879table.appendChild(tb_body); 7880var tb_row = document.createElement("tr"); 7881tb_body.appendChild(tb_row); 7882doc.appendChild(table); 7883return new Array(table, tb_row) 7884}; 7885function createSelect(txt) { 7886var options = null; 7887var el = null; 7888var cmd = null; 7889var customSelects = this.config.customSelects; 7890var context = null; 7891var tooltip = ""; 7892switch (txt) { 7893case "fontsize": 7894case "fontname": 7895case "formatblock": 7896options = this.config[txt]; 7897cmd = txt; 7898break; 7899default: 7900cmd = txt; 7901var dropdown = customSelects[cmd]; 7902if (typeof dropdown != "undefined") { 7903options = dropdown.options; 7904context = dropdown.context; 7905if (typeof dropdown.tooltip != "undefined") { 7906tooltip = dropdown.tooltip; 7907} 7908} else { 7909alert("ERROR [createSelect]:\nCan't find the requested dropdown definition"); 7910} 7911break; 7912} 7913if (options) { 7914el = document.createElement("select"); 7915el.title = tooltip; 7916var obj = { 7917name : txt, 7918element : el, 7919enabled : true, 7920text : false, 7921cmd : cmd, 7922state : this.setButtonStatus, 7923context : context 7924}; 7925tb_objects[txt] = obj; 7926for (var i in options) { 7927var op = document.createElement("option"); 7928op.innerHTML = i; 7929op.value = options[i]; 7930el.appendChild(op); 7931} 7932if(browser.isSafari) { 7933Event.observe(el, "mousedown", function () { 7934this.execCommand("bold", false, undefined);
7935var sel = this.getSelection(); 7936var range = this.createRange(sel); 7937var el_ac = sel.anchorNode; 7938var el_fc =sel.focusNode; 7939if(el_ac || el_fc) { 7940if(el_fc) var el = this.getParentElementByTagName(el_fc, "span"); 7941if(el.style.fontWeight != "bold" && el_ac) { 7942if(el_ac) el = this.getParentElementByTagName(el_ac, "span"); 7943} 7944if(el) { 7945el.style.fontWeight = ""; 7946this.sizeElement = el; 7947} 7948} 7949}.bindAsEventListener(this),false, this.id); 7950} 7951Event.observe(el, "change", function () { 7952this.comboSelected(el, txt); 7953}.bindAsEventListener(this),false, this.id); 7954} 7955return el; 7956}; 7957function createButton(text, class_name) { 7958var el = null; 7959var btn = null; 7960var tb_cell = null; 7961switch (text) { 7962case "linebreak": 7963var ret = newLine(doc); 7964table = ret[0]; 7965tb_row = ret[1]; 7966return false; 7967case "separator": 7968el = document.createElement("div"); 7969el.className = "comptextarea_separator"; 7970break; 7971case "space": 7972el = document.createElement("div"); 7973el.className = "comptextarea_space"; 7974break; 7975default: 7976btn = this.config.btnList[text]; 7977} 7978if (!el && btn) { 7979var el = document.createElement("IMG"); 7980el.src = btn[1]; 7981el.unselectable = 'on'; 7982el.className = "comptextarea_"+text; 7983el.title = btn[0]; 7984el.alt = btn[0]; 7985var obj = { 7986name : text, 7987element : el, 7988enabled : true, 7989active : false, 7990text : btn[2], 7991cmd : btn[3], 7992state : this.setButtonStatus, 7993context : btn[4] || null 7994}; 7995tb_objects[text] = obj; 7996if(!el.src.match(/ed_arrow/)) { 7997Event.observe(el, "mouseover", function () { 7998if (obj.enabled && Element.addClassName) { 7999Element.addClassName(el.parentNode,class_name+"Hover"); 8000} 8001},false, this.id); 8002Event.observe(el, "mouseout", function () { 8003if (obj.enabled && Element.removeClassName) { 8004Element.removeClassName(el.parentNode, class_name+"Hover"); 8005Element.removeClassName(el.parentNode, class_name+"Active"); 8006} 8007},false, this.id); 8008Event.observe(el, "mousedown", function (event) { 8009if (obj.enabled) { 8010Element.addClassName(el.parentNode, class_name+"Active"); 8011Element.removeClassName(el.parentNode, class_name+"Pressed"); 8012Event.stop(event); 8013} 8014},false, this.id); 8015} else { 8016Event.observe(el, "mousedown", function (event) { 8017if (obj.enabled) { 8018Event.stop(event); 8019} 8020},false, this.id); 8021} 8022Event.observe(el, "click", function (event) { 8023if (obj.enabled) { 8024Element.removeClassName(el.parentNode, class_name+"Active"); 8025Element.removeClassName(el.parentNode, class_name+"Hover"); 8026obj.cmd(this, obj.name, obj); 8027Event.stop(event); 8028} 8029}.bindAsEventListener(this),false, this.id); 8030} else if (!el) { 8031el = createSelect.bind(this)(text); 8032} 8033if (el) { 8034tb_cell = document.createElement("td"); 8035if(el.tagName.toLowerCase() == "img") { 8036tb_cell.className = class_name; 8037} 8038tb_cell.appendChild(el); 8039} else { 8040alert("FIXME: Unknown toolbar item: " + text); 8041} 8042return tb_cell; 8043}; 8044var ret = newLine(doc); 8045table = ret[0]; 8046tb_row = ret[1]; 8047var first = true; 8048for (var i = 0, confLen = this.config.toolbar.length; i < confLen; i++) { 8049if (!first) { 8050var tb_cell = createButton.bind(this)("linebreak"); 8051if(tb_cell) tb_row.appendChild(tb_cell); 8052} else { 8053first = false; 8054} 8055var group = this.config.toolbar[i]; 8056for (var j = 0, groupLen = group.length; j < groupLen; j++) { 8057var code = group[j]; 8058if(this.config.btnList[code]) { 8059var tb_cell = createButton.bind(this)(code, this.config.btnList[code][4]); 8060if(tb_cell) tb_row.appendChild(tb_cell); 8061} else { 8062var tb_cell = createButton.bind(this)(code); 8063if(tb_cell) tb_row.appendChild(tb_cell); 8064} 8065} 8066} 8067toolbar.appendChild(doc); 8068}, 8069handleEvent: function(event) { 8070var keyEvent = ((browser.isIE || browser.isOpera) && event.type == "keydown") || (!(browser.isIE || browser.isOpera) && event.type == "keypress"); 8071if (keyEvent && event.ctrlKey && !event.altKey) { 8072var sel = null; 8073var range = null; 8074var key = String.fromCharCode((browser.isIE || browser.isOpera) ? event.keyCode : event.charCode).toLowerCase(); 8075var cmd = null; 8076var value = null; 8077switch (key) { 8078case 'a': 8079if (!(browser.isIE)) { 8080sel = this.getSelection(); 8081sel.removeAllRanges(); 8082range = this.createRange(); 8083range.selectNodeContents(this.text_content.body); 8084sel.addRange(range); 8085Event.stop(event); 8086} 8087break; 8088case 'b': cmd = "bold"; break; 8089case 'i': cmd = "italic"; break; 8090case 'u': cmd = "underline"; break; 8091case 's': cmd = "strikethrough"; break; 8092case 'l': cmd = "justifyleft"; break; 8093case 'e': cmd = "justifycenter"; break; 8094case 'r': cmd = "justifyright"; break; 8095case 'j': cmd = "justifyfull"; break; 8096case 'z': cmd = "undo"; break; 8097case 'y': cmd = "redo"; break; 8098case 'v': if ((browser.isIE || browser.isOpera) || this.config.htmlareaPaste) { cmd = "paste"; } break; 8099case 'n': cmd = "formatblock"; value = (browser.isIE || browser.isOpera) ? "<div>" : "div"; break; 8100case '0': cmd = "killword"; break; 8101case '1': 8102case '2': 8103case '3': 8104case '4': 8105case '5': 8106case '6': 8107cmd = "formatblock"; 8108value = "h" + key; 8109if ((browser.isIE || browser.isOpera)) 8110value = "<" + value + ">"; 8111break; 8112} 8113if (cmd) { 8114this.execCommand(cmd, false, value); 8115Event.stop(event); 8116} 8117}else { 8118switch (event.type) { 8119case "mouseup": 8120this.execCommand("addundolevel"); 8121break; 8122case "keyup": 8123if(event.keyCode == 13 && (event.shiftKey == false)) { 8124var el = this.getParentElement(); 8125if(el.tagName == "BLOCKQUOTE") {
8126this.text_content.execCommand("outdent", false, value); 8127} else if(el.parentNode.tagName == "BLOCKQUOTE"){ 8128this.text_content.execCommand("outdent", false, value); 8129} 8130} 8131break; 8132case "keydown": 8133var sel = this.getSelection(); 8134if (sel.type == "Control") { 8135return; 8136} 8137var range = this.createRange(sel); 8138if (event.keyCode == 13 && (event.shiftKey == false)){ 8139if(browser.isIE) { 8140var el = this.getParentElement(); 8141if((el.tagName != "LI")){ 8142if(el.innerHTML == "") 8143range.pasteHTML(" "); 8144var value = (browser.isIE || browser.isOpera) ? "<div>" : "div"; 8145this.execCommand("formatblock", false, value); 8146} 8147this.execCommand("foce_addundolevel"); 8148this.detachBlockQuoteIE(); 8149} else { 8150this.execCommand("foce_addundolevel"); 8151this.detachBlockQuoteGecko(); 8152} 8153} 8154else if(event.keyCode == 8 || event.keyCode == 46){ 8155this.execCommand("addundolevel"); 8156} else if(event.keyCode == 9 && browser.isGecko && !event.shiftKey){ 8157Element.getChildElement(this.htmlModeBtn).focus(); 8158Event.stop(event); 8159} 8160break; 8161} 8162} 8163if(event.type == "keyup" || event.type == "mouseup") { 8164if (this.timerToolbar) { 8165clearTimeout(this.timerToolbar); 8166} 8167this.timerToolbar = setTimeout(function() { 8168this.updateToolbar(); 8169this.el_array = this.getAllAncestors(); 8170this.timerToolbar = null; 8171}.bind(this), 50); 8172} 8173}, 8174detachBlockQuoteIE: function() { 8175var range = this.text_content.selection.createRange(); 8176var id_name = "split_buf"; 8177var count = 0,buf_id_name = id_name; 8178while(this.text_content.getElementById(buf_id_name)) { 8179count += 1; 8180buf_id_name = id_name + count; 8181} 8182range.pasteHTML('<span id="' + buf_id_name + '"></span>'); 8183var id_name_el = this.text_content.getElementById(buf_id_name); 8184id_name_el.id = ""; 8185var node_arr = this.scanParentNode(id_name_el.parentNode), bq_el = null; 8186for(var i = 0; i < node_arr.length; i++) { 8187var buf_el= node_arr[i]; 8188if(buf_el.tagName == "BLOCKQUOTE" && Element.hasClassName(buf_el, "quote")) { 8189bq_el = buf_el; 8190} 8191} 8192if(bq_el) { 8193var clone_el = id_name_el.cloneNode(false); 8194var new_text_nd = this.cloneTextElement(id_name_el, clone_el, bq_el); 8195if(!bq_el.nextSibling) { 8196bq_el.parentNode.appendChild(new_text_nd); 8197} else { 8198bq_el.parentNode.insertBefore(new_text_nd, bq_el.nextSibling); 8199} 8200var br_el = this.text_content.createElement("BR"); 8201bq_el.parentNode.insertBefore(br_el, new_text_nd); 8202var div_el = this.text_content.createElement("DIV"); 8203bq_el.parentNode.insertBefore(div_el, br_el); 8204div_el.innerHTML=" "; 8205range.move("character",2); 8206range.select(); 8207div_el.innerHTML=""; 8208id_name_el.removeNode(true); 8209} 8210id_name_el.removeNode(true); 8211}, 8212detachBlockQuoteGecko: function() { 8213var sel = this.getSelection(); 8214var range = this.createRange(sel); 8215var cpRange = range.cloneRange(); 8216var stNode = sel.anchorNode; 8217var node_arr = this.scanParentNode(stNode.parentNode); 8218var bq_el = null; 8219for(var i=0;i<node_arr.length;i++) { 8220var buf_el = node_arr[i]; 8221if(buf_el.tagName=="BLOCKQUOTE" && Element.hasClassName(buf_el, "quote")) { 8222bq_el = buf_el; 8223} 8224} 8225var text_nd,nd_flag = false; 8226if(bq_el) 8227{ 8228if(stNode.nodeType == 3) { 8229text_nd = stNode.splitText(sel.anchorOffset); 8230} else { 8231nd_flag = true; 8232} 8233} else { 8234if(stNode.tagName == "BLOCKQUOTE" && Element.hasClassName(stNode, "quote")) { 8235bq_el = stNode; 8236nd_flag = true; 8237} 8238} 8239if(nd_flag) { 8240stNode = this.text_content.createTextNode(""); 8241cpRange.insertNode(stNode); 8242text_nd = this.text_content.createTextNode(""); 8243cpRange.insertNode(text_nd) 8244} 8245if(bq_el) { 8246var new_text_nd = this.cloneTextElement(stNode,text_nd,bq_el); 8247if(!bq_el.nextSibling) { 8248bq_el.parentNode.appendChild(new_text_nd) 8249} else { 8250bq_el.parentNode.insertBefore(new_text_nd, bq_el.nextSibling) 8251} 8252var br_el = this.text_content.createElement("BR"); 8253bq_el.parentNode.insertBefore(br_el, new_text_nd); 8254var div_el = this.text_content.createElement("DIV"); 8255div_el.innerHTML = " "; 8256bq_el.parentNode.insertBefore(div_el, br_el); 8257sel.collapse(div_el, 0); 8258} 8259}, 8260scanParentNode: function(el) { 8261var node_arr=[]; 8262while(el && el.nodeType==1 && el.tagName != "BODY") { 8263node_arr[node_arr.length] = el; 8264el = el.parentNode; 8265} 8266return node_arr; 8267}, 8268cloneTextElement: function(node_el, text_el, bq_el) { 8269while(node_el != bq_el) 8270{ 8271var parent_el = node_el.parentNode; 8272if(!parent_el) { 8273return false;
8274} 8275var clone_el = parent_el.cloneNode(false); 8276clone_el.appendChild(text_el); 8277var next_el = node_el.nextSibling; 8278while(next_el != null) { 8279parent_el.removeChild(next_el); 8280clone_el.appendChild(next_el); 8281next_el = node_el.nextSibling; 8282} 8283node_el = parent_el; 8284text_el = clone_el; 8285} 8286return text_el; 8287}, 8288updateToolbar: function() { 8289var text_content = this.text_content; 8290var text = (this.editMode == "html"); 8291for (var i in this.toolbarObjects) { 8292var btn = this.toolbarObjects[i]; 8293var cmd = i; 8294var inContext = true; 8295if (btn.element == undefined) { 8296continue; 8297} 8298btn.state("enabled", (!text || btn.text) && inContext); 8299if (typeof cmd == "function") { 8300continue; 8301} 8302var dropdown = this.config.customSelects[cmd]; 8303if ((!text || btn.text) && (typeof dropdown != "undefined")) { 8304dropdown.refresh(this); 8305continue; 8306} 8307switch (cmd) { 8308case "fontname": 8309case "fontsize": 8310case "formatblock": 8311if (!text) try { 8312var value = ("" + text_content.queryCommandValue(cmd)).toLowerCase(); 8313if (!value) { 8314btn.element.selectedIndex = 0; 8315break; 8316} 8317var options = this.config[cmd]; 8318var k = 0; 8319for (var j in options) { 8320if ((j.toLowerCase() == value) || 8321(options[j].substr(0, value.length).toLowerCase() == value)) { 8322btn.element.selectedIndex = k; 8323throw "ok"; 8324} 8325++k; 8326} 8327btn.element.selectedIndex = 0; 8328} catch(e) {}; 8329break; 8330case "htmlmode": btn.state("active", text); break; 8331case "lefttoright": 8332case "righttoleft": 8333var el = this.getParentElement(); 8334while (el && !this.isBlockElement(el)) 8335el = el.parentNode; 8336if (el) 8337btn.state("active", (el.style.direction == ((cmd == "righttoleft") ? "rtl" : "ltr"))); 8338break; 8339case "undo": 8340case "redo": 8341case "setforecolor": 8342case "forecolor": 8343case "createlink": 8344case "sethilitecolor": 8345case "hilitecolor": 8346case "removeformat": 8347case "inserttable": 8348case "tablemenu": 8349case "savezip": 8350case "insertvideo": 8351case "inserttex": 8352case "insertsmiley": 8353case "insertupload": 8354btn.state("active", false); 8355break; 8356case "createlink": 8357case "unablelink": 8358var el = this.getParentElement(); 8359if(el) { 8360var anchorLink = this.getParentElementByTagName(el, "a", "href"); 8361if (anchorLink) { 8362btn.state("active", true); 8363} else { 8364btn.state("active", false); 8365} 8366} else { 8367btn.state("active", false); 8368} 8369break; 8370default: 8371cmd = cmd.replace(/(un)?orderedlist/i, "insert$1orderedlist"); 8372try { 8373btn.state("active", (text_content.queryCommandState(cmd))); 8374} catch (e) {} 8375} 8376} 8377}, 8378createRange: function(sel) { 8379if((browser.isIE || browser.isOpera)) { 8380return sel.createRange(); 8381} else { 8382if (typeof sel != "undefined"){ 8383try { 8384return sel.getRangeAt(0); 8385} catch(e) { 8386return this.text_content.createRange(); 8387} 8388}else { 8389return this.text_content.createRange(); 8390} 8391} 8392}, 8393getSelection: function() { 8394return this.text_content.selection ? this.text_content.selection : this.text.contentWindow.getSelection(); 8395}, 8396undo: function() { 8397if (this.custom_undo_redo_levels >= 0) { 8398this.execCommand("addundolevel"); 8399var txt = this.undoLevels[--this.custom_undo_redo_levels]; 8400if (txt) this.text_content.body.innerHTML = txt; 8401else ++this.custom_undo_redo_levels; 8402} 8403}, 8404redo: function() { 8405if (this.custom_undo_redo_levels < this.undoLevels.length - 1) { 8406var txt = this.undoLevels[++this.custom_undo_redo_levels]; 8407if (txt) this.text_content.body.innerHTML = txt; 8408else --this.custom_undo_redo_levels; 8409} 8410}, 8411showColorDialog: function(cmdID, el, img_el, parent_id) { 8412if(cmdID == "forecolor" || cmdID == "hilitecolor") { 8413var img_el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_set"+cmdID); 8414this.change_el = { el: el, 8415img_el: img_el 8416} 8417} else { 8418this.change_el = { el: el, 8419img_el: img_el 8420} 8421} 8422if(cmdID == "forecolor" || cmdID == "hilitecolor") { 8423var offset = [0, 0]; 8424} else { 8425var popup_el = $(this.popup[this.popupPrefix + this.id + parent_id].popupID); 8426var offset = Position.cumulativeOffset(popup_el); 8427} 8428this.showDialogBox(cmdID, "comp_textarea_view_selectcolor", el, false, offset); 8429}, 8430showTableDialog: function(el) { 8431this.showDialogBox("inserttable", "comp_textarea_view_inserttable", el); 8432}, 8433showTableMenuDialog: function(el) { 8434this.showDialogBox("tablemenu", "comp_textarea_view_tablemenu", el); 8435}, 8436showTableMergeDialog: function(td) { 8437this.closePopup("tablemenu"); 8438this.closePopup("tableinsertmenu"); 8439var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_inserttable"); 8440this.showDialogBox("tablemerge", "comp_textarea_view_tablemerge", el); 8441}, 8442showTableOperationDialog: function() { 8443var el = $(this.popup[this.popupPrefix + this.id + "tablemenu"].popupID); 8444this.showDialogBox("tableinsertmenu", "comp_textarea_view_tableinsertmenu", el, true); 8445}, 8446insertImageDialog: function(image) { 8447if (typeof image == "undefined") { 8448image = this.getParentElement(); 8449if (image && !/^img$/i.test(image.tagName)) 8450image = null; 8451} 8452if (image) { 8453var border = valueParseInt(Element.getStyle(image, "borderWidth")); 8454if(typeof image.style.cssFloat != "undefined") { 8455var float_value = image.style.cssFloat; 8456} else { 8457var float_value = image.style.styleFloat; 8458} 8459if(float_value == "left" || float_value == "right") { 8460var align = float_value; 8461} else { 8462var align = image.align; 8463} 8464this.imageProperty = { 8465f_base : '', 8466f_url : (browser.isIE || browser.isOpera) ? image.src : image.getAttribute("src"), 8467f_alt : image.alt.strip(), 8468f_align : align, 8469f_border : (border <= 0) ? '' : border, 8470f_vert : (image.vspace <= 0) ? '' : image.vspace, 8471f_horiz : (image.hspace <= 0) ? '' : image.hspace, 8472f_width : image.offsetWidth, 8473f_height : image.offsetHeight 8474}; 8475} else { 8476this.imageProperty = { 8477f_base : '', 8478f_url : '', 8479f_alt : '', 8480f_border : '', 8481f_align : '', 8482f_vert : '', 8483f_horiz : '', 8484f_width : '', 8485f_height : '' 8486}; 8487} 8488this.el = image; 8489var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_insertimage"); 8490this.showDialogBox("insertimage", "comp_textarea_view_insertimage", el); 8491}, 8492insertTexDialog: function(image) { 8493if (typeof image == "undefined") { 8494image = this.getParentElement(); 8495if(image) { 8496image = this.getParentElementByTagName(image, "image", "src"); 8497} 8498} 8499if (image) { 8500if (/^img$/i.test(image.tagName)) { 8501this.texProperty = { 8502f_texexp : (browser.isIE || browser.isOpera) ? image.src : image.getAttribute("src") 8503}; 8504} else { 8505var str = this.createRange(this.getSelection()); 8506str = (browser.isIE || browser.isOpera) ? str.text : String(str); 8507this.texProperty = { 8508f_texexp : str.replace(/\n/g, '') 8509}; 8510} 8511} else { 8512image = null; 8513this.texProperty = { 8514f_texexp : '' 8515}; 8516} 8517this.el = image; 8518var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_inserttex"); 8519this.showDialogBox("inserttex", "comp_textarea_view_inserttex", el); 8520}, 8521insertSmileyDialog: function(el) { 8522this.showDialogBox("insertsmiley", "comp_textarea_view_insertsmiley", el); 8523}, 8524insertVideoDialog: function(el) { 8525this.showDialogBox("insertvideo", "comp_textarea_view_insertvideo", el); 8526}, 8527createLinkDialog: function(link) { 8528if (typeof link == "undefined") { 8529link = this.getParentElement(); 8530if (link) { 8531if (link && !/^a$/i.test(link.tagName)) 8532link = null; 8533} 8534} 8535if (!link) {
8536var sel = this.getSelection(); 8537this.linkProperty = { 8538f_href : '', 8539f_title : '', 8540f_target : '', 8541f_usetarget : true 8542}; 8543} else { 8544this.linkProperty = { 8545f_href : (browser.isIE || browser.isOpera) ? link.href : link.getAttribute("href"), 8546f_title : link.title, 8547f_target : link.target, 8548f_usetarget : true 8549}; 8550} 8551this.el = link; 8552var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_createlink"); 8553this.showDialogBox("createlink", "comp_textarea_view_createlink", el); 8554}, 8555insertUploadDialog: function(link) { 8556this.el = null; 8557if (typeof link == "undefined") { 8558link = this.getParentElement(); 8559if (link) { 8560if (link && !/^a$/i.test(link.tagName)) 8561link = null; 8562} 8563} 8564this.el = link; 8565var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_" + "insertupload"); 8566this.showDialogBox("insertupload", "comp_textarea_view_insertupload", el); 8567}, 8568setColor: function(cmdID, param) { 8569var color = null; 8570if(param.color != '' && param.color != '#') { 8571color = param.color.toLowerCase(); 8572} 8573if (color) { 8574this.closePopup(cmdID); 8575if(cmdID == "hilitecolor") { (browser.isIE || browser.isOpera|| browser.isSafari) && (cmdID = "backcolor");} 8576if(cmdID == "forecolor" || cmdID == "hilitecolor" || cmdID == "backcolor"){ 8577if(this.preRange.select) this.preRange.select(); 8578this.text_content.execCommand(cmdID, false, color); 8579}else { 8580this.change_el.el.value = color; 8581} 8582this.change_el.img_el.style.backgroundColor = color; 8583} 8584}, 8585insertTable: function(param) { 8586if(this.popup[this.popupPrefix + this.id + "edittable"]) { 8587var el = $(this.popup[this.popupPrefix + this.id + "edittable"].popupID); 8588} 8589if(el != undefined ) { 8590ret = this.setDialogProperty(el); 8591if(!ret) 8592return false; 8593} 8594this.closePopup("inserttable"); 8595if(typeof param != "undefined") { 8596if(this.preRange.select) 8597this.preRange.select(); 8598this.focusEditor(); 8599var row = param.f_rows; 8600var col = param.f_cols; 8601var sel = this.getSelection(); 8602var range = this.createRange(sel); 8603var text_content = this.text_content; 8604var table = text_content.createElement("table"); 8605for (var field in this.tableProperty) { 8606var value = this.tableProperty[field]; 8607if (!value) { 8608continue; 8609} 8610switch (field) { 8611case "f_width" : 8612if(value=="") 8613this.tableProperty.f_w_unit = ""; 8614table.style.width = (value + this.tableProperty.f_w_unit); break; 8615break; 8616case "f_height" : 8617if(value=="") 8618this.tableProperty.f_h_unit = ""; 8619table.style.height = value + this.tableProperty.f_h_unit; break; 8620break; 8621case "f_align" : table.align = value; break; 8622case "f_border" : 8623table.border = parseInt(value); 8624if(parseInt(value) == 0) { 8625table.style.border = "1px dotted #666665"; 8626} else if(this.tableProperty.f_border_style !="" || this.tableProperty.f_border_color !=""){ 8627table.style.borderColor = this.tableProperty.f_border_color; 8628table.style.borderStyle = this.tableProperty.f_border_style; 8629table.style.borderWidth = parseInt(value)+"px"; 8630} 8631break; 8632case "f_spacing" : table.cellSpacing = parseInt(value); break; 8633case "f_padding" : table.cellPadding = parseInt(value); break; 8634case "f_background" : 8635if(value!="") 8636table.style.backgroundColor=value; 8637break; 8638case "f_collapse" : 8639if(value) 8640table.style.borderCollapse = "collapse"; 8641break; 8642case "f_horiz" : 8643if(value) { 8644table.style.marginLeft = parseInt(value) + "px"; 8645table.style.marginRight = parseInt(value) + "px"; 8646} 8647break; 8648case "f_vert" : 8649if(value) { 8650table.style.marginTop = parseInt(value) + "px"; 8651table.style.marginBottom = parseInt(value) + "px"; 8652} 8653break; 8654} 8655} 8656var cellwidth = 0; 8657if (this.tableProperty.f_fixed) 8658cellwidth = Math.floor(100 / parseInt(col)); 8659var tbody = text_content.createElement("tbody"); 8660table.appendChild(tbody); 8661for (var i = 0; i < row; ++i) { 8662var tr = text_content.createElement("tr"); 8663tbody.appendChild(tr); 8664for (var j = 0; j < col; ++j) { 8665var td = text_content.createElement("td"); 8666var td_style = td.style; 8667if(this.tableProperty.f_border == 0) 8668td_style.border = "1px dotted #666665"; 8669else if(this.tableProperty.f_border_style !="" || this.tableProperty.f_border_color !=""){ 8670td_style.borderColor = this.tableProperty.f_border_color; 8671td_style.borderStyle = this.tableProperty.f_border_style; 8672td_style.borderWidth = parseInt(this.tableProperty.f_border)+"px"; 8673} 8674if (cellwidth) { 8675td_style.width = cellwidth + "%"; 8676} 8677tr.appendChild(td); 8678if (browser.isGecko) { 8679td.innerHTML = td.innerHTML + " "; 8680} 8681} 8682} 8683if (browser.isIE) { 8684range.pasteHTML(table.outerHTML); 8685range.pasteHTML("<div> </div>"); 8686} else { 8687this.insertNodeAtSelection(table); 8688} 8689return true; 8690} 8691}, 8692insertImage: function(params) { 8693this.closePopup("insertimage"); 8694this.closePopup("insertsmiley"); 8695if(this.preRange.select) { 8696this.preRange.select(); 8697} 8698this.focusEditor(); 8699if (!params) { 8700return false;
8701} 8702if(this.el && this.el.tagName.toLowerCase() == 'img') { 8703var img = this.el; 8704} else { 8705var img = ""; 8706} 8707if (!img) { 8708var sel = this.getSelection(); 8709var range = this.createRange(sel); 8710if(!browser.isSafari) { 8711this.text_content.execCommand("insertimage", false, params.f_url); 8712if (browser.isIE || browser.isOpera) { 8713img = range.parentElement(); 8714if (img.tagName.toLowerCase() != "img") { 8715img = img.previousSibling; 8716} 8717} else { 8718if (range.startContainer.nodeType == 1) { 8719img = range.startContainer.childNodes[range.startOffset]; 8720} else { 8721img = range.startContainer.nextSibling; 8722if (!img || !img.tagName || img.tagName.toLowerCase() != "img") { 8723img = range.startContainer.previousSibling; 8724} 8725} 8726} 8727} else { 8728img = this.insertImageSafari(params.f_url); 8729} 8730} else { 8731img.src = params.f_url; 8732} 8733img.alt = ""; 8734for (var field in params) { 8735var value = params[field]; 8736value = value.strip(); 8737switch (field) { 8738case "f_alt" : img.title = value; img.alt = value; break; 8739case "f_border" : Element.setStyle(img, {"border":parseInt(value || "0")+"px solid #cccccc"}); break; /* img.border = parseInt(value || "0"); */ 8740case "f_align" : 8741break; 8742case "f_vert" : img.vspace = parseInt(value || "0"); break; 8743case "f_horiz" : img.hspace = parseInt(value || "0"); break; 8744case "f_width" : img.style.width = (value=='' || value=='0') ? '' : parseInt(value || "0") + "px"; break; 8745case "f_height" : img.style.height = (value=='' || value=='0') ? '' : parseInt(value || "0") + "px"; break; 8746} 8747} 8748var value = params["f_align"]; 8749if(value == "") { 8750if(typeof img.style.cssFloat != "undefined") { 8751img.style.cssFloat = "none"; 8752} else { 8753img.style.styleFloat = "none"; 8754} 8755} 8756if(value == "left" || value == "right") { 8757if(typeof img.style.cssFloat != "undefined") { 8758img.style.cssFloat = value; 8759} else { 8760img.style.styleFloat = value; 8761} 8762} else { 8763img.align = value; 8764} 8765}, 8766insertUpload: function(params) { 8767this.closePopup("insertupload"); 8768if(this.preRange.select) 8769this.preRange.select(); 8770this.focusEditor(); 8771if (!params) { 8772return false; 8773} 8774if (this.el && this.el.tagName.toLowerCase() == 'a') { 8775var a = this.el; 8776} else { 8777var a = ""; 8778} 8779if (a) { 8780this.selectNodeContents(a); 8781this.text_content.execCommand("unlink", false, null); 8782} 8783var sel = this.getSelection(); 8784var range = this.createRange(sel); 8785if (browser.isIE) { 8786range.pasteHTML(params); 8787} else if(browser.isOpera) { 8788var p = this.getParentElement(); 8789var insert = this.text_content.createElement("span"); 8790insert.innerHTML = params; 8791p.appendChild(a); 8792} else if(browser.isSafari) { 8793range.setStart(this.text_content.body, 0); 8794range.setEnd(this.text_content.body, 0); 8795var insert = range.createContextualFragment(params); 8796if(this.startNode == this.endNode) { 8797range.setStartAfter(this.startNode); 8798} else { 8799range.setStartBefore(this.startNode); 8800} 8801range.setEndAfter(this.endNode); 8802if(this.startNode.tagName == "BR") { 8803for (var i = insert.childNodes.length - 1; i >= 0; i--) { 8804this.startNode.parentNode.insertBefore(insert.childNodes[i], this.startNode); 8805} 8806} else { 8807range.insertNode(insert); 8808} 8809} else { 8810var insert = range.createContextualFragment(params); 8811this.insertNodeAtSelection(insert); 8812} 8813}, 8814insertTex: function(params) { 8815this.closePopup("inserttex"); 8816if(this.preRange.select) 8817this.preRange.select(); 8818this.focusEditor(); 8819if (!params) { 8820return false; 8821} 8822if(this.el && this.el.tagName.toLowerCase() == 'img') 8823var img = this.el; 8824else 8825var img = ""; 8826var texexp = params.f_texexp.replace(/\'/g, "'"); 8827var texsrc = _nc_base_url + _nc_index_file_name + "?action=common_tex_main&c=" + encodeURIComponent(texexp).replace(/%C2%A5/g,"%5C").replace(/%/g, "%_"); 8828if (!img) { 8829var sel = this.getSelection(); 8830var range = this.createRange(sel); 8831if(!browser.isSafari) { 8832this.text_content.execCommand("insertimage", false, texsrc); 8833if (browser.isIE || browser.isOpera) { 8834img = range.parentElement(); 8835if (img.tagName.toLowerCase() != "img") { 8836img = img.previousSibling; 8837} 8838} else { 8839if (range.startContainer.nodeType == 1) { 8840img = range.startContainer.childNodes[range.startOffset]; 8841} else { 8842img = range.startContainer.previousSibling; 8843} 8844} 8845} else { 8846img = this.insertImageSafari(texsrc); 8847} 8848} else { 8849img.src = texsrc; 8850} 8851if (img) { 8852img.alt = "Tex"; 8853img.border = "0"; 8854} 8855}, 8856insertData: function(str) { 8857if(this.preRange.select) 8858this.preRange.select(); 8859this.focusEditor(); 8860if (!str) { 8861return false;
8862} 8863var sel = this.getSelection(); 8864var range = this.createRange(sel); 8865if (browser.isIE) { 8866range.pasteHTML(str); 8867} else { 8868var value = range.createContextualFragment(str); 8869range.insertNode(value); 8870} 8871}, 8872insertImageSafari: function(src) { 8873var range = this.preRange; 8874range.setStart(this.text_content.body, 0); 8875range.setEnd(this.text_content.body, 0); 8876var value = range.createContextualFragment("<img src=\"" + src + "\" />"); 8877var img = value.childNodes[0]; 8878if(this.startNode == this.endNode) { 8879range.setStartAfter(this.startNode); 8880} else { 8881range.setStartBefore(this.startNode); 8882} 8883range.setEndAfter(this.endNode); 8884if(this.startNode.tagName == "BR") { 8885this.startNode.parentNode.insertBefore(img, this.startNode); 8886} else { 8887if(this.startNode.tagName == "BODY" && this.endNode.tagName == "BODY" ) { 8888this.startNode.appendChild(img); 8889} else { 8890range.insertNode(value); 8891} 8892} 8893return img; 8894}, 8895insertLink: function(params) { 8896this.closePopup("createlink"); 8897if(this.preRange.select) 8898this.preRange.select(); 8899if (!params) 8900return false; 8901if(this.el && this.el.tagName.toLowerCase() == 'a') 8902var a = this.el; 8903else 8904var a = ""; 8905if (!a) try { 8906this.text_content.execCommand("createlink", false, params.f_href); 8907a = this.getParentElement(); 8908var sel = this.getSelection(); 8909var range = this.createRange(sel); 8910if (!(browser.isIE || browser.isOpera)) { 8911var buf_a = a; 8912a = range.startContainer; 8913if (!/^a$/i.test(a.tagName)) { 8914a = a.nextSibling; 8915if (a == null) 8916a = range.startContainer.parentNode; 8917if (!/^a$/i.test(a.tagName)) { 8918a = buf_a; 8919} 8920} 8921} else if (!/^a$/i.test(a.tagName) && a.tagName == "IMG") { 8922a = a.parentNode; 8923} 8924} catch(e) {} 8925else { 8926var href = params.f_href.trim(); 8927this.selectNodeContents(a); 8928if (href == "") { 8929this.text_content.execCommand("unlink", false, null); 8930this.updateToolbar(); 8931return false; 8932} 8933else { 8934a.href = href; 8935} 8936} 8937if (!(a && /^a$/i.test(a.tagName))){ 8938if(params.f_title.strip() != "") var title = params.f_title.strip(); 8939else var title = params.f_href; 8940if (browser.isIE) { 8941var text = "<a href=\"" + params.f_href + "\" "; 8942if(params.f_target.strip() != "") { 8943text += "target=\""+ params.f_target.strip() + "\" "; 8944} 8945if(params.f_title.strip() != "") { 8946text += "title=\""+ params.f_title.strip() + "\" "; 8947} 8948text += "/>" + title + "</a>"; 8949range.pasteHTML(text); 8950this.borderChange(); 8951return; 8952} else if(browser.isOpera) { 8953if (typeof compTextareaLang == "undefined" || typeof compTextareaLang.msg["selectlink_error"] == "undefined") 8954alert("You need to select some text before creating a link"); 8955else 8956alert(compTextareaLang.msg["selectlink_error"]); 8957return; 8958} else { 8959if(browser.isSafari) { 8960range.setStart(this.text_content.body, 0); 8961range.setEnd(this.text_content.body, 0); 8962} 8963var value = range.createContextualFragment("<a href=\"" + params.f_href + "\" />" + title + "</a>"); 8964var a = value.childNodes[0]; 8965if(browser.isSafari) { 8966if(this.startNode == this.endNode) { 8967range.setStartAfter(this.startNode); 8968} else { 8969range.setStartBefore(this.startNode); 8970} 8971range.setEndAfter(this.endNode); 8972if(this.startNode.tagName == "BR") { 8973this.startNode.parentNode.insertBefore(a, this.startNode); 8974} else { 8975range.insertNode(value); 8976} 8977} else { 8978range.insertNode(value); 8979} 8980} 8981} 8982a.target = params.f_target.strip(); 8983a.title = params.f_title.strip(); 8984this.selectNodeContents(a); 8985this.updateToolbar(); 8986this.borderChange(); 8987}, 8988updateTableMerge: function(numCols, numRows) { 8989if(numCols > 0 || numRows > 0) { 8990var table = null; 8991var edit_td = null; 8992var rows = new Array(); 8993for (var i = 0, el_array_len = this.el_array.length; i < el_array_len; ++i) { 8994var el_tmp = this.el_array[i]; 8995if (el_tmp.tagName.toLowerCase() == "table") { 8996table = el_tmp; 8997break; 8998}else if (el_tmp.tagName.toLowerCase() == "td") { 8999edit_td = el_tmp; 9000} 9001} 9002if(table == undefined) 9003return; 9004var tableData = this.getTableData(table); 9005var cpos = this.getCellPos(tableData, edit_td); 9006for (var i=cpos.rowindex,tableData_len = tableData.length; i < tableData_len; i++) { 9007var rowCells = new Array(); 9008for (var j= cpos.cellindex, tableData_rowlen = tableData[i].length; j < tableData_rowlen; j++) { 9009var td = tableData[i][j]; 9010if (td && !this.inArray(rows, td) && !this.inArray(rowCells, td)) { 9011var cp = this.getCellPos(tableData, td); 9012if (cp.cellindex >= cpos.cellindex && cp.cellindex < cpos.cellindex+parseInt(numCols) + 1 &&
9013cp.rowindex >= cpos.rowindex && cp.rowindex < cpos.rowindex+parseInt(numRows) + 1){ 9014rowCells[rowCells.length] = td; 9015} 9016} 9017} 9018if (rowCells.length > 0){ 9019rows[rows.length] = rowCells; 9020} 9021} 9022var rowSpan = 1, colSpan = 1; 9023var lastRowSpan = -1; 9024var row_len = rows.length; 9025if(row_len > 0) { 9026for (var i=0; i<row_len; i++) { 9027var rowColSpan = 0; 9028for (var j=0; j<rows[i].length; j++) { 9029rowColSpan += rows[i][j].colSpan; 9030if (lastRowSpan != -1 && rows[i][j].rowSpan != lastRowSpan) { 9031alert(compTextareaLang.msg["tablemerge_row_error"]); 9032return true; 9033} 9034lastRowSpan = rows[i][j].rowSpan; 9035} 9036if (rowColSpan > colSpan) 9037colSpan = rowColSpan; 9038lastRowSpan = -1; 9039} 9040var lastColSpan = -1; 9041for (var i=0; i<rows[0].length; i++) { 9042var colRowSpan = 0; 9043for (var j=0, col_len = rows.length; j<col_len; j++) { 9044colRowSpan += rows[j][i].rowSpan; 9045if (lastColSpan != -1 && rows[j][i].colSpan != lastColSpan) { 9046alert(compTextareaLang.msg["tablemerge_col_error"]); 9047return true; 9048} 9049lastColSpan = rows[j][i].colSpan; 9050} 9051if (colRowSpan > rowSpan) 9052rowSpan = colRowSpan; 9053lastColSpan = -1; 9054} 9055tdElm = rows[0][0]; 9056tdElm.rowSpan = rowSpan; 9057tdElm.colSpan = colSpan; 9058for (var i=0; i<rows.length; i++) { 9059for (var j=0; j<rows[i].length; j++) { 9060var html = rows[i][j].innerHTML; 9061if(html == "<br>" || html == "<br />" || html == " ") { 9062; 9063} else { 9064tdElm.innerHTML += html; 9065} 9066if (rows[i][j] != tdElm && !rows[i][j]._deleted) { 9067var cpos = this.getCellPos(tableData, rows[i][j]); 9068var tr = rows[i][j].parentNode; 9069tr.removeChild(rows[i][j]); 9070rows[i][j]._deleted = true; 9071if (!tr.hasChildNodes()) { 9072tr.parentNode.removeChild(tr); 9073var lastCell = null; 9074for (var x=0; cellElm = tableData[cpos.rowindex][j]; j++) { 9075if (cellElm != lastCell && cellElm.rowSpan > 1) 9076cellElm.rowSpan--; 9077lastCell = cellElm; 9078} 9079if (tdElm.rowSpan > 1) 9080tdElm.rowSpan--; 9081} 9082} 9083} 9084if(browser.isGecko && tdElm.innerHTML == "") 9085tdElm.innerHTML = " "; 9086} 9087} 9088} 9089this.closePopup("tablemerge"); 9090}, 9091closePopup: function(cmdID) { 9092if(this.popup[this.popupPrefix + this.id + cmdID]) { 9093this.popup[this.popupPrefix + this.id + cmdID].closePopup(); 9094if(cmdID == "inserttable" && this.popup[this.popupPrefix + this.id + "edittable"]) { 9095this.closePopup("edittable"); 9096} 9097} 9098}, 9099updateTable: function(edit_name, update_area) { 9100if(update_area != undefined && update_area > 0) { 9101for (var i = 0; i < this.el_array.length; ++i) { 9102var el_tmp = this.el_array[i]; 9103if (el_tmp.tagName.toLowerCase() == "table" && (edit_name == "edittablerow" || (edit_name == "edittablecell" && update_area==2))) { 9104break; 9105}else if (el_tmp.tagName.toLowerCase() == "tr" && edit_name == "edittablecell" && update_area==1) { 9106break; 9107} 9108} 9109if(edit_name == "edittablerow"){ 9110var trList = el_tmp.getElementsByTagName("tr"); 9111for (var i = 0; i < trList.length; i++){ 9112this.el = trList[i]; 9113this.updateTable(edit_name,-1); 9114} 9115}else{ 9116var tdList = el_tmp.getElementsByTagName("td"); 9117for (var i = 0; i < tdList.length; i++){ 9118this.el = tdList[i]; 9119this.updateTable(edit_name,-1); 9120} 9121} 9122this.closePopup(edit_name); 9123return ; 9124} 9125var el = $(this.popup[this.popupPrefix + this.id + edit_name].popupID); 9126if(el == undefined) 9127return; 9128if(el != undefined ) { 9129ret = this.setDialogProperty(el); 9130if(!ret) 9131return false; 9132} 9133if(update_area == undefined || update_area >= 0) 9134this.closePopup(edit_name); 9135var el_style = this.el.style; 9136for (var field in this.tableProperty) { 9137var value = this.tableProperty[field]; 9138if (edit_name == "edittable" && field.substr(0,1)!='f') 9139continue; 9140else if(edit_name == "edittablerow" && field.substr(0,1)!='r') 9141continue; 9142else if(edit_name == "edittablecell" && field.substr(0,1)!='c') 9143continue; 9144switch (field) { 9145case "f_width" : 9146if(value=="") 9147this.tableProperty.f_w_unit = ""; 9148el_style.width = value + this.tableProperty.f_w_unit; break; 9149break; 9150case "r_width" : 9151if(value=="") 9152this.tableProperty.r_w_unit = ""; 9153el_style.width = value + this.tableProperty.r_w_unit; break; 9154break; 9155case "c_width" : 9156if(value=="") 9157this.tableProperty.c_w_unit = ""; 9158el_style.width = value + this.tableProperty.c_w_unit; break; 9159break; 9160case "f_height" : 9161if(value=="") 9162this.tableProperty.f_h_unit = ""; 9163el_style.height = value + this.tableProperty.f_h_unit; break; 9164break; 9165case "r_height" : 9166if(value=="") 9167this.tableProperty.r_h_unit = ""; 9168el_style.height = value + this.tableProperty.r_h_unit; break; 9169break; 9170case "c_height" : 9171if(value=="") 9172this.tableProperty.c_h_unit = ""; 9173el_style.height = value + this.tableProperty.c_h_unit; break; 9174break; 9175case "f_align" : this.el.align = value; break; 9176case "r_align" : 9177case "c_align" : 9178el_style.textAlign = value; 9179break; 9180case "r_valign" : 9181case "c_valign" : 9182el_style.verticalAlign = value; break; 9183case "f_border" : 9184this.el.border = parseInt(value); 9185if(parseInt(value) == 0) 9186el_style.border = "1px dotted #666665"; 9187else if(this.tableProperty.f_border_style !="" || this.tableProperty.f_border_color !=""){ 9188el_style.borderWidth = parseInt(value)+"px"; 9189el_style.borderColor = this.tableProperty.f_border_color; 9190el_style.borderStyle = this.tableProperty.f_border_style + " " + this.tableProperty.f_border_style + " " + this.tableProperty.f_border_style + " " + this.tableProperty.f_border_style; 9191} 9192break; 9193case "c_t_border" : 9194var parent_el = Element.getParentElement(this.el,3); 9195if(parent_el.tagName.toLowerCase() == "table" && parent_el.border == 0) 9196el_style.borderTop = "1px dotted #666665"; 9197else if(this.tableProperty.c_t_border_style !="" || this.tableProperty.c_t_border_color !=""){ 9198el_style.borderTopWidth = parseInt(value)+"px"; 9199el_style.borderTopColor = this.tableProperty.c_t_border_color; 9200el_style.borderTopStyle = this.tableProperty.c_t_border_style; 9201} 9202break; 9203case "c_r_border" : 9204var parent_el = Element.getParentElement(this.el,3); 9205if(parent_el.tagName.toLowerCase() == "table" && parent_el.border == 0) 9206el_style.borderRight = "1px dotted #666665"; 9207else if(this.tableProperty.c_r_border_style !="" || this.tableProperty.c_r_border_color !=""){ 9208el_style.borderRightWidth = parseInt(value)+"px"; 9209el_style.borderRightColor = this.tableProperty.c_r_border_color; 9210el_style.borderRightStyle = this.tableProperty.c_r_border_style; 9211} 9212break; 9213case "c_b_border" : 9214var parent_el = Element.getParentElement(this.el,3); 9215if(parent_el.tagName.toLowerCase() == "table" && parent_el.border == 0) 9216el_style.borderBottom = "1px dotted #666665"; 9217else if(this.tableProperty.c_b_border_style !="" || this.tableProperty.c_b_border_color !=""){ 9218el_style.borderBottomWidth = parseInt(value)+"px"; 9219el_style.borderBottomColor = this.tableProperty.c_b_border_color; 9220el_style.borderBottomStyle = this.tableProperty.c_b_border_style; 9221} 9222break; 9223case "c_l_border" : 9224var parent_el = Element.getParentElement(this.el,3); 9225if(parent_el.tagName.toLowerCase() == "table" && parent_el.border == 0) 9226el_style.borderLeft = "1px dotted #666665"; 9227else if(this.tableProperty.c_l_border_style !="" || this.tableProperty.c_l_border_color !=""){ 9228el_style.borderLeftWidth = parseInt(value)+"px"; 9229el_style.borderLeftColor = this.tableProperty.c_l_border_color; 9230el_style.borderLeftStyle = this.tableProperty.c_l_border_style; 9231} 9232break; 9233case "f_spacing" : this.el.cellSpacing = parseInt(value); break; 9234case "f_padding" : this.el.cellPadding = parseInt(value); break; 9235case "f_background" : 9236case "r_background" : 9237case "c_background" : 9238if(value!="") 9239el_style.backgroundColor=value; 9240else 9241el_style.backgroundColor=""; 9242break; 9243case "r_fontcolor" : 9244case "c_fontcolor" : 9245if(value!="") 9246el_style.color=value; 9247else 9248el_style.color=""; 9249break; 9250case "f_collapse" : 9251if(value) 9252el_style.borderCollapse = "collapse"; 9253else 9254el_style.borderCollapse = "separate"; 9255break; 9256case "c_nowrap" : 9257if(value) 9258el_style.whiteSpace = "nowrap"; 9259else 9260el_style.whiteSpace = ""; 9261break; 9262case "f_horiz" : 9263if(value) { 9264el_style.marginLeft = parseInt(value) + "px"; 9265el_style.marginRight = parseInt(value) + "px"; 9266} 9267break; 9268case "f_vert" : 9269if(value) { 9270el_style.marginTop = parseInt(value) + "px"; 9271el_style.marginBottom = parseInt(value) + "px"; 9272} 9273break; 9274} 9275} 9276if(this.el.tagName.toLowerCase() == "table") { 9277var tdList = this.el.getElementsByTagName("td"); 9278var col = 0; 9279for (var i = 0; i < tdList.length; i++){ 9280col = col + tdList[i].colSpan; 9281} 9282col = col/this.el.rows.length; 9283var cellwidth = 0; 9284if (this.tableProperty.f_fixed) 9285cellwidth = Math.floor(100 / parseInt(col)); 9286var td = null; 9287for (var i = 0; i < tdList.length; i++){ 9288var td_style = tdList[i].style; 9289if(this.tableProperty.f_border == 0) 9290td_style.border = "1px dotted #666665"; 9291else if(this.tableProperty.f_border_style !="" || this.tableProperty.f_border_color !=""){ 9292td_style.borderWidth = parseInt(this.tableProperty.f_border)+"px"; 9293td_style.borderColor = this.tableProperty.f_border_color; 9294td_style.borderStyle = this.tableProperty.f_border_style + " " + this.tableProperty.f_border_style + " " + this.tableProperty.f_border_style + " " + this.tableProperty.f_border_style; 9295} 9296var re = /\s*%/; 9297if (cellwidth!=0) 9298td_style.width = cellwidth*tdList[i].colSpan + "%"; 9299else if (td_style.width.match(re)) 9300td_style.width = ""; 9301} 9302var table = this.el; 9303} else { 9304var table = this.el; 9305while(1) { 9306table = table.parentNode; 9307if(!table) { 9308break; 9309} 9310if(table.tagName.toLowerCase() == "table") { 9311break; 9312} 9313} 9314} 9315if(table) { 9316this.tableRedraw(table); 9317} 9318this.forceRedraw(); 9319this.focusEditor(); 9320}, 9321getTableData: function(table) { 9322var rows = table.rows; 9323var ret = new Array(); 9324for (var i=0; i<rows.length; i++) { 9325for (var j=0; j<rows[i].cells.length; j++) { 9326var td = rows[i].cells[j]; 9327for (var jstart = j; ret[i] && ret[i][jstart]; jstart++) ; 9328for (var i2=i; i2<i+td.rowSpan; i2++) { 9329if (!ret[i2]) 9330ret[i2] = new Array(); 9331for (var j2=jstart; j2 < jstart+td.colSpan; j2++) { 9332ret[i2][j2] = td; 9333} 9334} 9335} 9336} 9337return ret; 9338}, 9339inArray: function(ar, v) { 9340for (var i=0; i<ar.length; i++) { 9341if (ar[i].length > 0 && this.inArray(ar[i], v)) 9342return true; 9343if (ar[i] == v) 9344return true; 9345} 9346return false;
9347}, 9348getCellPos: function(tableData, td) { 9349for (var y=0; y<tableData.length; y++) { 9350for (var x=0; x<tableData[y].length; x++) { 9351if (tableData[y][x] == td) 9352return {cellindex : x, rowindex : y}; 9353} 9354} 9355return null; 9356}, 9357showDialogBox: function(cmdID, action_name, el, right_flag , offset, modal_flag) { 9358var update_flag = this.update_flag; 9359var EX1 = Position.positionedOffset(el)[0]; 9360var EY1 = Position.positionedOffset(el)[1]; 9361var EY2 = el.offsetHeight + EY1; 9362var EX2 = el.offsetWidth + EX1; 9363offset = (offset == undefined || offset == null) ? [0,0] : offset; 9364modal_flag = (modal_flag == undefined || modal_flag == null) ? true : modal_flag; 9365if(right_flag) { 9366var x = EX2 + offset[0]; 9367var y = EY1 + offset[1]; 9368} else { 9369var x = EX1 + offset[0]; 9370var y = EY2 + offset[1]; 9371} 9372if(browser.isSafari) { 9373this.preSel = this.getSelection(); 9374this.preRange = this.createRange(this.preSel); 9375var sel = this.preSel; 9376if(sel.focusNode) { 9377var rngBefore = this.createRange(sel); 9378rngBefore.setEndBefore(sel.anchorNode); 9379rngBefore.collapse(true); 9380var rngAfter = this.createRange(sel); 9381rngAfter.setEndAfter(sel.focusNode); 9382rngAfter.collapse(true); 9383var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0; 9384this.startNode = direct ? sel.anchorNode : sel.focusNode; 9385this.startOffset = direct ? sel.anchorOffset : sel.focusOffset; 9386this.endNode = direct ? sel.focusNode : sel.anchorNode; 9387this.endOffset = direct ? sel.focusOffset : sel.anchorOffset; 9388} else { 9389this.startNode = this.text_content.body; 9390this.endNode = this.text_content.body; 9391this.startOffset = 0; 9392this.endOffset = 0; 9393} 9394} else { 9395var sel = this.getSelection(); 9396this.preRange = this.createRange(sel); 9397} 9398if((cmdID == "insertimage" || cmdID == "insertupload") && !browser.isIE) { 9399var src = _nc_base_url + _nc_index_file_name + "?action=" + action_name + "&prefix_id_name="+ "dialog_"+cmdID + "&parent_id_name=" + 9400this.id + this.popupPrefix + "&top_id_name=" + this.id + "&cmd_name=" + cmdID + "&update_flag=" + update_flag + 9401"&_header=1&_noscript=1"; 9402var queryParams = commonCls.getParams(this.id); 9403if(queryParams) { 9404var page_id = queryParams["page_id"]; 9405var block_id = queryParams["block_id"]; 9406var module_id = queryParams["module_id"]; 9407if(page_id) src += "&page_id=" + page_id; 9408if(block_id) src += "&block_id=" + block_id; 9409if(module_id) src += "&module_id=" + module_id; 9410} 9411this._showPopup(cmdID, null, x, y, modal_flag, src); 9412} else { 9413var dialog_params = new Object(); 9414dialog_params["param"] = {"action":action_name,"prefix_id_name":"dialog_"+cmdID, "parent_id_name":this.id + this.popupPrefix, "cmd_name":cmdID, "update_flag":update_flag, "top_id_name":this.id,"_noscript":1}; 9415dialog_params["top_el"] = this.id; 9416dialog_params["callbackfunc"] = function(res) { 9417if(!modal_flag && cmdID == "edittable") { 9418var insert_el = $(this.popup[this.popupPrefix + this.id + "inserttable"].popupID); 9419if(!insert_el || insert_el.style.display == "none") { 9420return; 9421} 9422} 9423this._showPopup(cmdID, res, x, y, modal_flag); 9424}.bind(this); 9425commonCls.send(dialog_params); 9426} 9427}, 9428_showPopup: function(cmdID, res, x, y, modal_flag, src) { 9429this.popup[this.popupPrefix + this.id + cmdID] = new compPopup(this.id, this.popupPrefix + this.id + cmdID); 9430if(modal_flag) { 9431this.popup[this.popupPrefix + this.id + cmdID].observer = function(){this.closePopup(cmdID);}.bind(this); 9432this.popup[this.popupPrefix + this.id + cmdID].observing = true; 9433this.popup[this.popupPrefix + this.id + cmdID].modal = true; 9434} else { 9435this.popup[this.popupPrefix + this.id + cmdID].observing = false; 9436this.popup[this.popupPrefix + this.id + cmdID].modal = false; 9437} 9438if(typeof compTextareaLang != "undefined" && typeof compTextareaLang.icons[cmdID] != "undefined") { 9439this.popup[this.popupPrefix + this.id + cmdID].setTitle(compTextareaLang.icons[cmdID]); 9440} 9441this.popup[this.popupPrefix + this.id + cmdID].setPosition(Array(x, y)); 9442if(res == null) { 9443if(this.popup[this.popupPrefix + this.id + cmdID].popupElement) { 9444this.popup[this.popupPrefix + this.id + cmdID].popupElement.src = ""; 9445} 9446this.popup[this.popupPrefix + this.id + cmdID].showSrcPopup(src); 9447} else { 9448this.popup[this.popupPrefix + this.id + cmdID].showPopup(res); 9449} 9450}, 9451setDialogProperty: function(el) { 9452var contentWin = el.contentWindow; 9453if(contentWin && contentWin.getProperty != undefined) { 9454var params = contentWin.getProperty(); 9455if(params == false) 9456return false;
9457for (var field in params) { 9458var value = eval("params." + field); 9459this.tableProperty[field] = value; 9460} 9461} 9462return true; 9463}, 9464showCellSetProperty: function(el) { 9465if(el) { 9466var el_style = el.style; 9467for (var field in this.tableProperty) { 9468var value = this.tableProperty[field]; 9469if (el.tagName.toLowerCase() == "tr" && field.substr(0,1)!='r') 9470continue; 9471else if(el.tagName.toLowerCase() == "td" && field.substr(0,1)!='c') 9472continue; 9473switch (field) { 9474case "r_width" : 9475var re = /\s*%/; 9476if (el_style.width.match(re)) { 9477this.tableProperty.r_w_unit = "%"; 9478}else{ 9479this.tableProperty.r_w_unit = "px"; 9480} 9481this.tableProperty.r_width = (isNaN(parseInt(el_style.width))==true) ? "" : parseInt(el_style.width); 9482break; 9483case "c_width" : 9484var re = /\s*%/; 9485if (el_style.width.match(re)) { 9486this.tableProperty.c_w_unit = "%"; 9487}else{ 9488this.tableProperty.c_w_unit = "px"; 9489} 9490this.tableProperty.c_width = (isNaN(parseInt(el_style.width))==true) ? "" : parseInt(el_style.width); 9491break; 9492case "r_height" : 9493var re = /\s*%/; 9494if (el_style.height.match(re)) { 9495this.tableProperty.r_h_unit = "%"; 9496}else{ 9497this.tableProperty.r_h_unit = "px"; 9498} 9499this.tableProperty.r_height = (isNaN(parseInt(el_style.height))==true) ? "" : parseInt(el_style.height); 9500break; 9501case "c_height" : 9502var re = /\s*%/; 9503if (el_style.height.match(re)) { 9504this.tableProperty.c_h_unit = "%"; 9505}else{ 9506this.tableProperty.c_h_unit = "px"; 9507} 9508this.tableProperty.c_height = (isNaN(parseInt(el_style.height))==true) ? "" : parseInt(el_style.height); 9509break; 9510case "r_align" : 9511this.tableProperty.r_align = el_style.textAlign; break; 9512case "c_align" : 9513this.tableProperty.c_align = el_style.textAlign; break; 9514case "r_valign" : 9515this.tableProperty.r_valign = el_style.verticalAlign; break; 9516case "c_valign" : 9517this.tableProperty.c_valign = el_style.verticalAlign; break; 9518case "c_t_border" : 9519this.tableProperty.c_t_border = (isNaN(parseInt(el_style.borderTopWidth))==true) ? "" : parseInt(el_style.borderTopWidth); 9520this.tableProperty.c_t_border_style = el_style.borderTopStyle; 9521this.tableProperty.c_t_border_color = this.getColorCode(el, "borderTopColor"); 9522break; 9523case "c_r_border" : 9524this.tableProperty.c_r_border = (isNaN(parseInt(el_style.borderRightWidth))==true) ? "" : parseInt(el_style.borderRightWidth); 9525this.tableProperty.c_r_border_style = el_style.borderRightStyle; 9526this.tableProperty.c_r_border_color = this.getColorCode(el, "borderRightColor"); 9527break; 9528case "c_b_border" : 9529this.tableProperty.c_b_border = (isNaN(parseInt(el_style.borderBottomWidth))==true) ? "" : parseInt(el_style.borderBottomWidth); 9530this.tableProperty.c_b_border_style = el_style.borderBottomStyle; 9531this.tableProperty.c_b_border_color = this.getColorCode(el, "borderBottomColor"); 9532break; 9533case "c_l_border" : 9534this.tableProperty.c_l_border = (isNaN(parseInt(el_style.borderLeftWidth))==true) ? "" : parseInt(el_style.borderLeftWidth); 9535this.tableProperty.c_l_border_style = el_style.borderLeftStyle; 9536this.tableProperty.c_l_border_color = this.getColorCode(el, "borderLeftColor"); 9537break; 9538case "r_background" : 9539this.tableProperty.r_background = this.getColorCode(el, "backgroundColor"); 9540break; 9541case "c_background" : 9542this.tableProperty.c_background = this.getColorCode(el, "backgroundColor"); 9543break; 9544case "r_fontcolor" : 9545this.tableProperty.r_fontcolor = this.getColorCode(el, "color"); 9546break; 9547case "c_fontcolor" : 9548this.tableProperty.c_fontcolor = this.getColorCode(el, "color"); 9549break; 9550case "c_nowrap" : 9551this.tableProperty.c_nowrap = el_style.whiteSpace; 9552break; 9553} 9554} 9555} 9556if (el.tagName.toLowerCase() == "tr") { 9557var cmdID = "edittablerow"; 9558} else { 9559var cmdID = "edittablecell"; 9560} 9561this.el =el; 9562this.update_flag = true; 9563var tablemenu_el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_" + "tablemenu"); 9564this.showDialogBox(cmdID, "comp_textarea_view_" + cmdID, tablemenu_el, true); 9565this.closePopup("tablemenu"); 9566}, 9567showTableSetProperty: function(el) { 9568var table = el; 9569if(table) { 9570for (var field in this.tableProperty) { 9571var value = this.tableProperty[field]; 9572switch (field) { 9573case "f_width" : 9574var re = /\s*%/; 9575if (table.style.width.match(re)) { 9576this.tableProperty.f_w_unit = "%"; 9577}else{ 9578this.tableProperty.f_w_unit = "px"; 9579} 9580this.tableProperty.f_width = (isNaN(parseInt(table.style.width))==true) ? "" : parseInt(table.style.width); 9581break; 9582case "f_height" : 9583var re = /\s*%/; 9584if (table.style.height.match(re)) { 9585this.tableProperty.f_h_unit = "%"; 9586}else{ 9587this.tableProperty.f_h_unit = "px"; 9588} 9589this.tableProperty.f_height = (isNaN(parseInt(table.style.height))==true) ? "" : parseInt(table.style.height); 9590break; 9591case "f_align" : this.tableProperty.f_align = table.align; break; 9592case "f_border" : 9593if(table.border == 0) { 9594this.tableProperty.f_border = "0"; 9595}else{ 9596this.tableProperty.f_border = (isNaN(parseInt(table.style.borderWidth))==true) ? "" : parseInt(table.style.borderWidth); 9597this.tableProperty.f_border_style = table.style.borderStyle; 9598this.tableProperty.f_border_color = this.getColorCode(table, "borderColor"); 9599} 9600break; 9601case "f_spacing" : this.tableProperty.f_spacing = table.cellSpacing; break; 9602case "f_padding" : this.tableProperty.f_padding = table.cellPadding; break; 9603case "f_background" : 9604this.tableProperty.f_background = this.getColorCode(table, "backgroundColor"); 9605break; 9606case "f_collapse" : 9607this.tableProperty.f_collapse = table.style.borderCollapse; 9608break; 9609case "f_horiz" : 9610this.tableProperty.f_horiz = valueParseInt(table.style.marginLeft); 9611break; 9612case "f_vert" : 9613this.tableProperty.f_vert = valueParseInt(table.style.marginTop); 9614break; 9615} 9616} 9617var tdList = table.getElementsByTagName("td"); 9618var col = 0; 9619for (var i = 0; i < tdList.length; i++){ 9620col = col + tdList[i].colSpan; 9621} 9622col = col/table.rows.length; 9623var cellwidth = 0; 9624cellwidth = Math.floor(100 / parseInt(col)); 9625var td_tmp = null; 9626var fix_flag = true; 9627for (var i = 0; i < tdList.length; i++){ 9628td_tmp = tdList[i]; 9629if (cellwidth*tdList[i].colSpan + "%"==td_tmp.style.width) 9630; 9631else{ 9632fix_flag = false;
9633break; 9634} 9635} 9636if(fix_flag) 9637this.tableProperty.f_fixed = true; 9638else 9639this.tableProperty.f_fixed = false; 9640} 9641var update_flag = false; 9642if(typeof el != "undefined") { 9643this.el = el; 9644update_flag = true; 9645} 9646this.update_flag = update_flag; 9647if(this.popup[this.popupPrefix + this.id + "edittable"] && this.popup[this.popupPrefix + this.id + "edittable"].isVisible()) { 9648this.closePopup("edittable"); 9649} else { 9650if(table) { 9651var tablemenu_el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_" + "tablemenu"); 9652this.showDialogBox("edittable", "comp_textarea_view_edittable", tablemenu_el, true); 9653this.closePopup("tablemenu"); 9654} else { 9655var inserttable_el = $(this.popup[this.popupPrefix + this.id + "inserttable"].popupID); 9656this.showDialogBox("edittable", "comp_textarea_view_edittable", inserttable_el, true, null, false); 9657} 9658} 9659}, 9660isBlockElement: function(el) { 9661var blockTags = " body form textarea fieldset ul ol dl li div " + 9662"p h1 h2 h3 h4 h5 h6 quote pre table thead " + 9663"tbody tfoot tr td iframe address "; 9664return el && el.nodeType == 1 && (blockTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); 9665}, 9666getAllAncestors: function() { 9667var p = this.getParentElement(); 9668var a = []; 9669while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) { 9670a.push(p); 9671p = p.parentNode; 9672} 9673a.push(this.text_content.body); 9674return a; 9675}, 9676getParentElementByTagName : function(n, na, f, r) { 9677var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v; 9678if (f && typeof(f) == 'string') 9679return this.getParentElementByTagName(n, na, function(no) {return this.getAttrib(no, f) !== '';}.bind(this)); 9680return this.getParentNode(n, function(n) { 9681return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n)); 9682}, r); 9683}, 9684getParentNode : function(n, f, r) { 9685while (n) { 9686if (n == r) 9687return null; 9688if (f(n)) 9689return n; 9690n = n.parentNode; 9691} 9692return null; 9693}, 9694getAttrib : function(elm, name, dv) { 9695var v; 9696if (typeof(dv) == "undefined") 9697dv = ""; 9698if (!elm || elm.nodeType != 1) 9699return dv; 9700try { 9701v = elm.getAttribute(name, 0); 9702} catch (e) { 9703v = elm.getAttribute(name, 2); 9704} 9705if (name == "class" && !v) 9706v = elm.className; 9707if (browser.isGecko) { 9708if (name == "src" && elm.src != null && elm.src !== '') 9709v = elm.src; 9710if (name == "href" && elm.href != null && elm.href !== '') 9711v = elm.href; 9712} else if (browser.isIE) { 9713switch (name) { 9714case "http-equiv": 9715v = elm.httpEquiv; 9716break; 9717case "width": 9718case "height": 9719v = elm.getAttribute(name, 2); 9720break; 9721} 9722} 9723if (name == "style" && !browser.isOpera) 9724v = elm.style.cssText; 9725return (v && v !== '') ? v : dv; 9726}, 9727getParentElement: function() { 9728var sel = this.getSelection(); 9729var range = this.createRange(sel); 9730if ((browser.isIE || browser.isOpera)) { 9731switch (sel.type) { 9732case "Text": 9733case "None": 9734return range.parentElement(); 9735case "Control": 9736return range.item(0); 9737default: 9738return this.text_content.body; 9739} 9740} else if(browser.isSafari) { 9741if(sel.focusNode) { 9742return sel.anchorNode; 9743} else { 9744return null; 9745} 9746} else try { 9747var p = range.commonAncestorContainer; 9748if (!range.collapsed && range.startContainer == range.endContainer && 9749range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes()) 9750p = range.startContainer.childNodes[range.startOffset]; 9751while (p.nodeType == 3) { 9752p = p.parentNode; 9753} 9754return p; 9755} catch (e) { 9756return null; 9757} 9758}, 9759getSelectElements: function() { 9760var sel = this.getSelection(); 9761var range = this.createRange(sel); 9762var ret_el = Array(); 9763if ((browser.isIE || browser.isOpera)) { 9764switch (sel.type) { 9765case "Text": 9766case "None": 9767var bufText = range.htmlText.replace(/[\n\r]/g,""); 9768var el = range.parentElement(); 9769if(el.tagName == "BODY") { 9770var j = 0; 9771for (var i = 0; i < el.childNodes.length; i++) { 9772var re_el = new RegExp(el.childNodes[i].outerHTML.replace(/[\n\r]/g,""), "i"); 9773if(this.isBlockElement(el.childNodes[i]) && bufText.match(re_el)) { 9774ret_el[j] = el.childNodes[i]; 9775j++; 9776} 9777} 9778} else { 9779var re_el = new RegExp(el.outerHTML.replace(/[\n\r]/g,""), "i"); 9780bufText = bufText.replace(re_el, ""); 9781ret_el[0] = el; 9782if(bufText.length > 0) { 9783var j = 1; 9784while(1) { 9785el = el.previousSibling; 9786if(!el) { 9787break; 9788} 9789var re_pre_el = new RegExp(el.outerHTML.replace(/[\n\r]/g,""), "i"); 9790if(this.isBlockElement(el) && bufText.match(re_pre_el)) { 9791bufText = bufText.replace(re_pre_el, ""); 9792ret_el[j] = el; 9793j++; 9794} 9795} 9796} 9797} 9798break; 9799case "Control": 9800for (var i = 0; i < range.length; i++) { 9801ret_el[i] = range.item(i); 9802} 9803break; 9804default: 9805ret_el[0] = this.text_content.body 9806} 9807return ret_el; 9808} else try { 9809var el = range.startContainer.parentNode; 9810var end_el = range.endContainer.parentNode; 9811if(el == end_el) { 9812ret_el[0] = el; 9813} else { 9814var i = 0; 9815while(el) { 9816if(this.isBlockElement(el)) {ret_el[i] = el;i++;} 9817if(el == end_el) { 9818break; 9819} 9820el = el.nextSibling; 9821} 9822} 9823return ret_el; 9824} catch (e) { 9825return null; 9826} 9827}, 9828comboSelected: function(el, txt) { 9829this.focusEditor(); 9830var value = el.options[el.selectedIndex].value; 9831switch (txt) { 9832case "fontsize": 9833if(!browser.isSafari) { 9834this.execCommand(txt, false, value); 9835} else { 9836var fontsize = ["8","10","12","14","18","24","36"]; 9837this.sizeElement.style.fontSize = fontsize[value]+"px"; 9838} 9839break; 9840case "fontname": 9841if(browser.isNS) { 9842this.execCommand("formatblock", false, "span"); 9843var el = this.getParentElement(); 9844Element.setStyle(el,{"font-family":value}); 9845} else { 9846this.execCommand(txt, false, value); 9847} 9848break; 9849case "formatblock": 9850((browser.isIE || browser.isOpera)) && (value = "<" + value + ">"); 9851if (browser.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) { 9852this.execCommand(txt, false, '<p>'); 9853var el = this.getParentElement(); 9854var new_el = this.text_content.createElement(value); 9855if(value == "blockquote") Element.addClassName(new_el, "quote"); 9856ar = el.attributes; 9857for (var i=ar.length-1; i>-1; i--) { 9858if (ar[i].specified && ar[i].nodeValue) 9859new_el.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); 9860} 9861ar = el.childNodes; 9862for (var i=0; i<ar.length; i++) 9863new_el.appendChild(ar[i].cloneNode(true)); 9864el.parentNode.replaceChild(new_el, el); 9865} else { 9866this.execCommand(txt, false, value); 9867} 9868break; 9869default: 9870var dropdown = this.config.customSelects[txt]; 9871if (typeof dropdown != "undefined") { 9872dropdown.action(this); 9873} else { 9874alert("FIXME: combo box " + txt + " not implemented"); 9875} 9876} 9877}, 9878execCommand: function(cmdID, UI, param) { 9879var el = Element.getChildElementByClassName(this.htmlarea, "comptextarea_"+cmdID); 9880if(cmdID != "addundolevel" && cmdID != "foce_addundolevel") { 9881this.focusEditor(); 9882} 9883var text_content = this.text_content; 9884cmdID = cmdID.toLowerCase(); 9885switch (cmdID) { 9886case "undo": 9887case "redo": 9888if (this.custom_undo_redo){ 9889this[cmdID].bind(this)(); 9890}else 9891this.text_content.execCommand(cmdID, UI, param); 9892if(browser.isIE || browser.isOpera){ 9893this.forceRedraw(); 9894this.toolbar.focus(); 9895} 9896break; 9897case "cut": 9898case "copy": 9899case "paste": 9900try { 9901this.text_content.execCommand(cmdID, UI, param); 9902} catch (e) { 9903if (browser.isGecko) { 9904if (typeof TextArea.LangSet.msg["Moz-Clipboard"] == "undefined") { 9905TextArea.LangSet.msg["Moz-Clipboard"] = 9906"Unprivileged scripts cannot access Cut/Copy/Paste programatically " + 9907"for security reasons. Click OK to see a technical note at mozilla.org " + 9908"which shows you how to allow a script to access the clipboard.\n\n" +
9909"[FIXME: please translate this message in your language definition file.]"; 9910} 9911if (confirm(TextArea.LangSet.msg["Moz-Clipboard"])) 9912window.open("http://mozilla.org/editor/midasdemo/securityprefs.html"); 9913} 9914} 9915break; 9916case "lefttoright": 9917case "righttoleft": 9918var dir = (cmdID == "righttoleft") ? "rtl" : "ltr"; 9919var el = this.getParentElement(); 9920while (el && !this.isBlockElement(el)){ 9921el = el.parentNode; 9922} 9923if (el) { 9924if (el.style.direction == dir) 9925el.style.direction = ""; 9926else 9927el.style.direction = dir; 9928} 9929break; 9930case "sethilitecolor": 9931cmdID = "hilitecolor"; 9932(browser.isIE || browser.isOpera || browser.isSafari) && (cmdID = "backcolor"); 9933text_content.execCommand(cmdID, false, this.getColorCode(el, "backgroundColor")); 9934break; 9935case "setforecolor": 9936cmdID = "forecolor"; 9937text_content.execCommand("forecolor", false, this.getColorCode(el, "backgroundColor")); 9938break; 9939case "hilitecolor": 9940case "forecolor": 9941this.showColorDialog(cmdID, el); 9942break; 9943case "inserttable": this.showTableDialog(el); break; 9944case "tablemenu": this.showTableMenuDialog(el); break; 9945case "createlink": this.createLinkDialog(); break; 9946case "insertimage": this.insertImageDialog(); break; 9947case "inserttex": this.insertTexDialog(); break; 9948case "insertupload": this.insertUploadDialog(); break; 9949case "insertsmiley":this.insertSmileyDialog(el); break; 9950case "savezip":this.saveZip(); break; 9951case "insertvideo":this.insertVideoDialog(el); break; 9952case "foce_addundolevel": 9953case "addundolevel": 9954++this.custom_undo_redo_levels; 9955if (this.custom_undo_redo_levels >= this.custom_undo_redo_maxlevels) { 9956this.undoLevels.shift(); 9957--this.custom_undo_redo_levels; 9958} 9959var take = true; 9960var text = this.text_content.body.innerHTML; 9961if (this.custom_undo_redo_levels > 0) 9962take = (this.undoLevels[this.custom_undo_redo_levels - 1] != text); 9963if (cmdID == "foce_addundolevel" || take) { 9964this.undoLevels[this.custom_undo_redo_levels] = text; 9965} else { 9966this.custom_undo_redo_levels--; 9967} 9968break; 9969case "indent": 9970case "outdent": 9971if ((browser.isIE )) { 9972var margin_px = (cmdID == "indent") ? 20 : -20; 9973var value = (browser.isIE || browser.isOpera) ? "<div>" : "div"; 9974this.text_content.execCommand("formatblock", false, value); 9975var el_arr = this.getSelectElements(); 9976for (var i = 0; i < el_arr.length; i++) { 9977this.indentDiv(el_arr[i], margin_px); 9978} 9979} else { 9980this.text_content.execCommand(cmdID, UI, param); 9981} 9982break; 9983case "unlink": 9984if (!browser.isOpera) { 9985var el = this.getParentElement(); 9986if(el) { 9987var anchorLink = this.getParentElementByTagName(el, "a", "href"); 9988if(anchorLink) { 9989if (browser.isSafari) { 9990var sel = this.getSelection(); 9991var range = this.createRange(sel); 9992range.setStart(this.text_content.body, 0); 9993range.setEnd(this.text_content.body, 0); 9994var value = range.createContextualFragment(anchorLink.innerHTML); 9995range.selectNode(anchorLink); 9996range.deleteContents(); 9997range.insertNode(value); 9998return; 9999} 10000this.selectNodeContents(anchorLink); 10001} 10002} 10003} 10004this.text_content.execCommand(cmdID, UI, param); 10005break; 10006case "strikethrough": 10007if(browser.isSafari) { 10008this.text_content.execCommand("bold", UI, param); 10009var sel = this.getSelection(); 10010var range = this.createRange(sel); 10011var el_ac = sel.anchorNode; 10012var el_fc =sel.focusNode; 10013if(el_ac || el_fc) { 10014if(el_fc) var el = this.getParentElementByTagName(el_fc, "span"); 10015if(el.style.fontWeight != "bold" && el_ac) { 10016if(el_ac) el = this.getParentElementByTagName(el_ac, "span"); 10017} 10018if(el) { 10019el.style.fontWeight = ""; 10020el.style.textDecoration = "line-through"; 10021} 10022} 10023} else { 10024this.text_content.execCommand(cmdID, UI, param); 10025} 10026break; 10027default: 10028this.text_content.execCommand(cmdID, UI, param); 10029} 10030if(cmdID != "foce_addundolevel" && cmdID != "addundolevel") 10031this.updateToolbar(); 10032}, 10033indentDiv: function(el, margin_px) { 10034var style_value = Element.getStyle(el, "margin-left"); 10035var current_el = el; 10036var current_style_value = style_value; 10037while (current_style_value == null || current_style_value == "0px"){ 10038if(current_el.tagName == "BODY") break; 10039current_el = current_el.parentNode; 10040current_style_value = Element.getStyle(current_el, "margin-left"); 10041} 10042if(current_el.tagName != "BODY") el = current_el,style_value = current_style_value; 10043if(el.tagName == "BODY" || !this.isBlockElement(el)) return; 10044if(style_value == null) { 10045style_value = 0; 10046} 10047style_value = valueParseInt(style_value); 10048var style_value = (style_value+margin_px < 0) ? 0 : style_value+margin_px; 10049if(style_value == 0) { 10050Element.setStyle(el,{"margin-left":''}); 10051} else { 10052Element.setStyle(el,{"margin-left":style_value + 'px'}); 10053} 10054}, 10055popupURL: function(file) { 10056var url = ""; 10057if (file.match(/^plugin:\/\/(.*?)\/(.*)/)) { 10058var plugin = RegExp.$1; 10059var popup = RegExp.$2; 10060if (!/\.html$/.test(popup)) 10061popup += ".html"; 10062url = "http://www.yamatogokin.co.jp/images/comp/textarea/" + plugin + "popups/" + popup; 10063} else { 10064url = "http://www.yamatogokin.co.jp/images/comp/textarea/" + "popups/" + file; 10065} 10066return url; 10067}, 10068setStartsBarResizing: function(event) { 10069this.setWidthAndHeight(true); 10070if(this.editMode != "html") { 10071if(!browser.isIE) this.text_style.visibility='hidden'; 10072else commonCls.displayNone(this.text_content.body);
10073this.text_style.width= '0px'; 10074this.text_style.height= '0px'; 10075} else { 10076commonCls.displayNone(this.textarea); 10077} 10078this.setStartsBarDragGoEvent = this.setStartsBarDragGo.bindAsEventListener(this); 10079this.setStartsBarDragStopEvent = this.setStartsBarDragStop.bindAsEventListener(this); 10080Event.observe(document,"mousemove",this.setStartsBarDragGoEvent,false, this.id); 10081Event.observe(document,"mouseup",this.setStartsBarDragStopEvent,false, this.id); 10082Event.stop(event); 10083}, 10084setStartsBarDragGo: function(event) { 10085Event.stop(event); 10086var offset = Position.cumulativeOffset(this.resizeBox); 10087var EX1 = offset[0]; 10088var EY1 = offset[1]; 10089if((Event.pointerY(event) - EY1) > this.htmlareaMinHeight){ 10090this.resizeBox.style.height = Math.abs((Event.pointerY(event) - EY1)) + "px"; 10091} 10092if((Event.pointerX(event) - EX1) > this.htmlareaMinWidth){ 10093this.resizeBox.style.width = Math.abs((Event.pointerX(event) - EX1)) + "px"; 10094} 10095this.htmlarea.style.width = this.resizeBox.offsetWidth + valueParseInt(Element.getStyle(this.resizeBox,"borderRightWidth")) + valueParseInt(Element.getStyle(this.resizeBox,"borderLeftWidth")) + valueParseInt(Element.getStyle(this.resizeBox,"marginRight")) + valueParseInt(Element.getStyle(this.resizeBox,"marginLeft")) + 'px'; 10096commonCls.scrollMoveDrag(event, 15); 10097}, 10098setStartsBarDragStop: function(event) { 10099Event.stopObserving(document,"mousemove",this.setStartsBarDragGoEvent,false); 10100Event.stopObserving(document,"mouseup",this.setStartsBarDragStopEvent,false); 10101Event.stop(event); 10102if(this.editMode != "html") { 10103this.text_style.width= this.htmlareaOldWidth + 'px'; 10104this.text_style.height= this.htmlareaOldHeight + 'px'; 10105this.text_style.width = (valueParseInt(this.text_style.width) + (this.resizeBox.offsetWidth - this.htmlareaOldWidth)) + "px"; 10106this.text_style.height = (valueParseInt(this.text_style.height) + (this.resizeBox.offsetHeight - this.htmlareaOldHeight)) + "px"; 10107} 10108if(!browser.isSafari) { 10109this.textarea.style.width = (valueParseInt(Element.getStyle(this.textarea, "width")) + (this.resizeBox.offsetWidth - this.htmlareaOldWidth)) + "px"; 10110this.textarea.style.height = (valueParseInt(Element.getStyle(this.textarea, "height")) + (this.resizeBox.offsetHeight - this.htmlareaOldHeight)) + "px"; 10111} else { 10112this.textarea.style.width = (this.resizeBox.offsetWidth) + "px"; 10113this.textarea.style.height = (this.resizeBox.offsetHeight) + "px"; 10114} 10115if(this.editMode == "html") { 10116commonCls.displayVisible(this.textarea); 10117} else { 10118if(!browser.isIE) this.text_style.visibility='visible'; 10119else commonCls.displayVisible(this.text_content.body); 10120} 10121this.setWidthAndHeight(); 10122Element.remove(this.resizeBox); 10123if(!(browser.isIE)) { 10124try { 10125this.text_content.designMode = "off"; 10126this.text_content.designMode = "on"; 10127} catch(e) {}; 10128} 10129}, 10130setWidthAndHeight: function(resize_flag) { 10131if(this.editMode == "html") { 10132var width = this.textarea.offsetWidth; 10133var height = this.textarea.offsetHeight; 10134} else { 10135var width = this.text.clientWidth; 10136var height = this.text.clientHeight; 10137} 10138this.htmlareaOldWidth = width; 10139this.htmlareaOldHeight = height; 10140if(resize_flag) { 10141this.resizeBox = document.createElement("DIV"); 10142this.setTextAreaStyle(this.resizeBox); 10143this.resizeBox.style.border= "1px dotted #666665"; 10144this.resizeBox.style.width = width + "px"; 10145this.resizeBox.style.height = height + "px"; 10146this.text.parentNode.insertBefore(this.resizeBox, this.text); 10147} 10148}, 10149changeEditMode: function() { 10150if(this.oldeditMode == this.editMode) 10151return; 10152var mode = this.editMode; 10153if(this.oldeditMode == "edit") 10154Element.removeClassName(this.editModeBtn, "comptextarea_activeMode"); 10155else if(this.oldeditMode == "html") 10156Element.removeClassName(this.htmlModeBtn, "comptextarea_activeMode"); 10157else 10158Element.removeClassName(this.previewModeBtn, "comptextarea_activeMode"); 10159switch (mode) { 10160case "html": 10161this.borderChange(); 10162this.textarea.value = this.getHTML(); 10163this.text_style.visibility='hidden'; 10164this.text_style.width='0px'; 10165this.text_style.height='0px'; 10166this.textarea.style.display = "block"; 10167this.textarea.style.visibility = "visible"; 10168Element.addClassName(this.htmlModeBtn, "comptextarea_activeMode"); 10169this.toolbarVisble("none"); 10170break; 10171case "edit": 10172if(!(browser.isIE)) { 10173try { 10174this.text_content.designMode = "off"; 10175} catch(e) {}; 10176} 10177Element.addClassName(this.text_content.body, "comptextareat_content"); 10178var html = this.getHTML(); 10179if(browser.isIE || browser.isSafari) { 10180this.text_content.body.innerHTML = "<br />" + html; 10181this.text_content.body.removeChild(this.text_content.body.firstChild); 10182} else { 10183this.text_content.body.innerHTML =html; 10184} 10185this.text_style.visibility='visible'; 10186this.text_style.width= this.htmlareaOldWidth + 'px'; 10187this.text_style.height= this.htmlareaOldHeight + 'px'; 10188this.textarea.style.display = "none"; 10189if(!(browser.isIE)) { 10190try { 10191this.text_content.designMode = "on"; 10192} catch(e) {}; 10193}else{ 10194this.text_content.body.contentEditable = true; 10195} 10196Element.addClassName(this.editModeBtn, "comptextarea_activeMode"); 10197this.toolbarVisble(); 10198this.borderChange(); 10199break; 10200case "preview": 10201if(!(browser.isIE)) { 10202try { 10203this.text_content.designMode = "off"; 10204} catch(e) {}; 10205}else { 10206this.text_content.body.contentEditable = false;
10207} 10208Element.removeClassName(this.text_content.body, "comptextareat_content"); 10209var html = this.getHTML(); 10210if(browser.isIE || browser.isSafari) { 10211this.text_content.body.innerHTML = "<br />" + html; 10212this.text_content.body.removeChild(this.text_content.body.firstChild); 10213} else { 10214this.text_content.body.innerHTML =html; 10215} 10216this.text_style.visibility='visible'; 10217this.text_style.width= this.htmlareaOldWidth + 'px' 10218this.text_style.height= this.htmlareaOldHeight + 'px' 10219this.textarea.style.display = "none"; 10220Element.addClassName(this.previewModeBtn, "comptextarea_activeMode"); 10221this.toolbarVisble("none"); 10222this.borderChange(); 10223break; 10224default: 10225alert("Mode <" + mode + "> not defined!"); 10226return false; 10227} 10228this.editMode = mode; 10229this.forceRedraw(); 10230this.focusEditor(true); 10231}, 10232borderChange: function(set_mode) { 10233if(set_mode != undefined) { 10234var mode = set_mode; 10235} else { 10236var mode = this.editMode; 10237} 10238var tableList = this.text_content.getElementsByTagName("TABLE"); 10239for (var i = 0,tableLen = tableList.length; i < tableLen; i++) { 10240if ((tableList[i].border == 0 && 10241(Element.getStyle(tableList[i], "borderWidth") == "0px 0px 0px 0px" || 10242Element.getStyle(tableList[i], "borderWidth") == "0px")) || 10243((mode == "preview" || mode == "html") && Element.getStyle(tableList[i], "borderTopStyle") == "dotted" && 10244commonCls.getColorCode(tableList[i], "borderColor") == "#666665") && 10245(Element.getStyle(tableList[i], "borderWidth") == "1px 1px 1px 1px" || 10246Element.getStyle(tableList[i], "borderWidth") == "1px")) { 10247if (mode == "edit") { 10248tableList[i].style.border = "1px dotted #666665"; 10249} else { 10250tableList[i].style.border = "0px"; 10251} 10252for( var k = 0; k < tableList[i].rows.length; k++ ) { 10253for( var j = 0; j < tableList[i].rows[k].cells.length; j++ ) { 10254if ((tableList[i].rows[k].cells[j].border == 0 && (Element.getStyle(tableList[i].rows[k].cells[j], "borderWidth") == "0px 0px 0px 0px" || Element.getStyle(tableList[i].rows[k].cells[j], "borderWidth") == "0px")) || 10255((mode == "preview" || mode == "html") && Element.getStyle(tableList[i].rows[k].cells[j], "borderTopStyle") == "dotted" && 10256commonCls.getColorCode(tableList[i].rows[k].cells[j], "borderColor") == "#666665") && 10257(Element.getStyle(tableList[i].rows[k].cells[j], "borderWidth") == "1px 1px 1px 1px" || 10258Element.getStyle(tableList[i].rows[k].cells[j], "borderWidth") == "1px")) { 10259if (mode == "edit") { 10260tableList[i].rows[k].cells[j].style.border = "1px dotted #666665"; 10261}else { 10262tableList[i].rows[k].cells[j].style.border = "0px"; 10263} 10264} 10265} 10266} 10267if (mode == "edit" && set_mode == undefined) { 10268this.tableRedraw(tableList[i]); 10269} 10270} 10271} 10272if (mode == "preview") { 10273var aList = this.text_content.getElementsByTagName("A"); 10274for (var i = 0,aLen = aList.length; i < aLen; i++) { 10275if(aList[i].target != "_blank" && aList[i].onclick == undefined) { 10276aList[i].onclick = function(){return false;}; 10277} 10278} 10279} 10280}, 10281tableRedraw: function(table) { 10282if(!(browser.isIE || browser.isOpera)) { 10283commonCls.displayNone(table); 10284setTimeout(function() { 10285commonCls.displayVisible(table); 10286}.bind(this), 0); 10287} 10288}, 10289getHTML: function(set_mode) { 10290if(set_mode != undefined) { 10291var mode = set_mode; 10292if(mode == "preview") mode = ((this.editMode == "edit" || this.editMode == "preview") ? "edit" : "html"); 10293if(set_mode == "preview") this.borderChange("preview"); 10294} else if(this.editMode == "preview") 10295var mode = ((this.oldeditMode == "edit" || this.oldeditMode == "preview") ? "edit" : "html"); 10296else if(this.oldeditMode == "preview") 10297var mode = "edit"; 10298else 10299var mode = ((this.editMode == "edit") ? "html" : "edit"); 10300switch (mode) { 10301case "edit" : 10302var html = this.getHTMLWrapper(this.text_content.body, false, this); 10303html = this.setFormatHtml(html); 10304return html; 10305case "html" : return this.textarea.value; 10306default : alert("Mode <" + mode + "> not defined!"); 10307} 10308return false; 10309}, 10310getTextArea: function() { 10311var html = this.getHTML("preview"); 10312if(this.editMode == "html") { 10313var html = this.getHTML("preview"); 10314if(browser.isIE || browser.isSafari) { 10315this.text_content.body.innerHTML = "<br />" + html; 10316this.text_content.body.removeChild(this.text_content.body.firstChild); 10317} else { 10318this.text_content.body.innerHTML =html; 10319} 10320html = this.getHTMLWrapper(this.text_content.body, false, this); 10321html = this.setFormatHtml(html); 10322} 10323return html; 10324}, 10325setTextArea: function(textarea_value) { 10326if(this.textarea && Element.hasClassName(this.textarea.parentNode,"comptextarea_textarea")) { 10327textarea_value = (textarea_value == undefined) ? "" : textarea_value; 10328this.textarea.value = textarea_value; 10329this.writeTextAreaContent(); 10330} 10331}, 10332getHTMLWrapper: function(root, outputRoot, editor) { 10333try{ 10334var html = ""; 10335switch (root.nodeType) { 10336case 1: 10337case 11: 10338var closed; 10339var i; 10340var root_tag = (root.nodeType == 1) ? root.tagName.toLowerCase() : ''; 10341if (root_tag == 'br' && !root.nextSibling && !root.attributes){ 10342if(root.parentNode.tagName != "TD") { 10343html += "<br />"; 10344} 10345break; 10346} 10347if (outputRoot) 10348outputRoot = !(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(root_tag)); 10349if ((browser.isIE || browser.isOpera) && root_tag == "head") { 10350if (outputRoot) 10351html += "<head>"; 10352var save_multiline = RegExp.multiline; 10353RegExp.multiline = true; 10354var txt = root.innerHTML.replace(this.RE_tagName, function(str, p1, p2) { 10355return p1 + p2.toLowerCase(); 10356}); 10357RegExp.multiline = save_multiline;
10358html += txt; 10359if (outputRoot) 10360html += "</head>"; 10361break; 10362} else if (outputRoot) { 10363if(root.tagName.toLowerCase() == "iframe") { 10364closed = false; 10365} else { 10366closed = (!(root.hasChildNodes() || this.needsClosingTag(root))); 10367} 10368html = "<" + root.tagName.toLowerCase(); 10369var attrs = root.attributes; 10370var alt_flag = false; 10371for (var i = 0; i < attrs.length; ++i) { 10372var a = attrs.item(i); 10373if (!a.specified) { 10374continue; 10375} 10376var name = a.nodeName.toLowerCase(); 10377if (/_moz_editor_bogus_node/.test(name)) { 10378html = ""; 10379break; 10380} 10381if (/_moz|contenteditable|_msh/.test(name)) { 10382continue; 10383} 10384var value; 10385if (name != "style") { 10386if (typeof root[a.nodeName] != "undefined" && name != "height" && name != "width" && name != "href" && name != "src" && !/^on/.test(name)) { 10387value = root[a.nodeName]; 10388} else { 10389value = a.nodeValue; 10390} 10391} else { 10392value = root.style.cssText; 10393} 10394if (/(_moz|^$)/.test(value)) { 10395continue; 10396} 10397if(browser.isIE) { 10398if(a.nodeName == "_extended" || value != null && value != "" && typeof value=="function") { 10399continue; 10400} 10401} else if(browser.isFirefox){ 10402if(a.nodeName == "style" && (value != null && value != "")) { 10403value = value.replace(/\s*-moz-.*?;/g, ""); 10404if(value == "") continue; 10405} 10406} else if(browser.isSafari){ 10407if(a.nodeName == "class" && (value != null && value != "")) { 10408value = value.replace(/ *Apple-style-span *?/, ""); 10409if(value == "") continue; 10410} 10411} 10412if(name == "alt") { 10413alt_flag = true; 10414} 10415html += " " + name + '="' + value + '"'; 10416} 10417if(root.tagName.toLowerCase() == "img" && alt_flag == false) { 10418html += ' alt=""'; 10419} 10420if(browser.isIE && root.tagName == "INPUT" && root.value != undefined) { 10421html += " " + 'value="' + root.value + '"'; 10422} 10423if (html != "") { 10424html += closed ? " />" : ">"; 10425} 10426} 10427if(browser.isIE && root.tagName == "SCRIPT") { 10428html += root.innerHTML.trim(); 10429} else { 10430for (var i = root.firstChild; i; i = i.nextSibling) { 10431html += this.getHTMLWrapper(i, true, editor); 10432} 10433} 10434if (outputRoot && !closed) { 10435html += "</" + root.tagName.toLowerCase() + ">"; 10436} 10437break; 10438case 3: 10439if (!root.data.match(/^<!--/)) { 10440root.data = root.data.replace('\n',''); 10441} 10442html = /^noscript|script|style|table|tbody|tr$/i.test(root.parentNode.tagName) ? root.data : this.htmlEncode(root.data); 10443break; 10444case 4: 10445html = "<![CDATA[" + root.data + "]]>"; 10446break; 10447case 8: 10448root.data = root.data.replace('\n',''); 10449html = "<!--" + root.data + "-->"; 10450break; 10451} 10452return html; 10453} 10454catch(e){ 10455alert('Your Document is not well formed. Check JavaScript console for details.'); 10456return this.text.contentWindow.document.body.innerHTML; 10457} 10458}, 10459needsClosingTag: function(el) { 10460this.closingTags = " head noscript script style div span tr td tbody table em strong b i code cite dfn abbr acronym font a title "; 10461return el && el.nodeType == 1 && (this.closingTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); 10462}, 10463htmlEncode: function(str) { 10464str = str.replace(/&/ig, "&"); 10465str = str.replace(/</ig, "<"); 10466str = str.replace(/>/ig, ">"); 10467str = str.replace(/\x22/ig, """); 10468str = str.replace(/\xA0/ig, " "); 10469return str; 10470}, 10471focusEditor: function(first_flag) { 10472switch (this.editMode) { 10473case "edit" : 10474case "preview" : 10475try { 10476if(!browser.isOpera) { 10477this.text.contentWindow.focus(); 10478if(first_flag) { 10479if (browser.isIE) { 10480var range = this.text_content.body.createTextRange(); 10481range.collapse(); 10482range.move('character', 0); 10483range.select(); 10484} else { 10485var sel = this.getSelection(); 10486range = this.text_content.createRange(); 10487range.setEnd(this.text_content.body, 0); 10488range.setStart(this.text_content.body, 0); 10489sel.addRange(range); 10490} 10491} 10492} else { 10493this.text.contentWindow.document.body.blur(); 10494this.text.contentWindow.document.body.focus(); 10495} 10496} catch (e) {} 10497break; 10498case "html": try { this.textarea.focus(); } catch (e) {} break; 10499default : alert("ERROR: mode " + this.editMode + " is not defined"); 10500} 10501return this.text_content; 10502}, 10503setFormatHtml: function(html) { 10504html = html.replace(new RegExp('<br />', 'g'), "<br />\n"); 10505html = html.replace(new RegExp('</(ol|ul|li|div|table|pre|td)>', 'g'), "</$1>\n"); 10506html = html.replace(new RegExp('<(ol|table[^>]*|tbody|tr[^>]*)>', 'g'), "<$1>\n"); 10507html = html.replace(new RegExp('( *)</(tr[^>]*)>', 'g'), " </$2>\n"); 10508html = html.replace(new RegExp('( *)</(tbody[^>]*)>', 'g'), " </$2>\n"); 10509html = html.replace(new RegExp('\n<(li|tbody|tr[^>]*)>', 'g'), "\n <$1>"); 10510html = html.replace(new RegExp('\n<(td[^>]*)>', 'g'), "\n <$1>"); 10511html = html.replace(new RegExp('<div([^>]*)></div>\n(.)', 'g'), "<div$1> </div>\n$2"); 10512return html; 10513}, 10514insertNodeAtSelection: function(toBeInserted) { 10515if (!browser.isIE) {
10516var sel = this.getSelection(); 10517var range = this.createRange(sel); 10518sel.removeAllRanges(); 10519range.deleteContents(); 10520var node = range.startContainer; 10521var pos = range.startOffset; 10522switch (node.nodeType) { 10523case 3: 10524if (toBeInserted.nodeType == 3) { 10525node.insertData(pos, toBeInserted.data); 10526range = this.createRange(); 10527range.setEnd(node, pos + toBeInserted.length); 10528range.setStart(node, pos + toBeInserted.length); 10529sel.addRange(range); 10530} else { 10531node = node.splitText(pos); 10532var selnode = toBeInserted; 10533if (toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */) { 10534selnode = selnode.firstChild; 10535} 10536node.parentNode.insertBefore(toBeInserted, node); 10537this.selectNodeContents(selnode); 10538this.updateToolbar(); 10539} 10540break; 10541case 1: 10542var selnode = toBeInserted; 10543if (toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */) { 10544selnode = selnode.firstChild; 10545} 10546node.insertBefore(toBeInserted, node.childNodes[pos]); 10547this.selectNodeContents(selnode); 10548this.updateToolbar(); 10549break; 10550} 10551} else { 10552return null; 10553} 10554}, 10555selectNodeContents: function(node, pos) { 10556this.focusEditor(); 10557this.forceRedraw(); 10558var range; 10559var collapsed = (typeof pos != "undefined"); 10560if (browser.isIE || browser.isOpera) { 10561range = this.text_content.body.createTextRange(); 10562range.moveToElementText(node); 10563(collapsed) && range.collapse(pos); 10564range.select(); 10565} else { 10566var sel = this.getSelection(); 10567range = this.text_content.createRange(); 10568range.selectNodeContents(node); 10569(collapsed) && range.collapse(pos); 10570if (!browser.isSafari) { 10571sel.removeAllRanges(); 10572sel.addRange(range); 10573} 10574} 10575}, 10576tableButtonPress: function(button_id) { 10577var editor = this.text_content; 10578var thisobj = this; 10579var mozbr = (browser.isGecko) ? " " : ""; 10580this.closePopup("tableinsertmenu"); 10581this.closePopup("tablemenu"); 10582function clearRow(tr) { 10583var tds = tr.getElementsByTagName("td"); 10584for (var i = tds.length; --i >= 0;) { 10585var td = tds[i]; 10586td.rowSpan = 1; 10587td.innerHTML = mozbr; 10588} 10589}; 10590function splitRow(td) { 10591var n = parseInt("" + td.rowSpan); 10592var nc = parseInt("" + td.colSpan); 10593td.rowSpan = 1; 10594tr = td.parentNode; 10595var itr = tr.rowIndex; 10596var trs = tr.parentNode.rows; 10597var index = td.cellIndex; 10598while (--n > 0) { 10599tr = trs[++itr]; 10600var otd = thisobj.text_content.createElement("td"); 10601copytdStyle(otd,td); 10602otd.colSpan = td.colSpan; 10603otd.innerHTML = mozbr; 10604tr.insertBefore(otd, tr.cells[index]); 10605} 10606thisobj.forceRedraw(); 10607thisobj.updateToolbar(); 10608}; 10609function splitCol(td) { 10610var nc = parseInt("" + td.colSpan); 10611td.colSpan = 1; 10612tr = td.parentNode; 10613var ref = td.nextSibling; 10614while (--nc > 0) { 10615var otd = thisobj.text_content.createElement("td"); 10616copytdStyle(otd,td); 10617otd.rowSpan = td.rowSpan; 10618otd.innerHTML = mozbr; 10619tr.insertBefore(otd, ref); 10620} 10621thisobj.forceRedraw(); 10622thisobj.updateToolbar(); 10623}; 10624function splitCell(td) { 10625var nc = parseInt("" + td.colSpan); 10626splitCol(td); 10627var items = td.parentNode.cells; 10628var index = td.cellIndex; 10629while (nc-- > 0) { 10630splitRow(items[index++]); 10631} 10632}; 10633function copytdStyle(td,copytd) { 10634td.style.border = copytd.style.border; 10635td.style.backgroundColor = copytd.style.backgroundColor; 10636} 10637function selectNextNode(el) { 10638var node = el.nextSibling; 10639while (node && node.nodeType != 1) { 10640node = node.nextSibling; 10641} 10642if (!node) { 10643node = el.previousSibling; 10644while (node && node.nodeType != 1) { 10645node = node.previousSibling; 10646} 10647} 10648if (!node) { 10649node = el.parentNode; 10650} 10651thisobj.selectNodeContents(node); 10652}; 10653switch (button_id) { 10654case "insert_row_before": 10655case "insert_row_after": 10656var tr = this.getClosest("tr"); 10657if (!tr) { 10658break; 10659} 10660var otr = tr.cloneNode(true); 10661clearRow(otr); 10662tr.parentNode.insertBefore(otr, /after/.test(button_id) ? tr.nextSibling : tr); 10663this.forceRedraw(); 10664this.focusEditor(); 10665break; 10666case "row_delete": 10667var tr = this.getClosest("tr"); 10668if (!tr) { 10669break; 10670} 10671var par = tr.parentNode; 10672if (par.rows.length == 1) { 10673var el_table = this.getClosest("table"); 10674Element.remove(el_table); 10675this.forceRedraw(); 10676this.focusEditor(); 10677break; 10678} 10679selectNextNode(tr); 10680par.removeChild(tr); 10681this.forceRedraw(); 10682this.focusEditor(); 10683this.updateToolbar(); 10684break; 10685case "spilit_row": 10686var td = this.getClosest("td"); 10687if (!td) { 10688break; 10689} 10690splitRow(td); 10691break; 10692case "insert_col_before": 10693case "insert_col_after": 10694var td = this.getClosest("td"); 10695if (!td) { 10696break; 10697} 10698var rows = td.parentNode.parentNode.rows; 10699var index = commonCls.cellIndex(td); 10700for (var i = rows.length; --i >= 0;) { 10701var tr = rows[i]; 10702var ref = tr.cells[index]; 10703if(ref) { 10704var index_ref = commonCls.cellIndex(ref); 10705if(button_id == "insert_col_before") { 10706var insert_index = index_ref; 10707} else { 10708var insert_index = index_ref + 1; 10709} 10710var otd = tr.insertCell(insert_index); 10711otd.innerHTML = mozbr; 10712otd.style.border = td.style.border; 10713otd.style.backgroundColor = td.style.backgroundColor; 10714} 10715} 10716this.focusEditor(); 10717break; 10718case "spilit_col": 10719var td = this.getClosest("td"); 10720if (!td) { 10721break; 10722} 10723splitCol(td); 10724break; 10725case "col_delete": 10726var td = this.getClosest("td"); 10727if (!td) { 10728break; 10729} 10730var index = td.cellIndex; 10731if (td.parentNode.cells.length == 1) { 10732var el_table = this.getClosest("table"); 10733Element.remove(el_table); 10734this.forceRedraw(); 10735this.focusEditor(); 10736break; 10737} 10738selectNextNode(td); 10739var rows = td.parentNode.parentNode.rows; 10740for (var i = rows.length; --i >= 0;) { 10741var tr = rows[i]; 10742tr.removeChild(tr.cells[index]); 10743} 10744this.forceRedraw(); 10745this.focusEditor(); 10746this.updateToolbar(); 10747break; 10748case "spilit_cell": 10749var td = this.getClosest("td"); 10750if (!td) { 10751break; 10752} 10753splitCell(td); 10754break; 10755case "insert_cell_before": 10756case "insert_cell_before": 10757var td = this.getClosest("td"); 10758if (!td) { 10759break; 10760} 10761var tr = td.parentNode; 10762var otd = editor._doc.createElement("td"); 10763otd.innerHTML = mozbr; 10764tr.insertBefore(otd, /after/.test(button_id) ? td.nextSibling : td); 10765this.forceRedraw(); 10766this.focusEditor(); 10767break; 10768case "cell_delete": 10769var td = this.getClosest("td"); 10770if (!td) { 10771break; 10772} 10773if (td.parentNode.cells.length == 1) { 10774var el_table = this.getClosest("table"); 10775Element.remove(el_table); 10776this.forceRedraw(); 10777this.focusEditor(); 10778break; 10779} 10780selectNextNode(td); 10781td.parentNode.removeChild(td); 10782this.forceRedraw(); 10783this.updateToolbar(); 10784break; 10785case "marge_cell": 10786var td = this.getClosest("td");
10787var sel = this.getSelection(); 10788var range, i = 0; 10789var rows = []; 10790var row = null; 10791var cells = null; 10792if (sel.rangeCount == 1 || (browser.isIE || browser.isOpera)) { 10793this.showTableMergeDialog(td); break; 10794} else{ 10795try { 10796while (range = sel.getRangeAt(i++)) { 10797var td = range.startContainer.childNodes[range.startOffset]; 10798if (td.parentNode != row) { 10799row = td.parentNode; 10800(cells) && rows.push(cells); 10801cells = []; 10802} 10803cells.push(td); 10804} 10805} catch(e) {/* finished walking through selection */} 10806rows.push(cells); 10807var HTML = ""; 10808for (var i = 0; i < rows.length; ++i) { 10809var cells = rows[i]; 10810for (var j = 0; j < cells.length; ++j) { 10811var cell = cells[j]; 10812if(cell.innerHTML == "<br>" || cell.innerHTML == "<br />" || cell.innerHTML == " ") { 10813; 10814}else 10815HTML += cell.innerHTML; 10816(i || j) && (cell.parentNode.removeChild(cell)); 10817} 10818} 10819var td = rows[0][0]; 10820if(HTML == "") 10821HTML = "<br />"; 10822td.innerHTML = HTML; 10823td.rowSpan = rows.length; 10824td.colSpan = rows[0].length; 10825this.selectNodeContents(td); 10826this.forceRedraw(); 10827this.focusEditor(); 10828} 10829break; 10830default: 10831alert("Button [" + button_id + "] not yet implemented"); 10832} 10833}, 10834getClosest: function(tagName) { 10835var ancestors = this.el_array; 10836var ret = null; 10837tagName = ("" + tagName).toLowerCase(); 10838for (var i = 0; i < ancestors.length; ++i) { 10839var el = ancestors[i]; 10840if (el.tagName.toLowerCase() == tagName) { 10841ret = el; 10842break; 10843} 10844} 10845return ret; 10846}, 10847getColorCode: function(el , property_name) { 10848var ret = commonCls.getColorCode(el, property_name); 10849if(property_name == "color") { 10850var color = commonCls.getColorCode(document.body, property_name); 10851if(ret == color) ret = ""; 10852} 10853return (ret == "transparent") ? "" : ret; 10854}, 10855saveZip: function() { 10856var form_el = document.createElement('form'); 10857form_el.action = _nc_base_url + _nc_index_file_name; 10858form_el.method = 'POST'; 10859$(this.id).appendChild(form_el); 10860form_el.appendChild(this._createInputHidden('action', 'common_download_zip')); 10861form_el.appendChild(this._createInputHidden('content', this.getHTML("edit"))); 10862form_el.appendChild(this._createInputHidden('download_action', this.downloadAction)); 10863form_el.submit(); 10864Element.remove(form_el); 10865}, 10866_createInputHidden: function(name, value) { 10867var input_el = document.createElement('input'); 10868input_el.setAttribute('name', name); 10869input_el.setAttribute('type', 'hidden'); 10870input_el.setAttribute('value', value); 10871return input_el; 10872} 10873} 10874 10875var compCalendar = Class.create(); 10876var calendarComp = Array(); 10877compCalendar.prototype = { 10878initialize: function(id, text_el, options) { 10879this.id = id; 10880this.popup = null; 10881this.text_el = null; 10882this.calendarIcon_el = null; 10883this.options = { 10884onClickCallback: null, 10885parentFrame: "", 10886onClickCallback: null, 10887designatedDate: "", 10888pre_show_week: 0, 10889next_show_week: 1, 10890calendarImgPath: "http://www.yamatogokin.co.jp/themes/images/icons", 10891calendarColorDir: "default", 10892calendarImg: "calendar.gif", 10893calendarThemeDir: "default" 10894}; 10895Object.extend(this.options, options || {}); 10896this.date = null; 10897this.todayYear = null; 10898this.todayMonth = null; 10899this.todayDay = null; 10900this.selectedYear = null; 10901this.selectedMonth = null; 10902this.selectedDay = null; 10903this.currentYear = null; 10904this.currentMonth = null; 10905this.currentDay = null; 10906this.currentDate = null; 10907this.setDesignatedDateFlag = false; 10908this.Mdays = {"01":"31", "02":"28", "03":"31", "04":"30", "05":"31", "06":"30", "07":"31", "08":"31", "09":"30", "10":"31", "11":"30", "12":"31"}; 10909var key = id; 10910var count = 1; 10911while (calendarComp[key]) { 10912key = id + "_" + count; 10913count++; 10914} 10915calendarComp[key] = this; 10916this.key = key; 10917this._showCalendarImg(text_el); 10918}, 10919setDesignatedDate: function(yyyymmdd) { 10920this.options.designatedDate = yyyymmdd; 10921}, 10922onMoveClick: function(yyyymmdd) { 10923this.currentYear = yyyymmdd.substr(0, 4); 10924this.currentMonth = yyyymmdd.substr(4, 2); 10925this.currentDay = yyyymmdd.substr(6, 2); 10926this.currentDate = yyyymmdd; 10927var popup_el = this.popup.getPopupElement(); 10928popup_el.contentWindow.document.body.innerHTML = this._render(); 10929this.popup.resize(); 10930}, 10931onDayClick: function(yyyymmdd) { 10932var day_separator = (compCalendarLang.day_separator != undefined) ? compCalendarLang.day_separator : "/"; 10933if(this.options.onClickCallback != null) { 10934this.options.onClickCallback(yyyymmdd); 10935} else { 10936if(this.text_el.tagName.toLowerCase() == 'input' && this.text_el.type.toLowerCase() == 'text') { 10937this.text_el.value = yyyymmdd.substr(0, 4)+ day_separator + yyyymmdd.substr(4, 2) + day_separator + yyyymmdd.substr(6, 2); 10938commonCls.focus(this.text_el); 10939} 10940} 10941this._popupClose(); 10942}, 10943disabledCalendar: function(value) { 10944this.text_el.disabled = value; 10945if(value) { 10946this.text_el.blur(); 10947this.calendarIcon_el.blur();
10948Element.addClassName(this.calendarIcon_el, "display-none"); 10949if (this.popup != null) { 10950this.popup.closePopup(this.popup.getPopupElement()); 10951} 10952} else { 10953Element.removeClassName(this.calendarIcon_el, "display-none"); 10954commonCls.focus(this.text_el); 10955} 10956}, 10957_showCalendarImg: function(text_el) { 10958if(typeof text_el == 'string') { 10959if(this.options.parentFrame == "" || this.options.parentFrame == null) { 10960text_el = $(text_el); 10961} else { 10962text_el = this.options.parentFrame.contentWindow.document.getElementById(text_el); 10963} 10964} 10965if(typeof text_el != 'object') return; 10966if(this.options.parentFrame == "" || this.options.parentFrame == null) { 10967var calendarA_el = document.createElement("a"); 10968var calendarImg_el = document.createElement("img"); 10969} else { 10970var calendarA_el = this.options.parentFrame.contentWindow.document.createElement("a"); 10971var calendarImg_el = this.options.parentFrame.contentWindow.document.createElement("img"); 10972} 10973calendarA_el.href = "#"; 10974calendarImg_el.src = this.options.calendarImgPath + "/" + this.options.calendarColorDir + "/" + this.options.calendarImg; 10975Element.addClassName(calendarA_el, "comp_calendar_icon"); 10976if(text_el.tagName.toLowerCase() == 'input' && text_el.type.toLowerCase() == 'text') { 10977Element.addClassName(text_el, "comp_calendar_text"); 10978} 10979calendarImg_el.alt = (compCalendarLang.icon_alt != undefined) ? compCalendarLang.icon_alt : "Calendar"; 10980calendarImg_el.title = (compCalendarLang.icon_title != undefined) ? compCalendarLang.icon_title : "Show Calendar"; 10981text_el.parentNode.insertBefore(calendarA_el, text_el); 10982text_el.parentNode.insertBefore(text_el, calendarA_el); 10983calendarA_el.appendChild(calendarImg_el); 10984Event.observe(calendarA_el, "click", 10985function(event){ 10986this._showCalendar(); 10987Event.stop(event); 10988}.bindAsEventListener(this), false, this.id); 10989this.text_el = text_el; 10990this.calendarIcon_el = calendarA_el; 10991}, 10992_showCalendar: function() { 10993this.date = new Date(); 10994this.todayYear = this._getFormat(this.date.getFullYear()); 10995this.todayMonth = this._getFormat(this.date.getMonth() + 1); 10996this.todayDay = this._getFormat(this.date.getDate()); 10997if(this.setDesignatedDateFlag == true) { 10998this.options.designatedDate = null; 10999this.setDesignatedDateFlag = false; 11000} 11001if((this.options.designatedDate == null || this.options.designatedDate == "") && 11002this.text_el.tagName.toLowerCase() == 'input' && this.text_el.type.toLowerCase() == 'text') { 11003var sel_date = this.text_el.value; 11004if(sel_date.length == 10) { 11005var sel_year = sel_date.substr(0, 4); 11006var sel_month = sel_date.substr(5, 2); 11007var sel_day = sel_date.substr(8, 2); 11008if(valueParseInt(sel_month) > 0 && valueParseInt(sel_month) < 12 && 11009valueParseInt(sel_day) > 0 && valueParseInt(sel_day) < 32) { 11010this.setDesignatedDateFlag = true; 11011this.options.designatedDate = sel_year + sel_month + sel_day; 11012} 11013} 11014} 11015if(this.options.designatedDate == null || this.options.designatedDate == "") { 11016this.selectedYear = null; 11017this.selectedMonth = null; 11018this.selectedDay = null; 11019this.currentYear = this.todayYear; 11020this.currentMonth = this.todayMonth; 11021this.currentDay = "01"; 11022} else { 11023this.selectedYear = this.options.designatedDate.substr(0, 4); 11024this.selectedMonth = this.options.designatedDate.substr(4, 2); 11025this.selectedDay = this.options.designatedDate.substr(6, 2); 11026this.currentYear = this.selectedYear; 11027this.currentMonth = this.selectedMonth; 11028this.currentDay = "01"; 11029} 11030this.currentDate = this.currentYear + this.currentMonth + this.currentDay; 11031var html = this._render(); 11032if(!this.popup) { 11033this.popup = new compPopup(this.id, "compCalendar"); 11034var new_dir_name ="/comp/"+this.options.calendarThemeDir+"/comp_calendar.css"; 11035var css_name = "http://www.yamatogokin.co.jp" + _nc_index_file_name + "?action=common_download_css&dir_name="+new_dir_name+"&header=0"; 11036this.popup.addCSSFiles(css_name); 11037this.popup.observer = function(event) {this._popupClose(); }.bind(this); 11038} 11039if(this.options.parentFrame) { 11040this.popup.setLapPosition(this.calendarIcon_el, this.options.parentFrame); 11041this.popup.showPopup(html); 11042} else { 11043this.popup.showPopup(html, this.calendarIcon_el); 11044} 11045}, 11046_getNextYear: function(yyyy, mm, dd) { 11047yyyy = valueParseInt(yyyy) + 1; 11048return this._getFormat(yyyy) + this._getFormat(mm) + this._getFormat(dd); 11049}, 11050_getPrevYear: function(yyyy, mm, dd) { 11051yyyy = valueParseInt(yyyy) - 1; 11052if(yyyy < 1900) { 11053yyyy = 1900; 11054} 11055return this._getFormat(yyyy) + this._getFormat(mm) + this._getFormat(dd); 11056}, 11057_getNextDate: function(yyyy, mm, dd) { 11058mm = valueParseInt(mm) + 1; 11059if(mm == 13) { 11060mm = 1; 11061yyyy = valueParseInt(yyyy) + 1; 11062} 11063return this._getFormat(yyyy) + this._getFormat(mm) + this._getFormat(dd); 11064}, 11065_getPrevDate: function(yyyy, mm, dd) { 11066mm = valueParseInt(mm) - 1; 11067if(mm <= 0) { 11068mm = 12; 11069yyyy = valueParseInt(yyyy) - 1; 11070} 11071return this._getFormat(yyyy) + this._getFormat(mm) + this._getFormat(dd); 11072}, 11073_getFormat: function(num) { 11074return (valueParseInt(num) < 10) ? ("0" + valueParseInt(num)) : "" + num; 11075}, 11076_getMonthDays: function(yy, mm) { 11077if(mm == "02") { 11078if ((yy % 4) == 0) { 11079return "29"; 11080} else if ((yy % 100) == 0) { 11081return "28"; 11082} else if ((yy % 400) == 0) { 11083return "29"; 11084} 11085} 11086return this.Mdays[mm]; 11087}, 11088_getWeekDays: function(yyyy,mm,dd) { 11089var now = new Date(valueParseInt(yyyy), valueParseInt(mm) - 1, valueParseInt(dd)); 11090var w = now.getDay(); 11091return w; 11092}, 11093_render: function() { 11094var next_year = this._getNextYear(this.currentYear, this.currentMonth, this.currentDay); 11095var prev_year = this._getPrevYear(this.currentYear, this.currentMonth, this.currentDay);
11096var next_month = this._getNextDate(this.currentYear, this.currentMonth, this.currentDay); 11097var prev_month = this._getPrevDate(this.currentYear, this.currentMonth, this.currentDay); 11098var pre_end_date = this._getMonthDays(prev_month.substr(2, 2), prev_month.substr(4, 2)); 11099var end_date = this._getMonthDays(this.currentYear.substr(2, 2), this.currentMonth); 11100var start_w = this._getWeekDays(this.currentYear, this.currentMonth, this.currentDay); 11101if(start_w == 0) { 11102if(this.options.pre_show_week != 0) { 11103var pre_start_date = pre_end_date - 7*this.options.pre_show_week + 1; 11104} else { 11105var pre_start_date = 0; 11106} 11107} else { 11108var pre_start_date = pre_end_date - 7*this.options.pre_show_week - (start_w - 1); 11109} 11110var loop_week = valueParseInt(Math.ceil((valueParseInt(end_date) + start_w + 7*this.options.pre_show_week + 7*this.options.next_show_week) / 7)); 11111var currentMonth = valueParseInt(this.currentMonth); 11112if(currentMonth < 10) currentMonth = " " + currentMonth; 11113var html = 11114"<table class=\"compcalendar_top\" summary=\"\"><tr><td class=\"compcalendar_top_td\">" + 11115"<table border=\"0\" class=\"compcalendar\" summary=\"" + compCalendarLang.summary + "\">" + 11116"<tr>" + 11117"<td class=\"compcalendar_title\" colspan=\"7\">" + 11118this.currentYear + 11119compCalendarLang.year + 11120" " + 11121currentMonth + 11122compCalendarLang.month + 11123"</td>" + 11124"</tr>" + 11125"<tr class=\"compcalendar_button\">" + 11126"<td>" + 11127"<a class=\"compcalendar_btnlink\" href=\"#\" onclick=\"parent.calendarComp['" + this.key + "'].onMoveClick('" + prev_year + "'); return false;\" title=\"" + compCalendarLang.title_prev_year + "\">" + 11128compCalendarLang.btn_prev_year + 11129"</a>" + 11130"</td>" + 11131"<td>" + 11132"<a class=\"compcalendar_btnlink\" href=\"#\" onclick=\"parent.calendarComp['" + this.key + "'].onMoveClick('" + prev_month + "'); return false;\" title=\"" + compCalendarLang.title_prev_month + "\">" + 11133compCalendarLang.btn_prev_month + 11134"</a>" + 11135"</td>" + 11136"<td colspan=\"3\">" + 11137"<a class=\"compcalendar_btnlink\" href=\"#\" onclick=\"parent.calendarComp['" + this.key + "'].onMoveClick('" + this.todayYear + this.todayMonth + "01" + "'); return false;\" title=\"" + compCalendarLang.title_today + "\">" + 11138compCalendarLang.move_today + 11139"</a>" + 11140"</td>" + 11141"<td>" + 11142"<a class=\"compcalendar_btnlink\" href=\"#\" onclick=\"parent.calendarComp['" + this.key + "'].onMoveClick('" + next_month + "'); return false;\" title=\"" + compCalendarLang.title_next_month + "\">" + 11143compCalendarLang.btn_next_month + 11144"</a>" + 11145"</td>" + 11146"<td>" + 11147"<a class=\"compcalendar_btnlink\" href=\"#\" onclick=\"parent.calendarComp['" + this.key + "'].onMoveClick('" + next_year + "'); return false;\" title=\"" + compCalendarLang.title_next_year + "\">" + 11148compCalendarLang.btn_next_year + 11149"</a>" + 11150"</td>" + 11151"</tr>" + 11152"<tr class=\"compcalendar_week\">" + 11153"<td class=\"compcalendar_sun\">" + 11154compCalendarLang.week_sun + 11155"</td>" + 11156"<td>" + 11157compCalendarLang.week_mon + 11158"</td>" + 11159"<td>" + 11160compCalendarLang.week_tue + 11161"</td>" + 11162"<td>" + 11163compCalendarLang.week_wed + 11164"</td>" + 11165"<td>" + 11166compCalendarLang.week_thu + 11167"</td>" + 11168"<td>" + 11169compCalendarLang.week_fri + 11170"</td>" + 11171"<td class=\"compcalendar_sat\">" + 11172compCalendarLang.week_sat + 11173"</td>" + 11174"</tr>"; 11175var pre_outside_day = pre_start_date; 11176var current_day = 1; 11177var post_end_date = 1; 11178for (var i = 0; i < loop_week; i++) { 11179html += "<tr class=\"compcalendar_day\">"; 11180for (var j = 0; j < 7; j++) { 11181if(pre_outside_day > 0) { 11182var day_class = "compcalendar_outside"; 11183var day = pre_outside_day; 11184if(pre_end_date < day+1) { 11185pre_outside_day = 0 11186} else { 11187pre_outside_day++; 11188} 11189var prefix_day_click = prev_month.substr(0, 6); 11190} else if(current_day > 0) { 11191var day = current_day; 11192if (end_date < day+1) { 11193current_day = 0; 11194} else { 11195current_day++; 11196} 11197if (j == 0) { 11198var day_class="compcalendar_sun"; 11199} else if(j == 6) { 11200var day_class="compcalendar_sat"; 11201} else { 11202var day_class="compcalendar_weekday"; 11203} 11204if (this.currentYear == this.selectedYear && this.currentMonth == this.selectedMonth && this.selectedDay == day) { 11205day_class += " compcalendar_highlight"; 11206} 11207if (this.currentYear == this.todayYear && this.currentMonth == this.todayMonth && this.todayDay == day) { 11208day_class += " compcalendar_today"; 11209} 11210var prefix_day_click = this.currentYear + this.currentMonth; 11211} else { 11212var day_class = "compcalendar_outside"; 11213var day = post_end_date; 11214post_end_date++ 11215var prefix_day_click = next_month.substr(0, 6); 11216} 11217html += "<td class=\"" + day_class + "\">" + 11218"<a href=\"#\" onclick=\"parent.calendarComp['" + this.key + "'].onDayCl
11218ick('" + prefix_day_click + this._getFormat(day) + "'); return false;\" class=\"compcalendar_link\">" + 11219day + 11220"</a>" + 11221"</td>"; 11222} 11223html += "</tr>"; 11224} 11225html += "</table>" + 11226"</td></tr></table>"; 11227return html; 11228}, 11229_popupClose: function() { 11230this.popup.closePopup(this.popup.getPopupElement()); 11231if(this.text_el.tagName.toLowerCase() == 'input' && this.text_el.type.toLowerCase() == 'text') { 11232commonCls.focus(this.text_el); 11233} 11234} 11235} 11236var compColor = Class.create(); 11237compColor.prototype = { 11238initialize: function(id) { 11239this.id = id; 11240this.el = null; 11241this.popup = null; 11242}, 11243showDialogBox: function(el, hidden) { 11244this.el = el; 11245this.hidden = hidden; 11246commonCls.referComp[this.id] = this; 11247commonCls.referComp["compIcon" + this.id] = this; 11248if(!this.popup) { 11249this.popup = new compPopup(this.id); 11250} 11251var params = new Object(); 11252params["param"] = { 11253"action":"comp_textarea_view_selectcolor", 11254"prefix_id_name":"dialog_selectcolor", 11255"parent_id_name":"compIcon" + this.id, 11256"_noscript":1}; 11257params["top_el"] = this.id; 11258params["callbackfunc"] = function(res) { 11259this.popup.showPopup(res, this.el); 11260}.bind(this); 11261commonCls.send(params); 11262}, 11263setColor: function($dummy, params) { 11264this.el.style.backgroundColor = params["color"]; 11265this.hidden.value = params["color"]; 11266this.closePopup(); 11267}, 11268closePopup: function() { 11269if(this.popup) { 11270this.popup.closePopup(); 11271} 11272} 11273} 11274var clsPages = Class.create(); 11275clsPages.prototype = { 11276initialize: function() { 11277this.center_page_id = null; 11278this.pages_token = new Object(); 11279this.move_el = null; 11280this.move_td = null; 11281this.xOffset = 0; 11282this.yOffset = 0; 11283this.start_x = 0; 11284this.start_y = 0; 11285this.move_column_el = null; 11286this.insert_tr = null; 11287this.insert_el = null; 11288this.insert_td = null; 11289this.active = null; 11290this.active_style = null; 11291this.insertAction = null; 11292this.insertMoveEndRowThreadNum = null; 11293this.insertMoveEndRowParentId = null; 11294this.inMoveDrag = false; 11295this.inChgBlockName = new Object(); 11296this.inMoveShowHeader = new Object(); 11297this.inCancelGroupingDrag = false; 11298this.insertMoveCellIndex = null; 11299this.insertMoveRowIndex = null; 11300this.insertMoveRowLength = null; 11301this.insertMoveCellLength = null; 11302this.insertMoveRowParentId = null; 11303this.insertMoveRowBlockId = null; 11304this.show_count = new Object(); 11305this.winMoveDragStartEvent = new Object(); 11306this.winMoveDragGoEvent = new Object(); 11307this.winMoveDragStopEvent = new Object(); 11308this.winGroupingEvent = new Object(); 11309this.parentThreadNum = 0; 11310this.parentParentid = 0; 11311this.cloneTopPos = new Object(); 11312this.cloneColumnPos = Array(); 11313this.clonePos = Array(); 11314this.groupingList = Array(); 11315this.block_left_padding = 8; 11316this.block_right_padding = 8; 11317this.block_top_padding = 8; 11318this.block_bottom_padding = 8; 11319}, 11320pageInit: function(active_center) { 11321Event.observe(document,"mousedown",this.winMouseDownEvent.bindAsEventListener(this),false); 11322if($("_settingmode")) { 11323var centercolumn_el = $("__centercolumn"); 11324if(active_center == 0 && _nc_layoutmode != "on" && centercolumn_el) { 11325var cell_el = Element.getChildElementByClassName(centercolumn_el,"cell"); 11326if(!cell_el) { 11327var centercolumn_inf_mes_el = $("centercolumn_inf_mes"); 11328if(centercolumn_inf_mes_el) { 11329var div = document.createElement("DIV"); 11330div.innerHTML = pagesLang.centercolumnNoexists; 11331centercolumn_inf_mes_el.appendChild(div); 11332} else { 11333centercolumn_el.innerHTML = "<div id='centercolumn_inf_mes'><div>"+pagesLang.centercolumnNoexists+"</div></div>"; 11334} 11335} 11336} 11337} 11338}, 11339winMouseDownEvent: function(event) { 11340var el = Event.element(event); 11341if (Element.hasClassName(el,"header_btn") || Element.hasClassName(el,"header_btn_left")){ 11342return false; 11343} 11344var divList = document.getElementsByTagName("div"); 11345var check_flag = true; 11346for (var i = 0; i < divList.length; i++){ 11347if (Element.hasClassName(divList[i],"cell")){ 11348var child_el = Element.getChildElement(divList[i]); 11349if(child_el && Position.within(child_el, Event.pointerX(event),Event.pointerY(event))) { 11350check_flag = false; 11351break; 11352} 11353} 11354} 11355if(check_flag) { 11356var divList = document.getElementsByTagName("div"); 11357for (var i = 0; i < divList.length; i++){ 11358if (Element.hasClassName(divList[i],"cell")){ 11359pagesCls.cancelSelectStyle(divList[i]); 11360} 11361} 11362} 11363}, 11364setToken: function(page_id,token_value,center_flag) { 11365if(center_flag) 11366this.center_page_id = page_id; 11367this.pages_token[page_id] = token_value; 11368}, 11369setShowCount: function(page_id,show_count) { 11370this.show_count[page_id] = show_count; 11371}, 11372blockChangeName: function(event) { 11373var block_el = Element.getParentElementByClassName(this,"module_box");
11374if(Element.hasClassName(this,"nc_block_title") || Element.hasClassName(this,"_block_title_abs")) { 11375var title_el = this; 11376if(Element.getChildElement(title_el) && Element.getChildElement(title_el).tagName == "INPUT") { 11377} else { 11378var text = title_el.innerHTML.trim(); 11379title_el.innerHTML = "<input style='width:90%;' name=\"title_el\" type=\"text\" maxlength=\"50\" title=\"" + text + "\" value=\"" + text + "\" onblur=\"pagesCls.blockChangeNameCommit(event,this);\" onkeypress=\"if (event.keyCode == 13) {if(browser.isNS && !browser.isSafari) {pagesCls.blockChangeNameCommit(event,this);}else{this.blur();}return false;}\" autocomplete=\"off\" />"; 11380} 11381commonCls.focus(title_el); 11382pagesCls.inChgBlockName[block_el.id] = true; 11383} 11384}, 11385blockChangeNameCommit: function(event,input_el) { 11386var event_el = Event.element(event); 11387var block_el = Element.getParentElementByClassName(event_el,"module_box"); 11388var title_el = new Array(); 11389title_el[0] = Element.getChildElementByClassName(block_el,"nc_block_title"); 11390title_el[2] = Element.getChildElementByClassName(block_el,"_block_title_event"); 11391if(!title_el[2]) {title_el[2] = title_el[0];} 11392if(block_el) { 11393title_el[1] = Element.getChildElementByClassName(block_el,"_block_title_abs"); 11394var text = input_el.value.escapeHTML(); 11395var parent_el = input_el.parentNode; 11396if(!parent_el) 11397return false; 11398var old_text = input_el.title.escapeHTML(); 11399parent_el.innerHTML = text; 11400var queryParams = commonCls.getParams(block_el); 11401var page_id = queryParams["page_id"]; 11402var params = new Object(); 11403params["method"] = "post"; 11404params["param"] = "pages_actionblock_chgblockname" + "&block_name=" + encodeURIComponent(input_el.value); 11405params["top_el"] = block_el; 11406params["loading_el"] = parent_el; 11407params["callbackfunc_error"] = function(old_text,res){commonCls.alert(res); this.innerHTML = old_text;}.bind(parent_el); 11408params["func_error_param"] = old_text; 11409params["callbackfunc"] = function(text){ 11410this[0].innerHTML = text; 11411if( this[1] ) this[1].innerHTML = text; 11412if(text == '' && !Element.hasClassName(this[0], "display-none")) { 11413if(_nc_layoutmode=="off") Element.addClassName(this[2],"display-none"); 11414} else { 11415Element.removeClassName(this[2],"display-none"); 11416} 11417pagesCls.inChgBlockName[block_el.id] = false; 11418}.bind(title_el); 11419params["func_param"] = text; 11420params["token"] = pagesCls.pages_token[page_id]; 11421commonCls.send(params); 11422} 11423return false; 11424}, 11425addBlock: function(event, page_id, module_id_arr) { 11426var module_id_arr_list = module_id_arr.split("_"); 11427var module_id = module_id_arr_list[0]; 11428var dir_name = module_id_arr_list[1]; 11429if(module_id == "0") return; 11430if(dir_name != "login") { 11431var scripts = document.getElementsByTagName("script"); 11432for (var i = 0,scripts_len = scripts.length; i < scripts_len; i++) { 11433var script_el = scripts[i]; 11434if(script_el.src.match("common_download_js")) { 11435var queryParams = script_el.src.parseQuery(); 11436var re_dir_name = new RegExp("(.*?)(common_download_js&dir_name=)(.*?)("+dir_name+")(.*)", "i"); 11437if( !script_el.src.match(re_dir_name)) { 11438commonCls.addScript("http://www.yamatogokin.co.jp/"+ _nc_index_file_name + "?action=common_download_js&dir_name=" + dir_name + "&add_block_flag=1"+"&vs=" + _nc_js_vs); 11439} 11440break; 11441} 11442} 11443} 11444var event_el = Event.element(event); 11445var addmobule_box_el = Element.getParentElementByClassName(event_el,"addmobule_box"); 11446var main_column_el = Element.getChildElementByClassName(addmobule_box_el.parentNode.nextSibling, "main_column"); 11447var addblock_params = new Object(); 11448var postBody = "pages_actionblock_addblock" + "&module_id=" + module_id + "&page_id=" + page_id + 11449"&topmargin=" + this.block_top_padding + "&rightmargin=" + this.block_right_padding + 11450"&bottommargin=" +this.block_bottom_padding + "&leftmargin=" + this.block_left_padding + 11451"&_show_count=" + pagesCls.show_count[page_id]; 11452addblock_params["method"] = "post"; 11453addblock_params["param"] = postBody; 11454addblock_params["loading_el"] = event_el; 11455addblock_params["callbackfunc"] = function(res){ 11456for (var key in pagesCls.inMoveShowHeader) { 11457if(pagesCls.inMoveShowHeader[key]) { 11458var header_el = $("_move_header" + key); 11459Element.addClassName(header_el, "display-none"); 11460pagesCls.inMoveShowHeader[key] = false;
11461} 11462} 11463var table_el = Element.getChildElement(main_column_el); 11464var tr = table_el.getElementsByTagName("tr")[0]; 11465var column_el = Element.getChildElement(tr); 11466if(!column_el) { 11467column_el = tr.insertCell(0); 11468column_el.className = "column valign-top"; 11469} 11470var div = document.createElement("DIV"); 11471div.className = "cell"; 11472div.style.padding = this.block_top_padding + "px" + " " + this.block_right_padding + "px" + " " + this.block_bottom_padding + "px" + " " + this.block_left_padding + "px"; 11473var child_el = Element.getChildElement(column_el); 11474if(child_el) { 11475column_el.insertBefore(div, child_el); 11476} else { 11477column_el.appendChild(div); 11478} 11479var queryParams = res.parseQuery(); 11480commonCls.addBlockTheme(queryParams['theme_name']); 11481queryParams['page_id'] = page_id; 11482queryParams['module_id'] = module_id; 11483queryParams['_layoutmode'] = _nc_layoutmode; 11484var add_params = new Object(); 11485var action_name_list = queryParams['action'].split("_"); 11486if(action_name_list[1] && action_name_list[1]=="action") { 11487add_params["method"] = "post"; 11488} 11489add_params["param"] = queryParams; 11490add_params["target_el"] = div; 11491add_params["callbackfunc"] = function(res){ 11492if(browser.isGecko) { 11493} 11494this.show_count[page_id]++; 11495}.bind(this); 11496add_params["callbackfunc_error"] = function(res){this.show_count[page_id]++; commonCls.alert(res); location.reload();}.bind(this); 11497commonCls.send(add_params); 11498}.bind(this); 11499addblock_params["callbackfunc_error"] = function(res){commonCls.alert(res); location.reload();}; 11500addblock_params["token"] = pagesCls.pages_token[page_id]; 11501commonCls.send(addblock_params); 11502event_el.selectedIndex = 0; 11503if(browser.isIE) { 11504document.body.focus(); 11505} else { 11506event_el.blur(); 11507} 11508}, 11509deleteBlock: function(event, id, confirm_mes, request_flag) { 11510var target_el; 11511if (id == undefined) { 11512target_el = Event.element(event); 11513} else { 11514target_el = $(id); 11515} 11516var cell_el = Element.getParentElementByClassName(target_el,"cell"); 11517if(cell_el) { 11518var td_el = Element.getParentElement(cell_el); 11519var tr_el = Element.getParentElement(td_el); 11520var top_el = Element.getChildElement(cell_el); 11521var title_el = Element.getChildElementByClassName(top_el,"nc_block_title"); 11522var parent_cell = Element.getParentElementByClassName(tr_el,"cell"); 11523if(parent_cell) { 11524parent_id = commonCls.getBlockid(parent_cell); 11525} else { 11526parent_id = 0; 11527} 11528} else { 11529var top_el = Element.getChildElement(document.body); 11530var title_el = Element.getChildElementByClassName(top_el,"nc_block_title"); 11531} 11532if(confirm_mes != undefined || confirm_mes != null) { 11533var text = title_el.innerHTML.trim(); 11534if(text == "") text = pagesLang.emptyBlockname; 11535if (!commonCls.confirm(confirm_mes.replace("%s", text))) return false; 11536} 11537var queryParams = commonCls.getParams(top_el); 11538var page_id = queryParams["page_id"]; 11539if(cell_el) { 11540var count = 0; 11541for (var i = 0; i < td_el.childNodes.length; i++) { 11542var div = td_el.childNodes[i]; 11543if(div && div.tagName == "DIV" && Element.hasClassName(div,"cell")) { 11544count++; 11545} 11546} 11547if(count == 1) { 11548Element.remove(td_el); 11549} else { 11550Element.remove(cell_el); 11551} 11552var cell_length = tr_el.cells.length; 11553if(cell_length == 0 && parent_id != 0) { 11554pagesCls.delEmptyBlock(parent_id); 11555} 11556} else { 11557Element.remove(top_el); 11558} 11559var delblock_params = new Object(); 11560delblock_params["method"] = "post"; 11561delblock_params["param"] = "pages_actionblock_deleteblock" + 11562"&_show_count=" + pagesCls.show_count[page_id]; 11563delblock_params["top_el"] = top_el; 11564pagesCls.show_count[page_id]++; 11565if(request_flag == false) return; 11566if(cell_el) { 11567delblock_params["callbackfunc_error"] = function(res){commonCls.alert(res);location.reload();}; 11568} 11569delblock_params["token"] = pagesCls.pages_token[page_id]; 11570commonCls.send(delblock_params); 11571}, 11572winMoveShowHeader: function(event, el, resize_flag) { 11573resize_flag = (resize_flag == undefined) ? false : resize_flag; 11574if(event) { 11575var el = $(this.id); 11576} 11577if(typeof pagesCls == 'undefined' || !el || (pagesCls.inMoveDrag || pagesCls.inMoveShowHeader["_move_header" + el.id])) 11578return false; 11579var _move_header = $("_move_header" + el.id); 11580if(_move_header) { 11581if(_move_header.style.position != "absolute") { 11582_move_header.style.position = "absolute"; 11583if(Element.hasClassName(_move_header, "_move_header")) { 11584var _block_title = Element.getChildElementByClassName(_move_header, "_block_title_abs"); 11585var _block_title_event = Element.getChildElementByClassName(_move_header,"_block_title_event_abs");
11586if(!_block_title_event) _block_title_event = _block_title; 11587var move_bar = Element.getChildElementByClassName(_move_header,"_move_bar"); 11588Event.observe(_block_title, "mouseover", commonCls.blockNotice, false, el); 11589Event.observe(_block_title_event,"dblclick",pagesCls.blockChangeName.bindAsEventListener(_block_title),false, el); 11590pagesCls.winMoveDragStartEvent[el.id] = pagesCls.winMoveDragStart.bindAsEventListener(el); 11591Event.observe(move_bar,"mousedown",pagesCls.winMoveDragStartEvent[el.id],false, el); 11592pagesCls.winGroupingEvent[el.id] = pagesCls.onGroupingEvent.bindAsEventListener(el); 11593Event.observe(move_bar,"click",pagesCls.winGroupingEvent[el.id],false, el); 11594} 11595} 11596var offset = Position.cumulativeOffset(el); 11597var x = offset[0]; 11598var y = offset[1]; 11599var x2 = offset[0] + el.offsetWidth; 11600_move_header.style.left = x +"px"; 11601_move_header.style.width = (x2 - x) +"px"; 11602if(!resize_flag) { 11603Element.addClassName(_move_header, "visible-hide"); 11604Element.removeClassName(_move_header, "display-none"); 11605} 11606if(y < 0) _move_header.style.top = "0px"; 11607else _move_header.style.top = y +"px"; 11608if(!resize_flag) { 11609Element.removeClassName(_move_header, "visible-hide"); 11610pagesCls.inMoveShowHeader[el.id] = true; 11611commonCls.moveVisibleHide(_move_header); 11612if(event)Event.stop(event); 11613} 11614} 11615}, 11616winMoveResizeHeader: function() { 11617if(_nc_layoutmode == "on" && typeof pagesCls != 'undefined') { 11618for (var key in pagesCls.inMoveShowHeader) { 11619if(pagesCls.inMoveShowHeader[key]) { 11620var header_el = $(key); 11621pagesCls.winMoveShowHeader(null, header_el, true); 11622} 11623} 11624} 11625}, 11626winMoveHideHeader: function(event) { 11627var el = $(this.id); 11628var _move_header = $("_move_header" + this.id); 11629if(_move_header) { 11630if( Position.within(_move_header, Event.pointerX(event), Event.pointerY(event), 2) ) { 11631return; 11632} 11633if( !Position.within( el, Event.pointerX(event), Event.pointerY(event), 2) ) { 11634Element.addClassName(_move_header, "display-none"); 11635pagesCls.inMoveShowHeader["_move_header" + this.id] = null; 11636commonCls.moveVisibleHide(_move_header); 11637Event.stop(event); 11638} 11639} 11640}, 11641winMoveDragStart: function(event) {
11642if(!pagesCls || pagesCls.inMoveDrag) 11643return false; 11644var el = this.parentNode; 11645if(el.tagName == "BODY" || Element.hasClassName(el,"enlarged_display")) 11646return false; 11647if(pagesCls.inChgBlockName[this.id] == true ) { 11648return false; 11649} 11650pagesCls.move_column_el = Element.getParentElementByClassName(el,"main_column") 11651if(!pagesCls.move_column_el) { 11652pagesCls.move_column_el = Element.getChildElement(document.body); 11653pagesCls.parentThreadNum = $("_grouping_thread_num").value; 11654pagesCls.parentParentid = $("_grouping_parent_id").value; 11655pagesCls.insert_tr = Element.getParentElement(Element.getChildElementByClassName(pagesCls.move_column_el,"column")); 11656} else { 11657pagesCls.insert_tr = Element.getChildElement(pagesCls.move_column_el,3); 11658pagesCls.parentParentid = 0; 11659} 11660pagesCls.move_el = el; 11661pagesCls.move_td = Element.getParentElement(el); 11662var paddingLeft = valueParseInt(pagesCls.move_el.style.paddingLeft); 11663var paddingRight = valueParseInt(pagesCls.move_el.style.paddingRight); 11664var paddingTop = valueParseInt(pagesCls.move_el.style.paddingTop); 11665var paddingBottom = valueParseInt(pagesCls.move_el.style.paddingBottom); 11666pagesCls.active_style = paddingTop + "px" + " " + paddingRight + "px" + " " + paddingBottom + "px" + " " + paddingLeft + "px"; 11667var count = 1; 11668var top_el = Element.getChildElement(pagesCls.move_el); 11669var id_name = top_el.id; 11670pagesCls.insertMoveRowBlockId = commonCls.getBlockid(top_el); 11671for (var i = 0; i < pagesCls.move_td.childNodes.length; i++) { 11672var div = pagesCls.move_td.childNodes[i]; 11673if(div && div.tagName == "DIV" && Element.hasClassName(div,"cell")) { 11674if (Element.getChildElement(div).id == id_name){ 11675pagesCls.insertMoveRowIndex = count; 11676} 11677count++; 11678} 11679} 11680pagesCls.insertMoveRowLength = count - 1; 11681pagesCls.insertMoveCellIndex = commonCls.cellIndex(pagesCls.move_td) + 1; 11682pagesCls.insertMoveCellLength = pagesCls.move_td.parentNode.cells.length; 11683var parent_cell = Element.getParentElementByClassName(Element.getParentElement(el),"cell"); 11684if(parent_cell) { 11685pagesCls.insertMoveRowParentId = commonCls.getBlockid(parent_cell); 11686} else { 11687pagesCls.insertMoveRowParentId = pagesCls.parentParentid; 11688} 11689pagesCls.insertMoveEndRowThreadNum = null; 11690pagesCls.insertMoveEndRowParentId = null; 11691pagesCls.xOffset = Event.pointerX(event) - Position.cumulativeOffset(pagesCls.move_el)[0]; 11692pagesCls.yOffset = Event.pointerY(event) - Position.cumulativeOffset(pagesCls.move_el)[1]; 11693pagesCls.start_x = Event.pointerX(event); 11694pagesCls.start_y = Event.pointerY(event); 11695pagesCls.winMoveDragGoEvent = pagesCls.winMoveDragGo.bindAsEventListener(el); 11696pagesCls.winMoveDragStopEvent = pagesCls.winMoveDragStop.bindAsEventListener(el); 11697Event.observe(document,"mousemove",pagesCls.winMoveDragGoEvent,true); 11698Event.observe(document,"mouseup",pagesCls.winMoveDragStopEvent,true); 11699Event.stop(event); 11700pagesCls.inMoveDrag = true; 11701pagesCls.insertAction = ""; 11702}, 11703searchInsertBlock: function(cloneTopPos, x, y, now_thread_num, now_parent_id) { 11704pagesCls.insertMoveEndRowParentId = now_parent_id; 11705var insert_el = null; 11706if(cloneTopPos["el"].tagName == "TR") 11707var insert_tr = cloneTopPos["el"]; 11708else 11709var insert_tr = cloneTopPos["grouping_tr_el"]; 11710if( x >= cloneTopPos['left'] && 11711x < cloneTopPos['right']) { 11712for (var i = 0,col_len = pagesCls.cloneColumnPos[now_parent_id].length; i < col_len; i++) { 11713var el_left = pagesCls.cloneColumnPos[now_parent_id][i]["left"]; 11714var el_right = pagesCls.cloneColumnPos[now_parent_id][i]["right"]; 11715if(x >= el_left && 11716x <= el_right) { 11717var insert_td = pagesCls.cloneColumnPos[now_parent_id][i]["el"]; 11718for (var j = 0,row_count = pagesCls.clonePos[now_parent_id][i].length; j < row_count; j++) { 11719if(firstdiv_el == null) { 11720var firstdiv_el = pagesCls.clonePos[now_parent_id][i][j]['el']; 11721} 11722var enddiv_el = pagesCls.clonePos[now_parent_id][i][j]['el']; 11723if(this.clonePos[now_parent_id][i][j]['top'] > y && position_el == null) { 11724var position_el = pagesCls.clonePos[now_parent_id][i][j]['el']; 11725} 11726if(y >= pagesCls.clonePos[now_parent_id][i][j]['top'] && 11727y <= pagesCls.clonePos[now_parent_id][i][j]['bottom']) { 11728insert_el = pagesCls.clonePos[now_parent_id][i][j]['el']; 11729if(pagesCls.clonePos[now_parent_id][i][j]['grouping_flag']) { 11730var queryParams = commonCls.getParams(insert_el); 11731next_parent_id = parseInt(queryParams["block_id"]);
11732insert_el = pagesCls.searchInsertBlock(pagesCls.clonePos[now_parent_id][i][j], x,y,now_thread_num + 1,next_parent_id); 11733break; 11734} 11735var ex1 = pagesCls.clonePos[now_parent_id][i][j]['left']; 11736var ex2 = pagesCls.clonePos[now_parent_id][i][j]['right']; 11737var ey1= pagesCls.clonePos[now_parent_id][i][j]['top']; 11738var ey2 = pagesCls.clonePos[now_parent_id][i][j]['bottom']; 11739var direction = null; 11740var offset = Math.ceil((ex2 - ex1)/4); 11741if(x > ex2 - offset) { 11742direction = "right"; 11743} else if(x < ex1 + offset) { 11744direction = "left"; 11745}else if(y > ey1 + (ey2 - ey1)/2) { 11746direction = "bottom"; 11747} else { 11748direction = "top"; 11749} 11750var index = commonCls.cellIndex(insert_td); 11751switch (direction) { 11752case "left": 11753InsertCell(index,insert_tr); 11754break; 11755case "right": 11756index = index + 1; 11757InsertCell(index,insert_tr); 11758break; 11759case "top": 11760InsertBeforeEl(insert_el); 11761break; 11762case "bottom": 11763InsertAfterEl(insert_el); 11764break; 11765} 11766break; 11767} 11768} 11769if(insert_el == undefined || insert_el == null) { 11770if(position_el != null){ 11771insert_el = position_el; 11772InsertBeforeEl(insert_el); 11773} else { 11774insert_el = enddiv_el; 11775if(enddiv_el) InsertAfterEl(enddiv_el); 11776} 11777} 11778break; 11779} 11780} 11781} 11782if(insert_el == null) { 11783if(x < cloneTopPos['left']) { 11784InsertCell(0,cloneTopPos["el"]); 11785} else { 11786var index = insert_tr.cells.length; 11787InsertCell(index,insert_tr); 11788} 11789var tdList = insert_tr.getElementsByTagName("td"); 11790for (var i = 0,tdLen = tdList.length; i < tdLen; i++){ 11791if(Element.hasClassName(tdList[i],"column") && (tdList[i].innerHTML.trim()) == "") { 11792Element.remove(tdList[i]); 11793} 11794} 11795} 11796return pagesCls.insert_el; 11797function InsertBeforeEl(el){ 11798var div = document.createElement("DIV"); 11799div.className = "cell"; 11800div.style.padding = pagesCls.active_style; 11801pagesCls.insert_td = el.parentNode; 11802pagesCls.insert_el = el.parentNode.insertBefore(div, el); 11803delMoveEl(); 11804pagesCls.insertAction = "insertrow"; 11805} 11806function InsertAfterEl(el){ 11807var div = document.createElement("DIV"); 11808div.className = "cell"; 11809div.style.padding = pagesCls.active_style; 11810pagesCls.insert_td = el.parentNode; 11811pagesCls.insert_el = el.parentNode.insertBefore(div, el.nextSibling); 11812delMoveEl(); 11813pagesCls.insertAction = "insertrow"; 11814} 11815function InsertCell(Index,insert_tr){ 11816Index = delMoveEl(Index); 11817pagesCls.insert_td = insert_tr.insertCell(Index); 11818pagesCls.insert_td.className = "column valign-top"; 11819var div = document.createElement("DIV"); 11820div.className = "cell"; 11821div.style.padding = pagesCls.active_style; 11822pagesCls.insert_td.appendChild(div); 11823pagesCls.insert_el = div; 11824pagesCls.insertAction = "insertcell"; 11825} 11826function delMoveEl(Index) { 11827Index = (Index == undefined) ? 0 : Index; 11828if(pagesCls.move_el != null && pagesCls.move_el != undefined) { 11829if (Element.hasClassName(Element.getChildElement(pagesCls.move_el),"column_movedummy")){ 11830Element.remove(pagesCls.move_el); 11831} 11832pagesCls.move_el = null; 11833var divList = pagesCls.move_td.getElementsByTagName("div"); 11834if(divList.length == 0 && pagesCls.move_td.parentNode.cells.length > 1){ 11835if(Index > commonCls.cellIndex(pagesCls.move_td)) { 11836Index = Index - 1; 11837} 11838Element.remove(pagesCls.move_td); 11839pagesCls.move_td = null; 11840} 11841} 11842return Index; 11843} 11844}, 11845getSearchBlock: function(top_td_el,insert_tr,now_thread_num,now_parent_id) {
11846if(!pagesCls.cloneTopPos["el"]) { 11847var offset = Position.cumulativeOffset(top_td_el); 11848pagesCls.cloneTopPos["el"] = insert_tr; 11849pagesCls.cloneTopPos["top"] = offset[1]; 11850pagesCls.cloneTopPos["right"] = offset[0] + top_td_el.offsetWidth; 11851pagesCls.cloneTopPos["bottom"] = offset[1] + top_td_el.offsetHeight; 11852pagesCls.cloneTopPos["left"] = offset[0]; 11853} 11854pagesCls.cloneColumnPos[now_parent_id] = Array(); 11855pagesCls.clonePos[now_parent_id] = Array(); 11856for (var i = 0,col_len = insert_tr.childNodes.length; i < col_len; i++) { 11857var column_el = insert_tr.childNodes[i]; 11858pagesCls.cloneColumnPos[now_parent_id][i] = new Object(); 11859var offset = Position.cumulativeOffset(column_el); 11860pagesCls.cloneColumnPos[now_parent_id][i]["el"] = column_el; 11861pagesCls.cloneColumnPos[now_parent_id][i]["top"] = offset[1]; 11862pagesCls.cloneColumnPos[now_parent_id][i]["right"] = offset[0] + column_el.offsetWidth; 11863pagesCls.cloneColumnPos[now_parent_id][i]["bottom"] = offset[1] + column_el.offsetHeight; 11864pagesCls.cloneColumnPos[now_parent_id][i]["left"] = offset[0]; 11865pagesCls.clonePos[now_parent_id][i] = Array(); 11866for (var j = 0,row_len = column_el.childNodes.length; j < row_len; j++) { 11867var row_el = column_el.childNodes[j]; 11868var child_el = Element.getChildElement(row_el); 11869pagesCls.clonePos[now_parent_id][i][j] = new Object(); 11870pagesCls.clonePos[now_parent_id][i][j]["grouping_flag"] = false; 11871if(Element.hasClassName(child_el, "module_grouping_box")) { 11872var queryParams = commonCls.getParams(row_el); 11873next_parent_id = parseInt(queryParams["block_id"]); 11874var tdSubList = child_el.getElementsByTagName("td"); 11875for (var k = 0,tdSubListLen = tdSubList.length; k < tdSubListLen; k++){ 11876if(Element.hasClassName(tdSubList[k],"column")) { 11877var now_insert_tr = Element.getParentElement(tdSubList[k]); 11878break; 11879} 11880} 11881pagesCls.clonePos[now_parent_id][i][j]["grouping_flag"] = true; 11882pagesCls.clonePos[now_parent_id][i][j]["grouping_tr_el"] = now_insert_tr; 11883if(now_insert_tr) pagesCls.getSearchBlock(child_el, now_insert_tr, now_thread_num + 1,next_parent_id); 11884} 11885var offset = Position.cumulativeOffset(child_el); 11886pagesCls.clonePos[now_parent_id][i][j]["el"] = row_el; 11887pagesCls.clonePos[now_parent_id][i][j]["top"] = offset[1]; 11888pagesCls.clonePos[now_parent_id][i][j]["right"] = offset[0] + child_el.offsetWidth; 11889pagesCls.clonePos[now_parent_id][i][j]["bottom"] = offset[1] + child_el.offsetHeight; 11890pagesCls.clonePos[now_parent_id][i][j]["left"] = offset[0]; 11891} 11892} 11893}, 11894winMoveDragGo: function(event) {
11895if(!pagesCls.inMoveDrag) 11896return false; 11897pagesCls.insert_td = null; 11898pagesCls.insert_el = null; 11899var x = Event.pointerX(event); 11900var y = Event.pointerY(event); 11901var width = this.offsetWidth; 11902var height = this.offsetHeight; 11903var def_px = 5; 11904if(x <= pagesCls.start_x + def_px && x >= pagesCls.start_x - def_px && 11905y <= pagesCls.start_y + def_px && y >= pagesCls.start_y - def_px) { 11906return true; 11907} 11908commonCls.scrollMoveDrag(event); 11909if(pagesCls.active == null || pagesCls.active == undefined) { 11910var divList = document.getElementsByTagName("div"); 11911for (var i = 0; i < divList.length; i++){ 11912if (Element.hasClassName(divList[i],"cell")){ 11913pagesCls.cancelSelectStyle(divList[i]); 11914} 11915} 11916pagesCls.active = pagesCls.winCreateCopy(this,width,height); 11917for (var key in pagesCls.inMoveShowHeader) { 11918if(pagesCls.inMoveShowHeader[key]) { 11919var header_el = $("_move_header" + key); 11920Element.addClassName(header_el, "display-none"); 11921pagesCls.inMoveShowHeader[key] = false; 11922} 11923} 11924if (Element.hasClassName(pagesCls.move_column_el,"main_column")){ 11925pagesCls.getSearchBlock(pagesCls.move_column_el, pagesCls.insert_tr,0,0); 11926} else { 11927pagesCls.getSearchBlock(pagesCls.move_column_el, pagesCls.insert_tr,pagesCls.parentThreadNum,pagesCls.parentParentid); 11928} 11929} 11930if (Element.hasClassName(pagesCls.move_column_el,"main_column")){ 11931pagesCls.searchInsertBlock(pagesCls.cloneTopPos, x, y, 0, 0); 11932} else { 11933pagesCls.searchInsertBlock(pagesCls.cloneTopPos, x, y, pagesCls.parentThreadNum, pagesCls.parentParentid); 11934} 11935if(pagesCls.insert_td && pagesCls.insert_el) { 11936pagesCls.move_td = pagesCls.insert_td; 11937pagesCls.move_el = pagesCls.insert_el; 11938} 11939Event.stop(event); 11940var paddingLeft = valueParseInt(this.style.paddingLeft); 11941var paddingTop = valueParseInt(this.style.paddingTop); 11942if(Event.pointerX(event) - pagesCls.xOffset + paddingLeft <= 0){ 11943pagesCls.active.style.left = -paddingLeft + "px"; 11944}else{ 11945pagesCls.active.style.left = (x - pagesCls.xOffset) + "px"; 11946} 11947if(Event.pointerY(event) - pagesCls.yOffset + paddingTop <= 0){ 11948pagesCls.active.style.top = -paddingTop + "px"; 11949}else{ 11950pagesCls.active.style.top = (y - pagesCls.yOffset) + "px"; 11951} 11952if(pagesCls.move_el && (Element.getChildElement(pagesCls.move_el) == null || Element.getChildElement(pagesCls.move_el).innerHTML == "")) { 11953var div = document.createElement("DIV"); 11954var div_child = document.createElement("DIV"); 11955Element.addClassName(div,"column_movedummy"); 11956div_child.style.width = pagesCls.active.offsetWidth - valueParseInt(pagesCls.move_el.style.paddingLeft) - valueParseInt(pagesCls.move_el.style.paddingRight) + "px"; 11957div_child.style.height = pagesCls.active.offsetHeight - valueParseInt(pagesCls.move_el.style.paddingTop) - valueParseInt(pagesCls.move_el.style.paddingBottom) + "px"; 11958div.appendChild(div_child); 11959pagesCls.move_el.appendChild(div); 11960if(browser.isNS){ 11961pagesCls.move_column_el.style.display = "none"; 11962pagesCls.move_column_el.style.display = ""; 11963} 11964} 11965}, 11966winMoveDragStop: function(event) { 11967if(pagesCls.active != null && pagesCls.active != undefined) { 11968var _move_header = $("_move_header" + Element.getChildElement(pagesCls.active, 2).id); 11969if(Element.hasClassName(_move_header, "_move_header")) { 11970_move_header.style.display = ""; 11971} 11972Element.remove(Element.getChildElement(pagesCls.move_el)); 11973pagesCls.move_el.appendChild(Element.getChildElement(pagesCls.active,2)); 11974pagesCls.cancelSelectStyle(pagesCls.move_el); 11975Element.remove(pagesCls.active); 11976delete pagesCls.active; 11977pagesCls.active = null; 11978} 11979Event.stopObserving(document,"mousemove",pagesCls.winMoveDragGoEvent,true); 11980Event.stopObserving(document,"mouseup",pagesCls.winMoveDragStopEvent,true); 11981pagesCls.winMoveDragGoEvent = null; 11982pagesCls.winMoveDragStopEvent = null; 11983pagesCls.cloneTopPos = new Object(); 11984pagesCls.cloneColumnPos = Array(); 11985pagesCls.clonePos = Array(); 11986Event.stop(event); 11987if(pagesCls.insertMoveEndRowParentId != null) { 11988var id_name = Element.getChildElement(pagesCls.move_el).id; 11989var insertCellIndex = commonCls.cellIndex(pagesCls.move_td) + 1; 11990var insertRowIndex = 1; 11991var insertRowLength = 1; 11992if(pagesCls.insertAction == "insertrow") { 11993var count = 1; 11994for (var i = 0; i < pagesCls.move_td.childNodes.length; i++) {
11995var div = pagesCls.move_td.childNodes[i]; 11996if(div.tagName == "DIV" && Element.hasClassName(div,"cell")) { 11997if (Element.getChildElement(div).id == id_name){ 11998insertRowIndex = count; 11999} 12000count++; 12001} 12002} 12003insertRowLength = count - 1; 12004if(insertRowLength == 1) 12005pagesCls.insertAction = "insertcell"; 12006} 12007if(pagesCls.insertAction == "" || pagesCls.insertMoveCellIndex == insertCellIndex && 12008pagesCls.insertMoveRowIndex == insertRowIndex && 12009pagesCls.insertMoveRowLength == insertRowLength && 12010pagesCls.insertMoveRowParentId == pagesCls.insertMoveEndRowParentId) { 12011} else { 12012if(pagesCls.insertMoveRowLength == 1 && pagesCls.insertMoveCellLength == 1 && pagesCls.insertMoveRowParentId != 0) { 12013pagesCls.delEmptyBlock(pagesCls.insertMoveRowParentId); 12014} 12015var queryParams = commonCls.getParams(pagesCls.move_el); 12016var page_id = queryParams["page_id"]; 12017var postBody = "pages_action_" + pagesCls.insertAction + 12018"&block_id=" + pagesCls.insertMoveRowBlockId + 12019"&col_num=" + insertCellIndex + "&row_num=" + insertRowIndex + "&row_len=" + insertRowLength + 12020"&parent_id=" + pagesCls.insertMoveEndRowParentId + 12021"&pre_col_num=" + pagesCls.insertMoveCellIndex + "&pre_row_num=" + pagesCls.insertMoveRowIndex + "&pre_row_len=" + pagesCls.insertMoveRowLength + 12022"&pre_parent_id=" + pagesCls.insertMoveRowParentId + 12023"&_show_count=" + pagesCls.show_count[page_id]; 12024var params = new Object(); 12025params["method"] = "post"; 12026params["param"] = postBody; 12027params["top_el"] = pagesCls.move_el; 12028params["callbackfunc_error"] = function(){location.reload();}; 12029params["token"] = pagesCls.pages_token[page_id]; 12030commonCls.send(params); 12031pagesCls.show_count[page_id]++; 12032} 12033} 12034pagesCls.inMoveDrag = false; 12035}, 12036delEmptyBlock: function(del_parent_id) { 12037var divList = pagesCls.move_column_el.getElementsByTagName("div"); 12038for (var i = 0; i < divList.length; i++){ 12039if (Element.hasClassName(divList[i],"cell")){ 12040var id_name = Element.getChildElement(divList[i]).id; 12041var block_id = id_name.substr(1, id_name.length); 12042if(block_id == del_parent_id) { 12043var tr_el = Element.getParentElement(divList[i],2); 12044var td_el = divList[i].parentNode; 12045var parent_cell = Element.getParentElementByClassName(Element.getParentElement(divList[i]),"cell"); 12046if(parent_cell) { 12047var parent_id_name = Element.getChildElement(parent_cell).id; 12048var parent_id = parent_id_name.substr(1, parent_id_name.length); 12049} else { 12050var parent_id = 0; 12051} 12052Element.remove(divList[i]); 12053var count = 0; 12054for (var i = 0; i < td_el.childNodes.length; i++) { 12055var div = td_el.childNodes[i]; 12056if(div && div.tagName == "DIV" && Element.hasClassName(div,"cell")) { 12057count++; 12058} 12059} 12060if(count == 0) 12061Element.remove(td_el); 12062if(tr_el.cells.length == 0 && parent_id != 0) { 12063pagesCls.delEmptyBlock(parent_id); 12064} 12065} 12066} 12067} 12068}, 12069pageMoveComplete: function(transport) { 12070var res = transport.responseText; 12071if(res != "" && res != null) {
12072res = res.replace(/\\n/ig,"\n"); 12073alert(res); 12074window.location.reload(); 12075} 12076}, 12077winCreateCopy: function(el,width,height) { 12078var Block = document.createElement("div"); 12079var top_el_id = Element.getChildElement(el).id; 12080var _move_header = $("_move_header" + top_el_id); 12081Block.appendChild(el); 12082if(_move_header && !Element.hasClassName(_move_header, "display-none")) { 12083_move_header.style.position = "absolute"; 12084var paddingLeft = valueParseInt(el.style.paddingLeft); 12085var paddingTop = valueParseInt(el.style.paddingTop); 12086_move_header.style.top = paddingTop + "px"; 12087_move_header.style.left = paddingLeft + "px"; 12088Element.removeClassName(_move_header, "display-none"); 12089_move_header.style.display = "block"; 12090} 12091Block.style.position = "absolute"; 12092Block.style.zIndex = commonCls.max_zIndex + 1; 12093Block.style.width = width + "px"; 12094Block.style.height = height + "px"; 12095document.body.appendChild(Block); 12096return Block; 12097}, 12098onGroupingEvent: function(event) { 12099if(_nc_layoutmode != "on") return; 12100var cell_el = Element.getParentElementByClassName(Event.element(event),"cell"); 12101if(!cell_el) 12102return false;
12103if(!pagesCls.cancelSelectStyle(cell_el)) { 12104pagesCls.setSelectStyle(cell_el); 12105pagesCls.onGroupingCheck(cell_el); 12106} 12107}, 12108onGroupingCheck : function(cell_el) { 12109var main_column_el = Element.getParentElementByClassName(cell_el,"main_column"); 12110var grouping_flag = false; 12111if(!main_column_el) { 12112main_column_el = Element.getChildElement(document.body); 12113grouping_flag = true; 12114} 12115var parent_id = this.getParentid(cell_el); 12116var divList = document.getElementsByTagName("div"); 12117this.groupingList = Array(); 12118var groupingBlockidList = Array(); 12119var col_num = -1; 12120var row_num = 0; 12121var count = 0; 12122var cell_index = null; 12123var pre_cell_index = null; 12124for (var i = 0; i < divList.length; i++){ 12125if (Element.hasClassName(divList[i],"cell")){ 12126var now_parent_id = this.getParentid(divList[i]); 12127if(pagesCls.checkSelectStyle(divList[i])) { 12128if(now_parent_id != parent_id) { 12129pagesCls.cancelSelectStyle(divList[i]); 12130} else if(grouping_flag == false && main_column_el != Element.getParentElementByClassName(divList[i],"main_column")) { 12131pagesCls.cancelSelectStyle(divList[i]); 12132} else { 12133cell_index = commonCls.cellIndex(divList[i].parentNode); 12134if(pre_cell_index == null || cell_index != pre_cell_index) { 12135pre_cell_index = cell_index; 12136col_num++; 12137row_num = 0; 12138this.groupingList[col_num] = Array(); 12139groupingBlockidList[col_num] = Array(); 12140} 12141queryParams = commonCls.getParams(divList[i]); 12142var block_id = queryParams["block_id"]; 12143groupingBlockidList[col_num][row_num] = block_id; 12144this.groupingList[col_num][row_num] = divList[i]; 12145row_num++; 12146count++; 12147} 12148} 12149} 12150} 12151return groupingBlockidList; 12152}, 12153setSelectStyle: function(el) { 12154var main_column = Element.getParentElementByClassName(el,"main_column"); 12155var grouping_flag = false; 12156if(!main_column) { 12157main_column = Element.getChildElement(document.body); 12158grouping_flag = true; 12159} 12160if(main_column.id =="__leftcolumn") { 12161Element.addClassName(el, "select_leftcolumn"); 12162} else if(main_column.id =="__centercolumn") { 12163Element.addClassName(el, "select_centercolumn"); 12164} else if(main_column.id =="__rightcolumn") { 12165Element.addClassName(el, "select_rightcolumn"); 12166} else if(main_column.id =="__headercolumn") { 12167Element.addClassName(el, "select_headercolumn"); 12168} else if(grouping_flag) { 12169Element.addClassName(el, "select_centercolumn"); 12170} else { 12171return false; 12172} 12173return true; 12174}, 12175cancelSelectStyle: function(el) { 12176var style_name = this.checkSelectStyle(el); 12177if(!style_name) { 12178return false; 12179} 12180Element.removeClassName(el, style_name); 12181return true; 12182}, 12183checkSelectStyle: function(el) { 12184if(Element.hasClassName(el,"select_leftcolumn")) { 12185var style_name = "select_leftcolumn"; 12186} else if(Element.hasClassName(el,"select_centercolumn")) { 12187var style_name = "select_centercolumn"; 12188} else if(Element.hasClassName(el,"select_rightcolumn")) { 12189var style_name = "select_rightcolumn"; 12190} else if(Element.hasClassName(el,"select_headercolumn")) { 12191var style_name = "select_headercolumn"; 12192} else { 12193return false; 12194} 12195return style_name; 12196}, 12197getThreadnum: function(cell_el, thread_num) { 12198thread_num = (thread_num == undefined) ? pagesCls.parentThreadNum : thread_num; 12199var parent_cell = Element.getParentElementByClassName(Element.getParentElement(cell_el),"cell"); 12200if(parent_cell) { 12201thread_num++; 12202thread_num = this.getThreadnum(parent_cell,thread_num); 12203} 12204return thread_num; 12205}, 12206getParentid: function(cell_el) { 12207var parent_cell = Element.getParentElementByClassName(Element.getParentElement(cell_el),"cell"); 12208if(parent_cell) { 12209var queryParams = commonCls.getParams(parent_cell); 12210return queryParams["block_id"]; 12211} 12212return 0; 12213}, 12214addGrouping: function(event, confirm_mes , confirm_error_mes) { 12215var divList = document.getElementsByTagName("div"); 12216var cell_el = null; 12217for (var i = 0; i < divList.length; i++){ 12218if (Element.hasClassName(divList[i],"cell")){ 12219if(pagesCls.checkSelectStyle(divList[i])) { 12220cell_el = divList[i]; 12221var queryParams = commonCls.getParams(cell_el); 12222var ins_block_id = queryParams["block_id"]; 12223var page_id = queryParams["page_id"]; 12224break; 12225} 12226} 12227} 12228if(cell_el == null) { 12229commonCls.alert(confirm_error_mes); 12230return; 12231} 12232if (confirm_mes == undefined || !commonCls.confirm(confirm_mes)) return false; 12233var groupingBlockidList = this.onGroupingCheck(cell_el); 12234for(var i = 0; i < this.groupingList.length; i++) { 12235for(var j = 0; j < this.groupingList[i].length; j++) { 12236pagesCls.cancelSelectStyle(this.groupingList[i][j]); 12237} 12238} 12239var postBody = "pages_action_grouping&block_id=" + ins_block_id + 12240"&_show_count=" + pagesCls.show_count[page_id]; 12241postBody = postBody + "&_grouping_list="; 12242for(var i = 0; i < groupingBlockidList.length; i++) { 12243for(var j = 0; j < groupingBlockidList[i].length; j++) { 12244postBody = postBody + groupingBlockidList[i][j]; 12245if(j != groupingBlockidList[i].length - 1) 12246postBody = postBody + ","; 12247} 12248if(i != groupingBlockidList.length - 1) 12249postBody = postBody + ":"; 12250} 12251var params_grouping = new Object(); 12252var div = document.createElement("DIV"); 12253div.className = "cell"; 12254var paddingLeft = valueParseInt(cell_el.style.paddingLeft); 12255var paddingRight = valueParseInt(cell_el.style.paddingRight); 12256var paddingTop = valueParseInt(cell_el.style.paddingTop); 12257var paddingBottom = valueParseInt(cell_el.style.paddingBottom); 12258div.style.padding = paddingTop + "px" + " " + paddingRight + "px" + " " + paddingBottom + "px" + " " + paddingLeft + "px"; 12259var temp_html = cell_el.innerHTML; 12260div.appendChild(Element.getChildElement(cell_el)); 12261cell_el.innerHTML = temp_html; 12262pagesCls.active = div; 12263params_grouping["method"] = "post"; 12264params_grouping["param"] = postBody; 12265params_grouping["loading_el"] = Element.getChildElement(cell_el); 12266params_grouping["target_el"] = cell_el; 12267params_grouping["top_el"] = cell_el; 12268params_grouping["callbackfunc"] = function(cell_el){ 12269this.addGroupingComp(cell_el); 12270}.bind(this); 12271params_grouping["func_param"] = cell_el; 12272params_grouping["callbackfunc_error"] = function(res){ 12273pagesCls.active = null; location.reload(); 12274}; 12275params_grouping["token"] = pagesCls.pages_token[page_id]; 12276commonCls.send(params_grouping); 12277pagesCls.show_count[page_id]++; 12278return false;
12279}, 12280addGroupingComp: function(cell_el) { 12281var main_column_el = Element.getParentElementByClassName(cell_el,"main_column"); 12282if(!main_column_el) { 12283main_column_el = Element.getChildElement(document.body); 12284} 12285var insert_column_el = Element.getChildElementByClassName(cell_el,"column"); 12286var insert_tr = Element.getParentElement(insert_column_el); 12287for(var i = 0; i < this.groupingList.length; i++) { 12288for(var j = 0; j < this.groupingList[i].length; j++) { 12289if(this.groupingList[i][j] == cell_el) { 12290var append_el = pagesCls.active; 12291} else { 12292var append_el = this.groupingList[i][j]; 12293} 12294if(i==0) { 12295insert_column_el.appendChild(append_el); 12296} else { 12297if(i > insert_tr.cells.length - 1) { 12298insert_column_el = insert_tr.insertCell(i); 12299insert_column_el.className = "column valign-top"; 12300} 12301insert_column_el.appendChild(append_el); 12302} 12303} 12304} 12305pagesCls.active = null; 12306var tdList = main_column_el.getElementsByTagName("td"); 12307for (var i = 0; i < tdList.length; i++){ 12308if (Element.hasClassName(tdList[i],"column")){ 12309var count = 0; 12310for (var j = 0; j < tdList[i].childNodes.length; j++) { 12311var div = tdList[i].childNodes[j]; 12312if(div && div.tagName == "DIV" && Element.hasClassName(div,"cell")) { 12313count++; 12314} 12315} 12316if(count == 0) { 12317Element.remove(tdList[i]); 12318} 12319} 12320} 12321return true; 12322}, 12323cancelGrouping: function(event, confirm_mes , confirm_error_mes) { 12324var divList = document.getElementsByTagName("div"); 12325confirm_flag = false; 12326for (var i = 0; i < divList.length; i++){ 12327if (Element.hasClassName(divList[i],"cell")){ 12328if(pagesCls.checkSelectStyle(divList[i])) { 12329var queryParams = commonCls.getParams(divList[i]); 12330if(queryParams["action"] == "pages_view_grouping" || queryParams["action"] == "pages_action_grouping") { 12331if(confirm_flag == false) { 12332if (confirm_mes == undefined || !commonCls.confirm(confirm_mes)) return false; 12333confirm_flag = true; 12334} 12335var cell_el = divList[i]; 12336this.cancelGroupingDetail(cell_el); 12337} else { 12338pagesCls.cancelSelectStyle(divList[i]); 12339} 12340} 12341} 12342} 12343if(confirm_flag == false) { 12344commonCls.alert(confirm_error_mes); 12345} 12346}, 12347cancelGroupingDetail: function(cell_el) { 12348if(this.inCancelGroupingDrag == true ) { 12349setTimeout(this.cancelGroupingDetail(cell_el), 100); 12350} 12351this.inCancelGroupingDrag = true; 12352var queryParams = commonCls.getParams(cell_el); 12353var ins_block_id = queryParams["block_id"]; 12354var page_id = queryParams["page_id"]; 12355var postBody = "pages_action_cancelgrouping&block_id=" + ins_block_id + 12356"&_show_count=" + pagesCls.show_count[page_id]; 12357var params_grouping = new Object(); 12358params_grouping["method"] = "post"; 12359params_grouping["param"] = postBody; 12360params_grouping["loading_el"] = Element.getChildElement(cell_el); 12361params_grouping["top_el"] = cell_el; 12362params_grouping["callbackfunc"] = function(cell_el){this.cancelGroupingComp(cell_el);}.bind(this); 12363params_grouping["func_param"] = cell_el; 12364params_grouping["callbackfunc_error"] = function(){location.reload();}; 12365params_grouping["token"] = pagesCls.pages_token[page_id]; 12366commonCls.send(params_grouping); 12367pagesCls.show_count[page_id]++; 12368return false; 12369}, 12370cancelGroupingComp: function(parent_cell_el) { 12371this.inCancelGroupingDrag = false; 12372var top_el = Element.getChildElement(parent_cell_el); 12373var parent_column_el = Element.getParentElementByClassName(top_el,"column"); 12374var first_column_el = Element.getChildElementByClassName(top_el,"column"); 12375var tr_el = first_column_el.parentNode; 12376var divList = parent_cell_el.getElementsByTagName("div"); 12377for (var i = 0; i < divList.length; i++){ 12378if (Element.hasClassName(divList[i],"cell")){ 12379pagesCls.cancelSelectStyle(divList[i]); 12380} 12381} 12382var tdList = Array(); 12383var count_td = 0; 12384for (var i = 0; i < tr_el.childNodes.length; i++) { 12385var column_el = tr_el.childNodes[i]; 12386if(column_el && column_el.tagName == "TD" && Element.hasClassName(column_el,"column")) { 12387if(column_el == first_column_el) { 12388var divList = Array(); 12389var count = 0; 12390for (var j = 0; j < column_el.childNodes.length; j++) { 12391var div = column_el.childNodes[j]; 12392if(div && div.tagName == "DIV" && Element.hasClassName(div,"cell")) { 12393divList[count] = div; 12394count++; 12395} 12396} 12397for (var j = divList.length - 1; j >= 0; j--) { 12398parent_column_el.insertBefore(divList[j], parent_cell_el.nextSibling); 12399} 12400} else { 12401tdList[count_td] = column_el; 12402count_td++; 12403} 12404} 12405} 12406for (var i = tdList.length - 1; i >= 0; i--) {
12407parent_column_el.parentNode.insertBefore(tdList[i], parent_column_el.nextSibling); 12408} 12409Element.remove(parent_cell_el); 12410} 12411} 12412pagesCls = new clsPages(); 12413var clsBlockstyle = Class.create(); 12414clsBlockstyle.prototype = { 12415initialize: function() { 12416this.confirm_mes = null; 12417this.colorclick_flag = new Object(); 12418this.color_params = new Object(); 12419this.change_color = new Object(); 12420this.refresh_flag = new Object(); 12421}, 12422init: function(id, active_tab, blocktheme_name, lang_style, lang_theme, lang_coloration) { 12423var top_el = $(id); 12424this.refresh_flag[id] = false; 12425if(blocktheme_name) { 12426commonCls.addBlockTheme(blocktheme_name); 12427} 12428tabset = new compTabset(top_el); 12429tabset.setActiveIndex(valueParseInt(active_tab)); 12430tabset.addTabset(lang_theme); 12431tabset.addTabset(lang_style,blockstyleCls.clkStyle.bind($(id))); 12432tabset.addTabset(lang_coloration, blockstyleCls.clkCustomColor.bind($(id)), blockstyleCls.initCustomColor.bind($(id))); 12433tabset.render(); 12434}, 12435clkStyle: function() { 12436var top_el = this; 12437var form = top_el.getElementsByTagName("form")[0]; 12438commonCls.focus(form.block_name); 12439}, 12440clkCustomColor: function() { 12441var el = $("_blockstyle_custom_top" + this.id); 12442if(el) commonCls.focus(el); 12443}, 12444initCustomColor: function() { 12445var id = this.id; 12446var samplefields = Element.getElementsByClassName($(id), "_blockstyle_custom_sample"); 12447samplefields.each(function(coloration_el) { 12448var preview_el = Element.getChildElement(coloration_el); 12449var content_el = coloration_el.nextSibling; 12450var propertyfields = Element.getElementsByClassName(content_el, "_blockstyle_custom_property"); 12451propertyfields.each(function(field) { 12452var child_el = Element.getChildElement(field); 12453var property_name = child_el.value; 12454if(pagestyleCls.setHighlightColor(preview_el, field, property_name)) { 12455return; 12456} 12457}.bind(this)); 12458}.bind(this)); 12459var checkboxfields = Element.getElementsByClassName($(id), "_blockstyle_autocheckbox"); 12460checkboxfields.each(function(checkbox_el) { 12461checkbox_el.checked = true; 12462blockstyleCls.chkAutoClick(checkbox_el); 12463}.bind(this)); 12464}, 12465chkAutoClick: function(this_el) { 12466var input_el = this_el.parentNode.parentNode.previousSibling; 12467if(this_el.checked) { 12468input_el.disabled = true; 12469} else { 12470input_el.disabled = false; 12471input_el.focus(); 12472input_el.select(); 12473} 12474}, 12475colorClick: function(top_id, id, id_name, theme_name, property_name, color, this_el, count_color) { 12476count_color = (count_color == undefined || count_color == null) ? 0 : count_color; 12477var top_el = $(id); 12478if(!top_el) { 12479return; 12480} 12481if(this_el.tagName.toLowerCase() != "select" && (color != "transparent" && (Element.hasClassName(this_el,"highlight") || (color == null || color.length != 7 || color.indexOf('#') != 0)))) { 12482return; 12483} 12484this.colorclick_flag[top_id] = true; 12485var blockstyle_all_apply_el = $("blockstyle_all_apply" + top_id); 12486var append_class_name = ""; 12487if( this.change_color[top_id]) { 12488var old_change_color = this.change_color[top_id]; 12489} else { 12490var old_change_color = ""; 12491} 12492if(!blockstyle_all_apply_el || !blockstyle_all_apply_el.checked) { 12493append_class_name = ".blockstyle" + top_id + " "; 12494this.change_color[top_id] = "once"; 12495} else { 12496this.change_color[top_id] = "all"; 12497} 12498if(old_change_color != "" && this.change_color[top_id] != old_change_color) { 12499this.refresh_flag[top_id] = true; 12500} 12501var el = $(id_name); 12502var class_arr = el.className.split(" "); 12503var class_name = ""; 12504class_arr.each( 12505function(value){ 12506class_name += "." + value + " "; 12507} 12508); 12509class_name = append_class_name + class_name; 12510var style = null; 12511var styleList = document.getElementsByTagName("style"); 12512for (var i = 0; i < styleList.length; i++){ 12513if (styleList[i].title == "_blockstyle_custom_style" + theme_name){ 12514style = styleList[i]; 12515break; 12516} 12517} 12518if(!style) { 12519if(typeof document.createStyleSheet != 'undefined') { 12520var style=document.createStyleSheet(); 12521} else { 12522var style=document.createElement('STYLE'); 12523style.appendChild(document.createTextNode('')); 12524style.type="text/css"; 12525var oHEAD=document.getElementsByTagName('HEAD').item(0); 12526oHEAD.appendChild(style); 12527} 12528style.title = "_blockstyle_custom_style" + theme_name; 12529} 12530if(typeof style.addRule != 'undefined') { 12531style.addRule(class_name, property_name + ":" + color); 12532if(property_name == "backgroundColor" || property_name == "background-color") { 12533style.addRule(class_name, "background-image:none;"); 12534} 12535} else if(typeof style.styleSheet != 'undefined' && typeof style.styleSheet.addRule != 'undefined') { 12536style.styleSheet.addRule(class_name, property_name + ":" + color); 12537if(property_name == "backgroundColor" || property_name == "background-color") { 12538style.styleSheet.addRule(class_name, "background-image:none;"); 12539} 12540} else { 12541if(property_name == "background" && color == "") { 12542color = "none"; 12543} 12544if(typeof style.sheet.insertRule != 'undefined') { 12545style.sheet.insertRule(class_name + "{" + property_name + ":" + color + "}", style.sheet.cssRules.length); 12546if(property_name == "backgroundColor" || property_name == "background-color") { 12547style.sheet.insertRule(class_name + "{background-image:none;}", style.sheet.cssRules.length); 12548} 12549} else { 12550style.innerHTML = style.innerHTML + class_name + "{" + property_name + ":" + color + "}\n"; 12551if(property_name == "backgroundColor" || property_name == "background-color") { 12552style.innerHTML = style.innerHTML + class_name + "{background-image:none;}\n"; 12553} 12554} 12555} 12556if(browser.isGecko) { 12557if(property_name.match(/^border/)) {
12558var samplefields = Element.getElementsByClassName(document, class_arr[class_arr.length-1]); 12559samplefields.each(function(class_el) { 12560if(class_el.tagName == "TABLE" || class_el.tagName == "TR" || class_el.tagName == "TD") { 12561commonCls.displayChange(class_el); 12562setTimeout(function(){commonCls.displayChange(class_el);}.bind(this), 100); 12563} 12564}.bind(this)); 12565} 12566} 12567if(!this.color_params[theme_name]) { 12568this.color_params[theme_name] = new Object(); 12569this.color_params[theme_name]['color'] = new Object(); 12570} 12571if(!this.color_params[theme_name]['color'][el.className]) { 12572this.color_params[theme_name]['color'][el.className] = new Object(); 12573} 12574this.color_params[theme_name]['color'][el.className][property_name] = color; 12575var rgb = commonCls.getRGBtoHex(color); 12576var hsl = commonCls.getHSL(rgb.r,rgb.g,rgb.b); 12577var set_color_flag = false; 12578var inputList = top_el.getElementsByTagName("input"); 12579for (var i = 0; i < inputList.length; i++){ 12580if(inputList[i].disabled == true) { 12581var ref_class_name_el = inputList[i].previousSibling; 12582var ref_class_name = ref_class_name_el.value; 12583var same_flag = false; 12584if(ref_class_name.match(/^same:/)) { 12585same_flag = true; 12586ref_class_name = ref_class_name.replace(/^same:/, ""); 12587} 12588var ref_property_name_el = ref_class_name_el.previousSibling; 12589var current_el = Element.getChildElement(inputList[i].parentNode); 12590var current_property_name = current_el.value; 12591if(el.className == ref_class_name && 12592property_name == ref_property_name_el.value) { 12593var buf_count_color = count_color; 12594var change_flag = false; 12595if(buf_count_color) { 12596while(buf_count_color > 0) { 12597if(current_el) { 12598current_el = current_el.nextSibling; 12599buf_count_color--; 12600} else { 12601break; 12602} 12603} 12604if(current_el && Element.hasClassName(current_el,"_blocktheme_box")) { 12605current_el.onclick(); 12606change_flag = true; 12607} 12608} 12609if(!change_flag) { 12610if(same_flag) { 12611var set_color = color; 12612} else if(current_property_name == "background-color") { 12613var new_hsl_s = hsl.s;//+80; 12614var new_hsl_l = 240; 12615var new_rgb = commonCls.getRBG(hsl.h, new_hsl_s, new_hsl_l); 12616var set_color = commonCls.getHex(new_rgb.r,new_rgb.g,new_rgb.b); 12617} else { 12618var new_hsl_s = hsl.s; 12619var new_hsl_l = 124; 12620var new_rgb = commonCls.getRBG(hsl.h,new_hsl_s,new_hsl_l); 12621var set_color = commonCls.getHex(new_rgb.r,new_rgb.g,new_rgb.b); 12622} 12623inputList[i].value = set_color; 12624inputList[i].onchange(); 12625} 12626} 12627} 12628} 12629pagestyleCls.setHighlight(this_el); 12630}, 12631blockstyleSubmit: function(id, block_id, inside_flag, current_theme_name, confirm_mes, winclose_flag) { 12632this.confirm_mes = confirm_mes; 12633var winclose_flag = (winclose_flag == undefined || winclose_flag == null) ? true : winclose_flag; 12634var top_el = $(id); 12635if(!top_el) { 12636return; 12637} 12638var form = top_el.getElementsByTagName("form")[0]; 12639var param = "action=dialog_blockstyle_action_edit_init&block_id="+ block_id + "&"+ Form.serialize(form); 12640var current_queryParams = param.parseQuery(); 12641if(this.color_params[current_theme_name] && 12642this.color_params[current_theme_name]['color']) { 12643current_queryParams = Object.extend(current_queryParams, this.color_params[current_theme_name]); 12644} 12645if((current_queryParams['pre_block_name'] != current_queryParams['block_name'] || 12646current_queryParams['pre_theme_kind'] != current_queryParams['theme_kind'] || 12647current_queryParams['pre_template_kind'] != current_queryParams['template_kind'] || 12648current_queryParams['pre_minwidthsize'] != current_queryParams['minwidthsize'] || 12649current_queryParams['pre_topmargin'] != current_queryParams['topmargin'] || 12650current_queryParams['pre_rightmargin'] != current_queryParams['rightmargin'] || 12651current_queryParams['pre_bottommargin'] != current_queryParams['bottommargin'] || 12652current_queryParams['pre_leftmargin'] != current_queryParams['leftmargin']) || 12653current_queryParams['color']) { 12654var theme_params = new Object(); 12655var return_param = new Object(); 12656return_param['id'] = id; 12657return_param['winclose_flag'] = winclose_flag; 12658return_param['param'] = current_queryParams; 12659return_param['block_name'] = current_queryParams['block_name']; 12660return_param['pre_block_name'] = current_queryParams['pre_block_name']; 12661return_param['topmargin'] = current_queryParams['topmargin']; 12662return_param['rightmargin'] = current_queryParams['rightmargin']; 12663return_param['bottommargin'] = current_queryParams['bottommargin']; 12664return_param['leftmargin'] = current_queryParams['leftmargin']; 12665return_param['pre_theme_kind'] = current_queryParams['pre_theme_kind']; 12666return_param['pre_template_kind'] = current_queryParams['pre_template_kind']; 12667return_param['theme_kind'] = current_queryParams['theme_kind']; 12668return_param['template_kind'] = current_queryParams['template_kind']; 12669return_param['pre_minwidthsize'] = current_queryParams['pre_minwidthsize']; 12670return_param['minwidthsize'] = current_queryParams['minwidthsize']; 12671return_param['inside_flag'] = inside_flag; 12672theme_params["method"] = "post"; 12673theme_params["param"] = current_queryParams; 12674theme_params["top_el"] = top_el; 12675theme_params["loading_el"] = top_el; 12676theme_params["callbackfunc"] = function(return_param,res){this.themeChangeComplete(return_param,res);}.bind(this); 12677theme_params["callbackfunc_error"] = function(return_param,res){this.themeChangeComplete(return_param,res);}.bind(this); 12678theme_params["func_param"] = return_param; 12679theme_params["func_error_param"] = return_param; 12680commonCls.send(theme_params); 12681} else { 12682if(winclose_flag) { 12683form.cancel.onclick(); 12684} 12685} 12686}, 12687themeChangeComplete: function(return_param, res) { 12688var top_el = $(return_param['id']); 12689var parent_el = Element.getChildElementByClassName(top_el,"blockstyle_parent_id_n
12689ame"); 12690if(parent_el && parent_el.value) { 12691var parent_top_el = $(parent_el.value); 12692var parent_id = parent_el.value; 12693} else { 12694var parent_top_el = null; 12695} 12696var form = top_el.getElementsByTagName("form")[0]; 12697if(res == "") { 12698var queryParams = return_param['param'];//.parseQuery(); 12699if(parent_id) { 12700var url = commonCls.cutParamByUrl(commonCls.getUrl(parent_id)).parseQuery(); 12701url["active_tab"] = 1; 12702if(url['action'] == "pages_action_grouping") { 12703url['action'] = "pages_view_grouping"; 12704} 12705} 12706if(parent_top_el) { 12707if(parent_top_el.parentNode.tagName != "BODY") { 12708parent_top_el.parentNode.style.padding = return_param['topmargin'] + "px" + " " + return_param['rightmargin'] + "px" + " " + return_param['bottommargin'] + "px" + " " + return_param['leftmargin'] + "px"; 12709} 12710form.pre_block_name.value = return_param['block_name']; 12711form.pre_theme_kind.value = return_param['theme_kind']; 12712form.pre_template_kind.value = return_param['template_kind']; 12713form.pre_minwidthsize.value = return_param['minwidthsize']; 12714form.pre_topmargin.value = return_param['topmargin']; 12715form.pre_rightmargin.value = return_param['rightmargin']; 12716form.pre_bottommargin.value = return_param['bottommargin']; 12717form.pre_leftmargin.value = return_param['leftmargin']; 12718if(return_param['pre_block_name'] != return_param['block_name'] || 12719return_param['pre_theme_kind'] != return_param['theme_kind'] || 12720return_param['pre_template_kind'] != return_param['template_kind'] || 12721return_param['pre_minwidthsize'] != return_param['minwidthsize']) { 12722if(parent_top_el.parentNode.tagName == "BODY" || this.refresh_flag[return_param['id']] == true) { 12723location.reload(); 12724return false; 12725} else if(return_param['pre_template_kind'] != return_param['template_kind']) { 12726location.reload(); 12727return false; 12728} 12729if(return_param['inside_flag']) { 12730if(return_param['winclose_flag'] == true) { 12731form.cancel.onclick(); 12732} else { 12733commonCls.sendView(return_param['id'], url, null, true); 12734} 12735} else { 12736var win_params = new Object(); 12737win_params["method"] = "get"; 12738win_params["param"] = url; 12739win_params["loading_el"] = parent_top_el; 12740win_params["target_el"] = parent_top_el.parentNode; 12741win_params["callbackfunc"] = function(top_el){commonCls.moveVisibleHide(top_el);}.bind(this); 12742win_params["func_param"] = top_el; 12743commonCls.send(win_params); 12744if(return_param['winclose_flag'] == true) { 12745form.cancel.onclick(); 12746} 12747} 12748} else { 12749if(this.refresh_flag[return_param['id']] == true) { 12750location.reload(); 12751return true; 12752} 12753if(return_param['winclose_flag'] == true) { 12754form.cancel.onclick(); 12755} 12756} 12757} 12758}else { 12759if(res.match(":")) { 12760var mesArr = res.split(":"); 12761var alert_res = ""; 12762for(var i = 1; i < mesArr.length; i++) { 12763alert_res += mesArr[i]; 12764} 12765var elements = Form.getElements(form); 12766for (var i = 0; i < elements.length; i++) { 12767if (elements[i]) { 12768if(elements[i].name == mesArr[0]) { 12769try { 12770commonCls.alert(mesArr[1]); 12771elements[i].focus(); 12772if(elements[i].type == "text") 12773elements[i].select(); 12774} catch (e) {} 12775break; 12776} 12777} 12778} 12779} else { 12780commonCls.alert(res); 12781} 12782} 12783}, 12784themeClick: function(id, inside_flag, this_el, theme_name) { 12785var blocktheme_top = Element.getChildElementByClassName($(id), "_blocktheme_top"); 12786var themefields = Element.getElementsByClassName(blocktheme_top, "_blocktheme"); 12787var return_flag = false; 12788var highlight_flag = false; 12789themefields.each(function(field) { 12790if(Element.hasClassName(field,"highlight")) { 12791highlight_flag = true; 12792if(field == this_el) { 12793return_flag = true; 12794return; 12795} else { 12796Element.removeClassName(field,"highlight"); 12797} 12798} 12799}.bind(this)); 12800if(return_flag || (theme_name == "_auto" && highlight_flag == false)) { 12801return; 12802} 12803Element.addClassName(this_el,"highlight"); 12804var top_el = $(id); 12805if(!inside_flag) { 12806var parent_el = Element.getChildElementByClassName(top_el,"blockstyle_parent_id_name"); 12807if(parent_el && parent_el.value) { 12808var parent_top_el = $(parent_el.value); 12809var parent_id = parent_el.value; 12810} 12811} else { 12812var parent_id = id; 12813} 12814if(!$(parent_id)) { 12815return; 12816} 12817var url = commonCls.cutParamByUrl(commonCls.getUrl(parent_id)).parseQuery(); 12818if(url['action'] == "pages_action_grouping") { 12819url['action'] = "pages_view_grouping"; 12820} 12821url['blocktheme_name'] = theme_name; 12822url['active_tab'] = 0; 12823var send_params = new Object(); 12824send_params["callbackfunc"] = function(res){ 12825if(browser.isGecko) { 12826Element.addClassName(Element.getChildElement(send_params["target_el"]), "collapse_separate"); 12827setTimeout(function(){ 12828Element.removeClassName(Element.getChildElement(this), "collapse_separate"); 12829}.bind(send_params["target_el"]), 100); 12830} 12831}.bind(this); 12832if(!inside_flag) { 12833var popup_url = commonCls.cutParamByUrl(commonCls.getUrl(id)).parseQuery(); 12834if(popup_url['action'] == "pages_action_grouping") { 12835popup_url['action'] = "pages_view_grouping"; 12836} 12837popup_url['blocktheme_name'] = theme_name; 12838popup_url['active_tab'] = 0; 12839var top_el = $(id); 12840var theme_params = new Object(); 12841theme_params["method"] = "get"; 12842theme_params["param"] = popup_url; 12843theme_params["top_el"] = top_el; 12844theme_params["target_el"] = top_el.parentNode; 12845theme_params["loading_el"] = top_el; 12846theme_params["callbackfunc"] = function(){ 12847url['theme_name'] = theme_name; 12848commonCls.sendView(parent_id, url, send_params, true); 12849}.bind(this); 12850commonCls.send(theme_params); 12851} else { 12852commonCls.sendView(parent_id, url, send_params, true); 12853} 12854}, 12855defaultColorClick: function(id, theme_name) { 12856var top_el = $(id); 12857this.refresh_flag[id] = false;
12858var defultcolor_params = new Object(); 12859defultcolor_params["method"] = "post"; 12860defultcolor_params["param"] = {"action":"dialog_blockstyle_action_admin_setdefault","theme_name":theme_name}; 12861defultcolor_params["top_el"] = $(id); 12862defultcolor_params["callbackfunc"] = function(){ 12863var themefields = Element.getElementsByClassName($("_blockstyle_custom_top"+id), "_blocktheme_topbox"); 12864themefields.each(function(field) { 12865field.onclick(); 12866this.colorclick_flag[id] = false; 12867delete this.color_params; 12868this.color_params = new Object(); 12869this.color_params[theme_name] = new Object(); 12870this.color_params[theme_name]['color'] = new Object(); 12871var style = null; 12872var styleList = document.getElementsByTagName("style"); 12873for (var i = 0; i < styleList.length; i++){ 12874if (styleList[i].title == "_blockstyle_custom_style" + theme_name){ 12875style = styleList[i]; 12876if(style) { 12877Element.remove(style); 12878break; 12879} 12880} 12881} 12882}.bind(this)); 12883var links = document.getElementsByTagName("link"); 12884for (var i = 0,links_len = links.length; i < links_len; i++) { 12885var link_el = links[i]; 12886if(link_el.href.match("common_download_css")) { 12887var queryParams = link_el.href.parseQuery(); 12888var re_dir_name = new RegExp("(.*?)(common_download_css&dir_name=)(.*?)("+theme_name+")(.*)", "i"); 12889link_el.href = link_el.href.replace(re_dir_name,"$1$2$3$5"); 12890break; 12891} 12892} 12893}.bind(this); 12894commonCls.send(defultcolor_params); 12895}, 12896delStyleDef: function(theme_name) { 12897location.href = decodeURIComponent(_nc_current_url).replace("&","&"); 12898} 12899} 12900blockstyleCls = new clsBlockstyle(); 12901var clsPagestyle = Class.create(); 12902clsPagestyle.prototype = { 12903initialize: function() { 12904this.id = null; 12905this.top_el = null; 12906this.lang_down_arrow = null; 12907this.lang_right_arrow = null; 12908this.lang_cancel_confirm = null; 12909this.themefields = null; 12910this.theme_name = null; 12911this.header_flag = null; 12912this.leftcolumn_flag = null; 12913this.rightcolumn_flag = null; 12914this.header_el = null; 12915this.header_id_el = null; 12916this.leftcolumn_el = null; 12917this.centercolumn_el = null; 12918this.rightcolumn_el = null; 12919this.footer_el = null; 12920this.colorclick_flag = false; 12921this.chg_flag = false; 12922this.initColorFlag = false; 12923this.initStr = ""; 12924this.tabset = null; 12925}, 12926init: function(id, page_id, theme_name, header_flag, leftcolumn_flag, rightcolumn_flag, active_tab, change_flag, lang_cancel_confirm, lang_style, lang_theme, lang_layout, lang_coloration, lang_down_arrow, lang_right_arrow, pages_action, permalink_prohibition, permalink_prohibition_replace) { 12927this.id = id; 12928this.page_id = page_id; 12929this.theme_name = theme_name; 12930this.header_flag = header_flag; 12931this.leftcolumn_flag = leftcolumn_flag; 12932this.rightcolumn_flag = rightcolumn_flag; 12933this.pages_action = pages_action; 12934this.permalink_prohibition = permalink_prohibition; 12935this.permalink_prohibition_replace = permalink_prohibition_replace; 12936var top_el = $(id); 12937this.top_el = top_el; 12938this.header_id_el = $("__headercolumn"); 12939this.header_el = $("_headercolumn"); 12940if(this.header_el) { 12941this.header_add_module_el = Element.getChildElementByClassName(this.header_el, "headercolumn_addmodule"); 12942} 12943this.leftcolumn_el = $("_leftcolumn"); 12944this.centercolumn_el = $("_centercolumn"); 12945this.rightcolumn_el =$("_rightcolumn"); 12946this.footer_el = $("_footercolumn"); 12947tabset = new compTabset(top_el); 12948tabset.addTabset(lang_theme, null); 12949tabset.addTabset(lang_style,pagestyleCls.clkStyle.bind($(id))); 12950tabset.addTabset(lang_layout); 12951tabset.addTabset(lang_coloration, null, pagestyleCls.clkColor.bind(this)); 12952tabset.setActiveIndex(valueParseInt(active_tab)); 12953tabset.render(); 12954if(change_flag != "") { 12955this.chg_flag = true; 12956} else { 12957this.chg_flag = false; 12958} 12959this.tabset = tabset; 12960this.lang_cancel_confirm = lang_cancel_confirm; 12961this.lang_down_arrow = lang_down_arrow; 12962this.lang_right_arrow = lang_right_arrow; 12963}, 12964clkStyle: function() { 12965var top_el = this; 12966var form = top_el.getElementsByTagName("form")[0]; 12967commonCls.focus(form.page_name); 12968}, 12969clkColor: function() { 12970this.initColorFlag = true; 12971this.initStr = ""; 12972var coloration_el =$("_pagestyle_color"); 12973if(coloration_el != null) { 12974this.setHighlightColor(document.body, "_pagestyle_body","backgroundColor"); 12975this.setHighlightColor(this.header_el, "_pagestyle_headercolumn","backgroundColor"); 12976this.setHighlightColor(this.leftcolumn_el, "_pagestyle_leftcolumn","backgroundColor"); 12977this.setHighlightColor(this.centercolumn_el, "_pagestyle_centercolumn","backgroundColor"); 12978this.setHighlightColor(this.rightcolumn_el, "_pagestyle_rightcolumn","backgroundColor"); 12979this.setHighlightColor(this.footer_el, "_pagestyle_footercolumn","backgroundColor"); 12980this.setHighlightColor(this.header_el, "_pagestyle_headercolumn_border_top_color","borderTopColor"); 12981this.setHighlightColor(this.header_el, "_pagestyle_headercolumn_border_right_color","borderRightColor"); 12982this.setHighlightColor(this.header_el, "_pagestyle_headercolumn_border_bottom_color","borderBottomColor"); 12983this.setHighlightColor(this.header_el, "_pagestyle_headercolumn_border_left_color","borderLeftColor"); 12984this.setHighlightColor(this.leftcolumn_el, "_pagestyle_leftcolumn_border_top_color","borderTopColor"); 12985this.setHighlightColor(this.leftcolumn_el, "_pagestyle_leftcolumn_border_right_color","borderRightColor"); 12986this.setHighlightColor(this.leftcolumn_el, "_pagestyle_leftcolumn_border_bottom_color","borderBottomColor"); 12987this.setHighlightColor(this.leftcolumn_el, "_pagestyle_leftcolumn_border_left_color","borderLeftColor"); 12988this.setHighlightColor(this.centercolumn_el, "_pagestyle_centercolumn_border_top_color","borderTopColor"); 12989this.setHighlightColor(this.centercolumn_el, "_pagestyle_centercolumn_border_right_color","borderRightColor"); 12990this.setHighlightColor(this.centercolumn_el, "_pagestyle_centercolumn_border_bottom_color","borderBottomColor"); 12991this.setHighlightColor(this.centercolumn_el, "_pagestyle_centercolumn_border_left_color","borderLeftColor"); 12992this.setHighlightColor(this.rightcolumn_el, "_pagestyle_rightcolumn_border_top_color","borderTopColor"); 12993this.setHighlightColor(this.rightcolumn_el, "_pagestyle_rightcolumn_border_right_color","borderRightColor"); 12994this.setHighlightColor(this.rightcolumn_el, "_pagestyle_rightcolumn_border_bottom_color","borderBottomColor"); 12995this.setHighlightColor(this.rightcolumn_el, "_pagestyle_rightcolumn_border_left_color","borderLeftColor"); 12996this.setHighlightColor(this.footer_el, "_pagestyle_footercolumn_border_top_color","borderTopColor"); 12997this.setHighlightColor(this.footer_el, "_pagestyle_footercolumn_border_right_color","borderRightColor"); 12998this.setHighlightColor(this.footer_el, "_pagestyle_footercolumn_border_bottom_color","borderBottomColor"); 12999this.setHighlightColor(this.footer_el, "_pagestyle_footercolumn_border_left_color","borderLeftColor"); 13000} 13001this.initColorFlag = false;
13002if(this.initStr != "") { 13003var color_params = new Object(); 13004color_params["method"] = "post"; 13005color_params["param"] = "dialog_pagestyle_action_edit_change&page_id="+this.page_id+"&_pagestyle_flag=1"+this.initStr; 13006commonCls.send(color_params); 13007} 13008}, 13009setHighlightColor: function(el, child_class_name, property_name) { 13010if(el) { 13011var bgImageStyle = "none"; 13012if(property_name == "backgroundColor" || property_name == "background-color") { 13013bgImageStyle = Element.getStyle(el, "backgroundImage"); 13014} 13015var color = commonCls.getColorCode(el,property_name); 13016var column_el = $(child_class_name); 13017var count = 0; 13018for (var i = 0,column_len = column_el.childNodes.length; i < column_len; i++) { 13019var child_el = column_el.childNodes[i]; 13020if(child_el.nodeType == 1) { 13021if(child_el.tagName.toLowerCase() == "a" && child_el.title == color && bgImageStyle == "none") { 13022Element.addClassName(child_el, "highlight"); 13023child_el.onclick(); 13024break; 13025} else if(child_el.tagName.toLowerCase() == "select") { 13026if(bgImageStyle != "none") { 13027var selected_flag = false; 13028var select_el = child_el; 13029if(bgImageStyle.match("^url[(]{1}\"")) { 13030var repBgImageStyle = bgImageStyle.replace(_nc_base_url, "").replace("../", "").replace("url(\"", "").replace("\")", ""); 13031} else { 13032var repBgImageStyle = bgImageStyle.replace(_nc_base_url, "").replace("../", "").replace("url(", "").replace(")", ""); 13033} 13034for (var j = 0, option_len = select_el.childNodes.length; j < option_len; j++) { 13035var option_el = select_el.childNodes[j]; 13036if(option_el.value.match(repBgImageStyle)) { 13037option_el.selected = "selected"; 13038selected_flag = true; 13039select_el.onchange(); 13040break; 13041} 13042} 13043} 13044} else if(child_el.tagName.toLowerCase() == "input" && child_el.type != "hidden") { 13045if(color != "transparent") { 13046child_el.value = color; 13047child_el.onchange(); 13048} 13049} 13050count++; 13051} 13052} 13053} else { 13054commonCls.displayNone($(child_class_name)); 13055var sub_el = $(child_class_name + "_border"); 13056if(sub_el) { 13057commonCls.displayNone(sub_el); 13058} 13059} 13060}, 13061displayChange: function(this_el, el) { 13062var img_el = Element.getChildElement(this_el); 13063if(img_el.src.match("down_arrow.gif")) { 13064img_el.src = img_el.src.replace("down_arrow.gif","right_arrow.gif"); 13065img_el.alt = this.lang_right_arrow; 13066this_el.title = this.lang_right_arrow; 13067} else { 13068img_el.src = img_el.src.replace("right_arrow.gif","down_arrow.gif"); 13069img_el.alt = this.lang_down_arrow; 13070this_el.title = this.lang_down_arrow; 13071} 13072if(el == null || el == undefined) { 13073var next_el = this_el.nextSibling; 13074if(Element.hasClassName(next_el,"_blockstyle_custom_sample")) { 13075next_el = next_el.nextSibling; 13076} 13077commonCls.displayChange(next_el); 13078} else { 13079commonCls.displayChange($(el)); 13080} 13081}, 13082themeClick: function(this_el, theme_name) { 13083if(!this.themefields) { 13084var pagestyle_top = $("_pagestyle_top"); 13085this.themefields = Element.getElementsByClassName(pagestyle_top, "_pagestyle"); 13086} 13087var return_flag = false; 13088this.themefields.each(function(field) { 13089if(Element.hasClassName(field,"highlight")) { 13090if(field == this_el) { 13091return_flag = true; 13092return; 13093} else { 13094Element.removeClassName(field,"highlight"); 13095} 13096} 13097}.bind(this)); 13098if(return_flag) { 13099return; 13100} 13101Element.addClassName(this_el,"highlight"); 13102var all_apply = 0; 13103var defultcolor_params = new Object(); 13104defultcolor_params["method"] = "post"; 13105defultcolor_params["param"] = {"action":"dialog_pagestyle_action_edit_setdefault","page_id":this.page_id,"_pagestyle_flag":1,"all_apply":all_apply,"sesson_only":1}; 13106defultcolor_params["callbackfunc"] = function(){ 13107var theme_params = new Object(); 13108theme_params["method"] = "post"; 13109theme_params["param"] = {"action":"dialog_pagestyle_action_edit_change","page_id":this.page_id,"_pagestyle_flag":1,"theme_name": theme_name}; 13110theme_params["callbackfunc"] = function(){ 13111this.refresh(0); 13112}.bind(this); 13113commonCls.send(theme_params); 13114}.bind(this); 13115commonCls.send(defultcolor_params); 13116}, 13117colorClick: function(class_name, property_name, color, this_el) { 13118if(this_el.tagName.toLowerCase() != "select" && (color == "" || color =="1px solid " || this.colorclick_flag == true || (color.length == 7 && color.indexOf('#') != 0))) { 13119return; 13120} 13121if(property_name == "backgroundColor" && color == null) color = this_el.title; 13122else if(color == null && this_el.title == "transparent") color = "0px none"; 13123else if(color == null) color = "1px solid " + this_el.title; 13124if(typeof class_name == "string") {
13125var el = Element.getChildElementByClassName(document.body, class_name); 13126var send_name = class_name+"_"+property_name; 13127} else { 13128var el = class_name; 13129var send_name = "body"+"_"+property_name; 13130} 13131if(!this.initColorFlag) { 13132this.colorclick_flag = true; 13133if(property_name == "backgroundColor") { 13134el.style.background = "none" ; 13135} 13136if(property_name == "background" && color == "") { 13137color = "none"; 13138} 13139eval("el.style."+property_name + "=\"" + color+"\";"); 13140if(!(browser.isIE) && property_name.match("border")) { 13141$("_container").style.display = "none"; 13142} 13143var color_params = new Object(); 13144color_params["method"] = "post"; 13145color_params["param"] = "dialog_pagestyle_action_edit_change&page_id="+this.page_id+"&_pagestyle_flag=1&"+send_name+"="+encodeURIComponent(color); 13146color_params["callbackfunc"] = function(){ 13147this.colorclick_flag = false; 13148if(!(browser.isIE) && property_name.match("border") ) { 13149$("_container").style.display = "table"; 13150} 13151}.bind(this); 13152commonCls.send(color_params); 13153this.setHighlight(this_el); 13154this.chg_flag = true; 13155} else { 13156this.initStr += "&"+send_name+"="+encodeURIComponent(color); 13157} 13158}, 13159setHighlight: function(this_el) { 13160for (var i = 0; i < this_el.parentNode.childNodes.length; i++) { 13161var child_el = this_el.parentNode.childNodes[i]; 13162if(child_el.nodeType != 1) continue; 13163if(Element.hasClassName(child_el,"highlight")) { 13164Element.removeClassName(child_el,"highlight"); 13165} else if(this_el.tagName.toLowerCase() != "select" && child_el.tagName.toLowerCase() == "select") { 13166child_el.selectedIndex = 0; 13167} else if(this_el.tagName.toLowerCase() != "input" && child_el.tagName.toLowerCase() == "input" && child_el.type != "hidden") { 13168child_el.value = ""; 13169} 13170} 13171if(this_el.tagName.toLowerCase() != "input" && this_el.tagName.toLowerCase() != "select") { 13172Element.addClassName(this_el,"highlight"); 13173} 13174}, 13175defaultColorClick: function() { 13176var top_el = $(this.id); 13177var form = top_el.getElementsByTagName("form")[0]; 13178if(form.pagestyle_all_apply) { 13179if(form.pagestyle_all_apply.checked) { 13180var all_apply = 1; 13181} else { 13182var all_apply = 0; 13183} 13184} else { 13185var all_apply = 0; 13186} 13187var defultcolor_params = new Object(); 13188defultcolor_params["method"] = "post"; 13189defultcolor_params["param"] = {"action":"dialog_pagestyle_action_edit_setdefault","page_id":this.page_id,"_pagestyle_flag":1,"all_apply":all_apply}; 13190defultcolor_params["callbackfunc"] = function(){ 13191this.refresh(3); 13192}.bind(this); 13193commonCls.send(defultcolor_params); 13194}, 13195layoutClick: function(el , header_flag, leftcolum_flag, rightcolumn_flag) { 13196if(Element.hasClassName(el,"highlight")) { 13197return; 13198} 13199this.chg_flag = true; 13200var pagestyle_layout_el = Element.getParentElementByClassName(el, "_pagestyle_layout"); 13201var highlight_el = Element.getChildElementByClassName(pagestyle_layout_el, "highlight"); 13202Element.removeClassName(highlight_el,"highlight"); 13203Element.addClassName(el,"highlight"); 13204var refresh_flag = false; 13205if(header_flag) { 13206if(this.header_id_el) { 13207if(this.header_add_module_el) commonCls.displayVisible(this.header_add_module_el); 13208commonCls.displayVisible(this.header_id_el); 13209} else { 13210refresh_flag = true; 13211} 13212this.header_flag = 1; 13213} else { 13214if(this.header_add_module_el) commonCls.displayNone(this.header_add_module_el); 13215if(this.header_id_el) commonCls.displayNone(this.header_id_el); 13216this.header_flag = 0; 13217} 13218var colspan = 1; 13219if(leftcolum_flag) { 13220colspan++; 13221if(this.leftcolumn_el) { 13222commonCls.displayVisible(this.leftcolumn_el); 13223} else { 13224refresh_flag = true; 13225} 13226this.leftcolumn_flag = 1; 13227} else { 13228if(this.leftcolumn_el) commonCls.displayNone(this.leftcolumn_el); 13229this.leftcolumn_flag = 0; 13230} 13231if(rightcolumn_flag) { 13232colspan++; 13233if(this.rightcolumn_el) { 13234commonCls.displayVisible(this.rightcolumn_el); 13235} else { 13236refresh_flag = true; 13237} 13238this.rightcolumn_flag = 1; 13239} else { 13240if(this.rightcolumn_el) commonCls.displayNone(this.rightcolumn_el); 13241this.rightcolumn_flag = 0; 13242} 13243if(this.header_id_el) { 13244this.header_id_el.colspan = colspan; 13245} 13246if(this.footer_el) { 13247this.footer_el.colspan = colspan; 13248} 13249var layout_params = new Object(); 13250layout_params["method"] = "post"; 13251layout_params["param"] = {"action":"dialog_pagestyle_action_edit_change","_pagestyle_flag":1,"page_id":this.page_id,"header_flag": this.header_flag,"leftcolumn_flag": this.leftcolumn_flag,"rightcolumn_flag": this.rightcolumn_flag}; 13252layout_params["callbackfunc"] = function(){ 13253if(refresh_flag != "" || !(browser.isIE)) { 13254this.refresh(2); 13255} 13256}.bind(this); 13257commonCls.send(layout_params); 13258}, 13259refresh: function(active_tab, append_str) {
13260var top_el = $(this.id); 13261append_str = (append_str == undefined || append_str == null) ? "" : append_str; 13262var str = "&_layoutmode=off"; 13263if(active_tab != undefined && active_tab != null) { 13264str += "&active_tab="+active_tab; 13265} 13266location.href = _nc_base_url + _nc_index_file_name + "?action="+ this.pages_action+"&page_id="+this.page_id+ 13267"&_pagestyle_flag=1&pagestyle_x="+top_el.parentNode.style.left+"&pagestyle_y="+top_el.parentNode.style.top+ 13268str + append_str; 13269}, 13270chgGeneral: function(el) { 13271var top_el = $(this.id); 13272var form = top_el.getElementsByTagName("form")[0]; 13273var name = el.name; 13274var hidden_el = el.nextSibling; 13275if(hidden_el.value == el.value) { 13276return; 13277} 13278this.chg_flag = true; 13279var container_el = $("_container"); 13280if(name == "align") { 13281if(el.value == "center") { 13282form.leftmargin.value = "0"; 13283form.rightmargin.value = "0"; 13284container_el.style.marginRight = ""; 13285container_el.style.marginLeft = ""; 13286var buf_hidden_el = form.leftmargin.nextSibling; 13287buf_hidden_el.value = "0"; 13288var buf_hidden_el = form.rightmargin.nextSibling; 13289buf_hidden_el.value = "0"; 13290} 13291container_el.align = el.value; 13292container_el.style.textAlign = el.value; 13293} else if(name == "topmargin") { 13294container_el.style.marginTop = el.value + "px"; 13295} else if(name == "rightmargin") { 13296container_el.style.marginRight = el.value + "px"; 13297} else if(name == "bottommargin") { 13298container_el.style.marginBottom = el.value + "px"; 13299} else if(name == "leftmargin") { 13300container_el.style.marginLeft = el.value + "px"; 13301} 13302if((name == "leftmargin" || name == "rightmargin") && el.value != "0" && form.align.value == "center") { 13303form.align.value = "left"; 13304container_el.align = "left"; 13305container_el.style.textAlign = "left"; 13306var buf_hidden_el = form.align.nextSibling; 13307buf_hidden_el.value = "left"; 13308} 13309if(name == "page_name") { 13310var robj = new RegExp(this.permalink_prohibition, "ig"); 13311if(hidden_el.value.replace(robj, this.permalink_prohibition_replace) == form.permalink.value.replace(robj, this.permalink_prohibition_replace)) { 13312form.permalink.value = el.value.replace(robj, this.permalink_prohibition_replace); 13313} 13314} 13315hidden_el.value = el.value; 13316var general_params = new Object(); 13317general_params["method"] = "post"; 13318general_params["param"] = {"action":"dialog_pagestyle_action_edit_change","_pagestyle_flag":1,"page_id":this.page_id}; 13319general_params["param"][name] = el.value; 13320commonCls.send(general_params); 13321}, 13322okClick: function(id) { 13323var top_el = $(this.id); 13324var form = top_el.getElementsByTagName("form")[0]; 13325if(form.pagestyle_all_apply) { 13326if(form.pagestyle_all_apply.checked) { 13327var all_apply = 1; 13328} else { 13329var all_apply = 0; 13330} 13331} else { 13332var all_apply = 0; 13333} 13334if(this.chg_flag) { 13335setTimeout(function() { 13336var top_el = $(this.id); 13337var theme_params = new Object(); 13338if(typeof form.titletag != "undefined") { 13339var titletag = form.titletag.value; 13340} else { 13341var titletag = null; 13342} 13343if(typeof form.permalink != "undefined") { 13344var permalink = form.permalink.value; 13345} else { 13346var permalink = null; 13347} 13348theme_params["method"] = "post"; 13349theme_params["top_el"] = $(this.id); 13350theme_params["param"] = {"action":"dialog_pagestyle_action_edit_init","page_id":this.page_id,"page_name":form.page_name.value,"permalink":permalink,"titletag":titletag,"meta_description":form.meta_description.value,"meta_keywords":form.meta_keywords.value,"_pagestyle_flag":1,"all_apply":all_apply,"prefix_id_name":"dialog_pagestyle"}; 13351theme_params["callbackfunc"] = function(res){ 13352if(form.permalink_url) { 13353location.href = form.permalink_url.value + form.permalink.value + '/'; 13354} else { 13355location.href = _nc_base_url + _nc_index_file_name + "?action=" + this.pages_action + "&page_id="+this.page_id; 13356} 13357}.bind(this); 13358theme_params["callbackfunc_error"] = function(res){ 13359commonCls.alert(res); 13360this.tabset.setActiveIndex(1); 13361this.tabset.refresh(); 13362}.bind(this); 13363commonCls.send(theme_params); 13364}.bind(this),300); 13365} else { 13366commonCls.removeBlock(id); 13367} 13368}, 13369cancelClick: function(id) { 13370if(this.chg_flag) { 13371if(!commonCls.confirm(this.lang_cancel_confirm))return false; 13372location.href = _nc_base_url + _nc_index_file_name + "?action=pages_view_main&page_id="+this.page_id; 13373} else { 13374commonCls.removeBlock(id); 13375} 13376} 13377} 13378pagestyleCls = new clsPagestyle(); 13379var clsUserinf = Class.create(); 13380var userinfCls = Array(); 13381clsUserinf.prototype = { 13382initialize: function(id, user_id, prefix_id_name) { 13383this.id = id; 13384this.user_id = user_id; 13385this.prefix_id_name = prefix_id_name; 13386this.inEmailReception = new Object(); 13387this.inItems = new Object(); 13388this.inPublic = new Object(); 13389this.inUpdItems = new Object(); 13390}, 13391init:function() {
13392var top_el = $(this.id); 13393var focus_el = Element.getChildElementByClassName(top_el,"userinf_edit_item_label"); 13394commonCls.focus(focus_el); 13395}, 13396clkLabel: function(this_el) { 13397var edit_el = this_el.nextSibling; 13398var a_el = Element.getChildElement(edit_el); 13399if(a_el && a_el.tagName.toLowerCase() == "a") { 13400a_el.onclick(); 13401} 13402}, 13403clkItems: function(this_el, item_id, type) { 13404var edit_el = this_el.nextSibling; 13405commonCls.displayNone(this_el); 13406commonCls.displayVisible(edit_el); 13407switch (type) { 13408case "text": 13409case "textarea": 13410case "email": 13411case "mobile_email": 13412var input_el = Element.getChildElement(edit_el); 13413input_el.focus(); 13414input_el.select(); 13415break; 13416case "file": 13417var input_el = Element.getChildElement(edit_el, 2); 13418input_el.focus(); 13419input_el.select(); 13420break; 13421case "password": 13422var input_el = edit_el.getElementsByTagName("input")[0]; 13423input_el.focus(); 13424input_el.select(); 13425break; 13426case "select": 13427case "radio": 13428case "checkbox": 13429var form_el = edit_el.getElementsByTagName("form")[0]; 13430if(type == "select") { 13431var input_els = Form.getElements(form_el); 13432} else { 13433var input_els = Form.getInputs(form_el, type); 13434} 13435input_els[0].focus(); 13436break; 13437} 13438}, 13439focusReception: function(item_id, focus_flag) { 13440this.inEmailReception[item_id] = focus_flag; 13441}, 13442focusPublic: function(item_id, focus_flag) { 13443this.inPublic[item_id] = focus_flag; 13444}, 13445focusItem: function(item_id, focus_flag) { 13446this.inItems[item_id] = focus_flag; 13447}, 13448updItems: function(event_type, this_el, item_id, type, focus_flag) { 13449var input_type = this_el.type; 13450var reception_el = $("userinf_items_reception" + this.id + "_" + item_id); 13451var public_el = $("userinf_items_public" + this.id + "_" + item_id); 13452if(input_type == "text" && event_type == "keypress") { 13453this_el.blur(); 13454} 13455if((reception_el && !Element.hasClassName(reception_el.parentNode,"display-none")) || 13456(public_el && !Element.hasClassName(public_el.parentNode,"display-none"))) { 13457if(focus_flag == undefined) { 13458setTimeout(function(){this.updItems(event_type, this_el, item_id, type, true)}.bindAsEventListener(this), 500); 13459return; 13460} else { 13461if(this.inItems[item_id] === true || this.inEmailReception[item_id] === true || this.inPublic[item_id] === true) { 13462setTimeout(function(){this.updItems(event_type, this_el, item_id, type, true)}.bindAsEventListener(this), 500); 13463return; 13464} 13465} 13466} else if(type == "radio" && event_type == "blur" && focus_flag == undefined) { 13467return; 13468} 13469var top_el = $(this.id); 13470if(top_el == null) return; 13471var edit_el = Element.getParentElementByClassName(this_el,"userinf_edit_item"); 13472var label_el = edit_el.previousSibling; 13473var select_flag = false; 13474var upd_params = new Object(); 13475if(type != "file") { 13476upd_params['action'] = "userinf_action_main_init"; 13477} else { 13478upd_params['action'] = "userinf_action_main_upload_image"; 13479} 13480upd_params['item_id'] = item_id; 13481upd_params['user_id'] = this.user_id; 13482if(this.inUpdItems[upd_params['item_id']] == true) { 13483return; 13484} 13485this.inUpdItems[upd_params['item_id']] = true; 13486switch (type) { 13487case "text": 13488case "email": 13489case "mobile_email": 13490upd_params['content'] = this_el.value; 13491if(reception_el) { 13492upd_params['email_reception_flag'] = (reception_el.checked) ? 1 : 0; 13493} else { 13494if(type == "text") { 13495upd_params['email_reception_flag'] = 0; 13496} else { 13497upd_params['email_reception_flag'] = 1; 13498} 13499} 13500select_flag = true; 13501break; 13502case "textarea": 13503var textarea_el = $("userinf_items" + this.id + "_" + upd_params['item_id']); 13504upd_params['content'] = textarea_el.value; 13505this_el = textarea_el; 13506select_flag = true; 13507break; 13508case "password": 13509var current_el = $("userinf_items_current" + this.id + "_" + upd_params['item_id']); 13510var new_el = $("userinf_items_new" + this.id + "_" + upd_params['item_id']); 13511var comfirm_el = $("userinf_items_confirm" + this.id + "_" + upd_params['item_id']); 13512upd_params['content'] = new_el.value; 13513if(comfirm_el) upd_params['confirm_content'] = comfirm_el.value; 13514if(current_el) { 13515upd_params['current_content'] = current_el.value; 13516this_el = current_el; 13517} else { 13518this_el = new_el; 13519} 13520select_flag = true; 13521break; 13522case "file": 13523upd_params['unique_id'] = this.user_id; 13524break; 13525case "select": 13526case "radio": 13527case "checkbox": 13528var form_el = $("userinf_form" + this.id + "_" + item_id); 13529if(type == "select") { 13530var input_els = Form.getElements(form_el); 13531} else { 13532var input_els = Form.getInputs(form_el, type); 13533} 13534var value_lang = ""; 13535upd_params['content'] = ""; 13536for (var i = 0, length = input_els.length; i < length; i++) { 13537if(i == 0) { 13538this_el = input_els[i]; 13539} 13540var value = Form.Element.getValue(input_els[i]); 13541if(type == "select") { 13542var checked_flag = true; 13543} else { 13544var checked_flag = input_els[i].checked; 13545} 13546if(value != null && checked_flag) { 13547var value_arr = value.split("|"); 13548if(value_arr[1]) { 13549upd_params['content'] += value_arr[0] + "|"; 13550value_lang += value_arr[1] + "|"; 13551} else { 13552upd_params['content'] += value + "|"; 13553} 13554} 13555} 13556break; 13557} 13558if(public_el) { 13559upd_params['public_flag'] = (public_el.checked) ? 1 : 0; 13560} else { 13561upd_params['public_flag'] = 1; 13562} 13563upd_params['prefix_id_name'] = this.prefix_id_name; 13564var send_param = new Object(); 13565send_param["method"] = "post"; 13566send_param["param"] = upd_params; 13567send_param["top_el"] = top_el; 13568send_param["callbackfunc"] = function(file_list, res){ 13569if(type == "text" || type == "email" || type == "mobile_email" || type == "textarea" || 13570type == "select" || type == "radio" || type == "checkbox") { 13571upd_params['content'] = upd_params['content'].escapeHTML(); 13572} 13573if(upd_params['content'] == "") upd_params['content'] = " "; 13574switch (type) { 13575case "text": 13576case "email": 13577case "mobile_email": 13578label_el.innerHTML = upd_params['content']; 13579break; 13580case "textarea": 13581var re_cut = new RegExp("\n", "g"); 13582label_el.innerHTML = upd_params['content'].replace(re_cut, "<br />"); 13583break; 13584case "password": 13585if(current_el) current_el.value = upd_params['content']; 13586if(comfirm_el) comfirm_el.value = ""; 13587new_el.value = ""; 13588break; 13589case "file": 13590var url = "?action="+ file_list[0]['action_name'] + "&upload_id=" + file_list[0]['upload_id']; 13591var img_el = Element.getChildElement(label_el); 13592img_el.src = url; 13593commonCls.displayVisible(img_el); 13594break; 13595case "select": 13596case "radio": 13597case "checkbox": 13598var re_sep = new RegExp("\\|", "g"); 13599if(value_lang != "") { 13600var content_str = value_lang.replace(re_sep,",").substr(0,value_lang.length - 1); 13601} else { 13602var content_str = upd_params['content'].replace(re_sep,",").substr(0,upd_params['content'].length - 1); 13603} 13604label_el.innerHTML =content_str; 13605break; 13606} 13607commonCls.displayNone(edit_el); 13608commonCls.displayVisible(label_el); 13609if(input_type == "radio" || input_type == "select-one" 13610|| input_type == "button") { 13611label_el.focus(); 13612} 13613this.inUpdItems[upd_params['item_id']] = false;
13614}.bind(this); 13615if(type == "file") { 13616send_param["param"]['unique_id'] = this.user_id; 13617send_param['form_prefix'] = "userinf_attachment_"+ upd_params['item_id']; 13618send_param["callbackfunc_error"] = function(file_list, res){ 13619commonCls.alert(res); 13620this_el.focus(); 13621if(select_flag) this_el.select(); 13622this.inUpdItems[upd_params['item_id']] = false; 13623}.bind(this); 13624commonCls.sendAttachment(send_param); 13625} else { 13626send_param["callbackfunc_error"] = function(res){ 13627commonCls.alert(res); 13628this_el.focus(); 13629if(select_flag) this_el.select(); 13630this.inUpdItems[upd_params['item_id']] = false; 13631}.bind(this); 13632commonCls.send(send_param); 13633} 13634}, 13635cancelItems: function(event, this_el, type) { 13636var edit_el = Element.getParentElementByClassName(this_el,"userinf_edit_item"); 13637var label_el = edit_el.previousSibling; 13638commonCls.displayNone(edit_el); 13639commonCls.displayVisible(label_el); 13640label_el.focus(); 13641}, 13642delImage: function(event, this_el, type) { 13643var edit_el = Element.getParentElementByClassName(this_el,"userinf_edit_item"); 13644var label_el = edit_el.previousSibling; 13645var img_el = Element.getChildElement(label_el); 13646Element.addClassName(img_el, "display-none"); 13647img_el.src = ""; 13648commonCls.displayNone(edit_el); 13649commonCls.displayVisible(label_el); 13650label_el.focus(); 13651}, 13652initRoom: function(count, visible_rows) { 13653var opts = null; 13654new compLiveGrid (this.id, visible_rows, count, null, opts); 13655}, 13656initMonthly: function() { 13657var offset = 400; 13658var monthlynumber_list_el = $("monthlynumber_list" + this.id); 13659var height = monthlynumber_list_el.offsetHeight; 13660if(height >= offset) { 13661Element.setStyle(monthlynumber_list_el, {overflow:"auto"}); 13662Element.setStyle(monthlynumber_list_el, {height:offset+"px"}); 13663if(!browser.isIE) { 13664Element.setStyle(monthlynumber_list_el, {width:monthlynumber_list_el.offsetWidth+"px"}); 13665} 13666var parent_el = monthlynumber_list_el.parentNode; 13667if(browser.isIE) { 13668Element.setStyle(parent_el, {"padding-right":"20px"}); 13669} 13670} 13671}, 13672initModulesinfo: function() { 13673var top_el = $(this.id); 13674var tabset = new compTabset(top_el); 13675tabset.render(); 13676}, 13677withdrawAccept: function(this_el) { 13678var next_btn_el = $("userinf_next" + this.id); 13679if(this_el.checked) { 13680next_btn_el.disabled = false; 13681} else { 13682next_btn_el.disabled = true; 13683} 13684} 13685} 13686var clsJournal = Class.create(); 13687var journalCls = Array(); 13688clsJournal.prototype = { 13689initialize: function(id) { 13690this.id = id; 13691this.currentJournalId = null; 13692this.textarea = null; 13693this.textarea_more = null; 13694this.pager = null; 13695this.category_id =null; 13696this.visible_item = null; 13697this.inItems = new Object(); 13698this.inUpdItems = new Object(); 13699this.popupLnk = null; 13700this.dndCustomDrag = null; 13701this.dndCustomDropzone = null; 13702this.dndMgrCatObj = null; 13703this.titleIcon = null; 13704}, 13705initCategory: function() { 13706this.dndCustomDrag = Class.create(); 13707this.dndCustomDrag.prototype = Object.extend((new compDraggable), { 13708prestartDrag: function() { 13709var htmlElement = this.getHTMLElement(); 13710this._displayChg(htmlElement); 13711}, 13712cancelDrag: function() { 13713var draggable = this.htmlElement; 13714Element.setStyle(draggable, {opacity:""}); 13715this._displayChg(draggable, 1); 13716}, 13717_displayChg: function(htmlElement, cancel_flag) { 13718if(Element.hasClassName(htmlElement, "_journal_cat" + this.id)) { 13719var paramObj= this.getParams(); 13720var el= paramObj['top_el']; 13721var cat_fields = Element.getElementsByClassName(el, "_journal_cat" + this.id); 13722cat_fields.each(function(cat_el) { 13723commonCls.displayChange(cat_el); 13724}.bind(this)); 13725if(cancel_flag) { 13726var top_row_el = Element.getChildElementByClassName(htmlElement, "_journal_cat" + this.id); 13727commonCls.displayVisible(top_row_el); 13728} 13729} 13730} 13731}); 13732this.dndCustomDropzone = Class.create(); 13733this.dndCustomDropzone.prototype = Object.extend((new compDropzone), { 13734showHover: function(event) { 13735var htmlElement = this.getHTMLElement(); 13736if ( this._showHover(htmlElement) ) 13737return; 13738if(this.getParams() && !Element.hasClassName(htmlElement, "_journal_cat_top")) { 13739this.showChgSeqHoverInside(event); 13740} else { 13741this.showChgSeqHover(event); 13742} 13743}, 13744hideHover: function(event) { 13745this.hideChgSeqHover(event); 13746}, 13747accept: function(draggableObjects) { 13748this.acceptChgSeq(draggableObjects); 13749var drag_el = draggableObjects[0].getHTMLElement(); 13750commonCls.blockNotice(null, drag_el); 13751}, 13752save: function(draggableObjects) { 13753if(this.ChgSeqPosition == null) { 13754return false;
13755} 13756var htmlElement = this.getHTMLElement(); 13757var paramObj= draggableObjects[0].getParams(); 13758var id= paramObj['id']; 13759var drag_el = draggableObjects[0].getHTMLElement(); 13760var chgseq_params = new Object(); 13761var top_el = $(id); 13762if (Element.hasClassName(drag_el, "_journal_cat_top")) { 13763var category_id = drag_el.id.replace("_journal_cat"+ id + "_category_id_",""); 13764var drop_category_id = htmlElement.id.replace("_journal_cat"+ id + "_category_id_",""); 13765chgseq_params["param"] = {"action":"journal_action_edit_categoryseq", "category_id":category_id, 13766"drop_category_id":drop_category_id, 13767"position":this.ChgSeqPosition}; 13768} 13769chgseq_params["method"] = "post"; 13770chgseq_params["top_el"] = top_el; 13771chgseq_params["loading_el"] = drag_el; 13772commonCls.send(chgseq_params); 13773return true; 13774} 13775}); 13776var edit_top_el = $("_journal_cat"+ this.id); 13777this.dndMgrCatObj = new compDragAndDrop(); 13778this.dndMgrCatObj.registerDraggableRange(edit_top_el); 13779this.dndMgrLinkObj = new compDragAndDrop(); 13780this.dndMgrLinkObj.registerDraggableRange(edit_top_el); 13781var cat_rowfields = Element.getElementsByClassName(edit_top_el, "_journal_cat_chg_seq"); 13782cat_rowfields.each(function(row_el) { 13783var top_row_el = Element.getParentElementByClassName(row_el,"_journal_cat_top"); 13784this.dndMgrLinkObj.registerDraggable(new this.dndCustomDrag(top_row_el, row_el, {"top_el":edit_top_el,"id":this.id})); 13785this.dndMgrLinkObj.registerDropZone(new this.dndCustomDropzone(top_row_el)); 13786}.bind(this)); 13787}, 13788checkCurrent: function() { 13789var currentRow = $("journal_current_row" + this.currentJournalId + this.id); 13790if (!currentRow) { 13791return; 13792} 13793Element.addClassName(currentRow, "highlight"); 13794var current = $("journal_current" + this.currentJournalId + this.id); 13795current.checked = true; 13796}, 13797changeCurrent: function(journal_id) { 13798var oldCurrentRow = $("journal_current_row" + this.currentJournalId + this.id); 13799if (oldCurrentRow) { 13800Element.removeClassName(oldCurrentRow, "highlight"); 13801} 13802this.currentJournalId = journal_id; 13803var currentRow = $("journal_current_row" + this.currentJournalId + this.id); 13804Element.addClassName(currentRow, "highlight"); 13805var post = { 13806"action":"journal_action_edit_change", 13807"journal_id":journal_id 13808}; 13809var params = new Object(); 13810params["callbackfunc_error"] = function(res){ 13811commonCls.alert(res); 13812commonCls.sendView(this.id, "journal_view_edit_list"); 13813}.bind(this); 13814commonCls.sendPost(this.id, post, params); 13815}, 13816changeActivity: function(element, journal_id, activity) { 13817var elements = element.parentNode.childNodes; 13818for (var i = 0, length = elements.length; i < length; i++) { 13819if (elements[i] == element) { 13820Element.addClassName(elements[i], "display-none"); 13821} else { 13822Element.removeClassName(elements[i], "display-none"); 13823} 13824} 13825var post = { 13826"action":"journal_action_edit_activity", 13827"journal_id":journal_id, 13828"active_flag":activity 13829}; 13830var params = new Object(); 13831params["callbackfunc_error"] = function(res){ 13832commonCls.alert(res); 13833commonCls.sendView(this.id, "journal_view_edit_list"); 13834}.bind(this); 13835commonCls.sendPost(this.id, post, params); 13836}, 13837editCancel: function() { 13838commonCls.sendView(this.id,"journal_view_main_init"); 13839}, 13840referenceJournal: function(event, journal_id) { 13841var params = new Object(); 13842params["action"] = "journal_view_main_init"; 13843params["journal_id"] = journal_id; 13844params["prefix_id_name"] = "popup_journal_reference" + journal_id; 13845var popupParams = new Object(); 13846var top_el = $(this.id); 13847popupParams['top_el'] = top_el; 13848popupParams['target_el'] = top_el; 13849popupParams['center_flag'] = true; 13850commonCls.sendPopupView(event, params, popupParams); 13851}, 13852delJournal: function(journal_id, confirmMessage) { 13853if (!commonCls.confirm(confirmMessage)) { 13854return false; 13855} 13856var params = new Object(); 13857params["target_el"] = $(this.id); 13858params["callbackfunc_error"] = function(res){ 13859commonCls.sendView(this.id, "journal_view_edit_list"); 13860}.bind(this); 13861commonCls.sendPost(this.id, "action=journal_action_edit_delete&journal_id=" + journal_id, params); 13862}, 13863insJournal: function(form_el) { 13864commonCls.sendPost(this.id, "action=journal_action_edit_create&" + Form.serialize(form_el), {"target_el":$(this.id)}); 13865}, 13866styleEdit: function(form_el) { 13867commonCls.sendPost(this.id, "action=journal_action_edit_style&" + Form.serialize(form_el), {"target_el":$(this.id
13867)}); 13868}, 13869postInit: function() { 13870this.textarea = new compTextarea(); 13871this.textarea.uploadAction = { 13872image : "journal_action_upload_image", 13873file : "journal_action_upload_init" 13874}; 13875this.textarea.textareaShow(this.id, "textarea"+this.id, "full"); 13876new compCalendar(this.id, "journal_date" + this.id); 13877}, 13878moreInit: function() { 13879if(this.textarea_more == null) { 13880this.textarea_more = new compTextarea(); 13881this.textarea_more.uploadAction = { 13882image : "journal_action_upload_image", 13883file : "journal_action_upload_init" 13884}; 13885} 13886this.textarea_more.textareaShow(this.id, "textarea_more"+this.id, "full"); 13887}, 13888showIcon: function() { 13889this.titleIcon = new compTitleIcon(this.id); 13890this.titleIcon.showDialogBox($("journal_icon_name_img" + this.id), $("journal_icon_name_hidden" + this.id)); 13891this.titleIcon == null; 13892}, 13893post: function(form_el, temp_flag) { 13894var top_el = $(this.id); 13895var journal_id = form_el.journal_id.value; 13896var journal_date = form_el.journal_date.value; 13897var journal_hour = form_el.journal_hour.value; 13898var journal_minute = form_el.journal_minute.value; 13899var icon_name = form_el.icon_name.value; 13900var title = form_el.title.value; 13901var category_id = form_el.category_id.value; 13902var content = this.textarea.getTextArea(); 13903var more_checked = 0; 13904if(form_el.more_checkbox.checked) { 13905more_checked = 1; 13906} 13907var more_title = null; 13908var more_content = null; 13909var hide_more_title = null; 13910if(this.textarea_more != null) { 13911more_title = form_el.more_title.value; 13912more_content = this.textarea_more.getTextArea(); 13913hide_more_title = form_el.hide_more_title.value; 13914} 13915var edit_flag = form_el.edit_flag.value; 13916var post_id = form_el.post_id.value; 13917var tb_url = ""; 13918if(form_el.tb_url) { 13919tb_url = form_el.tb_url.value; 13920} 13921var ins_params = new Object(); 13922ins_params["method"] = "post"; 13923ins_params["param"] = { 13924"action":"journal_action_main_post", 13925"journal_id":journal_id, 13926"journal_date":journal_date, 13927"journal_hour":journal_hour, 13928"journal_minute":journal_minute, 13929"icon_name":icon_name, 13930"title":title, 13931"category_id":category_id, 13932"content":content, 13933"more_checked":more_checked, 13934"more_title":more_title, 13935"more_content":more_content, 13936"hide_more_title":hide_more_title, 13937"edit_flag":edit_flag, 13938"post_id":post_id, 13939"temp_flag":temp_flag, 13940"tb_url":tb_url 13941}; 13942ins_params["top_el"] = top_el; 13943ins_params["loading_el"] = top_el; 13944ins_params["target_el"] = top_el; 13945ins_params["callbackfunc"] = function(){ 13946commonCls.sendPost(this.id, {"action":"journal_action_main_mail"}, {"loading_el":null}); 13947commonCls.sendPost(this.id, {"action":"journal_action_main_confirmmail"}); 13948}.bind(this); 13949ins_params["callbackfunc_error"] = function(res){ 13950commonCls.alert(res); 13951}.bind(this); 13952commonCls.send(ins_params); 13953}, 13954checkMore: function(check_el, confirmMessage) { 13955if(check_el.checked == true) { 13956commonCls.displayChange($('journal_more_content' + this.id)); 13957this.moreInit(); 13958}else { 13959if (!commonCls.confirm(confirmMessage)) { 13960check_el.checked = true; 13961return false; 13962} 13963commonCls.displayChange($('journal_more_content' + this.id)); 13964} 13965}, 13966postComment: function(form_el) { 13967var params = new Object(); 13968params["target_el"] = $(this.id); 13969params["callbackfunc"] = function(res){ 13970commonCls.sendPost(this.id, {"action":"journal_action_main_mail"}, {"loading_el":null}); 13971commonCls.sendPost(this.id, {"action":"journal_action_main_confirmmail"}); 13972}.bind(this); 13973commonCls.sendPost(this.id, "action=journal_action_main_comment&" + Form.serialize(form_el), params); 13974}, 13975postConfirm: function(el, post_id, confirmMessage) { 13976if (!commonCls.confirm(confirmMessage)) { 13977return false; 13978} 13979var params = new Object(); 13980params["loading_el"] = el; 13981params["target_el"] = $(this.id); 13982params["callbackfunc"] = function(res){ 13983commonCls.sendPost(this.id, {"action":"journal_action_main_mail"}, {"loading_el":null}); 13984commonCls.sendPost(this.id, {"action":"journal_action_main_confirmmail"}); 13985}.bind(this); 13986commonCls.sendPost(this.id, "action=journal_action_main_confirm&post_id=" + post_id, params); 13987}, 13988toPage: function(el, journal_id, cat_classname, num_classname, now_page, position) { 13989var cat_name = null; 13990var num_name = null; 13991if(position == "bottom") { 13992cat_name = cat_classname + "_bottom"; 13993num_name = num_classname + "_bottom"; 13994}else { 13995cat_name = cat_classname; 13996num_name = num_classname; 13997} 13998var cat = $(cat_name); 13999var visible_item = $(num_name); 14000var catlist = document.getElementsByClassName(cat_classname); 14001var cats = $A(catlist); 14002cats.each(function(c){ 14003c.selectedIndex = cat.selectedIndex; 14004}); 14005var numlist = document.getElementsByClassName(num_classname); 14006var nums = $A(numlist); 14007nums.each(function(n){ 14008n.selectedIndex = visible_item.selectedIndex; 14009}); 14010var cat_id = cat.options[cat.selectedIndex].value; 14011var num = visible_item.options[visible_item.selectedIndex].value;
14012var journal_id = $("journal_id"+this.id).value; 14013var top_el = $(this.id); 14014var params = new Object(); 14015params["param"] = { 14016"action":"journal_view_main_init", 14017"journal_id":journal_id, 14018"category_id":cat_id, 14019"visible_item":num, 14020"now_page":now_page 14021}; 14022params["top_el"] = top_el; 14023params["loading_el"] = el; 14024params["target_el"] = top_el; 14025commonCls.send(params); 14026}, 14027deleteComment: function(el, comment_id, post_id, confirmMessage) { 14028if (!commonCls.confirm(confirmMessage)) { 14029return false; 14030} 14031var params = new Object(); 14032params["target_el"] = $(this.id); 14033params["loading_el"] = el; 14034params["callbackfunc"] = function(res){ 14035commonCls.displayVisible($('journal_comment' + this.id)); 14036}.bind(this); 14037commonCls.sendPost(this.id, "action=journal_action_main_delete&post_id=" + post_id + "&comment_id=" + comment_id, params); 14038}, 14039deleteTrackback: function(el, trackback_id, post_id, confirmMessage) { 14040if (!commonCls.confirm(confirmMessage)) { 14041return false; 14042} 14043var params = new Object(); 14044params["target_el"] = $(this.id); 14045params["loading_el"] = el; 14046params["callbackfunc"] = function(res){ 14047commonCls.displayVisible($('journal_trackback' + this.id)); 14048}.bind(this); 14049commonCls.sendPost(this.id, "action=journal_action_main_deltrackback&post_id=" + post_id + "&trackback_id=" + trackback_id, params); 14050}, 14051editComment: function(comment_id, post_id) { 14052var div_content = $("journal_comment_content_" + comment_id + this.id); 14053var textbox = $("journal_comment_textarea" + this.id); 14054textbox.value = div_content.innerHTML.replace(/\n/ig,"").replace(/(<br(?:.|\s|\/)*?>)/ig,"\n").unescapeHTML(); 14055var hidden_flag = $("comment_post_id" + this.id); 14056hidden_flag.value = comment_id; 14057textbox.focus(); 14058textbox.select(); 14059}, 14060deletePost: function(el, post_id, confirmMessage) { 14061if (!commonCls.confirm(confirmMessage)) { 14062return false; 14063} 14064var params = new Object(); 14065params["target_el"] = $(this.id); 14066params["loading_el"] = el; 14067commonCls.sendPost(this.id, "action=journal_action_main_delete&post_id=" + post_id, params); 14068}, 14069vote: function(el, post_id) { 14070var params = new Object(); 14071params["top_el"] = $(this.id); 14072params["loading_el"] = el; 14073params["callbackfunc"] = function(res){ 14074commonCls.sendRefresh(this.id); 14075}.bind(this); 14076params["callbackfunc_error"] = function(res){ 14077commonCls.sendView(this.id, "journal_view_main_init"); 14078}.bind(this); 14079commonCls.sendPost(this.id, "action=journal_action_main_vote&post_id=" + post_id, params); 14080}, 14081focusItem: function(item_id, focus_flag) { 14082this.inItems[item_id] = focus_flag; 14083}, 14084updItems: function(event, this_el, category_id) { 14085var top_el = $(this.id); 14086var edit_el = Element.getParentElementByClassName(this_el,"journal_cat_edit_item"); 14087var label_el = edit_el.previousSibling; 14088var upd_params = new Object(); 14089upd_params['action'] = "journal_action_edit_category"; 14090upd_params['category_id'] = category_id; 14091upd_params['category_name'] = this_el.value; 14092if(this.inUpdItems[upd_params['category_id']] == true) { 14093return; 14094} 14095this.inUpdItems[upd_params['category_id']] = true; 14096var send_param = new Object(); 14097send_param["method"] = "post"; 14098send_param["param"] = upd_params; 14099send_param["top_el"] = top_el; 14100send_param["callbackfunc"] = function(res){ 14101commonCls.displayNone(edit_el); 14102commonCls.displayVisible(label_el); 14103label_el.innerHTML = upd_params['category_name'].escapeHTML(); 14104if(Event.element(event).type == "radio" || Event.element(event).type == "select-one" 14105|| Event.element(event).type == "button" || event.keyCode == 13) { 14106label_el.focus(); 14107} 14108this.inUpdItems[upd_params['category_id']] = false; 14109}.bind(this); 14110send_param["callbackfunc_error"] = function(res){ 14111commonCls.alert(res); 14112this_el.focus(); 14113this.inUpdItems[upd_params['category_id']] = false; 14114}.bind(this); 14115commonCls.send(send_param); 14116}, 14117clkItems: function(this_el) { 14118var edit_el = this_el.nextSibling; 14119commonCls.displayNone(this_el); 14120commonCls.displayVisible(edit_el); 14121var input_el = Element.getChildElement(edit_el); 14122input_el.focus(); 14123input_el.select(); 14124}, 14125delCategory: function(journal_id, category_id, confirmMessage) { 14126if (!commonCls.confirm(confirmMessage)) { 14127return false; 14128} 14129var top_el = $(this.id); 14130var del_params = new Object(); 14131del_params["param"] = {"action":"journal_action_edit_categorydel","category_id":category_id}; 14132del_params["callbackfunc"] = function(){ 14133commonCls.sendView(this.id,{"action":"journal_view_edit_category","journal_id":journal_id}); 14134}.bind(this); 14135del_params["callbackfunc_error"] = function(res){ 14136commonCls.alert(res); 14137commonCls.sendView(this.id,"journal_view_edit_list"); 14138}.bind(this); 14139del_params["method"] = "post"; 14140del_params["loading_el"] = top_el; 14141del_params["top_el"] = top_el; 14142commonCls.send(del_params); 14143}, 14144showAddPopup: function(this_el) { 14145if(this.popupLnk == null || !$(this.popupLnk.popupID)) { 14146this.popupLnk = new compPopup(this.id, "addCategory" + this.id); 14147this.popupLnk.stopLoadEvent(); 14148} 14149this.popupLnk.showPopup(this.popupLnk.getPopupElementByEvent(this_el), this_el); 14150}, 14151addCategory: function() {
14152var top_el = $(this.id); 14153var form = this.popupLnk.popupElement.contentWindow.document.getElementsByTagName("form")[0]; 14154var add_params = new Object(); 14155add_params["param"] = "journal_action_edit_categoryadd" + "&"+ Form.serialize(form); 14156add_params["callbackfunc"] = function(){ 14157this.popupLnk.closePopup(); 14158commonCls.sendView(this.id,{"action":"journal_view_edit_category","journal_id":form.journal_id.value}); 14159}.bind(this); 14160add_params["callbackfunc_error"] = function(res){ 14161if(res.match("^(category_name):")) { 14162var mesArr = res.split(":"); 14163commonCls.alert(mesArr[1]); 14164form.content.focus(); 14165form.content.select(); 14166} else { 14167commonCls.alert(res); 14168} 14169}.bind(this); 14170add_params["method"] = "post"; 14171add_params["loading_el"] = top_el; 14172add_params["top_el"] = top_el; 14173commonCls.send(add_params); 14174}, 14175showEditPost: function(el, post_id) { 14176var top_el = $(this.id); 14177var params = new Object(); 14178params["param"] = { 14179"action":"journal_view_main_post", 14180"post_id":post_id 14181}; 14182params["top_el"] = top_el; 14183params["loading_el"] = el; 14184params["target_el"] = top_el; 14185commonCls.send(params); 14186} 14187} 14188var clsAnnouncement = Class.create(); 14189var announcementCls = Array(); 14190clsAnnouncement.prototype = { 14191initialize: function(id) { 14192this.id = id; 14193this.textarea = null; 14194this.textarea_more = null; 14195}, 14196announcementMainShow: function() { 14197commonCls.sendView(this.id,"announcement_view_main_init"); 14198}, 14199announcementEditShow: function() { 14200commonCls.sendView(this.id,"announcement_view_edit_init"); 14201}, 14202announcementEditInit: function() { 14203this.textarea = new compTextarea(); 14204this.textarea.uploadAction = { 14205image : "announcement_action_upload_image", 14206file : "announcement_action_upload_init" 14207}; 14208this.textarea.focus = true; 14209this.textarea.textareaShow(this.id, "comptextarea", "full"); 14210}, 14211moreInit: function() { 14212if(this.textarea_more == null) { 14213this.textarea_more = new compTextarea(); 14214this.textarea_more.uploadAction = { 14215image : "announcement_action_upload_image", 14216file : "announcement_action_upload_init" 14217}; 14218} 14219this.textarea_more.textareaShow(this.id, "textarea_more"+this.id, "full"); 14220}, 14221announcementRegist: function(form_el) { 14222var top_el = $(this.id); 14223var more_checked = 0; 14224if(form_el.more_checkbox.checked) { 14225more_checked = 1; 14226} 14227var more_title = null; 14228var more_content = null; 14229var hide_more_title = null; 14230if(this.textarea_more != null) { 14231more_title = form_el.more_title.value; 14232more_content = this.textarea_more.getTextArea(); 14233hide_more_title = form_el.hide_more_title.value; 14234} 14235var content = this.textarea.getTextArea(); 14236var ins_params = new Object(); 14237ins_params["method"] = "post"; 14238ins_params["param"] = {"action":"announcement_action_edit_init", 14239"content":content, 14240"more_checked":more_checked, 14241"more_content":more_content, 14242"more_title":more_title, 14243"hide_more_title":hide_more_title 14244}; 14245ins_params["top_el"] = top_el; 14246ins_params["loading_el"] = top_el; 14247ins_params["callbackfunc"] = function(){this.announcementMainShow();}.bind(this); 14248commonCls.send(ins_params); 14249}, 14250checkMore: function(check_el, confirmMessage) { 14251if(check_el.checked == true) { 14252commonCls.displayChange($('announcement_more_content' + this.id)); 14253this.moreInit(); 14254}else { 14255if (!commonCls.confirm(confirmMessage)) { 14256check_el.checked = true; 14257return false; 14258} 14259commonCls.displayChange($('announcement_more_content' + this.id)); 14260} 14261}, 14262announcementCancel: function() { 14263this.announcementMainShow(); 14264} 14265} 14266var clsMenu = Class.create(); 14267var menuCls = Array(); 14268clsMenu.prototype = { 14269initialize: function(id) { 14270this.id = id; 14271this.form = null; 14272this.menuLodingFlag = true; 14273this.url = null; 14274this.center_flag = false; 14275this.dndMgrMenuObj = new Object(); 14276this.dndCustomDrag = null; 14277this.dndCustomDropzone = null; 14278this.margin_left = 20; 14279this.inRenameFlag = false; 14280this.flat_flag = false; 14281}, 14282menuMainInit: function() { 14283}, 14284menuEditInit: function(center_flag,margin_left, flat_flag) { 14285var top_el = $(this.id); 14286this.flat_flag = flat_flag; 14287this.form = top_el.getElementsByTagName("form")[0]; 14288var input = this.form.page_name; 14289setTimeout(this.menuRenameFocus.bind(this),0); 14290this._editObserver(input); 14291this.center_flag = center_flag; 14292this.margin_left = margin_left; 14293this.dndCustomDrag = Class.create(); 14294this.dndCustomDrag.prototype = Object.extend((new compDraggable), { 14295prestartDrag: function() 14296{ 14297var draggable = this.htmlElement; 14298var next_el = draggable.nextSibling; 14299if(next_el && next_el.id.match("_menu_")) { 14300Element.addClassName(next_el,"display-none"); 14301} 14302}, 14303endDrag: function() { 14304var draggable = this.htmlElement; 14305Element.setStyle(draggable, {opacity:""}); 14306var drag_params = this.getParams(); 14307var parent_el = $(drag_params[1]); 14308if(parent_el && parent_el.innerHTML=="") { 14309Element.remove(parent_el); 14310} 14311} 14312}); 14313this.dndCustomDropzone = Class.create(); 14314this.dndCustomDropzone.prototype = Object.extend((new compDropzone), { 14315canAccept: function(draggableObjects) { 14316var theGUI = draggableObjects[0].getDroppedGUI(); 14317var htmlElement = this.getHTMLElement(); 14318var id_arr = theGUI.id.split("_"); 14319var parent_id = id_arr[3]; 14320if((parent_id == "1" && Element.hasClassName(theGUI, "_menu_sub_group")) && valueParseInt(theGUI.style.marginLeft) != valueParseInt(htmlElement.style.marginLeft)) { 14321return false;
14322} 14323return true; 14324}, 14325showHover: function(event) { 14326var htmlElement = this.getHTMLElement(); 14327var id_arr = htmlElement.id.split("_"); 14328var room_id = id_arr[3]; 14329var subgroup_flag = false; 14330var current_drop_el = Element.getParentElementByClassName(Event.element(event), "menu_row_top"); 14331if(Element.hasClassName(current_drop_el, "_menu_sub_group")) { 14332subgroup_flag = true; 14333} 14334var child_el = Element.getChildElement(htmlElement); 14335var node_type_el = Element.getChildElementByClassName(htmlElement,"_menu_node_type"); 14336if(Element.hasClassName(node_type_el, "menu_node") && room_id != "top" && room_id != "group" && subgroup_flag != true) { 14337if ( this._showHover(child_el) ) 14338return; 14339var offset = Position.cumulativeOffset(htmlElement); 14340var ex = offset[0]; 14341var ey = offset[1]; 14342var part_height = (htmlElement.offsetHeight/5); 14343var y = Event.pointerY(event); 14344if(y < ey + part_height * 2) { 14345this.ChgSeqPosition = "top"; 14346var top_px = ey + "px"; 14347} else if(y > ey + part_height * 3) { 14348this.ChgSeqPosition = "bottom"; 14349var top_px = (ey + htmlElement.offsetHeight) + "px"; 14350} else { 14351this.ChgSeqPosition = "inside"; 14352if(this.ChgSeqHover) { 14353Element.remove(this.ChgSeqHover); 14354this.ChgSeqHover = null; 14355} 14356child_el.style.backgroundColor = "#ffff99"; 14357} 14358if(this.ChgSeqPosition != "inside") { 14359if(this.ChgSeqHover == undefined || this.ChgSeqHover == null) { 14360this._hideHover(child_el); 14361this.ChgSeqHover = document.createElement("DIV"); 14362} 14363document.body.appendChild(this.ChgSeqHover); 14364this.ChgSeqHover.style.width = htmlElement.offsetWidth + "px"; 14365this.ChgSeqHover.style.height = "1px"; 14366this.ChgSeqHover.style.position = "absolute"; 14367this.ChgSeqHover.style.left = ex + "px"; 14368this.ChgSeqHover.style.top = top_px; 14369this.ChgSeqHover.style.borderTop = "3px"; 14370this.ChgSeqHover.style.borderTopStyle = "solid"; 14371this.ChgSeqHover.style.borderTopColor = "#ffff00"; 14372} 14373} else { 14374this.showChgSeqHover(event); 14375} 14376}, 14377hideHover: function(event) 14378{ 14379var htmlElement = this.getHTMLElement(); 14380var child_el = Element.getChildElement(htmlElement); 14381if ( this._hideHover(child_el) ) 14382return; 14383if(this.ChgSeqHover) { 14384Element.remove(this.ChgSeqHover); 14385this.ChgSeqHover = null; 14386} 14387}, 14388accept: function(draggableObjects) 14389{ 14390var params = this.getParams(); 14391var top_id = params[0]; 14392var htmlElement = this.getHTMLElement(); 14393if ( htmlElement == null ) 14394return; 14395var n = draggableObjects.length; 14396for ( var i = 0 ; i < n ; i++ ) { 14397var theGUI = draggableObjects[i].getDroppedGUI(); 14398if ( Element.getStyle( theGUI, "position" ) == "absolute" ) { 14399theGUI.style.position = "static"; 14400theGUI.style.top = ""; 14401theGUI.style.left = ""; 14402} 14403var margin_left = params[1]; 14404var id_arr = theGUI.id.split("_"); 14405var page_id = id_arr[2]; 14406if(this.ChgSeqPosition == "inside") { 14407var margin_px = (valueParseInt(htmlElement.style.marginLeft) + margin_left); 14408} else { 14409var margin_px = valueParseInt(htmlElement.style.marginLeft); 14410} 14411theGUI.style.marginLeft = margin_px + "px"; 14412var doc = document.createDocumentFragment(); 14413doc.appendChild(theGUI); 14414var child_el = $("_menu_"+page_id+top_id); 14415if(child_el) { 14416var child_parent_el = child_el.parentNode; 14417this._setMargin(child_el, margin_px, margin_left); 14418doc.appendChild(child_el); 14419if(child_parent_el && child_parent_el.innerHTML=="") { 14420Element.remove(child_parent_el); 14421} 14422} 14423if(this.ChgSeqPosition == "top") { 14424htmlElement.parentNode.insertBefore(doc, htmlElement); 14425} else if(this.ChgSeqPosition == "bottom"){ 14426var next_el = htmlElement.nextSibling; 14427if(next_el && next_el.id.match("_menu_")) { 14428next_el = next_el.nextSibling; 14429} 14430if(!next_el) { 14431htmlElement.parentNode.appendChild(doc); 14432} else { 14433next_el.parentNode.insertBefore(doc, next_el); 14434} 14435} else { 14436var next_el = htmlElement.nextSibling; 14437if(next_el && next_el.id.match("_menu_")) { 14438next_el.appendChild(doc); 14439if(next_el.innerHTML != "") { 14440Element.removeClassName(next_el,"display-none"); 14441} 14442} else { 14443var id_arr = htmlElement.id.split("_"); 14444var page_id = id_arr[2]; 14445var div = document.createElement("DIV"); 14446div.id = "_menu_"+page_id+top_id; 14447div.className = "_menu_"+page_id+top_id; 14448var next_el = htmlElement.nextSibling; 14449if(!next_el) { 14450htmlElement.parentNode.appendChild(div); 14451} else { 14452next_el.parentNode.insertBefore(div, next_el); 14453} 14454div.appendChild(doc); 14455} 14456} 14457} 14458}, 14459_setMargin: function(child_el, margin_px, margin_left) { 14460if(child_el) { 14461for (var i = 0,child_len=child_el.childNodes.length; i < child_len; i++) { 14462if(!child_el.childNodes[i].id.match("_menu_")) { 14463child_el.childNodes[i].style.marginLeft = (margin_px + margin_left) + "px"; 14464} else { 14465this._setMargin(child_el.childNodes[i], margin_px, margin_px + margin_left); 14466} 14467} 14468} 14469}, 14470save: function(draggableObjects) { 14471if(this.ChgSeqPosition == null) { 14472return false;
14473} 14474var params = this.getParams(); 14475var id = params[0]; 14476var top_el = $(id); 14477var drag_el = draggableObjects[0].getHTMLElement(); 14478var id_arr = drag_el.id.split("_"); 14479var drag_page_id = id_arr[2]; 14480var htmlElement = this.getHTMLElement(); 14481var id_arr = htmlElement.id.split("_"); 14482var drop_page_id = id_arr[2]; 14483var chgseq_params = new Object(); 14484chgseq_params["param"] = {"action":"menu_action_edit_chgseq", "drag_page_id":drag_page_id, 14485"drop_page_id":drop_page_id, "position":this.ChgSeqPosition}; 14486chgseq_params["callbackfunc_error"] = function(res){ 14487commonCls.alert(res); 14488location.reload(); 14489}.bind(this); 14490chgseq_params["method"] = "post"; 14491chgseq_params["top_el"] = top_el; 14492commonCls.send(chgseq_params); 14493return true; 14494} 14495}); 14496this.dndMgrMenuObj = new Object(); 14497var range_el = $("_menu_range"+this.id); 14498var menu_rowfields = Element.getElementsByClassName(range_el, "menu_row_top"); 14499menu_rowfields.each(function(menu_row_el) { 14500if(menu_row_el.id) { 14501this._dndObserver(menu_row_el); 14502} 14503}.bind(this)); 14504}, 14505menuRenameFocus: function(input) { 14506if(!input || input.tagName == undefined) { 14507var input = this.form.page_name; 14508} 14509if(input) { 14510input.focus(); 14511input.select(); 14512} 14513}, 14514_dndObserver: function(el) { 14515var id_arr = el.id.split("_"); 14516var room_id = id_arr[3]; 14517var img_el = Element.getChildElementByClassName(el,"_menu_displayseq"); 14518if(img_el != null) { 14519if(!this.dndMgrMenuObj[room_id]) { 14520this.dndMgrMenuObj[room_id] = new compDragAndDrop(); 14521this.dndMgrMenuObj[room_id].registerDraggableRange(el.parentNode); 14522} 14523this.dndMgrMenuObj[room_id].registerDraggable(new this.dndCustomDrag(el, img_el.parentNode, new Array(this.id, el.parentNode.id))); 14524this.dndMgrMenuObj[room_id].registerDropZone(new this.dndCustomDropzone(el, new Array(this.id, this.margin_left))); 14525} 14526}, 14527_editObserver: function(el) { 14528if(el) { 14529Event.observe(el, 'keydown', this.menuRename.bindAsEventListener(this, el) , true, $(this.id)); 14530Event.observe(el, 'change', this.menuRename.bindAsEventListener(this, el), true, $(this.id)) ; 14531} 14532}, 14533menuRename: function(event, el) { 14534if (!this.inRenameFlag && (event.type == "change" || event.keyCode == 13)) { 14535var top_el = $(this.id); 14536var parent_el = Element.getParentElement(el, 2); 14537if(parent_el) { 14538this.inRenameFlag = true; 14539var idName = parent_el.id; 14540var page_id = parseInt(idName.replace("_menutop"+this.id+"_","")); 14541var rename_params = new Object(); 14542rename_params["method"] = "post"; 14543rename_params["param"] = {"action":"menu_action_edit_rename","main_page_id":page_id,"page_name": el.value}; 14544rename_params["callbackfunc"] = function(res){ 14545this.inRenameFlag = false; 14546if(el) { 14547if(res == "") { 14548var value = el.value; 14549} else { 14550var value = res; 14551} 14552Event.stopObserving(el, "keydown",this.menuRename.bindAsEventListener(this, el),false); 14553Event.stopObserving(el, "change",this.menuRename.bindAsEventListener(this, el),false); 14554var text = document.createTextNode(value); 14555var span_el = Element.getChildElement(parent_el); 14556span_el.innerHTML = ""; 14557span_el.appendChild(text); 14558} 14559}.bind(this); 14560rename_params["callbackfunc_error"] = function(res){ 14561this.inRenameFlag = false; 14562commonCls.alert(res); 14563}.bind(this); 14564rename_params["top_el"] = top_el; 14565commonCls.send(rename_params); 14566} 14567} 14568}, 14569menuMainShow: function() { 14570commonCls.sendView(this.id,"menu_view_main_init"); 14571}, 14572menuEditShow: function() { 14573commonCls.sendView(this.id,"menu_view_edit_init"); 14574}, 14575menuNodeClick: function(event, page_id, edit_flag, addpage_flag) { 14576var class_name = "_menu_" + page_id+this.id; 14577var top_class_name = "_menutop_" + page_id; 14578var top_el = $(this.id); 14579var top_node_el = Element.getChildElementByClassName(top_el,top_class_name); 14580var el = Element.getChildElementByClassName(top_el,class_name); 14581if(edit_flag) { 14582var top_node_el_href = Element.getParentElementByClassName(top_node_el, "menu_row_top"); 14583this.cancelActiveBtn(); 14584this.addActiveBtn(top_node_el_href); 14585var child_el = Element.getChildElement(top_node_el); 14586var input_el = Element.getChildElement(child_el); 14587var node_type_el = Element.getChildElementByClassName(top_node_el_href, "_menu_node_type"); 14588if(!input_el && !Element.hasClassName(child_el, "menu_lbl_disabled")) { 14589var input = document.createElement("INPUT"); 14590input.type = "text"; 14591input.className = "menu_pagename_text"; 14592input.value = child_el.innerHTML.unescapeHTML(); 14593child_el.innerHTML = ""; 14594child_el.appendChild(input); 14595this.menuRenameFocus(input);
14596this._editObserver(input); 14597} 14598} else { 14599var top_node_el_href = top_node_el; 14600} 14601if(!el) { 14602var detail_params = new Object(); 14603detail_params["method"] = "get"; 14604if(edit_flag) { 14605var visibility_el = $("_menuvisibility"+this.id+"_" + page_id); 14606if(!visibility_el || visibility_el.src == undefined) { 14607var visibility_flag = 1; 14608} else if(visibility_el.src.match("off.gif")) { 14609var visibility_flag = 0; 14610} else { 14611var visibility_flag = 1; 14612} 14613detail_params["param"] = {"action":"menu_view_edit_detail","main_page_id":page_id,"visibility_flag":visibility_flag}; 14614} else { 14615detail_params["param"] = {"action":"menu_view_main_detail","main_page_id":page_id}; 14616} 14617detail_params["callbackfunc"] = function(res){ 14618var div = document.createElement("DIV"); 14619div.id = "_menu_"+page_id+this.id; 14620if(res == "") { 14621div.className = "_menu_"+page_id+this.id+" display-none"; 14622} else { 14623div.className = "_menu_"+page_id+this.id; 14624} 14625var next_el = top_node_el_href.nextSibling; 14626if(!next_el) { 14627top_node_el_href.parentNode.appendChild(div); 14628} else { 14629next_el.parentNode.insertBefore(div, next_el); 14630} 14631div.innerHTML = res; 14632var menu_rowfields = Element.getElementsByClassName(div, "menu_row_top"); 14633menu_rowfields.each(function(menu_row_el) { 14634if(menu_row_el.id) { 14635this._dndObserver(menu_row_el); 14636} 14637}.bind(this)); 14638}.bind(this); 14639detail_params["top_el"] = top_el; 14640commonCls.send(detail_params); 14641return; 14642} 14643var parent_el = Element.getParentElement(el); 14644for (var i = 0; i < parent_el.childNodes.length; i++) { 14645var div = parent_el.childNodes[i]; 14646if(div && div.tagName == "DIV" && Element.hasClassName(div,class_name)) { 14647if(Element.hasClassName(div,"display-none")) { 14648if(div.innerHTML != "") { 14649Element.removeClassName(div,"display-none"); 14650} 14651var display_flag = true; 14652break; 14653} else { 14654Element.addClassName(div,"display-none"); 14655var display_flag = false; 14656break; 14657} 14658} 14659} 14660var img_el= top_node_el.getElementsByTagName("img")[0]; 14661if(img_el) { 14662if(display_flag) { 14663img_el.src = img_el.src.replace("right_arrow.gif","down_arrow.gif"); 14664} else { 14665img_el.src = img_el.src.replace("down_arrow.gif","right_arrow.gif"); 14666} 14667} 14668}, 14669menuleafClick: function(this_el, url, page_id, edit_flag) { 14670var top_table_el = Element.getParentElementByClassName(this_el, "menu_row_top"); 14671var top_class_name = "_menutop_" + page_id; 14672var top_el = $(this.id); 14673var top_node_el = Element.getChildElementByClassName(top_el,top_class_name); 14674var child_el = Element.getChildElement(top_table_el); 14675if(edit_flag) { 14676if(Element.hasClassName(child_el,"highlight")) { 14677var highlight_flag = true; 14678} else { 14679var highlight_flag = false; 14680this.cancelActiveBtn(); 14681this.addActiveBtn(top_table_el); 14682} 14683} 14684var child_el = Element.getChildElement(top_node_el); 14685var input_el = Element.getChildElement(child_el); 14686if(!input_el && edit_flag) { 14687var input = document.createElement("INPUT"); 14688input.type = "text"; 14689input.value = child_el.innerHTML.unescapeHTML();; 14690child_el.innerHTML = ""; 14691child_el.appendChild(input); 14692this.menuRenameFocus(input); 14693this._editObserver(input); 14694} 14695this.url = url; 14696}, 14697addActiveBtn: function(el) { 14698var child_el = Element.getChildElement(el); 14699if(!Element.hasClassName(child_el,"highlight")) { 14700Element.addClassName(child_el,"highlight"); 14701this._chgImage(child_el, true); 14702} 14703}, 14704cancelActiveBtn: function() { 14705var active_el = this._searchActiveBtn(); 14706var child_el = Element.getChildElement(active_el); 14707if(Element.hasClassName(child_el,"highlight")) { 14708Element.removeClassName(child_el,"highlight"); 14709this._chgImage(child_el); 14710} 14711}, 14712_searchActiveBtn: function() { 14713var top_el = $(this.id); 14714var tableList = top_el.getElementsByTagName("table"); 14715for (var i = 0; i < tableList.length; i++){ 14716if(Element.hasClassName(tableList[i],"highlight")) { 14717return tableList[i].parentNode; 14718} 14719} 14720}, 14721_chgImage: function (el, active_flag) { 14722var img_el = Element.getChildElementByClassName(el, "_menu_displayseq"); 14723if(img_el) { 14724if(active_flag) { 14725img_el.src = img_el.src.replace("move_bar.gif","move_bar_active.gif"); 14726} else { 14727img_el.src = img_el.src.replace("move_bar_active.gif","move_bar.gif"); 14728} 14729} 14730}, 14731insPage: function(category_flag) { 14732var active_el = this._searchActiveBtn(); 14733var node_type_el = Element.getChildElementByClassName(active_el, "_menu_node_type"); 14734if(Element.hasClassName(node_type_el, "menu_node") || Element.hasClassName(node_type_el, "menu_room")) { 14735var node_flag = true; 14736} else { 14737var node_flag = false;
14738} 14739var href_el = Element.getChildElementByClassName(active_el, "_menutop"); 14740var div_el = Element.getChildElement(href_el); 14741var idName = href_el.id; 14742var page_id = parseInt(idName.replace("_menutop"+this.id+"_","")); 14743var top_el = $(this.id); 14744if(node_flag) { 14745var visibility_el = $("_menuvisibility"+this.id+"_" + page_id); 14746if(!visibility_el) { 14747return; 14748} else if(visibility_el.src != undefined && visibility_el.src.match("off.gif")) { 14749var visibility_flag = 0; 14750} else { 14751var visibility_flag = 1; 14752} 14753} else { 14754if(!this.chkVisibility(active_el)) { 14755var visibility_flag = 0; 14756} else { 14757var visibility_flag = 1; 14758} 14759} 14760var ins_params = new Object(); 14761ins_params["method"] = "post"; 14762if(category_flag) { 14763ins_params["param"] = {"action":"menu_action_edit_addpage","main_page_id":page_id, "node_flag":"1", "visibility_flag":visibility_flag}; 14764} else { 14765ins_params["param"] = {"action":"menu_action_edit_addpage","main_page_id":page_id, "visibility_flag":visibility_flag}; 14766} 14767ins_params["top_el"] = top_el; 14768ins_params["callbackfunc"] = function(res){ 14769if(node_flag) { 14770var next_el = active_el.nextSibling; 14771var id_name = "_menu_"+page_id+this.id; 14772} else { 14773var next_el = active_el.parentNode;
14774var id_name = next_el.id; 14775} 14776if(next_el && next_el.id == id_name) { 14777var div = document.createElement("DIV"); 14778next_el.appendChild(div); 14779div.innerHTML = res; 14780var new_el = Element.getChildElement(div); 14781var observe_el = Element.getChildElement(div); 14782next_el.appendChild(observe_el); 14783Element.remove(div); 14784if(next_el.innerHTML != "") { 14785Element.removeClassName(next_el,"display-none"); 14786} 14787} else { 14788var div = document.createElement("DIV"); 14789div.id = "_menu_"+page_id+this.id; 14790div.className = "_menu_"+page_id+this.id; 14791if(!next_el) { 14792active_el.parentNode.appendChild(div); 14793} else { 14794next_el.parentNode.insertBefore(div, next_el); 14795} 14796div.innerHTML = res; 14797var new_el = Element.getChildElement(div); 14798var observe_el = Element.getChildElement(div); 14799} 14800var new_href_el = Element.getChildElementByClassName(new_el, "_menutop"); 14801new_href_el.onclick(); 14802var input = new_href_el.getElementsByTagName("input")[0]; 14803this.menuRenameFocus(input); 14804this._editObserver(input); 14805this._dndObserver(observe_el); 14806}.bind(this); 14807commonCls.send(ins_params); 14808}, 14809delPage: function(page_id, id_name) { 14810var top_el = $(this.id); 14811var del_params = new Object(); 14812del_params["method"] = "post"; 14813del_params["param"] = {"action":"menu_action_edit_deletepage","main_page_id":page_id}; 14814del_params["top_el"] = top_el; 14815del_params["callbackfunc"] = function(res){ 14816if(res != "true") { 14817location.href = res; 14818} else { 14819var del_el = $(id_name); 14820var parent_el = del_el.parentNode.previousSibling; 14821this.cancelActiveBtn(); 14822this.addActiveBtn(parent_el); 14823Element.remove(del_el); 14824var child_el = $("_menu_" + page_id+this.id); 14825if(child_el) { 14826var parent_el = child_el.parentNode; 14827Element.remove(child_el); 14828if(parent_el.innerHTML=="") { 14829Element.remove(parent_el); 14830} 14831} 14832} 14833}.bind(this); 14834commonCls.send(del_params); 14835}, 14836chkVisibility: function(menu_top_el) { 14837if((this.flat_flag == false && menu_top_el && menu_top_el.parentNode) || 14838(this.flat_flag == true && menu_top_el && parseInt(Element.getStyle(menu_top_el, "marginLeft")) == 0)) { 14839var idName = menu_top_el.parentNode.id; 14840var parent_page_id = idName.replace("_menu_",""); 14841var rObj = new RegExp(this.id+"$"); 14842parent_page_id = parent_page_id.replace(rObj,""); 14843if(parent_page_id != "") { 14844parent_page_id = parseInt(parent_page_id); 14845var parent_visibility_el = $("_menuvisibility"+this.id+"_" + parent_page_id); 14846if(parent_visibility_el) { 14847if(parent_visibility_el.src && parent_visibility_el.src.match("off.gif")) { 14848return false; 14849} 14850} 14851} 14852} 14853return true; 14854}, 14855chgVisibilityPage: function(this_el, page_id) { 14856var menu_top_el = Element.getParentElementByClassName(this_el, "menu_row_top"); 14857if(!this.chkVisibility(menu_top_el)) return; 14858var img_el = Element.getChildElement(this_el); 14859if(img_el.src.match("on.gif")) { 14860var visibility_flag = 0; 14861} else { 14862var visibility_flag = 1; 14863} 14864var top_el = $(this.id); 14865var chg_params = new Object(); 14866chg_params["method"] = "post"; 14867chg_params["param"] = {"action":"menu_action_edit_visibility","main_page_id":page_id, "visibility_flag":visibility_flag}; 14868chg_params["top_el"] = top_el; 14869chg_params["callbackfunc"] = function(res){ 14870if(visibility_flag) { 14871img_el.src = img_el.src.replace("off.gif","on.gif"); 14872} else { 14873img_el.src = img_el.src.replace("on.gif","off.gif"); 14874} 14875var next_el = menu_top_el.nextSibling; 14876if(this.flat_flag == false || (this.flat_flag == true && parseInt(Element.getStyle(menu_top_el, "marginLeft")) == 0)) { 14877if(next_el && next_el.id == "_menu_" + page_id+this.id) { 14878var visibilityfields = Element.getElementsByClassName(next_el, "_menuvisibility"); 14879visibilityfields.each(function(visibility_el) { 14880if(visibility_flag) { 14881visibility_el.src = visibility_el.src.replace("off.gif","on.gif"); 14882} else { 14883visibility_el.src = visibility_el.src.replace("on.gif","off.gif"); 14884} 14885}.bind(this)); 14886} 14887} 14888}.bind(this); 14889commonCls.send(chg_params); 14890} 14891} 14892var clsCounter = Class.create(); 14893var counterCls = Array(); 14894clsCounter.prototype = { 14895initialize: function(id) { 14896this.id = id; 14897}, 14898counterMainShow: function() { 14899commonCls.sendView(this.id,"counter_view_main_init"); 14900}, 14901counterPreview: function() { 14902var top_el = $(this.id); 14903var form = top_el.getElementsByTagName("form")[0];
14904var preview_el = $("_counter_preview"+this.id); 14905var params = new Object(); 14906params["method"] = "get"; 14907params["param"] = "action=counter_view_edit_preview" + "&"+ Form.serialize(form); 14908params["top_el"] = top_el; 14909params["loading_el"] = preview_el; 14910params["target_el"] = preview_el; 14911commonCls.send(params); 14912}, 14913counterRegist: function(cmd) { 14914var top_el = $(this.id); 14915var form = top_el.getElementsByTagName("form")[0]; 14916var params = new Object(); 14917params["method"] = "post"; 14918params["param"] = "action=counter_action_edit_init&zero_flag="+ cmd + "&"+ Form.serialize(form); 14919params["top_el"] = top_el; 14920params["loading_el"] = top_el; 14921params["target_el"] = top_el; 14922commonCls.send(params); 14923} 14924} 14925var clsLogin = Class.create(); 14926var loginCls = Array(); 14927clsLogin.prototype = { 14928initialize: function(id) { 14929this.id = id; 14930this.login_id = null; 14931this.password = null; 14932this.tokenValue = null; 14933this.sslPopup = null; 14934this.block_id = null; 14935}, 14936loginInit: function() { 14937this.login_id = $("login_id" + this.id); 14938this.password = $("password" + this.id); 14939setTimeout(this.loginFocus.bind(this.login_id), 200); 14940}, 14941loginEnterAction: function(event, prefix_id_name, token_value) { 14942if (event.keyCode == 13) { 14943this.loginAction(event, prefix_id_name, token_value); 14944return false; 14945} 14946return true; 14947}, 14948loginAction: function(event, prefix_id_name, token_value) { 14949var top_el = $(this.id); 14950var login_id = $F("login_id" + this.id); 14951var password = $F("password" + this.id); 14952if($("login_rememberme" + this.id)) { 14953var rememberme = $F("login_rememberme" + this.id); 14954} else { 14955var rememberme = 0; 14956} 14957var redirect_url = $_GET('_redirect_url'); 14958if(redirect_url == undefined) { 14959redirect_url = ""; 14960} 14961var login_params = new Object(); 14962login_params["method"] = "post"; 14963login_params["param"] = {"action":"login_action_main_init", 14964"login_id":login_id, 14965"password":password, 14966"rememberme":rememberme, 14967"_redirect_url":redirect_url}; 14968if (this.tokenValue) { 14969login_params["param"]["block_id"] = this.block_id; 14970login_params["param"]["_token"] = this.tokenValue; 14971} 14972login_params["top_el"] = top_el; 14973login_params["loading_el"] = top_el; 14974login_params["callbackfunc"] = function(res){this.loginComplete(res);}.bind(this); 14975login_params["callbackfunc_error"] = function(res){this.loginComplete(res);}.bind(this); 14976commonCls.send(login_params); 14977}, 14978loginLogout: function(event) { 14979var load_el = Event.element(event); 14980var logout_params = new Object(); 14981var top_el = $(this.id); 14982logout_params["method"] = "post"; 14983logout_params["param"] = {"action":"login_action_main_logout"}; 14984logout_params["loading_el"] = load_el; 14985logout_params["callbackfunc"] = function(res){this.loginComplete(res);}.bind(this); 14986logout_params["callbackfunc_error"] = function(res){this.loginComplete(res);}.bind(this); 14987commonCls.send(logout_params); 14988}, 14989loginComplete: function(res) { 14990var location_href = res.match("location\.href"); 14991if(location_href == null) { 14992if(res.match(":")) { 14993var mesArr = res.split(":"); 14994var alert_res = ""; 14995for(var i = 1; i < mesArr.length; i++) { 14996alert_res += mesArr[i]; 14997} 14998if(res.match("^(login_id|password|login_id,password|login_id,password,md5):")) { 14999commonCls.alert(alert_res); 15000if(mesArr[0] == "login_id,password") { 15001setTimeout(this.loginFocus.bind(this.login_id), 100); 15002this.password.value=""; 15003} else if(mesArr[0] == "login_id") 15004setTimeout(this.loginFocus.bind(this.login_id), 100); 15005else { 15006setTimeout(this.loginFocus.bind(this.password), 100); 15007} 15008} else { 15009commonCls.alert(res); 15010} 15011} else { 15012commonCls.alert(res); 15013} 15014} 15015}, 15016loginFocus: function() { 15017var el = $(this); 15018commonCls.focus(el); 15019}, 15020insAutoregist: function (form_el) { 15021var reg_params = new Object(); 15022reg_params["param"] = {'action': "login_action_main_autoregist"}; 15023reg_params["form_el"] = form_el; 15024reg_params["top_el"] = $(this.id); 15025reg_params["target_el"] = $("target"+this.id); 15026reg_params["method"] = "post"; 15027reg_params['form_prefix'] = "login_attachment"; 15028reg_params["callbackfunc_error"] = function(file_list, res){ 15029this.focusError(res); 15030}.bind(this); 15031commonCls.sendAttachment(reg_params); 15032}, 15033focusError: function(res) { 15034res = commonCls.cutErrorMes(res); 15035if(res.match(":")) { 15036var mesArr = res.split(":"); 15037var alert_res = ""; 15038for(var i = 1; i < mesArr.length; i++) { 15039alert_res += mesArr[i]; 15040} 15041var focus_el = $("login_items"+ this.id + "_" + mesArr[0]) 15042if(focus_el) { 15043commonCls.alert(alert_res); 15044commonCls.focus(focus_el); 15045} else { 15046commonCls.alert(res); 15047} 15048} else { 15049commonCls.alert(res); 15050} 15051}, 15052focusBtn: function(this_el) { 15053if(!browser.isNS){ 15054Element.removeClassName(this_el, 'login_popup_btn'); 15055Element.addClassName(this_el, 'login_popup_act_btn'); 15056} 15057}, 15058blurBtn: function(this_el) { 15059if(!browser.isNS){ 15060Element.addClassName(this_el, 'login_popup_btn'); 15061Element.removeClassName(this_el, 'login_popup_act_btn'); 15062} 15063} 15064}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.