/* * */ /* * @(#) du_ext.js * build version : 1.0.0 $Revision: 15341 $ * * Copyright ⓒ LG CNS, Inc. All rights reserved. * * devon@lgcns.com * http://www.dev-on.com * * Do Not Erase This Comment!!! (이 주석문을 지우지 말것) * * dujsf/license.txt를 반드시 읽어보고 사용하시기 바랍니다. * * 1. 사내 사용시 KAMS를 통해 요청하여 사용허가를 받아야만 소프트웨어 라이센스 계약서에 동의하는 것으로 간주됩니다. * 2. DevOn RUI가 포함된 제품을 판매할 경우에도 KAMS를 통해 요청하여 사용허가를 받아야만 합니다. * 3. KAMS를 통해 사용허가를 받지 않은 경우 소프트웨어 라이센스 계약을 위반한 것으로 간주됩니다. * 4. 별도로 판매될 경우 LGCNS의 소프트웨어 판매정책을 따릅니다. (KAMS에 문의 바랍니다.) * * (주의!) 원저자의 허락없이 재배포 할 수 없으며 * LG CNS 외부로의 유출을 하여서는 안 된다. */ /** * Form * @module widget_form * @title Form * @requires DU */ DU.namespace("DU.widget"); /** * LForm * @namespace DU.widget * @class LForm * @extends DU.widget.LUIComponent * @constructor LForm * @param {Object} oConfig The intial LForm. */ DU.widget.LForm = function(id, oConfig){ this.id = id; DU.widget.LForm.superclass.constructor.call(this, oConfig); var config = oConfig || {}; /** * @description DU.validate.LValidatorManager 객체 *

Sample: 보기

* @config validatorManager * @type {DU.validate.LValidatorManager} * @default null */ /** * @description DU.validate.LValidatorManager 객체 * @property validatorManager * @private * @type {DU.validate.LValidatorManager} */ this.validatorManager = null; DU.applyObject(this, config, true); // validatorManager 권장 안함. if(this.validatorManager == null && config.validators) { this.validatorManager = new DU.validate.LValidatorManager({ validators:config.validators }); } /** * @description DU.data.LTransactionManager 객체 * @property tm * @private * @type {DU.data.LTransactionManager} */ this.tm = new DU.data.LTransactionManager(); this.tm.on('success', this.onSuccess, this, true); this.tm.on('failure', this.onFailure, this, true); /** * @description sumbit 실행전 호출되는 이벤트, 이벤트 리턴값이 false면 submit이 호출되지 않는다. * @event beforesubmit */ this.createEvent('beforesubmit'); /** * @description invalid가 발생하는 발생하는 이벤트 * @event invalid * @param {Object} target this객체 * @param {Array} invalidList invalid 객체 List */ this.createEvent('invalid'); /** * @description sumbit이 성공하면 발생하는 이벤트 * @event success * @param {XMLHttpRequest} conn ajax response 객체 */ this.createEvent('success'); /** * @description sumbit이 실패하면 발생하는 이벤트 * @event failure * @param {XMLHttpRequest} conn ajax response 객체 */ this.createEvent('failure'); } DU.extend(DU.widget.LForm, DU.widget.LUIComponent, { /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ var elList = DU.select("form[name=" + this.id + "]"); if(elList.length > 0) this.el = elList.getAt(0); else this.el = DU.get(this.id); }, /** * @description LValidatorManager 객체를 설정하는 메소드 * @public * @method setValidatorManager * @param {DU.validate.LValidatorManager} validatorManager DU.validate.LValidatorManager 객체 * @return {void} */ setValidatorManager : function(validatorManager) { this.validatorManager = validatorManager; }, /** * @description submit 메소드 * @method submit * @public * @return void */ submit : function() { if (this.fireEvent('beforesubmit', this) == false) return; if(this.validate()) { this.tm.updateForm({ url : this.el.dom.action, form : this.id }); return true; } return false; }, /** * 성공시 발생하는 메소드 * @method onSuccess * @private * @param {Object} e 성공시 Response객체 * @return void */ onSuccess : function(e) { this.fireEvent('success', e); }, /** * 실패시 발생하는 메소드 * @method onFailure * @private * @param {Object} e 실패시 Response객체 * @return void */ onFailure : function(e) { this.fireEvent('failure', e); }, /** * reset시 발생하는 메소드 * @method onReset * @private * @return void */ onReset : function() { }, /** * validate 발생하는 메소드 * @method validate * @private * @return void */ validate : function() { if(this.validatorManager == null) return true; var isValid = this.validatorManager.validateGroup(this.id); if(isValid == false) { var invalidList = this.validatorManager.getInvalidList(); this.fireEvent('invalid', {target:this, invalidList:invalidList, isValid:isValid}); } return isValid; }, /** * form 객체의 invalid된 모든 객체를 초기화 하는 메소드 * @method clearInvalid * @public * @return void */ clearInvalid : function() { var children = this._getChildList(); var valid = true; DU.util.LArray.each(children, function(f) { var child = DU.get(f); child.valid(); }, this); }, /** * 배열 객체에 해당되는 모든 객체를 활성화 한다. * @method enable * @public * @param {Array} children enable할 배열 객체, 인수를 안 넘기면 모든 form객체 안의 child 모든 객체 자동 선택 * @return void */ enable : function(children) { children = DU.isUndefined(children) ? this._getChildList() : children; DU.util.LArray.each(children, function(f) { var child = DU.get(f); if(child) child.enable(); }, this); }, /** * 배열 객체에 해당되는 모든 객체를 비활성화 한다. * @method disable * @public * @param {Array} children enable할 배열 객체, 인수를 안 넘기면 모든 form객체 안의 child 모든 객체 자동 선택 * @return void */ disable : function(children) { children = DU.isUndefined(children) ? this._getChildList() : children; DU.util.LArray.each(children, function(f) { var child = DU.get(f); if(child) child.disable(); }, this); }, /** * 배열 객체에 해당되는 모든 객체중 비활성화가 하나라도 있으면 false를 리턴한다. * @method isDisable * @public * @param {Array} children enable할 배열 객체, 인수를 안 넘기면 모든 form객체 안의 child 모든 객체 자동 선택 * @return void */ isDisable : function(children) { var isDisable = false; children = DU.isUndefined(children) ? this._getChildList() : children; DU.util.LArray.each(children, function(f) { var child = DU.get(f); if(child) { isDisable = child.isDisable(); return; } }, this); return isDisable; }, /** * form 객체에 안에 있는 child객체 배열 * @method getValues * @public * @return {Array} */ getValues : function() { var obj = {}; var children = this._getChildList(); DU.util.LArray.each(children, function(child) { var f = DU.get(child); var element = f.dom; var name = element.name; var value = f.get("value"); if (typeof element.checked == "boolean") { if (/LRadio/.test(element.declaredClass)) { if (value !== false) { obj[name] = value; } } else { var ary = obj[name]; if (!ary) { ary = []; obj[name] = ary; } if (value !== false) { ary.push(value); } } } else { obj[name] = value; } }, this); return obj; }, /** * form 객체에 안에 있는 child객체에 모든 값 대입 * @method setValues * @public * @param {Array} children children에 해당되는 모든 객체에 값 대입 * @return void */ setValues : function(children) { for(var m in children) { var obj = DU.get(m); if(obj && obj instanceof DU.LElement) { obj.setValue(children[m]); } } }, /** * form 객체에 안에 있는 child객체중에 ID에 해당되는 객체를 찾아서 리턴한다. * @method findField * @public * @param {String} id 검색할 ID 값 * @return {HTMLElement} 검색된 결과 객체 */ findField : function(id) { var field = null; var children = this._getChildList(); DU.util.LArray.each(children, function(child) { var f = DU.get(child); if(f.dom.id == id || f.dom.name == id) { field = f.dom; return false; } }, this); return field; }, /** * form 객체에 안에 있는 child객체중에 invalid객체가 존재하면 false를 리턴한다. * @method isValid * @public * @return {Boolean} valid 여부 */ isValid : function() { var isValid = true; var children = this._getChildList(); DU.util.LArray.each(children, function(f) { var element = DU.get(f); if(element.isValid() == false) { isValid = false; return false; } }, this); return isValid; }, /** * form 객체 destroy * @method destroy * @public * @return {void} */ destroy : function(){ this.unOnAll(); }, /** * Record객체를 form 객체의 child객체에 반영한다. * @public * @method updateRecord * @param {DU.data.LRecord} record form객체에 반영할 Record객체 * @return {void} */ updateRecord : function(record) { var o = record.getValues(); this.setValues(o); }, /** * form 객체의 child 정보를 Record객체에 반영한다. * @public * @method updateRecord * @param {DU.data.LRecord} record form객체의 정보를 반영할 Record객체 * @return {DU.data.LRecord} 반영된 Record객체 */ loadRecord : function(record) { var o = this.getValues(); record.setValues(o); return record; }, /** * form 객체의 입력 가능한 child 정보를 리턴한다. * @private * @method _getChildList * @return {DU.LElementList} 반영된 ElementList객체 */ _getChildList : function() { return DU.util.LDomSelector.query('input,select,textarea', this.dom); } }); /** * Field * @module widget_form * @title Field * @requires DU */ DU.namespace("DU.widget"); /** * LField 객체 * @namespace DU.widget * @class LField * @extends DU.widget.LUIComponent * @constructor LField * @param {HTMLElement | String} id The html element that represents the Element. * @param {Object} oConfig The intial Field. */ DU.widget.LField = function(id, oConfig){ var config = oConfig || {}; DU.widget.LField.superclass.constructor.call(this, id, config); /** * @description changed 메소드가 호출되면 수행하는 이벤트 * @event changed */ this.changedEvent = this.createEvent('changed'); /** * @description valid 메소드가 호출되면 수행하는 이벤트 * @event valid */ this.validEvent = this.createEvent('valid'); /** * @description invalid 메소드가 호출되면 수행하는 이벤트 * @event invalid */ this.invalidEvent = this.createEvent('invalid'); /** * @description specialkey 메소드가 호출되면 수행하는 이벤트 * @event specialkey * @param {Object} e window event 객체 */ this.specialkeyEvent = this.createEvent('specialkey'); } DU.extend(DU.widget.LField, DU.widget.LUIComponent, { otype : 'DU.widget.LField', /** * @description field 객체 여부 * @property fieldObject * @private * @type {Boolean} */ fieldObject : true, /** * @description field의 name * @config name * @type {String} * @default null */ /** * @description field의 name * @property name * @private * @type {String} */ name : null, /** * @description field의 border width * @config borderWidth * @type {Int} * @default 4 */ /** * @description field의 border width * @property borderWidth * @private * @type {Int} */ borderWidth : 4, /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LField.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LField.superclass.initDefaultConfig.call(this); }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LField.superclass.afterRender.call(this, container); }, /** * @description Dom객체의 value값을 저장한다. * @method setValue * @param {Object} value 저장할 결과값 * @return void */ setValue : function(o) { this.el.setValue(o); }, /** * @description Dom객체의 value값을 리턴한다. * @method getValue * @return {Object} 객체에 들어 있는 값 */ getValue : function() { return this.el.getValue(); }, /** * @description 키 입력시 호출되는 이벤트 메소드 * @method onFireKey * @param {Object} e Event 객체 * @return {void} */ onFireKey : function(e){ if(DU.util.LEvent.isSpecialKey(e)) this.fireEvent("specialkey", e); }, /** * @description 이름을 셋팅하는 메소드 * @method setName * @param {String} name 이름 * @return {void} */ setName : function(name) { this.name = name; }, /** * @description 이름을 리턴하는 메소드 * @method getName * @return {String} */ getName : function() { return this.name; }, /** * @description 객체의 toString * @method toString * @public * @return {String} */ toString : function() { return 'DU.form.LField ' + this.id; } }); /** * LTextBox * @module widget_form * @title LTextBox * @requires DU */ DU.namespace("DU.widget"); (function(){ var Dom = DU.util.LDom; /** * LTextBox * @namespace DU.widget * @class LTextBox * @extends DU.widget.LField * @constructor LTextBox * @param {Object} oConfig The intial LTextBox. */ DU.widget.LTextBox = function(oConfig){ var config = oConfig || {}; config = Dom.applyIfProperties(config, '$.ext.textBox'); this.collapseIfDelegate = DU.util.LFunction.createDelegate(this.collapseIf, this); /** * @description displayField 명 * @config displayField * @type {String} * @default 'value' */ /** * @description displayField 명 * @property displayField * @private * @type {String} */ this.displayField = config.displayField || DU.getConfig().getFirst('$.ext.textBox.dataset.displayField'); this.isUseDataSet = this.isAutoComplete === true ? true : this.isUseDataSet; if(DU.isUndefined(config.isAddEmptyText) == false) config.isEmptyText = config.isAddEmptyText; DU.widget.LTextBox.superclass.constructor.call(this, config); if(this.isUseDataSet === true) { if(DU.isEmpty(this.dataSet) && DU.isEmpty(config.dataSet)) { this.createDataSet(); } } if (this.isUseDataSet === true) { if(this.dataSet) this.initDataSet(); if(config.url) { this.dataSet.load({ url: config.url }); } } /** * @description keydown 기능이 호출되면 수행하는 이벤트 * @event keydown */ this.keydownEvent = this.createEvent('keydown'); /** * @description keyup 기능이 호출되면 수행하는 이벤트 * @event keyup */ this.keyupEvent = this.createEvent('keyup'); /** * @description keypress 기능이 호출되면 수행하는 이벤트 * @event keypress */ this.keypressEvent = this.createEvent('keypress'); /** * @description cut 기능이 호출되면 수행하는 이벤트 * @event keypress */ this.cutEvent = this.createEvent('cut'); /** * @description copy 기능이 호출되면 수행하는 이벤트 * @event keypress */ this.copyEvent = this.createEvent('copy'); /** * @description paste 기능이 호출되면 수행하는 이벤트 * @event keypress */ this.pasteEvent = this.createEvent('paste'); /** * @description expand 기능이 호출되면 수행하는 이벤트 * @event expand */ this.createEvent('expand'); /** * @description collapse 기능이 호출되면 수행하는 이벤트 * @event collapse */ this.createEvent('collapse'); /** * @description changed 메소드가 호출되면 수행하는 이벤트 * @event changed * @param {Object} target this객체 * @param {String} value code값 * @param {String} displayValue displayValue값 */ } DU.extend(DU.widget.LTextBox, DU.widget.LField, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LTextBox', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-textbox', /** * @description placeholder CSS명 * @property CSS_PLACEHOLDER * @private * @type {String} */ CSS_PLACEHOLDER : 'L-placeholder', /** * @description type 종류 * text, password, email, url * @config type * @type {String} * @default true */ /** * @description type 종류 * text, password, email, url * @property type * @private * @type {String} */ type : 'text', /** * @description edit 가능 여부 *

Sample: 보기

* @config editable * @type {Boolean} * @default true */ /** * @description edit 가능 여부 * @property editable * @private * @type {Boolean} */ editable : true, /** * @description 가로 길이 *

Sample: 보기

* @config width * @type {Int} * @default 100 */ /** * @description 가로 길이 * @property width * @private * @type {String} */ width : 100, /** * @description 세로 길이 *

Sample: 보기

* @config height * @type {Int} * @default -1 */ /** * @description 세로 길이 * @property height * @private * @type {Int} */ height : -1, /** * @description 목록창의 가로 길이 *

Sample: 보기

* @config listWidth * @type {Int} * @default 200 */ /** * @description 목록창의 가로 길이 * @property listWidth * @private * @type {Int} */ listWidth : 200, /** * @description 기본 DataSet객체명, du_config.js에 따라 적용된다. * @property dataSetClassName * @private * @type {String} */ dataSetClassName : 'DU.data.LJsonDataSet', /** * @description filter시 메모리의 데이터로 처리할지 서버에서 load할지를 결정 *

Sample: 보기

* @config filterMode * @type {String} * @default 'local' */ /** * @description filter시 메모리의 데이터로 처리할지 서버에서 load할지를 결정 * @property filterMode * @private * @type {String} */ filterMode : 'local', /** * @description local filter시 delayTime값 *

Sample: 보기

* @config localDelayTime * @type {Int} * @default 30 */ /** * @description local filter시 delayTime값 * @property localDelayTime * @private * @type {Int} */ localDelayTime : 30, /** * @description remote filter시 delayTime값 *

Sample: 보기

* @config remoteDelayTime * @type {Int} * @default 250 */ /** * @description remote filter시 delayTime값 * @property remoteDelayTime * @private * @type {Int} */ remoteDelayTime : 250, /** * @description remote filter시 url값 *

Sample: 보기

* @config filterUrl * @type {String} * @default '' */ /** * @description remote filter시 url값 *

Sample: 보기

* @property filterUrl * @private * @type {String} */ filterUrl : '', /** * @description dataSet 사용 여부 *

Sample: 보기

* @config isUseDataSet * @type {Boolean} * @default false */ /** * @description dataSet 사용 여부 * @property isUseDataSet * @private * @type {Boolean} */ isUseDataSet : false, /** * @description 자동 완성 기능 사용 여부 *

Sample: 보기

* @config isAutoComplete * @type {Boolean} * @default false */ /** * @description 자동 완성 기능 사용 여부 * @property isAutoComplete * @private * @type {Boolean} */ isAutoComplete : false, /** * @description 자동 완성 기능을 정보를 가지는 dataSet * @config dataSet * @type {DU.data.LDataSet} * @default null */ /** * @description 자동 완성 기능을 정보를 가지는 dataSet * @property dataSet * @private * @type {DU.data.LDataSet} */ dataSet : null, /** * @description 입력 가능한 문자열 * @config allowChars * @type {String} * @default null */ /** * @description 입력 가능한 문자열 * @property allowChars * @private * @type {String} */ allowChars : null, /** * @description ime-mode값 * @config imeMode * @type {boolean} * @default true */ /** * @description ime-mode값 * @property imeMode * @private * @type {boolean} */ imeMode: true, /** * @description 기본 '선택하세요.' 메시지 값 *

Sample: 보기

* @config emptyText * @type {String} * @default Choose a state */ /** * @description 기본 '선택하세요.' 메시지 값 * @property emptyText * @private * @type {String} */ emptyText: 'Choose a state', /** * @description 기본 선택 항목 추가 여부 *

Sample: 보기

* @config isEmptyText * @type {Boolean} * @default false */ /** * @description 기본 선택 항목 추가 여부 * @property isEmptyText * @private * @type {Boolean} */ isEmptyText : false, /** * @description mask 적용 * @config mask * @type {String} * @default null */ /** * @description mask 적용 * new DU.form.LTextBox({ mask: '999999-9999999' }); * @property mask * @private * @type {String} */ mask: null, /** * @description getValue시 적용된 mask값으로 리턴할지 여부 * @config isMaskValue * @type {Boolean} * @default false */ /** * @description 기본 선택 항목 추가 여부 * mask가 적용된 값 111-11-111111 * isMaskValue가 true 일경우 getValue()는 111-11-111111 값으로 리턴 * isMaskValue가 false 일경우 getValue()는 11111111111 값으로 리턴 * @property isMaskValue * @private * @type {Boolean} */ isMaskValue: false, /** * @description mask의 형식 정의 * @config definitions * @type {String} * @default { '9': "[0-9]", 'a': "[A-Za-z]", '*': "[A-Za-z0-9]" } */ /** * @description mask의 형식 정의 * @property definitions * @private * @type {String} */ definitions: { '9': "[0-9]", 'a': "[A-Za-z]", '*': "[A-Za-z0-9]" }, /** * @description mask가 적용된 값 입력시에 나오는 문자 * @config maskPlaceholder * @type {String} * @default '_' */ /** * @description mask가 적용된 값 입력시에 나오는 문자 * @property maskPlaceholder * @private * @type {String} */ maskPlaceholder: '_', /** * @description html5에 있는 placeholder 기능 * @config placeholder * @type {String} * @default null */ /** * @description mask가 적용된 값 입력시에 나오는 문자 * @property placeholder * @private * @type {String} */ placeholder: null, /** * @description invalid focus 여부 * @config invalidBlur * @type {boolean} * @default false */ /** * @description invalid시 blur를 할 수 있을지 여부 * @property invalidBlur * @private * @type {boolean} */ invalidBlur: false, /** * @description option div 객체 * @property optionDivEl * @private * @type {LElement} */ optionDivEl: null, /** * @description 목록이 펼쳐질 경우 출력할 갯수 * @config expandCount * @type {int} * @default 20 */ /** * @description 목록이 펼쳐질 경우 출력할 갯수 * @property expandCount * @private * @type {int} */ expandCount: 20, isStringFromChatCode: false, /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LTextBox.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LTextBox.superclass.initDefaultConfig.call(this); this.cfg.addProperty("editable", { handler: this._setEditable, value: this.editable, validator: DU.isBoolean }); this.cfg.addProperty("listWidth", { handler: this._setListWidth, value: this.listWidth, validator: DU.isNumber }); this.cfg.addProperty("isEmptyText", { handler: this._setAddEmptyText, value: this.isEmptyText, validator: DU.isBoolean }); }, /** * @description element Dom객체 생성 * @method createContainer * @protected * @param {HTMLElement} parentNode 부모 노드 * @return {HTMLElement} */ createContainer : function(parentNode) { if(this.el) { if(this.el.dom.tagName == 'INPUT') { this.id = this.id || this.el.id; this.oldDom = this.el.dom; this.name = this.name || this.oldDom.name; var parent = this.el.parent(); this.el = DU.get(this.createElement().cloneNode(false)); this.el.dom.id = this.id; Dom.replaceChild(parent.dom, this.el.dom, this.oldDom); this.el.appendChild(this.oldDom); Dom.removeNode(this.oldDom); delete this.oldDom; } } DU.widget.LTextBox.superclass.createContainer.call(this, parentNode); }, /** * @description render시 발생하는 메소드 * @method doRender * @protected * @param {HttpElement} appendToNode 부모 객체 * @return {void} */ doRender : function(container) { this.createTemplete(this.el); }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LTextBox.superclass.afterRender.call(this, container); var inputEl = this.getDisplayEl(); inputEl.on('click', function(e) { if(this.editable != true) this.expand(); }, this, true); inputEl.on('keydown', this.onFilterKey, this, true); /* if(DU.browser.webkit || DU.browser.msie) inputEl.on('keydown', this.onFilterKey, this, true); else inputEl.on('keypress', this.onFilterKey, this, true); */ if((this.allowChars != null && this.allowChars != '') || (this.imeMode === false)) inputEl.setStyle('ime-mode', 'disabled'); inputEl.on('keydown', this.onSpecialkeyEvent, this, true); inputEl.on('keydown', this.onKeydown, this, true); inputEl.on('keyup', this.onKeyup, this, true); inputEl.on('keypress', this.onKeypress, this, true); var keyEventName = DU.browser.msie || (DU.browser.safari && DU.browser.version == 3) ? "keydown" : "keypress"; inputEl.on(keyEventName, this.onKeyAutoComplete, this, true); inputEl.on(keyEventName, this.onFireKey, this, true); this.createOptionDiv(); if (this.optionDivEl) { if(this.isUseDataSet === true && DU.isEmpty(this.dataSet)) this.createDataSet(); this.doLoadDataSet(); } this.initFocus(); if(this.type != 'text') this.initType(); if(this.mask) this.initMask(); this.addPlaceholder(); }, createDataSet: function() { this.dataSet = new (eval(this.dataSetClassName))({ id: 'dataSet', fields:[ {id:this.displayField} ], focusFirstRow : false }) }, /** * @description type에 따른 기능 초기화 * @method initType * @protected * @return {void} */ initType: function() { if (this.type == 'url') { this.placeholder = 'http://'; this.inputEl.on('focus', function(){ if (this.inputEl.getValue() == '') this.inputEl.setValue(this.placeholder); }, this, true); } else if(this.type == 'email') { this.placeholder = DU.getMessageManager().get('$.base.msg111'); } }, /** * @description dataset을 초기화한다. * @method initDataSet * @protected * @return {void} */ initDataSet: function() { this.doSyncDataSet(); }, /** * @description dataSet의 sync 적용 메소드 * @method doSyncDataSet * @protected * @return void */ doSyncDataSet: function() { this.dataSet.on('beforeLoad', this.onBeforeLoadDataSet, this, true); this.dataSet.on('load', this.onLoadDataSet, this, true); this.dataSet.on('dataChanged', this.onDataChangedDataSet, this, true); this.dataSet.on('rowPosChanged', this.onRowPosChangedDataSet, this, true); this.dataSet.on("add", this.onAddData, this, true); this.dataSet.on("update", this.onUpdateData, this, true); this.dataSet.on("remove", this.onRemoveData, this, true); this.dataSet.on("undo", this.onUndoData, this, true); }, /** * @description dataSet의 unsync 적용 메소드 * @method doUnSyncDataSet * @protected * @return void */ doUnSyncDataSet: function(){ this.dataSet.unOn('beforeLoad', this.onBeforeLoadDataSet, this); this.dataSet.unOn('load', this.onLoadDataSet, this); this.dataSet.unOn('dataChanged', this.onDataChangedDataSet, this); this.dataSet.unOn('rowPosChanged', this.onRowPosChangedDataSet, this); this.dataSet.unOn("add", this.onAddData, this); this.dataSet.unOn("update", this.onUpdateData, this); this.dataSet.unOn("remove", this.onRemoveData, this); this.dataSet.unOn("undo", this.onUndoData, this); }, /** * @description container안의 content의 focus/blur 연결 설정 * @method initFocus * @protected * @return {void} */ initFocus: function() { var inputEl = this.getDisplayEl(); if(inputEl) { inputEl.on('focus', this.onCheckFocus, this, true); if(!this.isCheckContainBlur) { inputEl.on('blur', this.onBlur, this, true); } } }, /** * @description placeholder를 추가하는 메소드 * @method addPlaceholder * @protected * @return {void} */ addPlaceholder: function() { if(this.placeholder && this.getValue() == '') { this.setDisplayValue(this.placeholder); this.getDisplayEl().addClass(this.CSS_PLACEHOLDER); } }, /** * @description placeholder를 제거하는 메소드 * @method removePlaceholder * @protected * @return {void} */ removePlaceholder: function() { if (this.placeholder && this.getDisplayValue() == this.placeholder) { this.setDisplayValue(''); } this.getDisplayEl().removeClass(this.CSS_PLACEHOLDER); }, /** * @description 키 입력시 filter되는 메소드 * @method onFilterKey * @protected * @param {Object} e Event 객체 * @return {void} */ onFilterKey : function(e) { if(this.allowChars == null || this.allowChars == '') return true; var KEY = DU.util.LKeyListener.KEY; if(e.keyCode != KEY.SPACE && (DU.util.LEvent.isSpecialKey(e) || e.keyCode == KEY.BACKSPACE || e.keyCode == KEY.DELETE)) return; var c = e.charCode || e.keyCode; var charCode = null; charCode = (this.isStringFromChatCode === false) ? this.fromCharCode(c) : String.fromCharCode(c); var charCode = this.fromCharCode(c); if(this.allowChars.indexOf(charCode) === -1){ DU.util.LEvent.stopEvent(e); e.returnValue = false; } }, fromCharCode: function(c) { if(c >= 96 && c <= 105) c -= 48; var charCode = String.fromCharCode(c); switch(c) { case 105: break; case 106: charCode = '*'; break; case 107: charCode = '+'; break; case 109: charCode = '-'; break; case 110: charCode = '.'; break; case 111: charCode = '/'; break; case 190: charCode = '.'; break; case 191: charCode = '/'; break; } return charCode; }, /** * @description focus 이벤트 발생시 호출되는 메소드 * @method onFocus * @private * @param {Object} e Event 객체 * @return void */ onFocus : function(e) { DU.widget.LTextBox.superclass.onFocus.call(this, e); this.lastValue = this.getValue(); this.lastDisplayValue = this.getDisplayValue(); this.removePlaceholder(); this.doFocus(e); }, /** * @description focus 이벤트 발생시 호출되는 메소드, design 관련 * @method doFocus * @protected * @param {Object} e Event 객체 * @return void */ doFocus : function(e){ try { this.getDisplayEl().dom.select(); } catch(e) {} }, /** * @description blur 이벤트 발생시 defer를 연결하는 메소드 * @method deferOnBlur * @protected * @param {Object} e Event 객체 * @return {void} */ deferOnBlur : function(e) { var checkBlur = function(e) { if(e.deferCancelBubble == true) return; var target = e.target; if(this.iconDivEl && this.iconDivEl.dom == target) return; var isBlur = false; if(DU.isUndefined(this.optionDivEl)) { if(!this.el.isAncestor(target)) isBlur = true; } else { if(this.el.isAncestor(target) == false) { if(this.optionDivEl) { if((this.optionDivEl.dom !== target && !this.optionDivEl.isAncestor(target))) isBlur = true; } else isBlur = true; } } if(isBlur == true) { if(this.canBlur(e) === false) { this.focus(); return; } DU.util.LEvent.removeListener(DU.browser.msie ? document.body : document, "mousedown", this.deferOnBlurDelegate, this); this.onBlur.call(this, e); this.isFocus = null; } else { e.deferCancelBubble = true; } } DU.util.LFunction.defer(checkBlur, 10, this, [e]); }, /** * @description blur 이벤트 발생시 호출되는 메소드 * @method canBlur * @private * @param {Object} e Event 객체 * @return void */ canBlur: function(e) { var displayValue = this.getDisplayEl().getValue(); if (this.lastDisplayValue != displayValue && this.validateValue(displayValue) == false) { if(this.invalidBlur !== true) return false; this.setValue(this.lastValue); this.setDisplayValue(this.lastDisplayValue); } }, /** * @description blur 이벤트 발생시 호출되는 메소드 * @method onBlur * @private * @param {Object} e Event 객체 * @return void */ onBlur : function(e) { if(this.isExpand()) this.collapse(); if(DU.isUndefined(this.lastDisplayValue) == false && this.lastDisplayValue != this.getDisplayValue()) this.doChangedDisplayValue(this.getDisplayValue()); DU.widget.LTextBox.superclass.onBlur.call(this, e); this.addPlaceholder(); }, /** * @description 출력데이터가 변경되면 호출되는 메소드 * @method doChangedDisplayValue * @private * @param {String} o 적용할 값 * @return void */ doChangedDisplayValue : function(o) { this.setValue(o); }, /** * @description 객체를 destroy하는 메소드 *

Sample: 보기

* @method destroy * @public * @return void */ destroy : function() { if(this.dataSet) this.doUnSyncDataSet(); var displayEl = this.getDisplayEl(); displayEl.unOnAll(); if (this.optionDivEl) { this.optionDivEl.unOnAll(); this.optionDivEl = null; } DU.widget.LTextBox.superclass.destroy.call(this); }, /** * @description Dom객체 생성 * @method createTemplete * @private * @param {String|Object} el 객체의 아이디나 객체 * @return {DU.LElement} Element 객체 */ createTemplete : function(el) { var elContainer = DU.get(el); elContainer.addClass(this.CSS_BASE); elContainer.addClass("L-fixed"); var input = document.createElement('input'); input.name = this.name || this.id; input.type = this.type; input.instance = this; elContainer.appendChild(input); this.inputEl = DU.get(input); return elContainer; }, /** * @description width 속성에 따른 실제 적용 메소드 * @method _setWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setWidth : function(type, args, obj) { var width = args[0]; this.el.setWidth(width); this.getDisplayEl().setWidth(width); this.width = width; this.cfg.setProperty('width', width, true); }, /** * @description height 속성에 따른 실제 적용 메소드 * @method _setHeight * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setHeight : function(type, args, obj) { var height = args[0]; if(height < 0) return; this.el.setHeight(height); this.getDisplayEl().setHeight(height); if(DU.browser.msie) this.getDisplayEl().setStyle('line-height', height + 'px'); this.height = height; }, /** * @description listWidth 속성에 따른 실제 적용 메소드 * @method _setListWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setListWidth : function(type, args, obj) { this.optionDivEl ? this.optionDivEl.setWidth(this.listWidth) : null; this.listWidth = args[0]; }, /** * @description width 값을 셋팅하는 메소드 *

Sample: 보기

* @method setWidth * @public * @param {Int} w width 값 * @return void */ setWidth : function(w) { this.cfg.setProperty("width", w); }, /** * @description width 값을 리턴하는 메소드 *

Sample: 보기

* @method getWidth * @public * @return {Int} width 값 */ getWidth : function() { return this.cfg.getProperty("width"); }, /** * @description listWidth 값을 셋팅하는 메소드 * @method listWidth * @param {Int} w width 값 * @return void */ setListWidth : function(w) { this.cfg.setProperty("listWidth", w); }, /** * @description listWidth 값을 리턴하는 메소드 * @method getWidth * @public * @return {Int} width 값 */ getListWidth : function() { return this.cfg.getProperty("listWidth"); }, /** * @description AddEmptyText 속성에 따른 실제 적용 메소드 * @method _setAddEmptyText * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setAddEmptyText : function(type, args, obj) { if(!this.optionDivEl) return; if(args[0] == true && this.hasEmptyText() == false) this.createEmptyText(); else this.removeEmptyText(); }, /** * @description isEmptyText 값을 변경하는 메소드 * @method setAddEmptyText * @public * @param {Boolean} isEmptyText 변경하고자 하는 값 * @return {void} */ setAddEmptyText : function(isEmptyText) { this.cfg.setProperty('isEmptyText', isEmptyText); }, /** * @description isEmptyText 값을 리턴하는 메소드 * @method getAddEmptyText * @public * @return {Boolean} */ getAddEmptyText : function() { return this.cfg.getProperty("isEmptyText"); }, /** * @description height 값을 셋팅하는 메소드 *

Sample: 보기

* @method setHeight * @public * @param {String} w height 값 * @return void */ setHeight : function(h) { this.cfg.setProperty("height", h); }, /** * @description height 값을 리턴하는 메소드 *

Sample: 보기

* @method getHeight * @public * @return {String} height 값 */ getHeight : function() { return this.cfg.getProperty("height"); }, /** * @description disabled 속성에 따른 실제 적용 메소드 * @method _setDisabled * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setDisabled : function(type, args, obj) { args = args[0]; if(args === false) { this.disabled = false; this.getDisplayEl().enable(); } else { this.disabled = true; this.getDisplayEl().disable(); } }, /** * @description editable 값을 셋팅하는 메소드 *

Sample: 보기

* @method setEditable * @public * @param {Boolean} isEditable editable 셋팅 값 * @return void */ setEditable : function(isEditable) { this.cfg.setProperty("editable", isEditable); }, /** * @description editable 속성에 따른 실제 적용 메소드 * @method _setEditable * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setEditable : function(type, args, obj) { args = args[0]; if (args === false) { this.getDisplayEl().dom.readOnly = true; } else { this.getDisplayEl().dom.readOnly = false; } }, /** * @description 화면 출력되는 객체 리턴 * @method getDisplayEl * @protected * @return {DU.LElement} Element 객체 */ getDisplayEl : function() { return this.inputEl || this.el; }, /** * @description Tries to focus the element. Any exceptions are caught and ignored. *

Sample: 보기

* @method focus * @public * @return {void} */ focus : function() { var displayEl = this.getDisplayEl(); displayEl.focus(); }, /** * @description Tries to blur the element. Any exceptions are caught and ignored. *

Sample: 보기

* @method blur * @public * @return {void} */ blur : function() { this.getDisplayEl().blur(); }, /** * @description 객체를 유효여부를 확인하는 메소드 *

Sample: 보기

* @method isValid * @public * @return {void} */ isValid : function() { return this.getDisplayEl().isValid(); }, /** * @description 객체를 유효한 상태로 설정하는 메소드 *

Sample: 보기

* @method valid * @public * @return {void} */ valid : function(){ this.getDisplayEl().valid(); this.validEvent.fire(); }, /** * @description 객체를 유효하지 않은 상태로 설정하는 메소드 *

Sample: 보기

* @method invalid * @public * @return {void} */ invalid : function(message) { this.getDisplayEl().invalid(message); this.invalidEvent.fire(message); }, /** * @description Keyup 이벤트가 발생하면 처리하는 메소드 * @method onKeyup * @private * @param {Object} e Event 객체 * @return {void} */ onKeyup : function(e) { this.keyupEvent.fire(e); }, /** * @description Keydown 이벤트가 발생하면 처리하는 메소드 * @method onKeydown * @private * @param {Object} e Event 객체 * @return {void} */ onKeydown : function(e){ this.keydownEvent.fire(e); }, /** * @description Keypress 이벤트가 발생하면 처리하는 메소드 * @method onKeypress * @private * @param {Object} e Event 객체 * @return {void} */ onKeypress : function(e) { this.keypressEvent.fire(e); }, /** * @description copy, cut, paste 같은 특별한 이벤트 기능 연결 메소드 * @method onSpecialkeyEvent * @private * @param {Object} e Event 객체 * @return {void} */ onSpecialkeyEvent : function(e) { if(this.isCheckContainBlur === true) { if (e.keyCode == DU.util.LKeyListener.KEY.TAB) { if (this.canBlur(e) == false) { this.focus(); return false; } } } if (e.ctrlKey && String.fromCharCode(e.keyCode) == "X") { this.cutEvent.fire(e); } else if (e.ctrlKey && String.fromCharCode(e.keyCode) == "C") { this.copyEvent.fire(e); } else if (e.ctrlKey && String.fromCharCode(e.keyCode) == "V") { this.pasteEvent.fire(e); } }, /** * @description autocomplete 기능을 수항하는 메소드 * @method onKeyAutoComplete * @private * @param {Object} e Event 객체 * @return {void} */ onKeyAutoComplete : function(e) { if (this.isUseDataSet === true && this.isAutoComplete === true) { this.doKeyMove(e); this.doKeyInput(e); } }, /** * @description 키 입력에 따른 이동 이벤트를 처리하는 메소드 * @method doKeyMove * @private * @param {Object} e Event 객체 * @return {void} */ doKeyMove : function(e) { var k = DU.util.LKeyListener.KEY; switch (e.keyCode) { case k.ENTER: var activeItem = this.getActive(); if(activeItem != null) { this.doChangedItem(activeItem.dom); } this.collapse(); break; case k.DOWN: this.expand(); this.nextActive(); break; case k.UP: DU.util.LEvent.stopPropagation(e); this.expand(); this.prevActive(); break; case k.ESCAPE: this.collapse(); break; default: break; } }, /** * @description 키 입력에 따른 filter를 처리하는 메소드 * @method doKeyInput * @private * @param {Object} e Event 객체 * @return {void} */ doKeyInput : function(e) { this.isForceCheck = false; if(DU.util.LKeyListener.KEY.ENTER == e.keyCode) e.preventDefault(); if (DU.util.LKeyListener.KEY.TAB == e.keyCode) this.collapse(); var k = DU.util.LKeyListener.KEY; switch (e.keyCode) { case k.ENTER: case k.DOWN: case k.UP: case k.ESCAPE: break; default: this.lastValue = this.getDisplayEl().getValue(); if(this.filterTask) return; if(e.altKey == true|| e.ctrlKey == true) return; this.expand(); if(this.isAutoComplete == true) { this.filterTask = new DU.util.LDelayedTask(DU.util.LFunction.createDelegate(this.doFilter, this)); this.filterTask.delay(this.filterMode == 'remove' ? this.remoteDelayTime : this.localDelayTime); } break; } }, /** * @description filter시 처리하는 메소드 * @method doFilter * @private * @param {Object} e Event 객체 * @return {void} */ doFilter : function(e){ this.filterTask.cancel(); this.filterTask = null; this.filter(this.getDisplayEl().getValue()); }, /** * @description list를 출력하는 메소드 * @method expand * @protected * @return {void} */ expand : function() { if(this.disabled === true) return; if(this.isLoad !== true) this.doLoadDataSet(); if(this.optionDivEl && this.optionDivEl.hasClass('L-hide-display')) { this.doExpand(); if(this.getActiveIndex() < 0) this.firstActive(); this.getDisplayEl().dom.focus(); } }, /** * @description option div 객체 생성 * @method createOptionDiv * @protected * @return {void} */ createOptionDiv : function() { if(this.isUseDataSet === true) { var inputEl = this.getDisplayEl(); var optionDiv = document.createElement('div'); optionDiv.id = DU.id(); this.optionDivEl = DU.get(optionDiv); this.optionDivEl.setWidth(this.listWidth); this.optionDivEl.addClass(this.CSS_BASE + '-list-wrapper'); this.optionDivEl.addClass('L-hide-display'); this.optionDivEl.on('click', function(e) { inputEl.focus(); }); document.body.appendChild(optionDiv); } }, /** * @description option div에 해당되는 객체를 리턴한다. * @method getOptionDiv * @protected * @return {DU.LElement} */ getOptionDiv: function() { return this.optionDivEl; }, /** * @description 현재 활성화되어 있는 객체를 리턴 * @method getActive * @protected * @return {DU.LElement} */ getActive : function() { var activeList = this.optionDivEl.select('.active'); if(activeList.length < 1) return; return activeList.getAt(0); }, /** * @description 현재 활성화되어 있는 객체의 index를 리턴 * @method getActiveIndex * @protected * @return {Int} */ getActiveIndex : function() { var optionList = this.optionDivEl.select('div'); var idx = -1; for(var i = 0 ; i < optionList.length ; i++){ if(optionList.getAt(i).hasClass('active')) { idx = i; break; } } return idx; }, /** * @description 목록중에 h와 같은 html을 찾아 객체의 index를 리턴 * @method getDataIndex * @protected * @param {String} h 비교할 html 내용 * @return {Int} */ getDataIndex : function(h) { var optionList = this.optionDivEl.select('div'); var idx = -1; for(var i = 0 ; i < optionList.length ; i++){ if(optionList.getAt(i).dom.firstChild.nodeValue == h) { idx = i; break; } } if(idx > -1 && this.isEmptyText === true) idx--; return idx; }, /** * @description 목록중에 첫번째를 활성화하는 메소드 * @method firstActive * @protected * @return {void} */ firstActive : function() { var firstChildElList = this.optionDivEl.select(':first-child'); if(firstChildElList.length > 0) firstChildElList.getAt(0).addClass('active'); }, /** * @description 다음 목록을 활성화하는 메소드 * @method nextActive * @protected * @return {void} */ nextActive : function(){ var activeEl = this.getActive(); if(activeEl == null) { this.firstActive(); } else { var nextDom = Dom.getNextSibling(activeEl.dom); if(nextDom == null) return; var nextEl = DU.get(nextDom); activeEl.removeClass('active'); nextEl.addClass('active'); this.scrollDown(); } }, /** * @description 이전 목록을 활성화하는 메소드 * @method prevActive * @protected * @return {void} */ prevActive : function() { var activeEl = this.getActive(); if(activeEl == null) { this.firstActive(); } else { var prevDom = Dom.getPreviousSibling(activeEl.dom); if(prevDom == null) return; var prevEl = DU.get(prevDom); activeEl.removeClass('active'); prevEl.addClass('active'); this.scrollUp(); } }, /** * @description 목록이 스크롤다운이 되게 하는 메소드 * @method scrollDown * @protected * @return {void} */ scrollDown : function() { if ("scroll" != this.optionDivEl.getStyle(this.overflowCSS)) return; var activeEl = this.getActive(); var activeIndex = this.getActiveIndex() + 1; var minScroll = activeIndex * activeEl.getHeight() - this.optionDivEl.getHeight(); if (this.optionDivEl.dom.scrollTop < minScroll) this.optionDivEl.dom.scrollTop = minScroll; }, /** * @description 목록이 스크롤업이 되게 하는 메소드 * @method scrollUp * @protected * @return {void} */ scrollUp : function() { if ("scroll" != this.optionDivEl.getStyle(this.overflowCSS)) return; var activeEl = this.getActive(); var maxScroll = this.getActiveIndex() * activeEl.getHeight(); if (this.optionDivEl.dom.scrollTop > maxScroll) this.optionDivEl.dom.scrollTop = maxScroll; }, /** * @description 목록을 펼치는 메소드 * @method doExpand * @protected * @return {void} */ doExpand : function() { this.optionDivEl.removeClass('L-hide-display'); this.optionDivEl.addClass('L-show-display'); var top = this.el.getTop() + this.el.getHeight() + this.el.getBorderWidth('tb') + this.el.getPadding('tb') + this.optionDivEl.getBorderWidth('tb') + this.optionDivEl.getPadding('tb'); // ie7에서 document.documentElement.getBoundingClientRect의 값이 이상하게 나와 -2값으로 처리. var marginTop = DU.browser.msie7 ? -2 : 0; var marginLeft = DU.browser.msie7 ? -2 : 0; this.optionDivEl.setTop(top + marginTop); var left = this.el.getLeft(); this.optionDivEl.setLeft(left + marginLeft); this.activeItem(); //DU.util.LEvent.addListener(document, 'mousewheel', this.collapseIfDelegate, this); DU.util.LEvent.addListener(document, 'mousedown', this.collapseIfDelegate, this); this.reOnDeferOnBlur(); var count = this.dataSet.getCount(); if(this.dataSet.getCount() > this.expandCount) count = this.expandCount; if(this.optionDivEl.dom.childNodes.length > 0) { var childEl = DU.get(this.optionDivEl.dom.childNodes[this.optionDivEl.dom.childNodes.length - 1]); var childViewCount = (count + (this.isEmptyText ? 1 : 0)); var height = (childEl.getHeight() * childViewCount) + childViewCount; if(height > 0) this.optionDivEl.setHeight(height); } else this.optionDivEl.setHeight(20); this.fireEvent("expand"); }, /** * @description 목록이 펼쳐저 있는지 여부 * @method isExpand * @return {Boolean} */ isExpand : function() { return this.optionDivEl && this.optionDivEl.hasClass('L-show-display'); }, /** * @description target과 비교하여 목록을 줄이는 메소드 * @method collapseIf * @protected * @param {Object} e Event 객체 * @return {void} */ collapseIf : function(e) { var target = e.target; if (((this.optionDivEl && this.optionDivEl.dom == target)) || ((this.iconDivEl && this.iconDivEl.dom == target)) || ((this.inputEl && this.inputEl.dom == target))) return; var targetEl = DU.get(target); if(targetEl.hasClass('L-list')) { targetEl.removeClass('active'); this.doChangedItem(e.target); } this.collapse(); }, /** * @description 목록을 줄이는 메소드 * @method collapse * @protected * @return {void} */ collapse : function() { this.optionDivEl.removeClass('L-show-display'); this.optionDivEl.addClass('L-hide-display'); //DU.util.LEvent.removeListener(document, 'mousewheel', this.collapseIfDelegate, this); DU.util.LEvent.removeListener(document, 'mousedown', this.collapseIfDelegate, this); this.getDisplayEl().focus(); this.fireEvent("collapse"); this.optionDivEl.select('.active').removeClass('active'); }, /** * @description 현재 값에 맞는 목록을 활성화하는 메소드 * @method activeItem * @protected * @return {void} */ activeItem : function() { this.isForceCheck = false; var value = this.getDisplayEl().getValue(); if(value == '') return; var listElList = this.optionDivEl.select('.L-list'); var thisObj = this; listElList.each(function(child){ if(child.dom.firstChild.nodeValue == value) { child.addClass('active'); thisObj.scrollDown(); return false; } }); }, /** * @description 데이터셋이 Load 메소드가 호출되면 수행하는 이벤트 메소드 * @method doLoadDataSet * @private * @param {Object} e event 객체 * @return {void} */ doLoadDataSet: function() { if(this.optionDivEl) { this.onDataChangedDataSet(); this.focusDefaultValue(); } }, /** * @description 데이터셋이 beforeLoad 메소드가 호출되면 수행하는 이벤트 메소드 * @method onBeforeLoadDataSet * @private * @param {Object} e event 객체 * @return {void} */ onBeforeLoadDataSet: function(e) { this.dataSet.setRow(-1); }, /** * @description 데이터셋이 Load 메소드가 호출되면 수행하는 이벤트 메소드 * @method onLoadDataSet * @private * @return {void} */ onLoadDataSet : function(e) { this.doLoadDataSet(); this.isLoad = true; }, /** * @description 기본 값을 셋팅하는 메소드 * @method focusDefaultValue * @private * @return {void} */ focusDefaultValue : function() { this.setValue(this.defaultValue); }, /** * @description 목록에서 선택되면 출력객체에 값을 반영하는 메소드 * @method doChangedItem * @private * @param {HTMLElement} dom Dom 객체 * @return {void} */ doChangedItem : function(dom) { if(dom.innerHTML) { this.setValue(dom.childNodes[0].nodeValue); this.getDisplayEl().focus(); } }, /** * @description 데이터셋이 RowPosChanged 메소드가 호출되면 수행하는 이벤트 메소드 * @method onRowPosChangedDataSet * @private * @return {void} */ onRowPosChangedDataSet : function(e) { }, /** * @description 데이터셋이 add 메소드가 호출되면 수행하는 이벤트 메소드 * @method onAddData * @private * @return {void} */ onAddData : function(e) { var row = e.row, record = e.record, dataSet = e.target; var optionEl = this.createItem({ record : this.dataSet.getAt(row) }); if(dataSet.getCount(true) > 1) { var beforeRow = row - 1; if(beforeRow < 0) { var nextRow = row + 1; var nextRowEl = this.getRowEl(nextRow); if(nextRowEl == null) return; nextRowEl.insertBefore(optionEl.dom); } else { var beforeRowEl = this.getRowEl(beforeRow); if(beforeRowEl == null) return; beforeRowEl.insertAfter(optionEl.dom); } } else { this.getOptionDiv().appendChild(optionEl.dom); } }, /** * @description 데이터셋이 update 메소드가 호출되면 수행하는 이벤트 메소드 * @method onUpdateData * @private * @return {void} */ onUpdateData : function(e) { var row = e.row, col = e.col, colId = e.colId, record = e.record, dataSet = e.target; var currentRowEl = this.getRowEl(row); if(currentRowEl) { var optionEl = this.createItem({ record : this.dataSet.getAt(row) }); currentRowEl.html(optionEl.getHtml()); } }, /** * @description 데이터셋이 remove 메소드가 호출되면 수행하는 이벤트 메소드 * @method onRemoveData * @private * @return {void} */ onRemoveData : function(e) { var row = e.row, record = e.record, dataSet = e.target; var currentRowEl = this.getRowEl(row); (currentRowEl != null) ? currentRowEl.remove() : ''; }, /** * @description 데이터셋이 undo 메소드가 호출되면 수행하는 이벤트 메소드 * @method onUndoData * @private * @return {void} */ onUndoData : function(e) { var state = e.beforeState, row = e.row, record = e.record, dataSet = e.target; if(state == DU.data.LRecord.STATE_INSERT) { this.onRemoveData(e); } }, /** * @description 데이터셋이 DataChanged 메소드가 호출되면 수행하는 메소드 * @method onDataChangedDataSet * @private * @return {void} */ onDataChangedDataSet : function(e) { this.removeAllItem(); if(this.isEmptyText === true) this.createEmptyText(); if(this.optionDivEl) { for(var i = 0 ; i < this.dataSet.getCount() ; i++) { var optionEl = this.createItem({ record : this.dataSet.getAt(i) }); this.appendOption(optionEl.dom); } } }, /** * @description option 객체를 붙인다. * @method appendOption * @private * @param {HTMLElement} dom option dom 객체 * @return {void} */ appendOption: function(dom) { this.optionDivEl.appendChild(dom); }, /** * @description emptyText가 존재하는지 여부를 리턴한다. * @method hasEmptyText * @private * @return {Boolean} */ hasEmptyText : function() { if(!this.optionDivEl) return this.isEmptyText; if(this.optionDivEl.dom.childNodes.length < 1) return false; return Dom.hasClass(this.optionDivEl.dom.childNodes[0], 'L-empty'); }, /** * @description emptyText 항목을 생성한다. * @method createEmptyText * @private * @return {void} */ createEmptyText : function() { //if(this._rendered !== true) return; try { if(!this.el) return; var data = {}; data[this.valueField] = ''; data[this.displayField] = this.emptyText; var record = this.dataSet.createRecord(data); var optionEl = this.createItem({ record: record }); optionEl.addClass("L-empty"); this.insertEmptyText(optionEl.dom); } catch(e){} }, /** * @description emptyText 항목의 객체를 첫번째에 추가한다. * @method insertEmptyText * @private * @param {HTMLElement} dom option Dom 객체 * @return {void} */ insertEmptyText: function(dom) { if(this.optionDivEl.dom.childNodes.length > 0) Dom.insertBefore(dom, this.optionDivEl.dom.childNodes[0]); else this.optionDivEl.appendChild(dom); }, /** * @description emptyText 항목을 제거한다. * @method removeEmptyText * @private * @return {void} */ removeEmptyText : function() { if(this.hasEmptyText()) Dom.removeNode(this.optionDivEl.dom.childNodes[0]); }, /** * @description row에 해당되는 Element를 리턴하는 메소드 * @method getRowEl * @private * @return {DU.Element} */ getRowEl : function(row) { var rowElList = this.optionDivEl.select(".L-list"); return rowElList.length > 0 ? rowElList.getAt(row) : null; }, /** * @description 목록의 Item을 생성 * @method createItem * @private * @param {Object} e Event 객체 * @return {void} */ createItem : function(e) { var record = e.record; var displayValue = record.get(this.displayField); var option = document.createElement('div'); var optionEl = DU.get(option); var optionDivEl = this.optionDivEl; optionEl.hover(function(){ this.addClass('active'); }, function(){ optionDivEl.select('.active').removeClass('active'); }); optionEl.addClass('L-list'); var txtNode = document.createTextNode(displayValue); optionEl.appendChild(txtNode); return optionEl; }, /** * @description DataSet에 o객체를 추가하는 메소드 * @method add * @protected * @param {Object} o Record의 데이터 객체 * @param {Object} option Record의 생성시 option * @return {void} */ add : function(o, option){ var record = this.dataSet.createRecord(o, { id: this.dataSet.getNewRecordId() }); this.dataSet.add(record, option); }, /** * @description DataSet에 배열로 o객체를 추가하는 메소드 * @method addAll * @protected * @param {Array} o Record의 데이터 객체 배열 * @param {Object} option Record의 생성시 option * @return {void} */ addAll : function(o, option) { for(var i = 0 ; i < o.length ; i++) { this.add(o[i], option); } }, /** * @description DataSet에 row 위치의 있는 o객체를 반영하는 메소드 * @method setData * @protected * @param {Int} row row의 위치 * @param {Object} o Record의 데이터 객체 * @return {void} */ setData : function(row, o) { if(row > this.dataSet.getCount() - 1 || row == 0) return; var record = this.dataSet.getAt(row); record.setValues(o); }, /** * @description Record객체 배력을 추가한다. * @method removeAt * @protected * @param {int} index 지우고자 하는 위치값 * @return void */ removeAt : function(row) { this.dataSet.removeAt(row); }, /** * @description 목록의 모든 item을 삭제한다. * @method removeAllItem * @protected * @return void */ removeAllItem : function(){ if(this.optionDivEl != null) this.optionDivEl.select('.L-list').remove(); }, /** * @description 데이터셋의 레코드 건수를 리턴한다. * @method getCount * @protected * @return {Int} 데이터셋의 레코드 건수 */ getCount : function(){ return this.dataSet.getCount(); }, /** * @description 값에 따라 filter 하는 메소드 * @method filter * @protected * @param {String} val filter시 비교하는 값 * @return {void} */ filter : function(val) { if(this.filterMode == 'remote') { var p = {}; p[this.displayField] = val; this.dataSet.load({ url:this.filterUrl, params:p }); } else { this.dataSet.filter(function(id, record) { var val2 = record.get(this.displayField); if(DU.util.LString.startsWith(val2.toLowerCase(), val.toLowerCase())) return true; }, this, false); } }, /** * @description DataSet에 적용된 filter를 지운다. *

Sample: 보기

* @method clearFilter * @public * @return {void} */ clearFilter : function(){ if(this.dataSet) this.dataSet.clearFilter(false); }, /** * @description 현재 값을 리턴 *

Sample: 보기

* @method getValue * @public * @return {String} 결과값 */ getValue : function() { var value = this.getDisplayEl().getValue(); if(this.mask && value != null && value != '' && this.isMaskValue == false) { value = this.getUnMaskValue(value); } return (value == this.placeholder) ? '' : value; }, /** * @description mask가 입력된 값을 mask를 제외한 값으로 리턴한다. * @method getUnMaskValue * @protected * @param {String} value 입력 값 * @return {String} 결과값 */ getUnMaskValue : function(value) { var realValue = []; var defs = this.definitions; DU.each(value.split(""), function(c,i){ if(this.tests[i] && this.tests[i].test(c)) { realValue.push(c); } }, this); return realValue.join(""); }, /** * @description 현재 값을 리턴 *

Sample: 보기

* @method getDisplayValue * @public * @return {String} 결과값 */ getDisplayValue : function() { return this.getDisplayEl().getValue(); }, /** * @description 출력객체에 내용을 변경한다. * @method setDisplayValue * @protected * @param {String} o 출력객체에 내용을 변경할 값 * @return void */ setDisplayValue : function(o) { this.getDisplayEl().setValue(o); }, /** * @description 값을 변경한다. *

Sample: 보기

* @method setValue * @public * @param {String} o 반영할 값 * @return {void} */ setValue : function(o) { if(DU.isUndefined(o) == true || this.lastValue == o) return; this.getDisplayEl().dom.value = o; var displayValue = this.checkVal().displayValue; this.getDisplayEl().dom.value = displayValue; this.lastDisplayValue = displayValue; this.fireEvent('changed', {target:this, value:this.getValue(), displayValue:this.getDisplayValue()}); this.lastValue = o; }, /** * @description dataset을 리턴한다. *

Sample: 보기

* @method getDataSet * @public * @return {DU.data.DataSet} */ getDataSet : function() { return this.dataSet; }, /** * @description dataset을 변경한다. * @method setDataSet * @public * @param {DU.data.LDataSet} newDataSet 신규 DataSet * @return {DU.data.DataSet} */ setDataSet: function(d) { this.dataSet = d; this.initDataSet(); this.onLoadDataSet(); }, /** * @description 키 입력시 호출되는 메소드 * @method onFireKey * @protected * @param {Object} e Event 객체 * @return {void} */ onFireKey : function(e){ if(DU.util.LEvent.isSpecialKey(e) && !this.isExpand()) this.fireEvent("specialkey", e); }, /** * @description mask 적용시 초기화 * @method initMask * @protected * @return {void} */ initMask: function() { var displayEl = this.getDisplayEl(); var displayDom = displayEl.dom; var defs = this.definitions; var tests = []; this.partialPosition = this.mask.length; this.firstNonMaskPos = null; this.maskLength = this.mask.length; DU.each(this.mask.split(""), function(c, i) { if (c == '?') { this.maskLength--; this.partialPosition = i; } else if (defs[c]) { tests.push(new RegExp(defs[c])); if(this.firstNonMaskPos==null) this.firstNonMaskPos = tests.length - 1; } else { tests.push(null); } }, this); this.tests = tests; this.buffer = []; DU.each(this.mask.split(""), function(c, i) { if (c != '?') this.buffer.push(defs[c] ? this.maskPlaceholder : c); }, this); if (!this.cfg.getProperty("disabled")) { this.on("focus", function() { focusText = this.getDisplayValue(); var pos = this.checkVal().pos; this.writeBuffer(); setTimeout(DU.util.LFunction.createDelegate(function() { if (pos == this.mask.length) this.setCaret(0, pos); else this.setCaret(pos); }, this), 0); }, this, true) this.on("blur", function() { this.setDisplayValue(this.checkVal().displayValue); }) this.on("keydown", this.onKeyDownMask, this, true); this.on("keypress", this.onKeyPressMask, this, true); this.on("paste", function(e) { setTimeout(DU.util.LFunction.createDelegate(function() { this.setCaret(this.checkVal(true).pos); }, this), 0); }, this, true); this.setDisplayValue(this.checkVal().displayValue); //Perform initial check for existing values } }, /** * @description 입력 input 객체에 select 지정 * @method setCaret * @protected * @param {Int} begin 처음 * @param {Int} end [optional] 마지막 * @return {void} */ setCaret: function(begin, end) { var displayEl = this.getDisplayEl(); var displayDom = displayEl.dom; end = (typeof end == 'number') ? end : begin; if (displayDom.setSelectionRange) { displayDom.focus(); displayDom.setSelectionRange(begin, end); } else if (displayDom.createTextRange) { var range = displayDom.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', begin); range.select(); } }, /** * @description select 범위 정보를 가지는 객체 리턴 * @method getCaret * @protected * @return {Object} */ getCaret: function() { var displayEl = this.getDisplayEl(); var displayDom = displayEl.dom; if (displayDom.setSelectionRange) { begin = displayDom.selectionStart; end = displayDom.selectionEnd; } else if (document.selection && document.selection.createRange) { var range = document.selection.createRange(); begin = 0 - range.duplicate().moveStart('character', -100000); end = begin + range.text.length; } return { begin: begin, end: end }; }, /** * @description buffer에 가지고 있는 정보를 지우는 메소드 * @method clearBuffer * @protected * @param {Int} start 시작 * @param {Int} end 끝 * @return {void} */ clearBuffer: function(start, end) { for (var i = start; i < end && i < this.maskLength; i++) { if (this.tests[i]) this.buffer[i] = this.maskPlaceholder; } }, /** * @description buffer에 가지고 있는 정보를 출력하는 객체에 적용하는 메소드 * @method writeBuffer * @protected * @return {void} */ writeBuffer: function() { return this.setDisplayValue(this.buffer.join('')); }, /** * @description mask 적용시 keydown 이벤트 * @method onKeyDownMask * @protected * @param {Object} e event 객체 * @return {void} */ onKeyDownMask: function(e) { var pos = this.getCaret(); var k = e.keyCode; this.ignore = (k < 16 || (k > 16 && k < 32) || (k > 32 && k < 41)); //delete selection before proceeding if ((pos.begin - pos.end) != 0 && (!this.ignore || k == 8 || k == 46)) this.clearBuffer(pos.begin, pos.end); //backspace, delete, and escape get special treatment if (k == 8 || k == 46 || (DU.browser.iPhone && k == 127)) {//backspace/delete this.shiftL(pos.begin + (k == 46 ? 0 : -1)); DU.util.LEvent.stopEvent(e); return false; } else if (k == 27) {//escape this.setDisplayValue(focusText); this.setCaret(0, this.checkVal().pos); DU.util.LEvent.stopEvent(e); return false; } }, /** * @description mask 적용시 keypress 이벤트 * @method onKeyPressMask * @protected * @param {Object} e event 객체 * @return {void} */ onKeyPressMask: function(e) { if (this.ignore) { this.ignore = false; //Fixes Mac FF bug on backspace return (e.keyCode == 8) ? false : null; } e = e || window.event; var k = e.charCode || e.keyCode || e.which; var pos = this.getCaret(); if (e.ctrlKey || e.altKey || e.metaKey) {//Ignore return true; } else if ((k >= 32 && k <= 125) || k > 186) {//typeable characters var p = this.seekNext(pos.begin - 1); if (p < this.maskLength) { var c = String.fromCharCode(k); if (this.tests[p].test(c)) { this.shiftR(p); this.buffer[p] = c; this.writeBuffer(); var next = this.seekNext(p); this.setCaret(next); /* * 이벤트 처리 할까? 오히려 성능 저하 및 소스가 꼬일 확율이 있어서리... if (this.completed && next == this.maskLength) this.completed.call(input); */ } } } DU.util.LEvent.stopEvent(e); return false; }, /** * @description mask 적용시 buffer값중 현재 위치가 찾기 * @method seekNext * @protected * @param {Int} pos mask의 현재 위치값 * @return {void} */ seekNext: function(pos) { while (++pos <= this.maskLength && !this.tests[pos]); return pos; }, /** * @description mask 적용시 buffer를 지정하는 위치를 왼쪽으로 이동 * @method shiftL * @protected * @param {Int} pos 이동할 값 * @return {void} */ shiftL: function(pos) { while (!this.tests[pos] && --pos >= 0); for (var i = pos; i < this.maskLength; i++) { if (this.tests[i]) { this.buffer[i] = this.maskPlaceholder; var j = this.seekNext(i); if (j < this.maskLength && this.tests[i].test(this.buffer[j])) { this.buffer[i] = this.buffer[j]; } else break; } } this.writeBuffer(); this.setCaret(Math.max(this.firstNonMaskPos, pos)); }, /** * @description mask 적용시 buffer를 지정하는 위치를 오른쪽으로 이동 * @method shiftR * @protected * @param {Int} pos 이동할 값 * @return {void} */ shiftR: function(pos) { for (var i = pos, c = this.maskPlaceholder; i < this.maskLength; i++) { if (this.tests[i]) { var j = this.seekNext(i); var t = this.buffer[i]; this.buffer[i] = c; if (j < this.maskLength && this.tests[j].test(t)) c = t; else break; } } }, /** * @description mask 적용시 입력값의 유효성을 검사하여 실제 값에 대입하는 메소드 * @method checkVal * @protected * @param {boolean} allow 이동할 값 * @return {Int} */ checkVal: function(allow) { var test = this.getDisplayValue(); var lastMatch = -1; for (var i = 0, pos = 0; i < this.maskLength; i++) { if (this.tests[i]) { this.buffer[i] = this.maskPlaceholder; while (pos++ < test.length) { var c = test.charAt(pos - 1); if (this.tests[i].test(c)) { this.buffer[i] = c; lastMatch = i; break; } } if (pos > test.length) break; } else if (this.buffer[i] == test[pos] && i!=this.partialPosition) { pos++; lastMatch = i; } } if (!allow && lastMatch + 1 < this.partialPosition) { test = ""; this.clearBuffer(0, this.maskLength); } else if (allow || lastMatch + 1 >= this.partialPosition) { this.writeBuffer(); if (!allow) { test = this.getDisplayValue().substring(0, lastMatch + 1); }; } return { pos : (this.partialPosition ? i : this.firstNonMaskPos), displayValue: test } }, /** * @description 입력된 값의 유효성 체크 * @method validateValue * @protected * @param {String} value 입력된 값 * @return {boolean} */ validateValue: function(value) { if(this.vm) { if(this.vm.validateEl(this) !== true) return false; } if (this.type == 'email' && this.getValue() != '') return new DU.validate.LEmailValidator({id: this.id}).validate(this.getValue()); return true; } }); })(); /** * Form * @module widget_form * @title LCombo * @requires DU */ DU.namespace("DU.widget"); (function(){ var Dom = DU.util.LDom; /** * LCombo * @namespace DU.widget * @class LCombo * @extends DU.widget.LTextBox * @constructor LCombo * @param {HTMLElement | String} id The html element that represents the Element. * @param {Object} oConfig The intial LCombo. */ DU.widget.LCombo = function(oConfig){ var config = oConfig || {}; this.overflowCSS = DU.browser.opera ? "overflow" : "overflowY"; config = Dom.applyIfProperties(config, '$.ext.combo'); /** * @description valueField 명 *

Sample: 보기

* @config valueField * @type {String} * @default 'code' */ /** * @description valueField 명 * @property valueField * @private * @type {String} */ this.valueField = config.valueField || DU.getConfig().getFirst('$.ext.combo.dataset.valueField'); /** * @description displayField 명 *

Sample: 보기

* @config displayField * @type {String} * @default 'value' */ /** * @description displayField 명 * @property displayField * @private * @type {String} */ this.displayField = config.displayField || DU.getConfig().getFirst('$.ext.combo.dataset.displayField'); this.emptyText = config.emptyText || this.emptyText; DU.widget.LCombo.superclass.constructor.call(this, config); this.dataSet.focusFirstRow = DU.isUndefined(this.focusFirstRow) == false ? this.focusFirstRow : false; } DU.extend(DU.widget.LCombo, DU.widget.LTextBox, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LCombo', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-combo', /** * @description 기본 emptyText 메시지 코드값 * @property emptyTextMessageCode * @private * @type {String} */ emptyTextMessageCode : '$.base.msg108', /** * @description 값이 비였을때 출력할 text값 *

Sample: 보기

* @config emptyText * @type {String} * @default '' */ /** * @description 값이 비였을때 출력할 text값 * @property emptyText * @private * @type {String} */ emptyText : null, /** * @description '선택하세요.' 항목 추가 여부 *

Sample: 보기

* @config isEmptyText * @type {Boolean} * @default true */ /** * @description '선택하세요.' 항목 추가 여부 * @property isEmptyText * @private * @type {Boolean} */ isEmptyText : true, /** * @description 선택 필수 여부 *

Sample: 보기

* @config forceSelection * @type {Boolean} * @default true */ /** * @description 선택 필수 여부 * @property forceSelection * @private * @type {Boolean} */ forceSelection : true, /** * @description 변경전 마지막 출력값 * @property lastDisplayValue * @private * @type {String} */ lastDisplayValue : '', /** * @description 값 변경 여부 * @property isChange * @private * @type {Boolean} */ isChange : false, /** * @description 기본 설정 값 *

Sample: 보기

* @config defaultValue * @type {String} * @default '' */ /** * @description 기본 설정 값 * @property defaultValue * @private * @type {String} */ defaultValue : '', /** * @description 데이터 로딩시 combo의 row 위치 *

Sample: 보기

* @config selectedIndex * @type {Int} * @default '' */ /** * @description 데이터 로딩시 combo의 row 위치 * @property selectedIndex * @private * @type {Int} */ selectedIndex : -1, /** * @description edit 가능 여부 *

Sample: 보기

* @config editable * @type {Boolean} * @default false */ /** * @description edit 가능 여부 * @property editable * @private * @type {Boolean} */ editable : false, /** * @description dataSet 사용 여부 *

Sample: 보기

* @config isUseDataSet * @type {Boolean} * @default true */ /** * @description dataSet 사용 여부 * @property isUseDataSet * @private * @type {Boolean} */ isUseDataSet : true, /** * @description item 선택시 row이동을 반드시 할 것인지여부 *

Sample: 보기

* @config isForceRow * @type {Boolean} * @default false */ /** * @description item 선택시 row이동을 반드시 할 것인지여부 * @property isForceRow * @private * @type {Boolean} */ isForceRow : false, /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(id, oConfig) { this.emptyText = this.emptyText || DU.getMessageManager().get(this.emptyTextMessageCode); if(this.cfg.getProperty('isEmptyText') === true) this.forceSelection = false; }, /** * @description element Dom객체 생성 * @method createContainer * @protected * @param {HTMLElement} parentNode 부모 노드 * @return {HTMLElement} */ createContainer : function(parentNode) { if(this.el) { if(this.el.dom.tagName == 'SELECT') { this.id = this.id || this.el.id; this.oldDom = this.el.dom; if(this.oldDom.options && 0 < this.oldDom.options.length) { this.optionsData = []; for(var i = 0 ; this.oldDom.options && i < this.oldDom.options.length; i++) { if(Dom.hasClass(this.oldDom.options[i], 'empty')) { this.cfg.setProperty('isEmptyText', true); this.emptyText = this.oldDom.options[i].text; continue; } var option = { value: this.oldDom.options[i].value, text: this.oldDom.options[i].text }; this.optionsData.push(option); } } this.name = this.name || this.oldDom.name; var parent = this.el.parent(); this.el = DU.get(this.createElement().cloneNode(false)); this.el.dom.id = this.id; Dom.replaceChild(parent.dom, this.el.dom, this.oldDom); this.el.appendChild(this.oldDom); Dom.removeNode(this.oldDom); delete this.oldDom; } } DU.widget.LTextBox.superclass.createContainer.call(this, parentNode); }, /** * @description render시 발생하는 메소드 * @method doRender * @protected * @param {HttpElement} appendToNode 부모 객체 * @return {void} */ doRender : function(container) { this.createComboTemplete(this.el); }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LCombo.superclass.afterRender.call(this, container); if(this.dataSet.getCount() == 0 && this.optionsData) { for(var i = 0 ; i < this.optionsData.length ; i++) { var row = this.dataSet.newRecord(); if(row === false) break; this.dataSet.setNameValue(row, this.valueField, this.optionsData[i].value); this.dataSet.setNameValue(row, this.displayField, this.optionsData[i].text); this.dataSet.setState(row, DU.data.LRecord.STATE_NORMAL); } this.dataSet.setRow(this.forceSelection === true ? 0 : 1); delete this.optionsData; } if(this.iconDivEl) this.iconDivEl.on('click', this.doIconClick, this, true); this.applyEmptyText(); }, createDataSet: function() { this.dataSet = new (eval(this.dataSetClassName))({ id: 'dataSet', fields:[ {id:this.valueField}, {id:this.displayField} ], focusFirstRow : false }) }, /** * @description icon click 이벤트가 발생하면 호출되는 메소드 * @method doIconClick * @protected * @param {Object} e Event 객체 * @return {void} */ doIconClick : function(e) { this.expand(); }, /** * @description Dom객체 생성 * @method createComboTemplete * @private * @param {String|Object} el 객체의 아이디나 객체 * @return {DU.LElement} Element 객체 */ createComboTemplete : function(el) { var elContainer = el; elContainer.addClass(this.CSS_BASE); elContainer.addClass("L-fixed"); var input = document.createElement('input'); elContainer.appendChild(input); this.inputEl = DU.get(input); var hiddenInput = document.createElement('input'); hiddenInput.name = this.id; hiddenInput.style.display = "none"; hiddenInput.className = DU.widget.LCombo.CSS_HIDDEN_COMBO; hiddenInput.instance = this; elContainer.appendChild(hiddenInput); this.hiddenInputEl = DU.get(hiddenInput); var iconDiv = document.createElement('div'); iconDiv.className = 'icon'; iconDiv.id = DU.id(); this.iconDivEl = DU.get(iconDiv); elContainer.appendChild(iconDiv); return elContainer; }, /** * @description width 속성에 따른 실제 적용 메소드 * @method _setWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setWidth : function(type, args, obj) { var width = args[0]; if (!DU.isBorderBox) { this.el.setWidth(width); this.getDisplayEl().setWidth(width - 16); this.iconDivEl.setLeft(width - 16); } else { this.el.setWidth(width - this.borderWidth); this.getDisplayEl().setWidth(width - (16 + this.borderWidth)); this.iconDivEl.setLeft(width - (16 + this.borderWidth)); } this.width = width; this.cfg.setProperty('width', this.width, true); }, /** * @description Index 위치를 변경한다. * @method setSelectedIndex * @public * @param {Int} idx 위치를 변경할 값 * @return void */ setSelectedIndex : function(idx) { if(this.dataSet.getCount() - 1 < idx) return; this.dataSet.setRow(idx, {isForce:this.isForceRow}); }, /** * @description DataSet이 load후 기본으로 셋팅될 값을 변경한다. * @method setDefaultValue * @public * @param {String} o 기본 코드 값 * @return void */ setDefaultValue: function(o) { this.defaultValue = o; }, /** * @description 기본 값을 셋팅하는 메소드 * @method focusDefaultValue * @private * @return {void} */ focusDefaultValue : function() { if(this.isLoad !== true && !this.defaultValue) this.defaultValue = this.getValue(); if(this.defaultValue) this.setValue(this.defaultValue); else if(this.selectedIndex >= 0) { if(this.dataSet.getCount() - 1 >= this.selectedIndex) this.setValue(this.dataSet.getNameValue(this.selectedIndex, this.valueField)); } }, /** * @description 출력객체에 내용을 변경한다. * @method setDisplayValue * @protected * @param {String} o 출력객체에 내용을 변경할 값 * @return void */ setDisplayValue : function(o) { if(o != this.getDisplayValue()) { o = this.forceSelection === true ? (this.isForceSelectValue(o) ? o : this.lastDisplayValue ) : o; this.inputEl.setValue(o); this.applyEmptyText(); this.bindDataSet(); } this.lastDisplayValue = this.inputEl.getValue(); if(this.lastDisplayValue == this.emptyText) this.lastDisplayValue = ''; }, /** * @description 목록에서 선택된 항목에 대한 값을 값객체에 반영한다. * @method bindDataSet * @private * @return void */ bindDataSet : function() { if(this.dataSet) { var dataIndex = this.getDataIndex(this.getDisplayValue()); if(dataIndex > -1) { this.dataSet.setRow(dataIndex, {isForce:this.dataSet.isFilter()}); if(dataIndex > -1) { var record = this.dataSet.getAt(dataIndex); this.hiddenInputEl.setValue(record.get(this.valueField)); } else { this.hiddenInputEl.setValue(''); } } else { this.hiddenInputEl.setValue(''); } } this.isChange = true; }, /** * @description 목록에서 선택되었는지 여부 * @method isForceSelectValue * @private * @param {String} o 비교할 값 * @return void */ isForceSelectValue : function(o) { var listElList = this.optionDivEl.select('.L-list'); var isSelection = false; listElList.each(function(child){ if(child.dom.firstChild.nodeValue == o) { isSelection = true; return false; } }); return isSelection; }, /** * @description 값이 없으면 기본 메시지를 출력하는 메소드 * @method applyEmptyText * @private * @return void */ applyEmptyText : function() { if(this.inputEl.getValue() == '' || this.inputEl.getValue() == this.emptyText) { this.inputEl.setValue(this.emptyText); this.inputEl.addClass('empty'); } else { this.inputEl.removeClass('empty'); } }, /** * @description 출력 객체의 값을 리턴 * @method getDisplayValue * @return {String} 출력값 */ getDisplayValue : function() { var o = this.inputEl.getValue(); o = (o == this.emptyText) ? '' : o; return o; }, /** * @description 현재 DataSet의 fieldName에 해당되는 값을 리턴 * @method getBindValue * @param {String} fieldName [optional] 필드이름 * @return {Object} 출력값 */ getBindValue : function(fieldName) { fieldName = fieldName || this.valueField; var val = this.getValue(); var row = this.dataSet.findRow(this.valueField, val); if(row < 0) return ""; return this.dataSet.getAt(row).get(fieldName); }, /** * @description 객체를 destroy하는 메소드 * @method destroy * @public * @return void */ destroy : function() { DU.widget.LCombo.superclass.destroy.call(this); this.iconDivEl = null; this.hiddenInputEl = null; }, /** * @description DataSet의 내용으로 목록을 재생성하는 메소드 * @method repaint * @public * @return void */ repaint : function() { this.onLoadDataSet(); this.applyEmptyText(); }, /** * @description 목록에서 선택되면 출력객체에 값을 반영하는 메소드 * @method doChangedItem * @private * @param {HTMLElement} dom Dom 객체 * @return {void} */ doChangedItem : function(dom) { var displayValue = dom.childNodes[0].nodeValue; var row = this.dataSet.findRow(this.displayField, displayValue); this.setValue(this.dataSet.getNameValue(row, this.valueField)); this.getDisplayEl().focus(); }, /** * @description 데이터셋이 RowPosChanged 메소드가 호출되면 수행하는 메소드 * @method onRowPosChangedDataSet * @private * @return {void} */ onRowPosChangedDataSet : function(e) { if(!this.hiddenInputEl) return; if(e.row < 0) { this.setDisplayValue(''); } else { var record = this.dataSet.getAt(e.row); var value = record.get(this.valueField); if(value) { this.hiddenInputEl.setValue(value); var displayValue = record.get(this.displayField); this.inputEl.setValue(displayValue); } } }, /** * @description 현재 값을 리턴 * @method getValue * @public * @return {String} 결과값 */ getValue : function() { return this.hiddenInputEl.getValue(); }, /** * @description 값을 변경한다. * @method setValue * @public * @param {String} o 반영할 값 * @return {void} */ setValue : function(o) { if(this.hiddenInputEl.dom.value === o) return; var row = this.dataSet.findRow(this.valueField, o); this.dataSet.setRow(row); if(this.forceSelection === true && row < 0) this.hiddenInputEl.dom.value = ""; this.fireEvent('changed', {target:this, value:this.getValue(), displayValue:this.getDisplayValue()}); }, /** * @description disabled 속성에 따른 실제 적용 메소드 * @method _setDisabled * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setDisabled : function(type, args, obj) { if(this.isExpand()) this.collapse(); args = args[0]; if(args === false) { this.disabled = false; var displayEl = this.getDisplayEl(); if(displayEl) { displayEl.enable(); if(this.iconDivEl) this.iconDivEl.enable(); } this.enableEvent.fire(); } else { this.disabled = true; var displayEl = this.getDisplayEl(); if(displayEl) { displayEl.disable(); if(this.iconDivEl) this.iconDivEl.disable(); } this.disableEvent.fire(); } }, /** * @description height 속성에 따른 실제 적용 메소드 * @method _setHeight * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setHeight : function(type, args, obj) { DU.widget.LCombo.superclass._setHeight.call(this, type, args, obj); var height = args[0]; if(height < 0) return; if(this.iconDivEl) this.iconDivEl.setHeight(height); }, /** * @description display renderer * @method displayRenderer * @param {DU.widget.LCombo} combo 콤보 객체 * @return {String} */ displayRenderer : function(combo) { var dataSet = combo.getDataSet(); return function(val, p, record, row, i) { var displayValue = null; if(record.state == DU.data.LRecord.STATE_NORMAL) { displayValue = record.get(combo.displayField); } else { var row = dataSet.findRow(combo.valueField, val); displayValue = (row > -1) ? dataSet.getAt(row).get(combo.displayField) : val; } return displayValue ; } }, /** * @description focus 이벤트 발생시 호출되는 메소드 * @method onFocus * @private * @param {Object} e Event 객체 * @return void */ onFocus : function(e) { DU.widget.LCombo.superclass.onFocus.call(this, e); var inputEl = this.getDisplayEl(); inputEl.removeClass('empty'); if(inputEl.getValue() == this.emptyText) { if(this.editable === true) inputEl.setValue(''); } }, /** * @description blur 이벤트 발생시 호출되는 메소드 * @method onBlur * @private * @param {Object} e Event 객체 * @return void */ onBlur : function(e) { DU.widget.LCombo.superclass.onBlur.call(this, e); this.doForceSelection(); this.applyEmptyText(); }, /** * @description 출력데이터가 변경되면 호출되는 메소드 * @method doChangedDisplayValue * @private * @param {String} o 적용할 값 * @return void */ doChangedDisplayValue : function(o) { this.bindDataSet(); }, /** * @description 필수 선택 메소드 * @method doForceSelection * @private * @return void */ doForceSelection : function() { if(this.forceSelection === true) { if(this.isChange == true) { var inputEl = this.getDisplayEl(); var row = this.dataSet.findRow(this.displayField, inputEl.getValue()); if(row < 0) this.setDisplayValue(this.lastDisplayValue); else this.bindDataSet(); } } }, /** * @description 객체의 toString * @method toString * @public * @return {String} */ toString : function() { return 'DU.form.LCombo ' + this.id; } }); DU.widget.LCombo.CSS_HIDDEN_COMBO = "L-combo-hidden"; })(); /** * Form * @module widget_form * @title LBasicCombo * @requires DU */ DU.namespace("DU.widget"); /** * LBasicCombo * @namespace DU.widget * @class LBasicCombo * @extends DU.widget.LUIComponent * @constructor LBasicCombo * @param {Object} oConfig The intial LBasicCombo. */ DU.widget.LBasicCombo = function(id, oConfig){ DU.widget.LBasicCombo.superclass.constructor.call(this, id, oConfig); } DU.extend(DU.widget.LBasicCombo, DU.widget.LCombo, { /** * @description 선택 필수 여부 * @config forceSelection * @type {Boolean} * @default false */ /** * @description 선택 필수 여부 * @property forceSelection * @private * @type {Boolean} */ forceSelection : false, /** * @description Dom객체 생성 * @method createComboTemplete * @private * @param {String|Object} el 객체의 아이디나 객체 * @return {DU.LElement} Element 객체 */ createComboTemplete : function(el) { var elContainer = el; var parent = null; if(elContainer.dom.tagName == 'DIV') { parent = elContainer.parent(); var select = document.createElement('select'); parent.appendChild(select); elContainer.removeNode(); elContainer = DU.get(select); } elContainer.addClass(this.CSS_BASE); elContainer.addClass("L-fixed"); this.el = elContainer; this.inputEl = elContainer; this.hiddenInputEl = elContainer; return elContainer; }, /** * @description container안의 content의 focus/blur 연결 설정 * @method initFocus * @protected * @return {void} */ initFocus: function() { }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LCombo.superclass.afterRender.call(this, container); this.inputEl.on('change', function(e){ var row = this.inputEl.dom.selectedIndex; row = (this.isEmptyText === true) ? row - 1 : row; this.dataSet.setRow(row); }, this, true); this.applyEmptyText(); }, /** * @description width 속성에 따른 실제 적용 메소드 * @method _setWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setWidth : function(type, args, obj) { var width = args[0]; if (!DU.isBorderBox) { this.el.setWidth(width); } else { this.el.setWidth(width - 4); } this.width = width; this.cfg.setProperty('width', this.width, true); }, /** * @description option 객체를 붙인다. * @method appendOption * @private * @param {HTMLElement} dom option dom 객체 * @return {void} */ appendOption: function(dom) { this.getDisplayEl().appendChild(dom); }, /** * @description 목록의 모든 item을 삭제한다. * @method removeAllItem * @protected * @return void */ removeAllItem : function(){ this.getDisplayEl().html(''); }, /** * @description 목록의 Item을 생성 * @method createItem * @private * @param {Object} e Event 객체 * @return {void} */ createItem : function(e) { var record = e.record; var codeValue = record.get(this.valueField); var displayValue = record.get(this.displayField); var option = document.createElement('option'); var optionEl = DU.get(option); option.value = codeValue; var txtNode = document.createTextNode(displayValue); optionEl.appendChild(txtNode); return optionEl; }, /** * @description emptyText 항목의 객체를 첫번째에 추가한다. * @method insertEmptyText * @private * @param {HTMLElement} dom option Dom 객체 * @return {void} */ insertEmptyText: function(dom) { if(this.optionDivEl.dom.childNodes.length > 0) DU.util.LDom.insertBefore(dom, this.inputEl.dom.childNodes[0]); else this.inputEl.appendChild(dom); }, /** * @description 현재 값을 리턴 * @method getValue * @public * @return {String} 결과값 */ getValue : function() { return this.inputEl.dom[this.inputEl.dom.selectedIndex].value; }, /** * @description 현재 값을 리턴 *

Sample: 보기

* @method getDisplayValue * @public * @return {String} 결과값 */ getDisplayValue : function() { return this.inputEl.dom[this.inputEl.dom.selectedIndex].text; }, /** * @description 데이터셋이 RowPosChanged 메소드가 호출되면 수행하는 이벤트 메소드 * @method onRowPosChangedDataSet * @private * @return {void} */ onRowPosChangedDataSet : function(e) { var row = (this.isEmptyText === true) ? e.row + 1 : e.row; this.setValue(row < 0 ? '' : this.inputEl.dom[row].value); this.fireEvent('changed', {target:this, value:this.getValue(), displayValue:this.getDisplayValue()}); }, /** * @description 값을 변경한다. * @method setValue * @public * @param {String} o 반영할 값 * @return {void} */ setValue : function(o) { var row = this.dataSet.findRow(this.valueField, o); this.dataSet.setRow(row); row = (this.isEmptyText === true) ? row + 1 : row; this.inputEl.dom[row].selected = true; }, /** * @description row에 해당되는 Element를 리턴하는 메소드 * @method getRowEl * @private * @return {DU.Element} */ getRowEl : function(row) { row = (this.isEmptyText === true) ? row + 1 : row; return DU.get(this.inputEl.dom[row]); }, /** * @description option div에 해당되는 객체를 리턴한다. * @method getOptionDiv * @protected * @return {DU.LElement} */ getOptionDiv: function() { return this.inputEl; }, /** * @description 목록중에 h와 같은 html을 찾아 객체의 index를 리턴 * @method getDataIndex * @protected * @param {String} h 비교할 html 내용 * @return {Int} */ getDataIndex : function(h) { var optionList = this.inputEl.dom.options; var idx = -1; for(var i = 0 ; i < optionList.length ; i++){ if(optionList[i].text == h) { idx = i; break; } } if(idx > -1 && this.isEmptyText === true) idx--; return idx; } }); /** * LCheckBox * @module widget_form * @title LCheckBox * @requires DU */ DU.namespace("DU.widget"); /** * LCheckBox * @namespace DU.widget * @class LCheckBox * @extends DU.widget.LField * @constructor LCheckBox * @param {Object} oConfig The intial LCheckBox. */ DU.widget.LCheckBox = function(oConfig){ var config = oConfig || {}; config = DU.util.LDom.applyIfProperties(config, '$.ext.checkBox'); DU.applyObject(this, config, true); DU.widget.LCheckBox.superclass.constructor.call(this, config); this.deferOnBlurDelegate = DU.util.LFunction.createDelegate(this.deferOnBlur, this); } DU.extend(DU.widget.LCheckBox, DU.widget.LField, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LCheckBox', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-checkbox', /** * @description label로 출력할 값 * @config label * @type {String} * @default null */ /** * @description label로 출력할 값 * @property label * @private * @type {String} */ label : '', /** * @description 선택시 값 * @config value * @type {String} * @default null */ /** * @description 선택시 값 * @property value * @private * @type {String} */ value : null, /** * @description 체크 여부 *

Sample: 보기

* @config checked * @type {Boolean} * @default false */ /** * @description 체크 여부 * @property checked * @private * @type {Boolean} */ checked : false, /** * @description value checkbox 선택시 dataset에 bind할 값 *

Sample: 보기

* @config bindValues * @type {Array} * @default null */ /** * @description checkbox 선택시 dataset에 bind할 값 * @property bindValues * @private * @type {Array} */ bindValues : null, /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ DU.widget.LCheckBox.superclass.initComponent.call(this); if(!this.id) { this.id = DU.id(); } this.createTemplate(); }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LCheckBox.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LCheckBox.superclass.initDefaultConfig.call(this); /** * Specifies whether the Module is visible on the page. * @config visible * @type Boolean * @default true */ this.cfg.addProperty("checked", { handler: this.configChecked, value: this.checked }); }, /** * @description disabled 속성에 따른 실제 적용 메소드 * @method configChecked * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return {void} */ configChecked : function(type, args, obj) { var val = args[0]; this.checked = val; this.getDisplayEl().dom.checked = val; if(val) this.el.addClass("L-checked"); else this.el.removeClass("L-checked"); this.fireEvent('changed', {target:this, value:val}); }, /** * @description disabled 속성에 따른 실제 적용 메소드 * @method _setDisabled * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return {void} */ _setDisabled : function(type, args, obj) { if(args[0] === false) { this.getDisplayEl().enable(); } else { this.getDisplayEl().disable(); } DU.widget.LCheckBox.superclass._setDisabled.call(this, type, args, obj); }, /** * @description render시 호출되는 메소드 * @method doRender * @public * @param {String|Object} container 부모객체 정보 * @return void */ doRender : function(appendToNode) { this.el.addClass(this.CSS_BASE + "-panel"); this.el.addClass("L-fixed"); if(this.width) this.el.setWidth(!DU.isBorderBox ? this.width - 1 : this.width - 2); var html = this.getRenderBody(); this.el.html(html); }, /** * @description template 생성 * @method createTemplate * @protected * @return {void} */ createTemplate : function() { var ts = this.templates || {}; ts = new DU.LTemplate( '' ); this.templates = ts; }, /** * @description body html을 생성하여 리턴하는 메소드 * @method getRenderBody * @return {String} */ getRenderBody : function() { var ts = this.templates || {}; var p = { id : DU.id(), name : this.name, value : this.value, label : this.label, checked : this.checked ? 'checked=""' : '' }; return ts.apply(p); }, /** * @description render후 호출되는 메소드 * @method afterRender * @protected * @param {HTMLElement} container 부모 객체 * @return void */ afterRender : function(container) { DU.widget.LCheckBox.superclass.afterRender.call(this, container); if(this.checked) this.el.addClass("L-checked"); else this.el.removeClass("L-checked"); var displayEl = this.getDisplayEl(); this.el.on('click', function(e) { displayEl.focus(); DU.util.LEvent.stopPropagation(e); }); if(displayEl) { displayEl.on('focus', this.onCheckFocus, this, true); displayEl.on('click', this.onClick, this, true); } }, onClick : function(e) { this.cfg.setProperty('checked', e.target.checked); }, /** * @description 화면 출력되는 객체 리턴 * @method getDisplayEl * @protected * @return {DU.LElement} Element 객체 */ getDisplayEl : function() { if(!this.displayEl) { this.displayEl = this.el.select("input:checkbox").getAt(0); } return this.displayEl; }, /** * @description 객체를 유효한 상태로 설정하는 메소드 * @method valid * @public * @return {void} */ valid : function(){ this.el.valid(); this.validEvent.fire(); }, /** * @description 객체를 유효하지 않은 상태로 설정하는 메소드 * @method invalid * @public * @return {void} */ invalid : function(message) { this.el.invalid(message); this.invalidEvent.fire(message); }, /** * @description 객체를 focus한다. * @method focus * @public * @return {void} */ focus : function() { this.getDisplayEl().focus(); }, /** * @description 객체를 blur한다. * @method blur * @public * @return {void} */ blur : function() { this.getDisplayEl().blur(); }, /** * @description 객체를 destroy하는 메소드 * @method destroy * @public * @return void */ destroy : function() { var displayEl = this.getDisplayEl(); this.displayEl.unOnAll(); this.displayEl = null; DU.widget.LCheckBox.superclass.destroy.call(this); }, /** * @description 값을 변경한다. * @method setValue * @public * @param {String} o 반영할 값 * @return {void} */ setValue : function(val) { val = (this.bindValues) ? this.bindValues[0] == val ? true : false : val; var checked = (val === true || val == '1' || String(val).toLowerCase() == 'on'); this.cfg.setProperty('checked', checked); }, /** * @description 현재 값을 리턴 * @method getValue * @public * @return {String} 결과값 */ getValue : function() { return (this.bindValues) ? this.bindValues[this.checked ? 0 : 1] : this.checked; }, /** * @description 화면 출력객체의 실제 value값을 값을 리턴 * @method getRawValue * @public * @return {String} 결과값 */ getRawValue : function() { if(this.checked) return this.getDisplayEl().getValue(); else return ""; }, /** * @description blur 이벤트 발생시 호출되는 메소드 * @method onBlur * @private * @param {Object} e Event 객체 * @return void */ onBlur : function(e) { if(this.cfg.getProperty("checked") != this.getDisplayEl().dom.checked) this.cfg.setProperty("checked", this.getDisplayEl().dom.checked); DU.widget.LCheckBox.superclass.onBlur.call(this); }, /** * @description item객체가 focus되면 호출되는 메소드 * @method onCheckFocus * @protected * @param {Object} e event 객체 * @return {void} */ onCheckFocus : function(e) { if(!this.isFocus) { this.doFocus(this, e); this.isFocus = true; } }, /** * @description focus 메소드가 호출되면 수행되는 메소드 * @method doFocus * @protected * @param {Object} e event 객체 * @return {void} */ doFocus : function(e) { DU.widget.LCheckBox.superclass.onFocus.call(this, e); DU.util.LEvent.addListener(DU.browser.msie ? document.body : document, "mousedown", this.deferOnBlurDelegate, this); }, /** * @description blur 호출 지연 메소드 * @method deferOnBlur * @protected * @param {Object} e event 객체 * @return {void} */ deferOnBlur : function(e) { DU.util.LFunction.defer(this.onBlurContains, 10, this, [e]); }, /** * @description container에 포함된 객체를 선택했는지 판단하는 메소드 * @method onBlurContains * @protected * @param {Object} e event 객체 * @return {void} */ onBlurContains : function(e) { if(e.deferCancelBubble == true) return; var target = e.target; if (this.el.dom !== target && !this.el.isAncestor(target)) { DU.util.LEvent.removeListener(DU.browser.msie ? document.body : document, "mousedown", this.deferOnBlurDelegate, this); this.onBlur(e); this.isFocus = null; } else e.deferCancelBubble = true; } }); /** * LCheckBoxGroup * @module widget_form * @title LCheckBoxGroup * @requires DU */ DU.namespace("DU.widget"); /** * LCheckBoxGroup * @namespace DU.widget * @class LCheckBoxGroup * @extends DU.widget.LField * @constructor LCheckBoxGroup * @param {Object} oConfig The intial LCheckBoxGroup. */ DU.widget.LCheckBoxGroup = function(oConfig){ var config = oConfig || {}; DU.applyObject(this, config, true); DU.widget.LCheckBoxGroup.superclass.constructor.call(this, config); this.deferOnBlurDelegate = DU.util.LFunction.createDelegate(this.deferOnBlur, this); } DU.extend(DU.widget.LCheckBoxGroup, DU.widget.LField, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LCheckBoxGroup', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-checkbox-group', /** * @description checkbox item 배열 * @property items * @private * @type {Array} */ items : [], /** * @description 가로길이 * @property width * @private * @type {String} */ width : '', /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ DU.widget.LCheckBoxGroup.superclass.initComponent.call(this); this.name = this.name || DU.id(); }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LCheckBoxGroup.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LCheckBoxGroup.superclass.initDefaultConfig.call(this); }, /** * @description render시 호출되는 메소드 * @method doRender * @public * @param {String|Object} container 부모객체 정보 * @return void */ doRender : function(appendToNode) { this.el.addClass(this.CSS_BASE); this.el.addClass("L-fixed"); if(this.width) { this.el.setWidth(!DU.isBorderBox ? this.width - 1 : this.width - 2); } DU.util.LArray.each(this.items, function(item, i){ if((item instanceof DU.widget.LCheckBox) == false) { item.name = this.name; item = new DU.widget.LCheckBox(item); this.items[i] = item; } item.render(this.el.dom); }, this); }, /** * @description render후 호출되는 메소드 * @method afterRender * @protected * @param {HTMLElement} container 부모 객체 * @return void */ afterRender : function(container) { DU.widget.LCheckBoxGroup.superclass.afterRender.call(this, container); var me = this; this.el.on('click', function(e){ if(me.items.length > 0) me.items[0].focus(); DU.util.LEvent.stopPropagation(e); }); DU.util.LArray.each(this.items, function(item){ item.on('changed', this.onChanged, this, true); item.on('focus', this.onItemFocus, this, true); }, this); }, /** * @description LCheckBox에서 구현한 메소드를 호출해주는 기능 * @method invoke * @protected * @param {Function} fn function 객체 * @param {Array} args 인수 배열 * @return {DU.widget.LCheckBoxGroup} */ invoke : function(fn, args){ var els = this.items; DU.each(els, function(e) { DU.widget.LCheckBox.prototype[fn].apply(e, args); }, this); return this; }, /** * @description 값이 변경되면 호출되는 메소드 * @method onChanged * @protected * @param {Object} e event 객체 * @return {void} */ onChanged : function(e) { this.fireEvent('changed', e); }, /** * @description item객체가 focus되면 호출되는 메소드 * @method onItemFocus * @protected * @param {Object} e event 객체 * @return {void} */ onItemFocus : function(e) { if(!this.isFocus) { this.doFocus(this, e); this.isFocus = true; } }, /** * @description focus 메소드가 호출되면 수행되는 메소드 * @method doFocus * @protected * @param {Object} e event 객체 * @return {void} */ doFocus : function(e) { this.onFocus(e); DU.util.LEvent.addListener(DU.browser.msie ? document.body : document, "mousedown", this.deferOnBlurDelegate, this); }, onFocus : function(e) { DU.widget.LCheckBoxGroup.superclass.onFocus.call(this, e); }, onBlur : function(e) { DU.widget.LCheckBoxGroup.superclass.onBlur.call(this, e); }, /** * @description blur 호출 지연 메소드 * @method deferOnBlur * @protected * @param {Object} e event 객체 * @return {void} */ deferOnBlur : function(e) { DU.util.LFunction.defer(this.onBlurContains, 10, this, [e]); }, /** * @description container에 포함된 객체를 선택했는지 판단하는 메소드 * @method onBlurContains * @protected * @param {Object} e event 객체 * @return {void} */ onBlurContains : function(e) { var target = e.target; if(e.deferCancelBubble == true) return; if(this.el.dom !== target && !this.el.isAncestor(target)) { DU.util.LEvent.removeListener(DU.browser.msie ? document.body : document, "mousedown", this.deferOnBlurDelegate, this); this.onBlur(e); this.isFocus = null; } else e.deferCancelBubble = true; }, /** * @description 객체를 focus한다. * @method focus * @public * @return {void} */ focus : function() { if(this.items.length > 0) this.items[0].focus(); }, /** * @description 객체를 destroy하는 메소드 * @method destroy * @public * @return void */ destroy : function() { DU.util.LArray.each(this.items, function(item){ item.destroy(); }, this); DU.widget.LCheckBoxGroup.superclass.destroy.call(this); }, /** * @description item중에 value 맞는 항목을 선택하는 메소드 * @method setValue * @public * @param {String} val item의 value 값 * @return void */ setValue : function(val) { DU.util.LArray.each(this.items, function(item){ item.setValue(val); }, this); }, /** * @description 선택된 item의 값을 리턴하는 메소드 * @method getValue * @public * @return {String} */ getValue : function() { var val = []; DU.util.LArray.each(this.items, function(item){ val.push(item.getValue()); }, this); return val; } }); (function(){ var fnName, CbProto = DU.widget.LCheckBox.prototype, CbgProto = DU.widget.LCheckBoxGroup.prototype; for(var fnName in CbProto){ if(DU.isFunction(CbProto[fnName])){ (function(fnName){ CbgProto[fnName] = CbgProto[fnName] || function(){ return this.invoke(fnName, arguments); }; }).call(CbgProto, fnName); } }; })(); /** * LRadio * @module widget_form * @title LRadio * @requires DU */ DU.namespace("DU.widget"); /** * LRadio * @namespace DU.widget * @class LRadio * @extends DU.widget.LField * @constructor LRadio * @param {Object} oConfig The intial LRadio. */ DU.widget.LRadio = function(oConfig){ var config = oConfig || {}; config = DU.util.LDom.applyIfProperties(config, '$.ext.radio'); DU.applyObject(this, config, true); DU.widget.LRadio.superclass.constructor.call(this, config); } DU.extend(DU.widget.LRadio, DU.widget.LCheckBox, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LRadio', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-radio', /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ DU.widget.LRadio.superclass.initComponent.call(this); if(!this.id) { this.id = DU.id(); } }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LRadio.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LRadio.superclass.initDefaultConfig.call(this); }, /** * @description Template을 생성하는 메소드 * @method createTemplate * @private * @return {void} */ createTemplate : function() { var ts = this.templates || {}; ts = new DU.LTemplate( '' ); this.templates = ts; }, /** * @description 화면 출력되는 객체 리턴 * @method getDisplayEl * @protected * @return {DU.LElement} Element 객체 */ getDisplayEl : function() { if(!this.displayEl) { this.displayEl = this.el.select("input:radio").getAt(0); } return this.displayEl; } }); /** * LRadioGroup * @module widget_form * @title LRadioGroup * @requires DU */ DU.namespace("DU.widget"); /** * LRadioGroup * @namespace DU.widget * @class LRadioGroup * @extends DU.widget.LField * @constructor LRadioGroup * @param {Object} oConfig The intial LRadioGroup. */ DU.widget.LRadioGroup = function(oConfig){ var config = oConfig || {}; DU.applyObject(this, config, true); DU.widget.LRadioGroup.superclass.constructor.call(this, config); } DU.extend(DU.widget.LRadioGroup, DU.widget.LCheckBoxGroup, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LRadioGroup', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-radio-group', /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig){ DU.widget.LRadioGroup.superclass.initComponent.call(this); }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LRadioGroup.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LRadioGroup.superclass.initDefaultConfig.call(this); }, /** * @description render시 발생하는 메소드 * @method doRender * @protected * @param {HttpElement} appendToNode 부모 객체 * @return {void} */ doRender : function(appendToNode) { this.el.addClass(this.CSS_BASE); this.el.addClass("L-fixed"); this.el.setWidth(!DU.isBorderBox ? this.width - 5 : this.width - 2); DU.util.LArray.each(this.items, function(item, i){ if((item instanceof DU.widget.LRadio) == false) { item.name = this.name; item = new DU.widget.LRadio(item); this.items[i] = item; } item.render(this.el.dom); }, this); }, /** * @description Check를 취소하는 메소드 * @method cancelChecked * @param {Object} e Event객체 * @return {void} */ cancelChecked : function(e) { var target = e.target; DU.util.LArray.each(this.items, function(item){ if(item !== target) { item.checked = false; item.el.removeClass('L-checked'); } }, this); }, /** * @description Check를 모두 취소하는 메소드 * @method clearAllChecked * @param {Object} e Event객체 * @return {void} */ clearAllChecked : function(e) { DU.util.LArray.each(this.items, function(item, i){ item.setValue(false); }, this); }, /** * @description change 이벤트가 발생하면 호출되는 메소드 * @method onChanged * @param {Object} e Event객체 * @return {void} */ onChanged : function(e) { this.cancelChecked(e); DU.widget.LRadioGroup.superclass.onChanged.call(this, e); }, /** * @description check된 radio 객체를 리턴하는 메소드 * @method getCheckedItem * @return {DU.widget.LRadio} */ getCheckedItem : function() { var checkedItem = null; DU.util.LArray.each(this.items, function(item, i){ if(item.checked === true) { checkedItem = item; return false; } }, this); return checkedItem; }, /** * @description val 해당되는 radio를 선택하는 메소드 * @method setValue * @param {String} val radio의 value값에 해당되는 값 * @return {DU.widget.LRadio} */ setValue : function(val) { var radio = this.getRadioElByVal(val); if(radio == null) return; radio.setValue(true); }, /** * @description 선택된 raio의 값을 리턴하는 메소드 * @method getValue * @return {String} */ getValue : function() { var item = this.getCheckedItem(); return (item != null) ? item.getRawValue() : null; }, /** * @description 값에 해당되는 radio를 리턴하는 메소드 * @method getRadioElByVal * @return {String} */ getRadioElByVal : function(val) { var retItem = null; DU.util.LArray.each(this.items, function(item, i){ if(item.getDisplayEl().dom.value == val) { retItem = item; return false; } }, this); return retItem; }, onBlur : function(e) { DU.widget.LRadioGroup.superclass.onBlur.call(this, e); } }); (function(){ var fnName, CbProto = DU.widget.LRadio.prototype, groupProto = DU.widget.LRadioGroup.prototype; for(var fnName in CbProto){ if(DU.isFunction(CbProto[fnName])){ (function(fnName){ groupProto[fnName] = groupProto[fnName] || function(){ return this.invoke(fnName, arguments); }; }).call(groupProto, fnName); } }; })(); /** * Form * @module widget_form * @title LTextArea * @requires DU */ DU.namespace("DU.widget"); /** * LTextArea * @namespace DU.widget * @class LTextArea * @extends DU.widget.LTextBox * @constructor LTextArea * @param {HTMLElement | String} id The html element that represents the Element. * @param {Object} oConfig The intial LTextArea. */ DU.widget.LTextArea = function(oConfig){ var config = oConfig || {}; config = DU.util.LDom.applyIfProperties(config, '$.ext.textArea'); DU.widget.LTextArea.superclass.constructor.call(this, oConfig); } DU.extend(DU.widget.LTextArea, DU.widget.LTextBox, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LTextArea', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-textarea', /** * @description 목록창의 가로 길이 *

Sample: 보기

* @config width * @type {String} * @default '100px' */ /** * @description 목록창의 가로 길이 * @property width * @private * @type {String} */ width : '100px', /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(id, oConfig) { }, /** * @description 객체의 이벤트 초기화 메소드 * @method initEvents * @protected * @return void */ initEvents : function() { DU.widget.LTextArea.superclass.initEvents.call(this); }, /** * @description 객체를 Config정보를 초기화하는 메소드 * @method initDefaultConfig * @protected * @return void */ initDefaultConfig : function() { DU.widget.LTextArea.superclass.initDefaultConfig.call(this); }, /** * @description render시 발생하는 메소드 * @method doRender * @protected * @param {HttpElement} appendToNode 부모 객체 * @return {void} */ doRender : function(container) { this.el.addClass(this.CSS_BASE); this.el.addClass("L-fixed"); this.el.setWidth(this.width); this.createTemplate(); var html = this.getRenderBody(); this.el.html(html); }, /** * @description template객체 생성 * @method createTemplate * @protected * @return {void} */ createTemplate : function() { var ts = this.templates || {}; ts = new DU.LTemplate( '' ); this.templates = ts; }, /** * @description body html을 리턴하는 메소드 * @method getRenderBody * @return {String} */ getRenderBody : function() { var ts = this.templates || {}; var id = this.id ? this.id + '_hi' : DU.id(); var p = { id : id, name : this.name || this.id, value : this.value || '' }; return ts.apply(p); }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LTextArea.superclass.afterRender.call(this, container); }, /** * @description 화면 출력되는 객체 리턴 * @method getDisplayEl * @return {DU.LElement} Element 객체 */ getDisplayEl : function() { if(!this.displayEl) { this.displayEl = this.el.select("textarea").getAt(0); } return this.displayEl; }, /** * @description 키 입력시 호출되는 메소드 * @method onFireKey * @param {Object} e Event 객체 * @return {void} */ onFireKey : function(e){ if(DU.util.LEvent.isSpecialKey(e) && e.keyCode != DU.util.LKeyListener.KEY.ENTER) this.fireEvent("specialkey", e); } }); /** * Form * @module widget_form * @title LNumberBox * @requires DU */ DU.namespace("DU.widget"); (function(){ /** * LNumberBox * @namespace DU.widget * @class LNumberBox * @extends DU.widget.LTextBox * @constructor LNumberBox * @param {HTMLElement | String} id The html element that represents the Element. * @param {Object} oConfig The intial LNumberBox. */ DU.widget.LNumberBox = function(oConfig){ var config = oConfig || {}; config = DU.util.LDom.applyIfProperties(config, '$.ext.numberBox'); DU.widget.LNumberBox.superclass.constructor.call(this, oConfig); } DU.extend(DU.widget.LNumberBox, DU.widget.LTextBox, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LNumberBox', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-numberBox', /** * @description 입력 가능한 문자열 *

Sample: 보기

* @config allowChars * @type {String} * @default '0123456789' */ /** * @description 입력 가능한 문자열 * @property allowChars * @private * @type {String} */ allowChars : '0123456789.', /** * @description 소수점 허용 자리수 *

Sample: 보기

* @config decimalPrecision * @type {Int} * @default 0 */ /** * @description 소수점 허용 자리수 * @property decimalPrecision * @private * @type {Int} */ decimalPrecision : 0, /** * @description 입력 가능 최소값 정의 (미지원) * @config minValue * @type {Int} * @default null */ /** * @description 입력 가능 최소값 정의 * @property minValue * @private * @type {Int} */ minValue : null, /** * @description 입력 가능 최대값 정의 (미지원) * @config maxValue * @type {Int} * @default null */ /** * @description 입력 가능 최대값 정의 * @property maxValue * @private * @type {Int} */ maxValue : null, /** * @description 천단위 구분자 출력 여부 * @config thousandsSeparator * @type {boolean} * @default true */ /** * @description 입력 가능 최대값 정의 * @property thousandsSeparator * @private * @type {boolean} */ thousandsSeparator: true, /** * @description 값 변경을 할 수 있는 spin 기능 출력 여부 * @config isShowSpin * @type {boolean} * @default false */ /** * @description 값 변경을 할 수 있는 spin 기능 출력 여부 * @property isShowSpin * @private * @type {boolean} */ isShowSpin: false, /** * @description Dom객체 생성 및 초기화하는 메소드 * @method initComponent * @protected * @param {String|Object} el 객체의 아이디나 객체 * @param {Object} oConfig 환경정보 객체 * @return void */ initComponent : function(oConfig) { if(this.decimalPrecision > 0) this.allowChars += '.'; if (this.minValue != null && this.minValue < 0) this.allowChars += "-"; }, /** * @description Dom객체 생성 * @method createTimeTemplete * @private * @param {String|Object} el 객체의 아이디나 객체 * @return {DU.LElement} Element 객체 */ createTemplete : function(el) { DU.widget.LNumberBox.superclass.createTemplete.call(this, el); var elContainer = el; var hiddenInput = document.createElement('input'); hiddenInput.name = this.id; hiddenInput.style.display = "none"; hiddenInput.className = DU.widget.LNumberBox.CSS_HIDDEN_NUMBERBOX; hiddenInput.instance = this; el.appendChild(hiddenInput); this.hiddenInputEl = DU.get(hiddenInput); if(this.isShowSpin) { var iconDiv = document.createElement('div'); iconDiv.className = 'icon'; iconDiv.id = DU.id(); this.iconDivEl = DU.get(iconDiv); elContainer.appendChild(iconDiv); var spinUpDiv = document.createElement('div'); spinUpDiv.className = "L-spin-up"; this.spinUpDivEl = DU.get(spinUpDiv); this.iconDivEl.appendChild(spinUpDiv); var spinDownDiv = document.createElement('div'); spinDownDiv.className = "L-spin-down"; this.spinDownDivEl = DU.get(spinDownDiv); this.iconDivEl.appendChild(spinDownDiv); } return elContainer; }, /** * @description width 속성에 따른 실제 적용 메소드 * @method _setWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setWidth : function(type, args, obj) { if(this.isShowSpin) { var width = args[0]; if (!DU.isBorderBox) { this.el.setWidth(width); this.getDisplayEl().setWidth(width - 16); this.iconDivEl.setLeft(width - 16); } else { this.el.setWidth(width - 4); this.getDisplayEl().setWidth(width - 20); this.iconDivEl.setLeft(width - 20); } this.width = width; this.cfg.setProperty('width', this.width, true); } else DU.widget.LNumberBox.superclass._setWidth.call(this, type, args, obj); }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LNumberBox.superclass.afterRender.call(this, container); if(this.isShowSpin) { this.spinUpDivEl.on('mousedown', function(e){ this.spinUpDivEl.addClass('L-spin-up-click'); }, this, true); this.spinUpDivEl.on('mouseup', function(e){ this.spinUpDivEl.removeClass('L-spin-up-click'); }, this, true); this.spinDownDivEl.on('mousedown', function(e){ this.spinDownDivEl.addClass('L-spin-down-click'); }, this, true); this.spinDownDivEl.on('mouseup', function(e){ this.spinDownDivEl.removeClass('L-spin-down-click'); }, this, true); this.spinUpDivEl.on('click', function(e){ this.upValue(); DU.util.LEvent.stopEvent(e); }, this, true); this.spinDownDivEl.on('click', function(e){ this.downValue(); DU.util.LEvent.stopEvent(e); }, this, true); } }, /** * @description 값을 올리는 메소드 * @method upValue * @protected * @return void */ upValue: function() { var value = parseFloat(this.getValue(), 10) || 0; if(!DU.isUndefined(this.maxValue) && this.maxValue <= value) return; this.setValue(++value); }, /** * @description 값을 내리는 메소드 * @method downValue * @protected * @return void */ downValue: function() { var value = parseFloat(this.getValue(), 10) || 0; if(!DU.isUndefined(this.minValue) && this.minValue >= value) return; this.setValue(--value); }, /** * @description 유효성을 검증하는 메소드 * @method validateValue * @protected * @param {object} value 값 * @return {Boolean} */ validateValue : function(value) { if(value === this.lastValue) return true; value = String(value); value = value.replace(/,/g, ''); var isValid = true; isValid = new DU.validate.LNumberValidator({id: this.id}).validate(value); if(isValid == false) return false; if(!DU.isUndefined(value) && !DU.isNull(value)) { if(this.isNumberValue(value) == false) return false; if(this.minValue != null && this.minValue > value) { this.invalid(DU.getMessageManager().get("$.base.msg011", [this.minValue])); this.setValue(this.lastValue); return false; } if(this.maxValue != null && this.maxValue < value) { this.invalid(DU.getMessageManager().get("$.base.msg012", [this.maxValue])); this.setValue(this.lastValue); return false; } } this.valid(); return isValid; }, /** * @description 숫자 유효성을 검증하는 메소드 * @method isNumberValue * @protected * @param {object} value 값 * @return {Boolean} */ isNumberValue: function(value) { if(DU.isUndefined(value) || DU.isNull(value) || value === false) return false; value = value == '' ? 0 : value; if(value != parseFloat(value, 10)) return false; return true; }, /** * @description 값을 리턴하는 메소드 * @method getValue * @return {Int|Float} */ getValue : function() { var value = this.hiddenInputEl.getValue(); if(DU.isUndefined(this.lastValue) || value == this.lastValue) return value; if(DU.isEmpty(value)) return null; return parseFloat(value, 10); }, /** * @description decimal값을 리턴하는 메소드 * @method getDecimalValue * @return {Int|Float} */ getDecimalValue: function(value) { var newValue = value; var sValue = value + ''; var pos = sValue.indexOf(".") || 0; if (pos > 0) { var dpValue = sValue.substring(pos + 1); if (dpValue.length > this.decimalPrecision) dpValue = dpValue.substring(0, this.decimalPrecision); dpValue = DU.util.LString.rPad(dpValue, '0', this.decimalPrecision); newValue = value.substring(0, pos + 1) + dpValue; } else newValue += '.' + DU.util.LString.rPad('', '0', this.decimalPrecision); return newValue; }, /** * @description 출력데이터가 변경되면 호출되는 메소드 * @method doChangedDisplayValue * @private * @param {String} o 적용할 값 * @return void */ doChangedDisplayValue : function(o) { var val = String(o); val = val.replace(/,/g, ''); if(this.isNumberValue(val)) this.setValue(val); }, /** * @description 값을 변경한다. * @method setValue * @public * @param {Int} val 반영할 값 * @return {void} */ setValue : function(val) { if(DU.isUndefined(val) == true || DU.isNull(val)) return; this.hiddenInputEl.setValue(val); if(!DU.isEmpty(val)) { if(this.thousandsSeparator === true) val = DU.util.LNumber.format(parseFloat(val, 10), {thousandsSeparator: ','}); if (this.decimalPrecision > 0) val = this.getDecimalValue(val); } this.getDisplayEl().setValue(val); this.fireEvent('changed', {target:this, value:this.getValue(), displayValue:this.getDisplayValue()}); } }); DU.widget.LNumberBox.CSS_HIDDEN_NUMBERBOX = "L-number-hidden"; })(); /** * DateBox * @module widget_form * @title LDateBox * @requires DU */ DU.namespace("DU.widget"); /** * LDateBox * @namespace DU.widget * @class LDateBox * @extends DU.widget.LField * @constructor LDateBox * @param {Object} oConfig The intial LDateBox. */ DU.widget.LDateBox = function(oConfig){ var config = oConfig ||{}; config = DU.util.LDom.applyIfProperties(config, '$.ext.dateBox'); this.onIconClickDelegate = DU.util.LFunction.createDelegate(this.onIconClick, this); DU.widget.LDateBox.superclass.constructor.call(this, config); } DU.extend(DU.widget.LDateBox, DU.widget.LTextBox, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LDateBox', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-datebox', /** * @description 입출력 type * @property dateType * @private * @type {String} */ dateType : 'date', /** * @description 편집시, form submit시 적용되는 format * @property valueFormat * @private * @type {String} */ valueFormat : '%q', /** * @description calendar show할때 입력된 날짜를 calendar에서 선택할지 여부 * @property selectingInputDate * @type {boolean} */ selectingInputDate : true, /** * @description width * @property width * @type {int} * @default 100 */ width : 100, /** * @description height * @property height * @type {int} * @default 21 */ height : 21, /** * @description iconWidth * @property iconWidth * @type {int} * @default 18 */ iconWidth : 18, /** * @description iconMarginLeft, input과 달력 icon간의 간격 * @property iconMarginLeft * @type {int} * @default 2 */ iconMarginLeft : 2, /** * @description editableTextbox, 사용자가 input text box를 편집할 수 있는지 여부, 즉 달력으로만 입력할 것인가 여부 * @config editableTextbox * @type {boolean} * @default true */ /** * @description editableTextbox, 사용자가 input text box를 편집할 수 있는지 여부, 즉 달력으로만 입력할 것인가 여부 * @property editableTextbox * @type {boolean} * @default true */ editableTextbox : true, /** * @description mask 적용 * @config mask * @type {String} * @default null */ /** * @description mask 적용 * new DU.form.LTextBox({ mask: '999999-9999999' }); * @property mask * @private * @type {String} */ mask: '9999-99-99', /** * @description afterRender * @method afterRender * @private * @return void */ afterRender : function(container) { DU.widget.LDateBox.superclass.afterRender.call(this, container); this.doRenderCalendar(); if(!this.editableTextbox) this.getDisplayEl().dom.readOnly = true; }, /** * @description doRenderCalendar * @method doRenderCalendar * @private * @return void */ doRenderCalendar : function(){ var config = this.calendarConfig || {width:150}; config.applyTo = this.calendarDivEl.id; this.calendarDivEl.addClass('L-dateBox-calendar'); this.calendar = new DU.widget.LCalendar(config); this.calendar.render(); this.calendar.hide(); this.iconDivEl.on('click', this.onIconClickDelegate); }, /** * @description blur 이벤트 발생시 defer를 연결하는 메소드 * @method deferOnBlur * @protected * @param {Object} e Event 객체 * @return {void} */ deferOnBlur : function(e) { if (this.calendarDivEl.isAncestor(e.target)) { var el = DU.get(e.target); if (el.dom.tagName.toLowerCase() == "a" && el.hasClass("selector")) { var selectedDate = this.calendar.getProperty("pagedate"); selectedDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), parseInt(el.getHtml())); this.setValue(selectedDate); this.calendar.hide(); } } var checkBlur = function(e) { if(e.deferCancelBubble == true) return; var target = e.target; if (target !== this.el.dom && !this.el.isAncestor(target) && target !== this.calendarDivEl.dom && !this.calendarDivEl.isAncestor(target)) { DU.util.LEvent.removeListener(DU.browser.msie ? document.body : document, "mousedown", this.deferOnBlurDelegate, this); this.onBlur.call(this, e); this.isFocus = false; } else { e.deferCancelBubble = true; } } DU.util.LFunction.defer(checkBlur, 10, this, [e]); }, /** * @description onBlur * @method onBlur * @param {Object} e event object * @private * @return void */ onBlur : function(e){ DU.widget.LDateBox.superclass.onBlur.call(this, e); this.calendar.hide(); }, /** * @description 출력데이터가 변경되면 호출되는 메소드 * @method doChangedDisplayValue * @private * @param {String} o 적용할 값 * @return void */ doChangedDisplayValue : function(o) { this.setValue(o); }, /** * @description string convert to date object * @method getDate * @param {string} sDate * @private * @return {Date} */ getDate : function(sDate){ if (sDate instanceof Date) { return sDate; } var formatType = this.displayValue ? this.displayValue : "%x"; var oDate = DU.util.LFormat.stringToDate(sDate,{format:formatType}); if (!(oDate instanceof Date)) { oDate = DU.util.LFormat.stringToDate(sDate,{format:"%q"}); } if (!(oDate instanceof Date)) { oDate = DU.util.LFormat.stringToDate(sDate,{format:"%Q"}); } if (oDate instanceof Date) { return oDate; } else { return false; } }, /** * @description date convert to formatted string * @method getDateString * @param {Date} oDate * @param {String} format * @private * @return {String} */ getDateString : function(oDate, format){ //mask를 사용하므로 구분자가 없는 날짜 8자가 기본이다. format = format ? format : '%Y%m%d'; var value = oDate ? DU.util.LFormat.dateToString(oDate, { format: format }) : ""; return value ? value : ""; }, /** * @description calendar 전시 위치 설정 * @method setCalendarXY * @private */ setCalendarXY : function(){ var h = this.calendarDivEl.getHeight() || 0; var t = this.getDisplayEl().getTop() + this.getDisplayEl().getHeight(); var l = this.getDisplayEl().getLeft(); var visible = DU.util.LDom.isVisibleSide(h+t-40);//padding+border 빼기(22), ie borderbox 처리 필요. if(!visible){ t = this.getDisplayEl().getTop() - h; } this.calendarDivEl.setTop(t); this.calendarDivEl.setLeft(l); }, /** * @description onIconClick * @method onIconClick * @private * @param {Object} e */ onIconClick : function(e) { this.showCalendar(); this.inputEl.focus(); }, /** * @description * @method showCalendar * @private */ showCalendar : function(){ if(this.editable === false || this.disabled === true) return; this.setCalendarXY(); if (this.selectingInputDate) this.selectCalendarDate(); this.calendar.show(); this.setCalendarXY(); }, /** * @description 입력된 날짜 선택하기 * @method selectCalendarDate * @param {string} date */ selectCalendarDate : function(date){ date = date ? date : this.getDateString(this.getValue(),"%x"); if (date) { this.calendar.clear(); var selDates = this.calendar.select(date,false); if (selDates.length > 0) { var firstDate = selDates[0]; this.calendar.cfg.setProperty("pagedate", firstDate.getFullYear() + this.calendar.cfg.getProperty(DU.widget.LCalendar._DEFAULT_CONFIG.DATE_FIELD_DELIMITER.key) + (firstDate.getMonth() + 1)); this.calendar.render(); } } }, /** * @description Dom객체 생성 * @method createTemplete * @private * @param {String|Object} el 객체의 아이디나 객체 * @return {DU.LElement} Element 객체 */ createTemplete : function(el) { var elContainer = DU.get(el); elContainer.addClass(this.CSS_BASE); elContainer.addClass("L-fixed"); var input = document.createElement('input'); elContainer.appendChild(input); this.inputEl = DU.get(input); var iconDiv = document.createElement('div'); iconDiv.className = 'icon'; elContainer.appendChild(iconDiv); this.iconDivEl = DU.get(iconDiv); //form submit var hiddenInput = document.createElement('input'); hiddenInput.name = this.name || this.id; hiddenInput.instance = this; hiddenInput.className = "hiddenInput"; elContainer.appendChild(hiddenInput); this.hiddenInputEl = DU.get(hiddenInput); //calendar container 만들기 var calendarDiv = document.createElement('div'); calendarDiv.className = "L-cal-container"; this.calendarDivEl = DU.get(calendarDiv); //ie의 layer z-index문제로 body에 붙임 document.body.appendChild(calendarDiv); return elContainer; }, /** * @description width 속성에 따른 실제 적용 메소드 * @method _setWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setWidth : function(type, args, obj) { this.width = DU.util.LDom.toPixelNumber(args[0]); this._computeWidth(); }, /** * @description 넓이 계산, space는 input과 달력아이콘간의 간격이다. * @method _computeWidth * @protected */ _computeWidth : function(){ this.el.setWidth(this.width); this.iconDivEl.setWidth(this.iconWidth); var inputWidth = this.width - this.iconWidth - this.iconMarginLeft; this.getDisplayEl().setWidth(inputWidth); this.iconDivEl.setStyle("left",(inputWidth + this.iconMarginLeft) + "px"); }, /** * @description height 속성에 따른 실제 적용 메소드 * @method _setHeight * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setHeight : function(type, args, obj) { if(args[0] != "auto" && args[0] != "") { this.height = DU.util.LDom.toPixelNumber(args[0]); this._computeHeight(); } else { this._computeHeight(true); } }, /** * @description 높이 계산 * @method _computeHeight * @protected * @param {boolean} isAuto */ _computeHeight : function(isAuto) { if (!isAuto) { this.el.setHeight(this.height); this.getDisplayEl().setHeight(this.height-2); this.iconDivEl.setHeight(this.height); } else { this.el.setStyle("height",""); this.getDisplayEl().setStyle("height",""); this.iconDivEl.setStyle("height",""); } }, /** * @description disabled 속성에 따른 실제 적용 메소드 * @method _setDisabled * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setDisabled : function(type, args, obj) { args = args[0]; if(args === false) { this.disabled = false; this.inputEl.enable(); this.hiddenInputEl.enable(); this.iconDivEl.enable(); this.calendarDivEl.enable(); } else { this.disabled = true; this.inputEl.disable(); this.hiddenInputEl.disable(); this.iconDivEl.disable(); this.calendarDivEl.disable(); } }, /** * @description 날짜 설정 * @method setValue * @param {Date} oDate * @return void */ setValue : function(oDate){ //빈값을 입력하면 null, 잘못입력하면 이전값을 넣는다. if(typeof oDate === "string"){ //getUnMaskValue는 자리수로 검사하므로 mask안된 값이 들어오면 값을 잘라낸다. oDate = oDate.length == 8 ? oDate : this.getUnMaskValue(oDate); oDate = DU.isEmpty(oDate) ? null : this.getDate(oDate); } if (oDate === false) { this.getDisplayEl().dom.value = this.lastDisplayValue; } else { var hiddenValue = oDate === null ? "" : this.getDateString(oDate, this.valueFormat); var displayValue = oDate === null ? "" : this.getDateString(oDate); this.getDisplayEl().dom.value = displayValue; displayValue = this.checkVal().displayValue; this.getDisplayEl().dom.value = displayValue; if (this.hiddenInputEl.dom.value !== hiddenValue) { this.hiddenInputEl.setValue(hiddenValue); this.lastDisplayValue = displayValue; //값이 달라질 경우만 발생. this.fireEvent('changed', { target: this, value: this.getValue(), displayValue: this.getDisplayValue() }); } } }, /** * @description 입력된 날짜 가져오기 * @method getValue * @return {Date} */ getValue : function(){ var value = DU.widget.LDateBox.superclass.getValue.call(this); var oDate = this.getDate(value); return this.dateType == "date" ? (oDate ? oDate : null) : this.getDateString(oDate, this.valueFormat); }, /** * @description 달력 숨기기 * @method hide * @return void */ hide : function(anim) { this.calendar.hide(); DU.widget.LDateBox.superclass.hide.call(this,anim); }, /** * @description 객체를 destroy하는 메소드 * @method destroy * @public * @return void */ destroy : function() { DU.widget.LDateBox.superclass.destroy.call(this); this.iconDivEl.unOnAll(); this.inputEl = null; this.hiddenInputEl = null; this.iconDivEl = null; this.calendar.destroy(); this.calendarDivEl = null; } }); /** * Form * @module widget_form * @title LTimeBox * @requires DU */ DU.namespace("DU.widget"); /** * LTimeBox * @namespace DU.widget * @class LTimeBox * @extends DU.widget.LTextBox * @constructor LTimeBox * @param {HTMLElement | String} id The html element that represents the Element. * @param {Object} oConfig The intial LTimeBox. */ DU.widget.LTimeBox = function(oConfig){ var config = oConfig || {}; config = DU.util.LDom.applyIfProperties(config, '$.ext.timeBox'); DU.widget.LTimeBox.superclass.constructor.call(this, oConfig); } DU.extend(DU.widget.LTimeBox, DU.widget.LTextBox, { /** * @description 객체의 문자열 * @property otype * @private * @type {String} */ otype : 'DU.widget.LTimeBox', /** * @description 기본 CSS명 * @property CSS_BASE * @private * @type {String} */ CSS_BASE : 'L-timeBox', /** * @description 입력 가능한 문자열 * @config allowChars * @type {String} * @default '0123456789' */ /** * @description 입력 가능한 문자열 * @property allowChars * @private * @type {String} */ allowChars : '0123456789', /** * @description mask 적용 * @property mask * @private * @type {String} */ mask: '99:99', /** * @description 가로 길이 * @config width * @type {Int} * @default 60 */ /** * @description 가로 길이 * @property width * @private * @type {String} */ width: 60, /** * @description Dom객체 생성 * @method createTimeTemplete * @private * @param {String|Object} el 객체의 아이디나 객체 * @return {DU.LElement} Element 객체 */ createTemplete : function(el) { DU.widget.LTimeBox.superclass.createTemplete.call(this, el); var elContainer = el; var iconDiv = document.createElement('div'); iconDiv.className = 'icon'; iconDiv.id = DU.id(); this.iconDivEl = DU.get(iconDiv); elContainer.appendChild(iconDiv); var spinUpDiv = document.createElement('div'); spinUpDiv.className = "L-spin-up"; this.spinUpDivEl = DU.get(spinUpDiv); this.iconDivEl.appendChild(spinUpDiv); var spinDownDiv = document.createElement('div'); spinDownDiv.className = "L-spin-down"; this.spinDownDivEl = DU.get(spinDownDiv); this.iconDivEl.appendChild(spinDownDiv); return elContainer; }, /** * @description render 후 호출하는 메소드 * @method afterRender * @protected * @param {HttpElement} container 부모 객체 * @return {String} */ afterRender : function(container) { DU.widget.LTimeBox.superclass.afterRender.call(this, container); this.spinUpDivEl.on('mousedown', function(){ this.spinUpDivEl.addClass('L-spin-up-click'); }, this, true); this.spinUpDivEl.on('mouseup', function(){ this.spinUpDivEl.removeClass('L-spin-up-click'); }, this, true); this.spinDownDivEl.on('mousedown', function(){ this.spinDownDivEl.addClass('L-spin-down-click'); }, this, true); this.spinDownDivEl.on('mouseup', function(){ this.spinDownDivEl.removeClass('L-spin-down-click'); }, this, true); this.spinUpDivEl.on('click', function(){ this.upValue(); }, this, true); this.spinDownDivEl.on('click', function(){ this.downValue(); }, this, true); }, /** * @description 1분 올리는 메소드 * @method upValue * @protected * @return void */ upValue: function() { if(this.disabled) return; var value = this.getValue() || '0000'; var hh = parseInt(value.substring(0, 2), 10); var mm = parseInt(value.substring(2, 4), 10); if(mm == 59) { hh = hh == 23 ? 0: (hh + 1); mm = 0; } else mm++; this.setValue(DU.util.LString.lPad(hh, '0', 2) + DU.util.LString.lPad(mm, '0', 2)); }, /** * @description 1분 내리는 메소드 * @method downValue * @protected * @return void */ downValue: function() { if(this.disabled) return; var value = this.getValue() || '0000'; var hh = parseInt(value.substring(0, 2), 10); var mm = parseInt(value.substring(2, 4), 10); if(mm == 00) { hh = hh == 0 ? 23: (hh - 1); mm = 59; } else mm--; this.setValue(DU.util.LString.lPad(hh, '0', 2) + DU.util.LString.lPad(mm, '0', 2)); }, /** * @description width 속성에 따른 실제 적용 메소드 * @method _setWidth * @protected * @param {String} type 속성의 이름 * @param {Array} args 속성의 값 배열 * @param {Object} obj 적용된 객체 * @return void */ _setWidth : function(type, args, obj) { var width = args[0]; if (!DU.isBorderBox) { this.el.setWidth(width); this.getDisplayEl().setWidth(width - 16); this.iconDivEl.setLeft(width - 16); } else { this.el.setWidth(width - 4); this.getDisplayEl().setWidth(width - 20); this.iconDivEl.setLeft(width - 20); } this.width = width; this.cfg.setProperty('width', this.width, true); }, /** * @description 유효성을 검증하는 메소드 * @method validateValue * @protected * @param {object} value 값 * @return {Boolean} */ validateValue : function(val) { return DU.isEmpty(val) ? true : DU.util.LString.isTime(val); }, /** * @description 값을 변경한다. * @method setValue * @public * @param {String} o 반영할 값 * @return {void} */ setValue: function(val) { DU.widget.LTimeBox.superclass.setValue.call(this, val); if(this.getDisplayValue().length > 0 && this.getDisplayValue().length != 5) this.setDisplayValue(val.substring(0, 2) + ":" + val.substring(2, 4)); } }); /** * The LCalendar component * @module widget_calendar * @title LCalendar * @namespace DU.widget * @requires DU,dom,event */ (function() { var Dom = DU.util.LDom, Event = DU.util.LEvent, Lang = DU; /** * 달력 * @namespace DU.widget * @class LCalendar * @constructor * @param {String} id [optional] 달력 아이디 * @param {String | HTMLElement} container 달력 컨테이너 dom 객체 아이디 * @param {Object} config [optional] config 객체 */ function LCalendar(id, containerId, config) { this.init.apply(this, arguments); config = config || {}; } /** * The path to be used for images loaded for the LCalendar * @property DU.widget.LCalendar.IMG_ROOT * @static * @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively * @type String */ LCalendar.IMG_ROOT = null; /** * Type constant used for renderers to represent an individual date (M/D/Y) * @property DU.widget.LCalendar.DATE * @static * @final * @type String */ LCalendar.DATE = "D"; /** * Type constant used for renderers to represent an individual date across any year (M/D) * @property DU.widget.LCalendar.MONTH_DAY * @static * @final * @type String */ LCalendar.MONTH_DAY = "MD"; /** * Type constant used for renderers to represent a weekday * @property DU.widget.LCalendar.WEEKDAY * @static * @final * @type String */ LCalendar.WEEKDAY = "WD"; /** * Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y) * @property DU.widget.LCalendar.RANGE * @static * @final * @type String */ LCalendar.RANGE = "R"; /** * Type constant used for renderers to represent a month across any year * @property DU.widget.LCalendar.MONTH * @static * @final * @type String */ LCalendar.MONTH = "M"; /** * Constant that represents the total number of date cells that are displayed in a given month * @property DU.widget.LCalendar.DISPLAY_DAYS * @static * @final * @type Number */ LCalendar.DISPLAY_DAYS = 42; /** * Constant used for halting the execution of the remainder of the render stack * @property DU.widget.LCalendar.STOP_RENDER * @static * @final * @type String */ LCalendar.STOP_RENDER = "S"; /** * Constant used to represent short date field string formats (e.g. Tu or Feb) * @property DU.widget.LCalendar.SHORT * @static * @final * @type String */ LCalendar.SHORT = "short"; /** * Constant used to represent long date field string formats (e.g. Monday or February) * @property DU.widget.LCalendar.LONG * @static * @final * @type String */ LCalendar.LONG = "long"; /** * Constant used to represent medium date field string formats (e.g. Mon) * @property DU.widget.LCalendar.MEDIUM * @static * @final * @type String */ LCalendar.MEDIUM = "medium"; /** * Constant used to represent single character date field string formats (e.g. M, T, W) * @property DU.widget.LCalendar.ONE_CHAR * @static * @final * @type String */ LCalendar.ONE_CHAR = "1char"; /** * The set of default Config property keys and values for the LCalendar * @property DU.widget.LCalendar._DEFAULT_CONFIG * @final * @static * @private * @type Object */ LCalendar._DEFAULT_CONFIG = { // Default values for pagedate and selected are not class level constants - they are set during instance creation PAGEDATE: { key: "pagedate", value: null }, SELECTED: { key: "selected", value: null }, TITLE: { key: "title", value: "" }, CLOSE: { key: "close", value: false }, IFRAME: { key: "iframe", value: (DU.browser.msie && DU.browser.msie <= 6) ? true : false }, MINDATE: { key: "mindate", value: null }, MAXDATE: { key: "maxdate", value: null }, MULTI_SELECT: { key: "multi_select", value: false }, START_WEEKDAY: { key: "start_weekday", value: 0 }, SHOW_WEEKDAYS: { key: "show_weekdays", value: true }, SHOW_WEEK_HEADER: { key: "show_week_header", value: false }, SHOW_WEEK_FOOTER: { key: "show_week_footer", value: false }, HIDE_BLANK_WEEKS: { key: "hide_blank_weeks", value: false }, NAV_ARROW_LEFT: { key: "nav_arrow_left", value: null }, NAV_ARROW_RIGHT: { key: "nav_arrow_right", value: null }, MONTHS_SHORT: { key: "months_short", value: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }, MONTHS_LONG: { key: "months_long", value: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] }, WEEKDAYS_1CHAR: { key: "weekdays_1char", value: ["S", "M", "T", "W", "T", "F", "S"] }, WEEKDAYS_SHORT: { key: "weekdays_short", value: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] }, WEEKDAYS_MEDIUM: { key: "weekdays_medium", value: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] }, WEEKDAYS_LONG: { key: "weekdays_long", value: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] }, LOCALE_MONTHS: { key: "locale_months", value: "long" }, LOCALE_WEEKDAYS: { key: "locale_weekdays", value: "short" }, DATE_DELIMITER: { key: "date_delimiter", value: "," }, DATE_FIELD_DELIMITER: { key: "date_field_delimiter", value: "/" }, DATE_RANGE_DELIMITER: { key: "date_range_delimiter", value: "~" }, MY_MONTH_POSITION: { key: "my_month_position", value: 1 }, MY_YEAR_POSITION: { key: "my_year_position", value: 2 }, MD_MONTH_POSITION: { key: "md_month_position", value: 1 }, MD_DAY_POSITION: { key: "md_day_position", value: 2 }, MDY_MONTH_POSITION: { key: "mdy_month_position", value: 1 }, MDY_DAY_POSITION: { key: "mdy_day_position", value: 2 }, MDY_YEAR_POSITION: { key: "mdy_year_position", value: 3 }, MY_LABEL_MONTH_POSITION: { key: "my_label_month_position", value: 1 }, MY_LABEL_YEAR_POSITION: { key: "my_label_year_position", value: 2 }, MY_LABEL_MONTH_SUFFIX: { key: "my_label_month_suffix", value: " " }, MY_LABEL_YEAR_SUFFIX: { key: "my_label_year_suffix", value: "" }, NAV: { key: "navigator", value: null }, STRINGS: { key: "strings", value: { previousMonth: "Previous Month", nextMonth: "Next Month", previousYear: "Previous Year", nextYear: "Next Year", close: "Close" }, supercedes: ["close", "title"] } }; var DEF_CFG = LCalendar._DEFAULT_CONFIG; /** * The set of Custom Event types supported by the LCalendar * @property DU.widget.LCalendar._EVENT_TYPES * @final * @static * @private * @type Object */ LCalendar._EVENT_TYPES = { BEFORE_SELECT: "beforeSelect", SELECT: "select", BEFORE_DESELECT: "beforeDeselect", DESELECT: "deselect", CHANGE_PAGE: "changePage", BEFORE_RENDER: "beforeRender", RENDER: "render", RENDER_CELL: "renderCell", BEFORE_DESTROY: "beforeDestroy", DESTROY: "destroy", RESET: "reset", CLEAR: "clear", BEFORE_HIDE: "beforeHide", HIDE: "hide", BEFORE_SHOW: "beforeShow", SHOW: "show", BEFORE_HIDE_NAV: "beforeHideNav", HIDE_NAV: "hideNav", BEFORE_SHOW_NAV: "beforeShowNav", SHOW_NAV: "showNav", BEFORE_RENDER_NAV: "beforeRenderNav", RENDER_NAV: "renderNav" }; /** * The set of default style constants for the LCalendar * @property DU.widget.LCalendar._STYLES * @final * @static * @private * @type Object */ LCalendar._STYLES = { CSS_ROW_HEADER: "calrowhead", CSS_ROW_FOOTER: "calrowfoot", CSS_CELL: "calcell", CSS_CELL_SELECTOR: "selector", CSS_CELL_SELECTED: "selected", CSS_CELL_SELECTABLE: "selectable", CSS_CELL_RESTRICTED: "restricted", CSS_CELL_TODAY: "today", CSS_CELL_OOM: "oom", CSS_CELL_OOB: "previous", CSS_HEADER: "calheader", CSS_HEADER_TEXT: "calhead", CSS_BODY: "calbody", CSS_WEEKDAY_CELL: "calweekdaycell", CSS_WEEKDAY_ROW: "calweekdayrow", CSS_FOOTER: "calfoot", CSS_CALENDAR: "L-calendar", CSS_SINGLE: "single", CSS_CONTAINER: "L-calcontainer", CSS_NAV_YEAR_LEFT: "calnavyearleft", CSS_NAV_YEAR_RIGHT: "calnavyearright", CSS_NAV_LEFT: "calnavleft", CSS_NAV_RIGHT: "calnavright", CSS_NAV: "calnav", CSS_CLOSE: "calclose", CSS_CELL_TOP: "calcelltop", CSS_CELL_LEFT: "calcellleft", CSS_CELL_RIGHT: "calcellright", CSS_CELL_BOTTOM: "calcellbottom", CSS_CELL_HOVER: "calcellhover", CSS_CELL_HIGHLIGHT1: "highlight1", CSS_CELL_HIGHLIGHT2: "highlight2", CSS_CELL_HIGHLIGHT3: "highlight3", CSS_CELL_HIGHLIGHT4: "highlight4" }; LCalendar.prototype = { /** * config 객체 * @property Config * @private * @deprecated LConfiguration properties should be set by calling LCalendar.cfg.setProperty. * @type Object */ Config: null, /** * parent LCalendarGroup * @property parent * @type LCalendarGroup */ parent: null, /** * calendar group의 index * @property index * @type Number */ index: -1, /** * calendar table의 배열 * @property cells * @type HTMLTableCellElement[] */ cells: null, /** * calendar table의 배열의 날짜값, format은 [YYYY, M, D]. * @property cellDates * @type Array[](Number[]) */ cellDates: null, /** * 아이디 * @property id * @type String */ id: null, /** * 컨테이너 아이디 * @property containerId * @type String */ containerId: null, /** * 컨테이너 dom 객체 * @property oDomContainer * @type HTMLElement */ oDomContainer: null, /** * 오늘 날짜 * @property today * @type Date */ today: null, /** * cells을 render할 때 사용하는 내부배열 * @property renderStack * @type Array[] */ renderStack: null, /** * cells을 render할 때 사용하는 내부배열 사본 * @property _renderStack * @private * @type Array */ _renderStack: null, /** * LCalendarNavigator 객체 * @property oNavigator * @type LCalendarNavigator */ oNavigator: null, /** * 선택된 날짜 배열 * @property _selectedDates * @private * @type Array */ _selectedDates: null, /** * 이벤트 맵 * @property domEventMap * @type Object */ domEventMap: null, /** * 생성자 파라미터 파서 * @protected * @method _parseArgs * @param {Array} Function "arguments" array * @return {Object} Object with id, container, config properties containing * the reconciled argument values. **/ _parseArgs: function(args) { /* 2.4.0 Constructors signatures new LCalendar(String) new LCalendar(HTMLElement) new LCalendar(String, ConfigObject) new LCalendar(HTMLElement, ConfigObject) Pre 2.4.0 Constructor signatures new LCalendar(String, String) new LCalendar(String, HTMLElement) new LCalendar(String, String, ConfigObject) new LCalendar(String, HTMLElement, ConfigObject) */ var nArgs = { id: null, container: null, config: null }; if (args && args.length && args.length > 0) { switch (args.length) { case 1: nArgs.id = args[0].id ? args[0].id : null; nArgs.container = args[0].applyTo ? args[0].applyTo : args[0]; nArgs.config = typeof args[0] == 'object' ? args[0] : null; break; case 2: if (Lang.isObject(args[1]) && !args[1].tagName && !(args[1] instanceof String)) { nArgs.id = null; nArgs.container = args[0]; nArgs.config = args[1]; } else { nArgs.id = args[0]; nArgs.container = args[1]; nArgs.config = null; } break; default: // 3+ nArgs.id = args[0]; nArgs.container = args[1]; nArgs.config = args[2]; break; } } else { } return nArgs; }, /** * LCalendar init 메소드. * @method init * @private * @param {String} id optional The id of the table element that will represent the LCalendar widget. As of 2.4.0, this argument is optional. * @param {String | HTMLElement} container The id of the container div element that will wrap the LCalendar table, or a reference to a DIV element which exists in the document. * @param {Object} config optional The configuration object containing the initial configuration values for the LCalendar. */ init: function(id, container, config) { // Normalize 2.4.0, pre 2.4.0 args var nArgs = this._parseArgs(arguments); id = nArgs.id; container = nArgs.container; config = nArgs.config; //du_config설정 config = DU.util.LDom.applyIfProperties(config, '$.ext.calendar'); this.oDomContainer = Dom.get(container); if (!this.oDomContainer.id) { this.oDomContainer.id = Dom.generateId(); } if (!id) { id = this.oDomContainer.id + "_t"; } this.id = id; this.containerId = this.oDomContainer.id; this.initEvents(); this.today = new Date(); DU.util.LDate.clearTime(this.today); /** * The Config object used to hold the configuration variables for the LCalendar * @property cfg * @type DU.widget.LConfig */ this.cfg = new DU.widget.LConfig(this); /** * The local object which contains the LCalendar's options * @property Options * @type Object */ this.Options = {}; /** * The local object which contains the LCalendar's locale settings * @property Locale * @type Object */ this.Locale = {}; this.initStyles(); Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); Dom.addClass(this.oDomContainer, "L-fixed"); this.cellDates = []; this.cells = []; this.renderStack = []; this._renderStack = []; this.setupConfig(); if (config) { this.cfg.applyConfig(config, true); } this.cfg.fireQueue(); //du_config읽어서 local 설정하기 this._setDefaultLocale(); }, /** * @description 사용자가 직접 .cfg.setProperty 를 호출하지 않도록 사용성을 위해 wrapping * @method setProperty * @param key {object} * @param value {object} */ setProperty : function(key,value){ this.cfg.setProperty(key,value); }, /** * @description 사용자가 직접 .cfg.setProperty 를 호출하지 않도록 사용성을 위해 wrapping * @method getProperty * @param key {object} * @return {object} */ getProperty : function(key){ return this.cfg.getProperty(key); }, _setDefaultLocale: function(config) { var locale = DU.getConfig().getFirst("$.core.defaultLocale"); //LDateLocale값을 사용. var aLocale = DU.util.LDate.getLocale(locale); var configLocale = DU.getConfig().getFirst('$.ext.calendar.locale.' + locale); var x = aLocale["x"]; var order = x.split('%'); var posY = 1; var posM = 2; var posD = 3; var c = ""; for(var i=1;i