| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910 |
- if(typeof window.wd =="undefined"){
- window.wd={};
- }
- if (!wd.display) {
- wd.display = {};
- };
- (function () {
- if(wd.topWindow)return;
- var currParent = window;
- var i = 1;
- while (currParent != top) {
- try {
- currParent.parent[new Date().getMilliseconds()] = 1; // 如果这行不报“没权限错误”,才执行下一行。
- currParent = currParent.parent;
- } catch (e) {
- break;
- }
- }
- /**
- * 得到同域的顶层窗口,不直接用top,是因为有把WD的页面嵌入到OA的作子页面的情形 如果顶层窗口直接用top,当顶层窗口是另一网站时,就会报错。
- */
- wd.topWindow = currParent;
- })();
- if (!wd.topWindow.wd) {
- wd.topWindow.wd = {};
- }
- if (!wd.topWindow.wd.display) {
- wd.topWindow.wd.display = {};
- }
- /*
- * Change log:
- *
- * --02-14-2014-- function name wd.display.showComponent from title = '<span
- * style="font:14px \'宋体\'\;line-height:30px;" >'+title+'</span>'; to title = '<span>'+title+'</span>';
- *
- *
- */
- // 初始化滚动条,by SPACE 2019-01-07
- // 关闭鼠标加载动画, by SPACE 2019-04-02
- $(document).ready(function () {
- waitThenInitNiceScorll();
- try {
- wd.display.closeLoad();
- } catch (e) { }
- });
- function waitThenInitNiceScorll() {
- try {
- document.onreadystatechange = function () {
- if (document.readyState == "complete")
- setTimeout("initNiceScorll()", 200);
- else
- setTimeout("waitThenInitNiceScorll()", 10);
- }
- } catch (e) {
- console.log(e);
- }
- }
- /**
- * 初始化滚动条
- */
- var flag = false;
- var resizeScrollIv;
- function initNiceScroll() {
- try {
- // 流程设计器
- if ($("#draw_demo").html() != undefined || $("#draw_demo").html() != null || $("#workFlowDesigner").html() != null) {
- return;
- }
- // 网站设计页
- if ($("#updateDesignWebpageUrl").val() != null) {
- return;
- }
- // 内容播放器
- if ($("#fileProperty").val() != null) {
- return;
- }
- // 大滚动条
- var b = $("body");
- if ($(b).attr("nicescroll")) {
- if ($(b).attr("nicescroll") == 'true') {
- loadScorll(b);
- }
- } else {
- loadScorll(b);
- }
- loadScorll($("iframe[name='ssTabIframe']")); // [name='wdTabFrame']。Lin
- loadScorll($(".scrollbar"));
- loadScorll($(".mainDiv"));
- loadScorll($(".content-div"));
- loadScorll(parent.$(".content-div"));
- loadScorll($(".CodeMirror-vscrollbar"));
- var iframe = window.parent.getIframeByElement(document.body);
- var iframeObj = $(iframe);
- // loadScorll(iframeObj);
- // 小滚动条
- loadSmallScorll($(".smallScrollbar"))
- // 0.5秒定时监听滚动条变化
- clearInterval(resizeScrollIv);
- resizeScrollIv = setInterval(function () {
- try {
- $("body").getNiceScroll().resize();
- $("iframe[name='ssTabIframe']").getNiceScroll().resize(); // [name='wdTabFrame']。Lin
- $(".mainDiv").getNiceScroll().resize();
- $(".scrollbar").getNiceScroll().resize();
- $(".content-div").getNiceScroll().resize();
- $(parent.$(".content-div")).getNiceScroll().resize(); // $(iframeObj).getNiceScroll().resize();
- $(".CodeMirror-vscrollbar").getNiceScroll().resize();
- $(".smallScrollbar").getNiceScroll().resize();
- } catch (e) {
- console.error(e);
- }
- }, 500);
- } catch (e) {
- if (!flag) {
- flag = true;
- // 解决页面引入多个 Jquery 导致 not function 的问题
- /* 改。Lin
- $("head").append("<script src=\"/wd/js/nicescroll376/jquery.nicescroll.js\"></script>")
- */ $("head").append("<script src=\"/ss/nicescroll/jquery.nicescroll.js\"></script>")
- /* 改。Lin
- $("head").append("<script src=\"/wd/js/nicescroll376/jquery.nicescroll.iframehelper.min.js\"></script>")
- */ $("head").append("<script src=\"/ss/nicescroll/jquery.nicescroll.iframehelper.min.js\"></script>")
- clearInterval(resizeScrollIv);
- initNiceScorll();
- }
- }
- }
- function getIframeByElement(element) {
- var iframe;
- $("iframe").each(function () {
- if (element.ownerDocument === this.contentWindow.document) {
- iframe = this;
- }
- return !iframe;
- });
- return iframe;
- }
- // 大滚动条
- function loadScroll(dom) {
- try {
- if($(dom).attr("wdScroll")=="false")return;
- var hori= $(dom).attr("wdScroll")=="XY";
- $(dom).niceScroll({
- cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
- cursorwidth: "6px", // 滚动条的宽度,单位:便素
- cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
- cursorborderradius: "6px", // 滚动条圆角(像素)
- mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
- touchbehavior: false, // 激活拖拽滚动
- hwacceleration: false, // 激活硬件加速
- autohidemode: "true",
- background: "transparent", // 轨道的背景颜色
- iframeautoresize: true, // 在加载事件时自动重置iframe大小
- spacebarenabled: true, // 当按下空格时使页面向下滚动
- railpadding: {
- top: 0,
- right: 4,
- left: 4,
- bottom: 0
- }, // 设置轨道的内间距
- horizrailenabled: hori||false, // nicescroll可以管理水平滚动
- railalign: "right", // 对齐垂直轨道
- railvalign: "bottom", // 对齐水平轨道
- preservenativescrolling: true,
- enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
- enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件
- nativeparentscrolling: false //检测内容底部,并让父节点来滚动,作为原生滚动
- });
- } catch (e) {
- throw e;
- }
- }
- //初始化小滚动条
- function loadScrollXY(dom) {
- try {
- if($(dom).attr("wdScroll")=="false")return;
- $(dom).niceScroll({
- cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
- cursorwidth: "6px", // 滚动条的宽度,单位:便素
- cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
- cursorborderradius: "6px", // 滚动条圆角(像素)
- mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
- touchbehavior: false, // 激活拖拽滚动
- hwacceleration: false, // 激活硬件加速
- autohidemode: "true",
- background: "transparent", // 轨道的背景颜色
- iframeautoresize: true, // 在加载事件时自动重置iframe大小
- spacebarenabled: true, // 当按下空格时使页面向下滚动
- railpadding: {
- top: 0,
- right: 4,
- left: 4,
- bottom: 0
- }, // 设置轨道的内间距
- horizrailenabled: true, // nicescroll可以管理水平滚动
- railalign: "right", // 对齐垂直轨道
- railvalign: "bottom", // 对齐水平轨道
- preservenativescrolling: true,
- enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
- enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件
- nativeparentscrolling: false //检测内容底部,并让父节点来滚动,作为原生滚动
- });
- } catch (e) {
- throw e;
- }
- }
- // 小滚动条
- function loadSmallScroll(dom) {
- try {
- $(dom).niceScroll({
- cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
- cursorwidth: "1px", // 滚动条的宽度,单位:便素
- cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
- cursorborderradius: "1px", // 滚动条圆角(像素)
- mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
- touchbehavior: false, // 激活拖拽滚动
- hwacceleration: false, // 激活硬件加速
- background: "transparent", // 轨道的背景颜色
- iframeautoresize: true, // 在加载事件时自动重置iframe大小
- spacebarenabled: true, // 当按下空格时使页面向下滚动
- autohidemode: "true", // leave
- railpadding: {
- top: 0,
- right: 2,
- left: 2,
- bottom: 0
- }, // 设置轨道的内间距
- horizrailenabled: false, // nicescroll可以管理水平滚动
- railalign: "right", // 对齐垂直轨道
- railvalign: "bottom", // 对齐水平轨道
- enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
- nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动
- zindex: "999999"
- });
- } catch (e) {
- console.log(e);
- }
- }
- //原来拼写错误,兼容处理
- var initNiceScorll= initNiceScroll;
- var loadScorll=loadScroll;
- var loadScorllXY=loadScrollXY;
- var loadSmallScorll=loadSmallScroll;
- /*
- * 设置HTML元素属性 @param object o 要设置属性的HTML元素 @param string a 要设置的属性名 @param string
- * v 要设置的属性值
- */
- function setAttribute(o, a, v) {
- if (typeof o != 'object' || typeof a != 'string')
- return;
- a == 'class' ? o.className = v : o.setAttribute(a, v);
- }
- /*
- * 获取HTML元素属性值 @param object o 要获取属性的HTML元素 @param string a 要获取的属性名 @return
- * 返回要获取的属性值
- */
- function getAttribute(o, a) {
- if (typeof o != 'object' || typeof a != 'string')
- return;
- return a == 'class' ? o.className : o.getAttribute(a);
- }
- /*
- * 移除HTML元素属性 @param object o 要移除属性的HTML元素 @param string a 要移除的属性名
- */
- function removeAttribute(o, a) {
- if (typeof o != 'object' || typeof a != 'string')
- return;
- o.removeAttribute(a);
- if (a == 'class')
- o.removeAttribute('className');
- }
- /**
- * 去掉所有的html代码
- */
- wd.display.removeHTMLTag = wd.display.toPlainText = function (str) {
- str = str.replace(/<\/?[^>]*>/g, ''); // 去除HTML tag
- str = str.replace(/[ | ]*\n/g, '\n'); // 去除行尾空白
- // str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
- str = str.replace(/ /ig, ''); // 去掉
- str = str.replace(/\s/g, ''); // 将空格去掉
- return str;
- };
- /**
- * 初始化tr的显示样式
- */
- wd.display.initTrDisplay = function (trContainerNameOrId, // tr标签的直接父级标签的name或id
- oddClassName, // 奇数行的tr应用的class类名
- evenClassName, // 偶数行的tr应用的class类名
- onMouseOverClassName) { // 鼠标放在tr上时,tr应用的css样式
- var container = wd.c.g(trContainerNameOrId);
- // container 可能为 undefined
- if (!container)
- return;
- var trs = container.childNodes;
- if (!trs)
- return;
- var trIndex = 0;
- for (var i = 0; i < trs.length; i++) {
- var oneTr = trs[i];
- if (!oneTr.tagName || oneTr.tagName != 'TR' ||
- oneTr.style.display == 'none')
- continue;
- trIndex++;
- if (trIndex % 2 == 1) { // 奇数行的tr应用的class类名
- oneTr.className += " " + oddClassName;
- } else {
- oneTr.className += " " + evenClassName;
- }
- oneTr.oriClassName = oneTr.className;
- var omocn = new RegExp(" " + onMouseOverClassName);
- // console.log(omocn);
- oneTr.onmouseover = function () {
- this.className = this.className.replace(omocn, "") + " " +
- onMouseOverClassName;
- }
- oneTr.onmouseout = function () {
- this.className = this.className.replace(omocn, "");
- }
- }
- };
- wd.display.showDynamicParamDialog = function (url, datas) {
- eval(wd.display.replaceDynamicParam(url.toString(), datas));
- }
- wd.display.createMaskDiv = function (containerObj, currWindow, zIndex) { // 创建遮罩层
- var ele = currWindow.document.getElementsByTagName('BODY')[0];
- var newID = new Date().getTime();
- if (!(typeof zIndex != 'undefined' && zIndex)) {
- zIndex = 100001;
- }
- var coverDiv = document.createElement("div");
- coverDiv.id = newID;
- // coverDiv.style.cssText = 'display: none;' + 'position: absolute;' +
- // 'top: 0%;' + 'left: 0%;' + 'width: 100%;' + 'height: 100%;' +
- // 'background-color: #EEEEEE;' + '-moz-opacity: 0.5;' +
- // 'opacity: .50;' + 'filter: alpha(opacity=50);';
- coverDiv.setAttribute("class", "wdMaskDiv dialog-mask");
- coverDiv.style.zIndex = zIndex - 1;
- ele.appendChild(coverDiv);
- // coverDiv.style.display = 'block';
- var W = (currWindow.document.body.scrollLeft + currWindow.document.body.scrollWidth) ||
- (currWindow.document.documentElement.scrollLeft + currWindow.document.documentElement.scrollWidth);
- var H = (currWindow.document.body.scrollTop + currWindow.document.body.scrollHeight) ||
- (currWindow.document.documentElement.scrollTop + currWindow.document.documentElement.scrollHeight);
- coverDiv.style.width = W + 'px';
- coverDiv.style.height = H + 'px';
- var maskContainer = containerObj.mask;
- if (!maskContainer) {
- containerObj.mask = [];
- }
- containerObj.mask.push(newID);
- };
- //按钮 [id,pos,title,label,className]
- wd.display.wdButtons = [
- ["wdHelp", 3, "帮助", "帮助", "icon-help"],
- ["CMS_download", 3, "下载", "下载", "icon-download"],
- ["wdShare", 3, "收藏", "收藏", "icon-favorite"],
- ["wdShared", 3, "已收藏", "已收藏", "icon-favoriteOn"],
- ["editWdHelp", 3, "编辑帮助", "编辑帮助", "icon-setHelp"],
- ["editWdHelp_save", 3, "编辑帮助保存", "编辑帮助保存", "invertIcon-save"],
- ["wdTab", 3, "编辑选项卡", "编辑选项卡", "icon-set"],
- ["wdTab_save", 3, "保存选项卡", "保存选项卡", "invertIcon-save"],
- ["wdRecord", 3, "个人选值", "个人选值", "icon-setValue"],
- ["wdRecord_save", 3, "个人选值保存", "个人选值保存", "invertIcon-save"],
- ["CMS_fullscreen", 3, "全屏", "全屏", "dialog-restoreButton"],
- ["CMS_nrProperty", 3, "内容属性", "内容属性", "icon-property"],
- ["change_on", 3, "变动查看-开", "变动查看-开", "dialog-changeOnButton"],
- ["change_off", 3, "变动查看-关", "变动查看-关", "dialog-changeButton"],
- ["lockScreen", 3, "锁定", "锁定", "icon-lock"],
- ["wdPrint", 3, "打印", "打印", "icon-print"],
- ["wdBatchPrint", 3, "批量打印", "批量打印", "icon-print"],
- ["wdHelpCopyhexcode", 3, "复制帮助代码", "复制帮助代码", "icon-key"]
- ];
- wd.display.initStyleWdButtons = function () {
- for (var i = 0; i < wd.display.wdButtons.length; i++) {
- var className = "dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default";
- wd.topWindow.$("div.dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default").addClass(wd.display.wdButtons[i][4]);
- }
- // 特殊处理close,因为如果close和dhtmlx的close冲突,会隐藏原生,新增一个按钮
- var className = "dhtmlx_button_close_default";
- wd.topWindow.$("div.dhtmlx_button_close_default").removeClass(className).addClass("largeIcon-close");
- }
- /**
- * 添加隐藏按钮
- * @param {Object} w
- */
- wd.display.addWdUserButton = function (w) {
- var buttonType = wd.display.wdButtons;
- for (var i = 0; i < buttonType.length; i++) {
- //添加按钮
- w.addUserButton(buttonType[i][0], buttonType[i][1], buttonType[i][2], buttonType[i][3], buttonType[i][4]);
- //隐藏按钮
- w.button(buttonType[i][0]).hide();
- // console.log(buttonType[i][0]+":"+w.button(buttonType[i][0]).isHidden())
- }
- wd.display.initStyleWdButtons();
- }
- wd.display.showAllWdUserButton = function (w, nolimit) {
- //解除限制
- if (nolimit) {
- w.unAllowButton = false;
- } else {
- w.unAllowButton = true;
- }
- var buttonType = wd.display.wdButtons;
- for (var i = 0; i < buttonType.length; i++) {
- if (w.button(buttonType[i][0]).isHidden() == false) {
- w.button(buttonType[i][0]).show();
- }
- }
- }
- wd.display.hideAllWdUserButton = function (w) {
- w.unAllowButton = true;
- var buttonType = wd.display.wdButtons;
- for (var i = 0; i < buttonType.length; i++) {
- w.button(buttonType[i][0]).style.display = "none";
- }
- }
- /**
- * 添加弹窗事件
- * @param {Object} w
- */
- wd.display.addComponentEvent = function (w) {
- // 按钮:设置wdRecord
- w.getFrame().addEventListener("load", function () {
- var iframeWindow = w.getFrame().contentWindow
- if ("0" == iframeWindow.loginStatus)
- return;
- //wdShare
- var wdShare = function () {
- this.win = null;
- this.button;
- this.init = function (w) {
- this.win = w;
- // var wdDialogWin = iframeWindow.document.querySelector("wdDialog[collect=true]")
- // if (!wdDialogWin)
- // return;
- this.sendRequest("query", (function () {
- return function (data) {
- if (data == 1) {
- //已分享
- this.addButton("wdShared")
- } else if (data == 0) {
- //未分享
- this.addButton("wdShare")
- }
- }
- })())
- }
- this.addButton = function (buttontype) {
- var THIS = this;
- //恢复隐藏按钮
- if (this.win.button(buttontype) && this.win.button(buttontype) != null) {
- this.win.button(buttontype).show();
- } else {
- // if (buttontype == "wdShared") {
- // this.win.addUserButton(buttontype, 3, "已收藏", "已收藏")
- // } else if (buttontype == "wdShare") {
- // this.win.addUserButton(buttontype, 3, "未收藏", "未收藏")
- // }
- }
- this.win.button(buttontype).onclick = function () {
- THIS.wdshareClick(buttontype)
- }
- }
- this.wdshareClick = function (buttontype) {
- var type;
- //已收藏点击:取消收藏
- //未收藏点击:
- if (buttontype == "wdShared") {
- type = "delete"
- } else if (buttontype == "wdShare") {
- type = "add"
- }
- this.sendRequest(type, function (data) {
- if (data == 1) {
- this.win.button(buttontype).hide();
- this.addButton(buttontype == "wdShared" ? "wdShare" : "wdShared")
- } else if (data == 0) {
- console.log(data);
- } else {
- console.log(data)
- }
- });
- }
- this.sendRequest = function (type, callback) {
- var wdsharetype;
- if (type == "query") {
- wdsharetype = "";
- } else if (type == "add") {
- wdsharetype = 1;
- } else if (type == "delete") {
- wdsharetype = 0;
- } else {
- alert("type 值超出范围:"+ type) // ("我是不可能出现的!")。Lin
- }
- var THIS = this;
- $.post("/service?ssServ=wdShare", {
- wdsharetype: wdsharetype,
- wdshareurl: iframeWindow.window.location.href
- }, function (data) {
- if (callback) {
- callback.call(THIS, data)
- }
- })
- }
- }
- new wdShare().init(w);
- }, false);
- }
- /**
- * 将url中的动态参数替换成指定的值
- * 如果param为空,则参数的值在html元素中寻找,如果param的值不为空,则在param中获取
- * 对于现在的服务调用,采用匹配进行
- * @service{name:"xxx",dest:"xxx",param:{"xxx":"xxx","data":"wdVal{data}"}}@
- * 中的"data":"wdVal{data}"
- * 如果要添加额外变量参数,有两种方法
- * 1.在html中 添加 input标签 name对应 data,把需要的值传入value(即是用element获取) <input name="data">
- * 2.如果是js变量,通过传入json变量覆盖,例:
- * var json = JSON.parse('{"data":"' + encodeURI(obj) + '"}');
- * var url = '@service{name:"cd_ydck",dest:"cd_ydck",show:"wdDialog",param:{"cdydid":"wdVal{data}"}}@';
- * url = wd.display.replaceDynamicParam(url, json);
- * eval(url);
- */
- wd.display.replaceDynamicParam = function (url, param) {
- /* 再改,规范 wdVal{ 命名。Lin
- var reg = /wdVal\{\s*[A-Za-z0-9_]*\s*\}/g;
- */var reg = /ssVal\{\s*[A-Za-z0-9_]*\s*\}/g;
- //如果没有匹配的动态参数
- if (!reg.test(url)) {
- return url;
- } else {
- var result = url.match(reg);
- for (var i = 0; i < result.length; i++) {
- var source = result[i];
- //获取动态参数的name
- var name = source.trim().substring(6, source.trim().length - 1);
- //增加空字符串的可能性
- if (param && param[name] != undefined) {
- url = url.replace(source, param[name]);
- } else {
- var value = document.getElementsByName(name)[0].value;
- url = url.replace(source, value);
- }
- }
- return url;
- }
- };
- wd.display.Yi = 49;
- wd.display.Xi = 23;
- wd.display.addDialogLine = function (w) {
- if (!w) {
- var wdDialogId = wd.display.getwdDialogId();
- w = wd.topWindow.dhxWins.window(wdDialogId);
- }
- $(w).find(".dhtmlx_wins_body_inner").removeClass("dhtmlx_wins_body_inner_noborder").addClass(
- "dhtmlx_wins_body_inner_border");
- }
- wd.display.removeDialogLine = function (w) {
- if (!w) {
- var wdDialogId = wd.display.getwdDialogId();
- w = wd.topWindow.dhxWins.window(wdDialogId);
- }
- $(w).find(".dhtmlx_wins_body_inner").removeClass("dhtmlx_wins_body_inner_border").addClass(
- "dhtmlx_wins_body_inner_noborder");
- }
- /**
- * 方法中文名:切换DOM元素显示 显示第二个参数数组指定的所有DOM元素,隐藏第三个参数数组指定的所有DOM元素,
- * 第四个参数为选填,如果填了,则第二个参数中的第一个iframe将加载此参数(url)指定的页面
- *
- *
- * demo:
- * wd.display.showComponent({show:[{"name":"wdDialog","size":"450*380"}],hide:[],url:"/service?wdApplication=jw&wdService=ty_gg_ck&wdOutputComponent=44786&wdtest=false&ggid=44000059",dest:"gg.ty_gg_ck",title:"查看",width:450,high:380,wdDialogId:44786,form:""})
- * wd.display.showComponent({show:["wdDialog"],hide:[],url:"/service?wdApplication=wd&wdService=grxx_shlist&wdToken=689&wdOutputComponent=44983&wdtest=false&sqid=44438",dest:"shqk",title:"审核情况件",width:500,high:300,wdDialogId:44983,form:""})
- *
- */
- wd.display.showComponent = function (params) {
- if (typeof beacon != 'undefined' && beacon.shouldOpenOtherBrowser && beacon.shouldOpenOtherBrowser()) {
- var url = params.url;
- if (url.startsWith("/")) {
- url = window.location.origin + url;
- }
- beacon.openWindow(params.title, params.width, params.height, url);
- return;
- }
- // 加载鼠标动画 by SPACE 2019-04-02
- wd.display.showLoad();
- //alert(top.window.document.querySelector('iframe[name="win2"]'));
- if (window.event) {
- if (window.event.stopPropagation) {
- window.event.stopPropagation();
- } else {
- window.event.cancelBubble = true;
- }
- }
- var fullScreenLimitHeight = true; // 全屏时窗口的高度与window.innerHeight一致
- var showNameOrId = params.show; // 由需要显示的DOM元素的NAME或ID组成的数组或字符串,注意:
- // 如果含有值’wdDialog’,则弹出dhtmlxWindows窗口,否则只是切换部件显示
- var hideNameOrId = params.hide; // 由需要隐藏的DOM元素的NAME或ID组成的数组或字符串(可选参数,可以不填)
- if (!params["getSize"]) {
- params["getSize"] = "1";
- params["wdDialogId"] = new Date().getTime();
- /* 再改,规范 &token= 命名。Lin
- * IDEA = Redundant character escape '\=' in RegExp
- * IDEA = Redundant character escape '\&' in RegExp
- var exec = /token\=([^\&]*)/.exec(params.url)
- */ var exec = /ssToken=([^&]*)/.exec(params.url)
- if (exec) {
- $.ajax({
- url: "/service?ssServ=loadPageParm",
- data: {
- "tokenstring": exec[1]
- },
- async: true,
- timeout: 10000,
- type: "POST",
- dataType: "json",
- error: function (data) {
- console.log(arguments);
- wd.display.showComponent(params);
- },
- success: function (result) {
- params = $.extend(params, result, { title: params.title });
- wd.display.showComponent(params);
- }
- })
- return params["wdDialogId"];
- }
- }
- var url = wd.display.replaceDynamicParam(params.url); // 参数showElemNameOrIdArr中的第一个iframe将加载此URL的页面(可选参数,可以不填)
- var width = (parseInt(params.width) || 100) + this.Xi; // 当要弹出窗口宽度,单位为px
- ///??? 有空再去掉参数 high -- 统一用 height???Lin ///
- var high = (parseInt(params.high) || parseInt(params.height) || 100) + this.Yi; // 当要弹出窗口宽度,单位为px
- var showTitle = params.showTitle || false;
- //弹出窗口自适应高度
- if (!!params.minHeight && !!params.maxHeight) {
- params.minHeight = parseInt(params.minHeight);
- params.maxHeight = parseInt(params.maxHeight);
- if (params.minHeight + this.Yi > wd.topWindow.innerHeight) {
- high = params.minHeight + this.Yi;
- showNameOrId = 'wdFullScreen';
- fullScreenLimitHeight = false;
- } else if (params.maxHeight + this.Yi < wd.topWindow.innerHeight) {
- high = params.maxHeight + this.Yi;
- } else {
- /* 母体里的,showTitle="false" -- if(showTitle) 成立。Lin
- * PMS 里的 showTitle=false -- if(showTitle) 不成立
- * 先改为 high = wd.topWindow.innerHeight;
- * 先不改 */
- if (showTitle)
- high = wd.topWindow.innerHeight;
- else
- showNameOrId = 'wdFullScreen';
- }
- }
- url=wd.base.setRowCountPerPage(url,high-this.Yi,width);
- // if ( params.bjgd && params.wdFitHeightAttrs && params.wdFitHeightAttrs.length > 0 ){
- // var minHigh = params.bjgd;
- // var maxHigh = params.bjgd;
- // for( var i = 0 ; i < params.wdFitHeightAttrs.length; i ++ ){
- // var attr = params.wdFitHeightAttrs[i];
- // var max = attr.max;
- // var min = attr.min;
- // if( typeof(max) == 'string' ) {
- // var temp = /\d+/.exec(max);
- // if ( temp != null ) {
- // max = parseInt(temp[0]);
- // }else{
- // max = null;
- // }
- // }
- // if( typeof(min) == 'string' ) {
- // var temp = /\d+/.exec(min);
- // if ( temp != null ) {
- // min = parseInt(temp[0]);
- // } else {
- // min = null;
- // }
- // }
- // if( max != null ) {
- // maxHigh += max;
- // }
- // if ( min != null ) {
- // minHigh += min;
- // }
- // }
- // if(minHigh + 38 > wd.topWindow.innerHeight) {
- // high = minHigh + 38;
- // showNameOrId = 'wdFullScreen';
- // fullScreenLimitHeight = false;
- // } else if ( maxHigh + 38 < wd.topWindow.innerHeight ){
- // high = maxHigh + 38;
- // } else {
- // showNameOrId = 'wdFullScreen';
- // }
- // }
- // var topBodyHeight = wd.topWindow.document.body.offsetHeight;
- //var dialogHeight = wd.topWindow.document.querySelector('.dhtmlx_window_active').offsetHeight;
- // var dialogClientHeight = wd.topWindow.document.querySelector('.dhtmlx_wins_body_inner').offsetHeight;
- //var maxDialogClientHeight = topBodyHeight-(dialogHeight-dialogClientHeight);
- // if ( !!params.maxHigh && !!params.minHigh ) {
- // if(params.minHigh + 38 > topBodyHeight ) {
- // high = params.minHigh + 38;
- // showNameOrId = 'wdFullScreen';
- // }else if(params.maxHigh + 38 < topBodyHeight){
- // high = params.maxHigh + 38;
- // }else {
- // showNameOrId = 'wdFullScreen';
- // }
- // }
- var title = params.title || "无题,可能没找到部件"; // 窗口标题,(可选参数,可以不填)
- var form = params.form; // 需要提交的form名字
- // var wdDialogId = params.wdDialogId;//部件ID
- var wdDialogId = params.wdDialogId || new Date().getTime(); // 部件ID
- wd.display.winWidth = width;
- wd.display.winHeight = high;
- if (form) {
- wd.topWindow.wd.display.targetForm = window.document
- .getElementsByName(form)[0];
- wd.topWindow.wd.display.targetUrl = url;
- url = "/wd/js/cloneForm/cloneForm.jsp";
- }
- if (title) {
- // title = '<span style="font:14px
- // \'宋体\'\;line-height:30px;" >'+title+'</span>';
- title = '<span style="padding:5px;">' +
- '<a class="dialog-title" target="_blank" onclick="return false;" href="' +
- url +
- '&wdTitle=' +
- title +
- '">' +
- title +
- '</a>' +
- '<a class="secondTitle" target="_blank" onclick="return false;" href="javascript:void(0);"></a>' +
- '</span>';
- }
- if (showNameOrId) { // 如果需要显示部件
- if (typeof (showNameOrId) != 'object') { // 如果传入的不是数组
- var arr = [];
- arr.push(showNameOrId);
- showNameOrId = arr; // 统一为数组
- }
- var useUrl = true;
- var hasWdDialog = false;
- for (var i = 0; i < showNameOrId.length; i++) {
- var oneNameOrId = showNameOrId[i];
- if (oneNameOrId == 'wdDialog') { // 这里应该不是 <wdDialog。Lin
- hasWdDialog = true;
- break;
- }
- }
- for (var i = 0; i < showNameOrId.length; i++) {
- var oneNameOrId = showNameOrId[i];
- var selfParam = oneNameOrId.self;
- var titleParam = oneNameOrId.title;
- var nameParam = oneNameOrId.name;
- var sizeParam = oneNameOrId.size;
- var positionParam = oneNameOrId.position;
- var btnParam = oneNameOrId.button;
- /**
- * 下面是原来有 show:[{"name":"wdDialog","size":"450*380"}]
- * 这一part时,会走到的代码,但是这部分代码与wddialog这部分分离了,暂时不要了,以后看如何重写
- *
- * if(nameParam){ //参数格式为json的弹出窗口 if(selfParam){ //在本窗口弹出
- * if(!window.dhxWins){ window.dhxWins = new dhtmlXWindows(); } var
- * dhxWins = window.dhxWins;
- * dhxWinsdhxWins.setImagePath('/wd/theme/window/dhx_blue/image/active/'); //
- * //alert(dhxWinsdhxWins.vp.style.border);
- * //dhxWinsdhxWins.vp.style.border = ""; //
- * dhxWins.enableAutoViewport(true);
- * //dhxWins.attachViewportTo("dt");
- * //把当前窗口的window对象,保存到window窗口中,以便关闭窗口时使用 var ele =
- * {dom:window,wdDialogId:wdDialogId}; wd.display.windowToObj(ele);
- * var winParam =
- * {dom:window,wdDialogId:wdDialogId,btnParam:btnParam,sizeParam:sizeParam,title:titleParam,url:url,positionParam:positionParam};
- * wd.display.setDhtmlXWinParam(winParam); }else{ //弹窗在顶层
- * //把当前窗口的window对象,保存到wd.topWindow窗口中,以便关闭窗口时使用 var ele =
- * {dom:wd.topWindow,wdDialogId:wdDialogId};
- * wd.display.windowToObj(ele);
- *
- * if(!wd.topWindow.wd.display.wdDialogOpeners)
- * wd.topWindow.wd.display.wdDialogOpeners = {};
- * wd.topWindow.wd.display.wdDialogOpeners[wdDialogId]=window; var
- * winParam =
- * {dom:wd.topWindow,wdDialogId:wdDialogId,btnParam:btnParam,sizeParam:sizeParam,title:titleParam,url:url,positionParam:positionParam};
- * wd.display.setDhtmlXWinParam(winParam); } }
- */
- // wd.display.showComponent({show:[{"name":"wdDialog","size":"450*380"}],hide:[],url:"/service?wdApplication=jw&wdService=ty_gg_ck&wdOutputComponent=44786&wdtest=false&ggid=44000059",dest:"gg.ty_gg_ck",title:"查看",width:450,high:380,wdDialogId:44786,form:""})
- if (typeof (oneNameOrId) == 'object') {
- if (oneNameOrId.size) {
- var arr = oneNameOrId.size.split("*");
- var width = parseInt(arr[0]) + 15; // 当要弹出窗口宽度,单位为px
- var high = parseInt(arr[1]) + 38; // 当要弹出窗口宽度,单位为px
- }
- oneNameOrId = oneNameOrId.name;
- }
- var storage = window.localStorage;
- if (oneNameOrId == 'wdDialog') { // "如果要弹出窗口"。这里应该不是 <wdDialog。Lin
- // 把当前窗口的window对象,保存到wd.topWindow窗口中,以便关闭窗口时使用
- if (!wd.topWindow.wd.display.wdDialogOpeners)
- wd.topWindow.wd.display.wdDialogOpeners = {};
- wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
- var windowId = wdDialogId;
- // /当前可视区域
- var sw = wd.topWindow.screen.availWidth;
- var sh = wd.topWindow.screen.availHeight;
- // 根据可是区域调整窗口
- var cenFlag = false; // 超过时不居中
- if (width > (sw - 20)) {
- width = sw - 20;
- };
- if (high > (sh - 20))
- high = sh - 20;
- if (width > sw || high > sh)
- cenFlag = true;
- // /
- if (!wd.topWindow.dhxWins)
- wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
- var w = wd.topWindow.dhxWins.createWindow(windowId, 0, 0, width, high);
- w.keepInViewport(true); // 保持在窗口内
- if (!cenFlag)
- w.center(); // 居中
- w.setText(title); // 设置窗口标题
- //2021-09-06 新增,当url超长时候,改成form提交
- var hasInvalidUrlChar = false;
- var invalidUrlChar = ['{', '}', '[', ']', '|'];
- for (var _ici = 0; _ici < invalidUrlChar.length; _ici++) {
- if (url.indexOf(invalidUrlChar[_ici]) > -1) {
- hasInvalidUrlChar = true;
- break;
- }
- }
- if (hasInvalidUrlChar || (url && url.length > 1000)) {
- hasInvalidUrlChar && console.log("url中有非法字符");
- console.log("触发了form提交表单~,url长度:"+url.length);
- w.attachEvent("onContentLoaded", function () {
- try {
- if (this.getFrame().getAttribute("formload")) {
- return;
- }
- var myDoc = this.getFrame().contentDocument;
- var index = url.indexOf("?");
- index = index < 0 ? url.length - 1 : index;
- var base = url.substring(0, index);
- var params = url.substring(index + 1);
- var paramarr = params.split("&");
- var myform = myDoc.createElement("form");
- myform.setAttribute("action", base);
- myform.setAttribute("method", "post");
- myDoc.body.appendChild(myform);
- for (var pi = 0; pi < paramarr.length; pi++) {
- var pstr = paramarr[pi];
- var pei = pstr.indexOf("=");
- pei = pei < 0 ? pstr.length : pei;
- var k = pstr.substring(0, pei);
- var v = pstr.substring(pei + 1);
- var myInput = myDoc.createElement("input");
- myInput.setAttribute("type", "hidden");
- myInput.setAttribute("name", k);
- myInput.value =decodeURIComponent(v);//可能会有url编码了的情况
- myform.appendChild(myInput);
- }
- myform.submit();
- this.getFrame().setAttribute("formload", "true")
- } catch (e) {
- console.error(e)
- }
- });
- w.attachURL("javascript:false;");
- } else {
- w.attachURL(url); // 跳到此URL
- }
- useUrl = false;
- w.setModal(true); // 设置模式窗口
- w.bringToTop(); // 置顶
- wd.display.addWdUserButton(w);
- wd.display.addComponentEvent(w);
- wd.display.addDialogLine(w);
- // 改变按钮的类样式名
- // var buttonType = wd.display.wdButtons;
- // for (var i = 0; i < buttonType.length; i++) {
- // w.button(buttonType[i][0]).className = "dhtmlx_wins_btns_button " + buttonType[i][4];
- // }
- // 隐藏不需要的按钮
- w.clearIcon();
- if (w.button('help'))
- w.button('help').hide();
- if (w.button('stick'))
- w.button('stick').hide();
- if (w.button('sticked'))
- w.button('sticked').hide();
- if (w.button('park'))
- w.button('park').hide();
- if (w.button('minmax1')) // 隐藏最大化按钮
- w.button('minmax1').hide();
- w.denyResize(); // 不允许改变大小
- // if(w.button('close'))
- // w.button('close').hide();
- // w.btns.help.title = "帮助";
- w.button('close').setAttribute("title", "关闭"); // 修改关闭按钮提示
- var containerObj = wd.topWindow.wd.display;
- var currentDialogZIndex = w.zi; // 弹出窗口的z-index
- // wd.display.createMaskDiv(containerObj,wd.topWindow.wd.display.wdDialogOpeners[wdDialogId],currentDialogZIndex);
- /*
- * wd.display.createMaskDiv(containerObj, wd.topWindow,
- * currentDialogZIndex);
- */
- wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex);
- /*
- * var parentWdDialogId = wd.display.getwdDialogId(); if(typeof
- * parentWdDialogId != 'undefined' && parentWdDialogId ){ var
- * parentDialog = wd.topWindow.dhxWins.window(parentWdDialogId);
- * if( typeof parentDialog != 'undefined' && parentDialog ){
- * //parentDialog.button('close').disable(); } }
- */
- // // 点击时弹出帮助提示信息
- // w.button("help").attachEvent("onClick", function () {
- // alert("button \"help\" was clicked");
- // });
- w.attachEvent("onClose", function (win) {
- /*
- * var containerObj = wd.topWindow.wd.display.mask; var
- * currentMaskEleID = containerObj.pop(); // var currMaskEle = //
- * wd.topWindow.wd.display.wdDialogOpeners[wdDialogId].document.getElementById(currentMaskEleID);
- * var currMaskEle = wd.topWindow.document
- * .getElementById(currentMaskEleID); if (typeof currMaskEle !=
- * 'undefined' && currMaskEle) { if (typeof
- * currMaskEle.remove != 'undefined') {
- * currMaskEle.remove(); } else { currMaskEle.parentNode
- * .removeChild(currMaskEle); } }
- */
- wd.display.dxwindowsCloseMaskDiv();
- /*
- * var parentDialog =
- * wd.topWindow.dhxWins.window(parentWdDialogId); if(typeof
- * parentDialog != 'undefined' && parentDialog ){
- * //parentDialog.button('close').enable(); }
- */
- // var iframeObj = $(win).find('iframe')[0];
- function findIframe(dom) {
- for (var i = 0; i < dom.childNodes.length; i++) {
- var c = dom.childNodes[i];
- if (c.tagName == 'IFRAME') {
- return c;
- }
- var temp = findIframe(c);
- if (temp)
- return temp;
- }
- }
- try {
- var iframeObj = findIframe(win);
- var popWindow = iframeObj.contentWindow;
- // 调用关闭窗口时调用的回调方法
- if (typeof popWindow != 'undefined' && popWindow.wd.display.closeDialogCallbackFun) {
- popWindow.wd.display.closeDialogCallbackFun();
- }
- wd.display.onCloseDialog(win, popWindow);
- } catch (e) {
- console.log(e);
- }
- return true;
- });
- } else if (oneNameOrId == "wdFullScreen") { // 如果只是显示功能部件
- if (!wd.topWindow.dhxWins)
- wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
- if (!wd.topWindow.wd.display.wdDialogOpeners)
- wd.topWindow.wd.display.wdDialogOpeners = {};
- wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
- var w = wd.topWindow.dhxWins.createWindow(wdDialogId, 0, 0, width, high);
- w.keepInViewport(true); // 保持在窗口内
- w.attachURL(url); // 跳到此URL
- w.setModal(true); // 设置模式窗口
- w.bringToTop(); // 置顶
- w.setText(title);
- w.clearIcon();
- w.hideMenu();
- w.hideToolbar();
- w.center(); //窗口居中
- wd.display.addWdUserButton(w);
- wd.display.addComponentEvent(w);
- wd.display.hideAllWdUserButton(w);
- wd.display.addDialogLine(w);
- var winbody;
- var Pbtn = w.button('close').parentNode; //关闭按钮的父节点
- var titleline = w.childNodes[0].childNodes[2]//获取到标题元素
- var btns = w.childNodes[0].childNodes[3];
- var odiv = document.createElement("div"); //创建一个新的元素div,用于存放btn div以及标题的div
- w.childNodes[0].appendChild(odiv);
- odiv.style.height = 43 + "px"; //给新元素进行设置样式
- odiv.style.position = "absolute";
- // odiv.style.display = 'none';
- odiv.id = "odiv";
- odiv.style.top = 0;
- odiv.style.width = "100%";
- odiv.style.backgroundColor = '#ffffff';
- odiv.style.zIndex = -1;
- odiv.setAttribute("class", "hLine");
- w.fullScreen = function () { //初始化页面的函数
- var dhwin = wd.topWindow.dhxWins;
- if (fullScreenLimitHeight)
- wd.topWindow.document.body.style.overflow = "hidden";
- dhwin._engineGetWindowLabel(this).style.display = "none";
- // alert(dhwin._engineFixWindowPosInViewport(this));
- var vpw = (_isIE ? document.body.offsetWidth : window.innerWidth);
- var vph = (_isIE ? document.body.offsetHeight : window.innerHeight);
- // this.h = document.body.clientHeight;
- if (fullScreenLimitHeight)
- this.h = wd.topWindow.document.body.offsetHeight;
- this.y = wd.topWindow.document.body.scrollTop;
- // dhwin._engineFixWindowPosInViewport(this);
- dhwin._engineRedrawWindowSize(this);
- dhwin._engineRedrawWindowPos(this);
- winbody = this.vs[this.av].dhxcont;
- winbody.style.top = 0;
- winbody.style.marginTop = 0;
- winbody.style.height = this.h + "px";
- winbody.childNodes[0].style.height = this.h + "px";
- Pbtn.style.zIndex = 100;
- }
- w.fullScreen();
- Pbtn.onmouseover = function () {
- // console.log(w);
- wd.display.showAllWdUserButton(w, true);
- titleline.style.display = "block" //把标题的display属性改成block,在初始化的时候全部设置成了none
- odiv.style.zIndex = 99; //通过调整div的层数来对原有的信息进行覆盖
- odiv.style.display = 'block';
- titleline.style.zIndex = 100;
- }
- odiv.onmouseover = function () {
- this.style.display = 'block';
- this.style.zIndex = 99;
- titleline.style.zIndex = 100;
- }
- titleline.onmouseover = function () {
- odiv.style.zIndex = 99;
- odiv.style.display = 'block';
- this.style.zIndex = 100;
- }
- Pbtn.onmouseout = function (e) {
- if (!e)
- e = window.event;
- var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
- if (reltg.id != "odiv") {
- odiv.style.zIndex = -1;
- odiv.style.display = 'none';
- w.childNodes[0].childNodes[2].style.display = "none" //鼠标离开时进行还原
- wd.display.hideAllWdUserButton(w);
- } else {
- titleline.style.display = "block"
- }
- }
- odiv.onmouseout = function (e) {
- if (!e)
- e = window.event;
- var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
- // if (reltg.className == "dhtmlx_wins_btns_button dhtmlx_button_wdTab_default") { //判定离开新元素是否到了按钮
- // titleline.style.display = "block"
- // } else
- if (reltg.className == "dhtmlx_wins_title") { //判定离开了新元素是否到了title元素
- titleline.style.display = "block"
- } else {
- odiv.style.zIndex = -1;
- odiv.style.display = 'none';
- w.childNodes[0].childNodes[2].style.display = "none";
- wd.display.hideAllWdUserButton(w);
- }
- }
- titleline.onmouseout = function (e) {
- if (!e)
- e = window.event;
- var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
- if (reltg.id == "odiv") {
- titleline.style.display = "block"
- } else {
- odiv.style.zIndex = -1;
- odiv.style.display = 'none';
- w.childNodes[0].childNodes[2].style.display = "none" //鼠标离开时进行还原
- wd.display.hideAllWdUserButton(w);
- }
- }
- wd.display.hideAllWdUserButton(w);
- w.button('close').setAttribute("title", "关闭");
- //以上是对鼠标的走向进行判定
- w.attachEvent("onClose", function (win) {
- wd.topWindow.document.body.style.overflow = "auto";
- wd.display.dxwindowsCloseMaskDiv();
- function findIframe(dom) {
- for (var i = 0; i < dom.childNodes.length; i++) {
- var c = dom.childNodes[i];
- if (c.tagName == 'IFRAME') {
- return c;
- }
- var temp = findIframe(c);
- if (temp)
- return temp;
- }
- }
- try {
- var iframeObj = findIframe(win);
- var popWindow = iframeObj.contentWindow;
- // 调用关闭窗口时调用的回调方法
- if (typeof popWindow != 'undefined' && popWindow.wd.display.closeDialogCallbackFun) {
- popWindow.wd.display.closeDialogCallbackFun();
- }
- wd.display.onCloseDialog(win, popWindow);
- } catch (e) {
- console.log(e);
- }
- return true;
- });
- var currentDialogZIndex = w.zi;
- wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex);
- } else if (showNameOrId == "wdhelpdialog") {
- console.log("wdhelpdialog")
- if (!wd.topWindow.dhxWins)
- wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
- if (!wd.topWindow.wd.display.wdDialogOpeners)
- wd.topWindow.wd.display.wdDialogOpeners = {};
- wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
- var w;
- //判断窗口是否已关闭
- if (wd.topWindow.wdhelpdialog && wd.topWindow.wdhelpdialog.id) {
- w = wd.topWindow.wdhelpdialog
- } else {
- // x,y控制弹窗口位置
- w = wd.topWindow.dhxWins.createWindow(wdDialogId, params.x, params.y, width, high);
- wd.topWindow.wdhelpdialog = w;
- }
- if (params.center) {
- w.center(); //窗口居中
- }
- w.attachHTMLString(url); // 跳到此URL
- w.keepInViewport(true); // 保持在窗口内
- // w.setModal(true); // 设置模式窗口
- w.bringToTop(); // 置顶
- w.setText(title);
- w.clearIcon();
- // w.denyResize()
- // w.hideMenu();
- // w.hideToolbar();
- wd.display.addWdUserButton(w);
- // w.addUserButton("wdHelp_copyhashcode", 3, "复制代码", "复制代码")
- w.button("wdHelp_copyhashcode").onclick = function () {
- var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
- var fakeElem = document.createElement('textarea');
- // Prevent zooming on iOS
- fakeElem.style.fontSize = '12pt';
- // Reset box model
- fakeElem.style.border = '0';
- fakeElem.style.padding = '0';
- fakeElem.style.margin = '0';
- // Move element out of screen horizontally
- fakeElem.style.position = 'absolute';
- fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
- // Move element to the same position vertically
- fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
- fakeElem.setAttribute('readonly', '');
- fakeElem.value = params.helpHaShCode;
- document.body.appendChild(fakeElem);
- fakeElem.select();
- var succeeded;
- try {
- succeeded = document.execCommand('copy');
- alert("复制成功");
- } catch (err) {
- succeeded = false;
- alert("复制失败");
- }
- removeFake(fakeElem);
- return succeeded;
- }
- if (params.pin) {
- //已锁定
- w.denyMove();
- w.button("wdHelp_pin").hide();
- w.button("close").show();
- } else {
- //未锁定
- w.button("wdHelp_unpin").show();
- w.button("close").hide();
- w.allowMove();
- wd.topWindow.setTimeout(function () {
- if (w.isMovable()) {
- w.close();
- }
- }, 3000)
- }
- w.button("wdHelp_unpin").onclick = function () {
- w.button("close").show();
- w.denyMove();
- this.hide();
- w.button("wdHelp_pin").hide();
- }
- w.button("wdHelp_pin").onclick = function () {
- w.button("close").hide()
- w.allowMove();
- this.hide();
- w.button("wdHelp_unpin").hide();
- setTimeout(function () {
- if (w.isMovable()) {
- w.close();
- }
- }, 5000)
- }
- return w.getId();
- }
- }
- } // end if
- if (hideNameOrId) { // 如果有需要隐藏的DOM元素
- // 显示所有DOM元素
- for (var i = 0; i < hideNameOrId.length; i++) {
- var elem = wd.c.g(hideElemNameOrIdArr[i], windowObj);
- elem.style.display = "none";
- var p = elem.parentNode;
- if (p && p.tagName == 'DIV') {
- p.style.display = "none";
- }
- }
- }
- //允许所有iframe全屏
- var arr = wd.topWindow.document.getElementsByTagName('IFRAME');
- for (var i = 0; i < arr.length; i++) {
- var iframeObj = arr[i];
- iframeObj.setAttribute("allowfullscreen", true);
- }
- // w.button("wdHelp").show()
- // w.button("wdShare").show()
- // w.button("wdRecord").show()
- return wdDialogId;
- };
- /**
- *
- * 设置当前iframe部件的长宽
- */
- wd.display.changeDxwindowDimension = function (width, height) {
- //wd.topWindow.dhxWins.
- //刷新弹出本窗口的窗口
- if (null != wd.display.getwdDialogOpener)
- wd.display.refreshOpener();
- //获得弹出部件window对象,通过创建时的部件id
- var wdDialogId = wd.display.getwdDialogId();
- var win = wd.topWindow.dhxWins.window(wdDialogId);
- //myWins.window(id).setDimension(int width, int height);
- win.setDimension(width, height);
- win.keepInViewport(true); // 保持在窗口内
- win.center(); // 居中
- };
- /**
- *
- * @param {}
- * currentDialogZIndex:当前弹出窗口的zIndex
- */
- wd.display.dxwindowsCreateMaskDiv = function (currentDialogZIndex) {
- var containerObj = wd.topWindow.wd.display;
- var topWindow = wd.topWindow;
- wd.display.createMaskDiv(containerObj, topWindow, currentDialogZIndex);
- };
- // 关闭wddialog时,移除遮罩层
- wd.display.dxwindowsCloseMaskDiv = function () {
- var containerObj = wd.topWindow.wd.display.mask;
- var currentMaskEleID = containerObj.pop();
- var currMaskEle = wd.topWindow.document.getElementById(currentMaskEleID);
- if (typeof currMaskEle != 'undefined' && currMaskEle) {
- if (typeof currMaskEle.remove != 'undefined') {
- currMaskEle.remove();
- } else {
- currMaskEle.parentNode.removeChild(currMaskEle);
- }
- }
- };
- //获取当前窗口对应的dhxWin对象
- wd.display.getwdDialogWindows = function (dialogid) {
- /**
- * 根据是否找到wdDialogId判断当前页面在弹窗中或应用页面
- *
- */
- var wdDialogId = wd.display.getwdDialogId();
- if (dialogid)
- wdDialogId = dialogid
- var win = wd.topWindow.dhxWins.window(wdDialogId);
- return win;
- };
- // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回包含本窗口的iframe
- wd.display.getwdDialogId = function (winUnderIframe) {
- if (!winUnderIframe) {
- winUnderIframe = window;
- }
- var arr = wd.topWindow.document.getElementsByTagName('IFRAME');
- var wdDialogId = null;
- for (var i = 0; i < arr.length; i++) {
- var iframeObj = arr[i];
- var cw = iframeObj.contentWindow;
- var tempId = iframeObj.getAttribute('wdDialogId');
- if (cw == winUnderIframe) {
- if (tempId != null) { // 如果找到包含本窗口的iframe,ie走这里
- wdDialogId = tempId;
- break;
- } else if (iframeObj.dataset) { // chrome走这里
- if (iframeObj.dataset['wdDialogId']) {
- wdDialogId = iframeObj.dataset['wdDialogId'];
- break;
- }
- }
- }
- }
- if (!wdDialogId) {
- //最顶层页面跳出循环
- if (winUnderIframe == wd.topWindow)
- return null;
- wdDialogId = wd.display.getwdDialogId(winUnderIframe.parent);
- }
- return wdDialogId;
- }
- // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回弹出本窗口的原窗口window对象
- wd.display.getwdDialogOpener = function () {
- var wdDialogId = wd.display.getwdDialogId();
- return wd.topWindow.wd.display.wdDialogOpeners[wdDialogId];
- }
- // 刷新弹出本窗口的窗口
- wd.display.refreshOpener = function () {
- // //全屏模式下,按确定按钮关闭全屏模式
- // var fullFiv = wd.topWindow.document.querySelector("#wdfullscreen");
- // if (fullFiv) {
- // fullFiv.parentNode.removeChild(fullFiv);
- // }
- try {
- // 刷新原窗口页面
- var wdDialogOpener = wd.display.getwdDialogOpener(); // 获得原窗口window对象
- if (wd.topWindow == wdDialogOpener) {
- return;
- }
- //执行自定义刷新方法(需要打开窗口定义wdRefresh)
- if (wdDialogOpener.wdRefresh) {
- wdDialogOpener.wdRefresh();
- return;
- }
- //执行默认刷新方法
- var forms = wdDialogOpener.document.getElementsByTagName('FORM');
- //提交表单
- if (forms && forms.length > 0 && forms[0].action) {
- if (forms.length == 1) {
- var f = forms[0];
- f.submit();
- }
- //刷新个人首页部件
- } else {
- if (typeof wdDialogOpener.SYBJCTRL != 'undefined' && wdDialogOpener.SYBJCTRL) {
- // 个人首页分支 by Rd 2016-01-13
- // 通过刷新调用窗口的部件来替代刷新整个调用窗口
- wdDialogOpener.SYBJCTRL.EventCtrl.FlushBj();
- } else {
- wdDialogOpener.location.reload();
- }
- }
- } catch (e) {
- console.log(e)
- }
- }
- // 关闭弹出窗口
- wd.display.closeDialog = function () {
- try {
- if (typeof beacon != "undefined")
- beacon.beaconCloseWindow();
- } catch (e) {
- console.error(e);
- }
- var wdDialogId = wd.display.getwdDialogId();
- // console.log(wdDialogId);
- // console.log(wd.topWindow.dhxWins.window(wdDialogId));
- // 关闭鼠标加载动画 by SPACE 2019-04-02
- wd.display.closeLoad();
- // 关闭本弹出窗口
- wd.topWindow.dhxWins.window(wdDialogId).close();
- }
- /**
- * 改变对象的样式
- * event:监听事件的参数--{eventIds:['1','2'],styleName:{onclick:'样式名1',onmouseover:'样式名2',onmouseout:'样式名3'}}
- * eventIds: 监听事件的id数组
- * styleName:样式名(className),[0]是获得点击后样式名,[1]是鼠标移过时的样式名,[2]是对象默认的样式
- */
- wd.display.changeTabStyle = function (param) {
- /**
- * 绑定监听事件 eventIds:绑定事件的id数组, eventType:绑定的事件--onclick,onmouseout等,
- * styleName:样式的类名
- */
- var objClick = new Object();
- objClick.clickId = null;
- objClick.mouseoverId = null;
- function onEvent(tabIds, eventType, styleNames) {
- // try{
- if (eventType == 'onclick') {
- for (var key in tabIds) {
- var tagId = document.getElementById(tabIds[key]);
- (function (key) {
- wd.c.addEventListener(tagId, eventType, function () {
- setTabCssToNormal();
- var objById = this;
- var objFocus = document.activeElement
- objById.className = styleNames.onclick;
- objClick.clickId = tabIds[key];
- });
- })(key)
- }
- } else if (eventType == 'onmouseover') {
- for (var key in tabIds) {
- var tagId = document.getElementById(tabIds[key]);
- (function (key) {
- wd.c.addEventListener(tagId, eventType, function () {
- var objById = document.getElementById(tabIds[key]);
- if (tabIds[key] == objClick.clickId) {
- return;
- }
- objById.className = styleNames.onmouseover;
- objClick.mouseoverId = tabIds[key];
- });
- })(key)
- }
- } else if (eventType == 'onmouseout') {
- for (var key in tabIds) {
- var tagId = document.getElementById(tabIds[key]);
- (function (key) {
- wd.c.addEventListener(tagId, eventType, function () {
- var objById = document.getElementById(tabIds[key]);
- if (tabIds[key] == objClick.clickId) {
- return;
- }
- objById.className = styleNames.normal;
- });
- })(key)
- }
- }
- /**
- * }catch(e){ alert("创建监听事件错误:"+e.message+" Type:"+e.name); }
- */
- }
- // -----------------------
- var tabIds = param.tabIds;
- var styleNames = param.styleNames;
- onEvent(tabIds, 'onclick', styleNames);
- onEvent(tabIds, 'onmouseover', styleNames);
- onEvent(tabIds, 'onmouseout', styleNames);
- function setTabCssToNormal() {
- for (var i = 0; i < tabIds.length; i++) {
- var tabId = tabIds[i];
- document.getElementById(tabId).className = styleNames.normal;
- }
- }
- // 设置默认对象
- function setTabCssToNormalDefault() {
- for (var i = 0; i < tabIds.length; i++) {
- var tabId = tabIds[i];
- if (i == 0) {
- document.getElementById(tabId).className = styleNames.onclick;
- objClick.clickId = tabId;
- // objClick.clickId = tabId;
- } else {
- document.getElementById(tabId).className = styleNames.normal;
- }
- }
- }
- setTabCssToNormalDefault();
- }
- // 把当前窗口的window对象,保存到指定的窗口中,以便关闭窗口时使用
- wd.display.windowToObj = function (Ele) {
- if (!Ele.dom.wdDialogOpeners)
- Ele.dom.wdDialogOpeners = {};
- Ele.dom.wdDialogOpeners[Ele.wdDialogId] = window;
- }
- // 为dhtmlXWindows设置参数,创建窗口
- wd.display.setDhtmlXWinParam = function (winParam) {
- var windowId = winParam.wdDialogId;
- // /当前可视区域
- var sw = winParam.dom.document.body.offsetWidth;
- var sh = winParam.dom.document.body.offsetHeight;
- var positionParam = winParam.positionParam;
- var btnParam = winParam.btnParam;
- var sizeParam = winParam.sizeParam;
- var winWid;
- var winHeg;
- // 根据可是区域调整窗口
- var cenFlag = false; // 超过时不居中
- // 处理x,y
- if (positionParam) {
- var win_X = positionParam.split(",")[0];
- var win_Y = positionParam.split(",")[1];
- } else {
- cenFlag = true; // 居中
- }
- // 处理size属性
- if (!sizeParam) { // 用户不填写size属性
- winWid = wd.display.getDialogWidAndHei(wd.display.winWidth);
- winHeg = wd.display.getDialogWidAndHei(wd.display.winHeight);
- } else if ("max" == sizeParam) { // 这里设置的win
- // size是还原状态下的窗口大小,后面会直接调用控件的最大化方法
- if (wd.topWindow == winParam.dom) {
- winWidth = wd.topWindow.document.body.offsetWidth;
- winHeight = wd.topWindow.document.body.offsetHeight;
- } else {
- winWidth = document.body.offsetWidth;
- winHeight = document.body.offsetHeight;
- }
- winWid = wd.display.getDialogWidAndHei(winWidth);
- winHeg = wd.display.getDialogWidAndHei(winHeight);
- } else {
- winWid = wd.display.getDialogWidAndHei(sizeParam.split("*")[0],
- document.body.offsetWidth);
- winHeg = wd.display.getDialogWidAndHei(sizeParam.split("*")[1],
- document.body.offsetHeight);
- }
- // if(winParam.dom.width < winWid || winParam.dom.heigh < winHeg)
- // cenFlag=true;
- if (positionParam) {
- var w = winParam.dom.dhxWins.createWindow(windowId, parseInt(win_X),
- parseInt(win_Y), winWid, winHeg);
- } else {
- var w = winParam.dom.dhxWins.createWindow(windowId, 0, 0, winWid,
- winHeg);
- }
- w.keepInViewport(true); // 保持在窗口内
- if (cenFlag)
- w.center(); // 居中
- if (winParam.title)
- w.setText(winParam.title); // 设置窗口标题
- w.attachURL(winParam.url); // 跳到此URL
- useUrl = false;
- w.setModal(true); // 设置模式窗口
- w.bringToTop(); // 置顶
- // 隐藏不需要的按钮
- wd.display.showDialogBtn(w, btnParam);
- if ("max" == sizeParam) {
- w.maximize();
- }
- // if(w.button('help'))
- // w.button('help').hide();
- // if(w.button('stick'))
- // w.button('stick').hide();
- // if(w.button('sticked'))
- // w.button('sticked').hide();
- // if(w.button('park'))
- // w.button('park').hide();
- }
- // 处理弹出窗口的大小
- // 分为3中情况:数字*数字;max*数字;max
- wd.display.getDialogWidAndHei = function (p, wp) {
- if (p == "max") {
- p = wp;
- }
- return parseInt(p);
- }
- // 处理弹出窗口的按钮
- wd.display.showDialogBtn = function (w, btnParam) {
- if (w.button('help'))
- w.button('help').hide();
- if (w.button('stick'))
- w.button('stick').hide();
- if (w.button('sticked'))
- w.button('sticked').hide();
- if (w.button('park'))
- w.button('park').hide();
- if (w.button('minmax1'))
- w.button('minmax1').hide();
- w.button('minmax2').hide();
- if (w.button('close'))
- w.button('close').hide();
- if (btnParam) {
- if (btnParam.indexOf("min") >= 0) {
- w.button('park').show();
- }
- if (btnParam.indexOf("max") >= 0) {
- if (w.isMaximized())
- w.button('minmax2').show();
- else
- w.button('minmax1').show();
- }
- if (btnParam.indexOf("close") >= 0) {
- w.button('close').show();
- }
- } else { // 用户没填写的话,默认值为“max,close”
- if (w.isMaximized())
- w.button('minmax2').show();
- else
- w.button('minmax1').show();
- w.button('close').show();
- }
- }
- /**
- * 把名为frameName的frame的src属性置为url
- */
- wd.display.changeFrameSrc = function (frameName, url) {
- document.getElementsByName(frameName)[0].src = url;
- }
- wd.display.wdTabNo = wd.display.defaultTabNo = 1; //默认的tab索引值
- // 初始化tab的总方法
- wd.display.initTab = function () {
- (function () {
- var tab = function () {
- this.dom = null;
- this.wdTabFrame = null;
- this.wdTabList = [];
- this.wdSecondaryTab = [];
- this.styles = {
- wdNormalClass: null,
- wdSelectedClass: null,
- wdNormalMoreClass: null,
- wdSelectedMoreClass: null
- }
- this.selectTab = null;
- this.mouseoutid = null;
- var li = function () {
- this.topSide = null;
- this.dom = null;
- this.type = null; //1:普通,2,显示隐藏开关,3,二级选项
- this.parent = null;
- this.ul = null;
- this.url //点击刷新iframe的地址
- this.secondaryTabList = [];
- //独立
- this.init = function (ele, type, topside, styles) {
- //二级的顶层
- this.dom = ele
- this.url = this.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin
- this.setTopSide(topside)
- this.type = type;
- this.setStyle(styles);
- // this.dom.setAttribute("class", this.wdNormalClass)
- this.initEvent()
- return this;
- }
- //初始化样式属性
- this.setStyle = function (styles) {
- this.styles = styles;
- if (this.type == 1) {
- }else if (this.type == 2) {
- //初始二级的选项
- this.initSecondaryTap();
- $(this.dom).children("ul").addClass("popup-div").css({
- "position": "absolute"
- });
- } else if (this.type == 3) {
- this.dom.style.list_style_type = "none"
- $(this.dom).attr("class","");
- $(this.dom).addClass(styles.wdNormalMoreClass);
- }
- $(this.dom).removeClass(styles.wdSelectedClass).addClass(styles.wdNormalClass);
- return this;
- }
- //绑定事件初始化
- this.initEvent = function () {
- this.dom.addEventListener("click", this.mouseClickEvent(), false)
- this.dom.addEventListener("mouseover", this.mouseOverEvent(), false)
- this.dom.addEventListener("mouseout", this.mouseOutEvent(), false)
- }
- this.initSecondaryTap = function () {
- var newStyles = $.extend({},this.styles);
- newStyles.wdNormalClass = this.styles.wdNormalMoreClass;
- newStyles.wdSelectedClass = this.styles.wdSelectedMoreClass;
- var result = [];
- //显示隐藏的位置
- var ul = this.dom.getElementsByTagName("ul")[0]
- if (ul == null)
- return;
- this.ul = ul;
- ul.style.display = "none";
- var childNodes = ul.childNodes;
- for (var i = 0; i < childNodes.length; i++) {
- var nod = childNodes[i];
- if (nod.nodeType == 1) {
- if (nod.hasAttribute("ssTabClick")) { // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin
- var liobj = new li();
- liobj.init(nod, 3, this.topSide, newStyles)
- result.push(nod)
- }
- }
- }
- this.secondaryTabList = result;
- }
- //设置根
- this.setTopSide = function (obj) {
- this.topSide = obj;
- }
- this.mouseClickEvent = function () {
- var THIS = this;
- return function () {
- //编辑选项卡状态
- if ("1" == THIS.topSide.dom.getAttribute("editing")) {
- return true;
- }
- //清除上次点击
- if (THIS.type != 2 && THIS.topSide.selectTab) {
- $(THIS.topSide.selectTab.dom).removeClass(THIS.topSide.selectTab.styles.wdSelectedClass).addClass(THIS.topSide.selectTab.styles.wdNormalClass)
- // THIS.topSide.selectTab.dom.setAttribute("class", THIS.topSide.selectTab.wdNormalClass)
- THIS.topSide.selectTab = null
- }
- THIS.topSide.selectTab = THIS
- THIS.url = THIS.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin
- if (THIS.type == 1 || THIS.type == 3) {
- // THIS.topSide.wdTabFrame.src = THIS.url;
- THIS.topSide.wdTabFrame.src = wd.base.setRowCountPerPage(THIS.url, THIS.topSide.wdTabFrame.offsetHeight);
- $(THIS.dom).removeClass(THIS.styles.wdNormalClass).addClass(THIS.styles.wdSelectedClass)
- // THIS.dom.setAttribute("class", THIS.wdSelectedClass);
- } else if (THIS.type == 2) {
- if (THIS.ul) {
- if (THIS.ul.style.display == "none") {
- THIS.ul.style.display = ""
- } else {
- THIS.ul.style.display = "none"
- }
- }
- }
- /**
- * 找不到原来说的点击tab之后更多变成tab对应的名字
- */
- var secondarytab = document.querySelector('[wdsecondarytab="true"]');
- if (secondarytab) {
- var type = THIS.type;
- if (type != 2) {
- $(secondarytab).children(":not(ul)").remove();
- $(secondarytab).contents().filter(function () {
- if (this.nodeType == 3)
- return true
- }).remove()
- }
- var firstNode = secondarytab.firstChild;
- switch (type) {
- case 1:
- var moreNode = document.createTextNode('更多');
- if (firstNode.nodeType == 3) {
- secondarytab.replaceChild(moreNode, firstNode);
- } else {
- secondarytab.insertBefore(moreNode, firstNode);
- }
- secondarytab.currentSelectedItem = null;
- //删除小黄点
- $(secondarytab).children(".statePoint").remove();
- break;
- case 2:
- //“更多”被点击
- if (secondarytab.currentSelectedItem) {
- secondarytab.currentSelectedItem.dom.click();
- }
- break;
- case 3:
- //复制小黄点
- if($(THIS.dom).find(".statePoint").length>0){
- $(secondarytab).prepend($(THIS.dom).find(".statePoint").clone());
- }
- $(secondarytab).prepend(document.createTextNode($(THIS.dom).contents().text() + "..."))
- secondarytab.currentSelectedItem = THIS;
- break;
- }
- }
- }
- }
- this.mouseOverEvent = function () {
- var THIS = this;
- return function () {
- if ("1" == THIS.topSide.dom.getAttribute("editing")) {
- return true;
- }
- if (THIS.type == 2) {
- if (THIS.ul)
- THIS.ul.style.display = "block";
- //THIS.dom.getElementsByTagName("ul")[0]
- if (THIS.topSide.mouseoutid)
- clearTimeout(THIS.topSide.mouseoutid);
- THIS.topSide.mouseoutid = null;
- }
- }
- }
- this.mouseOutEvent = function () {
- var THIS = this;
- return function () {
- if ("1" == THIS.topSide.dom.getAttribute("editing")) {
- return true;
- }
- if (THIS.topSide.selectTab != THIS) {
- $(THIS.dom).removeClass(THIS.styles.wdSelectedClass).addClass(THIS.styles.wdNormalClass)
- }
- // if (THIS.type == 2 && THIS.ul && THIS.ul.style.display == "") {
- // THIS.ul.style.display = "none"
- // }
- if (THIS.type == 2) {
- var pos = THIS.dom.compareDocumentPosition(window.event.relatedTarget);
- if (pos == 10 || pos == 4) {
- if ("true" == THIS.dom.getAttribute("wdSecondaryTab")) {
- if (THIS.topSide.mouseoutid)
- clearTimeout(THIS.topSide.mouseoutid);
- THIS.topSide.mouseoutid = null;
- THIS.topSide.mouseoutid = setTimeout(function () {
- THIS.ul.style.display = "none";
- }, 800)
- }
- }
- }
- }
- }
- }
- this.init = function (dom) {
- this.dom = dom;
- //原为 this.wdTabFrame = document.getElementsByTagName("iframe")[0]
- this.wdTabFrame = document.querySelector('iframe[name="ssTabIframe"]') || // [name="wdTabFrame"]。Lin
- document.getElementsByTagName("iframe")[0];
- this.wdTabFrame.tabObj = this; //为了获取当前选中的tab来刷新当前的iframe
- /* 改,规范命名。Lin
- * wdNormalClass > ssNormClazz
- * 去掉 wdNomalClass
- * wdSelectedClass > ssSelClazz
- this.styles.wdNormalClass = this.dom.getAttribute("wdNormalClass") || this.dom.getAttribute("wdNomalClass");
- this.styles.wdSelectedClass = this.dom.getAttribute("wdSelectedClass");
- */
- this.styles.wdNormalClass = this.dom.getAttribute("ssNormClazz");
- this.styles.wdSelectedClass = this.dom.getAttribute("ssSelClazz");
- var parentiframe = window.parent.document.querySelector("iframe");
- if (parentiframe.tabObj) { //双层选项卡
- if (this.styles.wdSelectedClass != "lightTab-selected")
- this.styles.wdSelectedClass += " lightTab-selected";
- if (this.styles.wdNormalClass != "lightTab")
- this.styles.wdNormalClass += " lightTab";
- this.dom.style = "height:33px;padding-left: 14px;box-sizing:border-box";
- } else {
- if (this.styles.wdSelectedClass != "tab-selected")
- this.styles.wdSelectedClass += " tab-selected";
- if (this.styles.wdNormalClass != "tab")
- this.styles.wdNormalClass += " tab";
- }
- this.styles.wdNormalMoreClass = "popupList";
- this.styles.wdSelectedMoreClass = "popupList";
- //初始化
- var child = this.findChildLi();
- var secondLi;
- for (var i = 0; i < child.length; i++) {
- var type = 1;
- if (child[i].hasAttribute("wdSecondaryTab")) {
- type = 2;
- }
- var liobj = new li();
- liobj.init(child[i], type, this, this.styles);
- if(type==2){
- secondLi=liobj;
- }
- this.wdTabList.push(liobj)
- }
- //超出显示范围,就显示出更多选项卡 start
- var wholewidth=0;
- var domwidth=$(dom).width();
- for(var i=0;i<this.wdTabList.length;i++){
- var w=this.wdTabList[i].dom.offsetWidth;
- wholewidth+=w;
- }
- if(wholewidth>domwidth){
- secondLi.dom.style.display="";
- domwidth-=secondLi.dom.offsetWidth*2;
- var fistgroup=[];
- var secondgroup=[];
- var thirdgroup=[];
- wholewidth=0;
- for(var i=0;i<this.wdTabList.length;i++){
- wholewidth+=this.wdTabList[i].dom.offsetWidth
- var t=this.wdTabList[i].type;
- if(t==2){
- secondgroup.push(this.wdTabList[i]);
- continue;
- }
- if(wholewidth>domwidth){
- thirdgroup.push(this.wdTabList[i]);
- this.wdTabList[i].type=3;
- var oo=$.extend({},this.wdTabList[i].styles,{wdNormalClass:this.wdTabList[i].styles.wdNormalMoreClass,wdSelectedClass:this.wdTabList[i].styles.wdNormalMoreClass});
- this.wdTabList[i].setStyle(oo);
- $(this.wdTabList[i].dom).prependTo(secondLi.ul);
- }else{
- fistgroup.push(this.wdTabList[i]);
- }
- }
- this.wdTabList=fistgroup.concat(secondgroup);
- secondLi.secondaryTabList=thirdgroup.concat(secondLi.secondaryTabList);
- }
- //超出显示范围,就显示出更多选项卡 end
- this.selectClick(wd.display.wdTabNo);
- return this;
- }
- this.findChildLi = function () {
- var result = []
- var childNodes = this.dom.childNodes;
- for (var i = 0; i < childNodes.length; i++) {
- var nod = childNodes[i];
- if (nod.nodeType == 1) {
- /* 再改,规范 <li wdTabClick= 命名。Lin
- * 先改,是 wdtabclick,不是 wdTabClick
- * wdSecondaryTab,应该没有了 -- 没有 更多...
- if (nod.hasAttribute("wdtabclick") || nod.hasAttribute("wdSecondaryTab")) {
- */ if (nod.hasAttribute("ssTabClick") || nod.hasAttribute("wdSecondaryTab")) {
- result.push(nod);
- }
- }
- }
- return result;
- }
- //指定第几个tab点击
- this.selectClick = function (no) {
- var num = no || 1;
- var childLength = 0;
- var child = this.findChildLi();
- if (child.length == 0)
- return;
- for (var i = 0; i < child.length; i++) {
- if (child[i].hasAttribute("wdSecondaryTab")) { }
- else {
- childLength++;
- }
- }
- num = (isNaN(num) || num > childLength) ? wd.display.defaultTabNo : num;
- if (childLength == 0) {
- var cc = $(child[0]).find("li").filter(function () {
- return this.style != 'none'
- }).first();
- if (cc.length == 1)
- cc[0].click();
- //隐藏更多
- $(child[0]).find("#tabOption").hide();
- } else if (num > childLength) {
- child[0].click();
- } else {
- child[num - 1].click();
- }
- }
- }
- //从wdTabClick的元素顶层初始化
- var initList = document.querySelectorAll("[ssTabClick]"); // ("[wdTabClick]")。Lin
- var tabobj;
- if (initList.length > 0) {
- if ("tabOption" == initList[0].parentNode.getAttribute("id")) {
- tabobj = new tab().init(initList[0].parentNode.parentNode.parentNode)
- } else {
- tabobj = new tab().init(initList[0].parentNode)
- }
- }
- window.tabobj = tabobj;
- })()
- }
- wd.display.getTabInstance = function () {
- return window.tabobj;
- }
- /**
- * 打印指定div等内容,可多个selector
- */
- wd.display.printArea = function (selector, noscroll, options) {
- var jqsrc = "/wd/js/jquery/jquery.js";
- var printsrc = "/wd/js/print/jquery.PrintArea.js";
- if (typeof $ + "" == "undefined") {
- loadScript(jqsrc, "jquery", function () {
- loadAndPrint();
- });
- } else {
- loadAndPrint();
- }
- function loadAndPrint() {
- if (typeof $.PrintArea + '' == "undefined") {
- loadScript(printsrc, "print", function () {
- options = options || {
- "mode": "iframe",
- "popClose": false,
- "extraCss": "",
- "retainAttr": ["class", "id", "style", "on"],
- "extraHead": "<meta charset=\"utf-8\" />,<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>"
- }
- if (noscroll)
- $(selector).css("overflow", "");
- $(selector).append($("link").clone());
- $(selector).append($("style").clone());
- try {
- $(selector).printArea(options);
- } catch (e) {
- alert("打印出错,检查打印窗是否被拦截");
- console.error(e);
- }
- });
- } else {
- if (noscroll)
- $(selector).css("overflow", "");
- $(selector).append($("link").clone());
- $(selector).append($("style").clone());
- try {
- $(selector).printArea(options);
- } catch (e) {
- alert("打印出错,检查打印窗是否被拦截");
- console.error(e);
- }
- }
- }
- };
- /**
- *
- * @param {Object}
- * output
- * @param {Object}
- * wdurl
- */
- wd.display.qrcode = function (output, wdurl, width, height, render) {
- // console.log($().qrcode);
- // if (typeof $ + "" == "undefined") {
- // loadScript("/wd/js/jquery/jquery.js", "jquery~", function() {
- // wd.display.qrcode(output, wdurl, width, height, render);
- // });
- // } else {
- // if (!$().qrcode)
- // loadScript("/wd/js/qrcode/jquery.qrcode.js", "qrcode1", function() {
- // loadScript("/wd/js/qrcode/qrcode.js", "qrcode2", function() {
- // wd.display.qrcode(output, wdurl, width, height, render);
- // });
- // });
- // else {
- var option = {
- render: render || "table",
- text: wdurl.toString(),
- width: width || "200",
- height: height || "200"
- };
- $(output).find(".qrcode").remove();
- $(output).append("<div class='qrcode'></div>");
- $(output).find(".qrcode").qrcode(option);
- // }
- // }
- };
- /**
- * 改变dom元素的背景图片
- * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg)
- *
- * @param domId
- * 需要改变背景图片的dom元素id
- */
- wd.display.changeBackgroundImage = function (domId) {
- var domElement = document.getElementById(domId);
- var cssStr = getClass(domElement, "backgroundImage");
- cssStr = cssStr.substring(4, cssStr.length - 1);
- cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, "");
- var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?"));
- if (cssStr.lastIndexOf("?") != -1) {
- imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置
- var changeImgStartIndex = cssStr.lastIndexOf("=") + 1;
- var changeImg = cssStr.substring(parseInt(changeImgStartIndex),
- parseInt(cssStr.length));
- var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?"));
- var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1);
- changeImg = imgPath + changeImg;
- changeImg = changeImg.replace(/\"/g, "");
- var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL
- domElement.style.backgroundImage = imgUrl;
- }
- function getClass(obj, attr) {
- if (obj.currentStyle) {
- if (attr == "backgroundPosition") {
- return obj.currentStyle.backgroundPositionX + " " +
- obj.currentStyle.backgroundPositionY;
- } else {
- return obj.currentStyle[attr];
- }
- } else {
- return document.defaultView.getComputedStyle(obj, null)[attr];
- }
- }
- }
- /**
- * 改变dom元素的背景图片
- * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg)
- *
- * @param domId
- * 需要改变背景图片的dom元素id
- */
- wd.display.changeBackgroundImage = function (domId) {
- var domElement = document.getElementById(domId);
- var cssStr = getClass(domElement, "backgroundImage");
- cssStr = cssStr.substring(4, cssStr.length - 1);
- cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, "");
- var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?"));
- if (cssStr.lastIndexOf("?") != -1) {
- imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置
- var changeImgStartIndex = cssStr.lastIndexOf("=") + 1;
- var changeImg = cssStr.substring(parseInt(changeImgStartIndex),
- parseInt(cssStr.length));
- var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?"));
- var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1);
- changeImg = imgPath + changeImg;
- changeImg = changeImg.replace(/\"/g, "");
- var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL
- domElement.style.backgroundImage = imgUrl;
- }
- function getClass(obj, attr) {
- if (obj.currentStyle) {
- if (attr == "backgroundPosition") {
- return obj.currentStyle.backgroundPositionX + " " +
- obj.currentStyle.backgroundPositionY;
- } else {
- return obj.currentStyle[attr];
- }
- } else {
- return document.defaultView.getComputedStyle(obj, null)[attr];
- }
- }
- }
- // table列表自适应宽度
- // ;(function($){
- //但是每个部件都要加载一次
- if ((typeof $) + "" == "undefined") {
- loadScript("/wd/js/jquery.js", "Jquery", function () {
- setTimeout(tabFoo, 200);
- });
- }
- // 这个延迟执行在于加载时比dom元素先加载 而且该js文件在页面被加载多次消耗性能望后来者去解决这些问题
- function tabFoo() {
- var oTh = $('table.list th'),
- oTr = $('table.list tr'),
- arr_oth = Array.prototype.slice.apply(oTh),
- font_size = parseInt($(arr_oth[0]).css('fontSize')),
- style_h = $('style'),
- str_sheet = " white-space: nowrap;overflow: hidden;text-overflow: ellipsis;padding-left:10px;";
- if (oTh.length <= 5) {
- if (style_h.length) {
- var first_style = style_h[0],
- sheet = first_style.sheet ?
- first_style.sheet :
- first_style.styleSheet;
- if (sheet.insertRule) {
- sheet.insertRule('table.list td,table.list th{' + str_sheet + '}',
- 1);
- } else {
- sheet.addRule('table.list td,table.list th', str_sheet, 0)
- }
- } else {
- $('head').append('<style type="text/css">table.list td,table.list th{' +
- str_sheet + '}</style>')
- }
- for (var i = 0; i < arr_oth.length - 1; i++) {
- // console.log($(arr_oth[i]).text().length, '222');
- var thW = $(arr_oth[i]).text().length;
- thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符
- if (i == 0) {
- $(arr_oth[i]).css({
- 'min-width': (thW + 10) * font_size + 'px', // max-width and
- // min-width
- // 根据th字符数上下浮动一个
- 'max-width': (thW + 12) * font_size + 'px'
- });
- // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
- $('table.list tr td:nth-child(' + (i + 1) + ')').css({
- 'min-width': (thW + 10) * font_size + 'px',
- 'max-width': (thW + 12) * font_size + 'px'
- });
- } else {
- $(arr_oth[i]).css({
- 'min-width': (thW + 6) * font_size + 'px', // max-width and
- // min-width
- // 根据th字符数上下浮动一个
- 'max-width': (thW + 8) * font_size + 'px'
- });
- // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
- $('table.list tr td:nth-child(' + (i + 1) + ')').css({
- 'min-width': (thW + 6) * font_size + 'px',
- 'max-width': (thW + 8) * font_size + 'px'
- });
- }
- }
- $('table.list tr td:nth-child(' + arr_oth.length + ')').css({
- "white-space": "inherit",
- "overflow": "inherit",
- "text-overflow": "inherit"
- })
- $('.img1').parents('td').css('cssText', 'width:90px !important');
- return;
- }
- if (style_h.length) {
- var first_style = style_h[0],
- sheet = first_style.sheet ?
- first_style.sheet :
- first_style.styleSheet;
- if (sheet.insertRule) {
- sheet.insertRule('table.list td,table.list th{' + str_sheet + '}',
- 1);
- } else {
- sheet.addRule('table.list td,table.list th', str_sheet, 0)
- }
- } else {
- $('head').append('<style type="text/css">table.list td,table.list th{' +
- str_sheet + '}</style>')
- }
- // console.log(arr_oth.length)
- for (var i = 0; i < arr_oth.length - 1; i++) {
- var thW = $(arr_oth[i]).text().length;
- thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符
- $(arr_oth[i]).css({
- 'min-width': (thW - 1) * font_size + 'px', // max-width and
- // min-width
- // 根据th字符数上下浮动一个
- 'max-width': (thW + 1) * font_size + 'px'
- });
- // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
- $('table.list tr td:nth-child(' + (i + 1) + ')').css({
- 'min-width': (thW - 1) * font_size + 'px',
- 'max-width': (thW + 1) * font_size + 'px'
- });
- }
- $('table.list tr td:nth-child(1)').css({
- 'min-width': (thW + 1) * font_size + 'px',
- 'max-width': (thW + 3) * font_size + 'px'
- });
- $('table.list tr td:nth-child(' + arr_oth.length + ')').css({
- "white-space": "inherit",
- "overflow": "inherit",
- "text-overflow": "inherit"
- })
- $('.img1').parents('td').css('cssText', 'width:90px !important');
- // console.log($('.img1').parents('td').css('width'));
- }
- function loadScript(src, id, callback) {
- if (!document.getElementById(id)) {
- var head = document.getElementsByTagName('head')[0];
- var script = document.createElement('script');
- script.id = id;
- script.type = 'text/javascript';
- script.onreadystatechange = function () {
- if (this.readyState == 'complete') {
- callback();
- }
- }
- script.onload = function () {
- callback();
- }
- script.src = src;
- head.appendChild(script);
- } else {
- callback()
- };
- }
- // })($);
- //下拉改变irame
- wd.display.initWdSelectFrame = function () {
- (function () {
- // 查找所有的option
- var optionAll = document.querySelectorAll("option[wdSelectClick]")
- // 遍历option
- for (var i = 0; i < optionAll.length; i++) {
- var options = optionAll[i];
- // 找出匹配的option
- if (typeof options.getAttribute("wdSelectClick") != "undefined") {
- // 为其父元素绑定一个id
- options.parentNode.setAttribute("id", "wdSelect");
- // 为其父元素绑定一个事件
- options.parentNode.onchange = function () {
- iframeSrc();
- };
- }
- }
- // 下拉默认值
- function iframeSrc() {
- var mySelect = document.getElementById("wdSelect");
- var myOption = mySelect.options[mySelect.selectedIndex].getAttribute("wdSelectClick");
- document.getElementById("wdIframe").setAttribute("src", myOption);
- }
- if (optionAll.length > 0)
- iframeSrc();
- })()
- }
- wd.display.home = function () {
- //显示个人首页
- // if (document.getElementById("mbwzbj")) {
- // document.getElementById("mbwzbj").innerHTML = "个人首页";
- // } else {
- // var div = top.window.document.querySelector("div[name='mbwz']");
- // if (!div)
- try {
- // wd.topWindow.window.document.querySelector("span[id='mbwzbj']").innerHTML = "个人首页";
- wd.display.setHomeIconName("个人首页");
- } catch (e) {
- console.log(e);
- }
- // }
- var iframe = wd.topWindow.window.document.querySelector("iframe[oriSrc]");
- // console.log(iframe);
- iframe.src = iframe.getAttribute("oriSrc");
- //处理菜单项
- /*
- var menu = new dhtmlXMenuObject("menuObj440141088","dhx_black");
- var casState = new Object({
- ctrl: false,
- alt: false,
- shift: false
- });
- menu._clearAndHide();
- if(document.getElementById("mbwzbj")!=null){ //该文字部件可能不存在
- menu.dqlm=menu.itemPull[menu.idPrefix + id]["title"]; //改变当前栏目
- //document.getElementById("mbwzbj").innerHTML=this.itemPull[this.idPrefix + id]["title"]; //系统菜单下项目
- }
- if (menu._isContextMenuVisible() && menu.contextAutoHide) menu._hideContextMenu();
- menu.callEvent("onClick", ["shortcutMenu", false, casState]);
- */
- //
- // var bjsy = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsy');
- // if (bjsy != null && (bjsy.style.display == '' || bjsy.style.display == 'none'))
- // bjsy.style.display = 'inline';
- //
- // var bjsymb = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsymb');
- // if (bjsymb != null && (bjsymb.style.display == '' || bjsymb.style.display == 'none'))
- // bjsymb.style.display = 'inline';
- if (wd.topWindow.userEditButton_official) {
- wd.topWindow.userEditButton_official.style.display = "inline"
- }
- if (wd.topWindow.userEditButton_personal) {
- wd.topWindow.userEditButton_personal.style.display = "inline"
- }
- //自动调整win2的iframe大小
- if (wd.topWindow.wd.base.refreshApplyIframeHeight) {
- wd.topWindow.wd.base.refreshApplyIframeHeight();
- }
- if (wd.topWindow.wdHelpIcon)
- wd.topWindow.wdHelpIcon.style.display = "none";
- }
- /**
- 异步提交,试用 06-06 by david
- config: {
- param: {},
- async: boolean,
- contentType: string, 默认为application/x-www-form-urlencoded
- dataType: string 默认为json
- }
- callback: success回调
- error: error回调
- **/
- wd.display.ajaxSubmit = function (url, config, callback, error) {
- var xhr = getXmlHttpRequest();
- var callback = undefined == callback ? function () { }
- :
- callback;
- var error = undefined == error ? function (err) {
- console.log(err);
- }
- :
- error;
- var async;
- var method;
- var contentType;
- var dataType; //xmlhttprequest设置datatype
- if (undefined == config.async || config.async == true)
- async = true;
- else if (config.async == 'false')
- async = false;
- method = config.method;
- if (method.toLocaleLowerCase() == 'get') {
- url += '&'; //一般都带token参数
- url += params(config.param);
- }
- if (undefined == config.contentType)
- contentType = 'application/x-www-form-urlencoded';
- else
- contentType = config.contentType;
- if (undefined == config.dataType)
- dataType = 'json';
- else
- dataType = config.dataType;
- xhr.responseType = dataType;
- xhr.open(method, url, async);
- xhr.setRequestHeader("Content-Type", contentType);
- xhr.onreadystatechange = function () {
- switch (xhr.readyState) {
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- if (xhr.status == 200) {
- /* var result = xhr.response;
- if(window.JSON){
- result = JSON.parse(result);
- }else{
- result = eval("(" + result + ")");
- }
- callback(result); */
- callback(xhr.response);
- } else {
- error(xhr.response);
- }
- break;
- }
- };
- if (method.toLocaleLowerCase() == 'get')
- xhr.send();
- else
- xhr.send(params(config.param));
- function params(data) {
- var arr = [];
- for (var i in data) {
- arr.push(encodeURIComponent(i) + "=" + encodeURIComponent(data[i]));
- }
- return arr.join("&");
- }
- function getXmlHttpRequest() {
- var xmlHttpRequest = null;
- if ((typeof XMLHttpRequest) != 'undefined') {
- xmlHttpRequest = new XMLHttpRequest();
- } else {
- xmlHttpRequest = new ActiveXObject('Microsoft.XMLHttp');
- }
- return xmlHttpRequest;
- }
- }
- //表格批示使用,url带有单元格序号‘bgbj_xh’>0时全屏
- wd.display.JumpTest = function (params) {
- function FindParam(url, name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = url.substr(1).match(reg);
- if (r != null)
- return unescape(r[2]);
- return null;
- }
- /**
- function openScreenLayer(src) {
- var topbody = $("body", wd.topWindow.document);
- var wdfs = topbody.find("#wdfullscreen"); //弹层的div
- if(wdfs.length < 1) {
- topbody.append("<div id='wdfullscreen' style='display:none;top:-10;'></div>");
- wdfs = topbody.find("#wdfullscreen");
- }
- wdfs.html("");
- wdfs.append("<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/ueFull.css'>").show()
- wdfs.append('<div class="uefullscreen"><input type="button" style="z-index: 999999999;position: absolute;top:10px;right:10px" class="btn-list fulscrbtn fullButton" value="" state="1" /><div class="fullscreen fullscreenSrc" style="overflow:auto;-webkit-overflow-scrolling:touch!important;" ></div></div>');
- wdfs.find(".fullscreen").html('<iframe id="myIframe" src="' + src + '" style="width:100%;height:100%;position: absolute;top: 0;left: 0;right: 0;bottom: 0;margin: auto;border: 1px solid #e4e4e4;overflow:auto;-webkit-overflow-scrolling:touch!important;"></iframe>');
- wdfs.find(".fulscrbtn").click(function(e) {
- wdfs.remove();
- });
- }
- **/
- /****/
- function openScreenLayer(src) {
- var topbody = $("body", wd.topWindow.document);
- var wdfs = topbody.find("#wdfullscreen"); //弹层的div
- if (wdfs.length < 1) {
- topbody.append("<div id='wdfullscreen' style='display:none;width:100%;height:100%;margin:0;'></div>");
- wdfs = topbody.find("#wdfullscreen");
- }
- wdfs.html("");
- wdfs.append("<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/ueFull.css'>").show()
- wdfs.append(
- '<div class="uefullscreen" style="height:100%;margin:0;"><input type="button" style="z-index: 999999999;position: absolute;top:10px;right:14px" class="btn-list fulscrbtn fullButton" value="" state="1" /><div class="fullscreen fullscreenSrc" style="width:100%;height:1100px;-webkit-overflow-scrolling:touch; overflow:scroll;"></div></div>');
- wdfs.find(".fullscreen").html('<iframe id="myIframe" src="' + src + '" style="width:100%;height:96%;"></iframe>');
- wdfs.find(".fulscrbtn").click(function (e) {
- wdfs.remove();
- });
- }
- var a = parseInt(FindParam(params.url, "bgbj_xh"))
- if (a && a > 0) {
- // openScreenLayer(params.url);
- params.show = "wdFullScreen";
- params.width = wd.topWindow.document.body.offsetWidth;
- wd.display.showComponent(params);
- } else {
- wd.display.showComponent(params);
- }
- }
- //使参数指定的滚动图片全屏
- wd.display.fullgdtpScreen = function (element, bjid) {
- // console.log(element);
- // wd.display.CmsZNRFull(element);
- $("#ydfull" + bjid).css('display', '-webkit-flex');
- var index_img = 0;
- var lastindex_img = 0;
- var full_src;
- full_src = $(element).children("img")[0].src;
- // console.log(full_src);
- $("#imgfull" + bjid).attr("src", full_src);
- var items = $("#list" + bjid).find(".ydimg_item");
- if (items != undefined && items.length != 0) {
- lastindex_img = items.length - 1;
- for (var ii = 0; ii < items.length; ii++) {
- if ($(element).children("img")[0] == $(items[ii]).children("img")[0]) {
- index_img = ii;
- }
- }
- }
- var marioVideo = $("#ydfull" + bjid)[0];
- // wd.display.CmsZNRFull(element);
- var fullscreenchange = function () {
- if (document.webkitFullscreenElement != null) {
- // element.style.width = "100%";
- // element.style.height = "100%";
- // element.style.overflowY = 'hidden';
- //console.log("进入全屏函数");
- // $('#mainDiv').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="dhtmlx_wins_btns" style="position:fixed;right:0px;"><div class="dhtmlx_wins_btns_button dhtmlx_button_close_default" onclick="wd.display.exitFullScreen()" title="Close"></div></div></div></div>');
- } else {
- //console.log("退出全屏函数");
- $("#ydfull" + bjid).hide();
- //添加监听器,监听用户进入全屏和退出全屏操作
- marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
- }
- }
- // 判断各种浏览器,找到正确的方法
- var elem = marioVideo;
- elem.onmousemove = function (e) {
- // console.log(e.offsetY);
- e = e || window.event;
- var newY = e.screenY;
- //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
- if (newY < (window.screen.height / 3) && index_img != 0) {
- elem.style.cursor = "url(\"./wd/image/top.cur\"),default"; //上1/3区域
- } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) {
- elem.style.cursor = "url(\"./wd/image/bottom.cur\"),default"; //下1/3区域
- } else {
- elem.style.cursor = "default"; //中1/3区域
- }
- }
- elem.onclick = function (e) {
- e = e || window.event;
- var newY = e.screenY;
- //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
- if (newY < (window.screen.height / 3) && index_img != 0) { //上一张
- index_img = index_img - 1;
- if (items != undefined && items.length != 0) {
- for (var ii = 0; ii < items.length; ii++) {
- $(items[ii]).removeClass('selected');
- }
- full_src = $(items[index_img]).children("img")[0].src;
- $("#imgfull" + bjid).attr("src", full_src);
- $(items[index_img]).addClass('selected');
- $("#img" + bjid).attr("src", full_src);
- $("#bt" + bjid).html($(items[index_img]).children("img").eq(0).attr("alt"));
- }
- } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) { //下一张
- index_img = index_img + 1;
- if (items != undefined && items.length != 0) {
- for (var ii = 0; ii < items.length; ii++) {
- $(items[ii]).removeClass('selected');
- }
- full_src = $(items[index_img]).children("img")[0].src;
- $("#imgfull" + bjid).attr("src", full_src);
- $(items[index_img]).addClass('selected');
- $("#img" + bjid).attr("src", full_src);
- $("#bt" + bjid).html($(items[index_img]).children("img").eq(0).attr("alt"));
- }
- } else { //关闭
- wd.display.exitFullScreen();
- }
- }
- marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("fullscreenchange", fullscreenchange);
- marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
- if (marioVideo.requestFullscreen) {
- marioVideo.requestFullscreen(elem);
- } else if (marioVideo.msRequestFullscreen) {
- marioVideo.msRequestFullscreen(elem);
- } else if (marioVideo.mozRequestFullScreen) {
- marioVideo.mozRequestFullScreen(elem);
- } else if (marioVideo.webkitRequestFullScreen) {
- marioVideo.webkitRequestFullScreen(elem);
- }
- }
- wd.display.fullsltScreen = function (bjid) {
- $("#sltfull" + bjid).css('display', '-webkit-flex');
- var index_img = 0;
- var lastindex_img = 0;
- var full_src;
- var items_selected = $("#list" + bjid).find(".slximg_box.selected");
- if (items_selected != undefined && items_selected.length != 0) {
- for (var ii = 0; ii < items_selected.length; ii++) {
- full_src = $(items_selected[ii]).find("img")[0].src;
- // console.log(full_src);
- $("#imgfull" + bjid).attr("src", full_src);
- }
- }
- var items = $("#list" + bjid).find(".slximg_item");
- if (items != undefined && items.length != 0) {
- lastindex_img = items.length - 1;
- for (var ii = 0; ii < items.length; ii++) {
- if ($(items_selected[0]).find("img")[0] == $(items[ii]).find("img")[0]) {
- index_img = ii;
- }
- }
- }
- var marioVideo = $("#sltfull" + bjid)[0];
- // wd.display.CmsZNRFull(element);
- var fullscreenchange = function () {
- if (document.webkitFullscreenElement != null) {
- // element.style.width = "100%";
- // element.style.height = "100%";
- // element.style.overflowY = 'hidden';
- //console.log("进入全屏函数");
- // $('#mainDiv').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="dhtmlx_wins_btns" style="position:fixed;right:0px;"><div class="dhtmlx_wins_btns_button dhtmlx_button_close_default" onclick="wd.display.exitFullScreen()" title="Close"></div></div></div></div>');
- } else {
- //console.log("退出全屏函数");
- $("#sltfull" + bjid).hide();
- //添加监听器,监听用户进入全屏和退出全屏操作
- marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
- }
- }
- // 判断各种浏览器,找到正确的方法
- var elem = marioVideo;
- elem.onmousemove = function (e) {
- // console.log(e.offsetY);
- e = e || window.event;
- var newY = e.screenY;
- //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
- if (newY < (window.screen.height / 3) && index_img != 0) {
- elem.style.cursor = "url(" + wd.common.loadFile("theme/meow/image/top.cur") + "),default"; //上1/3区域
- } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) {
- elem.style.cursor = "url(" + wd.common.loadFile("theme/meow/image/bottom.cur") + "),default"; //下1/3区域
- } else {
- elem.style.cursor = "default"; //中1/3区域
- }
- }
- elem.onclick = function (e) {
- e = e || window.event;
- var newY = e.screenY;
- //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
- if (newY < (window.screen.height / 3) && index_img != 0) { //上一张
- index_img = index_img - 1;
- if (items != undefined && items.length != 0) {
- for (var ii = 0; ii < items.length; ii++) {
- $(items[ii]).removeClass('selected');
- }
- full_src = $(items[index_img]).find("img")[0].src;
- $("#imgfull" + bjid).attr("src", full_src);
- $(items[index_img]).addClass('selected');
- $("#img" + bjid).attr("src", full_src);
- $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt"));
- }
- } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) { //下一张
- index_img = index_img + 1;
- if (items != undefined && items.length != 0) {
- for (var ii = 0; ii < items.length; ii++) {
- $(items[ii]).removeClass('selected');
- }
- full_src = $(items[index_img]).find("img")[0].src;
- $("#imgfull" + bjid).attr("src", full_src);
- $(items[index_img]).addClass('selected');
- $("#img" + bjid).attr("src", full_src);
- $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt"));
- }
- } else { //关闭
- wd.display.exitFullScreen();
- }
- }
- marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("fullscreenchange", fullscreenchange);
- marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
- if (marioVideo.requestFullscreen) {
- marioVideo.requestFullscreen(elem);
- } else if (marioVideo.msRequestFullscreen) {
- marioVideo.msRequestFullscreen(elem);
- } else if (marioVideo.mozRequestFullScreen) {
- marioVideo.mozRequestFullScreen(elem);
- } else if (marioVideo.webkitRequestFullScreen) {
- marioVideo.webkitRequestFullScreen(elem);
- }
- }
- //使参数指定的DOM元素全屏,如果不传参数则默认带个页面全屏
- wd.display.fullScreen = function (element) {
- element.sdasdasds = playlist;
- // 判断各种浏览器,找到正确的方法
- var requestMethod = element.requestFullScreen || //W3C
- element.webkitRequestFullScreen || //Chrome等
- element.mozRequestFullScreen || //FireFox
- element.msRequestFullScreen; //IE11
- if (requestMethod) {
- requestMethod.call(element);
- } else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
- var wscript = new ActiveXObject("WScript.Shell");
- if (wscript !== null) {
- alert("f11");
- wscript.SendKeys("{F11}");
- }
- }
- }
- //从全屏状态切换为普通状态
- wd.display.exitFullScreen = function () {
- // 判断各种浏览器,找到正确的方法
- var exitMethod = document.exitFullscreen || //W3C
- document.mozCancelFullScreen || //Chrome等
- document.webkitExitFullscreen || //FireFox
- document.webkitExitFullscreen; //IE11
- if (exitMethod) {
- exitMethod.call(document);
- } else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
- var wscript = new ActiveXObject("WScript.Shell");
- if (wscript !== null) {
- wscript.SendKeys("{F11}");
- }
- }
- }
- wd.display.CmsZNRFull = function (element) {
- //目前对图片,视频,pdf,word,flash,全屏下特殊处理
- var IMG_TYPE = "IMG";
- var VIDEO_TYPE = "VIDEO";
- var PDF_TYPE = "PDF";
- var WORD_TYPE = "WORD";
- var FLASH_TYPE = "FLASH";
- var XLS_TYPE = "XLS";
- var PPT_TYPE = "PPT";
- function nrjsblmType(nrjslbm) {
- var group = {
- "300": IMG_TYPE,
- "310": IMG_TYPE,
- "320": IMG_TYPE,
- "330": IMG_TYPE,
- "340": IMG_TYPE,
- "500": VIDEO_TYPE,
- "510": VIDEO_TYPE,
- "520": VIDEO_TYPE,
- "1010": PDF_TYPE,
- "810": PPT_TYPE,
- "910": WORD_TYPE,
- "1110": XLS_TYPE,
- "710": FLASH_TYPE
- }
- return group[nrjslbm];
- }
- var width; //定义宽度与高度
- var height;
- var dataList = [];
- //查找出当前所有的所有播放器
- var playlist = element.querySelectorAll("[data-init]");
- console.log("555:" + playlist.length);
- // var nrid = null;
- for (var i = 0; i < playlist.length; i++) {
- var playDiv = playlist[i];
- var nrJson = JSON.parse(playDiv.getAttribute("data-init"));
- // console.log(nrJson);
- // nrid = nrJson.resDesign.ID;
- var nrjslbm = nrJson.resDesign.nrjslbm;
- var TYPE = nrjsblmType(nrjslbm);
- if (!TYPE)
- continue;
- // console.log("666:" + TYPE);
- var exitFunction = null; //退出全屏回调方法
- var data = {
- "type": TYPE,
- "nrjslbm": nrjslbm,
- }
- // console.log(TYPE);
- if (TYPE == IMG_TYPE) {
- var handle = playDiv.querySelector(".img");
- width = handle.naturalWidth;
- height = handle.naturalHeight;
- //退出全屏用到的数据缓存
- data.handle = handle;
- data.width = handle.style.width;
- data.height = handle.style.height;
- data.exitFunction = function (data) {
- // console.log(data)
- data.handle.style.width = data.width;
- data.handle.style.height = data.height;
- }
- var zzz = wd.display.CmscalZoomSize(width, height);
- handle.style.width = zzz.width + "px";
- handle.style.height = zzz.height + "px";
- // console.log(handle.style.width)
- // console.log(handle.style.height)
- } else if (TYPE == VIDEO_TYPE) {
- var handle = playDiv.querySelector(".video");
- var handleparent = playDiv.querySelector(".videoparent");
- width = handle.videoWidth;
- height = handle.videoHeight;
- //退出全屏还原
- data.handleparent = handleparent;
- data.width = handleparent.style.width;
- data.height = handleparent.style.height;
- data.exitFunction = function (data) {
- // console.log(data)
- data.handleparent.style.width = data.width;
- data.handleparent.style.height = data.height;
- }
- var zzz = wd.display.CmscalZoomSize(width, height);
- handleparent.style.width = zzz.width + "px";
- handleparent.style.height = zzz.height + "px";
- } else if (TYPE == PDF_TYPE || TYPE == WORD_TYPE || TYPE == XLS_TYPE) {
- var handle = playDiv.querySelector(".show");
- var son1 = handle.querySelector("#pf1");
- if (son1 == null)
- return;
- width = son1.clientWidth;
- height = son1.clientHeight;
- var zzz = wd.display.CmscalZoomSize(width, height);
- data.handle = handle;
- data.overflow = handle.style.overflow;
- data.zoom = handle.style.zoom;
- //特殊处理excel背景颜色变黑色
- if(TYPE == XLS_TYPE){
- playDiv.style.background = "white";
- }
- data.exitFunction = function (data) {
- if (zzz.zoom != null) {
- element.scrollTop = element.scrollTop / zzz.zoom;
- }
- // console.log(data)
- data.handle.style.zoom = data.zoom;
- data.handle.style.overflow = data.overflow;
- if(data.type == XLS_TYPE){
- data.handle.style.background = "";
- }
- }
- handle.style.zoom = zzz.zoom;
- element.scrollTop = element.scrollTop * zzz.zoom;
- } else if (TYPE == FLASH_TYPE) {
- var handle = playDiv.querySelector("#embed");
- //退出全屏方法
- data.handle = handle;
- data.width = handle.style.width;
- data.height = handle.style.height;
- data.exitFunction = function (data) {
- // console.log(data)
- data.handle.style.width = $("#mainDiv").innerWidth();
- data.handle.style.height = $("#mainDiv").innerHeight();
- }
- var zzz = wd.display.CmscalZoomSize();
- handle.style.width = zzz.maxWidth + 'px';
- handle.style.height = zzz.maxHeight + 'px';
- }
- dataList.push(data);
- playlist[i].dataList = dataList;
- }
- }
- /**
- *
- * 计算放大后width,height,zoom
- * @param {Object} w
- * @param {Object} h
- */
- wd.display.CmscalZoomSize = function (w, h) {
- var maxWidth = screen.availWidth - 1;
- var maxHeight = screen.availHeight - 1; //获取页面的高度与宽度
- var xswidth = w;
- var xsheight = h;
- if (w && h) {
- //显示的高度与宽度
- var ratio1 = w / maxWidth;
- var ratio2 = h / maxHeight;
- //根据长度与宽度获取缩放比例
- if (ratio1 > 1 || ratio2 > 1) {
- if (ratio1 > ratio2) { //选取较大的缩放比例
- xswidth = w / ratio1;
- xsheight = h / ratio1;
- } else {
- xswidth = w / ratio2;
- xsheight = h / ratio2;
- }
- }
- }
- if (w) {
- var zoom = maxWidth / w;
- if (zoom >= 2) { //确定zoom 用于word与pdf放缩
- zoom = 2;
- }
- }
- return {
- width: xswidth,
- height: xsheight,
- zoom: zoom,
- maxWidth: maxWidth,
- maxHeight: maxHeight
- }
- }
- wd.display.CmsFullDiv = function (element, onFullscreen, onExitfullscreen, win) {
- win = win || element.ownerDocument.defaultView;
- // var video,photo,pdf,word,flash;
- // console.log(element);
- var marioVideo = element;
- var fullscreenchange = function () {
- if (win.document.webkitFullscreenElement != null) {
- //$(element).addClass("scrollbar");
- // $(element).css("padding","25px");
- // $(element).css("box-sizing","border-box");
- // element.style.overflowY = "auto";
- // element.style.overflowX = "hidden";
- // element.style.width = "100%";
- // element.style.height = "100%";
- // console.log("进入全屏函数");
- // element.setAttribute("isCmsFullScreen", 'true');
- win.$(element).append(
- '<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="icon-restore" style="position: fixed;right: 10px;top: 10px;height:22px;width:22px;" onclick="wd.display.exitFullScreen()" ></div></div></div>');
- onFullscreen && onFullscreen()
- } else {
- // console.log("退出全屏函数");
- win.$(element).find('#pageClose').remove();
- //$(element).removeClass("scrollbar");
- // $(element).css("padding","0px");
- // $(element).css("box-sizing","border-box");
- // element.style.height = 'auto';
- // element.style.width = 'auto';
- // element.setAttribute("isCmsFullScreen", 'false');
- // element.style.overflowY = 'auto';
- // element.style.height = '100%';
- // element.style.width = '750px';
- //添加监听器,监听用户进入全屏和退出全屏操作
- marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
- onExitfullscreen && onExitfullscreen()
- }
- }
- var elem = marioVideo;
- marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("fullscreenchange", fullscreenchange);
- marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
- if (marioVideo.requestFullscreen) {
- marioVideo.requestFullscreen(elem);
- } else if (marioVideo.msRequestFullscreen) {
- marioVideo.msRequestFullscreen(elem);
- } else if (marioVideo.mozRequestFullScreen) {
- marioVideo.mozRequestFullScreen(elem);
- } else if (marioVideo.webkitRequestFullScreen) {
- marioVideo.webkitRequestFullScreen(elem);
- }
- }
- wd.display.CmsFullScreen = function (element, onFullscreen, onExitfullscreen, win) {
- win = win || element.ownerDocument.defaultView;
- // var video,photo,pdf,word,flash;
- // console.log(element);
- var marioVideo = element;
- try {
- win.wd.display.CmsZNRFull(element);
- } catch (e) { }
- var fullscreenchange = function () {
- if (win.document.webkitFullscreenElement != null) {
- //$(element).addClass("scrollbar");
- // $(element).css("padding","25px");
- // $(element).css("box-sizing","border-box");
- element.style.overflowY = "auto";
- element.style.overflowX = "hidden";
- element.style.width = "100%";
- element.style.height = "100%";
- // console.log("进入全屏函数");
- element.setAttribute("isCmsFullScreen", 'true');
- win.$(element).append(
- '<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="largeIcon-restore" style="position: fixed;right: 10px;top: 10px;" onclick="wd.display.exitFullScreen()" ></div></div></div>');
- onFullscreen && onFullscreen()
- } else {
- // console.log("退出全屏函数");
- win.$(element).find('#pageClose').remove();
- //$(element).removeClass("scrollbar");
- // $(element).css("padding","0px");
- // $(element).css("box-sizing","border-box");
- // element.style.height = 'auto';
- // element.style.width = 'auto';
- element.setAttribute("isCmsFullScreen", 'false');
- // element.style.overflowY = 'auto';
- element.style.height = '100%';
- element.style.width = '750px';
- //回调退出全屏方法
- var playlist = element.querySelectorAll("[data-init]");
- for (var i = 0; i < playlist.length; i++) {
- dataList = playlist[i].dataList;
- for (var j = 0; dataList != null && j < dataList.length; j++) {
- var data = dataList[j];
- if (data.exitFunction) {
- data.exitFunction.call(this, data);
- }
- }
- delete playlist[i].dataList;
- }
- //添加监听器,监听用户进入全屏和退出全屏操作
- marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
- onExitfullscreen && onExitfullscreen()
- }
- }
- var elem = marioVideo;
- marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("fullscreenchange", fullscreenchange);
- marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
- marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
- if (marioVideo.requestFullscreen) {
- marioVideo.requestFullscreen(elem);
- } else if (marioVideo.msRequestFullscreen) {
- marioVideo.msRequestFullscreen(elem);
- } else if (marioVideo.mozRequestFullScreen) {
- marioVideo.mozRequestFullScreen(elem);
- } else if (marioVideo.webkitRequestFullScreen) {
- marioVideo.webkitRequestFullScreen(elem);
- }
- }
- //附件滑动和上下项
- wd.display.CmsNrscroll = function (element, currSubNrid) {
- var ismousedown = false;
- var oldY,
- scollY;
- var nrid = currSubNrid;
- element.onmousedown = function (e) {
- oldscrollTop = element.scrollTop;
- oldY = e.screenY;
- scollY = element.scrollTop;
- ismousedown = true;
- }
- element.onmouseup = function (e) {
- ismousedown = false;
- }
- element.onmousemove = function (e) {
- // console.log(e.offsetY);
- e = e || window.event;
- var newY = e.screenY;
- //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
- if (ismousedown) {
- //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight)
- if (oldY - newY >= 150 && element.scrollTop + element.clientHeight + 1 >= element.scrollHeight && oldscrollTop +
- element.clientHeight + 1 >= element.scrollHeight) {
- ismousedown = false;
- // console.log("鼠标向上移动");
- nrid = nextitem(nrid);
- // console.log(element.getAttribute("isCmsFullScreen"));
- } else if (newY - oldY >= 150 && element.scrollTop <= 0 && oldscrollTop == 0) {
- ismousedown = false;
- // console.log("鼠标向下移动");
- nrid = lastitem(nrid);
- // console.log(element.getAttribute("isCmsFullScreen"));
- } else {
- element.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度
- }
- }
- }
- function nextitem(nrid) {
- var items = $(".dragList").find(".item");
- var i = 0;
- var result = nrid;
- items.each(function () {
- if (nrid == $(items[i]).find(".nrid").text()) {
- if (i < items.length - 1) {
- // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929
- // $(items[i + 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929
- selectItem($(items[i + 1])[0]);
- loadPlayer($(items[i + 1]).find(".nrid").text(), $(items[i + 1]).find(".nrjslbm").text());
- result = $(items[i + 1]).find(".nrid").text();
- }
- return false; //跳出循环
- } else {
- i++;
- }
- });
- return result;
- }
- function lastitem(nrid) {
- var items = $(".dragList").find(".item");
- var i = 0;
- var result = nrid;
- items.each(function () {
- if (nrid == $(items[i]).find(".nrid").text()) {
- if (i > 0) {
- // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929
- // $(items[i - 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929
- selectItem($(items[i - 1])[0]);
- loadPlayer($(items[i - 1]).find(".nrid").text(), $(items[i - 1]).find(".nrjslbm").text());
- //$(items[i - 1])[0].scrollTop( $(items[i - 1])[0].scrollHeight );
- result = $(items[i - 1]).find(".nrid").text();
- }
- return false; //跳出循环
- } else {
- i++;
- }
- });
- return result;
- }
- }
- /**
- * 退出登录
- */
- wd.display.exit = function (param) {
- // console.log("exit")
- wd.display.showLoad();
- var beaconLogin = wd.display.beaconLogin("loginOut") || wd.display.getBeaconWhetherToOpen();
- param=param||{};
- var homepage=(1==param.homepage)?("&homepage="+param.homepage):"";
- var urlparam=""+homepage;
- /* 改。Lin
- $.post("/service?wdApplication=wd&wdService=ss.exitByA&wdtest=false", {}, function (result) {
- */
- /* 再改,规范命名。Lin
- * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
- * &wdService= 改为 ssServ
- $.post("/service?wdApplication=wd&wdService=exit", {}, function (result) {
- */ $.post("/service?ssServ=exit", {}, function (result) {
- var newurl=result.path+(result.path.indexOf("?")==-1?"?":"")+urlparam;
- if (beaconLogin) {
- setTimeout(function () {
- wd.topWindow.location.href =newurl ;
- }, 1000);
- } else {
- wd.topWindow.location.href = newurl;
- }
- }, "json")
- }
- /**
- * 执行当前弹窗的wdfitheight调整事件
- */
- wd.display.initWdFitHeight = function (windowobj) {
- var dialogid = wd.display.getwdDialogId();
- if (!dialogid)
- return;
- //弹窗对象
- var win = wd.topWindow.dhxWins.window(dialogid);
- if (!win)
- return;
- var nextiframe = win.getFrame();
- var count = 0;
- while (nextiframe != null) {
- if (count > 10)
- break; // 最多查找10层iframe,防止死循环
- count++;
- //执行页面所在的初始化iframe事件
- if (nextiframe.contentWindow.window.initWdFitHeightFunction) {
- if (nextiframe.contentWindow.window != windowobj) {
- nextiframe.contentWindow.window.initWdFitHeightFunction();
- }
- }
- // console.log(nextiframe)
- nextiframe = nextiframe.contentWindow.document.querySelector("iframe[src]");
- }
- }
- /**
- *
- */
- wd.display.submitToTopTab = function (submitBtn) {
- if (!submitBtn)
- console.error("请指定submit按钮");
- var myform = submitBtn.form.cloneNode(true);
- myform.style.display = "none";
- submitBtn.form.parentNode.innerHTML = "";
- var win = window,
- topFrame = wd.display.getFrameOfWindow(win);
- while (topFrame.tabObj) { //找到不是tab为止
- win = win.parent;
- topFrame = wd.display.getFrameOfWindow(win);
- }
- topFrame.contentWindow.document.body.appendChild(myform);
- myform.submit();
- // submitBtn.click();
- }
- /**
- * 获取window所在的iframe
- *
- */
- wd.display.getFrameOfWindow = function (win) {
- win = win || window;
- if (win != win.top && win.parent && win.parent.document.querySelectorAll("iframe").length > 0) {
- var pfs = win.parent.document.querySelectorAll("iframe");
- for (var i = 0; i < pfs.length; i++) {
- if (pfs[i].contentWindow == win) {
- return pfs[i];
- }
- }
- console.error("没找到上级window所对应当前window的iframe")
- } else {
- console.warn("当前页面不存在任何iframe底下")
- return null
- }
- }
- /**
- * 刷新当前的tabframe
- */
- wd.display.refreshTabFrame = function (wdTabNo) {
- var frame = wd.display.getFrameOfWindow();
- if (frame) {
- if (frame.tabObj) {
- if (wdTabNo && /[0-9]*/.test(wdTabNo)) {
- // frame.contentWindow.wd.display.wdTabNo=wdTabNo;
- var num = parseInt(wdTabNo);
- frame.tabObj.selectClick(num);
- } else {
- frame.tabObj.selectTab.dom.click();
- }
- } else {
- console.error("当前iframe不是tabFrame");
- }
- }
- }
- wd.display.changeFormAction = function (url, element, width, height, minHeight, maxHeight) {
- var a = $(element).parents("form:first").attr("action", url);
- if (a.length != 1) {
- alert("找不到form元素");
- return false;
- }
- if (a[0].checkOnly) {
- if (!a[0].checkOnly(true)) {
- return
- }
- }
- if (width && height && minHeight && maxHeight) {
- wd.display.resizeComponent(width, height, minHeight, maxHeight);
- }
- return true;
- }
- wd.display.MsgManager = function (timeout, minHeight, minWidth) {
- if (wd.topWindow.popupPanel == null) {
- // 动画小圈圈
- //flashMessageDocument--fmd
- $("body", wd.topWindow.document).append('<div id="fMD" style="position: fixed; display:none; pointer-events:none; z-index: 9999;" class="cursor-loading" /></div>');
- this.element = wd.topWindow.popupPanel = $("<div id=\"flashmsgtipsId\" class=\"flashMsg-div\" style=\"display:none;position:fixed;z-index:999\"><div class='flashMsg-down' style='bottom: -10px;left: 7px'></div></div>");
- $("body", wd.topWindow.document).append(wd.topWindow.popupPanel);
- timeout = timeout || 1300;
- // minHeight = minHeight || "10px";
- // minWidth = minWidth || "70px";
- // this.element[0].className = "flashMsg-div";
- // this.element[0].id = "flashmsgtipsId";
- // $(".flashMsg-div").append("<div class='flashMsg-down' style='bottom: -10px;left: 7px'></div>");
- // this.element.css({
- // display: "none",
- // position: "fixed",
- // // minHeight: minHeight,
- // // minWidth: minWidth,
- // "z-index": "999"
- // });
- this.messages = [];
- var this_ = this;
- setInterval(function () {
- // if (this_.messages.length > 1) {
- // this_.removeMsg(this_.messages.shift());
- // } else if (this_.messages.length == 1) {
- // setTimeout(function () {
- // this_.removeMsg(this_.messages.shift());
- // }, 1700);
- // }
- if (this_.messages.length > 0) {
- var span=this_.messages.shift();
- setTimeout(function () {
- this_.removeMsg(span);
- },span.data("timeout"));
- }
- }, timeout);
- };
- this.removeMsg = function (span) {
- var $span = $(span);
- $span.slideUp("normal", function () {
- $span.trigger("onHide");
- $span.remove();
- });
- this.messages.length == 0 && this.element.fadeOut("fast");
- }
- this.pushMsg = function (msg, options) {
- if (msg == "" || msg == null)
- return;
- var $span = $("<p>");
- $span.text(msg);
- $span.data("timeout",Math.max(300*(msg.length/3),1700));
- $span.bind("onShow", function () {
- options && options.onShow && options.onShow.call(this);
- });
- $span.bind("onHide", function () {
- options && options.onHide && options.onHide.call(this);
- });
- this.messages.push($span);
- this.element.prepend($span).show();
- $span.fadeIn("normal", function () {
- $span.trigger("onShow");
- });
- }
- };
- //开启加载动画
- wd.display.showLoad = function () {
- wd.topWindow.$("#fMD").show();
- }
- //关闭加载动画
- wd.display.closeLoad = function () {
- wd.topWindow.$("#fMD").hide();
- }
- if(!window.flashmsgmousemove){
- window.flashmsgmousemove=1;
- document.addEventListener("mousemove", function () {
- if (wd.topWindow.$("#flashmsgtipsId").is(":visible")) {
- return;
- }
- if (wd.display.isFixation) {
- return;
- }
- // 有弹出窗口且大于 1 时,MSG固定右下角
- if (wd.topWindow.$(".wdMaskDiv").size() > 1) {
- setFixation();
- }
- // 无弹出窗口或弹出窗口等于 1 时,MSG跟随鼠标
- else {
- var xy,
- x,
- y;
- try {
- xy = recursionIframe();
- x = window.event.pageX += xy.left;
- y = window.event.pageY += xy.top;
- } catch (e) {
- //console.log("xy err " + e)
- x = window.event.pageX;
- y = window.event.pageY;
- }
- if (wd.topWindow.$("#flashmsgtipsId").find("p").size() < 1) {
- // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips").removeClass("flashmsgtips-submit");
- wd.topWindow.$("#flashmsgtipsId").css({
- "top": y - 53 + "px",
- "left": x - 7 + "px",
- "bottom": "",
- "right": ""
- })
- }
- wd.topWindow.$("#fMD").css("left", x - 10);
- wd.topWindow.$("#fMD").css("top", y - 4);
- }
- });
- }
- wd.display.showMsgPopup = function (msg, options) {
- if (window.location.href.indexOf("view.jsp") > 0)
- return;
- var msgs = wd.topWindow.wd.display.popupMsgMagager = wd.topWindow.window.wd.display.popupMsgMagager || new wd.topWindow.window
- .wd.display.MsgManager();
- msgs.pushMsg(msg, options);
- if (wd.display.isFixation) {
- setFixation();
- }
- }
- var setFixation = function () {
- // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips-submit").removeClass('flashmsgtips');
- wd.topWindow.$("#flashmsgtipsId").css({
- "bottom": "50px",
- "right": "10px",
- "top": "",
- "left": ""
- })
- }
- var recursionIframe = function (win) {
- try {
- win = win || window;
- function getTop(e) {
- var offset = e.offsetTop;
- if (e.offsetParent != null)
- offset += getTop(e.offsetParent);
- return offset;
- }
- function getLeft(e) {
- var offset = e.offsetLeft;
- if (e.offsetParent != null)
- offset += getLeft(e.offsetParent);
- return offset;
- }
- if (win.parent == top && win.parent == win || win.document == undefined) {
- return {
- "left": 0,
- "top": 0
- };
- }
- var winPar = win.parent;
- var iframeArr = winPar.document.getElementsByTagName('IFRAME');
- var targetIframe;
- var iframeArr1 = win.document.getElementsByTagName('IFRAME');
- for (var i = 0; i < iframeArr1.length; i++) {
- var iframeElem = iframeArr1[i];
- if (iframeElem.contentWindow == win) {
- targetIframe = iframeElem;
- break;
- }
- }
- for (var i = 0; i < iframeArr.length; i++) {
- var iframeElem = iframeArr[i];
- if (iframeElem.contentWindow == win) {
- targetIframe = iframeElem;
- break;
- }
- }
- var xy = {
- left: getLeft(targetIframe),
- top: getTop(targetIframe)
- }
- if (winPar.parent != winPar) {
- var xy2 = recursionIframe(winPar);
- xy.left += xy2.left;
- xy.top += xy2.top;
- }
- return xy
- } catch (e) {
- console.log("Point err " + e)
- }
- }
- wd.display.resizeComponent = function (width, height, minHeight, maxHeight) {
- if (parseInt(width) == "NaN" || parseInt(height) == "NaN")
- return;
- var dialog = wd.display.getwdDialogWindows();
- if (!dialog)
- return
- var changesize = true;
- if (minHeight && !isNaN(minHeight) && maxHeight && !isNaN(maxHeight)) {
- minHeight = parseInt(minHeight);
- maxHeight = parseInt(maxHeight);
- if (minHeight + this.Yi > wd.topWindow.innerHeight) {
- height = minHeight + this.Yi;
- // showNameOrId = 'wdFullScreen';
- // fullScreenLimitHeight = false;
- } else if (maxHeight + this.Yi < wd.topWindow.innerHeight) {
- height = maxHeight + this.Yi;
- } else {
- height = wd.topWindow.innerHeight;
- changesize = true;
- // changesize = false;
- // showNameOrId = 'wdFullScreen';
- }
- }
- wd.display.addDialogLine();
- if (changesize) {
- dialog.setDimension(width, height);
- dialog.keepInViewport(false);
- dialog.center();
- }
- }
- wd.display.reset = function (type, submitBtn, url, width, height, minHeight, maxHeight) {
- var canSubmit = false;
- if (submitBtn.iscommit) {
- canSubmit = true;
- } else if (!submitBtn.form) {
- console.warn("没找到元素所在form");
- } else {
- if (!submitBtn.form.checkOnly) { //没有校验器
- canSubmit = true;
- } else if (submitBtn.form.checkOnly(true)) { //验证通过
- canSubmit = true;
- } else { //表单验证不通过
- canSubmit = false;
- }
- }
- if (canSubmit) {
- wd.display.changeFormAction(url, submitBtn);
- if (type == "dialog") {
- wd.display.resizeComponent(width, height, minHeight, maxHeight);
- wd.display.submitToTopTab(submitBtn);
- return false;
- }
- // submitBtn.iscommit = true;
- // submitBtn.click();
- }
- return canSubmit;
- }
- /**
- * commwrite oneLine=true 限制宽度,结尾添加'...'
- * @param {Object} ele
- */
- wd.display.initOneLine = function (ele) {
- try {
- var parent = ele.parentNode;
- parent.removeChild(ele);
- parent.setAttribute("title", parent.innerHTML);
- parent.style.overflow = "hidden";
- parent.style.textOverflow = "ellipsis";
- parent.style.whiteSpace = "nowrap";
- // 如果无效 table加样式 table-layout: fixed;
- // var poffsetW = parent.offsetWidth;
- // var pscrollW = parent.scrollWidth;
- // console.log(poffsetW+" "+pscrollW)
- // parent.setAttribute("aaa",poffsetW+"/"+pscrollW)
- // if(poffsetW<pscrollW){
- // parent.style.overflow="hidden";
- // parent.style.textOverflow="ellipsis";
- // parent.style.whiteSpace="nowrap";
- // }
- } catch (e) {
- console.log(e)
- }
- };
- wd.display.callback_suffix = "confirm_callback";
- wd.display.cancelcallback_suffix = "cancel_callback";
- wd.display.confirm = function (title, msg, callback, cancelCallback) {
- var params = {
- dialog: "dialog",
- width: 400,
- height: 180
- };
- //第一个参数是对象参数 {title:title,msg:msg}
- if (typeof title == "object") {
- $.extend(params, title);
- } else {
- params.title = title;
- params.msg = msg;
- params.callback = callback;
- params.cancelCallback = cancelCallback;
- params.url = "/page/sure.jsp?msg=" + encodeURIComponent(msg);
- }
- /// 增加,来自 PMS下载。Lin
- if(!params.url)
- params.url = "/page/sure.jsp?msg=" + encodeURIComponent(params.msg);
- ///
- var dialogid = wd.display.showComponent({
- show: ["wdDialog"],
- hide: [],
- url: params.url,
- title: params.title||" ",
- width: params.width,
- height: params.height
- });
- if (typeof params.callback == "string") {
- // window[dialogid+wd.display.callback_suffix]=eval(callback);
- window[dialogid + wd.display.callback_suffix] = function () {
- var iframe = wd.display.getFrameOfWindow();
- // console.log(this)
- if (iframe.tabObj == null) {
- this.location = params.callback;
- } else {
- this.parent.location = params.callback;
- }
- };
- } else if (typeof params.callback == "function") {
- window[dialogid + wd.display.callback_suffix] = params.callback;
- }
- if (params.cancelCallback) {
- window[dialogid + wd.display.cancelcallback_suffix] = params.cancelCallback;
- }
- };
- //window.confirm = wd.display.confirm;
- //
- wd.display.alert = function (message, options) {
- wd.display.showMsgPopup(message, options);
- };
- // window.alert = wd.display.alert; // 再去掉,恢复 window.alert -- 需要使用不定时消失的对话框。Lin
- // isFixation 为 true 时,弹窗将立刻固定在右下角
- wd.display.isFixation = false;
- wd.display.fixationAlert = function (message, options) {
- wd.display.isFixation = true;
- wd.display.showMsgPopup(message, options);
- wd.display.isFixation = false;
- };
- // window.alert = wd.display.fixationAlert; // 再去掉,恢复 window.alert -- 需要使用不定时消失的对话框。Lin
- /**
- *
- * 获取弹窗内所有window对象
- *
- */
- wd.display.getwdDialogWindowObjects = function (wdDialogId) {
- var contain = wd.display.getwdDialogWindows(wdDialogId);
- if (!contain)
- return null;
- var aaa = [];
- var thisIframe = contain.getFrame();
- var cc = 0;
- do {
- if (thisIframe.contentWindow.closed)
- break;
- aaa.push(thisIframe.contentWindow.window);
- thisIframe = thisIframe.contentWindow.document.querySelector("iframe");
- cc++
- } while (thisIframe && cc <= 100)
- return aaa;
- }
- wd.display.shareTable = function (wdDialogId) {
- // console.log("archive!");
- var iframe = wd.display.getFrameOfWindow();
- //归档按钮
- if (iframe != null && iframe.contentWindow == window) {
- var bottom_div = $(".bottom-down-div");
- if (bottom_div.find(".submitButton").length == 0) {
- // bottom_div.append("<input type=\"button\" class=\"bottom-button submitButton\" value=\"确认\" />")
- // bottom_div.append("<input type=\"button\" class=\"bottom-button authorize\" value=\"授权\" />")
- // bottom_div.append("<select id=\"xxgkfsmOption\"><option value='1'>系统内公开</option><option value='1'>不公开</option></select>")
- bottom_div.html('<input type=\"button\" class=\"bottom-button submitButton\" value=\"确认\" />' +
- '<input type=\"button\" class=\"bottom-button authorize\" value=\"授权\" />' +
- '<select id=\"xxgkfsmOption\" style="display:none;"><option value="1">系统内公开</option><option value="1">不公开</option></select>' +
- bottom_div.html());
- bottom_div.on("click", ".authorize", function () {
- wd.display.getwdDialogWindows().getFrame().contentWindow.authorize();
- })
- bottom_div.on("click", ".submitButton", function () {
- wd.display.getwdDialogWindows().getFrame().contentWindow.agree();
- })
- }
- }
- var tokenList = [];
- var tokenData = {};
- var $elements = $("[onclick^='wd.display.showComponent']:not(:hidden)").each(function (num, ele) {
- var showComponentFunStr = this.getAttribute("onClick");
- //获取token查询
- var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
- var patt = reg.exec(showComponentFunStr);
- if (patt == null)
- return true;
- var token = patt[0].split("=")[1];
- tokenList.push(token);
- tokenData[token] = {
- 'type': 'childObject',
- 'ele': this
- };
- });
- // console.log(tokenData)
- if (iframe != null && iframe.contentWindow == window) {
- var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
- var patt = reg.exec(window.location.href);
- var token = "";
- if (patt == null) {
- // return true
- token = window.location.href
- } else {
- token = patt[0].split("=")[1];
- }
- tokenList.push(token);
- tokenData[token] = {
- 'type': 'primaryObject'
- };
- }
- if (tokenList.length == 0)
- return;
- // console.log(tokenList)
- /* 再改,规范命名。Lin
- * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
- * &wdService= 改为 ssServ
- $.post("/service?wdApplication=wd&wdService=objectDataQueryByToken", {
- */ $.post("/service?ssServ=objectDataQueryByToken", {
- 'tokenList': JSON.stringify(tokenList)
- }, function (data) {
- data = eval(data)
- var mark = wd.topWindow.mark[wdDialogId];
- // console.log(tokenData)
- for (var i = 0; i < data.length; i++) {
- var temp = data[i]
- var ele = tokenData[temp.token].ele;
- var type = tokenData[temp.token].type;
- var keyid = temp.object + temp.id;
- var checked = (temp.checked == "true" || temp.checked == true) ? true : false;
- if (!mark[keyid]) {
- mark[keyid] = {
- 'id': temp.id,
- 'type': type,
- 'object': temp.object,
- 'checkStatue': checked,
- 'checked': checked
- }
- }
- // console.log(mark[keyid]);
- // console.log(mark[keyid])
- if (type != "childObject")
- continue;
- var topDoc = window.document;
- var chartDiv = topDoc.createElement('div');
- chartDiv.setAttribute("id", keyid);
- topDoc.body.appendChild(chartDiv);
- // chartDiv.innerHTML = "<input id=\"" + keyid + "\" type='checkbox' " + (mark[keyid].checked ? "checked" : "") +
- // " value='' />";
- if (mark[keyid].checked) {
- chartDiv.setAttribute("class", "smallButton-checked checked")
- } else {
- chartDiv.setAttribute("class", "smallButton-unchecked")
- }
- var bounding = ele.getBoundingClientRect();
- $(chartDiv).css({
- left: bounding.left - chartDiv.offsetWidth * 0.5,
- top: bounding.top + (ele.offsetHeight * 0.5) - chartDiv.offsetHeight,
- // width: "auto",
- // height: ele.offsetHeight,
- zIndex: 65535,
- position: 'absolute',
- // background: (mark[keyid].checkStatue != mark[keyid].checked ? 'red' : 'cyan'),
- // display: 'block'
- })
- $(chartDiv).on("click", function () {
- var id = this.getAttribute("id");
- var checked = $(this).hasClass("smallButton-unchecked");
- var mark = wd.topWindow.mark[wdDialogId];
- mark[id]["checked"] = checked;
- // console.log(checked)
- if (checked) {
- this.setAttribute("class", "smallButton-checked")
- } else {
- this.setAttribute("class", "smallButton-unchecked")
- }
- //
- //
- // $(this).css({
- // background: (mark[id]["checkStatue"] != mark[id]["checked"] ? 'red' : 'cyan'),
- // })
- // console.log(wd.topWindow.mark[wdDialogId])
- })
- }
- })
- }
- //临时js
- $(function () {
- //首页模板添加样式
- if (wd.topWindow && wd.topWindow.MenuSetting) {
- var topiframe = wd.topWindow.document.querySelector("iframe[name=" + wd.topWindow.MenuSetting.target + "]");
- if (topiframe && topiframe.contentWindow) {
- if (topiframe.contentWindow == window) {
- $(window.document.body).addClass("home-div");
- $(wd.topWindow.document.body).addClass("home-div");
- $(".gridster,#pg_cj").addClass("home-div");
- }
- }
- }
- //动态添加单记录授权按钮
- var wdDialogId = wd.display.getwdDialogId();
- // return;
- if (!wdDialogId)
- return
- if (!wd.topWindow.mark)
- wd.topWindow.mark = {};
- //打标记
- if (document.querySelector("meow")) {
- if (!wd.topWindow.mark[wdDialogId])
- wd.topWindow.mark[wdDialogId] = {};
- }
- if (wd.topWindow.mark[wdDialogId]) {
- wd.display.shareTable(wdDialogId);
- }
- var win = wd.topWindow.dhxWins.window(wdDialogId);
- if (wd.topWindow.lockScreen) {
- win.button("lockScreen").onclick = function () {
- wd.display.beaconLogin("loginOut");
- wd.topWindow.lockScreen();
- }
- win.button("lockScreen").show();
- }
- })
- //查询获取object的function服务
- //结果用来调用弹窗方法 wd.display.showComponent.call(window,r);
- wd.display.createObjectService = function (objName, functionName) {
- var p = {
- objName: objName,
- funcName: functionName
- }
- var r = null;
- $.ajax({
- type: "post",
- /* 再改,规范命名。Lin
- * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
- * &wdService= 改为 ssServ
- url: "/service?wdApplication=wd&wdService=createObjectService&wdtest=false",
- */ url: "/service?ssServ=makeFuncParm",
- data: p,
- async: false,
- dataType: "json",
- success: function (result) {
- r = result;
- // console.log(r);
- addRemoveToken(r.token);
- r.show = "wdDialog";
- // wd.display.showComponent.call(window,r);
- if (r.pluginList) {
- for (var i = 0; i < r.pluginList.lenth; i++) {
- addRemoveToken(r.pluginList[i].token);
- }
- }
- },
- error: function (error) {
- // alert("查询失败")
- console.log(error)
- }
- })
- return r;
- }
- wd.display.showTextTile = function (id, msg) {
- var iii = document.getElementById(id);
- iii.parentNode.setAttribute("title", msg);
- iii.parentNode.removeChild(iii);
- }
- var styleAttrs = {
- "width": "width",
- "height": "minHeight"
- };
- var isdebug = false;
- wd.display.initGrowHighHtml = function (areaId, maxHeight, buttons) {
- return wd.display.initGrowHigh(areaId, maxHeight, buttons, true);
- }
- wd.display.initGrowHigh = function (areaId, maxHeight, buttons, multimedia) {
- // if (typeof GrowHeight == "undefined")
- // $.getScript("/wd/js/growHeight.js", function () {
- // getGrowHeight(areaId, maxHeight, buttons);
- // });
- // else
- return getGrowHeight(areaId, maxHeight, buttons, multimedia ? 2 : 3);
- }
- /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin
- if (!window.wdFitHeightbqgd) {
- window.wdFitHeightbqgd = 0;
- }
- */
- if (!window.ssLblHeightByFith)
- window.ssLblHeightByFith = 0;
- /**
- * wdfitheight传入减去高度
- */
- wd.display.fitHeightbqgd = function (n) {
- /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin
- window.wdFitHeightbqgd += n;
- */ window.ssLblHeightByFith += n;
- }
- wd.display.initGrowHighByIds = function (ids, maxHeight) {
- for (var i = 0; i < ids.length; i++) {
- if (typeof ids[i] != "string") {
- console.error("这不是一个ID")
- continue;
- }
- wd.display.initGrowHigh(ids[i], maxHeight, {});
- }
- }
- wd.display.ellipsisContent = function (dom, height) {
- function setText(text) {
- var nn = this.nodeName;
- if (nn == "TEXTAREA" || nn == "INPUT") {
- this.value = text;
- } else {
- this.innerText = text;
- }
- }
- function getText() {
- var nn = this.nodeName;
- if (nn == "TEXTAREA" || nn == "INPUT") {
- return this.value;
- } else {
- return this.innerText;
- }
- }
- function haveScroll(dom) {
- return dom.scrollHeight > dom.clientHeight;
- }
- function getCnHeight() {
- var otxt = getText.call(this);
- setText.call(this, "中");
- var cnHeight = Math.max(this.scrollHeight, this.clientHeight);
- setText.call(this, otxt);
- return cnHeight;
- }
- var css = dom.style.cssText,
- $dom = $(dom),
- srcText = getText.call(dom);
- dom.srcText = srcText;
- var _style = window.getComputedStyle(dom);
- var fontSize = _style.fontSize;
- fontSize = parseInt(fontSize) || $("body").css("font-size");
- var domWidth = $dom.width();
- var cnHeight = getCnHeight.call(dom);
- height = height || parseFloat(_style.height) || parseFloat($dom.css("min-height"));
- height = Math.max(cnHeight, height);
- dom.style.setProperty("height", height + "px", "important");
- setText.call(dom, dom.srcText);
- if (srcText.length == 0 || height == 0) {
- dom.style.cssText = css;
- return srcText;
- }
- // console.log(dom, cnHeight, height, fontSize, haveScroll(dom));
- // var noBlankText = srcText.replace(/\s/g, "");
- var endOffset = parseInt(domWidth / fontSize); //大概一行的字数
- var viewText = srcText.substring(0, endOffset);
- setText.call(dom, viewText);
- var dot = false;
- while (endOffset < srcText.length && !haveScroll(dom)) { //还有字但是没有滚动条,加
- endOffset++;
- viewText = srcText.substring(0, endOffset);
- setText.call(dom, viewText);
- if (haveScroll(dom)) { //
- dot = true;
- }
- }
- while (endOffset > 0 && haveScroll(dom)) { //出了滚动条,减
- endOffset--;
- viewText = viewText.substring(0, endOffset) + "...";
- (function (vt) {
- setText.call(dom, vt)
- })(viewText);
- }
- setText.call(dom, viewText)
- dom.style.cssText = css;
- return viewText;
- }
- //显示tag圆点
- wd.display.showTagState = function (url) {
- // console.log(url)
- $(function () {
- var tokenList = []
- var lis = document.querySelectorAll("[ssTabClick]"); // ("[wdtabclick]")。先改,是 wdtabclick,不是 wdTabClick。Lin
- for (var i = 0; i < lis.length; i++) {
- var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
- var patt = reg.exec(lis[i].getAttribute("ssTabClick")); // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin
- if (patt == null) {
- tokenList.push(null);
- } else {
- var token = patt[0].split("=")[1];
- tokenList.push(token);
- }
- }
- // console.log(7777777777)
- // console.log(tokenList)
- //
- $.post(url, {
- "tokenList": JSON.stringify(tokenList)
- }, function (result) {
- result = eval("(" + result + ")");
- // console.log(result);
- for (var i = 0; i < lis.length; i++) {
- if (!result[i])
- continue;
- if (true == result[i].cgxList) { // ("true" ==。字符串改为布尔型。Lin
- lis[i].innerHTML = lis[i].innerHTML + "<span class=\"statePoint icon-highlightPoint\"></span>"
- } else if (true == result[i].objectList) { // ("true" ==。字符串改为布尔型。Lin
- lis[i].innerHTML = lis[i].innerHTML + "<span class=\"statePoint icon-dimPoint\"></span>"
- } else { }
- }
- })
- })
- }
- //级联查看 growheight前文本处理
- wd.display.combineDiv = function (id) {
- // console.log($("#" + id).children().find("[id$=combine]"))
- //
- if ($("#" + id).children().find("[id$=combine]").length > 0)
- return
- var content = "";
- var isCascading = $("#" + id).find(".content-offButton,.content-onButton").length == 0;
- if (isCascading) {
- $("#" + id).children(":visible").each(function () {
- content += (this.innerHTML + " ");
- })
- } else {
- $("#" + id).find(":visible").each(function () {
- if ($(this).is("[type=button]")) {
- // var name = this.getAttribute("name");
- // if ("1" == $("[type=hidden][name=" + name + "]").val()) {
- // content += ($("[type=button][name=" + name + "][wdValue=1]").val() + " ");
- // }
- if ($(this).hasClass("content-onButton")) {
- content += ($(this).val() + " ");
- }
- }
- })
- }
- if (/\ \;$/.test(content))
- content = content.substring(0, content.length - " ".length)
- $("#" + id).empty().html(content);
- }
- wd.display.initSelectOption = function (id) {
- wd.topWindow.$("#" + id).remove();
- var ele = $("<div id=\"" + id + "\" class=\"popup-div hLine-highlightBlod\" >"
- + "<div class=\"scrollbar\" style=\"max-height:250px;overflow-x:auto;padding-right:16px;\"></div>"
- + "</div>")[0];
- wd.topWindow.document.body.appendChild(ele);
- return ele
- }
- wd.display.buildSelectOption = function (dom, datalist, valueKey, nameKey, selectValue, hasNullOption) {
- var ul = dom.childNodes[0];
- if (datalist && datalist.length > 0) {
- var listr = hasNullOption ? '<div class=\"popupList\" status="noitem"> </div>' : '';
- for (var i = 0; i < datalist.length; i++) {
- var name = datalist[i][nameKey];
- var value = datalist[i][valueKey];
- listr += '<div class=\"' + (value == selectValue ? ' selected ' : '') + 'popupList\" status="people" value="' + value + '"' + 'index="' + i + '">' + name + '</div>';
- }
- ul.innerHTML = listr;
- } else {
- ul.innerHTML = hasNullOption ? '<div class=\"popupList\" status="noitem">找不到相关项</div>' : '';
- }
- }
- wd.display.queryNrSubNr = function (nrid, jlztm, datas) {
- var result = [];
- $.ajax({
- type: 'post',
- url: "/service",
- dataType: "json",
- data: {
- ssServ: "wrCmsList", // wdService: "nrxtsy",。Lin
- nrid: "T-" + nrid,
- sfbf: 1,
- jlztm: jlztm
- },
- async: false,
- success: function (jsonData) {
- for (var i = 0; i < jsonData.length; i++) {
- result.push({
- name: jsonData[i].mc,
- value: jsonData[i].mswj,
- nrjslbm: jsonData[i].nrjslbm
- });
- }
- }
- });
- return result;
- }
- wd.display.initCmsbtn = function (btn, fjid) {
- if (fjid != null && fjid != "") {
- $.ajax({
- type: "post",
- url: "/service?ssServ=wrCcmsList", // =getSubNrCount",。Lin
- data: {
- nrid: "T-" + fjid,
- jlztm: 51
- },
- dataType: "json", // 增加,统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
- success: function (data) {
- /* 改,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
- * 去掉 JSON.parse(,改为用 Map<String, Object> 传输
- var names = JSON.parse(data);
- */
- if (data.ssCode != 0) {
- alert(data.ssMsg);
- return;
- }
- var names = data.ssData;
- var count = names.length;
- //if (count > 0) {
- var num = btn[0].querySelector(".attachment_count");
- if (!num) {
- num = document.createElement("span");
- num.className = "attachment_count";
- btn[0].appendChild(num);
- }
- num.innerText = count;
- if (count == 0) {
- $(num).hide();
- } else {
- $(num).show();
- }
- var datas = [];
- for (var iii = 0; iii < names.length; iii++) {
- datas.push({
- name: iii,
- value: names[iii]
- })
- }
- btn.off("mouseenter").on("mouseenter", function () {
- var menuelement = wd.display.initCmsMenu(fjid + "", 51);
- if (menuelement) {
- menuelement.showAt(btn[0]);
- btn.off("mouseleave").on("mouseleave", function () {
- menuelement.hide();
- });
- }
- });
- },
- error: function (data) {
- console.log(data);
- }
- });
- }
- }
- wd.display.initCmsMenu = function (id) {
- wd.topWindow.$("#CMSMENU").remove();
- var nrid = id = id.replace(/\D*/, "");
- //注册内容
- $.ajax({
- url: "/service",
- data: {
- nrid: "T-" + nrid,
- ssServ: "regCms" // wdService: "register"。Lin
- },
- async: false,
- dataType: "json",
- success: function (data) {
- console.log(data);
- }
- });
- var data = wd.display.queryNrSubNr(nrid);
- if (data.length == 0) {
- return;
- }
- var mainElement = wd.display.initSelectOption("CMSMENU");
- function loadPlayer(contentDiv) {
- var win = contentDiv.ownerDocument.defaultView;
- var se = contentDiv.srcElement,
- $se = $(se),
- subnrid = $se.attr("value"),
- nrjslbm = $se.attr("nrjslbm");
- win.$.ajax({
- type: "GET",
- url: "/service",
- data: {
- ssServ: "wrCmsPlay", // : wdService: "loadNrDesignAndPlayerData",。Lin
- "nrid": subnrid,
- "nrjslbm": nrjslbm
- },
- async: false,
- dataType: "json",
- success: function (data) {
- /// 增加,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
- if (data.ssCode != 0) {
- alert(data.ssMsg);
- return;
- }
- ///
- var div = document.createElement("div");
- var obj = {};
- obj.design = data.design;
- obj.resDesign = data.resDesign;
- div.setAttribute("data-init", JSON.stringify(obj));
- var tempData = data.data.replace(new RegExp('@dataFolder@', 'gm'), data.dataFolderPath);
- var $ma = win.$(contentDiv);
- var hasClose = $ma.find("#pageClose").length > 0;
- div.innerHTML = tempData;
- var $div = $(div);
- // $div.hide();
- $ma.html($div);
- $ma.append(
- '<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="icon-restore" style="position: fixed;right: 13px;top: 10px;height:22px;width:22px;" onclick="wd.display.exitFullScreen()" ></div></div></div>');
- // var $content = $(contentDiv);
- // loadScorll($content);
- // $content.getNiceScroll().resize();
- div.addEventListener("DOMSubtreeModified", function () {
- try {
- win.wd.display.CmsZNRFull(contentDiv);
- } catch (e) { }
- // var $content = $(contentDiv);
- // loadScorll($content);
- // $content.getNiceScroll().resize();
- // $content.css("height", $content.height());
- // $content.css("height", "100%");
- });
- }
- });
- var $pe = $se.prev(".popupList"),
- prev = $pe.attr("value"),
- $ne = $se.next(".popupList"),
- next = $ne.attr("value");
- var ismousedown = false;
- var oldY,
- scollY;
- contentDiv.onmousedown = function (e) {
- oldscrollTop = contentDiv.scrollTop;
- oldY = e.screenY;
- scollY = contentDiv.scrollTop;
- ismousedown = true;
- }
- contentDiv.onmouseup = function (e) {
- ismousedown = false;
- }
- contentDiv.onmousemove = function (e) {
- e = e || window.event;
- var newY = e.screenY;
- if (ismousedown) {
- //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight)
- if (oldY - newY >= 150 && contentDiv.scrollTop + contentDiv.clientHeight + 1 >= contentDiv.scrollHeight && oldscrollTop +
- contentDiv.clientHeight + 1 >= contentDiv.scrollHeight) {
- ismousedown = false;
- // console.log("鼠标向上移动");
- if ($ne.length > 0) {
- contentDiv.srcElement = $ne[0];
- loadPlayer(contentDiv);
- }
- // console.log(contentDiv.getAttribute("isCmsFullScreen"));
- } else if (newY - oldY >= 150 && contentDiv.scrollTop <= 0 && oldscrollTop == 0) {
- ismousedown = false;
- // console.log("鼠标向下移动");
- if ($pe.length > 0) {
- contentDiv.srcElement = $pe[0];
- loadPlayer(contentDiv);
- }
- // console.log(contentDiv.getAttribute("isCmsFullScreen"));
- } else {
- contentDiv.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度
- }
- }
- }
- // console.log("加载播放器完毕")
- }
- mainElement.style.minWidth = "180px";
- wd.display.buildSelectOption(mainElement, data, "value", "name", "null");
- var $mainElement = wd.topWindow.$(mainElement);
- $.each(data, function () {
- $mainElement.find("[value='" + this.value + "']").attr("nrjslbm", this.nrjslbm);
- });
- $mainElement.find(".popupList").click(function () {
- //绑定全屏
- var doc = mainElement.ownerDocument;
- var maindiv = doc.querySelector("#CMSPLAY" + id);
- if (maindiv == null) {
- //创建打的包装div
- maindiv = doc.createElement("div");
- maindiv.id = "CMSPLAY" + id;
- maindiv.style.textAlign = "center";
- maindiv.onselectstart = function () {
- return false;
- }
- doc.body.appendChild(maindiv);
- $(maindiv).append('<link rel="stylesheet" href="/ss/pdf/base.min.css">');
- $(maindiv).append('<link rel="stylesheet" href="/ss/pdf/fancy.min.css">');
- $(maindiv).append('<script type="text/javascript" src="/ss/pdf/compatibility.min.js"></script>');
- $(maindiv).append('<script type="text/javascript" src="/ss/pdf/pdf2htmlEX.min.js"></script>');
- var contentDiv = maindiv.contentDiv = doc.createElement("div");
- contentDiv.className = "mainDiv";
- contentDiv.style.width = "100%";
- contentDiv.style.height = "100%";
- contentDiv.style.display = "flex";
- contentDiv.style.justifyContent = "center";
- contentDiv.style.background = "white";
- contentDiv.style.alignItems = "center";
- maindiv.appendChild(contentDiv);
- }
- maindiv.contentDiv.srcElement = this;
- // setTimeout(function () {
- // console.log("开始全屏")
- doc.defaultView.wd.display.CmsFullScreen(maindiv.getElementsByTagName('DIV')[0], function () {
- loadPlayer(maindiv.contentDiv);
- $(maindiv).children("#pageClose").remove();
- }, function () {
- maindiv.parentNode.removeChild(maindiv);
- doc.defaultView.clearInterval(maindiv.contentDiv.intervalID);
- });
- // }, 500);
- });
- $mainElement.mouseenter(function () {
- if (this.removeTimerId != null) {
- this.ownerDocument.defaultView.clearTimeout(this.removeTimerId);
- this.removeTimerId = null;
- }
- });
- mainElement.hide = function () {
- mainElement.removeTimerId = mainElement.ownerDocument.defaultView.setTimeout(function () {
- $mainElement.remove();
- }, 300);
- };
- $mainElement.mouseleave(function () {
- this.hide();
- });
- mainElement.showAt = function (element) {
- $mainElement.show();
- var bounding = element.getBoundingClientRect(),
- mb = mainElement.getBoundingClientRect(),
- xy = recursionIframe(window);
- var left = bounding.right + xy.left - mb.width;
- var top_ = bounding.top + xy.top - 10 - mb.height;
- $mainElement.css({
- left: left,
- top: top_
- });
- }
- $mainElement.click(function (e) {
- e.stopPropagation();
- });
- $("body").click(function () {
- mainElement.hide()
- });
- $("body", wd.topWindow.document).click(function () {
- mainElement.hide()
- });
- $mainElement.hide();
- return mainElement;
- }
- //获取表单元素
- //growHeight
- //objectpicker
- //onoffbutton
- //ueditor
- //input select datepicker
- //编辑帮助,个人选值
- wd.display.getInputsGroups = function () {
- var arr = $("form,input,select,:radio,:checkbox").serializeArray();
- var ret = {};
- for (var i = 0; i < arr.length; i++) {
- var name = arr[i].name;
- if (!name)
- continue;
- if (/objectPicker.*/.test(name))
- continue;
- var cc = wd.display.getInputBox(name);
- if (!cc)
- continue;
- ret[name] = cc;
- }
- return ret;
- }
- /**
- *
- * @param {Object} name
- * @param {Object} any true:不过滤隐藏元素
- */
- wd.display.getInputBox = function (name,any) {
- if(wd.display.filterInputBoxNames[name]){
- // console.log("filterInputBoxNames:"+name);
- return null;
- }
- var result = {
- name: name,
- container: null, //定位元素
- setChange:null,
- focus:null,//光标
- onKeyDown:null,//enter key event
- onKeyDownContainer: null,
- modify:null,
- modifyContainer:null
- };
- result.getValue = function () {
- return $(this.container).val()
- }
- result.setValue = function (v) {
- $(this.container).val(v)
- }
- result.setChange = function (changefunc) {
- $(this.container).on("change",changefunc);
- }
- result.focus = function () {
- $(this.container).focus();
- }
- result.modify= function (canmodify) {
- if(canmodify){
- $(this.modifyContainer||this.container ).removeAttr("readonly");
- }else{
- $(this.modifyContainer||this.container).attr("readonly","readonly");
- }
- }
- //键盘录入监听,keycode 9:tab 13:enter
- result.onKeyDown=function (keycode,func) {
- var code=[];
- code=keycode;
- $(this.onKeyDownContainer||this.container).on("keydown",function(){
- if(code.indexOf(window.event.keyCode)!=-1){
- return func();
- }
- });
- }
- try {
- if (window.growHeightList &&window.growHeightList[name]) {
- result.type = "growHeight"
- result.instance = growHeightList[name];
- result.container = growHeightList[name].container.parentNode
- result.getValue = function () {
- return this.instance.val();
- }
- result.setValue = function (v) {
- this.instance.val(v);
- }
- result.focus = function () {
- this.instance.onFocus()
- }
- result.onKeyDownContainer=$(growHeightList[name].getInputElement().parentNode).find("textarea");
- result.modifyContainer=growHeightList[name].getInputElement();
- } else if (wd && wd.edit && wd.edit.objectPicker && wd.edit.objectPicker.getInstance(name)) {
- result.type = "objectPicker"
- result.instance = wd.edit.objectPicker.getInstance(name);
- result.container = result.instance.getDisplayElement();
- result.getValue = function () {
- return this.instance.getValue()
- }
- result.setValue = function (v) {
- this.instance.initValue(v);
- }
- result.setChange=function(func){
- this.instance.onchange=func;
- }
- result.modify=function(canmodify){
- this.instance.modify(canmodify);
- }
- } else if (window.EditorManager&&EditorManager.instances&&EditorManager.instances[name]) {
- result.type = "ueditor"
- result.container =EditorManager.instances[name].getUeditor().container;
- result.instance =EditorManager.instances[name].getUeditor();
- result.getValue = function () {
- var c= this.instance.getContent();
- return (c)?wd.display.toPlainText():c;
- }
- result.setValue = function (v) {
- return this.instance.setContent(v);
- }
- } else if ($("#" + name + "_onoffbutton_list").length == 1) {
- result.type = "onoffbutton"
- result.container = $("[name="+name+"][type=button]").last()[0];
- result.getValue = function () {
- return $("[name='"+name+"'][type=hidden]").val();
- }
- result.setValue = function (v) {
- /* 改,是小写的 wdvalue=,也改先 -- 规范命名。Lin
- $("[name='"+name+"'][type=button][wdvalue="+v+"]").click();
- */ $("[name='"+name+"'][type=button][ssVal="+v+"]").click();
- }
- }else if(window.enrolDateList&&window.enrolDateList[name]){
- result.type = "enrolDate"
- result.instance = window.enrolDateList[name];
- result.container = window.enrolDateList[name].container
- result.getValue = function () {
- return this.instance.getValue();
- }
- result.setValue = function (v) {
- this.instance.setValue(v);
- }
- result.setChange=function(func){
- this.instance.onchange=func;
- }
- }else if(window.editPhotoList&&window.editPhotoList[name]){
- result.type = "editPhoto"
- result.instance = window.editPhotoList[name];
- result.container = window.editPhotoList[name].container;
- result.getValue = function () {
- return this.instance.getValue();
- }
- result.setValue = function (v) {
- this.instance.setValue(v);
- }
- result.modify=function(canmodify){
- this.instance.modify(canmodify);
- }
- } else if (document.querySelector("[name='" + name + "']")) {
- result.type = "input";
- result.container = document.querySelector("[name='" + name + "']");
- } else {
- return null;
- }
- if(any){
- }else{
- if ($(result.container).width() == 0)
- return null;
- }
- } catch (e) {
- console.log(e);
- }
- return result;
- }
- if(!wd.display.filterInputBoxNames){
- wd.display.filterInputBoxNames={};
- }
- /**
- * 过滤inputbox
- */
- wd.display.filterInputBox=function (name) {
- for(var i=0;i<arguments.length;i++){
- var m=arguments[i];
- wd.display.filterInputBoxNames[m]="1";
- }
- // console.log(wd.display.filterInputBoxNames);
- }
- wd.display.changeFirstTitle = function (t) {
- var displgid = wd.display.getwdDialogId();
- if (!displgid)
- return;
- wd.topWindow.dhxWins.window(displgid).querySelector(".dialog-title").innerHTML = t
- }
- wd.display.changeSecondTitle = function (t) {
- var displgid = wd.display.getwdDialogId();
- if (!displgid)
- return;
- wd.topWindow.dhxWins.window(displgid).querySelector(".secondTitle").innerHTML = t
- }
- /**
- * 判断当前url是否个人首页
- * @param {Object} win
- */
- wd.display.isPersonalHomePageUrl = function (url) {
- if (!url)
- return false;
- return url.indexOf("initDesktop") == -1 ? false : true;
- }
- /**
- * 生成更多按钮
- * @param {Object} buttonId
- * @param {Object} childrenClass
- * selectedDiv 选中菜单,显示按钮名称
- * recordvalue 启用个人选值
- */
- wd.display.attachButton = function (buttonId, childrenClass, selectedDiv, buttonNotClickAschild, recordvalue) {
- var $button = $("#" + buttonId);
- var vanishId;
- //获取二级数据
- function findDatalist() {
- var datalist = [];
- var d = document.querySelectorAll("." + childrenClass);
- //adminNo
- for (var i = 0; i < d.length; i++) {
- datalist.push({
- name: d[i].getAttribute("value"),
- value: d[i].getAttribute("value"),
- ele: d[i]
- });
- }
- return datalist;
- }
- function showChild(v, isinit) {
- var datalist = findDatalist();
- var thisdata;
- for (var i = 0; i < datalist.length; i++) {
- if (datalist[i].value == v) {
- thisdata = datalist[i];
- }
- }
- //记忆,点击按钮触发上一个点击过的选项
- $button.off("click");
- if (true === buttonNotClickAschild) {
- $button.on("click", function () {
- vanishId = setTimeout(function () {
- $("#" + buttonId + "_buttons").hide();
- }, 500)
- })
- } else {
- $("#" + buttonId + "_buttons").hide();
- var html = thisdata ? thisdata.name : "";
- if (true === isinit) {
- html = $button.val() + html;
- }
- if (selectedDiv) {
- $button.find(selectedDiv).html(html);
- } else if ($button.is("input")) {
- $button.val(html);
- }
- $button.on("click", function () {
- $(thisdata.ele).trigger("click");
- })
- }
- return thisdata;
- }
- $button.on("mouseenter click", function () {
- //获取下拉数据
- var datalist = findDatalist();
- //create div
- $("#" + buttonId + "_buttons").remove();
- var dom = wd.display.initSelectOption(buttonId + "_buttons");
- if (datalist.length > 0) {
- /* 再改,不知为何要反转 细分部件(原 plugin) 顺序???Lin
- wd.display.buildSelectOption(dom, datalist.reverse(), "value", "name", null, false);
- */ wd.display.buildSelectOption(dom, datalist, "value", "name", null, false);
- $("body").append(dom);
- }
- //position
- var dombounding = dom.getBoundingClientRect();
- var bounding = (this.querySelector("img") || this).getBoundingClientRect();
- //console.log(bounding);
- var left = bounding.left;
- //防止超出屏幕出现滚动条
- if ((left + dombounding.width) > window.innerWidth) {
- left = window.innerWidth - dombounding.width;
- }
- dom.style.left = Math.max(left, 0) + "px";
- if (bounding.top + bounding.height + dombounding.height > window.innerHeight) {
- dom.style.top = (bounding.top - dombounding.height) + "px"
- //console.log("up side")
- } else {
- //console.log("down side")
- dom.style.top = (bounding.top + bounding.height) + "px"
- }
- //bind event
- $(dom).on("click", ".popupList", function () {
- if (window.event) {
- if (window.event.stopPropagation) {
- window.event.stopPropagation();
- } else {
- window.event.cancelBubble = true;
- }
- }
- var v = this.getAttribute("value");
- var thisdata = showChild(v);
- $(thisdata.ele).trigger("click");
- // console.log(thisdata);
- if (recordvalue) {
- var recordzhi = {};
- recordzhi[buttonId] = {
- value: v,
- default:
- true
- };
- wd.edit.insertRecord(recordzhi);
- }
- }).on("mouseleave", function () {
- $(this).hide();
- }).on("mouseenter", function () {
- if (vanishId)
- clearTimeout(vanishId);
- })
- }).on("mouseleave", function () {
- if ($(window.event.relatedTarget).is($(this).parents())) {
- vanishId = setTimeout(function () {
- $("#" + buttonId + "_buttons").hide();
- }, 500)
- }
- })
- if (recordvalue) {
- $(function () {
- var record = wd.edit.getRecord();
- // console.log(record);
- if (record && record[buttonId]) {
- var v = record[buttonId].value;
- showChild(v, true);
- }
- })
- }
- }
- wd.display.inputCaptcha = function (name, captchalength) {
- try {
- var inputbox = wd.display.getInputBox(name);
- if (!inputbox)
- return;
- var inputClass = name + "_inputCaptcha";
- var va = $("<div style=\"position:absolute; left: 5px;top: 5px;width: 100%;height: 100%;z-index: 1;display: flex;\">"
- + "<div class=\"hLine\" style=\"display: flex; height: 30px;\">"
- + "<input class=\"" + inputClass + "\" style=\"width:140px;border: none;padding-left: 7px;\" placeholder='请输入验证码'/>"
- + "<img align=\"middle\" vspace=\"2\" id=\"codeimg\" title=\"看不清楚可单击刷新\" class=\"header_yzmimg\" src=\"/wd/verificationCode.do?" + new Date().getTime() + "\">"
- // +"<input type=\"button\" value=\"确定\" class=\"content-button\" onclick=\"void(0);\" style=\"margin-left: 10px;\"/>"
- + "</div>"
- + "</div>");
- // va.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",background:"azure",zIndex:1})
- $(inputbox.container).before(va);
- va.on("click", "img", function () {
- this.setAttribute("src", "/wd/verificationCode.do?" + new Date().getTime());
- }).on("blur", "." + inputClass, function () {
- /* 再改,规范命名。Lin
- * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
- * &wdService= 改为 ssServ
- $.post("/service?wdApplication=wd&wdService=checkCaptcha_ajax&wdtest=false", {
- */ $.post("/service?ssServ=checkCaptcha_ajax", {
- yzm: this.value
- }, function (result) {
- if ("1" == result.result) {
- va.hide();
- $(inputbox.container).show();
- if (typeof window.inputCaptchaCallback == "function")
- window.inputCaptchaCallback();
- } else {
- wd.display.alert("验证码错误!")
- }
- }, "json")
- })
- $(inputbox.container).hide();
- } catch (e) {
- console.log(e);
- }
- }
- wd.display.previewPicture = function (url, errorPhoto) {
- if ($(window.event.srcElement).is("input,button"))
- return;
- $('.previewPicture').remove();
- // var onerror = errorPhoto ? ('this.src=\'' + errorPhoto + '\'') : "";
- var onerror = "";
- // if(true)return;
- // $("<div class='previewPicture ' style=\"display:none;z-index: 999999;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);border: 1px solid #6c9ddb;\">"
- // + "<img src=" + url + " onerror=\"" + onerror + "\" style=\"max-width:100%;max-height: 100%;\" onload=\"$('.previewPicture').show()\"/>"
- // +"<span class='close' style=\"width: 30px;height:30px;position: absolute;top: 0px;right: 0px;font-size: 20px;background-color: #e2e2e2;text-align: center;line-height: 30px;\">X</span>"
- // +"<span class='download' style=\"width: 30px;height:30px;position: absolute;top: 0px;right: -30px;font-size: 20px;background-color: #e2e2e2;text-align: center;line-height: 30px;\">download</span>"
- // + "</div>")
- // .appendTo("body")
- // .on('click',".close", function () {
- // $('.previewPicture').remove();
- // });
- var startLeft,startTop,startX,startY;
- $("<div class='previewPicture lightDialog-div' style=\"display:none;z-index: 9999;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);border: 1px solid #6c9ddb;\">"
- +'<div class="lightDialog-title hLine">'
- +'<div title="下载" class="download icon-download" style="position: absolute;right: 35px;top: 9px;"></div>'
- +'<div title="关闭" class="close icon-close"></div>'
- +'</div>'
- + "<img src=" + url + " onerror=\"" + onerror + "\" style=\"max-width:100%;max-height: 100%;\" onload=\"$('.previewPicture').show()\"/>"
- + "</div>"
- )
- .appendTo("body")
- .on('click',".close", function () {
- $('.previewPicture').remove();
- }).on('click',".download", function () {
- wd.display.downloadFile(url+"&download=1");
- // $('.previewPicture').remove();
- });
- // on("mousedown",function(){
- // startLeft=parseInt( $(this).css("marginLeft"));
- // startTop=parseInt( $(this).css("marginTop"));
- // startX=window.event.clientX;
- // startY=window.event.clientY;
- // this.setAttribute("move","1");
- // }).on("mouseup mouseout",function(){
- // this.setAttribute("move","0");
- // }).on("mousemove",function(){
- // if("1"!=this.getAttribute("move"))return;
- // $(this).css({
- // marginLeft:startLeft+window.event.clientX-startX,
- // marginTop:startTop+window.event.clientY-startY
- // })
- // })
- }
- wd.display.beaconLogin = function (type) {
- type = type || 'login';
- try {
- if (typeof beacon == "undefined")
- return false;
- if (type == 'login') {
- beacon.login(wd.topWindow.beaconLoginTicket);
- } else {
- beacon.loginOut();
- }
- return true;
- } catch (error) {
- console.log('------------------------------------');
- console.log(error);
- console.log('------------------------------------');
- }
- return false;
- }
- wd.display.getBeaconWhetherToOpen = function () {
- try {
- if (typeof beacon == "undefined")
- return false;
- if (beacon.getBeaconWhetherToOpen() == "True") {
- alert("“待办列表”已在烽火台打开");
- beacon.close2();
- }
- return true;
- } catch (error) {
- console.error(error);
- }
- return false
- }
- wd.display.refreshToDoList = function () {
- wd.display.refreshHomeplugin("6011");
- }
- wd.display.refreshHomeplugin = function (type) {
- if (!wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL)
- return "0";
- return wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL.refreshHomeplugin(type)
- }
- wd.display.setCloseWindowParam = function (p) {
- if (!p)
- return;
- var wdDialogId = wd.display.getwdDialogId();
- if (!wdDialogId)
- return;
- var win = wd.topWindow.dhxWins.window(wdDialogId);
- win.closeWindowParam = p;
- return win;
- }
- wd.display.onCloseDialog = function (win, popWindow) {
- try {
- // console.log("wd.display.onCloseDialog");
- // console.log(win.closeWindowParam);
- if (!win.closeWindowParam)
- return;
- var openerWindow = popWindow.wd.display.getwdDialogOpener();
- var name = openerWindow.wd.edit.objectPicker.addButtonClickName;
- if (!name)
- return;
- var objectpickerobj = openerWindow.wd.edit.objectPicker.getInstance(name);
- if (!objectpickerobj)
- return;
- // var data={option:[{name:"abc",id:"999"}]};
- var data = eval("(" + win.closeWindowParam + ")")
- objectpickerobj.setwdCloseWindowParamData(data);
- // console.log(objectpickerobj);
- } catch (err) {
- console.error(err);
- }
- }
- /**
- * 调用关闭窗口时调用的回调方法
- */
- wd.display.closeDialogCallbackFun = null;
- /**
- * 给一个按钮绑定事件
- * @param {Object} buttonname
- * @param {Object} bindevent
- * @param {Object} bindfunction
- */
- wd.display.bindWdButton = function (buttonname, bindevent, bindfunction) {
- var wdDialogId = wd.display.getwdDialogId();
- if (!wdDialogId)
- return;
- var win = wd.topWindow.dhxWins.window(wdDialogId);
- var b = win.button(buttonname);
- $(b).on(bindevent, bindfunction);
- }
- /**
- * px 2 rem
- */
- wd.display.px2Rem = function (px) {
- var unit = parseFloat($("html").css("font-size"));
- return px / unit;
- }
- /**
- *
- * rem 2 px
- */
- wd.display.rem2Px = function (rem) {
- var unit = parseFloat($("html").css("font-size"));
- return rem * unit;
- }
- /*
- *
- 调用示例
- 1:
- wd.flashMsg.show({
- el: $("#domDiv"), // 吸附的元素
- msg: "hi,hello", // 内容
- time: 200000, // 显示的时间,默认 3000,单位毫秒,
- offset: 'd', // 气泡方向,[u]: 上, [d]: 下,当所定的方向无法完全显示内容时,将自动进行调整方向
- arrowsOffset: 'r', // 箭头方位,[l]:左边,[c]:居中,[r]:右,默认为[c]居中
- zindex: 100, // 层级,默认 1996,
- animate: true, // 为真则开启动画,默认开启
- end: function() {
- console.log("销毁后的回调");
- }
- });
- 2:
- wd.flashMsg.show("内容");
- */
- wd.flashMsg = {
- vars: {
- ARROWS_UP_CLASS_NAME: "flashMsg-up",
- ARROWS_DOWN_CLASS_NAME: "flashMsg-down"
- },
- timeout: undefined,
- flashDivTemplate: `<div class="flashMsg-div {flashMsgClassName}" id="flashmsgtipsId" style="left: 0px; top: 0px; display: none;{position}">
- <p>{msg}</p>
- <div class="{arrorwsClassName}" style="{arrorwsStyle}"></div>
- </div>`,
- show: function (param) {
- var setting;
- if(typeof param=="object"){
- setting=param;
- }else{
- setting={
- el:window.event.srcElement,
- msg:param
- }
- }
- if (!this.validation(setting)) {
- return;
- }
- // 获取吸附元素的坐标和宽高
- // var positionObj = this.getAbsolute(document, $(setting.el)[0]);
- var positionObj = $(setting.el).position();
- var offsetObj = $(setting.el).offset();
- var elTop = offsetObj.top;
- var elLeft = offsetObj.left;
- var elWidth = $(setting.el).innerWidth();
- var elHeight = $(setting.el).innerHeight();
- setting.time = isNaN(setting.time)? 3000:setting.time; // 显示时间,默认3秒
- setting.animate = setting.animate == undefined ? true : setting.animate; // 动画,默认为真
- setting.zindex = this.isNull(setting.zindex) ? 1996 : setting.zindex; // 气泡的层级样式,默认层级 999
- setting.offset = this.isNull(setting.offset) ? 'd' : setting.offset; // 气泡的定位样式,默认在下面
- setting.arrowsOffset = this.isNull(setting.arrowsOffset) ? 'l' : setting.arrowsOffset; // 箭头的定位样式,默认左边
- var arrorwsStyle = ""; // 箭头样式
- var flashMsgClassName = setting.animate ? "wd-anim wd-anim-upbit" : ""; // 动画
- var arrorwsClassName = undefined; // 箭头的类名
- // 气泡在上
- if (setting.offset && setting.offset == "u") {
- arrorwsStyle += 'bottom: -10px;left: 7px';
- arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME;
- }
- // 气泡在下
- else if (setting.offset && setting.offset == "d") {
- arrorwsStyle += 'bottom: -10px;left: 7px';
- arrorwsClassName = this.vars.ARROWS_UP_CLASS_NAME;
- }
- // 默认气泡在上
- else {
- arrorwsStyle += 'bottom: -10px;left: 7px';
- arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME;
- }
- this.clearFlashMsg();
- $("body").append(this.getFlashDivTemplate(setting, elTop, elLeft, arrorwsClassName, arrorwsStyle, flashMsgClassName));
- ////////////////////////////// 计算最终的坐标 //////////////////////////////
- var lastTop = -1;
- var flashDom = $("#flashmsgtipsId");
- var flashDomWidth = $(flashDom).innerWidth();
- var flashDomHeight = $(flashDom).innerHeight(); // 是箭头的高度
- $(flashDom).css({
- top: elTop + "px"
- ,left: elLeft + "px"
- });
- // 气泡在上
- if (arrorwsClassName == this.vars.ARROWS_DOWN_CLASS_NAME) {
- var lastDomTop = elTop - flashDomHeight - 16;
- lastTop = elTop - flashDomHeight - 16;
- // flashMsg 元素超出了窗口顶部范围
- if (lastDomTop < 0) {
- // 未尝试过向上的方向
- if (!setting.upFlag) {
- setting.offset = "d";
- setting.downFlag = true;
- this.show(setting);
- return;
- }
- lastTop = flashDomHeight + 6;
- }
- }
- // 气泡在下
- else if (arrorwsClassName == this.vars.ARROWS_UP_CLASS_NAME) {
- lastTop = elTop + elHeight + 20;
- var lastDomTop = elTop + elHeight + flashDomHeight + 20;
- // flashMsg 元素超出了窗口底部范围
- if (lastDomTop > window.innerHeight) {
- // 未尝试过向下的方向
- if (!setting.downFlag) {
- setting.offset = "u";
- setting.upFlag = true;
- this.show(setting);
- return;
- }
- lastTop = window.innerHeight - flashDomHeight - 12;
- }
- } else {
- console.error("arrorwsClassName [" + arrorwsClassName + "] error!");
- return;
- }
- this.settingFlashMsgArrorwsLeft(setting, arrorwsClassName, elWidth, elLeft, flashDom, flashDomWidth);
- $(flashDom).css("top", lastTop + "px");
- $(flashDom).show();
- if(setting.time!=0){
- this.timeout = setTimeout(function () {
- wd.flashMsg.clearFlashMsg(setting);
- }, setting.time);
- }
- },
- /**
- * 清除气泡
- */
- clear: function () {
- this.clearFlashMsg();
- },
- settingFlashMsgArrorwsLeft: function (setting, arrorwsClassName, elWidth, elLeft, flashDom, flashDomWidth) {
- var arrorwsDom = $(flashDom).find("div." + arrorwsClassName);
- // 箭头往左
- if (setting.arrowsOffset == 'l') {
- var arrowLeft = 7;
- $(arrorwsDom).css("left", arrowLeft + "px");
- return;
- }
- // 箭头往右
- else if (setting.arrowsOffset == 'r') {
- var arrowLeft = flashDomWidth - 20;
- // 箭头的位置超出了元素的宽度
- var elEndLeft = elLeft + elWidth;
- if (arrowLeft > elEndLeft) {
- // 元素的一半宽度大于12像素的时候,看着就不会太别扭,放心置 left 为 6px
- if ((elWidth / 2) >= 12) {
- arrowLeft = elEndLeft - 6 - 7;
- }
- // 取半
- else {
- arrowLeft = elLeft + (elWidth / 2);
- }
- }
- $(arrorwsDom).css("left", arrowLeft + "px");
- }
- // 箭头居中
- else {
- /////////////////////// 重新定位气泡 ///////////////////////
- var flashMsgDomLeft = this.settingFlashMsgLeft(flashDom, flashDomWidth, elWidth, elLeft);
- var arrowLeft = elLeft - flashMsgDomLeft + (elWidth / 2);
- $(arrorwsDom).css("left", arrowLeft + "px");
- }
- },
- settingFlashMsgLeft: function (flashDom, flashDomWidth, elWidth, elLeft) {
- var flashMsgDomLeft = elLeft - ((flashDomWidth - elWidth) / 2);
- // 超出了屏幕左边,向右移动
- if (flashMsgDomLeft < 0) {
- flashMsgDomLeft = 6;
- }
- // 超出屏幕右边,向左移动
- else if ((flashMsgDomLeft + flashDomWidth) > window.innerWidth) {
- flashMsgDomLeft -= ((flashMsgDomLeft + flashDomWidth) - window.innerWidth);
- }
- $(flashDom).css("left", flashMsgDomLeft);
- return flashMsgDomLeft;
- },
- clearFlashMsg: function (setting) {
- window.clearTimeout(wd.flashMsg.timeout);
- wd.flashMsg.timeout = undefined;
- $("#flashmsgtipsId").remove(); // 移除掉之前的
- if (setting && setting.end) {
- setting.end();
- }
- },
- getFlashDivTemplate: function (setting, elTop, elLeft, arrorwsClassName, arrowsStyle, flashMsgClassName) {
- var html = this.flashDivTemplate.replace("{position}", "zindex:" + setting.zindex + ";");
- html = html.replace("{arrorwsClassName}", arrorwsClassName);
- html = html.replace("{arrorwsStyle}", arrowsStyle);
- html = html.replace("{msg}", setting.msg);
- html = html.replace("{flashMsgClassName}", flashMsgClassName);
- return html;
- },
- isNull: function (obj) {
- switch (typeof obj) {
- case 'undefined':
- return true;
- case 'string':
- if (obj.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
- break;
- case 'boolean':
- if (!obj) return true;
- break;
- case 'number':
- if (0 === obj || isNaN(obj)) return true;
- break;
- case 'object':
- if (null === obj || obj.length === 0) return true;
- for (var i in obj) {
- return false;
- }
- return true;
- }
- return false;
- },
- notNull: function (obj) {
- return !(this.isNull(obj));
- },
- validation: function (setting) {
- if (this.isNull(setting)) {
- console.error("flashMsg 未获取到 setting!");
- return false;
- }
- if (this.isNull(setting.el)) {
- console.error("flashMsg Setting [el] 属性不能为空 ");
- return false;
- }
- if (this.isNull(setting.msg)) {
- console.error("flashMsg Setting [msg] 属性不能为空 ");
- return false;
- }
- return true;
- },
- getAbsolute: function (reference, target) {
- var result = {
- left: -target.clientLeft,
- top: -target.clientTop
- }
- var node = target;
- while (node != reference && node != document) {
- result.left = result.left + node.offsetLeft + node.clientLeft;
- result.top = result.top + node.offsetTop + node.clientTop;
- node = node.parentNode;
- }
- if (isNaN(reference.scrollLeft)) {
- result.right = document.documentElement.scrollWidth - result.left;
- result.bottom = document.documentElement.scrollHeight - result.top;
- } else {
- result.right = reference.scrollWidth - result.left;
- result.bottom = reference.scrollHeight - result.top;
- }
- return result;
- }
- }
- //隐藏的元素
- wd.display._lockScreenElement = null;
- //有值表示正在执行lockScreen,unlockScreen
- wd.display._lockScreenWaitting = null;
- /**
- * 锁屏
- */
- wd.display.lockScreen = function () {
- "use strict";
- if (wd.display._lockScreenWaitting) return;
- wd.display._lockScreenWaitting = 0;
- $.post("/service?ssServ=lockScreen", {}, function (result) {
- if (wd.display._lockScreenElement) return;
- wd.display._lockScreenElement = $("body > * :visible");
- wd.display._lockScreenElement.hide();
- $("body").append("<div class=\"lockscreenMask\" style=\"position: absolute;left: 0px;top: 0px;width: 100%;height: 100%;background-color: black;z-index: 99;\"></div>");
- }, "json");
- wd.display._lockScreenWaitting = null;
- }
- /**
- * 解锁屏
- */
- wd.display.unlockScreen = function () {
- "use strict";
- if (wd.display._lockScreenWaitting) return;
- wd.display._lockScreenWaitting = 1;
- $.post("/service?ssServ=unlockScreen", {}, function (result) {
- if (!wd.display._lockScreenElement) return;
- wd.display._lockScreenElement.show();
- wd.display._lockScreenElement = null;
- $(".lockscreenMask").remove();
- }, "json");
- wd.display._lockScreenWaitting = null;
- }
- window.enrolDateList = window.enrolDateList || {};
- wd.display.initEnrolDate=function(nameee,mode){
- var hiddenEle=document.querySelector("[name="+nameee+"][type=hidden]");
- if("play"==mode){
- if(!hiddenEle.value)return;
- var year=parseInt( hiddenEle.value.split("-")[0]);
- var month=parseInt( hiddenEle.value.split("-")[1]);
- $(hiddenEle).before('<span>'+year+'年('+(month<=6?'春季':'秋季')+')</span>');
- return;
- }
- function editEnrolDate(name){
- var THIS=this;
- this.onchange=null;
- this.getValue=null;
- this.setValue=null;
- this.container=null;
- var hiddenEle=document.querySelector("[name="+name+"][type=hidden]");
- this.element=hiddenEle;
- var yyy=document.querySelector("[name="+name+"_year]");
- var mmm=document.querySelector("[name="+name+"_month]");
- wd.display.filterInputBox(name+"_year",name+"_month");
- var placeholder=hiddenEle.getAttribute("placeholder");
- if(placeholder){
- yyy.setAttribute("placeholder",placeholder);
- }else{//样式特殊处理
- yyy.style.width="30px";
- }
- this.container=yyy.parentNode;
- this.container.style.display="inline";
- var width=hiddenEle.getAttribute("width");
- if(width)yyy.style.width=width;
- this._initYear=function(y){
- yyy.value=y;
- }
- this._initMonth=function(m){
- /* 改,规范 wdValue= 命名。Lin
- $("[name="+name+"_month][type=button][wdValue="+(m<=6?3:9)+"]").trigger("click");
- */ $("[name="+name+"_month][type=button][ssVal="+(m<=6?3:9)+"]").trigger("click");
- }
- var year,month;
- //默认值为当前时间
- if("0"==hiddenEle.value){
- year=new Date().getUTCFullYear();
- month=new Date().getMonth()+1;
- }else if(hiddenEle.value&&hiddenEle.value.split("-").length>0){
- year=parseInt( hiddenEle.value.split("-")[0]);
- month=parseInt( hiddenEle.value.split("-")[1]);
- }else{
- //默认秋季
- month=9;
- }
- if(year){
- this._initYear(year);
- }
- if(month){
- this._initMonth(month);
- }
- function RebuildingValue(){
- var yy=document.querySelector("[name="+name+"_year]").value;
- var mm=document.querySelector("[name="+name+"_month][type=hidden]").value;
- var hiddenvalue="";
- if(yy&&mm){hiddenvalue=yy+"-0"+mm+"-01"}
- console.log(hiddenvalue);
- document.querySelector("[name="+name+"][type=hidden]").value=hiddenvalue;
- if(THIS.onchange)THIS.onchange();
- }
- RebuildingValue();
- $("[name="+name+"_month][type=button]").on("click",RebuildingValue)
- $("[name="+name+"_year][type=text]").on("click",function(){
- wd.edit.datePicker({dateFmt:'yyyy',onpicked:RebuildingValue,oncleared:RebuildingValue,el:this});
- });
- this.setValue=function(v){
- var v_year=v.split("-")[0];
- var v_month=v.split("-")[1];
- THIS._initYear(v_year);
- THIS._initMonth(v_month);
- }
- this.getValue=function(){
- return THIS.element.value;
- }
- }
- if(window.enrolDateList[nameee])return;
- window.enrolDateList[nameee]=new editEnrolDate(nameee);
- }
- window.defaultValueList = window.defaultValueList || {};
- wd.display.inputDefaultValue=function(name,param){
- //xq[rxnd];
- param=param.replace(/]$/,"");
- var pp=param.split(/\[/);
- var dictName=pp[0];
- var dictParam=pp[1];
- if(window.defaultValueList[name])return;
- window.defaultValueList[name]=new (function(name,n,p){
- var THIS=this;
- this.name=name;
- this.dict=n;
- this.dictParam=p;
- this.dictItem=wd.display.getInputBox(p);
- this._change=function(){
- console.log(THIS);
- var v=THIS.dictItem.getValue();
- $.ajax({
- url: "/service?ssServ=defaultValueTranslate",
- data: {
- dict: THIS.dict,
- param: "{"+THIS.dictParam+":"+v+"}"
- },
- async:true,
- dataType: "json",
- success: function (data) {
- wd.display.getInputBox(THIS.name).setValue(data.result);
- }
- });
- }
- this.dictItem.setChange(this._change);
- if(!wd.display.getInputBox(name).getValue()){
- this._change();
- }
- })(name,dictName,dictParam);
- }
- //下载文件
- wd.display.downloadFile=function(path,downloadName){
- var download=downloadName?("download=\""+downloadName+"\""):"";
- $('<a '+download+' href="'+path+'"><span></span></a>').find("span").trigger("click");
- //关闭圈圈
- wd.display.closeLoad();
- //ScreenOver层移除
- $("#ScreenOver").remove();
- }
- //首页图标
- wd.display.setHomeIconName=function(name){
- var ele =wd.topWindow.document.getElementById('mbwzbj');
- if (ele != null&&name) {
- ele.innerHTML =name;
- }
- }
- /**
- *
- * 弹出右键菜单
- *
- * param {
- * leftClick:true//左击弹菜单
- * }
- *
- * wd.display.showContextMenu("body",[{text:"图片",func:function(element){}}]);
- */
- wd.display.showContextMenu=function(selecter,datas,param){
- var options= $.extend({},{leftClick:false},param)
- for(var i=0;i<datas.length;i++){
- datas[i].value=i;
- }
- var id="what_menu"+new Date().getTime();
- var dom = wd.display.initSelectOption(id);
- wd.display.buildSelectOption(dom,datas, "value", "text", null, false);
- $("body").append(dom);
- var $dom=$(dom).css({position:"absolute"}).hide();
- var triggerElement;
- $dom.on("click",".popupList",function(){
- var v=$(this).attr("value");
- datas[v].func.call(triggerElement,triggerElement);
- $dom.hide();
- return false;
- })
- var eventName=options.leftClick?"contextmenu click":"contextmenu";
- $(document).on(eventName,selecter,function(){
- var offset=$(this).offset();
- dom.style.left=(offset.left+window.event.offsetX)+"px";
- dom.style.top =(offset.top+window.event.offsetY)+"px";
- $(dom).show();
- triggerElement=this;
- return false;
- })
- $(document).on("click",function(){
- $dom.hide();
- })
- $(".content-div,.list-div").scroll(function(){
- $dom.hide();
- })
- }
|