| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044 |
- /*
- DOMElement管理类
- var item = new MDomItem( containerNode, {
- name : "demo",
- type : "checkbox",
- selectValue: [opt1,opt2,opt3]
- selectText : function( callback , options ){ //异步方法的写法,需要一个callback,并且把该option值传给callback执行,这个function不能bind
- this.app.actions.XXX( id, function( json ){
- var optText = [];
- ....
- callback( optText )
- })
- },
- value : function(){ var val = .... ; return val; }
- } , null, app, css);
- item.load();
- 外部方法:
- get( textOrValue ) 参数"text"或"value" 获取文本或值
- getValue() 获取值
- getText() 获取文本
- getModifiedValue() 获取修改过的值,如果没有修改过返回null
- getModifiedText() 获取修改过的文本,如果没有修改过返回null
- setValue() 设置对象的值
- resetType( type ) 修改类型
- resetItemOptions( selectValue[, selectText ]) 修改可选项,selectValue可项值,selectText可选文本
- dispose() 清空对象
- verify( isShowWarning ) 参数isShowWarning,校验不通过的是否提示用户。根据isShowWarning参数和options的notEmpty、warningType、validRule属性校验对象,返回boolean
- */
- var MDomItem_ClassType = {
- "text" : "Text",
- "textarea" : "Textarea",
- "hidden" : "Hidden",
- "password" : "Password",
- "radio" : "Radio",
- "checkbox" : "Checkbox",
- "select" : "Select",
- "multiselect" : "Multiselect",
- "innertext" : "Innertext",
- "innerhtml" : "Innerhtml",
- "img" : "Img",
- "button" : "Button",
- "mselector" : "MSelector",
- "imageclipper" : "ImageClipper",
- "rtf" : "Rtf",
- "org" : "Org",
- "a" : "A"
- };
- var MDomItem = new Class({
- Implements: [Options, Events],
- options : {
- name : "", //生成的对象的name属性
- value : "", //对象的值
- text : "", //对应的中文名称
- type : "", //可以为 text,innertext, radio,checkbox,select,multiselect,img,button,hidden,rtf,imageClipper, org, mSelector
- isEdited : true,
- tType : "", //type 为text时候有效,可以为 number,date,time, datetime,person、unit、identity,如果是组织混合选择用数组,如["person"、"unit"、"identity"]
- orgType : "", //person、unit、identity, process, duty,如果是混合选择用数组,如["person"、"unit"、"identity"]
- unitType : "", //如果orgType包含unit,则可以指定组织类型
- count : 1, //如果是多选,多选的上限值,0表示无限制,默认为1,
- units : [], //orgType 为 identity、unit时的,部门选择范围
- groups : [], //orgType 为 person 时的选择访问
- exclude : [], //选择时的排除项目
- expandSubEnable : true, //orgType 为 identity、unit时是否展开下级选择范围
- orgStyle : "", //显示类型,比如default, xform 等
- unsetDefaultEvent : false, //tType 或 orgType 有值时,是否取消默认事件
- //可以传入json 如 : { change : function(){alert("change " + this.name );}, click : function(){alert("click " + this.name) } }
- //或 字符串 : "{ change : function(){alert('change ' + this.name );}, click : function(){alert('click ' + this.name) } }"
- //或字符串: "change^^function(){alert('change ' + this.name );##click^^function(obj){alert('click ' + this.name);}"
- event : null, //需要绑定的事件
- selectValue : "", //选择性控件的可选值
- selectText : "", //选择型控件的可选文本
- defaultValue : "", //默认值
- className : "", //类
- style : {}, //样式
- attr : {}, //其他参数, 比如 " {readonly : true, size : '20' }"
- notEmpty : false, //是否允许为空,默认允许
- defaultValueAsEmpty: false, //检查空值时,默认值是否为空,并且获取值得时候,如果是默认值,返回空值
- emptyTip : null, //为空时的提示,可以不设置
- disable : false, //为false,则load失效;
- //alert 或者 batch 或者 single,单个提醒或者批量提醒
- warningType : "batch",
- validImmediately : false,
- //可以传入校验类型或自定义方法,如
- //{email : true , url : true, date : true, dateISO : true, number : true, digits : true,
- // maxlength:5, minlength:10, rangelength:[5,10], max:5, min:10 ,range:[5,10], extension: ["xls","xlsx"],fun : function(){ return true }
- // }
- validRule : null,
- //validMessage和validRule对应,出错时提示的信息,如 {email : "请输入正确格式的电子邮件", fun : "请输入正确的密码"},如果不设置,默认如下:
- // { email: "请输入正确格式的电子邮件",
- // url: "请输入合法的网址",
- // date: "请输入合法的日期",
- // dateISO: "请输入合法的日期 (ISO).",
- // number: "请输入合法的数字",
- // digits: "只能输入整数",
- // maxlength: this.format("请输入一个 长度最多是 {0} 的字符串"),
- // minlength: this.format("请输入一个 长度最少是 {0} 的字符串"),
- // rangelength: this.format("请输入 一个长度介于 {0} 和 {1} 之间的字符串"),
- // range: this.format("请输入一个介于 {0} 和 {1} 之间的值"),
- // max: this.format("请输入一个最大为{0} 的值"),
- // min: this.format("请输入一个最小为{0} 的值"),
- // fun : "请输入正确的"+ this.options.text
- // }
- validMessage : null,
- RTFConfig : null, //CKEditor 的设置项
- mSelectorOptions : null, //自定义下拉组件设置项
- calendarOptions : null, //日期选择器的设置项
- orgWidgetOptions : null //org组件的选项
- },
- initialize: function (container, options , parent, app, css ) {
- this.form = parent;
- this.tr = parent;
- this.parent = parent;
- this.app = app;
- this.container = $(container);
- this.css = css;
- //for(var o in options ){ //允许使用 function 来计算设置, on开头的属性被留作 fireEvent
- // if( o != "validRule" && o!="validMessage" && o.substr(0,2)!="on" && typeOf( options[o] )== "function" ){
- // options[o] = options[o].call();
- // }
- //}
- //this.setOptions(options);
- this.valSeparator = /,|;|\^\^|\|/; //如果是多值对象,作为用户选择的多个值的分隔符
- this.mElement = this.container; //容器
- this.items = [];
- this.setOptionList( options );
- },
- setOptionList : function( options ){ //目的是使用options里的function异步方法通过 function(callback){ ...获取value; callback( value ); } 来回调设置option
- var callbackNameList = [];
- for(var o in options ){ //允许使用 function 来计算设置, on开头的属性被留作 fireEvent
- if( o != "validRule" && o!="validMessage" && o.substr(0,2)!="on" && typeOf( options[o] )== "function" ){
- var fun = options[o];
- if( fun.length && /\(\s*([\s\S]*?)\s*\)/.exec(fun)[1].split(/\s*,\s*/)[0] == "callback" ){ //如果有行参(fun.length!=0),并且第一形参是callback,注意,funciont不能bind(this),否则不能判断
- callbackNameList.push( o );
- }else{
- options[o] = fun( options ); //执行fun
- }
- }
- }
- this.setFunOption( options, callbackNameList, true ); //递归执行回调设置options
- },
- setFunOption : function( options, callbackNameList, isFirst ){
- this.optionsReady = false;
- if( callbackNameList.length == 0 ){
- this.setOptions( options );
- this.optionsReady = true;
- if( this.loadFunctionCalled ){ //如果外部程序已经执行过load,但是由于options没有设置完成而中断,需要再调用一下load
- this.load();
- }
- }else{
- if( isFirst )options = Object.merge( {}, options ); //避免外部程序对options的修改
- var name = callbackNameList.shift(); //返回第一个元素,然后在callbackNameList删除第一元素
- var fun = options[name]; //对应的参数,是一个function
- fun( function( val ){ //执行function
- options[name] = val; //在回调内部给option赋值
- this.setFunOption( options, callbackNameList, false ); //继续执行下一个回调
- }.bind(this), options );
- }
- },
- load: function () {
- if( !this.optionsReady ){ //如果options没有设置完成
- this.loadFunctionCalled = true;
- return;
- }
- if( this.options.disable )return;
- if( ! this.options.type ){
- this.options.type = this.options.orgType ? "org" : "text";
- }
- this.options.type = this.options.type.toLowerCase();
- this.fireEvent("queryLoad");
- this.createElement();
- this.fireEvent("postLoad", [this]);
- },
- editMode : function(){
- this.options.isEdited = true;
- this.dispose();
- this.load();
- },
- save : function(){
- this.options.value = this.getValue();
- },
- readMode : function(){
- this.options.isEdited = false;
- this.dispose();
- this.load();
- },
- enable : function(){
- this.options.disable = false;
- this.dispose();
- this.load();
- },
- disable : function(){
- this.options.disable = true;
- this.dispose();
- },
- createElement:function(){
- if( this.options.disable )return;
- var clazzName = MDomItem_ClassType[ this.options.type ];
- if( clazzName ){
- this.dom = new MDomItem[ clazzName ]( this );
- this.dom.load();
- }
- return this.container;
- },
- get: function( vort ){ //value 和 text
- if( this.options.disable ){
- return {
- text : "",
- value : ""
- };
- }
- if( this.dom )return this.dom.get( vort );
- },
- getValue : function( separator, name ){
- var result = this.get( null , name ).value;
- if( separator && typeOf( result ) == "array" ){
- return result.join( separator );
- }else{
- return result;
- }
- },
- getText : function( separator, name ){
- var result = this.get( null , name ).text;
- if( separator && typeOf( result ) == "array" ){
- return result.join( separator );
- }else{
- return result;
- }
- },
- getModifiedValue : function( separator ){
- var value = this.getValue( separator );
- return value == this.options.value ? null : value ;
- },
- getModifiedText : function(){
- var value = this.getText();
- return text == this.options.text ? null : text ;
- },
- getVaildValue : function(verify, separator, isHiddenWarming, onlyModified ) {
- if ( !verify || this.verify(!isHiddenWarming)) {
- return onlyModified ? this.getModifiedValue( separator ) : this.getValue( separator );
- } else {
- return false;
- }
- },
- set : function( type, valueOrText ){
- this.setValue( valueOrText )
- },
- resetItemOptions : function( selectValue, selectText, isForce ){
- if( this.options.disable ){
- if( isForce ){
- this.options.disable = false;
- }else{
- return;
- }
- }
- var availTypes = "radio,checkbox,select,multiselect".split( "," );
- if( !availTypes.contains( this.options.type ) )return;
- this.dispose();
- this.options.selectValue = selectValue;
- this.options.selectText = selectText;
- this.createElement();
- },
- reset: function(){
- this.setValue( this.options.defaultValue || "" );
- },
- setValue :function(value){
- if( this.dom )this.dom.setValue(value);
- },
- setStyles : function( styles ){
- if( this.options.disable )return;
- this.items.each( function( item ){
- item.setStyles( styles )
- })
- },
- getElements : function(){
- if( this.options.disable )return null;
- return this.mElement.getElements("[name='"+this.options.name+"']");
- },
- dispose : function(){
- this.container.empty();
- },
- verify : function( isShowWarning ){
- var flag = true;
- if( !this.options.isEdited )return flag;
- if( this.options.disable )return flag;
- if( this.options.warningType == "batch" ){
- if( !this.isNotEmpty(isShowWarning) ) flag = false;
- if( !this.checkValid(isShowWarning) ) flag = false;
- }else{
- if( !this.isNotEmpty(isShowWarning) || !this.checkValid(isShowWarning) ){
- return false;
- }
- }
- return flag;
- },
- isNotEmpty: function( isShowWarning ){
- if( !this.options.isEdited )return true;
- if( this.options.disable )return true;
- if( this.options.notEmpty == true || this.options.notEmpty == "yes" ){
- if( !this.checkNotEmpty( isShowWarning ) ){
- return false;
- }
- }
- return true;
- },
- checkNotEmpty:function( isShowWarning ){
- if( this.options.disable )return true;
- var value = this.getValue();
- var isEmpty = ( typeOf(value) === "array" ? ( value.length == 0 ) : ( value == "" || value == " ") );
- if( !isEmpty && this.options.defaultValueAsEmpty ){
- isEmpty = ( typeOf(value) === "array" ? ( value.length == 1 && value[0] == this.options.defaultValue ) : ( value == this.options.defaultValue ) );
- }
- if( !isEmpty ){
- this.clearWarning("empty");
- return true;
- }
- if( !isShowWarning )return false;
- var text = this.options.text;
- var items = this.mElement.getElements("[name='"+ this.options.name + "']");
- var warningText = "";
- var focus = false;
- try{
- warningText = this.options.emptyTip || (this.dom && this.dom.getErrorText()) || (text+"不能为空");
- if( this.options.warningType == "batch" ) {
- this.setWarning(warningText, "empty");
- }else if( this.options.warningType == "single" ){
- this.setWarning(warningText, "empty");
- }else{
- if( this.app && this.app.notice ){
- if (!this.container.isIntoView()){
- var pNode = this.container.getParent();
- while (pNode && ((pNode.getScrollSize().y-(pNode.getComputedSize().height+1)<=0) || pNode.getStyle("overflow")==="visible")) pNode = pNode.getParent();
- if (!pNode) pNode = document.body;
- pNode.scrollToNode(this.container, "bottom");
- }
- var y = this.container.getSize().y;
- this.app.notice(warningText,"error",this.container, {"x": "right", "y": "top"}, { x : 10, y : y });
- }
- if( !this.options.validImmediately ){
- if( ["text","password","textarea","select","multiselect"].contains( this.options.type ) ){
- items[0].focus();
- }
- }
- }
- this.fireEvent("empty", this);
- }catch( e ){
- }
- return false;
- },
- clearWarning : function( type ){
- if( this.tipNode && this.setedEmpty ){
- this.fireEvent("unempty", this);
- this.tipNode.empty();
- this.setedEmpty = false;
- }
- if( type == "empty" ){
- if( this.warningEmptyNode ){
- this.fireEvent("unempty", this);
- this.warningEmptyNode.destroy();
- this.warningEmptyNode = null;
- }
- }else{
- if( this.warningInvalidNode ){
- this.fireEvent("unempty", this);
- this.warningInvalidNode.destroy();
- this.warningInvalidNode = null;
- }
- }
- this.warningStatus = false;
- },
- setWarning : function( msg, type ){
- var div;
- if( type == "empty" ){
- if( this.tipNode ){
- this.setedEmpty = true;
- div = this.tipNode;
- div.set("html", "");
- }else if( this.warningEmptyNode ){
- div = this.warningEmptyNode;
- div.set("html", "");
- }else{
- div = this.warningEmptyNode = new Element("div");
- div.inject( this.container ) ;
- }
- }else{
- if( this.tipNode ){
- this.setedEmpty = true;
- div = this.tipNode;
- div.set("html", "");
- }else if( this.warningInvalidNode ){
- div = this.warningInvalidNode;
- div.set("html", "");
- }else{
- div = this.warningInvalidNode = new Element("div");
- div.inject( this.container ) ;
- }
- }
- this.warningStatus = true;
- if( typeOf(msg) != "array" ){
- msg = [msg];
- }
- msg.each( function(m){
- //var html = "<table style=\"margin-top:3px;\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
- //html += "<tr valign=\"middle\"><td><img src=\"./img/exclamation.png\" /></td>";
- //html += "<td style=\"width:3px;\"></td><td><div style=\"color:#FF0000; margin-top:2px;\">"+m+"</div></td></tr>";
- //html += "</table>";
- var node = new Element("div",{
- "text" : m,
- "styles" : this.css.warningMessageNode
- }).inject(div)
- }.bind(this))
- },
- checkValid : function( isShowWarning ){
- if( this.options.disable )return true;
- var value = this.getValue();
- var rules = this.options.validRule;
- if( !rules )return true;
- var msgs = [];
- var flag = true;
- //if( value && value != "" && value != " " ){
- for(var r in rules ){
- var valid = true;
- var rule = rules[r];
- if( typeof rule == "function"){
- valid = rule.call( this, value, this );
- }else if( this.validMethod[r] ){
- var method = this.validMethod[r];
- valid = method.call(this, value, rule, this );
- }
- if( !valid && isShowWarning ){
- var msg = this.getValidMessage( r, rule );
- if( msg != "" )msgs.push( msg );
- }
- if( !valid )flag = false;
- }
- //}
- if( msgs.length > 0 ){
- if( this.options.warningType == "batch" ) {
- this.setWarning(msgs, "invaild");
- }else if( this.options.warningType == "single" ){
- this.setWarning(msgs, "invaild");
- }else{
- if( this.app && this.app.notice ) {
- if (!this.container.isIntoView()) {
- var pNode = this.container.getParent();
- while (pNode && ((pNode.getScrollSize().y - (pNode.getComputedSize().height + 1) <= 0) || pNode.getStyle("overflow") === "visible")) pNode = pNode.getParent();
- if (!pNode) pNode = document.body;
- pNode.scrollToNode(this.container, "bottom");
- }
- var y = this.container.getSize().y;
- this.app.notice(msgs.join("\n"), "error", this.container, {"x": "right", "y": "top"}, { x : 10, y : y });
- }
- }
- this.fireEvent("empty", this);
- }else{
- if( this.warningInvalidNode ){
- this.warningInvalidNode.destroy();
- this.warningInvalidNode = null;
- }
- this.fireEvent("unempty", this);
- }
- return flag;
- },
- validMethod : {
- email: function( value ) {
- return /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value );
- },
- url: function( value ) {
- return /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test( value );
- },
- phoneNumber: function( value ){
- return /^0?1[0-9]\d{9}$/.test( value );
- },
- date: function( value ) {
- return !/Invalid|NaN/.test( new Date( value ).toString() );
- },
- dateISO: function( value ) {
- return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value );
- },
- number: function( value ) {
- return /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value );
- },
- digits: function( value ) {
- return /^\d+$/.test( value );
- },
- minlength: function( value, param ) {
- return value.length >= param;
- },
- maxlength: function( value, param ) {
- return value.length <= param;
- },
- rangelength: function( value, param ) {
- return ( value.length >= param[ 0 ] && value.length <= param[ 1 ] );
- },
- min: function( value, param ) {
- return value >= param;
- },
- max: function( value, param ) {
- return value <= param;
- },
- range: function( value, param ) {
- return ( value >= param[ 0 ] && value <= param[ 1 ] );
- },
- extension: function( value, param ){
- param = typeOf( param ) == "array" ? param.join("|") : param.replace(/,/g, "|"); //"png|jpe?g|gif";
- return value.match(new RegExp(".(" + param + ")$", "i"));
- }
- },
- getValidMessage : function( type, param ){
- var msg = this.options.validMessage;
- if( msg && typeOf(msg) == "object" ){
- if( msg[type] ){
- if( typeof msg[type] == "function" ){
- return (msg[type]).call(this);
- }else{
- return msg[type];
- }
- }
- }
- switch( type ){
- case "email":
- return "请输入正确格式的电子邮件";
- case "url":
- return "请输入合法的网址";
- case "phoneNumber" :
- return "请输入正确的手机号码";
- case "date":
- return "请输入合法的日期";
- case "dateISO":
- return "请输入合法的日期 .";
- case "number":
- return "请输入合法的数字";
- case "digits":
- return "只能输入整数";
- case "maxlength":
- return "长度不能超过"+ param ;
- case "minlength":
- return "长度不能小于"+ param ;
- case "rangelength":
- return "长度不能要介于"+ param[0] + "和" + param[1] + "之间" ;
- case "range":
- return "请输入一个介于"+ param[0] + " 和 "+ param[1] + "之间的值" ;
- case "min":
- return "请输入一个最小为"+ param +" 的值" ;
- case "max":
- return "请输入一个最大为"+ param +"的值" ;
- case "extension":
- return "请上传" + param + "格式的附件" ;
- default :
- return "请输入正确的"+ this.options.text ;
- }
- },
- destroy: function(){
- if( this.dom && this.dom.OrgWidgetList ){
- this.dom.OrgWidgetList.each( function( widget ){
- widget.destroy();
- })
- }
- if( this.mElement ){
- this.mElement.empty();
- }
- MWF.release( this );
- }
- });
- MDomItem.Util = {
- selectCalendar : function( target, container, options, callback ){
- var type = options.type;
- var calendarOptions = {
- "style" : "xform",
- "isTime": type == "time" || type.toLowerCase() == "datetime",
- "timeOnly": type == "time",
- "target": container,
- "onComplate" : function( dateString ,date ){
- if( callback )callback( dateString, date );
- }.bind(this)
- };
- if( options.calendarOptions ){
- calendarOptions = Object.merge( calendarOptions, options.calendarOptions )
- }
- var calendar;
- MWF.require("MWF.widget.Calendar", function(){
- calendar = new MWF.widget.Calendar( target, calendarOptions);
- calendar.show();
- }.bind(this), false);
- return calendar;
- },
- selectPerson: function( container, options, callback ){
- MWF.xDesktop.requireApp("Selector", "package", null, false);
- var selectType = "", selectTypeList = [];
- var type = options.type;
- if( typeOf( type ) == "array" ){
- if( type.length > 1 ){
- selectTypeList = type;
- }else if( type.length == 0 ) {
- selectType = "person";
- }else{
- selectType = type[0] || "person";
- }
- }else{
- selectType = type || "person";
- }
- var opt = {
- "type": selectType,
- "types" : selectTypeList,
- "title": options.title,
- "count" : options.count,
- "values": options.selectedValues || [],
- "units" : options.units,
- "unitType" : options.unitType,
- "groups" : options.groups,
- "expand": options.expand,
- "exclude" : options.exclude || [],
- "expandSubEnable" : options.expandSubEnable,
- "onComplete": function( array ){
- if( callback )callback( array );
- }.bind(this)
- };
- if( opt.types.length === 0 )opt.types = null;
- var selector = new MWF.O2Selector(container, opt );
- },
- replaceText : function( value, selectValue, selectText, separator ){
- if( typeOf( value ) == "number" )value = [ value ];
- if( typeOf( selectValue ) == "number" )selectValue = [ selectValue ];
- if( typeOf( selectText ) == "number" )selectText = [ selectText ];
- var vals = typeOf( value ) == "array" ? value : value.split( separator );
- var selectValues = typeOf( selectValue ) == "array" ? selectValue : selectValue.split( separator );
- var selectTexts = typeOf( selectText ) == "array" ? selectText : selectText.split( separator );
- for( var i=0 ;i<vals.length; i++ ){
- for( var j= 0; j<selectValues.length; j++){
- if( vals[i] == selectValues[j] ){
- vals[i] = selectTexts[j]
- }
- }
- }
- return vals;
- },
- getEvents : function( events ){
- if( !events || events == "" || events == "$none" )return;
- if( typeof events == "string" ){
- if( events.indexOf("^^") > -1 ){
- var eventsArr = events.split("##");
- if( eventsArr[0].split("^^").length != 2 )return;
- events = {};
- for(var i=0;i<eventsArr.length;i++){
- var ename = eventsArr[i].split("^^")[0];
- var efunction = eventsArr[i].split("^^")[1];
- events[ ename ] = eval( "(function(){ return "+ efunction +" })()" ); //字符串变对象或function,方法1
- }
- }else{
- //字符串变对象或function,方法2
- eval( "var events = " + events );
- }
- }
- return events;
- },
- bindEvent: function( obj, item, events){
- events = MDomItem.Util.getEvents( events );
- if( typeOf(events) == "object" ){
- for( var e in events ){
- //jquery的写法
- //item.bind( e, { fun : events[e] }, function( event ){
- //this 是触发事件的对象,self是当前jDomItem对象
- //event.data.fun.call( this, _self );
- //})
- //方法固定,把参数作为this指正传给方法,需要在方法体里通过this获取参数
- //item.addEvent( e, events[e].bind({"item": item, "_self":_self}));
- //参数固定,把方法传入到function中,可以在回调方法中直接获取,和jquery的写法一样
- item.addEvent( e, function(ev){
- this.fun.call( ev ? ev.target : null, obj.module || obj, ev );
- }.bind({fun : events[e]}));
- //不一定行
- //item.addEvent( e, (function(){
- // return function(){
- // events[e].call(item,_self);
- // }
- //})(e));
- }
- // for( var e in events ){
- // if( type && (e=="dblclick" || e=="click") ){
- // if( jQuery.inArray( type , this.unsetClassType) == -1 ){
- // if( !item.attr("title") || item.attr("title") == "" ){
- // item.attr( "title", e=="dblclick" ? "双击选择"+this.options.text : "单击选择"+this.options.text );
- // }
- // item.removeClass("inputtext").addClass("inputclick");
- // break;
- // }
- // }
- // }
- }
- }
- };
- MDomItem.Text = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- if( this.options.isEdited ){
- this.loadEdit()
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var module = this.module;
- var options = this.options;
- var item;
- var value ;
- if( typeOf( options.value ) === "boolean" ){
- value = options.value.toString();
- }else{
- value = options.value || options.defaultValue
- }
- var parent = module.container ;
- var className = this.getClassName();
- item = new Element( "input", {
- "type" : "text",
- "name" : options.name,
- "value" : value
- });
- item.set( options.attr || {} );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( options.style || {} );
- this.bindDefaultEvent( item );
- MDomItem.Util.bindEvent( this, item, options.event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- loadRead : function(){
- var module = this.module;
- var options = this.options;
- var item;
- var value;
- var className = this.getClassName();
- var parent = module.container ;
- if( typeOf( options.value ) === "boolean" ){
- value = options.value.toString();
- }else{
- value = options.value || options.defaultValue
- }
- item = new Element( "span", {
- "name" : options.name,
- "text" : value
- });
- item.set( options.attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( options.style || {} );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){ //value 和 text 或 空
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- if( this.options.isEdited ){
- value = item.get("value");
- }else{
- value = item.get("text");
- }
- if( vort == "value" )return value;
- if( vort == "text")return value;
- return {
- value : value,
- text : value
- };
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- if( this.options.isEdited ){
- item.set( "value", value );
- }else{
- item.set("text", value );
- }
- },
- getErrorText : function(){
- return this.options.text +"不能为空";
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- if (typeOf(tType) == "array") {
- if (tType.contains("identity") || tType.contains("person") || tType.contains("unit")) {
- className = "inputPerson";
- } else {
- className = "inputText";
- }
- } else {
- if (!tType) {
- className = "inputText";
- } else if (tType == "number") {
- className = "inputText";
- } else if (tType == "time" || tType == "date" || tType.toLowerCase() == "datetime") {
- className = "inputTime";
- } else if (tType == "identity" || tType == "person" || tType.toLowerCase() == "unit") {
- className = "inputPerson";
- } else {
- className = "inputText";
- }
- }
- }
- return className;
- },
- bindDefaultEvent : function( item ){
- if( this.options.unsetDefaultEvent )return;
- var tType = this.options.tType;
- var type = "text";
- if( typeOf( tType ) == "array" || ( tType == "identity" || tType.toLowerCase() == "person" || tType == "unit" ) ){
- item.addEvent( "click" , function(){
- this.module.fireEvent("querySelect", this.module );
- var options = this.options;
- var opt = {
- type : tType,
- title : options.text,
- count : options.count,
- selectedValues : this.get("value").split(","),
- units : options.units,
- unitType : options.unitType,
- groups : options.groups,
- expand : options.expand
- };
- MDomItem.Util.selectPerson( this.app.content, opt, function( array ){
- item.empty();
- this.orgData = this.module.orgData = [];
- this.orgObject = this.module.orgObject = array;
- array.each(function( it ){
- this.orgData.push( it.data.distinguishedName || it.data.name );
- }.bind(this));
- item.set("value",this.orgData.join(","));
- this.items[0].fireEvent("change");
- if( this.options.validImmediately )this.module.verify( true );
- }.bind(this))
- }.bind(this) );
- }else{
- if( tType == "number" ){
- item.addEvent( "keyup" , function(){
- this.value=this.value.replace(/[^\d.]/g,'');
- });
- if( this.options.validImmediately ){
- item.addEvent("blur", function(){ this.module.verify( true ); }.bind(this))
- }
- }else if( tType == "time" || tType.toLowerCase() == "datetime" || tType == "date" ){
- item.addEvent( "click" , function(){
- this.module.fireEvent("querySelect", this.module );
- if( this.calendarSelector ){
- this.calendarSelector.show();
- }else{
- this.calendarSelector = MDomItem.Util.selectCalendar( item, this.app.content, {
- calendarOptions : this.options.calendarOptions,
- type : tType
- }, function( dateString, date ){
- this.items[0].fireEvent("change");
- if( this.options.validImmediately )this.module.verify( true );
- }.bind(this) )
- }
- }.bind(this) );
- }else{
- if( this.options.validImmediately ){
- item.addEvent("blur", function(){ this.module.verify( true ); }.bind(this))
- }
- }
- }
- }
- });
- MDomItem.Textarea = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- if( this.options.isEdited ){
- this.loadEdit()
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var module = this.module;
- var options = this.options;
- var item;
- var value ;
- if( typeOf( options.value ) === "boolean" ){
- value = options.value.toString();
- }else{
- value = options.value || options.defaultValue
- }
- var parent = module.container ;
- var className = this.getClassName();
- item = new Element( "textarea", {
- "name" : options.name,
- "value" : value
- });
- item.set( options.attr || {} );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( options.style || {} );
- this.bindDefaultEvent( item );
- MDomItem.Util.bindEvent( this, item, options.event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- loadRead : function(){
- var module = this.module;
- var options = this.options;
- var item;
- var value;
- var className = this.getClassName();
- var parent = module.container ;
- if( typeOf( options.value ) === "boolean" ){
- value = options.value.toString();
- }else{
- value = options.value || options.defaultValue
- }
- item = new Element( "span", {
- "name" : options.name,
- "text" : value
- });
- item.set( options.attr || {} );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( options.style || {} );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- bindDefaultEvent : function( item ){
- if( this.options.unsetDefaultEvent )return;
- if( this.options.validImmediately ){
- item.addEvent("blur", function(){ this.module.verify( true ); }.bind(this))
- }
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- if( this.options.isEdited ){
- value = item.get("value");
- }else{
- value = item.get("text");
- }
- if( vort == "value" )return value;
- if( vort == "text")return value;
- return {
- value : value,
- text : value
- };
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- if( this.options.isEdited ){
- item.set( "value", value );
- }else{
- item.set("text", value );
- }
- },
- getErrorText : function(){
- return this.options.text +"不能为空";
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputTextarea"
- }
- return className;
- }
- });
- MDomItem.Hidden = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- var parent = this.container;
- var item = new Element( "input", {
- "type" : "hidden",
- "name" : this.options.name,
- "value" : this.options.value
- });
- item.set( this.options.attr || {} );
- //this.bindEvent(item,event,type);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- if( this.options.isEdited ){
- value = item.get("value");
- }else{
- value = item.get("text");
- }
- if( vort == "value" )return value;
- if( vort == "text")return value;
- return {
- value : value,
- text : value
- };
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set( "value", value );
- },
- getErrorText : function(){
- return this.options.text +"不能为空";
- }
- });
- MDomItem.Password = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- if( this.options.isEdited ){
- this.loadEdit()
- }else{
- }
- },
- loadEdit : function(){
- var module = this.module;
- var options = this.options;
- var item;
- var value ;
- if( typeOf( options.value ) === "boolean" ){
- value = options.value.toString();
- }else{
- value = options.value || options.defaultValue
- }
- var parent = module.container ;
- var className = this.getClassName();
- item = new Element( "input", {
- "type" : "password",
- "name" : options.name,
- "value" : value
- });
- item.set( options.attr || {} );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( options.style || {} );
- this.bindDefaultEvent( item );
- MDomItem.Util.bindEvent( this, item, options.event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- loadRead : function(){
- },
- bindDefaultEvent : function( item ){
- if( this.options.unsetDefaultEvent )return;
- if( this.options.validImmediately ){
- item.addEvent("blur", function(){ this.module.verify( true ); }.bind(this))
- }
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- if( this.options.isEdited ){
- value = item.get("value");
- }else{
- value = options.value || options.defaultValue
- }
- if( vort == "value" )return value;
- if( vort == "text")return value;
- return {
- value : value,
- text : value
- };
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- if( this.options.isEdited ){
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set( "value", value );
- }else{
- this.options.value = value;
- }
- },
- getErrorText : function(){
- return this.options.text +"不能为空";
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputPassword"
- }
- return className;
- }
- });
- MDomItem.Radio = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var _self = this;
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- var selectValues = typeOf( selectValue ) == "array" ? selectValue : selectValue.split( this.valSeparator );
- var selectTexts = typeOf( selectText ) == "array" ? selectText : selectText.split(this.valSeparator);
- for( i=0;i<selectValues.length;i++){
- item = new Element( "div");
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- var input = new Element( "input", {
- "type" : "radio",
- "name" : name,
- "value" : selectValues[i],
- "checked" : selectValues[i] == value
- }).inject( item );
- input.set( attr );
- var textNode = new Element( "span", {
- "text" : selectTexts[i]
- }).inject(item);
- textNode.addEvent("click", function( ev ){
- this.input.checked = ! this.input.checked;
- var envents = MDomItem.Util.getEvents( _self.options.event );
- if( typeOf( envents ) == "object" ){
- if( envents.change ){
- envents.change.call( this.input, _self.module, ev );
- }
- if( envents.click ){
- envents.click.call( this.input, _self.module, ev );
- }
- }
- if( _self.options.validImmediately ){
- _self.module.verify( true );
- }
- }.bind( {input : input} ) );
- if( this.options.validImmediately ){
- input.addEvent( "click", function(){ this.module.verify( true )}.bind(this) );
- }
- MDomItem.Util.bindEvent( this, item, event ); //? input or item
- if(parent)item.inject(parent);
- this.items.push( item );
- }
- },
- loadRead : function(){
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- if( selectValue && selectText ){
- value = MDomItem.Util.replaceText( value, selectValue , selectText, this.valSeparator );
- value = value.join(",");
- }
- item = new Element( "span", {
- "name" : name,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var items;
- var name = this.options.name;
- items = this.mElement.getElements("[name='"+name+"']");
- if( this.options.isEdited ){
- items.each(function( el ){
- if( el.checked ){
- value = el.get("value");
- text = el.getParent().get("text").trim();
- }
- });
- }else{
- text = items[0].get("text");
- if( this.options.selectValue && this.options.selectText ){
- value = MDomItem.Util.replaceText( text, this.options.selectText , this.options.selectValue , this.valSeparator).join();
- }else{
- value = text;
- }
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var items= this.mElement.getElements("[name='"+ this.options.name + "']");
- if( this.options.isEdited ){
- items.each(function( el ){
- if( el.get("value") == value ) el.checked = true;
- });
- }else{
- value = MDomItem.Util.replaceText( value, this.options.selectValue , this.options.selectText, this.valSeparator );
- value = value.join(",");
- items[0].set("text", value );
- }
- },
- getErrorText : function(){
- return "请先选择"+this.options.text;
- },
- getClassName : function(){
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputRadio"
- }
- return className;
- }
- });
- MDomItem.Checkbox = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var _self = this;
- var item;
- var values;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var isEdited = this.options.isEdited;
- var parent = this.mElement = this.container ;
- var className = this.getClassName();
- values = typeOf( value ) == "string" ? value.split(this.valSeparator) : value ;
- values = typeOf( value ) == "array" ? value : [value];
- var selectValues = typeOf( selectValue ) == "array" ? selectValue : selectValue.split( this.valSeparator );
- var selectTexts = typeOf( selectText ) == "array" ? selectText : selectText.split(this.valSeparator);
- for( var i=0;i<selectValues.length;i++){
- item = new Element( "div");
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- var input = new Element( "input", {
- "type" : "checkbox",
- "name" : name,
- "value" : selectValues[i],
- "checked" : values.contains( selectValues[i] )
- }).inject( item );
- input.set( attr );
- var textNode = new Element( "span", {
- "text" : selectTexts[i]
- }).inject(item);
- textNode.addEvent("click", function( ev ){
- this.input.checked = ! this.input.checked;
- var envents = MDomItem.Util.getEvents( _self.options.event );
- if( typeOf( envents ) == "object" ){
- if( envents.change ){
- envents.change.call( this.input, _self.module, ev );
- }
- if( envents.click ){
- envents.click.call( this.input, _self.module, ev );
- }
- }
- if( _self.options.validImmediately ){
- _self.module.verify( true );
- }
- }.bind( {input : input} ) );
- if( this.options.validImmediately ){
- item.addEvent("click", function(){ this.module.verify( true ); }.bind(this))
- }
- MDomItem.Util.bindEvent( this, item, event); // ? input or item
- if(parent)item.inject(parent);
- this.items.push( item );
- }
- },
- loadRead : function(){
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.mElement = this.container ;
- var className = this.getClassName();
- if( selectValue && selectText ){
- value = MDomItem.Util.replaceText( value, selectValue , selectText, this.valSeparator );
- value = value.join(",");
- }
- item = new Element( "span", {
- "name" : name,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var items;
- var name = this.options.name;
- items = this.mElement.getElements("[name='"+name+"']");
- if( this.options.isEdited ){
- value = [];
- text = [];
- items.each(function( el ){
- if( el.checked ){
- value.push(el.get("value"));
- text.push( el.getParent().get("text").trim() )
- }
- });
- }else{
- text = items[0].get("text");
- if( this.options.selectValue && this.options.selectText ){
- value = MDomItem.Util.replaceText( text, this.options.selectText , this.options.selectValue, this.valSeparator );
- }else{
- value = text;
- }
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var items= this.mElement.getElements("[name='"+ this.options.name + "']");
- if( this.options.isEdited ){
- var values = typeOf( value ) == "array" ? value : value.split("^^");
- items.each(function( el ){
- if( values.contains( el.get("value") ) ){
- el.checked = true;
- }else{
- el.checked = false;
- }
- });
- }else{
- value = MDomItem.Util.replaceText( value, this.options.selectValue , this.options.selectText, this.valSeparator );
- value = value.join(",");
- items[0].set("text", value );
- }
- },
- getErrorText : function(){
- return "请先选择"+this.options.text;
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputCheckbox"
- }
- return className;
- }
- });
- MDomItem.Select = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- item = new Element( "select" , {
- "name" : name
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- var selectValues = typeOf( selectValue ) == "array" ? selectValue : selectValue.split( this.valSeparator );
- var selectTexts = typeOf( selectText ) == "array" ? selectText : selectText.split(this.valSeparator);
- for( i=0;i<selectValues.length;i++){
- new Element("option" , {
- "value" : selectValues[i],
- "selected" : selectValues[i] == value,
- "text" : selectTexts[i]
- }).inject(item)
- }
- if( this.options.validImmediately ){
- item.addEvent("change", function(){ this.module.verify( true ); }.bind(this))
- }
- MDomItem.Util.bindEvent( this, item, event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- loadRead : function(){
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.mElement = this.container ;
- var className = this.getClassName();
- if( selectValue && selectText ){
- value = MDomItem.Util.replaceText( value, selectValue , selectText, this.valSeparator );
- value = value.join(",");
- }
- item = new Element( "span", {
- "name" : name,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var items;
- var name = this.options.name;
- items = this.mElement.getElements("[name='"+name+"']");
- if( this.options.isEdited ){
- items[0].getElements("option").each(function(el){
- if( el.selected ){
- value = el.get("value");
- text = el.get("text").trim();
- }
- });
- }else{
- text = items[0].get("text");
- if( this.options.selectValue && this.options.selectText ){
- value = MDomItem.Util.replaceText( text, this.options.selectText , this.options.selectValue , this.valSeparator).join();
- }else{
- value = text;
- }
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var items= this.mElement.getElements("[name='"+ this.options.name + "']");
- if( this.options.isEdited ){
- items[0].getElements("option").each(function( el ){
- if( el.get("value") == value ) el.selected = true;
- });
- }else{
- value = MDomItem.Util.replaceText( value, this.options.selectValue , this.options.selectText, this.valSeparator );
- value = value.join(",");
- items[0].set("text", value );
- }
- },
- getErrorText : function(){
- return "请先选择"+this.options.text;
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputSelect"
- }
- return className;
- }
- });
- MDomItem.Multiselect = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var item;
- var values;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- values = typeOf( value ) == "string" ? value.split(this.valSeparator) : value ;
- values = typeOf( value ) == "array" ? value : [value];
- item = new Element( "select" , {
- "name" : name,
- "multiple" : true
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- var selectValues = typeOf( selectValue ) == "array" ? selectValue : selectValue.split( this.valSeparator );
- var selectTexts = typeOf( selectText ) == "array" ? selectText : selectText.split(this.valSeparator);
- for( i=0;i<selectValues.length;i++){
- new Element("option" , {
- "value" : selectValues[i],
- "selected" : values.contains( selectValues[i] ),
- "text" : selectTexts[i]
- }).inject(item)
- }
- if( this.options.validImmediately ){
- item.addEvent("change", function(){ this.module.verify( true ); }.bind(this))
- }
- MDomItem.Util.bindEvent( this, item, event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- loadRead : function(){
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName();
- if( selectValue && selectText ){
- value = MDomItem.Util.replaceText( value, selectValue , selectText, this.valSeparator );
- value = value.join(",");
- }
- item = new Element( "span", {
- "name" : name,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var items;
- var name = this.options.name;
- items = this.mElement.getElements("[name='"+name+"']");
- if( this.options.isEdited ){
- value = [];
- text = [];
- items[0].getElements("option").each(function(el){
- if( el.selected ){
- value.push( el.get("value") );
- text.push( el.get("text").trim() );
- }
- });
- }else{
- text = items[0].get("text");
- if( this.options.selectValue && this.options.selectText ){
- value = MDomItem.Util.replaceText( text, this.options.selectText , this.options.selectValue , this.valSeparator );
- }else{
- value = text;
- }
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var items= this.mElement.getElements("[name='"+ this.options.name + "']");
- if( this.options.isEdited ){
- var values = typeOf( value ) == "array" ? value : value.split("^^");
- items[0].getElements("option").each(function( el ){
- if( values.contains( el.get("value") ) ){
- el.selected = true;
- }else{
- el.selected = false;
- }
- })
- }else{
- value = MDomItem.Util.replaceText( value, this.options.selectValue , this.options.selectText, this.valSeparator );
- value = value.join(",");
- items[0].set("text", value );
- }
- },
- getErrorText : function(){
- return "请先选择"+this.options.text;
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputMultiselect"
- }
- return className;
- }
- });
- MDomItem.Innertext = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.mElement = this.container ;
- var className = this.getClassName();
- if( selectValue && selectText ){
- value = MDomItem.Util.replaceText( value, selectValue , selectText, this.valSeparator );
- value = value.join(",");
- }
- item = new Element( "span", {
- "name" : name,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if( this.options.isEdited ){
- MDomItem.Util.bindEvent( this, item, this.options.event);
- }
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- text = item.get("text");
- if( this.options.selectValue && this.options.selectText ){
- value = MDomItem.Util.replaceText( text, this.options.selectText , this.options.selectValue , this.valSeparator);
- }else{
- value = text;
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- value = MDomItem.Util.replaceText( value, this.options.selectValue , this.options.selectText, this.valSeparator );
- value = value.join(",");
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set("text", value );
- },
- getErrorText : function(){
- return this.options.text+"不能为空";
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- }
- return className;
- }
- });
- MDomItem.Innerhtml = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.mElement = this.container ;
- var className = this.getClassName();
- if( selectValue && selectText ){
- value = MDomItem.Util.replaceText( value, selectValue , selectText, this.valSeparator );
- value = value.join(",");
- }
- item = new Element( "span", {
- "name" : name,
- "html" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if( this.options.isEdited ){
- MDomItem.Util.bindEvent( this, item, this.options.event);
- }
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- text = item.get("html");
- if( this.options.selectValue && this.options.selectText ){
- value = MDomItem.Util.replaceText( text, this.options.selectText , this.options.selectValue , this.valSeparator );
- }else{
- value = text;
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- value = MDomItem.Util.replaceText( value, this.options.selectValue , this.options.selectText, this.valSeparator );
- value = value.join(",");
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set("html", value );
- },
- getErrorText : function(){
- return this.options.text+"不能为空";
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- }
- return className;
- }
- });
- MDomItem.Img = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- if( this.options.disable )return;
- var item;
- var name = this.options.name;
- var value = this.options.value || this.options.defaultValue ;
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName();
- item = new Element( "img", {
- "name" : name,
- "src" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- MDomItem.Util.bindEvent( this, item, event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- value = item.get("src");
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set("src",value);
- },
- getErrorText : function(){
- return this.options.text + "不能为空"
- },
- getClassName : function(){
- var tType = this.options.tType;
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- }
- return className;
- }
- });
- MDomItem.Button = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- if( this.options.disable )return;
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- item = new Element( "button", {
- "type" : "button",
- "name" : name,
- "value" : value,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- MDomItem.Util.bindEvent( this, item, event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- value = item.get("value");
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item= this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set( "value", value );
- },
- getErrorText : function(){
- return this.options.text+"不能为空";
- },
- getClassName : function(){
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputButton"
- }
- return className;
- }
- });
- MDomItem.A = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.items = module.items;
- this.container = this.mElement = module.container;
- },
- load : function(){
- if( this.options.disable )return;
- var item;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var event = this.options.event;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- item = new Element( "a", {
- "name" : name,
- "value" : value,
- "text" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- MDomItem.Util.bindEvent( this, item, event);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- var name = this.options.name;
- var item = this.mElement.getElement("[name='"+name+"']");
- value = item.get("value");
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item= this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set( "value", value );
- },
- getErrorText : function(){
- return this.options.text+"不能为空";
- },
- getClassName : function(){
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputA"
- }
- return className;
- }
- });
- MDomItem.MSelector = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- MWF.xDesktop.requireApp("Template", "MSelector",null,false);
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var selectValue = this.options.selectValue || this.options.selectText;
- var selectText = this.options.selectText || this.options.selectValue ;
- this.mSelectorOptions = {
- "style": "default",
- "width": "230px",
- "height": "30px",
- "defaultOptionLp" : "请选择",
- "trigger" : "delay", //immediately
- "isSetSelectedValue" : true,
- "inputEnable" : false,
- "isCreateReadNode" : false, //适应给MDomItem的做法
- "textField" : "",
- "valueField" : "",
- "value" : value,
- "text" : "",
- "defaultVaue" : this.options.defaultValue,
- "selectValue" : selectValue,
- "selectText" : selectText,
- "isEdited" : this.options.isEdited
- //"onSelectItem" : function( itemNode, itemData ){}.bind(this)
- //"onLoadData" :function( callback ){}.bind(this)
- };
- if( this.options.mSelectorOptions ){
- this.mSelectorOptions = Object.merge( this.mSelectorOptions, this.options.mSelectorOptions );
- }
- this.mSelectorOptions.value = value;
- if( !this.options.isEdited ){
- var name = this.options.name;
- var item;
- var attr = this.options.attr || {};
- var className = this.getClassName();
- var styles = this.options.style || {};
- var parent = this.container;
- this.mSelectorOptions.onLoadReadNode = function( text ){
- if( this.items.length > 0 ){
- parent.empty();
- }
- item = new Element( "span", {
- "name" : name,
- "text" : text
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if(parent)item.inject(parent);
- this.items.push( item );
- }.bind(this);
- }
- this.mSelector = new MSelector(this.container, this.mSelectorOptions , this.app , this.css);
- this.mSelector.load();
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- if( vort == "value" )return this.mSelector.getValue();
- if( vort == "text")return this.mSelector.getText();
- return this.mSelector.get();
- },
- setValue : function( value ){
- this.mSelector.setValue( value );
- },
- getErrorText : function(){
- return this.options.text + "不能为空";
- },
- getClassName : function(){
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- }
- return className;
- }
- });
- MDomItem.ImageClipper = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var item;
- var values;
- var name = this.options.name;
- var value ;
- if( typeOf( this.options.value ) === "boolean" ){
- value = this.options.value.toString();
- }else{
- value = this.options.value || this.options.defaultValue
- }
- var styles = this.options.style || {};
- var parent = this.container ;
- this.imageId = this.module.imageId = value;
- if( value && parent ){
- if( styles.imageWrapStyle ){
- this.imageWrap = new Element("div", { styles : styles.imageWrapStyle}).inject( parent )
- }
- this.image = new Element("img", {
- "src" : MWF.xDesktop.getImageSrc( value )
- }).inject( this.imageWrap || parent );
- this.image.addEvent("click",function(){
- window.open( o2.filterUrl(MWF.xDesktop.getImageSrc( this.imageId )), "_blank" );
- }.bind(this));
- if( styles.imageStyle )this.image.setStyles( styles.imageStyle );
- }
- var action = new Element("button",{
- "text" : "设置图片"
- }).inject( parent );
- //if( this.css && this.css["inputButton"] )action.setStyles( this.css["inputButton"] );
- if( styles.actionStyle )action.setStyles( styles.actionStyle );
- action.addEvents({
- "click": function(){
- MWF.xDesktop.requireApp("Template", "widget.ImageClipper",null,false);
- this.clipper = new MWF.xApplication.Template.widget.ImageClipper(this.app, {
- "imageUrl": value ? MWF.xDesktop.getImageSrc( value ) : "",
- "aspectRatio": this.options.aspectRatio || 0,
- "ratioAdjustedEnable" : this.options.ratioAdjustedEnable || false,
- "reference": this.options.reference,
- "referenceType": this.options.referenceType,
- "onChange": function () {
- if( this.image )this.image.destroy();
- if(this.imageWrap)this.imageWrap.destroy();
- if( styles.imageWrapStyle ){
- this.imageWrap = new Element("div", { styles : styles.imageWrapStyle}).inject( parent, "top" )
- }
- this.image = new Element("img", {
- "src" : this.clipper.imageSrc
- }).inject( this.imageWrap || parent, "top" );
- if( styles.imageStyle )this.image.setStyles( styles.imageStyle );
- this.image.addEvent("click",function(){
- window.open( o2.filterUrl(MWF.xDesktop.getImageSrc( this.imageId )), "_blank" );
- }.bind(this));
- this.imageId = this.module.imageId = this.clipper.imageId;
- if( this.options.validImmediately ){
- this.module.verify( true )
- }
- }.bind(this)
- });
- this.clipper.load();
- }.bind(this)
- });
- },
- loadRead : function(){
- var value = this.options.value || this.options.defaultValue ;
- var parent = this.container ;
- this.imageId = this.module.imageId = value;
- if( value && parent ){
- this.image = new Element("img", {
- "src" : MWF.xDesktop.getImageSrc( value )
- }).inject( parent );
- var styles = this.options.style || {};
- if( styles.imageStyle )this.image.setStyles( styles.imageStyle );
- }
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var items;
- var value = this.imageId;
- if( vort == "value" )return value;
- if( vort == "text")return value;
- var result = {};
- result.value = value;
- result.text = value;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var styles = this.options.style || {};
- this.imageId = this.module.imageId = value;
- if( value ){
- if( this.image ){
- this.image.set("src", MWF.xDesktop.getImageSrc( value ))
- }else{
- if( styles.imageWrapStyle ){
- this.imageWrap = new Element("div", { styles : styles.imageWrapStyle}).inject( this.container )
- }
- this.image = new Element("img", {
- "src" : MWF.xDesktop.getImageSrc( value )
- }).inject( this.imageWrap || this.container );
- if( styles.imageStyle )this.image.setStyles( styles.imageStyle );
- }
- }
- },
- getErrorText : function(){
- return "请先上传图片:"+this.options.text
- }
- });
- MDomItem.Rtf = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var _self = this;
- var item;
- var name = this.options.name;
- var value = this.options.value || this.options.defaultValue ;
- var attr = this.options.attr || {};
- var parent = this.container ;
- COMMON.AjaxModule.load("ckeditor", function(){
- CKEDITOR.disableAutoInline = true;
- var item = new Element("div",{
- "name" : name,
- "id" : name
- });
- item.set( attr );
- if(parent)item.inject(parent);
- if( value )item.set("html", value);
- var editorConfig = {
- //"autoGrow_maxHeight": 400,
- //"autoGrow_minHeight": 300,
- "resize_enabled": true,
- //"resize_maxHeight": "3000",
- //"resize_minHeight": "200",
- "autoParagraph": true,
- "autoUpdateElement": true,
- "enterMode": 1,
- //"height": "200",
- //"width": "",
- "readOnly": false,
- "extraAllowedContent " : "img[onerror,data-id]"
- };
- if( this.options.RTFConfig ){
- editorConfig = Object.merge( editorConfig, this.options.RTFConfig )
- }
- if( editorConfig.skin )editorConfig.skin = "moono-lisa";
- if( !editorConfig.filebrowserFilesImage && !editorConfig.cloudFileDisable ){
- editorConfig.filebrowserFilesImage = function( e, callback ){
- MWF.xDesktop.requireApp("File", "FileSelector", function(){
- _self.selector_cloud = new MWF.xApplication.File.FileSelector( document.body ,{
- "style" : "default",
- "title": "选择云文件图片",
- "toBase64" : true,
- "listStyle": "preview",
- "selectType" : "images",
- "onPostSelectAttachment" : function(url, base64File){
- if(callback)callback(url, base64File);
- }
- });
- _self.selector_cloud.load();
- }, true);
- }
- }
- this.editor = this.module.editor = CKEDITOR.replace(item, editorConfig);
- var imgSrc = MWF.xDesktop.getImageSrc();
- var imgHost = imgSrc.split("/x_file_assemble_control/")[0];
- debugger;
- this.editor.on("instanceReady", function(e){
- debugger;
- var editable = e.editor.editable && e.editor.editable();
- if(!editable)return;
- var imgs = editable.find("img");
- for( var i=0; i<imgs.count(); i++ ){
- var img = imgs.getItem(i);
- var src = img.getAttribute("src");
- if( src && src.indexOf("/x_file_assemble_control/") > -1 ){
- if( imgHost !== src.split("/x_file_assemble_control/")[0] ){
- var id = img.getAttribute("data-id");
- if( id ){
- var newSrc = MWF.xDesktop.getImageSrc(id);
- if(newSrc){
- img.setAttribute("src" , newSrc );
- img.setAttribute("data-cke-saved-src" , newSrc );
- }
- }
- }
- }
- }
- });
- this.items.push( this.editor );
- }.bind(this));
- },
- loadRead : function(){var _self = this;
- var item;
- var name = this.options.name;
- var value = this.options.value || this.options.defaultValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = null ;
- item = new Element( "span", {
- "name" : name,
- "html" : value
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value;
- var text;
- if( this.options.isEdited ){
- if( this.options.RTFConfig && this.options.RTFConfig.isSetImageMaxWidth ){
- var div = new Element( "div" , {
- "styles" : { "display" : "none" },
- "html" : this.editor.getData()
- } ).inject( this.container );
- div.getElements( "img").each( function( el ){
- el.setStyle( "max-width" , "100%" );
- });
- value = div.get("html");
- div.destroy();
- }else{
- value = this.editor.getData();
- }
- }else{
- var item = this.mElement.getElement("[name='"+name+"']");
- value = item.get("html");
- }
- if( !value )value="";
- if( !text )text = value;
- if( vort == "value" )return value;
- if( vort == "text")return text;
- var result = {};
- result.value = value;
- result.text = text;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- if( this.options.isEdited ){
- this.editor.setData(value);
- }else{
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- item.set("html", value );
- }
- },
- getErrorText : function(){
- return this.options.text+"不能为空"
- },
- getClassName : function(){
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- }
- return className;
- }
- });
- MDomItem.Org = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- var item;
- var name = this.options.name;
- var value = this.options.value || this.options.defaultValue ;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName() ;
- if( !value ){
- this.orgData = [];
- }else if( typeOf( value ) == "array" ){
- this.orgData = value;
- }else if( typeOf( value ) == "string" ){
- this.orgData = value.split( this.valSeparator )
- }else if( typeOf( value ) == "object" ){
- this.orgData = [value]
- }else{
- this.orgData = [];
- }
- item = new Element( "div", {
- "name" : name
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- this.loadOrgWidget( this.orgData, item, true );
- this.bindDefaultEvent( item );
- MDomItem.Util.bindEvent( this, item, this.options.event );
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- loadRead : function(){
- var item;
- var name = this.options.name;
- var value = this.options.value || this.options.defaultValue;
- var styles = this.options.style || {};
- var attr = this.options.attr || {};
- var parent = this.container ;
- var className = this.getClassName();
- if( !value ){
- this.orgData = [];
- }else if( typeOf( value ) == "array" ){
- this.orgData = value;
- }else if( typeOf( value ) == "string" ){
- this.orgData = value.split( this.valSeparator )
- }else{
- this.orgData = [];
- }
- this.module.orgData = this.orgData;
- item = new Element( "div", {
- "name" : name
- });
- item.set( attr );
- if( className && this.css && this.css[className] )item.setStyles( this.css[className] );
- item.setStyles( styles );
- this.loadOrgWidget( this.orgData, item , false);
- if(parent)item.inject(parent);
- this.items.push( item );
- },
- getData : function( parse ){
- var data = [];
- this.OrgWidgetList.each( function( widget ){
- data.push( parse ? MWF.org.parseOrgData(widget.data, true) : widget.data );
- }.bind(this));
- return data;
- },
- get : function( vort ){
- if( this.options.disable ){
- return ( vort == "value" || vort == "text" ) ? null : {
- value : null,
- text : null
- };
- }
- var value = this.orgData;
- if( vort == "value" )return value;
- if( vort == "text")return value;
- var result = {};
- result.value = value;
- result.text = value;
- return result;
- },
- setValue : function( value ){
- if( this.options.disable ){
- return;
- }
- var item = this.mElement.getElement("[name='"+ this.options.name + "']");
- if( !value ){
- this.orgData = [];
- }else if( typeOf( value ) == "array" ){
- this.orgData = value;
- }else if( typeOf( value ) == "string" ){
- this.orgData = value.split( this.valSeparator );
- }else{
- this.orgData = [];
- }
- item.empty();
- this.loadOrgWidget( this.orgData, item, this.options.isEdited );
- this.module.orgData = this.orgData
- },
- getErrorText : function(){
- return "请先选择" + this.options.text;
- },
- bindDefaultEvent : function( item ){
- if( this.options.unsetDefaultEvent )return;
- item.addEvent( "click" , function(){
- debugger;
- this.module.fireEvent("querySelect", this.module );
- var options = this.options;
- var opt = {
- type : options.orgType,
- title : options.text,
- count : options.count,
- selectedValues : this.orgObjData || this.orgData,
- units : options.units,
- unitType : options.unitType,
- groups : options.groups,
- expand : options.expand,
- exclude : options.exclude,
- expandSubEnable : options.expandSubEnable
- };
- MDomItem.Util.selectPerson( this.app.content, opt, function( array ){
- item.empty();
- this.orgData = this.module.orgData = [];
- this.orgObjData = [];
- this.orgObject = this.module.orgObject = array;
- array.each(function( it ){
- this.orgData.push( it.data.distinguishedName || it.data.name );
- this.orgObjData.push( it.data );
- }.bind(this));
- this.OrgWidgetList = [];
- this.loadOrgWidget( this.orgObjData, item, true );
- this.modified = true;
- this.items[0].fireEvent("change");
- if( this.options.validImmediately )this.module.verify( true );
- }.bind(this))
- }.bind(this) );
- },
- getValueByType : function( type ){
- var types = typeOf( type ) == "string" ? type.split(",") : type;
- types = types.map( function( item, index ){
- switch (item.toLowerCase()) {
- case "person": return "p";
- case "identity": return "i";
- case "unit": return "u";
- case "group": return "g";
- case "role": return "r";
- default: return item.toLowerCase();
- }
- });
- var value = [];
- this.get("value").each( function( v ){
- var flag = v.substr(v.length-1, 1);
- if( types.contains( flag.toLowerCase() ) )value.push( v );
- });
- return value;
- },
- loadOrgWidget: function(value, node, canRemove){
- this.OrgWidgetList = this.OrgWidgetList || [];
- MWF.require("MWF.widget.O2Identity", null, false);
- var options = { "style": this.options.orgStyle || "xform", "canRemove": canRemove , "onRemove" : this.removeOrgItem };
- if( this.options.orgWidgetOptions ){
- options = Object.merge( options, this.options.orgWidgetOptions );
- }
- value.each(function( v ){
- var distinguishedName;
- if( typeOf(v) === "string" ){
- distinguishedName = v;
- }else{
- distinguishedName = v.distinguishedName || v.name || ""
- }
- var flag = distinguishedName.substr(distinguishedName.length-1, 1);
- var data = { "name" : distinguishedName };
- switch (flag.toLowerCase()){
- case "i":
- var widget = new MWF.widget.O2Identity( data, node, options );
- break;
- case "p":
- var widget = new MWF.widget.O2Person(data, node, options);
- break;
- case "u":
- var widget = new MWF.widget.O2Unit(data, node, options);
- break;
- case "g":
- var widget = new MWF.widget.O2Group(data, node, options);
- break;
- //case "d":
- // var widget = new MWF.widget.O2Duty(data, node, options);
- // break;
- default:
- var orgType = this.options.orgType;
- var t = ( typeOf( orgType ) == "array" && orgType.length == 1 ) ? orgType[0] : orgType;
- t = typeOf( t ) == "string" ? t.toLowerCase() : "";
- if( t == "identity" ){
- var widget = new MWF.widget.O2Identity( data, node, options );
- }else if( t == "person" ){
- var widget = new MWF.widget.O2Person(data, node, options);
- }else if( t == "unit" ){
- var widget = new MWF.widget.O2Unit(data, node, options);
- }else if( t == "group" ){
- var widget = new MWF.widget.O2Group(data, node, options);
- }else if( t == "process" ){
- var d = { id : distinguishedName };
- var widget = new MWF.widget.O2Process(d, node, options);
- //}else if( t == "duty" ){
- // var widget = new MWF.widget.O2Duty(data, node, options);
- }else if( t == "CMSView" ){
- var d = { id : distinguishedName };
- var widget = new MWF.widget.O2CMSView(d, node, options);
- //}else if( t == "duty" ){
- // var widget = new MWF.widget.O2Duty(data, node, options);
- }else{
- var widget = new MWF.widget.O2Other( data, node, options);
- }
- }
- widget.field = this;
- this.OrgWidgetList.push( widget );
- }.bind(this));
- },
- removeOrgItem : function( widget, ev ){
- //this 是 MWF.widget.O2Identity 之类的对象
- var _self = this.field; //这个才是MDomItem 对象
- var dn = widget.data.distinguishedName || widget.data.name;
- var data = [];
- var index;
- _self.orgData.each( function ( d , i){
- if( d != dn )data.push( d )
- });
- _self.orgData = data;
- if( _self.orgObject ){
- data = [];
- _self.orgObject.each( function( d ){
- if( d.distinguishedName ){
- if( d.distinguishedName != dn )data.push( d );
- }else{
- if( d.name != dn )data.push( d );
- }
- });
- _self.orgObject = data;
- }
- this.node.destroy();
- _self.items[0].fireEvent("change");
- ev.stopPropagation();
- },
- getClassName : function(){
- var className = null ;
- if( this.options.className == "none" ){
- }else if( this.options.className != "") {
- className = this.options.className
- }else if( !this.options.isEdited ){
- }else {
- className = "inputPerson"
- }
- return className;
- }
- });
- MDomItem.File = new Class({
- initialize: function ( module ) {
- this.module = module;
- this.options = module.options;
- this.css = module.css;
- this.app = module.app;
- this.items = module.items;
- this.container = this.mElement = module.container;
- this.valSeparator = module.valSeparator;
- },
- load : function(){
- if( this.options.disable )return;
- if( this.options.isEdited ){
- this.loadEdit();
- }else{
- this.loadRead();
- }
- },
- loadEdit : function(){
- },
- loadRead : function(){
- },
- get : function( vort ){
- },
- setValue : function( value ){
- },
- getErrorText : function(){
- }
- });
|