display.js 179 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007
  1. if(typeof window.wd =="undefined"){
  2. window.wd={};
  3. }
  4. if (!wd.display) {
  5. wd.display = {};
  6. };
  7. (function () {
  8. if(wd.topWindow)return;
  9. var currParent = window;
  10. var i = 1;
  11. while (currParent != top) {
  12. try {
  13. currParent.parent[new Date().getMilliseconds()] = 1; // 如果这行不报“没权限错误”,才执行下一行。
  14. currParent = currParent.parent;
  15. } catch (e) {
  16. break;
  17. }
  18. }
  19. /**
  20. * 得到同域的顶层窗口,不直接用top,是因为有把WD的页面嵌入到OA的作子页面的情形 如果顶层窗口直接用top,当顶层窗口是另一网站时,就会报错。
  21. */
  22. wd.topWindow = currParent;
  23. })();
  24. if (!wd.topWindow.wd) {
  25. wd.topWindow.wd = {};
  26. }
  27. if (!wd.topWindow.wd.display) {
  28. wd.topWindow.wd.display = {};
  29. }
  30. /*
  31. * Change log:
  32. *
  33. * --02-14-2014-- function name wd.display.showComponent from title = '<span
  34. * style="font:14px \'宋体\'\;line-height:30px;" >'+title+'</span>'; to title = '<span>'+title+'</span>';
  35. *
  36. *
  37. */
  38. // 初始化滚动条,by SPACE 2019-01-07
  39. // 关闭鼠标加载动画, by SPACE 2019-04-02
  40. $(document).ready(function () {
  41. waitThenInitNiceScorll();
  42. try {
  43. wd.display.closeLoad();
  44. } catch (e) { }
  45. });
  46. function waitThenInitNiceScorll() {
  47. try {
  48. document.onreadystatechange = function () {
  49. if (document.readyState == "complete")
  50. setTimeout("initNiceScorll()", 200);
  51. else
  52. setTimeout("waitThenInitNiceScorll()", 10);
  53. }
  54. } catch (e) {
  55. console.log(e);
  56. }
  57. }
  58. /**
  59. * 初始化滚动条
  60. */
  61. var flag = false;
  62. var resizeScrollIv;
  63. function initNiceScroll() {
  64. try {
  65. // 流程设计器
  66. if ($("#draw_demo").html() != undefined || $("#draw_demo").html() != null || $("#workFlowDesigner").html() != null) {
  67. return;
  68. }
  69. // 网站设计页
  70. if ($("#updateDesignWebpageUrl").val() != null) {
  71. return;
  72. }
  73. // 内容播放器
  74. if ($("#fileProperty").val() != null) {
  75. return;
  76. }
  77. // 大滚动条
  78. var b = $("body");
  79. if ($(b).attr("nicescroll")) {
  80. if ($(b).attr("nicescroll") == 'true') {
  81. loadScorll(b);
  82. }
  83. } else {
  84. loadScorll(b);
  85. }
  86. loadScorll($("iframe[name='ssTabIframe']")); // [name='wdTabFrame']。Lin
  87. loadScorll($(".scrollbar"));
  88. loadScorll($(".mainDiv"));
  89. loadScorll($(".content-div"));
  90. loadScorll(parent.$(".content-div"));
  91. loadScorll($(".CodeMirror-vscrollbar"));
  92. var iframe = window.parent.getIframeByElement(document.body);
  93. var iframeObj = $(iframe);
  94. // loadScorll(iframeObj);
  95. // 小滚动条
  96. loadSmallScorll($(".smallScrollbar"))
  97. // 0.5秒定时监听滚动条变化
  98. clearInterval(resizeScrollIv);
  99. resizeScrollIv = setInterval(function () {
  100. try {
  101. $("body").getNiceScroll().resize();
  102. $("iframe[name='ssTabIframe']").getNiceScroll().resize(); // [name='wdTabFrame']。Lin
  103. $(".mainDiv").getNiceScroll().resize();
  104. $(".scrollbar").getNiceScroll().resize();
  105. $(".content-div").getNiceScroll().resize();
  106. $(parent.$(".content-div")).getNiceScroll().resize(); // $(iframeObj).getNiceScroll().resize();
  107. $(".CodeMirror-vscrollbar").getNiceScroll().resize();
  108. $(".smallScrollbar").getNiceScroll().resize();
  109. } catch (e) {
  110. console.error(e);
  111. }
  112. }, 500);
  113. } catch (e) {
  114. if (!flag) {
  115. flag = true;
  116. // 解决页面引入多个 Jquery 导致 not function 的问题
  117. /* 改。Lin
  118. $("head").append("<script src=\"/wd/js/nicescroll376/jquery.nicescroll.js\"></script>")
  119. */
  120. // $("head").append("<script src=\"/ss/nicescroll/jquery.nicescroll.js\"></script>")
  121. /* 改。Lin
  122. $("head").append("<script src=\"/wd/js/nicescroll376/jquery.nicescroll.iframehelper.min.js\"></script>")
  123. */
  124. // $("head").append("<script src=\"/ss/nicescroll/jquery.nicescroll.iframehelper.min.js\"></script>")
  125. clearInterval(resizeScrollIv);
  126. initNiceScorll();
  127. }
  128. }
  129. }
  130. function getIframeByElement(element) {
  131. var iframe;
  132. $("iframe").each(function () {
  133. if (element.ownerDocument === this.contentWindow.document) {
  134. iframe = this;
  135. }
  136. return !iframe;
  137. });
  138. return iframe;
  139. }
  140. // 大滚动条
  141. function loadScroll(dom) {
  142. try {
  143. if($(dom).attr("wdScroll")=="false")return;
  144. var hori= $(dom).attr("wdScroll")=="XY";
  145. $(dom).niceScroll({
  146. cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
  147. cursorwidth: "6px", // 滚动条的宽度,单位:便素
  148. cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
  149. cursorborderradius: "6px", // 滚动条圆角(像素)
  150. mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
  151. touchbehavior: false, // 激活拖拽滚动
  152. hwacceleration: false, // 激活硬件加速
  153. autohidemode: "true",
  154. background: "transparent", // 轨道的背景颜色
  155. iframeautoresize: true, // 在加载事件时自动重置iframe大小
  156. spacebarenabled: true, // 当按下空格时使页面向下滚动
  157. railpadding: {
  158. top: 0,
  159. right: 4,
  160. left: 4,
  161. bottom: 0
  162. }, // 设置轨道的内间距
  163. horizrailenabled: hori||false, // nicescroll可以管理水平滚动
  164. railalign: "right", // 对齐垂直轨道
  165. railvalign: "bottom", // 对齐水平轨道
  166. preservenativescrolling: true,
  167. enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
  168. enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件
  169. nativeparentscrolling: false //检测内容底部,并让父节点来滚动,作为原生滚动
  170. });
  171. } catch (e) {
  172. throw e;
  173. }
  174. }
  175. //初始化小滚动条
  176. function loadScrollXY(dom) {
  177. try {
  178. if($(dom).attr("wdScroll")=="false")return;
  179. $(dom).niceScroll({
  180. cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
  181. cursorwidth: "6px", // 滚动条的宽度,单位:便素
  182. cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
  183. cursorborderradius: "6px", // 滚动条圆角(像素)
  184. mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
  185. touchbehavior: false, // 激活拖拽滚动
  186. hwacceleration: false, // 激活硬件加速
  187. autohidemode: "true",
  188. background: "transparent", // 轨道的背景颜色
  189. iframeautoresize: true, // 在加载事件时自动重置iframe大小
  190. spacebarenabled: true, // 当按下空格时使页面向下滚动
  191. railpadding: {
  192. top: 0,
  193. right: 4,
  194. left: 4,
  195. bottom: 0
  196. }, // 设置轨道的内间距
  197. horizrailenabled: true, // nicescroll可以管理水平滚动
  198. railalign: "right", // 对齐垂直轨道
  199. railvalign: "bottom", // 对齐水平轨道
  200. preservenativescrolling: true,
  201. enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
  202. enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件
  203. nativeparentscrolling: false //检测内容底部,并让父节点来滚动,作为原生滚动
  204. });
  205. } catch (e) {
  206. throw e;
  207. }
  208. }
  209. // 小滚动条
  210. function loadSmallScroll(dom) {
  211. try {
  212. $(dom).niceScroll({
  213. cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
  214. cursorwidth: "1px", // 滚动条的宽度,单位:便素
  215. cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
  216. cursorborderradius: "1px", // 滚动条圆角(像素)
  217. mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
  218. touchbehavior: false, // 激活拖拽滚动
  219. hwacceleration: false, // 激活硬件加速
  220. background: "transparent", // 轨道的背景颜色
  221. iframeautoresize: true, // 在加载事件时自动重置iframe大小
  222. spacebarenabled: true, // 当按下空格时使页面向下滚动
  223. autohidemode: "true", // leave
  224. railpadding: {
  225. top: 0,
  226. right: 2,
  227. left: 2,
  228. bottom: 0
  229. }, // 设置轨道的内间距
  230. horizrailenabled: false, // nicescroll可以管理水平滚动
  231. railalign: "right", // 对齐垂直轨道
  232. railvalign: "bottom", // 对齐水平轨道
  233. enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
  234. nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动
  235. zindex: "999999"
  236. });
  237. } catch (e) {
  238. console.log(e);
  239. }
  240. }
  241. //原来拼写错误,兼容处理
  242. var initNiceScorll= initNiceScroll;
  243. var loadScorll=loadScroll;
  244. var loadScorllXY=loadScrollXY;
  245. var loadSmallScorll=loadSmallScroll;
  246. /*
  247. * 设置HTML元素属性 @param object o 要设置属性的HTML元素 @param string a 要设置的属性名 @param string
  248. * v 要设置的属性值
  249. */
  250. function setAttribute(o, a, v) {
  251. if (typeof o != 'object' || typeof a != 'string')
  252. return;
  253. a == 'class' ? o.className = v : o.setAttribute(a, v);
  254. }
  255. /*
  256. * 获取HTML元素属性值 @param object o 要获取属性的HTML元素 @param string a 要获取的属性名 @return
  257. * 返回要获取的属性值
  258. */
  259. function getAttribute(o, a) {
  260. if (typeof o != 'object' || typeof a != 'string')
  261. return;
  262. return a == 'class' ? o.className : o.getAttribute(a);
  263. }
  264. /*
  265. * 移除HTML元素属性 @param object o 要移除属性的HTML元素 @param string a 要移除的属性名
  266. */
  267. function removeAttribute(o, a) {
  268. if (typeof o != 'object' || typeof a != 'string')
  269. return;
  270. o.removeAttribute(a);
  271. if (a == 'class')
  272. o.removeAttribute('className');
  273. }
  274. /**
  275. * 去掉所有的html代码
  276. */
  277. wd.display.removeHTMLTag = wd.display.toPlainText = function (str) {
  278. str = str.replace(/<\/?[^>]*>/g, ''); // 去除HTML tag
  279. str = str.replace(/[ | ]*\n/g, '\n'); // 去除行尾空白
  280. // str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
  281. str = str.replace(/&nbsp;/ig, ''); // 去掉&nbsp;
  282. str = str.replace(/\s/g, ''); // 将空格去掉
  283. return str;
  284. };
  285. /**
  286. * 初始化tr的显示样式
  287. */
  288. wd.display.initTrDisplay = function (trContainerNameOrId, // tr标签的直接父级标签的name或id
  289. oddClassName, // 奇数行的tr应用的class类名
  290. evenClassName, // 偶数行的tr应用的class类名
  291. onMouseOverClassName) { // 鼠标放在tr上时,tr应用的css样式
  292. var container = wd.c.g(trContainerNameOrId);
  293. // container 可能为 undefined
  294. if (!container)
  295. return;
  296. var trs = container.childNodes;
  297. if (!trs)
  298. return;
  299. var trIndex = 0;
  300. for (var i = 0; i < trs.length; i++) {
  301. var oneTr = trs[i];
  302. if (!oneTr.tagName || oneTr.tagName != 'TR' ||
  303. oneTr.style.display == 'none')
  304. continue;
  305. trIndex++;
  306. if (trIndex % 2 == 1) { // 奇数行的tr应用的class类名
  307. oneTr.className += " " + oddClassName;
  308. } else {
  309. oneTr.className += " " + evenClassName;
  310. }
  311. oneTr.oriClassName = oneTr.className;
  312. var omocn = new RegExp(" " + onMouseOverClassName);
  313. // console.log(omocn);
  314. oneTr.onmouseover = function () {
  315. this.className = this.className.replace(omocn, "") + " " +
  316. onMouseOverClassName;
  317. }
  318. oneTr.onmouseout = function () {
  319. this.className = this.className.replace(omocn, "");
  320. }
  321. }
  322. };
  323. wd.display.showDynamicParamDialog = function (url, datas) {
  324. eval(wd.display.replaceDynamicParam(url.toString(), datas));
  325. }
  326. wd.display.createMaskDiv = function (containerObj, currWindow, zIndex) { // 创建遮罩层
  327. var ele = currWindow.document.getElementsByTagName('BODY')[0];
  328. var newID = new Date().getTime();
  329. if (!(typeof zIndex != 'undefined' && zIndex)) {
  330. zIndex = 100001;
  331. }
  332. var coverDiv = document.createElement("div");
  333. coverDiv.id = newID;
  334. // coverDiv.style.cssText = 'display: none;' + 'position: absolute;' +
  335. // 'top: 0%;' + 'left: 0%;' + 'width: 100%;' + 'height: 100%;' +
  336. // 'background-color: #EEEEEE;' + '-moz-opacity: 0.5;' +
  337. // 'opacity: .50;' + 'filter: alpha(opacity=50);';
  338. coverDiv.setAttribute("class", "wdMaskDiv dialog-mask");
  339. coverDiv.style.zIndex = zIndex - 1;
  340. ele.appendChild(coverDiv);
  341. // coverDiv.style.display = 'block';
  342. var W = (currWindow.document.body.scrollLeft + currWindow.document.body.scrollWidth) ||
  343. (currWindow.document.documentElement.scrollLeft + currWindow.document.documentElement.scrollWidth);
  344. var H = (currWindow.document.body.scrollTop + currWindow.document.body.scrollHeight) ||
  345. (currWindow.document.documentElement.scrollTop + currWindow.document.documentElement.scrollHeight);
  346. coverDiv.style.width = W + 'px';
  347. coverDiv.style.height = H + 'px';
  348. var maskContainer = containerObj.mask;
  349. if (!maskContainer) {
  350. containerObj.mask = [];
  351. }
  352. containerObj.mask.push(newID);
  353. };
  354. //按钮 [id,pos,title,label,className]
  355. wd.display.wdButtons = [
  356. //功能: 旧UI弹窗右上角按钮图标升级为 icon-base(先改 help/lock/close)by xu 20251223
  357. ["wdHelp", 3, "帮助", "帮助", "dialog-toolbar-icon icon-help"],
  358. ["CMS_download", 3, "下载", "下载", "icon-download"],
  359. ["wdShare", 3, "收藏", "收藏", "icon-favorite"],
  360. ["wdShared", 3, "已收藏", "已收藏", "icon-favoriteOn"],
  361. ["editWdHelp", 3, "编辑帮助", "编辑帮助", "icon-setHelp"],
  362. ["editWdHelp_save", 3, "编辑帮助保存", "编辑帮助保存", "invertIcon-save"],
  363. //功能: icon-base 图标名调整:编辑选项卡 icon-ptab(弹窗顶部用细体)by xu 20251224
  364. ["wdTab", 3, "编辑选项卡", "编辑选项卡", "dialog-toolbar-icon icon-ptab"],
  365. //功能: icon-base 图标名调整:保存选项卡使用 icon-save(不再用 invertIcon-save)by xu 20251225
  366. ["wdTab_save", 3, "保存选项卡", "保存选项卡", "invertIcon-save dialog-toolbar-icon icon-save"],
  367. //功能: icon-base 图标名调整:个人选值 icon-pval(弹窗顶部用细体)by xu 20251224
  368. ["wdRecord", 3, "个人选值", "个人选值", "dialog-toolbar-icon icon-pval"],
  369. //功能: icon-base 图标名调整:个人选值保存使用 icon-save(不再用 invertIcon-save)by xu 20251225
  370. ["wdRecord_save", 3, "个人选值保存", "个人选值保存", "invertIcon-save dialog-toolbar-icon icon-save"],
  371. ["CMS_fullscreen", 3, "全屏", "全屏", "dialog-restoreButton"],
  372. ["CMS_nrProperty", 3, "内容属性", "内容属性", "icon-property"],
  373. ["change_on", 3, "变动查看-开", "变动查看-开", "dialog-changeOnButton"],
  374. ["change_off", 3, "变动查看-关", "变动查看-关", "dialog-changeButton"],
  375. ["lockScreen", 3, "锁定", "锁定", "dialog-toolbar-icon icon-lock"],
  376. ["wdPrint", 3, "打印", "打印", "icon-print"],
  377. ["wdBatchPrint", 3, "批量打印", "批量打印", "icon-print"],
  378. ["wdHelpCopyhexcode", 3, "复制帮助代码", "复制帮助代码", "icon-key"]
  379. //功能: SsSubTab 菜单模式切换按钮改为按需创建,避免所有弹窗都出现 by xu 20251224
  380. ];
  381. wd.display.initStyleWdButtons = function () {
  382. for (var i = 0; i < wd.display.wdButtons.length; i++) {
  383. var className = "dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default";
  384. wd.topWindow.$("div.dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default").addClass(wd.display.wdButtons[i][4]);
  385. }
  386. // 特殊处理close,因为如果close和dhtmlx的close冲突,会隐藏原生,新增一个按钮
  387. var className = "dhtmlx_button_close_default";
  388. //功能: 弹窗关闭按钮使用 icon-base(避免依赖 svg/png)by xu 20251223
  389. wd.topWindow.$("div.dhtmlx_button_close_default").removeClass(className).addClass("dialog-toolbar-close-icon icon-close");
  390. }
  391. /**
  392. * 添加隐藏按钮
  393. * @param {Object} w
  394. */
  395. wd.display.addWdUserButton = function (w) {
  396. var buttonType = wd.display.wdButtons;
  397. for (var i = 0; i < buttonType.length; i++) {
  398. //添加按钮
  399. w.addUserButton(buttonType[i][0], buttonType[i][1], buttonType[i][2], buttonType[i][3], buttonType[i][4]);
  400. //隐藏按钮
  401. w.button(buttonType[i][0]).hide();
  402. // console.log(buttonType[i][0]+":"+w.button(buttonType[i][0]).isHidden())
  403. }
  404. wd.display.initStyleWdButtons();
  405. }
  406. wd.display.showAllWdUserButton = function (w, nolimit) {
  407. //解除限制
  408. if (nolimit) {
  409. w.unAllowButton = false;
  410. } else {
  411. w.unAllowButton = true;
  412. }
  413. var buttonType = wd.display.wdButtons;
  414. for (var i = 0; i < buttonType.length; i++) {
  415. if (w.button(buttonType[i][0]).isHidden() == false) {
  416. w.button(buttonType[i][0]).show();
  417. }
  418. }
  419. }
  420. wd.display.hideAllWdUserButton = function (w) {
  421. w.unAllowButton = true;
  422. var buttonType = wd.display.wdButtons;
  423. for (var i = 0; i < buttonType.length; i++) {
  424. w.button(buttonType[i][0]).style.display = "none";
  425. }
  426. }
  427. /**
  428. * 添加弹窗事件
  429. * @param {Object} w
  430. */
  431. wd.display.addComponentEvent = function (w) {
  432. // 按钮:设置wdRecord
  433. w.getFrame().addEventListener("load", function () {
  434. var iframeWindow = w.getFrame().contentWindow
  435. if ("0" == iframeWindow.loginStatus)
  436. return;
  437. //wdShare
  438. var wdShare = function () {
  439. this.win = null;
  440. this.button;
  441. this.init = function (w) {
  442. this.win = w;
  443. // var wdDialogWin = iframeWindow.document.querySelector("wdDialog[collect=true]")
  444. // if (!wdDialogWin)
  445. // return;
  446. this.sendRequest("query", (function () {
  447. return function (data) {
  448. if (data == 1) {
  449. //已分享
  450. this.addButton("wdShared")
  451. } else if (data == 0) {
  452. //未分享
  453. this.addButton("wdShare")
  454. }
  455. }
  456. })())
  457. }
  458. this.addButton = function (buttontype) {
  459. var THIS = this;
  460. //恢复隐藏按钮
  461. if (this.win.button(buttontype) && this.win.button(buttontype) != null) {
  462. this.win.button(buttontype).show();
  463. } else {
  464. // if (buttontype == "wdShared") {
  465. // this.win.addUserButton(buttontype, 3, "已收藏", "已收藏")
  466. // } else if (buttontype == "wdShare") {
  467. // this.win.addUserButton(buttontype, 3, "未收藏", "未收藏")
  468. // }
  469. }
  470. this.win.button(buttontype).onclick = function () {
  471. THIS.wdshareClick(buttontype)
  472. }
  473. }
  474. this.wdshareClick = function (buttontype) {
  475. var type;
  476. //已收藏点击:取消收藏
  477. //未收藏点击:
  478. if (buttontype == "wdShared") {
  479. type = "delete"
  480. } else if (buttontype == "wdShare") {
  481. type = "add"
  482. }
  483. this.sendRequest(type, function (data) {
  484. if (data == 1) {
  485. this.win.button(buttontype).hide();
  486. this.addButton(buttontype == "wdShared" ? "wdShare" : "wdShared")
  487. } else if (data == 0) {
  488. console.log(data);
  489. } else {
  490. console.log(data)
  491. }
  492. });
  493. }
  494. this.sendRequest = function (type, callback) {
  495. var wdsharetype;
  496. if (type == "query") {
  497. wdsharetype = "";
  498. } else if (type == "add") {
  499. wdsharetype = 1;
  500. } else if (type == "delete") {
  501. wdsharetype = 0;
  502. } else {
  503. alert("type 值超出范围:"+ type) // ("我是不可能出现的!")。Lin
  504. }
  505. var THIS = this;
  506. $.post("/service?ssServ=wdShare", {
  507. wdsharetype: wdsharetype,
  508. wdshareurl: iframeWindow.window.location.href
  509. }, function (data) {
  510. if (callback) {
  511. callback.call(THIS, data)
  512. }
  513. })
  514. }
  515. }
  516. new wdShare().init(w);
  517. }, false);
  518. }
  519. //功能: SsSubTab 菜单模式切换按钮启用(由页面主动调用)by xu 20251223
  520. wd.display.enableSsSubTabMenuModeButton = function () {
  521. try {
  522. var wdDialogId = wd.display.getwdDialogId();
  523. if (!wdDialogId) return false;
  524. if (!wd.topWindow || !wd.topWindow.dhxWins) return false;
  525. var w = wd.topWindow.dhxWins.window(wdDialogId);
  526. if (!w) return false;
  527. //功能: 打印调试信息(定位点击无反应问题)by xu 20251224
  528. try { console.log("[SsSubTabMenuMode] enable start, wdDialogId=", wdDialogId); } catch (e) { }
  529. //功能: 获取当前弹窗的 DOM 容器(用于精准定位按钮,避免多弹窗 querySelector 选错)by xu 20251224
  530. var iframeEl = null;
  531. //功能: 优先通过 wdDialogId 精确定位 iframe(避免误拿到 SsSubTab 内部 iframe)by xu 20251224
  532. try {
  533. var ifs = wd.topWindow.document.getElementsByTagName("IFRAME");
  534. for (var ii = 0; ii < ifs.length; ii++) {
  535. var iframeObj = ifs[ii];
  536. var tempId = iframeObj.getAttribute("wdDialogId");
  537. if (!tempId && iframeObj.dataset) {
  538. tempId = iframeObj.dataset["wdDialogId"];
  539. }
  540. if (tempId && (tempId + "") === (wdDialogId + "")) {
  541. iframeEl = iframeObj;
  542. break;
  543. }
  544. }
  545. } catch (e) { }
  546. if (!iframeEl) {
  547. try { iframeEl = w.getFrame && w.getFrame(); } catch (e) { }
  548. }
  549. if (!iframeEl) {
  550. try { console.log("[SsSubTabMenuMode] fail: no iframeEl"); } catch (e) { }
  551. return false;
  552. }
  553. var winEl = null;
  554. try { winEl = iframeEl.closest && iframeEl.closest("div.dhtmlx_window_active,div.dhtmlx_window_inactive"); } catch (e) { }
  555. if (!winEl) {
  556. try { console.log("[SsSubTabMenuMode] fail: no winEl"); } catch (e) { }
  557. return false;
  558. }
  559. //功能: 精准获取当前弹窗的按钮 DOM(dhtmlx 会切换 _default/_over_default 等)by xu 20251224
  560. var btnEl = null;
  561. try { btnEl = winEl.querySelector("div[class*='dhtmlx_button_ssSubTabMenuMode_']"); } catch (e) { }
  562. if (!btnEl) {
  563. //功能: 仅在使用 SsSubTab 的页面按需创建按钮,避免所有弹窗默认带出 by xu 20251224
  564. //功能: icon-base 图标名调整:弹窗顶部菜单模式按钮使用细体 icon-autoTxt / icon-fix by xu 20251224
  565. try { w.addUserButton("ssSubTabMenuMode", 3, "菜单模式", "菜单模式", "dialog-toolbar-icon icon-autoTxt"); } catch (e) { }
  566. try { wd.display.initStyleWdButtons && wd.display.initStyleWdButtons(); } catch (e) { }
  567. try { btnEl = winEl.querySelector("div[class*='dhtmlx_button_ssSubTabMenuMode_']"); } catch (e) { }
  568. if (!btnEl) {
  569. // 页面可能还没创建完成,交给调用方重试 by xu 20251224
  570. try { console.log("[SsSubTabMenuMode] fail: button dom not found"); } catch (e) { }
  571. return false;
  572. }
  573. //功能: 打印调试信息(按钮按需创建成功)by xu 20251224
  574. try { console.log("[SsSubTabMenuMode] button created"); } catch (e) { }
  575. }
  576. var btn = null;
  577. try { btn = w.button && w.button("ssSubTabMenuMode"); } catch (e) { }
  578. //功能: 弹窗右上角切换按钮放到最左边(flex 顺序)by xu 20251223
  579. try {
  580. var btnContainer = btnEl.parentNode;
  581. if (btnContainer && btnContainer.firstElementChild && btnContainer.firstElementChild !== btnEl) {
  582. btnContainer.insertBefore(btnEl, btnContainer.firstElementChild);
  583. }
  584. } catch (e) { }
  585. //功能: 旧UI弹窗中使用顶部按钮控制 SsSubTab,隐藏组件内置切换按钮 by xu 20251223
  586. try { document.documentElement && document.documentElement.classList && document.documentElement.classList.add("ss-sub-tab-dialog"); } catch (e) { }
  587. // 确保组类存在 by xu 20251223
  588. try { btnEl.classList && btnEl.classList.add("dialog-toolbar-icon"); } catch (e) { }
  589. //功能: 获取 iframeWindow(用于 click 时动态拿 API,避免 enable 时机问题)by xu 20251224
  590. var iframeWindow = null;
  591. try { iframeWindow = iframeEl && iframeEl.contentWindow; } catch (e) { }
  592. if (!iframeWindow) {
  593. try { console.log("[SsSubTabMenuMode] fail: no iframeWindow"); } catch (e) { }
  594. return false;
  595. }
  596. //功能: 递归在多层 iframe 中查找 SsSubTab API(objPlay -> objInfo -> ss-sub-tab)by xu 20251224
  597. var findSsSubTabCtx = function (win, depth) { //功能 by xu 20251224
  598. if (!win) return null;
  599. if (depth > 6) return null;
  600. try {
  601. var api =
  602. (win.SS && win.SS.dom && win.SS.dom.ssSubTabApi) ||
  603. (win.ss && win.ss.dom && win.ss.dom.ssSubTabApi);
  604. var left = win.document && win.document.querySelector && win.document.querySelector(".project-edit-container .left-side");
  605. if (api && api.toggleMenuMode && left) {
  606. return { win: win, api: api, leftSide: left };
  607. }
  608. } catch (e) { }
  609. try {
  610. var ifs = win.document && win.document.getElementsByTagName ? win.document.getElementsByTagName("IFRAME") : [];
  611. if (!ifs || !ifs.length) return null;
  612. // 限制扫描数量,避免极端页面卡顿 by xu 20251224
  613. var maxScan = Math.min(ifs.length, 30);
  614. for (var i = 0; i < maxScan; i++) {
  615. var cw = null;
  616. try { cw = ifs[i].contentWindow; } catch (e) { cw = null; }
  617. if (!cw) continue;
  618. var r = findSsSubTabCtx(cw, depth + 1);
  619. if (r) return r;
  620. }
  621. } catch (e) { }
  622. return null;
  623. };
  624. var updateIcon = function () { //功能 by xu 20251224
  625. // dhtmlx hover/active 会切换 class(_default/_over_default 等),这里每次取当前节点 by xu 20251224
  626. var currentBtnEl = null;
  627. try { currentBtnEl = winEl.querySelector("div[class*='dhtmlx_button_ssSubTabMenuMode_']"); } catch (e) { }
  628. if (!currentBtnEl || !currentBtnEl.classList) return;
  629. //功能: 优先从 topWindow 的 apiMap 取(解决 objPlay->objInfo 这种多层iframe拿不到 SS 的问题)by xu 20251224
  630. var ctx = null;
  631. try {
  632. var apiFromTop = wd.topWindow && wd.topWindow.__ssSubTabApiMap && wd.topWindow.__ssSubTabApiMap[wdDialogId];
  633. if (apiFromTop && apiFromTop.toggleMenuMode) {
  634. ctx = { api: apiFromTop, leftSide: null };
  635. }
  636. } catch (e) { }
  637. if (!ctx) {
  638. ctx = findSsSubTabCtx(iframeWindow, 0);
  639. }
  640. var mode = "collapse";
  641. try {
  642. mode = (ctx && ctx.api && ctx.api.getMenuMode && ctx.api.getMenuMode()) || (ctx && ctx.leftSide && ctx.leftSide.getAttribute("data-mode")) || "collapse";
  643. } catch (e) { }
  644. currentBtnEl.classList.add("dialog-toolbar-icon");
  645. //功能: icon-base 图标名调整:弹窗顶部菜单模式按钮 icon-autoTxt / icon-fix by xu 20251224
  646. currentBtnEl.classList.remove("icon-autoTxt", "icon-fix");
  647. if (mode === "fixed") {
  648. currentBtnEl.classList.add("icon-fix");
  649. currentBtnEl.setAttribute("title", "固定菜单");
  650. } else {
  651. currentBtnEl.classList.add("icon-autoTxt");
  652. currentBtnEl.setAttribute("title", "悬浮菜单");
  653. }
  654. };
  655. //功能: 用事件委托绑定点击(避免 dhtmlx 切换 class/替换节点导致点击失效)by xu 20251224
  656. try {
  657. var btnsEl = winEl.querySelector("div.dhtmlx_wins_btns");
  658. if (btnsEl && btnsEl.getAttribute("data-ss-sub-tab-menu-bound") !== "1") {
  659. btnsEl.setAttribute("data-ss-sub-tab-menu-bound", "1");
  660. btnsEl.addEventListener("click", function (e) {
  661. try {
  662. var t = e && e.target;
  663. var hit = t && t.closest ? t.closest("div[class*='dhtmlx_button_ssSubTabMenuMode_']") : null;
  664. if (!hit) return;
  665. //功能: 优先从 topWindow 的 apiMap 取(解决 objPlay->objInfo)by xu 20251224
  666. var ctx = null;
  667. var ssSubTabApi = null;
  668. try {
  669. ssSubTabApi = wd.topWindow && wd.topWindow.__ssSubTabApiMap && wd.topWindow.__ssSubTabApiMap[wdDialogId];
  670. } catch (ee) { ssSubTabApi = null; }
  671. if (ssSubTabApi && ssSubTabApi.toggleMenuMode) {
  672. ctx = { api: ssSubTabApi };
  673. } else {
  674. ctx = findSsSubTabCtx(iframeWindow, 0);
  675. ssSubTabApi = ctx && ctx.api;
  676. }
  677. if (!ssSubTabApi || !ssSubTabApi.toggleMenuMode) {
  678. try {
  679. console.log(
  680. "[SsSubTabMenuMode] click but api not ready",
  681. "href=", iframeWindow.location && iframeWindow.location.href,
  682. "foundCtx=", !!ctx
  683. );
  684. } catch (ee) { }
  685. return;
  686. }
  687. //功能: 打印调试信息(点击事件触发)by xu 20251224
  688. try { console.log("[SsSubTabMenuMode] click, before=", ssSubTabApi.getMenuMode && ssSubTabApi.getMenuMode()); } catch (ee) { }
  689. try { ssSubTabApi.toggleMenuMode(); } catch (ee) { console.log(ee); }
  690. try { console.log("[SsSubTabMenuMode] click, after=", ssSubTabApi.getMenuMode && ssSubTabApi.getMenuMode()); } catch (ee) { }
  691. setTimeout(updateIcon, 0);
  692. } catch (ee) {
  693. console.log(ee);
  694. }
  695. }, false);
  696. }
  697. } catch (e) { }
  698. updateIcon();
  699. try { btn && btn.show && btn.show(); } catch (e) { }
  700. return true;
  701. } catch (e) {
  702. console.log(e);
  703. return false;
  704. }
  705. };
  706. /**
  707. * 将url中的动态参数替换成指定的值
  708. * 如果param为空,则参数的值在html元素中寻找,如果param的值不为空,则在param中获取
  709. * 对于现在的服务调用,采用匹配进行
  710. * @service{name:"xxx",dest:"xxx",param:{"xxx":"xxx","data":"wdVal{data}"}}@
  711. * 中的"data":"wdVal{data}"
  712. * 如果要添加额外变量参数,有两种方法
  713. * 1.在html中 添加 input标签 name对应 data,把需要的值传入value(即是用element获取) <input name="data">
  714. * 2.如果是js变量,通过传入json变量覆盖,例:
  715. * var json = JSON.parse('{"data":"' + encodeURI(obj) + '"}');
  716. * var url = '@service{name:"cd_ydck",dest:"cd_ydck",show:"wdDialog",param:{"cdydid":"wdVal{data}"}}@';
  717. * url = wd.display.replaceDynamicParam(url, json);
  718. * eval(url);
  719. */
  720. wd.display.replaceDynamicParam = function (url, param) {
  721. /* 再改,规范 wdVal{ 命名。Lin
  722. var reg = /wdVal\{\s*[A-Za-z0-9_]*\s*\}/g;
  723. */var reg = /ssVal\{\s*[A-Za-z0-9_]*\s*\}/g;
  724. //如果没有匹配的动态参数
  725. if (!reg.test(url)) {
  726. return url;
  727. } else {
  728. var result = url.match(reg);
  729. for (var i = 0; i < result.length; i++) {
  730. var source = result[i];
  731. //获取动态参数的name
  732. var name = source.trim().substring(6, source.trim().length - 1);
  733. //增加空字符串的可能性
  734. if (param && param[name] != undefined) {
  735. url = url.replace(source, param[name]);
  736. } else {
  737. var value = document.getElementsByName(name)[0].value;
  738. url = url.replace(source, value);
  739. }
  740. }
  741. return url;
  742. }
  743. };
  744. wd.display.Yi = 49;
  745. wd.display.Xi = 23;
  746. wd.display.addDialogLine = function (w) {
  747. if (!w) {
  748. var wdDialogId = wd.display.getwdDialogId();
  749. w = wd.topWindow.dhxWins.window(wdDialogId);
  750. }
  751. $(w).find(".dhtmlx_wins_body_inner").removeClass("dhtmlx_wins_body_inner_noborder").addClass(
  752. "dhtmlx_wins_body_inner_border");
  753. }
  754. wd.display.removeDialogLine = function (w) {
  755. if (!w) {
  756. var wdDialogId = wd.display.getwdDialogId();
  757. w = wd.topWindow.dhxWins.window(wdDialogId);
  758. }
  759. $(w).find(".dhtmlx_wins_body_inner").removeClass("dhtmlx_wins_body_inner_border").addClass(
  760. "dhtmlx_wins_body_inner_noborder");
  761. }
  762. /**
  763. * 方法中文名:切换DOM元素显示 显示第二个参数数组指定的所有DOM元素,隐藏第三个参数数组指定的所有DOM元素,
  764. * 第四个参数为选填,如果填了,则第二个参数中的第一个iframe将加载此参数(url)指定的页面
  765. *
  766. *
  767. * demo:
  768. * 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:""})
  769. * 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:""})
  770. *
  771. */
  772. wd.display.showComponent = function (params) {
  773. if (typeof beacon != 'undefined' && beacon.shouldOpenOtherBrowser && beacon.shouldOpenOtherBrowser()) {
  774. var url = params.url;
  775. if (url.startsWith("/")) {
  776. url = window.location.origin + url;
  777. }
  778. beacon.openWindow(params.title, params.width, params.height, url);
  779. return;
  780. }
  781. // 加载鼠标动画 by SPACE 2019-04-02
  782. wd.display.showLoad();
  783. //alert(top.window.document.querySelector('iframe[name="win2"]'));
  784. if (window.event) {
  785. if (window.event.stopPropagation) {
  786. window.event.stopPropagation();
  787. } else {
  788. window.event.cancelBubble = true;
  789. }
  790. }
  791. var fullScreenLimitHeight = true; // 全屏时窗口的高度与window.innerHeight一致
  792. var showNameOrId = params.show; // 由需要显示的DOM元素的NAME或ID组成的数组或字符串,注意:
  793. // 如果含有值’wdDialog’,则弹出dhtmlxWindows窗口,否则只是切换部件显示
  794. var hideNameOrId = params.hide; // 由需要隐藏的DOM元素的NAME或ID组成的数组或字符串(可选参数,可以不填)
  795. if (!params["getSize"]) {
  796. params["getSize"] = "1";
  797. params["wdDialogId"] = new Date().getTime();
  798. /* 再改,规范 &token= 命名。Lin
  799. * IDEA = Redundant character escape '\=' in RegExp
  800. * IDEA = Redundant character escape '\&' in RegExp
  801. var exec = /token\=([^\&]*)/.exec(params.url)
  802. */ var exec = /ssToken=([^&]*)/.exec(params.url)
  803. if (exec) {
  804. $.ajax({
  805. url: "/service?ssServ=loadPageParm",
  806. data: {
  807. "tokenstring": exec[1]
  808. },
  809. async: true,
  810. timeout: 10000,
  811. type: "POST",
  812. dataType: "json",
  813. error: function (data) {
  814. console.log(arguments);
  815. wd.display.showComponent(params);
  816. },
  817. success: function (result) {
  818. params = $.extend(params, result, { title: params.title });
  819. wd.display.showComponent(params);
  820. }
  821. })
  822. return params["wdDialogId"];
  823. }
  824. }
  825. var url = wd.display.replaceDynamicParam(params.url); // 参数showElemNameOrIdArr中的第一个iframe将加载此URL的页面(可选参数,可以不填)
  826. var width = (parseInt(params.width) || 100) + this.Xi; // 当要弹出窗口宽度,单位为px
  827. ///??? 有空再去掉参数 high -- 统一用 height???Lin ///
  828. var high = (parseInt(params.high) || parseInt(params.height) || 100) + this.Yi; // 当要弹出窗口宽度,单位为px
  829. var showTitle = params.showTitle || false;
  830. //弹出窗口自适应高度
  831. if (!!params.minHeight && !!params.maxHeight) {
  832. params.minHeight = parseInt(params.minHeight);
  833. params.maxHeight = parseInt(params.maxHeight);
  834. if (params.minHeight + this.Yi > wd.topWindow.innerHeight) {
  835. high = params.minHeight + this.Yi;
  836. showNameOrId = 'wdFullScreen';
  837. fullScreenLimitHeight = false;
  838. } else if (params.maxHeight + this.Yi < wd.topWindow.innerHeight) {
  839. high = params.maxHeight + this.Yi;
  840. } else {
  841. /* 母体里的,showTitle="false" -- if(showTitle) 成立。Lin
  842. * PMS 里的 showTitle=false -- if(showTitle) 不成立
  843. * 先改为 high = wd.topWindow.innerHeight;
  844. * 先不改 */
  845. if (showTitle)
  846. high = wd.topWindow.innerHeight;
  847. else
  848. showNameOrId = 'wdFullScreen';
  849. }
  850. }
  851. url=wd.base.setRowCountPerPage(url,high-this.Yi,width);
  852. var title = params.title || "无题,可能没找到部件"; // 窗口标题,(可选参数,可以不填)
  853. var form = params.form; // 需要提交的form名字
  854. // var wdDialogId = params.wdDialogId;//部件ID
  855. var wdDialogId = params.wdDialogId || new Date().getTime(); // 部件ID
  856. wd.display.winWidth = width;
  857. wd.display.winHeight = high;
  858. if (form) {
  859. wd.topWindow.wd.display.targetForm = window.document
  860. .getElementsByName(form)[0];
  861. wd.topWindow.wd.display.targetUrl = url;
  862. url = "/wd/js/cloneForm/cloneForm.jsp";
  863. }
  864. if (title) {
  865. // title = '<span style="font:14px
  866. // \'宋体\'\;line-height:30px;" >'+title+'</span>';
  867. title = '<span style="padding:5px;">' +
  868. '<a class="dialog-title" target="_blank" onclick="return false;" href="' +
  869. url +
  870. '&wdTitle=' +
  871. title +
  872. '">' +
  873. title +
  874. '</a>' +
  875. '<a class="secondTitle" target="_blank" onclick="return false;" href="javascript:void(0);"></a>' +
  876. '</span>';
  877. }
  878. if (showNameOrId) { // 如果需要显示部件
  879. if (typeof (showNameOrId) != 'object') { // 如果传入的不是数组
  880. var arr = [];
  881. arr.push(showNameOrId);
  882. showNameOrId = arr; // 统一为数组
  883. }
  884. var useUrl = true;
  885. var hasWdDialog = false;
  886. for (var i = 0; i < showNameOrId.length; i++) {
  887. var oneNameOrId = showNameOrId[i];
  888. if (oneNameOrId == 'wdDialog') { // 这里应该不是 <wdDialog。Lin
  889. hasWdDialog = true;
  890. break;
  891. }
  892. }
  893. for (var i = 0; i < showNameOrId.length; i++) {
  894. var oneNameOrId = showNameOrId[i];
  895. var selfParam = oneNameOrId.self;
  896. var titleParam = oneNameOrId.title;
  897. var nameParam = oneNameOrId.name;
  898. var sizeParam = oneNameOrId.size;
  899. var positionParam = oneNameOrId.position;
  900. var btnParam = oneNameOrId.button;
  901. // 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:""})
  902. if (typeof (oneNameOrId) == 'object') {
  903. if (oneNameOrId.size) {
  904. var arr = oneNameOrId.size.split("*");
  905. var width = parseInt(arr[0]) + 15; // 当要弹出窗口宽度,单位为px
  906. var high = parseInt(arr[1]) + 38; // 当要弹出窗口宽度,单位为px
  907. }
  908. oneNameOrId = oneNameOrId.name;
  909. }
  910. var storage = window.localStorage;
  911. if (oneNameOrId == 'wdDialog') { // "如果要弹出窗口"。这里应该不是 <wdDialog。Lin
  912. // 把当前窗口的window对象,保存到wd.topWindow窗口中,以便关闭窗口时使用
  913. if (!wd.topWindow.wd.display.wdDialogOpeners)
  914. wd.topWindow.wd.display.wdDialogOpeners = {};
  915. wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
  916. var windowId = wdDialogId;
  917. // /当前可视区域
  918. var sw = wd.topWindow.screen.availWidth;
  919. var sh = wd.topWindow.screen.availHeight;
  920. // 根据可是区域调整窗口
  921. var cenFlag = false; // 超过时不居中
  922. if (width > (sw - 20)) {
  923. width = sw - 20;
  924. };
  925. if (high > (sh - 20))
  926. high = sh - 20;
  927. if (width > sw || high > sh)
  928. cenFlag = true;
  929. // /
  930. if (!wd.topWindow.dhxWins)
  931. wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
  932. var w = wd.topWindow.dhxWins.createWindow(windowId, 0, 0, width, high);
  933. w.keepInViewport(true); // 保持在窗口内
  934. if (!cenFlag)
  935. w.center(); // 居中
  936. w.setText(title); // 设置窗口标题
  937. //2021-09-06 新增,当url超长时候,改成form提交
  938. var hasInvalidUrlChar = false;
  939. var invalidUrlChar = ['{', '}', '[', ']', '|'];
  940. for (var _ici = 0; _ici < invalidUrlChar.length; _ici++) {
  941. if (url.indexOf(invalidUrlChar[_ici]) > -1) {
  942. hasInvalidUrlChar = true;
  943. break;
  944. }
  945. }
  946. if (hasInvalidUrlChar || (url && url.length > 1000)) {
  947. hasInvalidUrlChar && console.log("url中有非法字符");
  948. console.log("触发了form提交表单~,url长度:"+url.length);
  949. w.attachEvent("onContentLoaded", function () {
  950. try {
  951. if (this.getFrame().getAttribute("formload")) {
  952. return;
  953. }
  954. var myDoc = this.getFrame().contentDocument;
  955. var index = url.indexOf("?");
  956. index = index < 0 ? url.length - 1 : index;
  957. var base = url.substring(0, index);
  958. var params = url.substring(index + 1);
  959. var paramarr = params.split("&");
  960. var myform = myDoc.createElement("form");
  961. myform.setAttribute("action", base);
  962. myform.setAttribute("method", "post");
  963. myDoc.body.appendChild(myform);
  964. for (var pi = 0; pi < paramarr.length; pi++) {
  965. var pstr = paramarr[pi];
  966. var pei = pstr.indexOf("=");
  967. pei = pei < 0 ? pstr.length : pei;
  968. var k = pstr.substring(0, pei);
  969. var v = pstr.substring(pei + 1);
  970. var myInput = myDoc.createElement("input");
  971. myInput.setAttribute("type", "hidden");
  972. myInput.setAttribute("name", k);
  973. myInput.value =decodeURIComponent(v);//可能会有url编码了的情况
  974. myform.appendChild(myInput);
  975. }
  976. myform.submit();
  977. this.getFrame().setAttribute("formload", "true")
  978. } catch (e) {
  979. console.error(e)
  980. }
  981. });
  982. w.attachURL("javascript:false;");
  983. } else {
  984. w.attachURL(url); // 跳到此URL
  985. }
  986. useUrl = false;
  987. w.setModal(true); // 设置模式窗口
  988. w.bringToTop(); // 置顶
  989. wd.display.addWdUserButton(w);
  990. wd.display.addComponentEvent(w);
  991. wd.display.addDialogLine(w);
  992. // 改变按钮的类样式名
  993. // var buttonType = wd.display.wdButtons;
  994. // for (var i = 0; i < buttonType.length; i++) {
  995. // w.button(buttonType[i][0]).className = "dhtmlx_wins_btns_button " + buttonType[i][4];
  996. // }
  997. // 隐藏不需要的按钮
  998. w.clearIcon();
  999. if (w.button('help'))
  1000. w.button('help').hide();
  1001. if (w.button('stick'))
  1002. w.button('stick').hide();
  1003. if (w.button('sticked'))
  1004. w.button('sticked').hide();
  1005. if (w.button('park'))
  1006. w.button('park').hide();
  1007. if (w.button('minmax1')) // 隐藏最大化按钮
  1008. w.button('minmax1').hide();
  1009. w.denyResize(); // 不允许改变大小
  1010. // if(w.button('close'))
  1011. // w.button('close').hide();
  1012. // w.btns.help.title = "帮助";
  1013. w.button('close').setAttribute("title", "关闭"); // 修改关闭按钮提示
  1014. var containerObj = wd.topWindow.wd.display;
  1015. var currentDialogZIndex = w.zi; // 弹出窗口的z-index
  1016. wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex);
  1017. w.attachEvent("onClose", function (win) {
  1018. wd.display.dxwindowsCloseMaskDiv();
  1019. /*
  1020. * var parentDialog =
  1021. * wd.topWindow.dhxWins.window(parentWdDialogId); if(typeof
  1022. * parentDialog != 'undefined' && parentDialog ){
  1023. * //parentDialog.button('close').enable(); }
  1024. */
  1025. // var iframeObj = $(win).find('iframe')[0];
  1026. function findIframe(dom) {
  1027. for (var i = 0; i < dom.childNodes.length; i++) {
  1028. var c = dom.childNodes[i];
  1029. if (c.tagName == 'IFRAME') {
  1030. return c;
  1031. }
  1032. var temp = findIframe(c);
  1033. if (temp)
  1034. return temp;
  1035. }
  1036. }
  1037. try {
  1038. var iframeObj = findIframe(win);
  1039. var popWindow = iframeObj.contentWindow;
  1040. // 调用关闭窗口时调用的回调方法
  1041. if (typeof popWindow != 'undefined' && popWindow.wd.display.closeDialogCallbackFun) {
  1042. popWindow.wd.display.closeDialogCallbackFun();
  1043. }
  1044. wd.display.onCloseDialog(win, popWindow);
  1045. } catch (e) {
  1046. console.log(e);
  1047. }
  1048. return true;
  1049. });
  1050. } else if (oneNameOrId == "wdFullScreen") { // 如果只是显示功能部件
  1051. if (!wd.topWindow.dhxWins)
  1052. wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
  1053. if (!wd.topWindow.wd.display.wdDialogOpeners)
  1054. wd.topWindow.wd.display.wdDialogOpeners = {};
  1055. wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
  1056. var w = wd.topWindow.dhxWins.createWindow(wdDialogId, 0, 0, width, high);
  1057. w.keepInViewport(true); // 保持在窗口内
  1058. w.attachURL(url); // 跳到此URL
  1059. w.setModal(true); // 设置模式窗口
  1060. w.bringToTop(); // 置顶
  1061. w.setText(title);
  1062. w.clearIcon();
  1063. w.hideMenu();
  1064. w.hideToolbar();
  1065. w.center(); //窗口居中
  1066. wd.display.addWdUserButton(w);
  1067. wd.display.addComponentEvent(w);
  1068. wd.display.hideAllWdUserButton(w);
  1069. wd.display.addDialogLine(w);
  1070. var winbody;
  1071. var Pbtn = w.button('close').parentNode; //关闭按钮的父节点
  1072. var titleline = w.childNodes[0].childNodes[2]//获取到标题元素
  1073. var btns = w.childNodes[0].childNodes[3];
  1074. var odiv = document.createElement("div"); //创建一个新的元素div,用于存放btn div以及标题的div
  1075. w.childNodes[0].appendChild(odiv);
  1076. odiv.style.height = 43 + "px"; //给新元素进行设置样式
  1077. odiv.style.position = "absolute";
  1078. // odiv.style.display = 'none';
  1079. odiv.id = "odiv";
  1080. odiv.style.top = 0;
  1081. odiv.style.width = "100%";
  1082. odiv.style.backgroundColor = '#ffffff';
  1083. odiv.style.zIndex = -1;
  1084. odiv.setAttribute("class", "hLine");
  1085. w.fullScreen = function () { //初始化页面的函数
  1086. var dhwin = wd.topWindow.dhxWins;
  1087. if (fullScreenLimitHeight)
  1088. wd.topWindow.document.body.style.overflow = "hidden";
  1089. dhwin._engineGetWindowLabel(this).style.display = "none";
  1090. // alert(dhwin._engineFixWindowPosInViewport(this));
  1091. var vpw = (_isIE ? document.body.offsetWidth : window.innerWidth);
  1092. var vph = (_isIE ? document.body.offsetHeight : window.innerHeight);
  1093. // this.h = document.body.clientHeight;
  1094. if (fullScreenLimitHeight)
  1095. this.h = wd.topWindow.document.body.offsetHeight;
  1096. this.y = wd.topWindow.document.body.scrollTop;
  1097. // dhwin._engineFixWindowPosInViewport(this);
  1098. dhwin._engineRedrawWindowSize(this);
  1099. dhwin._engineRedrawWindowPos(this);
  1100. winbody = this.vs[this.av].dhxcont;
  1101. winbody.style.top = 0;
  1102. winbody.style.marginTop = 0;
  1103. winbody.style.height = this.h + "px";
  1104. winbody.childNodes[0].style.height = this.h + "px";
  1105. Pbtn.style.zIndex = 100;
  1106. }
  1107. w.fullScreen();
  1108. Pbtn.onmouseover = function () {
  1109. // console.log(w);
  1110. wd.display.showAllWdUserButton(w, true);
  1111. titleline.style.display = "block" //把标题的display属性改成block,在初始化的时候全部设置成了none
  1112. odiv.style.zIndex = 99; //通过调整div的层数来对原有的信息进行覆盖
  1113. odiv.style.display = 'block';
  1114. titleline.style.zIndex = 100;
  1115. }
  1116. odiv.onmouseover = function () {
  1117. this.style.display = 'block';
  1118. this.style.zIndex = 99;
  1119. titleline.style.zIndex = 100;
  1120. }
  1121. titleline.onmouseover = function () {
  1122. odiv.style.zIndex = 99;
  1123. odiv.style.display = 'block';
  1124. this.style.zIndex = 100;
  1125. }
  1126. Pbtn.onmouseout = function (e) {
  1127. if (!e)
  1128. e = window.event;
  1129. var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
  1130. if (reltg.id != "odiv") {
  1131. odiv.style.zIndex = -1;
  1132. odiv.style.display = 'none';
  1133. w.childNodes[0].childNodes[2].style.display = "none" //鼠标离开时进行还原
  1134. wd.display.hideAllWdUserButton(w);
  1135. } else {
  1136. titleline.style.display = "block"
  1137. }
  1138. }
  1139. odiv.onmouseout = function (e) {
  1140. if (!e)
  1141. e = window.event;
  1142. var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
  1143. // if (reltg.className == "dhtmlx_wins_btns_button dhtmlx_button_wdTab_default") { //判定离开新元素是否到了按钮
  1144. // titleline.style.display = "block"
  1145. // } else
  1146. if (reltg.className == "dhtmlx_wins_title") { //判定离开了新元素是否到了title元素
  1147. titleline.style.display = "block"
  1148. } else {
  1149. odiv.style.zIndex = -1;
  1150. odiv.style.display = 'none';
  1151. w.childNodes[0].childNodes[2].style.display = "none";
  1152. wd.display.hideAllWdUserButton(w);
  1153. }
  1154. }
  1155. titleline.onmouseout = function (e) {
  1156. if (!e)
  1157. e = window.event;
  1158. var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
  1159. if (reltg.id == "odiv") {
  1160. titleline.style.display = "block"
  1161. } else {
  1162. odiv.style.zIndex = -1;
  1163. odiv.style.display = 'none';
  1164. w.childNodes[0].childNodes[2].style.display = "none" //鼠标离开时进行还原
  1165. wd.display.hideAllWdUserButton(w);
  1166. }
  1167. }
  1168. wd.display.hideAllWdUserButton(w);
  1169. w.button('close').setAttribute("title", "关闭");
  1170. //以上是对鼠标的走向进行判定
  1171. w.attachEvent("onClose", function (win) {
  1172. wd.topWindow.document.body.style.overflow = "auto";
  1173. wd.display.dxwindowsCloseMaskDiv();
  1174. function findIframe(dom) {
  1175. for (var i = 0; i < dom.childNodes.length; i++) {
  1176. var c = dom.childNodes[i];
  1177. if (c.tagName == 'IFRAME') {
  1178. return c;
  1179. }
  1180. var temp = findIframe(c);
  1181. if (temp)
  1182. return temp;
  1183. }
  1184. }
  1185. try {
  1186. var iframeObj = findIframe(win);
  1187. var popWindow = iframeObj.contentWindow;
  1188. // 调用关闭窗口时调用的回调方法
  1189. if (typeof popWindow != 'undefined' && popWindow.wd.display.closeDialogCallbackFun) {
  1190. popWindow.wd.display.closeDialogCallbackFun();
  1191. }
  1192. wd.display.onCloseDialog(win, popWindow);
  1193. } catch (e) {
  1194. console.log(e);
  1195. }
  1196. return true;
  1197. });
  1198. var currentDialogZIndex = w.zi;
  1199. wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex);
  1200. } else if (showNameOrId == "wdhelpdialog") {
  1201. console.log("wdhelpdialog")
  1202. if (!wd.topWindow.dhxWins)
  1203. wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
  1204. if (!wd.topWindow.wd.display.wdDialogOpeners)
  1205. wd.topWindow.wd.display.wdDialogOpeners = {};
  1206. wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
  1207. var w;
  1208. //判断窗口是否已关闭
  1209. if (wd.topWindow.wdhelpdialog && wd.topWindow.wdhelpdialog.id) {
  1210. w = wd.topWindow.wdhelpdialog
  1211. } else {
  1212. // x,y控制弹窗口位置
  1213. w = wd.topWindow.dhxWins.createWindow(wdDialogId, params.x, params.y, width, high);
  1214. wd.topWindow.wdhelpdialog = w;
  1215. }
  1216. if (params.center) {
  1217. w.center(); //窗口居中
  1218. }
  1219. w.attachHTMLString(url); // 跳到此URL
  1220. w.keepInViewport(true); // 保持在窗口内
  1221. // w.setModal(true); // 设置模式窗口
  1222. w.bringToTop(); // 置顶
  1223. w.setText(title);
  1224. w.clearIcon();
  1225. // w.denyResize()
  1226. // w.hideMenu();
  1227. // w.hideToolbar();
  1228. wd.display.addWdUserButton(w);
  1229. // w.addUserButton("wdHelp_copyhashcode", 3, "复制代码", "复制代码")
  1230. w.button("wdHelp_copyhashcode").onclick = function () {
  1231. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  1232. var fakeElem = document.createElement('textarea');
  1233. // Prevent zooming on iOS
  1234. fakeElem.style.fontSize = '12pt';
  1235. // Reset box model
  1236. fakeElem.style.border = '0';
  1237. fakeElem.style.padding = '0';
  1238. fakeElem.style.margin = '0';
  1239. // Move element out of screen horizontally
  1240. fakeElem.style.position = 'absolute';
  1241. fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  1242. // Move element to the same position vertically
  1243. fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
  1244. fakeElem.setAttribute('readonly', '');
  1245. fakeElem.value = params.helpHaShCode;
  1246. document.body.appendChild(fakeElem);
  1247. fakeElem.select();
  1248. var succeeded;
  1249. try {
  1250. succeeded = document.execCommand('copy');
  1251. alert("复制成功");
  1252. } catch (err) {
  1253. succeeded = false;
  1254. alert("复制失败");
  1255. }
  1256. removeFake(fakeElem);
  1257. return succeeded;
  1258. }
  1259. if (params.pin) {
  1260. //已锁定
  1261. w.denyMove();
  1262. w.button("wdHelp_pin").hide();
  1263. w.button("close").show();
  1264. } else {
  1265. //未锁定
  1266. w.button("wdHelp_unpin").show();
  1267. w.button("close").hide();
  1268. w.allowMove();
  1269. wd.topWindow.setTimeout(function () {
  1270. if (w.isMovable()) {
  1271. w.close();
  1272. }
  1273. }, 3000)
  1274. }
  1275. w.button("wdHelp_unpin").onclick = function () {
  1276. w.button("close").show();
  1277. w.denyMove();
  1278. this.hide();
  1279. w.button("wdHelp_pin").hide();
  1280. }
  1281. w.button("wdHelp_pin").onclick = function () {
  1282. w.button("close").hide()
  1283. w.allowMove();
  1284. this.hide();
  1285. w.button("wdHelp_unpin").hide();
  1286. setTimeout(function () {
  1287. if (w.isMovable()) {
  1288. w.close();
  1289. }
  1290. }, 5000)
  1291. }
  1292. return w.getId();
  1293. }
  1294. }
  1295. } // end if
  1296. if (hideNameOrId) { // 如果有需要隐藏的DOM元素
  1297. // 显示所有DOM元素
  1298. for (var i = 0; i < hideNameOrId.length; i++) {
  1299. var elem = wd.c.g(hideElemNameOrIdArr[i], windowObj);
  1300. elem.style.display = "none";
  1301. var p = elem.parentNode;
  1302. if (p && p.tagName == 'DIV') {
  1303. p.style.display = "none";
  1304. }
  1305. }
  1306. }
  1307. //允许所有iframe全屏
  1308. var arr = wd.topWindow.document.getElementsByTagName('IFRAME');
  1309. for (var i = 0; i < arr.length; i++) {
  1310. var iframeObj = arr[i];
  1311. iframeObj.setAttribute("allowfullscreen", true);
  1312. }
  1313. // w.button("wdHelp").show()
  1314. // w.button("wdShare").show()
  1315. // w.button("wdRecord").show()
  1316. return wdDialogId;
  1317. };
  1318. /**
  1319. *
  1320. * 设置当前iframe部件的长宽
  1321. */
  1322. wd.display.changeDxwindowDimension = function (width, height) {
  1323. //wd.topWindow.dhxWins.
  1324. //刷新弹出本窗口的窗口
  1325. if (null != wd.display.getwdDialogOpener)
  1326. wd.display.refreshOpener();
  1327. //获得弹出部件window对象,通过创建时的部件id
  1328. var wdDialogId = wd.display.getwdDialogId();
  1329. var win = wd.topWindow.dhxWins.window(wdDialogId);
  1330. //myWins.window(id).setDimension(int width, int height);
  1331. win.setDimension(width, height);
  1332. win.keepInViewport(true); // 保持在窗口内
  1333. win.center(); // 居中
  1334. };
  1335. /**
  1336. *
  1337. * @param {}
  1338. * currentDialogZIndex:当前弹出窗口的zIndex
  1339. */
  1340. wd.display.dxwindowsCreateMaskDiv = function (currentDialogZIndex) {
  1341. var containerObj = wd.topWindow.wd.display;
  1342. var topWindow = wd.topWindow;
  1343. wd.display.createMaskDiv(containerObj, topWindow, currentDialogZIndex);
  1344. };
  1345. // 关闭wddialog时,移除遮罩层
  1346. wd.display.dxwindowsCloseMaskDiv = function () {
  1347. var containerObj = wd.topWindow.wd.display.mask;
  1348. var currentMaskEleID = containerObj.pop();
  1349. var currMaskEle = wd.topWindow.document.getElementById(currentMaskEleID);
  1350. if (typeof currMaskEle != 'undefined' && currMaskEle) {
  1351. if (typeof currMaskEle.remove != 'undefined') {
  1352. currMaskEle.remove();
  1353. } else {
  1354. currMaskEle.parentNode.removeChild(currMaskEle);
  1355. }
  1356. }
  1357. };
  1358. //获取当前窗口对应的dhxWin对象
  1359. wd.display.getwdDialogWindows = function (dialogid) {
  1360. /**
  1361. * 根据是否找到wdDialogId判断当前页面在弹窗中或应用页面
  1362. *
  1363. */
  1364. var wdDialogId = wd.display.getwdDialogId();
  1365. if (dialogid)
  1366. wdDialogId = dialogid
  1367. var win = wd.topWindow.dhxWins.window(wdDialogId);
  1368. return win;
  1369. };
  1370. // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回包含本窗口的iframe
  1371. wd.display.getwdDialogId = function (winUnderIframe) {
  1372. if (!winUnderIframe) {
  1373. winUnderIframe = window;
  1374. }
  1375. var arr = wd.topWindow.document.getElementsByTagName('IFRAME');
  1376. var wdDialogId = null;
  1377. for (var i = 0; i < arr.length; i++) {
  1378. var iframeObj = arr[i];
  1379. var cw = iframeObj.contentWindow;
  1380. var tempId = iframeObj.getAttribute('wdDialogId');
  1381. if (cw == winUnderIframe) {
  1382. if (tempId != null) { // 如果找到包含本窗口的iframe,ie走这里
  1383. wdDialogId = tempId;
  1384. break;
  1385. } else if (iframeObj.dataset) { // chrome走这里
  1386. if (iframeObj.dataset['wdDialogId']) {
  1387. wdDialogId = iframeObj.dataset['wdDialogId'];
  1388. break;
  1389. }
  1390. }
  1391. }
  1392. }
  1393. if (!wdDialogId) {
  1394. //最顶层页面跳出循环
  1395. if (winUnderIframe == wd.topWindow)
  1396. return null;
  1397. wdDialogId = wd.display.getwdDialogId(winUnderIframe.parent);
  1398. }
  1399. return wdDialogId;
  1400. }
  1401. // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回弹出本窗口的原窗口window对象
  1402. wd.display.getwdDialogOpener = function () {
  1403. var wdDialogId = wd.display.getwdDialogId();
  1404. return wd.topWindow.wd.display.wdDialogOpeners[wdDialogId];
  1405. }
  1406. // 刷新弹出本窗口的窗口
  1407. wd.display.refreshOpener = function () {
  1408. // //全屏模式下,按确定按钮关闭全屏模式
  1409. // var fullFiv = wd.topWindow.document.querySelector("#wdfullscreen");
  1410. // if (fullFiv) {
  1411. // fullFiv.parentNode.removeChild(fullFiv);
  1412. // }
  1413. try {
  1414. // 刷新原窗口页面
  1415. var wdDialogOpener = wd.display.getwdDialogOpener(); // 获得原窗口window对象
  1416. if (wd.topWindow == wdDialogOpener) {
  1417. return;
  1418. }
  1419. //执行自定义刷新方法(需要打开窗口定义wdRefresh)
  1420. if (wdDialogOpener.wdRefresh) {
  1421. wdDialogOpener.wdRefresh();
  1422. return;
  1423. }
  1424. //执行默认刷新方法
  1425. var forms = wdDialogOpener.document.getElementsByTagName('FORM');
  1426. //提交表单
  1427. if (forms && forms.length > 0 && forms[0].action) {
  1428. if (forms.length == 1) {
  1429. var f = forms[0];
  1430. f.submit();
  1431. }
  1432. //刷新个人首页部件
  1433. } else {
  1434. if (typeof wdDialogOpener.SYBJCTRL != 'undefined' && wdDialogOpener.SYBJCTRL) {
  1435. // 个人首页分支 by Rd 2016-01-13
  1436. // 通过刷新调用窗口的部件来替代刷新整个调用窗口
  1437. wdDialogOpener.SYBJCTRL.EventCtrl.FlushBj();
  1438. } else {
  1439. wdDialogOpener.location.reload();
  1440. }
  1441. }
  1442. } catch (e) {
  1443. console.log(e)
  1444. }
  1445. }
  1446. // 关闭弹出窗口
  1447. wd.display.closeDialog = function () {
  1448. try {
  1449. if (typeof beacon != "undefined")
  1450. beacon.beaconCloseWindow();
  1451. } catch (e) {
  1452. console.error(e);
  1453. }
  1454. var wdDialogId = wd.display.getwdDialogId();
  1455. // console.log(wdDialogId);
  1456. // console.log(wd.topWindow.dhxWins.window(wdDialogId));
  1457. // 关闭鼠标加载动画 by SPACE 2019-04-02
  1458. wd.display.closeLoad();
  1459. // 关闭本弹出窗口
  1460. wd.topWindow.dhxWins.window(wdDialogId).close();
  1461. }
  1462. /**
  1463. * 改变对象的样式
  1464. * event:监听事件的参数--{eventIds:['1','2'],styleName:{onclick:'样式名1',onmouseover:'样式名2',onmouseout:'样式名3'}}
  1465. * eventIds: 监听事件的id数组
  1466. * styleName:样式名(className),[0]是获得点击后样式名,[1]是鼠标移过时的样式名,[2]是对象默认的样式
  1467. */
  1468. wd.display.changeTabStyle = function (param) {
  1469. /**
  1470. * 绑定监听事件 eventIds:绑定事件的id数组, eventType:绑定的事件--onclick,onmouseout等,
  1471. * styleName:样式的类名
  1472. */
  1473. var objClick = new Object();
  1474. objClick.clickId = null;
  1475. objClick.mouseoverId = null;
  1476. function onEvent(tabIds, eventType, styleNames) {
  1477. // try{
  1478. if (eventType == 'onclick') {
  1479. for (var key in tabIds) {
  1480. var tagId = document.getElementById(tabIds[key]);
  1481. (function (key) {
  1482. wd.c.addEventListener(tagId, eventType, function () {
  1483. setTabCssToNormal();
  1484. var objById = this;
  1485. var objFocus = document.activeElement
  1486. objById.className = styleNames.onclick;
  1487. objClick.clickId = tabIds[key];
  1488. });
  1489. })(key)
  1490. }
  1491. } else if (eventType == 'onmouseover') {
  1492. for (var key in tabIds) {
  1493. var tagId = document.getElementById(tabIds[key]);
  1494. (function (key) {
  1495. wd.c.addEventListener(tagId, eventType, function () {
  1496. var objById = document.getElementById(tabIds[key]);
  1497. if (tabIds[key] == objClick.clickId) {
  1498. return;
  1499. }
  1500. objById.className = styleNames.onmouseover;
  1501. objClick.mouseoverId = tabIds[key];
  1502. });
  1503. })(key)
  1504. }
  1505. } else if (eventType == 'onmouseout') {
  1506. for (var key in tabIds) {
  1507. var tagId = document.getElementById(tabIds[key]);
  1508. (function (key) {
  1509. wd.c.addEventListener(tagId, eventType, function () {
  1510. var objById = document.getElementById(tabIds[key]);
  1511. if (tabIds[key] == objClick.clickId) {
  1512. return;
  1513. }
  1514. objById.className = styleNames.normal;
  1515. });
  1516. })(key)
  1517. }
  1518. }
  1519. /**
  1520. * }catch(e){ alert("创建监听事件错误:"+e.message+" Type:"+e.name); }
  1521. */
  1522. }
  1523. // -----------------------
  1524. var tabIds = param.tabIds;
  1525. var styleNames = param.styleNames;
  1526. onEvent(tabIds, 'onclick', styleNames);
  1527. onEvent(tabIds, 'onmouseover', styleNames);
  1528. onEvent(tabIds, 'onmouseout', styleNames);
  1529. function setTabCssToNormal() {
  1530. for (var i = 0; i < tabIds.length; i++) {
  1531. var tabId = tabIds[i];
  1532. document.getElementById(tabId).className = styleNames.normal;
  1533. }
  1534. }
  1535. // 设置默认对象
  1536. function setTabCssToNormalDefault() {
  1537. for (var i = 0; i < tabIds.length; i++) {
  1538. var tabId = tabIds[i];
  1539. if (i == 0) {
  1540. document.getElementById(tabId).className = styleNames.onclick;
  1541. objClick.clickId = tabId;
  1542. // objClick.clickId = tabId;
  1543. } else {
  1544. document.getElementById(tabId).className = styleNames.normal;
  1545. }
  1546. }
  1547. }
  1548. setTabCssToNormalDefault();
  1549. }
  1550. // 把当前窗口的window对象,保存到指定的窗口中,以便关闭窗口时使用
  1551. wd.display.windowToObj = function (Ele) {
  1552. if (!Ele.dom.wdDialogOpeners)
  1553. Ele.dom.wdDialogOpeners = {};
  1554. Ele.dom.wdDialogOpeners[Ele.wdDialogId] = window;
  1555. }
  1556. // 为dhtmlXWindows设置参数,创建窗口
  1557. wd.display.setDhtmlXWinParam = function (winParam) {
  1558. var windowId = winParam.wdDialogId;
  1559. // /当前可视区域
  1560. var sw = winParam.dom.document.body.offsetWidth;
  1561. var sh = winParam.dom.document.body.offsetHeight;
  1562. var positionParam = winParam.positionParam;
  1563. var btnParam = winParam.btnParam;
  1564. var sizeParam = winParam.sizeParam;
  1565. var winWid;
  1566. var winHeg;
  1567. // 根据可是区域调整窗口
  1568. var cenFlag = false; // 超过时不居中
  1569. // 处理x,y
  1570. if (positionParam) {
  1571. var win_X = positionParam.split(",")[0];
  1572. var win_Y = positionParam.split(",")[1];
  1573. } else {
  1574. cenFlag = true; // 居中
  1575. }
  1576. // 处理size属性
  1577. if (!sizeParam) { // 用户不填写size属性
  1578. winWid = wd.display.getDialogWidAndHei(wd.display.winWidth);
  1579. winHeg = wd.display.getDialogWidAndHei(wd.display.winHeight);
  1580. } else if ("max" == sizeParam) { // 这里设置的win
  1581. // size是还原状态下的窗口大小,后面会直接调用控件的最大化方法
  1582. if (wd.topWindow == winParam.dom) {
  1583. winWidth = wd.topWindow.document.body.offsetWidth;
  1584. winHeight = wd.topWindow.document.body.offsetHeight;
  1585. } else {
  1586. winWidth = document.body.offsetWidth;
  1587. winHeight = document.body.offsetHeight;
  1588. }
  1589. winWid = wd.display.getDialogWidAndHei(winWidth);
  1590. winHeg = wd.display.getDialogWidAndHei(winHeight);
  1591. } else {
  1592. winWid = wd.display.getDialogWidAndHei(sizeParam.split("*")[0],
  1593. document.body.offsetWidth);
  1594. winHeg = wd.display.getDialogWidAndHei(sizeParam.split("*")[1],
  1595. document.body.offsetHeight);
  1596. }
  1597. // if(winParam.dom.width < winWid || winParam.dom.heigh < winHeg)
  1598. // cenFlag=true;
  1599. if (positionParam) {
  1600. var w = winParam.dom.dhxWins.createWindow(windowId, parseInt(win_X),
  1601. parseInt(win_Y), winWid, winHeg);
  1602. } else {
  1603. var w = winParam.dom.dhxWins.createWindow(windowId, 0, 0, winWid,
  1604. winHeg);
  1605. }
  1606. w.keepInViewport(true); // 保持在窗口内
  1607. if (cenFlag)
  1608. w.center(); // 居中
  1609. if (winParam.title)
  1610. w.setText(winParam.title); // 设置窗口标题
  1611. w.attachURL(winParam.url); // 跳到此URL
  1612. useUrl = false;
  1613. w.setModal(true); // 设置模式窗口
  1614. w.bringToTop(); // 置顶
  1615. // 隐藏不需要的按钮
  1616. wd.display.showDialogBtn(w, btnParam);
  1617. if ("max" == sizeParam) {
  1618. w.maximize();
  1619. }
  1620. // if(w.button('help'))
  1621. // w.button('help').hide();
  1622. // if(w.button('stick'))
  1623. // w.button('stick').hide();
  1624. // if(w.button('sticked'))
  1625. // w.button('sticked').hide();
  1626. // if(w.button('park'))
  1627. // w.button('park').hide();
  1628. }
  1629. // 处理弹出窗口的大小
  1630. // 分为3中情况:数字*数字;max*数字;max
  1631. wd.display.getDialogWidAndHei = function (p, wp) {
  1632. if (p == "max") {
  1633. p = wp;
  1634. }
  1635. return parseInt(p);
  1636. }
  1637. // 处理弹出窗口的按钮
  1638. wd.display.showDialogBtn = function (w, btnParam) {
  1639. if (w.button('help'))
  1640. w.button('help').hide();
  1641. if (w.button('stick'))
  1642. w.button('stick').hide();
  1643. if (w.button('sticked'))
  1644. w.button('sticked').hide();
  1645. if (w.button('park'))
  1646. w.button('park').hide();
  1647. if (w.button('minmax1'))
  1648. w.button('minmax1').hide();
  1649. w.button('minmax2').hide();
  1650. if (w.button('close'))
  1651. w.button('close').hide();
  1652. if (btnParam) {
  1653. if (btnParam.indexOf("min") >= 0) {
  1654. w.button('park').show();
  1655. }
  1656. if (btnParam.indexOf("max") >= 0) {
  1657. if (w.isMaximized())
  1658. w.button('minmax2').show();
  1659. else
  1660. w.button('minmax1').show();
  1661. }
  1662. if (btnParam.indexOf("close") >= 0) {
  1663. w.button('close').show();
  1664. }
  1665. } else { // 用户没填写的话,默认值为“max,close”
  1666. if (w.isMaximized())
  1667. w.button('minmax2').show();
  1668. else
  1669. w.button('minmax1').show();
  1670. w.button('close').show();
  1671. }
  1672. }
  1673. /**
  1674. * 把名为frameName的frame的src属性置为url
  1675. */
  1676. wd.display.changeFrameSrc = function (frameName, url) {
  1677. document.getElementsByName(frameName)[0].src = url;
  1678. }
  1679. wd.display.wdTabNo = wd.display.defaultTabNo = 1; //默认的tab索引值
  1680. // 初始化tab的总方法
  1681. wd.display.initTab = function () {
  1682. (function () {
  1683. var tab = function () {
  1684. this.dom = null;
  1685. this.wdTabFrame = null;
  1686. this.wdTabList = [];
  1687. this.wdSecondaryTab = [];
  1688. this.styles = {
  1689. wdNormalClass: null,
  1690. wdSelectedClass: null,
  1691. wdNormalMoreClass: null,
  1692. wdSelectedMoreClass: null
  1693. }
  1694. this.selectTab = null;
  1695. this.mouseoutid = null;
  1696. var li = function () {
  1697. this.topSide = null;
  1698. this.dom = null;
  1699. this.type = null; //1:普通,2,显示隐藏开关,3,二级选项
  1700. this.parent = null;
  1701. this.ul = null;
  1702. this.url //点击刷新iframe的地址
  1703. this.secondaryTabList = [];
  1704. //独立
  1705. this.init = function (ele, type, topside, styles) {
  1706. //二级的顶层
  1707. this.dom = ele
  1708. this.url = this.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin
  1709. this.setTopSide(topside)
  1710. this.type = type;
  1711. this.setStyle(styles);
  1712. // this.dom.setAttribute("class", this.wdNormalClass)
  1713. this.initEvent()
  1714. return this;
  1715. }
  1716. //初始化样式属性
  1717. this.setStyle = function (styles) {
  1718. this.styles = styles;
  1719. if (this.type == 1) {
  1720. }else if (this.type == 2) {
  1721. //初始二级的选项
  1722. this.initSecondaryTap();
  1723. $(this.dom).children("ul").addClass("popup-div").css({
  1724. "position": "absolute"
  1725. });
  1726. } else if (this.type == 3) {
  1727. this.dom.style.list_style_type = "none"
  1728. $(this.dom).attr("class","");
  1729. $(this.dom).addClass(styles.wdNormalMoreClass);
  1730. }
  1731. $(this.dom).removeClass(styles.wdSelectedClass).addClass(styles.wdNormalClass);
  1732. return this;
  1733. }
  1734. //绑定事件初始化
  1735. this.initEvent = function () {
  1736. this.dom.addEventListener("click", this.mouseClickEvent(), false)
  1737. this.dom.addEventListener("mouseover", this.mouseOverEvent(), false)
  1738. this.dom.addEventListener("mouseout", this.mouseOutEvent(), false)
  1739. }
  1740. this.initSecondaryTap = function () {
  1741. var newStyles = $.extend({},this.styles);
  1742. newStyles.wdNormalClass = this.styles.wdNormalMoreClass;
  1743. newStyles.wdSelectedClass = this.styles.wdSelectedMoreClass;
  1744. var result = [];
  1745. //显示隐藏的位置
  1746. var ul = this.dom.getElementsByTagName("ul")[0]
  1747. if (ul == null)
  1748. return;
  1749. this.ul = ul;
  1750. ul.style.display = "none";
  1751. var childNodes = ul.childNodes;
  1752. for (var i = 0; i < childNodes.length; i++) {
  1753. var nod = childNodes[i];
  1754. if (nod.nodeType == 1) {
  1755. if (nod.hasAttribute("ssTabClick")) { // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin
  1756. var liobj = new li();
  1757. liobj.init(nod, 3, this.topSide, newStyles)
  1758. result.push(nod)
  1759. }
  1760. }
  1761. }
  1762. this.secondaryTabList = result;
  1763. }
  1764. //设置根
  1765. this.setTopSide = function (obj) {
  1766. this.topSide = obj;
  1767. }
  1768. this.mouseClickEvent = function () {
  1769. var THIS = this;
  1770. return function () {
  1771. //编辑选项卡状态
  1772. if ("1" == THIS.topSide.dom.getAttribute("editing")) {
  1773. return true;
  1774. }
  1775. //清除上次点击
  1776. if (THIS.type != 2 && THIS.topSide.selectTab) {
  1777. $(THIS.topSide.selectTab.dom).removeClass(THIS.topSide.selectTab.styles.wdSelectedClass).addClass(THIS.topSide.selectTab.styles.wdNormalClass)
  1778. // THIS.topSide.selectTab.dom.setAttribute("class", THIS.topSide.selectTab.wdNormalClass)
  1779. THIS.topSide.selectTab = null
  1780. }
  1781. THIS.topSide.selectTab = THIS
  1782. THIS.url = THIS.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin
  1783. if (THIS.type == 1 || THIS.type == 3) {
  1784. // THIS.topSide.wdTabFrame.src = THIS.url;
  1785. THIS.topSide.wdTabFrame.src = wd.base.setRowCountPerPage(THIS.url, THIS.topSide.wdTabFrame.offsetHeight);
  1786. $(THIS.dom).removeClass(THIS.styles.wdNormalClass).addClass(THIS.styles.wdSelectedClass)
  1787. // THIS.dom.setAttribute("class", THIS.wdSelectedClass);
  1788. } else if (THIS.type == 2) {
  1789. if (THIS.ul) {
  1790. if (THIS.ul.style.display == "none") {
  1791. THIS.ul.style.display = ""
  1792. } else {
  1793. THIS.ul.style.display = "none"
  1794. }
  1795. }
  1796. }
  1797. /**
  1798. * 找不到原来说的点击tab之后更多变成tab对应的名字
  1799. */
  1800. var secondarytab = document.querySelector('[wdsecondarytab="true"]');
  1801. if (secondarytab) {
  1802. var type = THIS.type;
  1803. if (type != 2) {
  1804. $(secondarytab).children(":not(ul)").remove();
  1805. $(secondarytab).contents().filter(function () {
  1806. if (this.nodeType == 3)
  1807. return true
  1808. }).remove()
  1809. }
  1810. var firstNode = secondarytab.firstChild;
  1811. switch (type) {
  1812. case 1:
  1813. var moreNode = document.createTextNode('更多');
  1814. if (firstNode.nodeType == 3) {
  1815. secondarytab.replaceChild(moreNode, firstNode);
  1816. } else {
  1817. secondarytab.insertBefore(moreNode, firstNode);
  1818. }
  1819. secondarytab.currentSelectedItem = null;
  1820. //删除小黄点
  1821. $(secondarytab).children(".statePoint").remove();
  1822. break;
  1823. case 2:
  1824. //“更多”被点击
  1825. if (secondarytab.currentSelectedItem) {
  1826. secondarytab.currentSelectedItem.dom.click();
  1827. }
  1828. break;
  1829. case 3:
  1830. //复制小黄点
  1831. if($(THIS.dom).find(".statePoint").length>0){
  1832. $(secondarytab).prepend($(THIS.dom).find(".statePoint").clone());
  1833. }
  1834. $(secondarytab).prepend(document.createTextNode($(THIS.dom).contents().text() + "..."))
  1835. secondarytab.currentSelectedItem = THIS;
  1836. break;
  1837. }
  1838. }
  1839. }
  1840. }
  1841. this.mouseOverEvent = function () {
  1842. var THIS = this;
  1843. return function () {
  1844. if ("1" == THIS.topSide.dom.getAttribute("editing")) {
  1845. return true;
  1846. }
  1847. if (THIS.type == 2) {
  1848. if (THIS.ul)
  1849. THIS.ul.style.display = "block";
  1850. //THIS.dom.getElementsByTagName("ul")[0]
  1851. if (THIS.topSide.mouseoutid)
  1852. clearTimeout(THIS.topSide.mouseoutid);
  1853. THIS.topSide.mouseoutid = null;
  1854. }
  1855. }
  1856. }
  1857. this.mouseOutEvent = function () {
  1858. var THIS = this;
  1859. return function () {
  1860. if ("1" == THIS.topSide.dom.getAttribute("editing")) {
  1861. return true;
  1862. }
  1863. if (THIS.topSide.selectTab != THIS) {
  1864. $(THIS.dom).removeClass(THIS.styles.wdSelectedClass).addClass(THIS.styles.wdNormalClass)
  1865. }
  1866. // if (THIS.type == 2 && THIS.ul && THIS.ul.style.display == "") {
  1867. // THIS.ul.style.display = "none"
  1868. // }
  1869. if (THIS.type == 2) {
  1870. var pos = THIS.dom.compareDocumentPosition(window.event.relatedTarget);
  1871. if (pos == 10 || pos == 4) {
  1872. if ("true" == THIS.dom.getAttribute("wdSecondaryTab")) {
  1873. if (THIS.topSide.mouseoutid)
  1874. clearTimeout(THIS.topSide.mouseoutid);
  1875. THIS.topSide.mouseoutid = null;
  1876. THIS.topSide.mouseoutid = setTimeout(function () {
  1877. THIS.ul.style.display = "none";
  1878. }, 800)
  1879. }
  1880. }
  1881. }
  1882. }
  1883. }
  1884. }
  1885. this.init = function (dom) {
  1886. this.dom = dom;
  1887. //原为 this.wdTabFrame = document.getElementsByTagName("iframe")[0]
  1888. this.wdTabFrame = document.querySelector('iframe[name="ssTabIframe"]') || // [name="wdTabFrame"]。Lin
  1889. document.getElementsByTagName("iframe")[0];
  1890. this.wdTabFrame.tabObj = this; //为了获取当前选中的tab来刷新当前的iframe
  1891. /* 改,规范命名。Lin
  1892. * wdNormalClass > ssNormClazz
  1893. * 去掉 wdNomalClass
  1894. * wdSelectedClass > ssSelClazz
  1895. this.styles.wdNormalClass = this.dom.getAttribute("wdNormalClass") || this.dom.getAttribute("wdNomalClass");
  1896. this.styles.wdSelectedClass = this.dom.getAttribute("wdSelectedClass");
  1897. */
  1898. this.styles.wdNormalClass = this.dom.getAttribute("ssNormClazz");
  1899. this.styles.wdSelectedClass = this.dom.getAttribute("ssSelClazz");
  1900. var parentiframe = window.parent.document.querySelector("iframe");
  1901. if (parentiframe.tabObj) { //双层选项卡
  1902. if (this.styles.wdSelectedClass != "lightTab-selected")
  1903. this.styles.wdSelectedClass += " lightTab-selected";
  1904. if (this.styles.wdNormalClass != "lightTab")
  1905. this.styles.wdNormalClass += " lightTab";
  1906. this.dom.style = "height:33px;padding-left: 14px;box-sizing:border-box";
  1907. } else {
  1908. if (this.styles.wdSelectedClass != "tab-selected")
  1909. this.styles.wdSelectedClass += " tab-selected";
  1910. if (this.styles.wdNormalClass != "tab")
  1911. this.styles.wdNormalClass += " tab";
  1912. }
  1913. this.styles.wdNormalMoreClass = "popupList";
  1914. this.styles.wdSelectedMoreClass = "popupList";
  1915. //初始化
  1916. var child = this.findChildLi();
  1917. var secondLi;
  1918. for (var i = 0; i < child.length; i++) {
  1919. var type = 1;
  1920. if (child[i].hasAttribute("wdSecondaryTab")) {
  1921. type = 2;
  1922. }
  1923. var liobj = new li();
  1924. liobj.init(child[i], type, this, this.styles);
  1925. if(type==2){
  1926. secondLi=liobj;
  1927. }
  1928. this.wdTabList.push(liobj)
  1929. }
  1930. //超出显示范围,就显示出更多选项卡 start
  1931. var wholewidth=0;
  1932. var domwidth=$(dom).width();
  1933. for(var i=0;i<this.wdTabList.length;i++){
  1934. var w=this.wdTabList[i].dom.offsetWidth;
  1935. wholewidth+=w;
  1936. }
  1937. if(wholewidth>domwidth){
  1938. secondLi.dom.style.display="";
  1939. domwidth-=secondLi.dom.offsetWidth*2;
  1940. var fistgroup=[];
  1941. var secondgroup=[];
  1942. var thirdgroup=[];
  1943. wholewidth=0;
  1944. for(var i=0;i<this.wdTabList.length;i++){
  1945. wholewidth+=this.wdTabList[i].dom.offsetWidth
  1946. var t=this.wdTabList[i].type;
  1947. if(t==2){
  1948. secondgroup.push(this.wdTabList[i]);
  1949. continue;
  1950. }
  1951. if(wholewidth>domwidth){
  1952. thirdgroup.push(this.wdTabList[i]);
  1953. this.wdTabList[i].type=3;
  1954. var oo=$.extend({},this.wdTabList[i].styles,{wdNormalClass:this.wdTabList[i].styles.wdNormalMoreClass,wdSelectedClass:this.wdTabList[i].styles.wdNormalMoreClass});
  1955. this.wdTabList[i].setStyle(oo);
  1956. $(this.wdTabList[i].dom).prependTo(secondLi.ul);
  1957. }else{
  1958. fistgroup.push(this.wdTabList[i]);
  1959. }
  1960. }
  1961. this.wdTabList=fistgroup.concat(secondgroup);
  1962. secondLi.secondaryTabList=thirdgroup.concat(secondLi.secondaryTabList);
  1963. }
  1964. //超出显示范围,就显示出更多选项卡 end
  1965. this.selectClick(wd.display.wdTabNo);
  1966. return this;
  1967. }
  1968. this.findChildLi = function () {
  1969. var result = []
  1970. var childNodes = this.dom.childNodes;
  1971. for (var i = 0; i < childNodes.length; i++) {
  1972. var nod = childNodes[i];
  1973. if (nod.nodeType == 1) {
  1974. /* 再改,规范 <li wdTabClick= 命名。Lin
  1975. * 先改,是 wdtabclick,不是 wdTabClick
  1976. * wdSecondaryTab,应该没有了 -- 没有 更多...
  1977. if (nod.hasAttribute("wdtabclick") || nod.hasAttribute("wdSecondaryTab")) {
  1978. */ if (nod.hasAttribute("ssTabClick") || nod.hasAttribute("wdSecondaryTab")) {
  1979. result.push(nod);
  1980. }
  1981. }
  1982. }
  1983. return result;
  1984. }
  1985. //指定第几个tab点击
  1986. this.selectClick = function (no) {
  1987. var num = no || 1;
  1988. var childLength = 0;
  1989. var child = this.findChildLi();
  1990. if (child.length == 0)
  1991. return;
  1992. for (var i = 0; i < child.length; i++) {
  1993. if (child[i].hasAttribute("wdSecondaryTab")) { }
  1994. else {
  1995. childLength++;
  1996. }
  1997. }
  1998. num = (isNaN(num) || num > childLength) ? wd.display.defaultTabNo : num;
  1999. if (childLength == 0) {
  2000. var cc = $(child[0]).find("li").filter(function () {
  2001. return this.style != 'none'
  2002. }).first();
  2003. if (cc.length == 1)
  2004. cc[0].click();
  2005. //隐藏更多
  2006. $(child[0]).find("#tabOption").hide();
  2007. } else if (num > childLength) {
  2008. child[0].click();
  2009. } else {
  2010. child[num - 1].click();
  2011. }
  2012. }
  2013. }
  2014. //从wdTabClick的元素顶层初始化
  2015. var initList = document.querySelectorAll("[ssTabClick]"); // ("[wdTabClick]")。Lin
  2016. var tabobj;
  2017. if (initList.length > 0) {
  2018. if ("tabOption" == initList[0].parentNode.getAttribute("id")) {
  2019. tabobj = new tab().init(initList[0].parentNode.parentNode.parentNode)
  2020. } else {
  2021. tabobj = new tab().init(initList[0].parentNode)
  2022. }
  2023. }
  2024. window.tabobj = tabobj;
  2025. })()
  2026. }
  2027. wd.display.getTabInstance = function () {
  2028. return window.tabobj;
  2029. }
  2030. /**
  2031. * 打印指定div等内容,可多个selector
  2032. */
  2033. wd.display.printArea = function (selector, noscroll, options) {
  2034. var jqsrc = "/wd/js/jquery/jquery.js";
  2035. var printsrc = "/wd/js/print/jquery.PrintArea.js";
  2036. if (typeof $ + "" == "undefined") {
  2037. loadScript(jqsrc, "jquery", function () {
  2038. loadAndPrint();
  2039. });
  2040. } else {
  2041. loadAndPrint();
  2042. }
  2043. function loadAndPrint() {
  2044. if (typeof $.PrintArea + '' == "undefined") {
  2045. loadScript(printsrc, "print", function () {
  2046. options = options || {
  2047. "mode": "iframe",
  2048. "popClose": false,
  2049. "extraCss": "",
  2050. "retainAttr": ["class", "id", "style", "on"],
  2051. "extraHead": "<meta charset=\"utf-8\" />,<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>"
  2052. }
  2053. if (noscroll)
  2054. $(selector).css("overflow", "");
  2055. $(selector).append($("link").clone());
  2056. $(selector).append($("style").clone());
  2057. try {
  2058. $(selector).printArea(options);
  2059. } catch (e) {
  2060. alert("打印出错,检查打印窗是否被拦截");
  2061. console.error(e);
  2062. }
  2063. });
  2064. } else {
  2065. if (noscroll)
  2066. $(selector).css("overflow", "");
  2067. $(selector).append($("link").clone());
  2068. $(selector).append($("style").clone());
  2069. try {
  2070. $(selector).printArea(options);
  2071. } catch (e) {
  2072. alert("打印出错,检查打印窗是否被拦截");
  2073. console.error(e);
  2074. }
  2075. }
  2076. }
  2077. };
  2078. /**
  2079. *
  2080. * @param {Object}
  2081. * output
  2082. * @param {Object}
  2083. * wdurl
  2084. */
  2085. wd.display.qrcode = function (output, wdurl, width, height, render) {
  2086. // console.log($().qrcode);
  2087. // if (typeof $ + "" == "undefined") {
  2088. // loadScript("/wd/js/jquery/jquery.js", "jquery~", function() {
  2089. // wd.display.qrcode(output, wdurl, width, height, render);
  2090. // });
  2091. // } else {
  2092. // if (!$().qrcode)
  2093. // loadScript("/wd/js/qrcode/jquery.qrcode.js", "qrcode1", function() {
  2094. // loadScript("/wd/js/qrcode/qrcode.js", "qrcode2", function() {
  2095. // wd.display.qrcode(output, wdurl, width, height, render);
  2096. // });
  2097. // });
  2098. // else {
  2099. var option = {
  2100. render: render || "table",
  2101. text: wdurl.toString(),
  2102. width: width || "200",
  2103. height: height || "200"
  2104. };
  2105. $(output).find(".qrcode").remove();
  2106. $(output).append("<div class='qrcode'></div>");
  2107. $(output).find(".qrcode").qrcode(option);
  2108. // }
  2109. // }
  2110. };
  2111. /**
  2112. * 改变dom元素的背景图片
  2113. * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg)
  2114. *
  2115. * @param domId
  2116. * 需要改变背景图片的dom元素id
  2117. */
  2118. wd.display.changeBackgroundImage = function (domId) {
  2119. var domElement = document.getElementById(domId);
  2120. var cssStr = getClass(domElement, "backgroundImage");
  2121. cssStr = cssStr.substring(4, cssStr.length - 1);
  2122. cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, "");
  2123. var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2124. if (cssStr.lastIndexOf("?") != -1) {
  2125. imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置
  2126. var changeImgStartIndex = cssStr.lastIndexOf("=") + 1;
  2127. var changeImg = cssStr.substring(parseInt(changeImgStartIndex),
  2128. parseInt(cssStr.length));
  2129. var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2130. var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1);
  2131. changeImg = imgPath + changeImg;
  2132. changeImg = changeImg.replace(/\"/g, "");
  2133. var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL
  2134. domElement.style.backgroundImage = imgUrl;
  2135. }
  2136. function getClass(obj, attr) {
  2137. if (obj.currentStyle) {
  2138. if (attr == "backgroundPosition") {
  2139. return obj.currentStyle.backgroundPositionX + " " +
  2140. obj.currentStyle.backgroundPositionY;
  2141. } else {
  2142. return obj.currentStyle[attr];
  2143. }
  2144. } else {
  2145. return document.defaultView.getComputedStyle(obj, null)[attr];
  2146. }
  2147. }
  2148. }
  2149. /**
  2150. * 改变dom元素的背景图片
  2151. * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg)
  2152. *
  2153. * @param domId
  2154. * 需要改变背景图片的dom元素id
  2155. */
  2156. wd.display.changeBackgroundImage = function (domId) {
  2157. var domElement = document.getElementById(domId);
  2158. var cssStr = getClass(domElement, "backgroundImage");
  2159. cssStr = cssStr.substring(4, cssStr.length - 1);
  2160. cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, "");
  2161. var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2162. if (cssStr.lastIndexOf("?") != -1) {
  2163. imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置
  2164. var changeImgStartIndex = cssStr.lastIndexOf("=") + 1;
  2165. var changeImg = cssStr.substring(parseInt(changeImgStartIndex),
  2166. parseInt(cssStr.length));
  2167. var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2168. var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1);
  2169. changeImg = imgPath + changeImg;
  2170. changeImg = changeImg.replace(/\"/g, "");
  2171. var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL
  2172. domElement.style.backgroundImage = imgUrl;
  2173. }
  2174. function getClass(obj, attr) {
  2175. if (obj.currentStyle) {
  2176. if (attr == "backgroundPosition") {
  2177. return obj.currentStyle.backgroundPositionX + " " +
  2178. obj.currentStyle.backgroundPositionY;
  2179. } else {
  2180. return obj.currentStyle[attr];
  2181. }
  2182. } else {
  2183. return document.defaultView.getComputedStyle(obj, null)[attr];
  2184. }
  2185. }
  2186. }
  2187. // table列表自适应宽度
  2188. // ;(function($){
  2189. //但是每个部件都要加载一次
  2190. if ((typeof $) + "" == "undefined") {
  2191. loadScript("/wd/js/jquery.js", "Jquery", function () {
  2192. setTimeout(tabFoo, 200);
  2193. });
  2194. }
  2195. // 这个延迟执行在于加载时比dom元素先加载 而且该js文件在页面被加载多次消耗性能望后来者去解决这些问题
  2196. function tabFoo() {
  2197. var oTh = $('table.list th'),
  2198. oTr = $('table.list tr'),
  2199. arr_oth = Array.prototype.slice.apply(oTh),
  2200. font_size = parseInt($(arr_oth[0]).css('fontSize')),
  2201. style_h = $('style'),
  2202. str_sheet = " white-space: nowrap;overflow: hidden;text-overflow: ellipsis;padding-left:10px;";
  2203. if (oTh.length <= 5) {
  2204. if (style_h.length) {
  2205. var first_style = style_h[0],
  2206. sheet = first_style.sheet ?
  2207. first_style.sheet :
  2208. first_style.styleSheet;
  2209. if (sheet.insertRule) {
  2210. sheet.insertRule('table.list td,table.list th{' + str_sheet + '}',
  2211. 1);
  2212. } else {
  2213. sheet.addRule('table.list td,table.list th', str_sheet, 0)
  2214. }
  2215. } else {
  2216. $('head').append('<style type="text/css">table.list td,table.list th{' +
  2217. str_sheet + '}</style>')
  2218. }
  2219. for (var i = 0; i < arr_oth.length - 1; i++) {
  2220. // console.log($(arr_oth[i]).text().length, '222');
  2221. var thW = $(arr_oth[i]).text().length;
  2222. thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符
  2223. if (i == 0) {
  2224. $(arr_oth[i]).css({
  2225. 'min-width': (thW + 10) * font_size + 'px', // max-width and
  2226. // min-width
  2227. // 根据th字符数上下浮动一个
  2228. 'max-width': (thW + 12) * font_size + 'px'
  2229. });
  2230. // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
  2231. $('table.list tr td:nth-child(' + (i + 1) + ')').css({
  2232. 'min-width': (thW + 10) * font_size + 'px',
  2233. 'max-width': (thW + 12) * font_size + 'px'
  2234. });
  2235. } else {
  2236. $(arr_oth[i]).css({
  2237. 'min-width': (thW + 6) * font_size + 'px', // max-width and
  2238. // min-width
  2239. // 根据th字符数上下浮动一个
  2240. 'max-width': (thW + 8) * font_size + 'px'
  2241. });
  2242. // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
  2243. $('table.list tr td:nth-child(' + (i + 1) + ')').css({
  2244. 'min-width': (thW + 6) * font_size + 'px',
  2245. 'max-width': (thW + 8) * font_size + 'px'
  2246. });
  2247. }
  2248. }
  2249. $('table.list tr td:nth-child(' + arr_oth.length + ')').css({
  2250. "white-space": "inherit",
  2251. "overflow": "inherit",
  2252. "text-overflow": "inherit"
  2253. })
  2254. $('.img1').parents('td').css('cssText', 'width:90px !important');
  2255. return;
  2256. }
  2257. if (style_h.length) {
  2258. var first_style = style_h[0],
  2259. sheet = first_style.sheet ?
  2260. first_style.sheet :
  2261. first_style.styleSheet;
  2262. if (sheet.insertRule) {
  2263. sheet.insertRule('table.list td,table.list th{' + str_sheet + '}',
  2264. 1);
  2265. } else {
  2266. sheet.addRule('table.list td,table.list th', str_sheet, 0)
  2267. }
  2268. } else {
  2269. $('head').append('<style type="text/css">table.list td,table.list th{' +
  2270. str_sheet + '}</style>')
  2271. }
  2272. // console.log(arr_oth.length)
  2273. for (var i = 0; i < arr_oth.length - 1; i++) {
  2274. var thW = $(arr_oth[i]).text().length;
  2275. thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符
  2276. $(arr_oth[i]).css({
  2277. 'min-width': (thW - 1) * font_size + 'px', // max-width and
  2278. // min-width
  2279. // 根据th字符数上下浮动一个
  2280. 'max-width': (thW + 1) * font_size + 'px'
  2281. });
  2282. // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
  2283. $('table.list tr td:nth-child(' + (i + 1) + ')').css({
  2284. 'min-width': (thW - 1) * font_size + 'px',
  2285. 'max-width': (thW + 1) * font_size + 'px'
  2286. });
  2287. }
  2288. $('table.list tr td:nth-child(1)').css({
  2289. 'min-width': (thW + 1) * font_size + 'px',
  2290. 'max-width': (thW + 3) * font_size + 'px'
  2291. });
  2292. $('table.list tr td:nth-child(' + arr_oth.length + ')').css({
  2293. "white-space": "inherit",
  2294. "overflow": "inherit",
  2295. "text-overflow": "inherit"
  2296. })
  2297. $('.img1').parents('td').css('cssText', 'width:90px !important');
  2298. // console.log($('.img1').parents('td').css('width'));
  2299. }
  2300. function loadScript(src, id, callback) {
  2301. if (!document.getElementById(id)) {
  2302. var head = document.getElementsByTagName('head')[0];
  2303. var script = document.createElement('script');
  2304. script.id = id;
  2305. script.type = 'text/javascript';
  2306. script.onreadystatechange = function () {
  2307. if (this.readyState == 'complete') {
  2308. callback();
  2309. }
  2310. }
  2311. script.onload = function () {
  2312. callback();
  2313. }
  2314. script.src = src;
  2315. head.appendChild(script);
  2316. } else {
  2317. callback()
  2318. };
  2319. }
  2320. // })($);
  2321. //下拉改变irame
  2322. wd.display.initWdSelectFrame = function () {
  2323. (function () {
  2324. // 查找所有的option
  2325. var optionAll = document.querySelectorAll("option[wdSelectClick]")
  2326. // 遍历option
  2327. for (var i = 0; i < optionAll.length; i++) {
  2328. var options = optionAll[i];
  2329. // 找出匹配的option
  2330. if (typeof options.getAttribute("wdSelectClick") != "undefined") {
  2331. // 为其父元素绑定一个id
  2332. options.parentNode.setAttribute("id", "wdSelect");
  2333. // 为其父元素绑定一个事件
  2334. options.parentNode.onchange = function () {
  2335. iframeSrc();
  2336. };
  2337. }
  2338. }
  2339. // 下拉默认值
  2340. function iframeSrc() {
  2341. var mySelect = document.getElementById("wdSelect");
  2342. var myOption = mySelect.options[mySelect.selectedIndex].getAttribute("wdSelectClick");
  2343. document.getElementById("wdIframe").setAttribute("src", myOption);
  2344. }
  2345. if (optionAll.length > 0)
  2346. iframeSrc();
  2347. })()
  2348. }
  2349. wd.display.home = function () {
  2350. //显示个人首页
  2351. // if (document.getElementById("mbwzbj")) {
  2352. // document.getElementById("mbwzbj").innerHTML = "个人首页";
  2353. // } else {
  2354. // var div = top.window.document.querySelector("div[name='mbwz']");
  2355. // if (!div)
  2356. try {
  2357. // wd.topWindow.window.document.querySelector("span[id='mbwzbj']").innerHTML = "个人首页";
  2358. wd.display.setHomeIconName("个人首页");
  2359. } catch (e) {
  2360. console.log(e);
  2361. }
  2362. // }
  2363. var iframe = wd.topWindow.window.document.querySelector("iframe[oriSrc]");
  2364. // console.log(iframe);
  2365. iframe.src = iframe.getAttribute("oriSrc");
  2366. //处理菜单项
  2367. /*
  2368. var menu = new dhtmlXMenuObject("menuObj440141088","dhx_black");
  2369. var casState = new Object({
  2370. ctrl: false,
  2371. alt: false,
  2372. shift: false
  2373. });
  2374. menu._clearAndHide();
  2375. if(document.getElementById("mbwzbj")!=null){ //该文字部件可能不存在
  2376. menu.dqlm=menu.itemPull[menu.idPrefix + id]["title"]; //改变当前栏目
  2377. //document.getElementById("mbwzbj").innerHTML=this.itemPull[this.idPrefix + id]["title"]; //系统菜单下项目
  2378. }
  2379. if (menu._isContextMenuVisible() && menu.contextAutoHide) menu._hideContextMenu();
  2380. menu.callEvent("onClick", ["shortcutMenu", false, casState]);
  2381. */
  2382. //
  2383. // var bjsy = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsy');
  2384. // if (bjsy != null && (bjsy.style.display == '' || bjsy.style.display == 'none'))
  2385. // bjsy.style.display = 'inline';
  2386. //
  2387. // var bjsymb = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsymb');
  2388. // if (bjsymb != null && (bjsymb.style.display == '' || bjsymb.style.display == 'none'))
  2389. // bjsymb.style.display = 'inline';
  2390. if (wd.topWindow.userEditButton_official) {
  2391. wd.topWindow.userEditButton_official.style.display = "inline"
  2392. }
  2393. if (wd.topWindow.userEditButton_personal) {
  2394. wd.topWindow.userEditButton_personal.style.display = "inline"
  2395. }
  2396. //自动调整win2的iframe大小
  2397. if (wd.topWindow.wd.base.refreshApplyIframeHeight) {
  2398. wd.topWindow.wd.base.refreshApplyIframeHeight();
  2399. }
  2400. if (wd.topWindow.wdHelpIcon)
  2401. wd.topWindow.wdHelpIcon.style.display = "none";
  2402. }
  2403. /**
  2404. 异步提交,试用 06-06 by david
  2405. config: {
  2406. param: {},
  2407. async: boolean,
  2408. contentType: string, 默认为application/x-www-form-urlencoded
  2409. dataType: string 默认为json
  2410. }
  2411. callback: success回调
  2412. error: error回调
  2413. **/
  2414. wd.display.ajaxSubmit = function (url, config, callback, error) {
  2415. var xhr = getXmlHttpRequest();
  2416. var callback = undefined == callback ? function () { }
  2417. :
  2418. callback;
  2419. var error = undefined == error ? function (err) {
  2420. console.log(err);
  2421. }
  2422. :
  2423. error;
  2424. var async;
  2425. var method;
  2426. var contentType;
  2427. var dataType; //xmlhttprequest设置datatype
  2428. if (undefined == config.async || config.async == true)
  2429. async = true;
  2430. else if (config.async == 'false')
  2431. async = false;
  2432. method = config.method;
  2433. if (method.toLocaleLowerCase() == 'get') {
  2434. url += '&'; //一般都带token参数
  2435. url += params(config.param);
  2436. }
  2437. if (undefined == config.contentType)
  2438. contentType = 'application/x-www-form-urlencoded';
  2439. else
  2440. contentType = config.contentType;
  2441. if (undefined == config.dataType)
  2442. dataType = 'json';
  2443. else
  2444. dataType = config.dataType;
  2445. xhr.responseType = dataType;
  2446. xhr.open(method, url, async);
  2447. xhr.setRequestHeader("Content-Type", contentType);
  2448. xhr.onreadystatechange = function () {
  2449. switch (xhr.readyState) {
  2450. case 1:
  2451. break;
  2452. case 2:
  2453. break;
  2454. case 3:
  2455. break;
  2456. case 4:
  2457. if (xhr.status == 200) {
  2458. /* var result = xhr.response;
  2459. if(window.JSON){
  2460. result = JSON.parse(result);
  2461. }else{
  2462. result = eval("(" + result + ")");
  2463. }
  2464. callback(result); */
  2465. callback(xhr.response);
  2466. } else {
  2467. error(xhr.response);
  2468. }
  2469. break;
  2470. }
  2471. };
  2472. if (method.toLocaleLowerCase() == 'get')
  2473. xhr.send();
  2474. else
  2475. xhr.send(params(config.param));
  2476. function params(data) {
  2477. var arr = [];
  2478. for (var i in data) {
  2479. arr.push(encodeURIComponent(i) + "=" + encodeURIComponent(data[i]));
  2480. }
  2481. return arr.join("&");
  2482. }
  2483. function getXmlHttpRequest() {
  2484. var xmlHttpRequest = null;
  2485. if ((typeof XMLHttpRequest) != 'undefined') {
  2486. xmlHttpRequest = new XMLHttpRequest();
  2487. } else {
  2488. xmlHttpRequest = new ActiveXObject('Microsoft.XMLHttp');
  2489. }
  2490. return xmlHttpRequest;
  2491. }
  2492. }
  2493. //表格批示使用,url带有单元格序号‘bgbj_xh’>0时全屏
  2494. wd.display.JumpTest = function (params) {
  2495. function FindParam(url, name) {
  2496. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  2497. var r = url.substr(1).match(reg);
  2498. if (r != null)
  2499. return unescape(r[2]);
  2500. return null;
  2501. }
  2502. /**
  2503. function openScreenLayer(src) {
  2504. var topbody = $("body", wd.topWindow.document);
  2505. var wdfs = topbody.find("#wdfullscreen"); //弹层的div
  2506. if(wdfs.length < 1) {
  2507. topbody.append("<div id='wdfullscreen' style='display:none;top:-10;'></div>");
  2508. wdfs = topbody.find("#wdfullscreen");
  2509. }
  2510. wdfs.html("");
  2511. wdfs.append("<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/ueFull.css'>").show()
  2512. 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>');
  2513. 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>');
  2514. wdfs.find(".fulscrbtn").click(function(e) {
  2515. wdfs.remove();
  2516. });
  2517. }
  2518. **/
  2519. /****/
  2520. function openScreenLayer(src) {
  2521. var topbody = $("body", wd.topWindow.document);
  2522. var wdfs = topbody.find("#wdfullscreen"); //弹层的div
  2523. if (wdfs.length < 1) {
  2524. topbody.append("<div id='wdfullscreen' style='display:none;width:100%;height:100%;margin:0;'></div>");
  2525. wdfs = topbody.find("#wdfullscreen");
  2526. }
  2527. wdfs.html("");
  2528. wdfs.append("<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/ueFull.css'>").show()
  2529. wdfs.append(
  2530. '<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>');
  2531. wdfs.find(".fullscreen").html('<iframe id="myIframe" src="' + src + '" style="width:100%;height:96%;"></iframe>');
  2532. wdfs.find(".fulscrbtn").click(function (e) {
  2533. wdfs.remove();
  2534. });
  2535. }
  2536. var a = parseInt(FindParam(params.url, "bgbj_xh"))
  2537. if (a && a > 0) {
  2538. // openScreenLayer(params.url);
  2539. params.show = "wdFullScreen";
  2540. params.width = wd.topWindow.document.body.offsetWidth;
  2541. wd.display.showComponent(params);
  2542. } else {
  2543. wd.display.showComponent(params);
  2544. }
  2545. }
  2546. //使参数指定的滚动图片全屏
  2547. wd.display.fullgdtpScreen = function (element, bjid) {
  2548. // console.log(element);
  2549. // wd.display.CmsZNRFull(element);
  2550. $("#ydfull" + bjid).css('display', '-webkit-flex');
  2551. var index_img = 0;
  2552. var lastindex_img = 0;
  2553. var full_src;
  2554. full_src = $(element).children("img")[0].src;
  2555. // console.log(full_src);
  2556. $("#imgfull" + bjid).attr("src", full_src);
  2557. var items = $("#list" + bjid).find(".ydimg_item");
  2558. if (items != undefined && items.length != 0) {
  2559. lastindex_img = items.length - 1;
  2560. for (var ii = 0; ii < items.length; ii++) {
  2561. if ($(element).children("img")[0] == $(items[ii]).children("img")[0]) {
  2562. index_img = ii;
  2563. }
  2564. }
  2565. }
  2566. var marioVideo = $("#ydfull" + bjid)[0];
  2567. // wd.display.CmsZNRFull(element);
  2568. var fullscreenchange = function () {
  2569. if (document.webkitFullscreenElement != null) {
  2570. // element.style.width = "100%";
  2571. // element.style.height = "100%";
  2572. // element.style.overflowY = 'hidden';
  2573. //console.log("进入全屏函数");
  2574. // $('#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>');
  2575. } else {
  2576. //console.log("退出全屏函数");
  2577. $("#ydfull" + bjid).hide();
  2578. //添加监听器,监听用户进入全屏和退出全屏操作
  2579. marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
  2580. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  2581. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  2582. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  2583. }
  2584. }
  2585. // 判断各种浏览器,找到正确的方法
  2586. var elem = marioVideo;
  2587. elem.onmousemove = function (e) {
  2588. // console.log(e.offsetY);
  2589. e = e || window.event;
  2590. var newY = e.screenY;
  2591. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2592. if (newY < (window.screen.height / 3) && index_img != 0) {
  2593. elem.style.cursor = "url(\"./wd/image/top.cur\"),default"; //上1/3区域
  2594. } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) {
  2595. elem.style.cursor = "url(\"./wd/image/bottom.cur\"),default"; //下1/3区域
  2596. } else {
  2597. elem.style.cursor = "default"; //中1/3区域
  2598. }
  2599. }
  2600. elem.onclick = function (e) {
  2601. e = e || window.event;
  2602. var newY = e.screenY;
  2603. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2604. if (newY < (window.screen.height / 3) && index_img != 0) { //上一张
  2605. index_img = index_img - 1;
  2606. if (items != undefined && items.length != 0) {
  2607. for (var ii = 0; ii < items.length; ii++) {
  2608. $(items[ii]).removeClass('selected');
  2609. }
  2610. full_src = $(items[index_img]).children("img")[0].src;
  2611. $("#imgfull" + bjid).attr("src", full_src);
  2612. $(items[index_img]).addClass('selected');
  2613. $("#img" + bjid).attr("src", full_src);
  2614. $("#bt" + bjid).html($(items[index_img]).children("img").eq(0).attr("alt"));
  2615. }
  2616. } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) { //下一张
  2617. index_img = index_img + 1;
  2618. if (items != undefined && items.length != 0) {
  2619. for (var ii = 0; ii < items.length; ii++) {
  2620. $(items[ii]).removeClass('selected');
  2621. }
  2622. full_src = $(items[index_img]).children("img")[0].src;
  2623. $("#imgfull" + bjid).attr("src", full_src);
  2624. $(items[index_img]).addClass('selected');
  2625. $("#img" + bjid).attr("src", full_src);
  2626. $("#bt" + bjid).html($(items[index_img]).children("img").eq(0).attr("alt"));
  2627. }
  2628. } else { //关闭
  2629. wd.display.exitFullScreen();
  2630. }
  2631. }
  2632. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  2633. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  2634. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  2635. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  2636. if (marioVideo.requestFullscreen) {
  2637. marioVideo.requestFullscreen(elem);
  2638. } else if (marioVideo.msRequestFullscreen) {
  2639. marioVideo.msRequestFullscreen(elem);
  2640. } else if (marioVideo.mozRequestFullScreen) {
  2641. marioVideo.mozRequestFullScreen(elem);
  2642. } else if (marioVideo.webkitRequestFullScreen) {
  2643. marioVideo.webkitRequestFullScreen(elem);
  2644. }
  2645. }
  2646. wd.display.fullsltScreen = function (bjid) {
  2647. $("#sltfull" + bjid).css('display', '-webkit-flex');
  2648. var index_img = 0;
  2649. var lastindex_img = 0;
  2650. var full_src;
  2651. var items_selected = $("#list" + bjid).find(".slximg_box.selected");
  2652. if (items_selected != undefined && items_selected.length != 0) {
  2653. for (var ii = 0; ii < items_selected.length; ii++) {
  2654. full_src = $(items_selected[ii]).find("img")[0].src;
  2655. // console.log(full_src);
  2656. $("#imgfull" + bjid).attr("src", full_src);
  2657. }
  2658. }
  2659. var items = $("#list" + bjid).find(".slximg_item");
  2660. if (items != undefined && items.length != 0) {
  2661. lastindex_img = items.length - 1;
  2662. for (var ii = 0; ii < items.length; ii++) {
  2663. if ($(items_selected[0]).find("img")[0] == $(items[ii]).find("img")[0]) {
  2664. index_img = ii;
  2665. }
  2666. }
  2667. }
  2668. var marioVideo = $("#sltfull" + bjid)[0];
  2669. // wd.display.CmsZNRFull(element);
  2670. var fullscreenchange = function () {
  2671. if (document.webkitFullscreenElement != null) {
  2672. // element.style.width = "100%";
  2673. // element.style.height = "100%";
  2674. // element.style.overflowY = 'hidden';
  2675. //console.log("进入全屏函数");
  2676. // $('#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>');
  2677. } else {
  2678. //console.log("退出全屏函数");
  2679. $("#sltfull" + bjid).hide();
  2680. //添加监听器,监听用户进入全屏和退出全屏操作
  2681. marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
  2682. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  2683. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  2684. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  2685. }
  2686. }
  2687. // 判断各种浏览器,找到正确的方法
  2688. var elem = marioVideo;
  2689. elem.onmousemove = function (e) {
  2690. // console.log(e.offsetY);
  2691. e = e || window.event;
  2692. var newY = e.screenY;
  2693. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2694. if (newY < (window.screen.height / 3) && index_img != 0) {
  2695. elem.style.cursor = "url(" + wd.common.loadFile("theme/meow/image/top.cur") + "),default"; //上1/3区域
  2696. } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) {
  2697. elem.style.cursor = "url(" + wd.common.loadFile("theme/meow/image/bottom.cur") + "),default"; //下1/3区域
  2698. } else {
  2699. elem.style.cursor = "default"; //中1/3区域
  2700. }
  2701. }
  2702. elem.onclick = function (e) {
  2703. e = e || window.event;
  2704. var newY = e.screenY;
  2705. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2706. if (newY < (window.screen.height / 3) && index_img != 0) { //上一张
  2707. index_img = index_img - 1;
  2708. if (items != undefined && items.length != 0) {
  2709. for (var ii = 0; ii < items.length; ii++) {
  2710. $(items[ii]).removeClass('selected');
  2711. }
  2712. full_src = $(items[index_img]).find("img")[0].src;
  2713. $("#imgfull" + bjid).attr("src", full_src);
  2714. $(items[index_img]).addClass('selected');
  2715. $("#img" + bjid).attr("src", full_src);
  2716. $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt"));
  2717. }
  2718. } else if (newY > (window.screen.height / 3 * 2) && index_img != lastindex_img) { //下一张
  2719. index_img = index_img + 1;
  2720. if (items != undefined && items.length != 0) {
  2721. for (var ii = 0; ii < items.length; ii++) {
  2722. $(items[ii]).removeClass('selected');
  2723. }
  2724. full_src = $(items[index_img]).find("img")[0].src;
  2725. $("#imgfull" + bjid).attr("src", full_src);
  2726. $(items[index_img]).addClass('selected');
  2727. $("#img" + bjid).attr("src", full_src);
  2728. $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt"));
  2729. }
  2730. } else { //关闭
  2731. wd.display.exitFullScreen();
  2732. }
  2733. }
  2734. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  2735. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  2736. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  2737. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  2738. if (marioVideo.requestFullscreen) {
  2739. marioVideo.requestFullscreen(elem);
  2740. } else if (marioVideo.msRequestFullscreen) {
  2741. marioVideo.msRequestFullscreen(elem);
  2742. } else if (marioVideo.mozRequestFullScreen) {
  2743. marioVideo.mozRequestFullScreen(elem);
  2744. } else if (marioVideo.webkitRequestFullScreen) {
  2745. marioVideo.webkitRequestFullScreen(elem);
  2746. }
  2747. }
  2748. //使参数指定的DOM元素全屏,如果不传参数则默认带个页面全屏
  2749. wd.display.fullScreen = function (element) {
  2750. element.sdasdasds = playlist;
  2751. // 判断各种浏览器,找到正确的方法
  2752. var requestMethod = element.requestFullScreen || //W3C
  2753. element.webkitRequestFullScreen || //Chrome等
  2754. element.mozRequestFullScreen || //FireFox
  2755. element.msRequestFullScreen; //IE11
  2756. if (requestMethod) {
  2757. requestMethod.call(element);
  2758. } else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
  2759. var wscript = new ActiveXObject("WScript.Shell");
  2760. if (wscript !== null) {
  2761. alert("f11");
  2762. wscript.SendKeys("{F11}");
  2763. }
  2764. }
  2765. }
  2766. //从全屏状态切换为普通状态
  2767. wd.display.exitFullScreen = function () {
  2768. // 判断各种浏览器,找到正确的方法
  2769. var exitMethod = document.exitFullscreen || //W3C
  2770. document.mozCancelFullScreen || //Chrome等
  2771. document.webkitExitFullscreen || //FireFox
  2772. document.webkitExitFullscreen; //IE11
  2773. if (exitMethod) {
  2774. exitMethod.call(document);
  2775. } else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
  2776. var wscript = new ActiveXObject("WScript.Shell");
  2777. if (wscript !== null) {
  2778. wscript.SendKeys("{F11}");
  2779. }
  2780. }
  2781. }
  2782. wd.display.CmsZNRFull = function (element) {
  2783. //目前对图片,视频,pdf,word,flash,全屏下特殊处理
  2784. var IMG_TYPE = "IMG";
  2785. var VIDEO_TYPE = "VIDEO";
  2786. var PDF_TYPE = "PDF";
  2787. var WORD_TYPE = "WORD";
  2788. var FLASH_TYPE = "FLASH";
  2789. var XLS_TYPE = "XLS";
  2790. var PPT_TYPE = "PPT";
  2791. function nrjsblmType(nrjslbm) {
  2792. var group = {
  2793. "300": IMG_TYPE,
  2794. "310": IMG_TYPE,
  2795. "320": IMG_TYPE,
  2796. "330": IMG_TYPE,
  2797. "340": IMG_TYPE,
  2798. "500": VIDEO_TYPE,
  2799. "510": VIDEO_TYPE,
  2800. "520": VIDEO_TYPE,
  2801. "1010": PDF_TYPE,
  2802. "810": PPT_TYPE,
  2803. "910": WORD_TYPE,
  2804. "1110": XLS_TYPE,
  2805. "710": FLASH_TYPE
  2806. }
  2807. return group[nrjslbm];
  2808. }
  2809. var width; //定义宽度与高度
  2810. var height;
  2811. var dataList = [];
  2812. //查找出当前所有的所有播放器
  2813. var playlist = element.querySelectorAll("[data-init]");
  2814. console.log("555:" + playlist.length);
  2815. // var nrid = null;
  2816. for (var i = 0; i < playlist.length; i++) {
  2817. var playDiv = playlist[i];
  2818. var nrJson = JSON.parse(playDiv.getAttribute("data-init"));
  2819. // console.log(nrJson);
  2820. // nrid = nrJson.resDesign.ID;
  2821. var nrjslbm = nrJson.resDesign.nrjslbm;
  2822. var TYPE = nrjsblmType(nrjslbm);
  2823. if (!TYPE)
  2824. continue;
  2825. // console.log("666:" + TYPE);
  2826. var exitFunction = null; //退出全屏回调方法
  2827. var data = {
  2828. "type": TYPE,
  2829. "nrjslbm": nrjslbm,
  2830. }
  2831. // console.log(TYPE);
  2832. if (TYPE == IMG_TYPE) {
  2833. var handle = playDiv.querySelector(".img");
  2834. width = handle.naturalWidth;
  2835. height = handle.naturalHeight;
  2836. //退出全屏用到的数据缓存
  2837. data.handle = handle;
  2838. data.width = handle.style.width;
  2839. data.height = handle.style.height;
  2840. data.exitFunction = function (data) {
  2841. // console.log(data)
  2842. data.handle.style.width = data.width;
  2843. data.handle.style.height = data.height;
  2844. }
  2845. var zzz = wd.display.CmscalZoomSize(width, height);
  2846. handle.style.width = zzz.width + "px";
  2847. handle.style.height = zzz.height + "px";
  2848. // console.log(handle.style.width)
  2849. // console.log(handle.style.height)
  2850. } else if (TYPE == VIDEO_TYPE) {
  2851. var handle = playDiv.querySelector(".video");
  2852. var handleparent = playDiv.querySelector(".videoparent");
  2853. width = handle.videoWidth;
  2854. height = handle.videoHeight;
  2855. //退出全屏还原
  2856. data.handleparent = handleparent;
  2857. data.width = handleparent.style.width;
  2858. data.height = handleparent.style.height;
  2859. data.exitFunction = function (data) {
  2860. // console.log(data)
  2861. data.handleparent.style.width = data.width;
  2862. data.handleparent.style.height = data.height;
  2863. }
  2864. var zzz = wd.display.CmscalZoomSize(width, height);
  2865. handleparent.style.width = zzz.width + "px";
  2866. handleparent.style.height = zzz.height + "px";
  2867. } else if (TYPE == PDF_TYPE || TYPE == WORD_TYPE || TYPE == XLS_TYPE) {
  2868. var handle = playDiv.querySelector(".show");
  2869. var son1 = handle.querySelector("#pf1");
  2870. if (son1 == null)
  2871. return;
  2872. width = son1.clientWidth;
  2873. height = son1.clientHeight;
  2874. var zzz = wd.display.CmscalZoomSize(width, height);
  2875. data.handle = handle;
  2876. data.overflow = handle.style.overflow;
  2877. data.zoom = handle.style.zoom;
  2878. //特殊处理excel背景颜色变黑色
  2879. if(TYPE == XLS_TYPE){
  2880. playDiv.style.background = "white";
  2881. }
  2882. data.exitFunction = function (data) {
  2883. if (zzz.zoom != null) {
  2884. element.scrollTop = element.scrollTop / zzz.zoom;
  2885. }
  2886. // console.log(data)
  2887. data.handle.style.zoom = data.zoom;
  2888. data.handle.style.overflow = data.overflow;
  2889. if(data.type == XLS_TYPE){
  2890. data.handle.style.background = "";
  2891. }
  2892. }
  2893. handle.style.zoom = zzz.zoom;
  2894. element.scrollTop = element.scrollTop * zzz.zoom;
  2895. } else if (TYPE == FLASH_TYPE) {
  2896. var handle = playDiv.querySelector("#embed");
  2897. //退出全屏方法
  2898. data.handle = handle;
  2899. data.width = handle.style.width;
  2900. data.height = handle.style.height;
  2901. data.exitFunction = function (data) {
  2902. // console.log(data)
  2903. data.handle.style.width = $("#mainDiv").innerWidth();
  2904. data.handle.style.height = $("#mainDiv").innerHeight();
  2905. }
  2906. var zzz = wd.display.CmscalZoomSize();
  2907. handle.style.width = zzz.maxWidth + 'px';
  2908. handle.style.height = zzz.maxHeight + 'px';
  2909. }
  2910. dataList.push(data);
  2911. playlist[i].dataList = dataList;
  2912. }
  2913. }
  2914. /**
  2915. *
  2916. * 计算放大后width,height,zoom
  2917. * @param {Object} w
  2918. * @param {Object} h
  2919. */
  2920. wd.display.CmscalZoomSize = function (w, h) {
  2921. var maxWidth = screen.availWidth - 1;
  2922. var maxHeight = screen.availHeight - 1; //获取页面的高度与宽度
  2923. var xswidth = w;
  2924. var xsheight = h;
  2925. if (w && h) {
  2926. //显示的高度与宽度
  2927. var ratio1 = w / maxWidth;
  2928. var ratio2 = h / maxHeight;
  2929. //根据长度与宽度获取缩放比例
  2930. if (ratio1 > 1 || ratio2 > 1) {
  2931. if (ratio1 > ratio2) { //选取较大的缩放比例
  2932. xswidth = w / ratio1;
  2933. xsheight = h / ratio1;
  2934. } else {
  2935. xswidth = w / ratio2;
  2936. xsheight = h / ratio2;
  2937. }
  2938. }
  2939. }
  2940. if (w) {
  2941. var zoom = maxWidth / w;
  2942. if (zoom >= 2) { //确定zoom 用于word与pdf放缩
  2943. zoom = 2;
  2944. }
  2945. }
  2946. return {
  2947. width: xswidth,
  2948. height: xsheight,
  2949. zoom: zoom,
  2950. maxWidth: maxWidth,
  2951. maxHeight: maxHeight
  2952. }
  2953. }
  2954. wd.display.CmsFullDiv = function (element, onFullscreen, onExitfullscreen, win) {
  2955. win = win || element.ownerDocument.defaultView;
  2956. // var video,photo,pdf,word,flash;
  2957. // console.log(element);
  2958. var marioVideo = element;
  2959. var fullscreenchange = function () {
  2960. if (win.document.webkitFullscreenElement != null) {
  2961. //$(element).addClass("scrollbar");
  2962. // $(element).css("padding","25px");
  2963. // $(element).css("box-sizing","border-box");
  2964. // element.style.overflowY = "auto";
  2965. // element.style.overflowX = "hidden";
  2966. // element.style.width = "100%";
  2967. // element.style.height = "100%";
  2968. // console.log("进入全屏函数");
  2969. // element.setAttribute("isCmsFullScreen", 'true');
  2970. win.$(element).append(
  2971. '<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>');
  2972. onFullscreen && onFullscreen()
  2973. } else {
  2974. // console.log("退出全屏函数");
  2975. win.$(element).find('#pageClose').remove();
  2976. //$(element).removeClass("scrollbar");
  2977. // $(element).css("padding","0px");
  2978. // $(element).css("box-sizing","border-box");
  2979. // element.style.height = 'auto';
  2980. // element.style.width = 'auto';
  2981. // element.setAttribute("isCmsFullScreen", 'false');
  2982. // element.style.overflowY = 'auto';
  2983. // element.style.height = '100%';
  2984. // element.style.width = '750px';
  2985. //添加监听器,监听用户进入全屏和退出全屏操作
  2986. marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
  2987. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  2988. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  2989. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  2990. onExitfullscreen && onExitfullscreen()
  2991. }
  2992. }
  2993. var elem = marioVideo;
  2994. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  2995. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  2996. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  2997. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  2998. if (marioVideo.requestFullscreen) {
  2999. marioVideo.requestFullscreen(elem);
  3000. } else if (marioVideo.msRequestFullscreen) {
  3001. marioVideo.msRequestFullscreen(elem);
  3002. } else if (marioVideo.mozRequestFullScreen) {
  3003. marioVideo.mozRequestFullScreen(elem);
  3004. } else if (marioVideo.webkitRequestFullScreen) {
  3005. marioVideo.webkitRequestFullScreen(elem);
  3006. }
  3007. }
  3008. wd.display.CmsFullScreen = function (element, onFullscreen, onExitfullscreen, win) {
  3009. win = win || element.ownerDocument.defaultView;
  3010. // var video,photo,pdf,word,flash;
  3011. // console.log(element);
  3012. var marioVideo = element;
  3013. try {
  3014. win.wd.display.CmsZNRFull(element);
  3015. } catch (e) { }
  3016. var fullscreenchange = function () {
  3017. if (win.document.webkitFullscreenElement != null) {
  3018. //$(element).addClass("scrollbar");
  3019. // $(element).css("padding","25px");
  3020. // $(element).css("box-sizing","border-box");
  3021. element.style.overflowY = "auto";
  3022. element.style.overflowX = "hidden";
  3023. element.style.width = "100%";
  3024. element.style.height = "100%";
  3025. // console.log("进入全屏函数");
  3026. element.setAttribute("isCmsFullScreen", 'true');
  3027. win.$(element).append(
  3028. '<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>');
  3029. onFullscreen && onFullscreen()
  3030. } else {
  3031. // console.log("退出全屏函数");
  3032. win.$(element).find('#pageClose').remove();
  3033. //$(element).removeClass("scrollbar");
  3034. // $(element).css("padding","0px");
  3035. // $(element).css("box-sizing","border-box");
  3036. // element.style.height = 'auto';
  3037. // element.style.width = 'auto';
  3038. element.setAttribute("isCmsFullScreen", 'false');
  3039. // element.style.overflowY = 'auto';
  3040. element.style.height = '100%';
  3041. element.style.width = '750px';
  3042. //回调退出全屏方法
  3043. var playlist = element.querySelectorAll("[data-init]");
  3044. for (var i = 0; i < playlist.length; i++) {
  3045. dataList = playlist[i].dataList;
  3046. for (var j = 0; dataList != null && j < dataList.length; j++) {
  3047. var data = dataList[j];
  3048. if (data.exitFunction) {
  3049. data.exitFunction.call(this, data);
  3050. }
  3051. }
  3052. delete playlist[i].dataList;
  3053. }
  3054. //添加监听器,监听用户进入全屏和退出全屏操作
  3055. marioVideo.removeEventListener("webkitfullscreenchange", fullscreenchange);
  3056. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  3057. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  3058. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  3059. onExitfullscreen && onExitfullscreen()
  3060. }
  3061. }
  3062. var elem = marioVideo;
  3063. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  3064. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  3065. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  3066. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  3067. if (marioVideo.requestFullscreen) {
  3068. marioVideo.requestFullscreen(elem);
  3069. } else if (marioVideo.msRequestFullscreen) {
  3070. marioVideo.msRequestFullscreen(elem);
  3071. } else if (marioVideo.mozRequestFullScreen) {
  3072. marioVideo.mozRequestFullScreen(elem);
  3073. } else if (marioVideo.webkitRequestFullScreen) {
  3074. marioVideo.webkitRequestFullScreen(elem);
  3075. }
  3076. }
  3077. //附件滑动和上下项
  3078. wd.display.CmsNrscroll = function (element, currSubNrid) {
  3079. var ismousedown = false;
  3080. var oldY,
  3081. scollY;
  3082. var nrid = currSubNrid;
  3083. element.onmousedown = function (e) {
  3084. oldscrollTop = element.scrollTop;
  3085. oldY = e.screenY;
  3086. scollY = element.scrollTop;
  3087. ismousedown = true;
  3088. }
  3089. element.onmouseup = function (e) {
  3090. ismousedown = false;
  3091. }
  3092. element.onmousemove = function (e) {
  3093. // console.log(e.offsetY);
  3094. e = e || window.event;
  3095. var newY = e.screenY;
  3096. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  3097. if (ismousedown) {
  3098. //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight)
  3099. if (oldY - newY >= 150 && element.scrollTop + element.clientHeight + 1 >= element.scrollHeight && oldscrollTop +
  3100. element.clientHeight + 1 >= element.scrollHeight) {
  3101. ismousedown = false;
  3102. // console.log("鼠标向上移动");
  3103. nrid = nextitem(nrid);
  3104. // console.log(element.getAttribute("isCmsFullScreen"));
  3105. } else if (newY - oldY >= 150 && element.scrollTop <= 0 && oldscrollTop == 0) {
  3106. ismousedown = false;
  3107. // console.log("鼠标向下移动");
  3108. nrid = lastitem(nrid);
  3109. // console.log(element.getAttribute("isCmsFullScreen"));
  3110. } else {
  3111. element.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度
  3112. }
  3113. }
  3114. }
  3115. function nextitem(nrid) {
  3116. var items = $(".dragList").find(".item");
  3117. var i = 0;
  3118. var result = nrid;
  3119. items.each(function () {
  3120. if (nrid == $(items[i]).find(".nrid").text()) {
  3121. if (i < items.length - 1) {
  3122. // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929
  3123. // $(items[i + 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929
  3124. selectItem($(items[i + 1])[0]);
  3125. loadPlayer($(items[i + 1]).find(".nrid").text(), $(items[i + 1]).find(".nrjslbm").text());
  3126. result = $(items[i + 1]).find(".nrid").text();
  3127. }
  3128. return false; //跳出循环
  3129. } else {
  3130. i++;
  3131. }
  3132. });
  3133. return result;
  3134. }
  3135. function lastitem(nrid) {
  3136. var items = $(".dragList").find(".item");
  3137. var i = 0;
  3138. var result = nrid;
  3139. items.each(function () {
  3140. if (nrid == $(items[i]).find(".nrid").text()) {
  3141. if (i > 0) {
  3142. // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929
  3143. // $(items[i - 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929
  3144. selectItem($(items[i - 1])[0]);
  3145. loadPlayer($(items[i - 1]).find(".nrid").text(), $(items[i - 1]).find(".nrjslbm").text());
  3146. //$(items[i - 1])[0].scrollTop( $(items[i - 1])[0].scrollHeight );
  3147. result = $(items[i - 1]).find(".nrid").text();
  3148. }
  3149. return false; //跳出循环
  3150. } else {
  3151. i++;
  3152. }
  3153. });
  3154. return result;
  3155. }
  3156. }
  3157. /**
  3158. * 退出登录
  3159. */
  3160. wd.display.exit = function (param) {
  3161. // console.log("exit")
  3162. wd.display.showLoad();
  3163. var beaconLogin = wd.display.beaconLogin("loginOut") || wd.display.getBeaconWhetherToOpen();
  3164. param=param||{};
  3165. var homepage=(1==param.homepage)?("&homepage="+param.homepage):"";
  3166. var urlparam=""+homepage;
  3167. /* 改。Lin
  3168. $.post("/service?wdApplication=wd&wdService=ss.exitByA&wdtest=false", {}, function (result) {
  3169. */
  3170. /* 再改,规范命名。Lin
  3171. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  3172. * &wdService= 改为 ssServ
  3173. $.post("/service?wdApplication=wd&wdService=exit", {}, function (result) {
  3174. */ $.post("/service?ssServ=exit", {}, function (result) {
  3175. var newurl=result.path+(result.path.indexOf("?")==-1?"?":"")+urlparam;
  3176. if (beaconLogin) {
  3177. setTimeout(function () {
  3178. wd.topWindow.location.href =newurl ;
  3179. }, 1000);
  3180. } else {
  3181. wd.topWindow.location.href = newurl;
  3182. }
  3183. }, "json")
  3184. }
  3185. /**
  3186. * 执行当前弹窗的wdfitheight调整事件
  3187. */
  3188. wd.display.initWdFitHeight = function (windowobj) {
  3189. var dialogid = wd.display.getwdDialogId();
  3190. if (!dialogid)
  3191. return;
  3192. //弹窗对象
  3193. var win = wd.topWindow.dhxWins.window(dialogid);
  3194. if (!win)
  3195. return;
  3196. var nextiframe = win.getFrame();
  3197. var count = 0;
  3198. while (nextiframe != null) {
  3199. if (count > 10)
  3200. break; // 最多查找10层iframe,防止死循环
  3201. count++;
  3202. //执行页面所在的初始化iframe事件
  3203. if (nextiframe.contentWindow.window.initWdFitHeightFunction) {
  3204. if (nextiframe.contentWindow.window != windowobj) {
  3205. nextiframe.contentWindow.window.initWdFitHeightFunction();
  3206. }
  3207. }
  3208. // console.log(nextiframe)
  3209. nextiframe = nextiframe.contentWindow.document.querySelector("iframe[src]");
  3210. }
  3211. }
  3212. /**
  3213. *
  3214. */
  3215. wd.display.submitToTopTab = function (submitBtn) {
  3216. if (!submitBtn)
  3217. console.error("请指定submit按钮");
  3218. var myform = submitBtn.form.cloneNode(true);
  3219. myform.style.display = "none";
  3220. submitBtn.form.parentNode.innerHTML = "";
  3221. var win = window,
  3222. topFrame = wd.display.getFrameOfWindow(win);
  3223. while (topFrame.tabObj) { //找到不是tab为止
  3224. win = win.parent;
  3225. topFrame = wd.display.getFrameOfWindow(win);
  3226. }
  3227. topFrame.contentWindow.document.body.appendChild(myform);
  3228. myform.submit();
  3229. // submitBtn.click();
  3230. }
  3231. /**
  3232. * 获取window所在的iframe
  3233. *
  3234. */
  3235. wd.display.getFrameOfWindow = function (win) {
  3236. win = win || window;
  3237. if (win != win.top && win.parent && win.parent.document.querySelectorAll("iframe").length > 0) {
  3238. var pfs = win.parent.document.querySelectorAll("iframe");
  3239. for (var i = 0; i < pfs.length; i++) {
  3240. if (pfs[i].contentWindow == win) {
  3241. return pfs[i];
  3242. }
  3243. }
  3244. console.error("没找到上级window所对应当前window的iframe")
  3245. } else {
  3246. console.warn("当前页面不存在任何iframe底下")
  3247. return null
  3248. }
  3249. }
  3250. /**
  3251. * 刷新当前的tabframe
  3252. */
  3253. wd.display.refreshTabFrame = function (wdTabNo) {
  3254. var frame = wd.display.getFrameOfWindow();
  3255. if (frame) {
  3256. if (frame.tabObj) {
  3257. if (wdTabNo && /[0-9]*/.test(wdTabNo)) {
  3258. // frame.contentWindow.wd.display.wdTabNo=wdTabNo;
  3259. var num = parseInt(wdTabNo);
  3260. frame.tabObj.selectClick(num);
  3261. } else {
  3262. frame.tabObj.selectTab.dom.click();
  3263. }
  3264. } else {
  3265. console.error("当前iframe不是tabFrame");
  3266. }
  3267. }
  3268. }
  3269. wd.display.changeFormAction = function (url, element, width, height, minHeight, maxHeight) {
  3270. var a = $(element).parents("form:first").attr("action", url);
  3271. if (a.length != 1) {
  3272. alert("找不到form元素");
  3273. return false;
  3274. }
  3275. if (a[0].checkOnly) {
  3276. if (!a[0].checkOnly(true)) {
  3277. return
  3278. }
  3279. }
  3280. if (width && height && minHeight && maxHeight) {
  3281. wd.display.resizeComponent(width, height, minHeight, maxHeight);
  3282. }
  3283. return true;
  3284. }
  3285. wd.display.MsgManager = function (timeout, minHeight, minWidth) {
  3286. if (wd.topWindow.popupPanel == null) {
  3287. // 动画小圈圈
  3288. //flashMessageDocument--fmd
  3289. $("body", wd.topWindow.document).append('<div id="fMD" style="position: fixed; display:none; pointer-events:none; z-index: 9999;" class="cursor-loading" /></div>');
  3290. 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>");
  3291. $("body", wd.topWindow.document).append(wd.topWindow.popupPanel);
  3292. timeout = timeout || 1300;
  3293. // minHeight = minHeight || "10px";
  3294. // minWidth = minWidth || "70px";
  3295. // this.element[0].className = "flashMsg-div";
  3296. // this.element[0].id = "flashmsgtipsId";
  3297. // $(".flashMsg-div").append("<div class='flashMsg-down' style='bottom: -10px;left: 7px'></div>");
  3298. // this.element.css({
  3299. // display: "none",
  3300. // position: "fixed",
  3301. // // minHeight: minHeight,
  3302. // // minWidth: minWidth,
  3303. // "z-index": "999"
  3304. // });
  3305. this.messages = [];
  3306. var this_ = this;
  3307. setInterval(function () {
  3308. // if (this_.messages.length > 1) {
  3309. // this_.removeMsg(this_.messages.shift());
  3310. // } else if (this_.messages.length == 1) {
  3311. // setTimeout(function () {
  3312. // this_.removeMsg(this_.messages.shift());
  3313. // }, 1700);
  3314. // }
  3315. if (this_.messages.length > 0) {
  3316. var span=this_.messages.shift();
  3317. setTimeout(function () {
  3318. this_.removeMsg(span);
  3319. },span.data("timeout"));
  3320. }
  3321. }, timeout);
  3322. };
  3323. this.removeMsg = function (span) {
  3324. var $span = $(span);
  3325. $span.slideUp("normal", function () {
  3326. $span.trigger("onHide");
  3327. $span.remove();
  3328. });
  3329. this.messages.length == 0 && this.element.fadeOut("fast");
  3330. }
  3331. this.pushMsg = function (msg, options) {
  3332. if (msg == "" || msg == null)
  3333. return;
  3334. var $span = $("<p>");
  3335. $span.text(msg);
  3336. $span.data("timeout",Math.max(300*(msg.length/3),1700));
  3337. $span.bind("onShow", function () {
  3338. options && options.onShow && options.onShow.call(this);
  3339. });
  3340. $span.bind("onHide", function () {
  3341. options && options.onHide && options.onHide.call(this);
  3342. });
  3343. this.messages.push($span);
  3344. this.element.prepend($span).show();
  3345. $span.fadeIn("normal", function () {
  3346. $span.trigger("onShow");
  3347. });
  3348. }
  3349. };
  3350. //开启加载动画
  3351. wd.display.showLoad = function () {
  3352. wd.topWindow.$("#fMD").show();
  3353. }
  3354. //关闭加载动画
  3355. wd.display.closeLoad = function () {
  3356. wd.topWindow.$("#fMD").hide();
  3357. }
  3358. if(!window.flashmsgmousemove){
  3359. window.flashmsgmousemove=1;
  3360. document.addEventListener("mousemove", function () {
  3361. if (wd.topWindow.$("#flashmsgtipsId").is(":visible")) {
  3362. return;
  3363. }
  3364. if (wd.display.isFixation) {
  3365. return;
  3366. }
  3367. // 有弹出窗口且大于 1 时,MSG固定右下角
  3368. if (wd.topWindow.$(".wdMaskDiv").size() > 1) {
  3369. setFixation();
  3370. }
  3371. // 无弹出窗口或弹出窗口等于 1 时,MSG跟随鼠标
  3372. else {
  3373. var xy,
  3374. x,
  3375. y;
  3376. try {
  3377. xy = recursionIframe();
  3378. x = window.event.pageX += xy.left;
  3379. y = window.event.pageY += xy.top;
  3380. } catch (e) {
  3381. //console.log("xy err " + e)
  3382. x = window.event.pageX;
  3383. y = window.event.pageY;
  3384. }
  3385. if (wd.topWindow.$("#flashmsgtipsId").find("p").size() < 1) {
  3386. // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips").removeClass("flashmsgtips-submit");
  3387. wd.topWindow.$("#flashmsgtipsId").css({
  3388. "top": y - 53 + "px",
  3389. "left": x - 7 + "px",
  3390. "bottom": "",
  3391. "right": ""
  3392. })
  3393. }
  3394. wd.topWindow.$("#fMD").css("left", x - 10);
  3395. wd.topWindow.$("#fMD").css("top", y - 4);
  3396. }
  3397. });
  3398. }
  3399. wd.display.showMsgPopup = function (msg, options) {
  3400. if (window.location.href.indexOf("view.jsp") > 0)
  3401. return;
  3402. var msgs = wd.topWindow.wd.display.popupMsgMagager = wd.topWindow.window.wd.display.popupMsgMagager || new wd.topWindow.window
  3403. .wd.display.MsgManager();
  3404. msgs.pushMsg(msg, options);
  3405. if (wd.display.isFixation) {
  3406. setFixation();
  3407. }
  3408. }
  3409. var setFixation = function () {
  3410. // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips-submit").removeClass('flashmsgtips');
  3411. wd.topWindow.$("#flashmsgtipsId").css({
  3412. "bottom": "50px",
  3413. "right": "10px",
  3414. "top": "",
  3415. "left": ""
  3416. })
  3417. }
  3418. var recursionIframe = function (win) {
  3419. try {
  3420. win = win || window;
  3421. function getTop(e) {
  3422. var offset = e.offsetTop;
  3423. if (e.offsetParent != null)
  3424. offset += getTop(e.offsetParent);
  3425. return offset;
  3426. }
  3427. function getLeft(e) {
  3428. var offset = e.offsetLeft;
  3429. if (e.offsetParent != null)
  3430. offset += getLeft(e.offsetParent);
  3431. return offset;
  3432. }
  3433. if (win.parent == top && win.parent == win || win.document == undefined) {
  3434. return {
  3435. "left": 0,
  3436. "top": 0
  3437. };
  3438. }
  3439. var winPar = win.parent;
  3440. var iframeArr = winPar.document.getElementsByTagName('IFRAME');
  3441. var targetIframe;
  3442. var iframeArr1 = win.document.getElementsByTagName('IFRAME');
  3443. for (var i = 0; i < iframeArr1.length; i++) {
  3444. var iframeElem = iframeArr1[i];
  3445. if (iframeElem.contentWindow == win) {
  3446. targetIframe = iframeElem;
  3447. break;
  3448. }
  3449. }
  3450. for (var i = 0; i < iframeArr.length; i++) {
  3451. var iframeElem = iframeArr[i];
  3452. if (iframeElem.contentWindow == win) {
  3453. targetIframe = iframeElem;
  3454. break;
  3455. }
  3456. }
  3457. var xy = {
  3458. left: getLeft(targetIframe),
  3459. top: getTop(targetIframe)
  3460. }
  3461. if (winPar.parent != winPar) {
  3462. var xy2 = recursionIframe(winPar);
  3463. xy.left += xy2.left;
  3464. xy.top += xy2.top;
  3465. }
  3466. return xy
  3467. } catch (e) {
  3468. console.log("Point err " + e)
  3469. }
  3470. }
  3471. wd.display.resizeComponent = function (width, height, minHeight, maxHeight) {
  3472. if (parseInt(width) == "NaN" || parseInt(height) == "NaN")
  3473. return;
  3474. var dialog = wd.display.getwdDialogWindows();
  3475. if (!dialog)
  3476. return
  3477. var changesize = true;
  3478. if (minHeight && !isNaN(minHeight) && maxHeight && !isNaN(maxHeight)) {
  3479. minHeight = parseInt(minHeight);
  3480. maxHeight = parseInt(maxHeight);
  3481. if (minHeight + this.Yi > wd.topWindow.innerHeight) {
  3482. height = minHeight + this.Yi;
  3483. // showNameOrId = 'wdFullScreen';
  3484. // fullScreenLimitHeight = false;
  3485. } else if (maxHeight + this.Yi < wd.topWindow.innerHeight) {
  3486. height = maxHeight + this.Yi;
  3487. } else {
  3488. height = wd.topWindow.innerHeight;
  3489. changesize = true;
  3490. // changesize = false;
  3491. // showNameOrId = 'wdFullScreen';
  3492. }
  3493. }
  3494. wd.display.addDialogLine();
  3495. if (changesize) {
  3496. dialog.setDimension(width, height);
  3497. dialog.keepInViewport(false);
  3498. dialog.center();
  3499. }
  3500. }
  3501. wd.display.reset = function (type, submitBtn, url, width, height, minHeight, maxHeight) {
  3502. var canSubmit = false;
  3503. if (submitBtn.iscommit) {
  3504. canSubmit = true;
  3505. } else if (!submitBtn.form) {
  3506. console.warn("没找到元素所在form");
  3507. } else {
  3508. if (!submitBtn.form.checkOnly) { //没有校验器
  3509. canSubmit = true;
  3510. } else if (submitBtn.form.checkOnly(true)) { //验证通过
  3511. canSubmit = true;
  3512. } else { //表单验证不通过
  3513. canSubmit = false;
  3514. }
  3515. }
  3516. if (canSubmit) {
  3517. wd.display.changeFormAction(url, submitBtn);
  3518. if (type == "dialog") {
  3519. wd.display.resizeComponent(width, height, minHeight, maxHeight);
  3520. wd.display.submitToTopTab(submitBtn);
  3521. return false;
  3522. }
  3523. // submitBtn.iscommit = true;
  3524. // submitBtn.click();
  3525. }
  3526. return canSubmit;
  3527. }
  3528. /**
  3529. * commwrite oneLine=true 限制宽度,结尾添加'...'
  3530. * @param {Object} ele
  3531. */
  3532. wd.display.initOneLine = function (ele) {
  3533. try {
  3534. var parent = ele.parentNode;
  3535. parent.removeChild(ele);
  3536. parent.setAttribute("title", parent.innerHTML);
  3537. parent.style.overflow = "hidden";
  3538. parent.style.textOverflow = "ellipsis";
  3539. parent.style.whiteSpace = "nowrap";
  3540. // 如果无效 table加样式 table-layout: fixed;
  3541. // var poffsetW = parent.offsetWidth;
  3542. // var pscrollW = parent.scrollWidth;
  3543. // console.log(poffsetW+" "+pscrollW)
  3544. // parent.setAttribute("aaa",poffsetW+"/"+pscrollW)
  3545. // if(poffsetW<pscrollW){
  3546. // parent.style.overflow="hidden";
  3547. // parent.style.textOverflow="ellipsis";
  3548. // parent.style.whiteSpace="nowrap";
  3549. // }
  3550. } catch (e) {
  3551. console.log(e)
  3552. }
  3553. };
  3554. wd.display.callback_suffix = "confirm_callback";
  3555. wd.display.cancelcallback_suffix = "cancel_callback";
  3556. wd.display.confirm = function (title, msg, callback, cancelCallback) {
  3557. var params = {
  3558. dialog: "dialog",
  3559. width: 400,
  3560. height: 180
  3561. };
  3562. //第一个参数是对象参数 {title:title,msg:msg}
  3563. if (typeof title == "object") {
  3564. $.extend(params, title);
  3565. } else {
  3566. params.title = title;
  3567. params.msg = msg;
  3568. params.callback = callback;
  3569. params.cancelCallback = cancelCallback;
  3570. params.url = "/page/sure.jsp?msg=" + encodeURIComponent(msg);
  3571. }
  3572. /// 增加,来自 PMS下载。Lin
  3573. if(!params.url)
  3574. params.url = "/page/sure.jsp?msg=" + encodeURIComponent(params.msg);
  3575. ///
  3576. var dialogid = wd.display.showComponent({
  3577. show: ["wdDialog"],
  3578. hide: [],
  3579. url: params.url,
  3580. title: params.title||" ",
  3581. width: params.width,
  3582. height: params.height
  3583. });
  3584. if (typeof params.callback == "string") {
  3585. // window[dialogid+wd.display.callback_suffix]=eval(callback);
  3586. window[dialogid + wd.display.callback_suffix] = function () {
  3587. var iframe = wd.display.getFrameOfWindow();
  3588. // console.log(this)
  3589. if (iframe.tabObj == null) {
  3590. this.location = params.callback;
  3591. } else {
  3592. this.parent.location = params.callback;
  3593. }
  3594. };
  3595. } else if (typeof params.callback == "function") {
  3596. window[dialogid + wd.display.callback_suffix] = params.callback;
  3597. }
  3598. if (params.cancelCallback) {
  3599. window[dialogid + wd.display.cancelcallback_suffix] = params.cancelCallback;
  3600. }
  3601. };
  3602. //window.confirm = wd.display.confirm;
  3603. //
  3604. wd.display.alert = function (message, options) {
  3605. wd.display.showMsgPopup(message, options);
  3606. };
  3607. // window.alert = wd.display.alert; // 再去掉,恢复 window.alert -- 需要使用不定时消失的对话框。Lin
  3608. // isFixation 为 true 时,弹窗将立刻固定在右下角
  3609. wd.display.isFixation = false;
  3610. wd.display.fixationAlert = function (message, options) {
  3611. wd.display.isFixation = true;
  3612. wd.display.showMsgPopup(message, options);
  3613. wd.display.isFixation = false;
  3614. };
  3615. // window.alert = wd.display.fixationAlert; // 再去掉,恢复 window.alert -- 需要使用不定时消失的对话框。Lin
  3616. /**
  3617. *
  3618. * 获取弹窗内所有window对象
  3619. *
  3620. */
  3621. wd.display.getwdDialogWindowObjects = function (wdDialogId) {
  3622. var contain = wd.display.getwdDialogWindows(wdDialogId);
  3623. if (!contain)
  3624. return null;
  3625. var aaa = [];
  3626. var thisIframe = contain.getFrame();
  3627. var cc = 0;
  3628. do {
  3629. if (thisIframe.contentWindow.closed)
  3630. break;
  3631. aaa.push(thisIframe.contentWindow.window);
  3632. thisIframe = thisIframe.contentWindow.document.querySelector("iframe");
  3633. cc++
  3634. } while (thisIframe && cc <= 100)
  3635. return aaa;
  3636. }
  3637. wd.display.shareTable = function (wdDialogId) {
  3638. // console.log("archive!");
  3639. var iframe = wd.display.getFrameOfWindow();
  3640. //归档按钮
  3641. if (iframe != null && iframe.contentWindow == window) {
  3642. var bottom_div = $(".bottom-down-div");
  3643. if (bottom_div.find(".submitButton").length == 0) {
  3644. // bottom_div.append("<input type=\"button\" class=\"bottom-button submitButton\" value=\"确认\" />")
  3645. // bottom_div.append("<input type=\"button\" class=\"bottom-button authorize\" value=\"授权\" />")
  3646. // bottom_div.append("<select id=\"xxgkfsmOption\"><option value='1'>系统内公开</option><option value='1'>不公开</option></select>")
  3647. bottom_div.html('<input type=\"button\" class=\"bottom-button submitButton\" value=\"确认\" />' +
  3648. '<input type=\"button\" class=\"bottom-button authorize\" value=\"授权\" />' +
  3649. '<select id=\"xxgkfsmOption\" style="display:none;"><option value="1">系统内公开</option><option value="1">不公开</option></select>' +
  3650. bottom_div.html());
  3651. bottom_div.on("click", ".authorize", function () {
  3652. wd.display.getwdDialogWindows().getFrame().contentWindow.authorize();
  3653. })
  3654. bottom_div.on("click", ".submitButton", function () {
  3655. wd.display.getwdDialogWindows().getFrame().contentWindow.agree();
  3656. })
  3657. }
  3658. }
  3659. var tokenList = [];
  3660. var tokenData = {};
  3661. var $elements = $("[onclick^='wd.display.showComponent']:not(:hidden)").each(function (num, ele) {
  3662. var showComponentFunStr = this.getAttribute("onClick");
  3663. //获取token查询
  3664. var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
  3665. var patt = reg.exec(showComponentFunStr);
  3666. if (patt == null)
  3667. return true;
  3668. var token = patt[0].split("=")[1];
  3669. tokenList.push(token);
  3670. tokenData[token] = {
  3671. 'type': 'childObject',
  3672. 'ele': this
  3673. };
  3674. });
  3675. // console.log(tokenData)
  3676. if (iframe != null && iframe.contentWindow == window) {
  3677. var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
  3678. var patt = reg.exec(window.location.href);
  3679. var token = "";
  3680. if (patt == null) {
  3681. // return true
  3682. token = window.location.href
  3683. } else {
  3684. token = patt[0].split("=")[1];
  3685. }
  3686. tokenList.push(token);
  3687. tokenData[token] = {
  3688. 'type': 'primaryObject'
  3689. };
  3690. }
  3691. if (tokenList.length == 0)
  3692. return;
  3693. // console.log(tokenList)
  3694. /* 再改,规范命名。Lin
  3695. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  3696. * &wdService= 改为 ssServ
  3697. $.post("/service?wdApplication=wd&wdService=objectDataQueryByToken", {
  3698. */ $.post("/service?ssServ=objectDataQueryByToken", {
  3699. 'tokenList': JSON.stringify(tokenList)
  3700. }, function (data) {
  3701. data = eval(data)
  3702. var mark = wd.topWindow.mark[wdDialogId];
  3703. // console.log(tokenData)
  3704. for (var i = 0; i < data.length; i++) {
  3705. var temp = data[i]
  3706. var ele = tokenData[temp.token].ele;
  3707. var type = tokenData[temp.token].type;
  3708. var keyid = temp.object + temp.id;
  3709. var checked = (temp.checked == "true" || temp.checked == true) ? true : false;
  3710. if (!mark[keyid]) {
  3711. mark[keyid] = {
  3712. 'id': temp.id,
  3713. 'type': type,
  3714. 'object': temp.object,
  3715. 'checkStatue': checked,
  3716. 'checked': checked
  3717. }
  3718. }
  3719. // console.log(mark[keyid]);
  3720. // console.log(mark[keyid])
  3721. if (type != "childObject")
  3722. continue;
  3723. var topDoc = window.document;
  3724. var chartDiv = topDoc.createElement('div');
  3725. chartDiv.setAttribute("id", keyid);
  3726. topDoc.body.appendChild(chartDiv);
  3727. // chartDiv.innerHTML = "<input id=\"" + keyid + "\" type='checkbox' " + (mark[keyid].checked ? "checked" : "") +
  3728. // " value='' />";
  3729. if (mark[keyid].checked) {
  3730. chartDiv.setAttribute("class", "smallButton-checked checked")
  3731. } else {
  3732. chartDiv.setAttribute("class", "smallButton-unchecked")
  3733. }
  3734. var bounding = ele.getBoundingClientRect();
  3735. $(chartDiv).css({
  3736. left: bounding.left - chartDiv.offsetWidth * 0.5,
  3737. top: bounding.top + (ele.offsetHeight * 0.5) - chartDiv.offsetHeight,
  3738. // width: "auto",
  3739. // height: ele.offsetHeight,
  3740. zIndex: 65535,
  3741. position: 'absolute',
  3742. // background: (mark[keyid].checkStatue != mark[keyid].checked ? 'red' : 'cyan'),
  3743. // display: 'block'
  3744. })
  3745. $(chartDiv).on("click", function () {
  3746. var id = this.getAttribute("id");
  3747. var checked = $(this).hasClass("smallButton-unchecked");
  3748. var mark = wd.topWindow.mark[wdDialogId];
  3749. mark[id]["checked"] = checked;
  3750. // console.log(checked)
  3751. if (checked) {
  3752. this.setAttribute("class", "smallButton-checked")
  3753. } else {
  3754. this.setAttribute("class", "smallButton-unchecked")
  3755. }
  3756. //
  3757. //
  3758. // $(this).css({
  3759. // background: (mark[id]["checkStatue"] != mark[id]["checked"] ? 'red' : 'cyan'),
  3760. // })
  3761. // console.log(wd.topWindow.mark[wdDialogId])
  3762. })
  3763. }
  3764. })
  3765. }
  3766. //临时js
  3767. $(function () {
  3768. //首页模板添加样式
  3769. if (wd.topWindow && wd.topWindow.MenuSetting) {
  3770. var topiframe = wd.topWindow.document.querySelector("iframe[name=" + wd.topWindow.MenuSetting.target + "]");
  3771. if (topiframe && topiframe.contentWindow) {
  3772. if (topiframe.contentWindow == window) {
  3773. $(window.document.body).addClass("home-div");
  3774. $(wd.topWindow.document.body).addClass("home-div");
  3775. $(".gridster,#pg_cj").addClass("home-div");
  3776. }
  3777. }
  3778. }
  3779. //动态添加单记录授权按钮
  3780. var wdDialogId = wd.display.getwdDialogId();
  3781. // return;
  3782. if (!wdDialogId)
  3783. return
  3784. if (!wd.topWindow.mark)
  3785. wd.topWindow.mark = {};
  3786. //打标记
  3787. if (document.querySelector("meow")) {
  3788. if (!wd.topWindow.mark[wdDialogId])
  3789. wd.topWindow.mark[wdDialogId] = {};
  3790. }
  3791. if (wd.topWindow.mark[wdDialogId]) {
  3792. wd.display.shareTable(wdDialogId);
  3793. }
  3794. var win = wd.topWindow.dhxWins.window(wdDialogId);
  3795. if (wd.topWindow.lockScreen) {
  3796. win.button("lockScreen").onclick = function () {
  3797. wd.display.beaconLogin("loginOut");
  3798. wd.topWindow.lockScreen();
  3799. }
  3800. win.button("lockScreen").show();
  3801. }
  3802. })
  3803. //查询获取object的function服务
  3804. //结果用来调用弹窗方法 wd.display.showComponent.call(window,r);
  3805. wd.display.createObjectService = function (objName, functionName) {
  3806. var p = {
  3807. objName: objName,
  3808. funcName: functionName
  3809. }
  3810. var r = null;
  3811. $.ajax({
  3812. type: "post",
  3813. /* 再改,规范命名。Lin
  3814. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  3815. * &wdService= 改为 ssServ
  3816. url: "/service?wdApplication=wd&wdService=createObjectService&wdtest=false",
  3817. */ url: "/service?ssServ=makeFuncParm",
  3818. data: p,
  3819. async: false,
  3820. dataType: "json",
  3821. success: function (result) {
  3822. r = result;
  3823. // console.log(r);
  3824. addRemoveToken(r.token);
  3825. r.show = "wdDialog";
  3826. // wd.display.showComponent.call(window,r);
  3827. if (r.pluginList) {
  3828. for (var i = 0; i < r.pluginList.lenth; i++) {
  3829. addRemoveToken(r.pluginList[i].token);
  3830. }
  3831. }
  3832. },
  3833. error: function (error) {
  3834. // alert("查询失败")
  3835. console.log(error)
  3836. }
  3837. })
  3838. return r;
  3839. }
  3840. wd.display.showTextTile = function (id, msg) {
  3841. var iii = document.getElementById(id);
  3842. iii.parentNode.setAttribute("title", msg);
  3843. iii.parentNode.removeChild(iii);
  3844. }
  3845. var styleAttrs = {
  3846. "width": "width",
  3847. "height": "minHeight"
  3848. };
  3849. var isdebug = false;
  3850. wd.display.initGrowHighHtml = function (areaId, maxHeight, buttons) {
  3851. return wd.display.initGrowHigh(areaId, maxHeight, buttons, true);
  3852. }
  3853. wd.display.initGrowHigh = function (areaId, maxHeight, buttons, multimedia) {
  3854. // if (typeof GrowHeight == "undefined")
  3855. // $.getScript("/wd/js/growHeight.js", function () {
  3856. // getGrowHeight(areaId, maxHeight, buttons);
  3857. // });
  3858. // else
  3859. return getGrowHeight(areaId, maxHeight, buttons, multimedia ? 2 : 3);
  3860. }
  3861. /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin
  3862. if (!window.wdFitHeightbqgd) {
  3863. window.wdFitHeightbqgd = 0;
  3864. }
  3865. */
  3866. if (!window.ssLblHeightByFith)
  3867. window.ssLblHeightByFith = 0;
  3868. /**
  3869. * wdfitheight传入减去高度
  3870. */
  3871. wd.display.fitHeightbqgd = function (n) {
  3872. /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin
  3873. window.wdFitHeightbqgd += n;
  3874. */ window.ssLblHeightByFith += n;
  3875. }
  3876. wd.display.initGrowHighByIds = function (ids, maxHeight) {
  3877. for (var i = 0; i < ids.length; i++) {
  3878. if (typeof ids[i] != "string") {
  3879. console.error("这不是一个ID")
  3880. continue;
  3881. }
  3882. wd.display.initGrowHigh(ids[i], maxHeight, {});
  3883. }
  3884. }
  3885. wd.display.ellipsisContent = function (dom, height) {
  3886. function setText(text) {
  3887. var nn = this.nodeName;
  3888. if (nn == "TEXTAREA" || nn == "INPUT") {
  3889. this.value = text;
  3890. } else {
  3891. this.innerText = text;
  3892. }
  3893. }
  3894. function getText() {
  3895. var nn = this.nodeName;
  3896. if (nn == "TEXTAREA" || nn == "INPUT") {
  3897. return this.value;
  3898. } else {
  3899. return this.innerText;
  3900. }
  3901. }
  3902. function haveScroll(dom) {
  3903. return dom.scrollHeight > dom.clientHeight;
  3904. }
  3905. function getCnHeight() {
  3906. var otxt = getText.call(this);
  3907. setText.call(this, "中");
  3908. var cnHeight = Math.max(this.scrollHeight, this.clientHeight);
  3909. setText.call(this, otxt);
  3910. return cnHeight;
  3911. }
  3912. var css = dom.style.cssText,
  3913. $dom = $(dom),
  3914. srcText = getText.call(dom);
  3915. dom.srcText = srcText;
  3916. var _style = window.getComputedStyle(dom);
  3917. var fontSize = _style.fontSize;
  3918. fontSize = parseInt(fontSize) || $("body").css("font-size");
  3919. var domWidth = $dom.width();
  3920. var cnHeight = getCnHeight.call(dom);
  3921. height = height || parseFloat(_style.height) || parseFloat($dom.css("min-height"));
  3922. height = Math.max(cnHeight, height);
  3923. dom.style.setProperty("height", height + "px", "important");
  3924. setText.call(dom, dom.srcText);
  3925. if (srcText.length == 0 || height == 0) {
  3926. dom.style.cssText = css;
  3927. return srcText;
  3928. }
  3929. // console.log(dom, cnHeight, height, fontSize, haveScroll(dom));
  3930. // var noBlankText = srcText.replace(/\s/g, "");
  3931. var endOffset = parseInt(domWidth / fontSize); //大概一行的字数
  3932. var viewText = srcText.substring(0, endOffset);
  3933. setText.call(dom, viewText);
  3934. var dot = false;
  3935. while (endOffset < srcText.length && !haveScroll(dom)) { //还有字但是没有滚动条,加
  3936. endOffset++;
  3937. viewText = srcText.substring(0, endOffset);
  3938. setText.call(dom, viewText);
  3939. if (haveScroll(dom)) { //
  3940. dot = true;
  3941. }
  3942. }
  3943. while (endOffset > 0 && haveScroll(dom)) { //出了滚动条,减
  3944. endOffset--;
  3945. viewText = viewText.substring(0, endOffset) + "...";
  3946. (function (vt) {
  3947. setText.call(dom, vt)
  3948. })(viewText);
  3949. }
  3950. setText.call(dom, viewText)
  3951. dom.style.cssText = css;
  3952. return viewText;
  3953. }
  3954. //显示tag圆点
  3955. wd.display.showTagState = function (url) {
  3956. // console.log(url)
  3957. $(function () {
  3958. var tokenList = []
  3959. var lis = document.querySelectorAll("[ssTabClick]"); // ("[wdtabclick]")。先改,是 wdtabclick,不是 wdTabClick。Lin
  3960. for (var i = 0; i < lis.length; i++) {
  3961. var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
  3962. var patt = reg.exec(lis[i].getAttribute("ssTabClick")); // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin
  3963. if (patt == null) {
  3964. tokenList.push(null);
  3965. } else {
  3966. var token = patt[0].split("=")[1];
  3967. tokenList.push(token);
  3968. }
  3969. }
  3970. // console.log(7777777777)
  3971. // console.log(tokenList)
  3972. //
  3973. $.post(url, {
  3974. "tokenList": JSON.stringify(tokenList)
  3975. }, function (result) {
  3976. result = eval("(" + result + ")");
  3977. // console.log(result);
  3978. for (var i = 0; i < lis.length; i++) {
  3979. if (!result[i])
  3980. continue;
  3981. if (true == result[i].cgxList) { // ("true" ==。字符串改为布尔型。Lin
  3982. lis[i].innerHTML = lis[i].innerHTML + "<span class=\"statePoint icon-highlightPoint\"></span>"
  3983. } else if (true == result[i].objectList) { // ("true" ==。字符串改为布尔型。Lin
  3984. lis[i].innerHTML = lis[i].innerHTML + "<span class=\"statePoint icon-dimPoint\"></span>"
  3985. } else { }
  3986. }
  3987. })
  3988. })
  3989. }
  3990. //级联查看 growheight前文本处理
  3991. wd.display.combineDiv = function (id) {
  3992. // console.log($("#" + id).children().find("[id$=combine]"))
  3993. //
  3994. if ($("#" + id).children().find("[id$=combine]").length > 0)
  3995. return
  3996. var content = "";
  3997. var isCascading = $("#" + id).find(".content-offButton,.content-onButton").length == 0;
  3998. if (isCascading) {
  3999. $("#" + id).children(":visible").each(function () {
  4000. content += (this.innerHTML + "&nbsp;");
  4001. })
  4002. } else {
  4003. $("#" + id).find(":visible").each(function () {
  4004. if ($(this).is("[type=button]")) {
  4005. // var name = this.getAttribute("name");
  4006. // if ("1" == $("[type=hidden][name=" + name + "]").val()) {
  4007. // content += ($("[type=button][name=" + name + "][wdValue=1]").val() + "&nbsp;");
  4008. // }
  4009. if ($(this).hasClass("content-onButton")) {
  4010. content += ($(this).val() + "&nbsp;");
  4011. }
  4012. }
  4013. })
  4014. }
  4015. if (/\&nbsp\;$/.test(content))
  4016. content = content.substring(0, content.length - "&nbsp;".length)
  4017. $("#" + id).empty().html(content);
  4018. }
  4019. wd.display.initSelectOption = function (id) {
  4020. wd.topWindow.$("#" + id).remove();
  4021. var ele = $("<div id=\"" + id + "\" class=\"popup-div hLine-highlightBlod\" >"
  4022. + "<div class=\"scrollbar\" style=\"max-height:250px;overflow-x:auto;padding-right:16px;\"></div>"
  4023. + "</div>")[0];
  4024. wd.topWindow.document.body.appendChild(ele);
  4025. return ele
  4026. }
  4027. wd.display.buildSelectOption = function (dom, datalist, valueKey, nameKey, selectValue, hasNullOption) {
  4028. var ul = dom.childNodes[0];
  4029. if (datalist && datalist.length > 0) {
  4030. var listr = hasNullOption ? '<div class=\"popupList\" status="noitem">&nbsp;&nbsp;&nbsp;</div>' : '';
  4031. for (var i = 0; i < datalist.length; i++) {
  4032. var name = datalist[i][nameKey];
  4033. var value = datalist[i][valueKey];
  4034. listr += '<div class=\"' + (value == selectValue ? ' selected ' : '') + 'popupList\" status="people" value="' + value + '"' + 'index="' + i + '">' + name + '</div>';
  4035. }
  4036. ul.innerHTML = listr;
  4037. } else {
  4038. ul.innerHTML = hasNullOption ? '<div class=\"popupList\" status="noitem">找不到相关项</div>' : '';
  4039. }
  4040. }
  4041. wd.display.queryNrSubNr = function (nrid, jlztm, datas) {
  4042. var result = [];
  4043. $.ajax({
  4044. type: 'post',
  4045. url: "/service",
  4046. dataType: "json",
  4047. data: {
  4048. ssServ: "wrCmsList", // wdService: "nrxtsy",。Lin
  4049. nrid: "T-" + nrid,
  4050. sfbf: 1,
  4051. jlztm: jlztm
  4052. },
  4053. async: false,
  4054. success: function (jsonData) {
  4055. for (var i = 0; i < jsonData.length; i++) {
  4056. result.push({
  4057. name: jsonData[i].mc,
  4058. value: jsonData[i].mswj,
  4059. nrjslbm: jsonData[i].nrjslbm
  4060. });
  4061. }
  4062. }
  4063. });
  4064. return result;
  4065. }
  4066. wd.display.initCmsbtn = function (btn, fjid) {
  4067. if (fjid != null && fjid != "") {
  4068. $.ajax({
  4069. type: "post",
  4070. url: "/service?ssServ=wrCcmsList", // =getSubNrCount",。Lin
  4071. data: {
  4072. nrid: "T-" + fjid,
  4073. jlztm: 51
  4074. },
  4075. dataType: "json", // 增加,统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  4076. success: function (data) {
  4077. /* 改,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  4078. * 去掉 JSON.parse(,改为用 Map<String, Object> 传输
  4079. var names = JSON.parse(data);
  4080. */
  4081. if (data.ssCode != 0) {
  4082. alert(data.ssMsg);
  4083. return;
  4084. }
  4085. var names = data.ssData;
  4086. var count = names.length;
  4087. //if (count > 0) {
  4088. var num = btn[0].querySelector(".attachment_count");
  4089. if (!num) {
  4090. num = document.createElement("span");
  4091. num.className = "attachment_count";
  4092. btn[0].appendChild(num);
  4093. }
  4094. num.innerText = count;
  4095. if (count == 0) {
  4096. $(num).hide();
  4097. } else {
  4098. $(num).show();
  4099. }
  4100. var datas = [];
  4101. for (var iii = 0; iii < names.length; iii++) {
  4102. datas.push({
  4103. name: iii,
  4104. value: names[iii]
  4105. })
  4106. }
  4107. btn.off("mouseenter").on("mouseenter", function () {
  4108. var menuelement = wd.display.initCmsMenu(fjid + "", 51);
  4109. if (menuelement) {
  4110. menuelement.showAt(btn[0]);
  4111. btn.off("mouseleave").on("mouseleave", function () {
  4112. menuelement.hide();
  4113. });
  4114. }
  4115. });
  4116. },
  4117. error: function (data) {
  4118. console.log(data);
  4119. }
  4120. });
  4121. }
  4122. }
  4123. wd.display.initCmsMenu = function (id) {
  4124. wd.topWindow.$("#CMSMENU").remove();
  4125. var nrid = id = id.replace(/\D*/, "");
  4126. //注册内容
  4127. $.ajax({
  4128. url: "/service",
  4129. data: {
  4130. nrid: "T-" + nrid,
  4131. ssServ: "regCms" // wdService: "register"。Lin
  4132. },
  4133. async: false,
  4134. dataType: "json",
  4135. success: function (data) {
  4136. console.log(data);
  4137. }
  4138. });
  4139. var data = wd.display.queryNrSubNr(nrid);
  4140. if (data.length == 0) {
  4141. return;
  4142. }
  4143. var mainElement = wd.display.initSelectOption("CMSMENU");
  4144. function loadPlayer(contentDiv) {
  4145. var win = contentDiv.ownerDocument.defaultView;
  4146. var se = contentDiv.srcElement,
  4147. $se = $(se),
  4148. subnrid = $se.attr("value"),
  4149. nrjslbm = $se.attr("nrjslbm");
  4150. win.$.ajax({
  4151. type: "GET",
  4152. url: "/service",
  4153. data: {
  4154. ssServ: "wrCmsPlay", // : wdService: "loadNrDesignAndPlayerData",。Lin
  4155. "nrid": subnrid,
  4156. "nrjslbm": nrjslbm
  4157. },
  4158. async: false,
  4159. dataType: "json",
  4160. success: function (data) {
  4161. /// 增加,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  4162. if (data.ssCode != 0) {
  4163. alert(data.ssMsg);
  4164. return;
  4165. }
  4166. ///
  4167. var div = document.createElement("div");
  4168. var obj = {};
  4169. obj.design = data.design;
  4170. obj.resDesign = data.resDesign;
  4171. div.setAttribute("data-init", JSON.stringify(obj));
  4172. var tempData = data.data.replace(new RegExp('@dataFolder@', 'gm'), data.dataFolderPath);
  4173. var $ma = win.$(contentDiv);
  4174. var hasClose = $ma.find("#pageClose").length > 0;
  4175. div.innerHTML = tempData;
  4176. var $div = $(div);
  4177. // $div.hide();
  4178. $ma.html($div);
  4179. $ma.append(
  4180. '<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>');
  4181. // var $content = $(contentDiv);
  4182. // loadScorll($content);
  4183. // $content.getNiceScroll().resize();
  4184. div.addEventListener("DOMSubtreeModified", function () {
  4185. try {
  4186. win.wd.display.CmsZNRFull(contentDiv);
  4187. } catch (e) { }
  4188. // var $content = $(contentDiv);
  4189. // loadScorll($content);
  4190. // $content.getNiceScroll().resize();
  4191. // $content.css("height", $content.height());
  4192. // $content.css("height", "100%");
  4193. });
  4194. }
  4195. });
  4196. var $pe = $se.prev(".popupList"),
  4197. prev = $pe.attr("value"),
  4198. $ne = $se.next(".popupList"),
  4199. next = $ne.attr("value");
  4200. var ismousedown = false;
  4201. var oldY,
  4202. scollY;
  4203. contentDiv.onmousedown = function (e) {
  4204. oldscrollTop = contentDiv.scrollTop;
  4205. oldY = e.screenY;
  4206. scollY = contentDiv.scrollTop;
  4207. ismousedown = true;
  4208. }
  4209. contentDiv.onmouseup = function (e) {
  4210. ismousedown = false;
  4211. }
  4212. contentDiv.onmousemove = function (e) {
  4213. e = e || window.event;
  4214. var newY = e.screenY;
  4215. if (ismousedown) {
  4216. //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight)
  4217. if (oldY - newY >= 150 && contentDiv.scrollTop + contentDiv.clientHeight + 1 >= contentDiv.scrollHeight && oldscrollTop +
  4218. contentDiv.clientHeight + 1 >= contentDiv.scrollHeight) {
  4219. ismousedown = false;
  4220. // console.log("鼠标向上移动");
  4221. if ($ne.length > 0) {
  4222. contentDiv.srcElement = $ne[0];
  4223. loadPlayer(contentDiv);
  4224. }
  4225. // console.log(contentDiv.getAttribute("isCmsFullScreen"));
  4226. } else if (newY - oldY >= 150 && contentDiv.scrollTop <= 0 && oldscrollTop == 0) {
  4227. ismousedown = false;
  4228. // console.log("鼠标向下移动");
  4229. if ($pe.length > 0) {
  4230. contentDiv.srcElement = $pe[0];
  4231. loadPlayer(contentDiv);
  4232. }
  4233. // console.log(contentDiv.getAttribute("isCmsFullScreen"));
  4234. } else {
  4235. contentDiv.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度
  4236. }
  4237. }
  4238. }
  4239. // console.log("加载播放器完毕")
  4240. }
  4241. mainElement.style.minWidth = "180px";
  4242. wd.display.buildSelectOption(mainElement, data, "value", "name", "null");
  4243. var $mainElement = wd.topWindow.$(mainElement);
  4244. $.each(data, function () {
  4245. $mainElement.find("[value='" + this.value + "']").attr("nrjslbm", this.nrjslbm);
  4246. });
  4247. $mainElement.find(".popupList").click(function () {
  4248. //绑定全屏
  4249. var doc = mainElement.ownerDocument;
  4250. var maindiv = doc.querySelector("#CMSPLAY" + id);
  4251. if (maindiv == null) {
  4252. //创建打的包装div
  4253. maindiv = doc.createElement("div");
  4254. maindiv.id = "CMSPLAY" + id;
  4255. maindiv.style.textAlign = "center";
  4256. maindiv.onselectstart = function () {
  4257. return false;
  4258. }
  4259. doc.body.appendChild(maindiv);
  4260. $(maindiv).append('<link rel="stylesheet" href="/ss/pdf/base.min.css">');
  4261. $(maindiv).append('<link rel="stylesheet" href="/ss/pdf/fancy.min.css">');
  4262. $(maindiv).append('<script type="text/javascript" src="/ss/pdf/compatibility.min.js"></script>');
  4263. $(maindiv).append('<script type="text/javascript" src="/ss/pdf/pdf2htmlEX.min.js"></script>');
  4264. var contentDiv = maindiv.contentDiv = doc.createElement("div");
  4265. contentDiv.className = "mainDiv";
  4266. contentDiv.style.width = "100%";
  4267. contentDiv.style.height = "100%";
  4268. contentDiv.style.display = "flex";
  4269. contentDiv.style.justifyContent = "center";
  4270. contentDiv.style.background = "white";
  4271. contentDiv.style.alignItems = "center";
  4272. maindiv.appendChild(contentDiv);
  4273. }
  4274. maindiv.contentDiv.srcElement = this;
  4275. // setTimeout(function () {
  4276. // console.log("开始全屏")
  4277. doc.defaultView.wd.display.CmsFullScreen(maindiv.getElementsByTagName('DIV')[0], function () {
  4278. loadPlayer(maindiv.contentDiv);
  4279. $(maindiv).children("#pageClose").remove();
  4280. }, function () {
  4281. maindiv.parentNode.removeChild(maindiv);
  4282. doc.defaultView.clearInterval(maindiv.contentDiv.intervalID);
  4283. });
  4284. // }, 500);
  4285. });
  4286. $mainElement.mouseenter(function () {
  4287. if (this.removeTimerId != null) {
  4288. this.ownerDocument.defaultView.clearTimeout(this.removeTimerId);
  4289. this.removeTimerId = null;
  4290. }
  4291. });
  4292. mainElement.hide = function () {
  4293. mainElement.removeTimerId = mainElement.ownerDocument.defaultView.setTimeout(function () {
  4294. $mainElement.remove();
  4295. }, 300);
  4296. };
  4297. $mainElement.mouseleave(function () {
  4298. this.hide();
  4299. });
  4300. mainElement.showAt = function (element) {
  4301. $mainElement.show();
  4302. var bounding = element.getBoundingClientRect(),
  4303. mb = mainElement.getBoundingClientRect(),
  4304. xy = recursionIframe(window);
  4305. var left = bounding.right + xy.left - mb.width;
  4306. var top_ = bounding.top + xy.top - 10 - mb.height;
  4307. $mainElement.css({
  4308. left: left,
  4309. top: top_
  4310. });
  4311. }
  4312. $mainElement.click(function (e) {
  4313. e.stopPropagation();
  4314. });
  4315. $("body").click(function () {
  4316. mainElement.hide()
  4317. });
  4318. $("body", wd.topWindow.document).click(function () {
  4319. mainElement.hide()
  4320. });
  4321. $mainElement.hide();
  4322. return mainElement;
  4323. }
  4324. //获取表单元素
  4325. //growHeight
  4326. //objectpicker
  4327. //onoffbutton
  4328. //ueditor
  4329. //input select datepicker
  4330. //编辑帮助,个人选值
  4331. wd.display.getInputsGroups = function () {
  4332. var arr = $("form,input,select,:radio,:checkbox").serializeArray();
  4333. var ret = {};
  4334. for (var i = 0; i < arr.length; i++) {
  4335. var name = arr[i].name;
  4336. if (!name)
  4337. continue;
  4338. if (/objectPicker.*/.test(name))
  4339. continue;
  4340. var cc = wd.display.getInputBox(name);
  4341. if (!cc)
  4342. continue;
  4343. ret[name] = cc;
  4344. }
  4345. return ret;
  4346. }
  4347. /**
  4348. *
  4349. * @param {Object} name
  4350. * @param {Object} any true:不过滤隐藏元素
  4351. */
  4352. wd.display.getInputBox = function (name,any) {
  4353. if(wd.display.filterInputBoxNames[name]){
  4354. // console.log("filterInputBoxNames:"+name);
  4355. return null;
  4356. }
  4357. var result = {
  4358. name: name,
  4359. container: null, //定位元素
  4360. setChange:null,
  4361. focus:null,//光标
  4362. onKeyDown:null,//enter key event
  4363. onKeyDownContainer: null,
  4364. modify:null,
  4365. modifyContainer:null
  4366. };
  4367. result.getValue = function () {
  4368. return $(this.container).val()
  4369. }
  4370. result.setValue = function (v) {
  4371. $(this.container).val(v)
  4372. }
  4373. result.setChange = function (changefunc) {
  4374. $(this.container).on("change",changefunc);
  4375. }
  4376. result.focus = function () {
  4377. $(this.container).focus();
  4378. }
  4379. result.modify= function (canmodify) {
  4380. if(canmodify){
  4381. $(this.modifyContainer||this.container ).removeAttr("readonly");
  4382. }else{
  4383. $(this.modifyContainer||this.container).attr("readonly","readonly");
  4384. }
  4385. }
  4386. //键盘录入监听,keycode 9:tab 13:enter
  4387. result.onKeyDown=function (keycode,func) {
  4388. var code=[];
  4389. code=keycode;
  4390. $(this.onKeyDownContainer||this.container).on("keydown",function(){
  4391. if(code.indexOf(window.event.keyCode)!=-1){
  4392. return func();
  4393. }
  4394. });
  4395. }
  4396. try {
  4397. if (window.growHeightList &&window.growHeightList[name]) {
  4398. result.type = "growHeight"
  4399. result.instance = growHeightList[name];
  4400. result.container = growHeightList[name].container.parentNode
  4401. result.getValue = function () {
  4402. return this.instance.val();
  4403. }
  4404. result.setValue = function (v) {
  4405. this.instance.val(v);
  4406. }
  4407. result.focus = function () {
  4408. this.instance.onFocus()
  4409. }
  4410. result.onKeyDownContainer=$(growHeightList[name].getInputElement().parentNode).find("textarea");
  4411. result.modifyContainer=growHeightList[name].getInputElement();
  4412. } else if (wd && wd.edit && wd.edit.objectPicker && wd.edit.objectPicker.getInstance(name)) {
  4413. result.type = "objectPicker"
  4414. result.instance = wd.edit.objectPicker.getInstance(name);
  4415. result.container = result.instance.getDisplayElement();
  4416. result.getValue = function () {
  4417. return this.instance.getValue()
  4418. }
  4419. result.setValue = function (v) {
  4420. this.instance.initValue(v);
  4421. }
  4422. result.setChange=function(func){
  4423. this.instance.onchange=func;
  4424. }
  4425. result.modify=function(canmodify){
  4426. this.instance.modify(canmodify);
  4427. }
  4428. } else if (window.EditorManager&&EditorManager.instances&&EditorManager.instances[name]) {
  4429. result.type = "ueditor"
  4430. result.container =EditorManager.instances[name].getUeditor().container;
  4431. result.instance =EditorManager.instances[name].getUeditor();
  4432. result.getValue = function () {
  4433. var c= this.instance.getContent();
  4434. return (c)?wd.display.toPlainText():c;
  4435. }
  4436. result.setValue = function (v) {
  4437. return this.instance.setContent(v);
  4438. }
  4439. } else if ($("#" + name + "_onoffbutton_list").length == 1) {
  4440. result.type = "onoffbutton"
  4441. result.container = $("[name="+name+"][type=button]").last()[0];
  4442. result.getValue = function () {
  4443. return $("[name='"+name+"'][type=hidden]").val();
  4444. }
  4445. result.setValue = function (v) {
  4446. /* 改,是小写的 wdvalue=,也改先 -- 规范命名。Lin
  4447. $("[name='"+name+"'][type=button][wdvalue="+v+"]").click();
  4448. */ $("[name='"+name+"'][type=button][ssVal="+v+"]").click();
  4449. }
  4450. }else if(window.enrolDateList&&window.enrolDateList[name]){
  4451. result.type = "enrolDate"
  4452. result.instance = window.enrolDateList[name];
  4453. result.container = window.enrolDateList[name].container
  4454. result.getValue = function () {
  4455. return this.instance.getValue();
  4456. }
  4457. result.setValue = function (v) {
  4458. this.instance.setValue(v);
  4459. }
  4460. result.setChange=function(func){
  4461. this.instance.onchange=func;
  4462. }
  4463. }else if(window.editPhotoList&&window.editPhotoList[name]){
  4464. result.type = "editPhoto"
  4465. result.instance = window.editPhotoList[name];
  4466. result.container = window.editPhotoList[name].container;
  4467. result.getValue = function () {
  4468. return this.instance.getValue();
  4469. }
  4470. result.setValue = function (v) {
  4471. this.instance.setValue(v);
  4472. }
  4473. result.modify=function(canmodify){
  4474. this.instance.modify(canmodify);
  4475. }
  4476. } else if (document.querySelector("[name='" + name + "']")) {
  4477. result.type = "input";
  4478. result.container = document.querySelector("[name='" + name + "']");
  4479. } else {
  4480. return null;
  4481. }
  4482. if(any){
  4483. }else{
  4484. if ($(result.container).width() == 0)
  4485. return null;
  4486. }
  4487. } catch (e) {
  4488. console.log(e);
  4489. }
  4490. return result;
  4491. }
  4492. if(!wd.display.filterInputBoxNames){
  4493. wd.display.filterInputBoxNames={};
  4494. }
  4495. /**
  4496. * 过滤inputbox
  4497. */
  4498. wd.display.filterInputBox=function (name) {
  4499. for(var i=0;i<arguments.length;i++){
  4500. var m=arguments[i];
  4501. wd.display.filterInputBoxNames[m]="1";
  4502. }
  4503. // console.log(wd.display.filterInputBoxNames);
  4504. }
  4505. wd.display.changeFirstTitle = function (t) {
  4506. var displgid = wd.display.getwdDialogId();
  4507. if (!displgid)
  4508. return;
  4509. wd.topWindow.dhxWins.window(displgid).querySelector(".dialog-title").innerHTML = t
  4510. }
  4511. wd.display.changeSecondTitle = function (t) {
  4512. var displgid = wd.display.getwdDialogId();
  4513. if (!displgid)
  4514. return;
  4515. wd.topWindow.dhxWins.window(displgid).querySelector(".secondTitle").innerHTML = t
  4516. }
  4517. /**
  4518. * 判断当前url是否个人首页
  4519. * @param {Object} win
  4520. */
  4521. wd.display.isPersonalHomePageUrl = function (url) {
  4522. if (!url)
  4523. return false;
  4524. return url.indexOf("initDesktop") == -1 ? false : true;
  4525. }
  4526. /**
  4527. * 生成更多按钮
  4528. * @param {Object} buttonId
  4529. * @param {Object} childrenClass
  4530. * selectedDiv 选中菜单,显示按钮名称
  4531. * recordvalue 启用个人选值
  4532. */
  4533. wd.display.attachButton = function (buttonId, childrenClass, selectedDiv, buttonNotClickAschild, recordvalue) {
  4534. var $button = $("#" + buttonId);
  4535. var vanishId;
  4536. //获取二级数据
  4537. function findDatalist() {
  4538. var datalist = [];
  4539. var d = document.querySelectorAll("." + childrenClass);
  4540. //adminNo
  4541. for (var i = 0; i < d.length; i++) {
  4542. datalist.push({
  4543. name: d[i].getAttribute("value"),
  4544. value: d[i].getAttribute("value"),
  4545. ele: d[i]
  4546. });
  4547. }
  4548. return datalist;
  4549. }
  4550. function showChild(v, isinit) {
  4551. var datalist = findDatalist();
  4552. var thisdata;
  4553. for (var i = 0; i < datalist.length; i++) {
  4554. if (datalist[i].value == v) {
  4555. thisdata = datalist[i];
  4556. }
  4557. }
  4558. //记忆,点击按钮触发上一个点击过的选项
  4559. $button.off("click");
  4560. if (true === buttonNotClickAschild) {
  4561. $button.on("click", function () {
  4562. vanishId = setTimeout(function () {
  4563. $("#" + buttonId + "_buttons").hide();
  4564. }, 500)
  4565. })
  4566. } else {
  4567. $("#" + buttonId + "_buttons").hide();
  4568. var html = thisdata ? thisdata.name : "";
  4569. if (true === isinit) {
  4570. html = $button.val() + html;
  4571. }
  4572. if (selectedDiv) {
  4573. $button.find(selectedDiv).html(html);
  4574. } else if ($button.is("input")) {
  4575. $button.val(html);
  4576. }
  4577. $button.on("click", function () {
  4578. $(thisdata.ele).trigger("click");
  4579. })
  4580. }
  4581. return thisdata;
  4582. }
  4583. $button.on("mouseenter click", function () {
  4584. //获取下拉数据
  4585. var datalist = findDatalist();
  4586. //create div
  4587. $("#" + buttonId + "_buttons").remove();
  4588. var dom = wd.display.initSelectOption(buttonId + "_buttons");
  4589. if (datalist.length > 0) {
  4590. /* 再改,不知为何要反转 细分部件(原 plugin) 顺序???Lin
  4591. wd.display.buildSelectOption(dom, datalist.reverse(), "value", "name", null, false);
  4592. */ wd.display.buildSelectOption(dom, datalist, "value", "name", null, false);
  4593. $("body").append(dom);
  4594. }
  4595. //position
  4596. var dombounding = dom.getBoundingClientRect();
  4597. var bounding = (this.querySelector("img") || this).getBoundingClientRect();
  4598. //console.log(bounding);
  4599. var left = bounding.left;
  4600. //防止超出屏幕出现滚动条
  4601. if ((left + dombounding.width) > window.innerWidth) {
  4602. left = window.innerWidth - dombounding.width;
  4603. }
  4604. dom.style.left = Math.max(left, 0) + "px";
  4605. if (bounding.top + bounding.height + dombounding.height > window.innerHeight) {
  4606. dom.style.top = (bounding.top - dombounding.height) + "px"
  4607. //console.log("up side")
  4608. } else {
  4609. //console.log("down side")
  4610. dom.style.top = (bounding.top + bounding.height) + "px"
  4611. }
  4612. //bind event
  4613. $(dom).on("click", ".popupList", function () {
  4614. if (window.event) {
  4615. if (window.event.stopPropagation) {
  4616. window.event.stopPropagation();
  4617. } else {
  4618. window.event.cancelBubble = true;
  4619. }
  4620. }
  4621. var v = this.getAttribute("value");
  4622. var thisdata = showChild(v);
  4623. $(thisdata.ele).trigger("click");
  4624. // console.log(thisdata);
  4625. if (recordvalue) {
  4626. var recordzhi = {};
  4627. recordzhi[buttonId] = {
  4628. value: v,
  4629. default:
  4630. true
  4631. };
  4632. wd.edit.insertRecord(recordzhi);
  4633. }
  4634. }).on("mouseleave", function () {
  4635. $(this).hide();
  4636. }).on("mouseenter", function () {
  4637. if (vanishId)
  4638. clearTimeout(vanishId);
  4639. })
  4640. }).on("mouseleave", function () {
  4641. if ($(window.event.relatedTarget).is($(this).parents())) {
  4642. vanishId = setTimeout(function () {
  4643. $("#" + buttonId + "_buttons").hide();
  4644. }, 500)
  4645. }
  4646. })
  4647. if (recordvalue) {
  4648. $(function () {
  4649. var record = wd.edit.getRecord();
  4650. // console.log(record);
  4651. if (record && record[buttonId]) {
  4652. var v = record[buttonId].value;
  4653. showChild(v, true);
  4654. }
  4655. })
  4656. }
  4657. }
  4658. wd.display.inputCaptcha = function (name, captchalength) {
  4659. try {
  4660. var inputbox = wd.display.getInputBox(name);
  4661. if (!inputbox)
  4662. return;
  4663. var inputClass = name + "_inputCaptcha";
  4664. var va = $("<div style=\"position:absolute; left: 5px;top: 5px;width: 100%;height: 100%;z-index: 1;display: flex;\">"
  4665. + "<div class=\"hLine\" style=\"display: flex; height: 30px;\">"
  4666. + "<input class=\"" + inputClass + "\" style=\"width:140px;border: none;padding-left: 7px;\" placeholder='请输入验证码'/>"
  4667. + "<img align=\"middle\" vspace=\"2\" id=\"codeimg\" title=\"看不清楚可单击刷新\" class=\"header_yzmimg\" src=\"/wd/verificationCode.do?" + new Date().getTime() + "\">"
  4668. // +"<input type=\"button\" value=\"确定\" class=\"content-button\" onclick=\"void(0);\" style=\"margin-left: 10px;\"/>"
  4669. + "</div>"
  4670. + "</div>");
  4671. // va.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",background:"azure",zIndex:1})
  4672. $(inputbox.container).before(va);
  4673. va.on("click", "img", function () {
  4674. this.setAttribute("src", "/wd/verificationCode.do?" + new Date().getTime());
  4675. }).on("blur", "." + inputClass, function () {
  4676. /* 再改,规范命名。Lin
  4677. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  4678. * &wdService= 改为 ssServ
  4679. $.post("/service?wdApplication=wd&wdService=checkCaptcha_ajax&wdtest=false", {
  4680. */ $.post("/service?ssServ=checkCaptcha_ajax", {
  4681. yzm: this.value
  4682. }, function (result) {
  4683. if ("1" == result.result) {
  4684. va.hide();
  4685. $(inputbox.container).show();
  4686. if (typeof window.inputCaptchaCallback == "function")
  4687. window.inputCaptchaCallback();
  4688. } else {
  4689. wd.display.alert("验证码错误!")
  4690. }
  4691. }, "json")
  4692. })
  4693. $(inputbox.container).hide();
  4694. } catch (e) {
  4695. console.log(e);
  4696. }
  4697. }
  4698. wd.display.previewPicture = function (url, errorPhoto) {
  4699. if ($(window.event.srcElement).is("input,button"))
  4700. return;
  4701. $('.previewPicture').remove();
  4702. // var onerror = errorPhoto ? ('this.src=\'' + errorPhoto + '\'') : "";
  4703. var onerror = "";
  4704. // if(true)return;
  4705. // $("<div class='previewPicture ' style=\"display:none;z-index: 999999;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);border: 1px solid #6c9ddb;\">"
  4706. // + "<img src=" + url + " onerror=\"" + onerror + "\" style=\"max-width:100%;max-height: 100%;\" onload=\"$('.previewPicture').show()\"/>"
  4707. // +"<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>"
  4708. // +"<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>"
  4709. // + "</div>")
  4710. // .appendTo("body")
  4711. // .on('click',".close", function () {
  4712. // $('.previewPicture').remove();
  4713. // });
  4714. var startLeft,startTop,startX,startY;
  4715. $("<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;\">"
  4716. +'<div class="lightDialog-title hLine">'
  4717. +'<div title="下载" class="download icon-download" style="position: absolute;right: 35px;top: 9px;"></div>'
  4718. +'<div title="关闭" class="close icon-close"></div>'
  4719. +'</div>'
  4720. + "<img src=" + url + " onerror=\"" + onerror + "\" style=\"max-width:100%;max-height: 100%;\" onload=\"$('.previewPicture').show()\"/>"
  4721. + "</div>"
  4722. )
  4723. .appendTo("body")
  4724. .on('click',".close", function () {
  4725. $('.previewPicture').remove();
  4726. }).on('click',".download", function () {
  4727. wd.display.downloadFile(url+"&download=1");
  4728. // $('.previewPicture').remove();
  4729. });
  4730. // on("mousedown",function(){
  4731. // startLeft=parseInt( $(this).css("marginLeft"));
  4732. // startTop=parseInt( $(this).css("marginTop"));
  4733. // startX=window.event.clientX;
  4734. // startY=window.event.clientY;
  4735. // this.setAttribute("move","1");
  4736. // }).on("mouseup mouseout",function(){
  4737. // this.setAttribute("move","0");
  4738. // }).on("mousemove",function(){
  4739. // if("1"!=this.getAttribute("move"))return;
  4740. // $(this).css({
  4741. // marginLeft:startLeft+window.event.clientX-startX,
  4742. // marginTop:startTop+window.event.clientY-startY
  4743. // })
  4744. // })
  4745. }
  4746. wd.display.beaconLogin = function (type) {
  4747. type = type || 'login';
  4748. try {
  4749. if (typeof beacon == "undefined")
  4750. return false;
  4751. if (type == 'login') {
  4752. beacon.login(wd.topWindow.beaconLoginTicket);
  4753. } else {
  4754. beacon.loginOut();
  4755. }
  4756. return true;
  4757. } catch (error) {
  4758. console.log('------------------------------------');
  4759. console.log(error);
  4760. console.log('------------------------------------');
  4761. }
  4762. return false;
  4763. }
  4764. wd.display.getBeaconWhetherToOpen = function () {
  4765. try {
  4766. if (typeof beacon == "undefined")
  4767. return false;
  4768. if (beacon.getBeaconWhetherToOpen() == "True") {
  4769. alert("“待办列表”已在烽火台打开");
  4770. beacon.close2();
  4771. }
  4772. return true;
  4773. } catch (error) {
  4774. console.error(error);
  4775. }
  4776. return false
  4777. }
  4778. wd.display.refreshToDoList = function () {
  4779. wd.display.refreshHomeplugin("6011");
  4780. }
  4781. wd.display.refreshHomeplugin = function (type) {
  4782. if (!wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL)
  4783. return "0";
  4784. return wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL.refreshHomeplugin(type)
  4785. }
  4786. wd.display.setCloseWindowParam = function (p) {
  4787. if (!p)
  4788. return;
  4789. var wdDialogId = wd.display.getwdDialogId();
  4790. if (!wdDialogId)
  4791. return;
  4792. var win = wd.topWindow.dhxWins.window(wdDialogId);
  4793. win.closeWindowParam = p;
  4794. return win;
  4795. }
  4796. wd.display.onCloseDialog = function (win, popWindow) {
  4797. try {
  4798. // console.log("wd.display.onCloseDialog");
  4799. // console.log(win.closeWindowParam);
  4800. if (!win.closeWindowParam)
  4801. return;
  4802. var openerWindow = popWindow.wd.display.getwdDialogOpener();
  4803. var name = openerWindow.wd.edit.objectPicker.addButtonClickName;
  4804. if (!name)
  4805. return;
  4806. var objectpickerobj = openerWindow.wd.edit.objectPicker.getInstance(name);
  4807. if (!objectpickerobj)
  4808. return;
  4809. // var data={option:[{name:"abc",id:"999"}]};
  4810. var data = eval("(" + win.closeWindowParam + ")")
  4811. objectpickerobj.setwdCloseWindowParamData(data);
  4812. // console.log(objectpickerobj);
  4813. } catch (err) {
  4814. console.error(err);
  4815. }
  4816. }
  4817. /**
  4818. * 调用关闭窗口时调用的回调方法
  4819. */
  4820. wd.display.closeDialogCallbackFun = null;
  4821. /**
  4822. * 给一个按钮绑定事件
  4823. * @param {Object} buttonname
  4824. * @param {Object} bindevent
  4825. * @param {Object} bindfunction
  4826. */
  4827. wd.display.bindWdButton = function (buttonname, bindevent, bindfunction) {
  4828. var wdDialogId = wd.display.getwdDialogId();
  4829. if (!wdDialogId)
  4830. return;
  4831. var win = wd.topWindow.dhxWins.window(wdDialogId);
  4832. var b = win.button(buttonname);
  4833. $(b).on(bindevent, bindfunction);
  4834. }
  4835. /**
  4836. * px 2 rem
  4837. */
  4838. wd.display.px2Rem = function (px) {
  4839. var unit = parseFloat($("html").css("font-size"));
  4840. return px / unit;
  4841. }
  4842. /**
  4843. *
  4844. * rem 2 px
  4845. */
  4846. wd.display.rem2Px = function (rem) {
  4847. var unit = parseFloat($("html").css("font-size"));
  4848. return rem * unit;
  4849. }
  4850. /*
  4851. *
  4852. 调用示例
  4853. 1:
  4854. wd.flashMsg.show({
  4855. el: $("#domDiv"), // 吸附的元素
  4856. msg: "hi,hello", // 内容
  4857. time: 200000, // 显示的时间,默认 3000,单位毫秒,
  4858. offset: 'd', // 气泡方向,[u]: 上, [d]: 下,当所定的方向无法完全显示内容时,将自动进行调整方向
  4859. arrowsOffset: 'r', // 箭头方位,[l]:左边,[c]:居中,[r]:右,默认为[c]居中
  4860. zindex: 100, // 层级,默认 1996,
  4861. animate: true, // 为真则开启动画,默认开启
  4862. end: function() {
  4863. console.log("销毁后的回调");
  4864. }
  4865. });
  4866. 2:
  4867. wd.flashMsg.show("内容");
  4868. */
  4869. wd.flashMsg = {
  4870. vars: {
  4871. ARROWS_UP_CLASS_NAME: "flashMsg-up",
  4872. ARROWS_DOWN_CLASS_NAME: "flashMsg-down"
  4873. },
  4874. timeout: undefined,
  4875. flashDivTemplate: `<div class="flashMsg-div {flashMsgClassName}" id="flashmsgtipsId" style="left: 0px; top: 0px; display: none;{position}">
  4876. <p>{msg}</p>
  4877. <div class="{arrorwsClassName}" style="{arrorwsStyle}"></div>
  4878. </div>`,
  4879. show: function (param) {
  4880. var setting;
  4881. if(typeof param=="object"){
  4882. setting=param;
  4883. }else{
  4884. setting={
  4885. el:window.event.srcElement,
  4886. msg:param
  4887. }
  4888. }
  4889. if (!this.validation(setting)) {
  4890. return;
  4891. }
  4892. // 获取吸附元素的坐标和宽高
  4893. // var positionObj = this.getAbsolute(document, $(setting.el)[0]);
  4894. var positionObj = $(setting.el).position();
  4895. var offsetObj = $(setting.el).offset();
  4896. var elTop = offsetObj.top;
  4897. var elLeft = offsetObj.left;
  4898. var elWidth = $(setting.el).innerWidth();
  4899. var elHeight = $(setting.el).innerHeight();
  4900. setting.time = isNaN(setting.time)? 3000:setting.time; // 显示时间,默认3秒
  4901. setting.animate = setting.animate == undefined ? true : setting.animate; // 动画,默认为真
  4902. setting.zindex = this.isNull(setting.zindex) ? 1996 : setting.zindex; // 气泡的层级样式,默认层级 999
  4903. setting.offset = this.isNull(setting.offset) ? 'd' : setting.offset; // 气泡的定位样式,默认在下面
  4904. setting.arrowsOffset = this.isNull(setting.arrowsOffset) ? 'l' : setting.arrowsOffset; // 箭头的定位样式,默认左边
  4905. var arrorwsStyle = ""; // 箭头样式
  4906. var flashMsgClassName = setting.animate ? "wd-anim wd-anim-upbit" : ""; // 动画
  4907. var arrorwsClassName = undefined; // 箭头的类名
  4908. // 气泡在上
  4909. if (setting.offset && setting.offset == "u") {
  4910. arrorwsStyle += 'bottom: -10px;left: 7px';
  4911. arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME;
  4912. }
  4913. // 气泡在下
  4914. else if (setting.offset && setting.offset == "d") {
  4915. arrorwsStyle += 'bottom: -10px;left: 7px';
  4916. arrorwsClassName = this.vars.ARROWS_UP_CLASS_NAME;
  4917. }
  4918. // 默认气泡在上
  4919. else {
  4920. arrorwsStyle += 'bottom: -10px;left: 7px';
  4921. arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME;
  4922. }
  4923. this.clearFlashMsg();
  4924. $("body").append(this.getFlashDivTemplate(setting, elTop, elLeft, arrorwsClassName, arrorwsStyle, flashMsgClassName));
  4925. ////////////////////////////// 计算最终的坐标 //////////////////////////////
  4926. var lastTop = -1;
  4927. var flashDom = $("#flashmsgtipsId");
  4928. var flashDomWidth = $(flashDom).innerWidth();
  4929. var flashDomHeight = $(flashDom).innerHeight(); // 是箭头的高度
  4930. $(flashDom).css({
  4931. top: elTop + "px"
  4932. ,left: elLeft + "px"
  4933. });
  4934. // 气泡在上
  4935. if (arrorwsClassName == this.vars.ARROWS_DOWN_CLASS_NAME) {
  4936. var lastDomTop = elTop - flashDomHeight - 16;
  4937. lastTop = elTop - flashDomHeight - 16;
  4938. // flashMsg 元素超出了窗口顶部范围
  4939. if (lastDomTop < 0) {
  4940. // 未尝试过向上的方向
  4941. if (!setting.upFlag) {
  4942. setting.offset = "d";
  4943. setting.downFlag = true;
  4944. this.show(setting);
  4945. return;
  4946. }
  4947. lastTop = flashDomHeight + 6;
  4948. }
  4949. }
  4950. // 气泡在下
  4951. else if (arrorwsClassName == this.vars.ARROWS_UP_CLASS_NAME) {
  4952. lastTop = elTop + elHeight + 20;
  4953. var lastDomTop = elTop + elHeight + flashDomHeight + 20;
  4954. // flashMsg 元素超出了窗口底部范围
  4955. if (lastDomTop > window.innerHeight) {
  4956. // 未尝试过向下的方向
  4957. if (!setting.downFlag) {
  4958. setting.offset = "u";
  4959. setting.upFlag = true;
  4960. this.show(setting);
  4961. return;
  4962. }
  4963. lastTop = window.innerHeight - flashDomHeight - 12;
  4964. }
  4965. } else {
  4966. console.error("arrorwsClassName [" + arrorwsClassName + "] error!");
  4967. return;
  4968. }
  4969. this.settingFlashMsgArrorwsLeft(setting, arrorwsClassName, elWidth, elLeft, flashDom, flashDomWidth);
  4970. $(flashDom).css("top", lastTop + "px");
  4971. $(flashDom).show();
  4972. if(setting.time!=0){
  4973. this.timeout = setTimeout(function () {
  4974. wd.flashMsg.clearFlashMsg(setting);
  4975. }, setting.time);
  4976. }
  4977. },
  4978. /**
  4979. * 清除气泡
  4980. */
  4981. clear: function () {
  4982. this.clearFlashMsg();
  4983. },
  4984. settingFlashMsgArrorwsLeft: function (setting, arrorwsClassName, elWidth, elLeft, flashDom, flashDomWidth) {
  4985. var arrorwsDom = $(flashDom).find("div." + arrorwsClassName);
  4986. // 箭头往左
  4987. if (setting.arrowsOffset == 'l') {
  4988. var arrowLeft = 7;
  4989. $(arrorwsDom).css("left", arrowLeft + "px");
  4990. return;
  4991. }
  4992. // 箭头往右
  4993. else if (setting.arrowsOffset == 'r') {
  4994. var arrowLeft = flashDomWidth - 20;
  4995. // 箭头的位置超出了元素的宽度
  4996. var elEndLeft = elLeft + elWidth;
  4997. if (arrowLeft > elEndLeft) {
  4998. // 元素的一半宽度大于12像素的时候,看着就不会太别扭,放心置 left 为 6px
  4999. if ((elWidth / 2) >= 12) {
  5000. arrowLeft = elEndLeft - 6 - 7;
  5001. }
  5002. // 取半
  5003. else {
  5004. arrowLeft = elLeft + (elWidth / 2);
  5005. }
  5006. }
  5007. $(arrorwsDom).css("left", arrowLeft + "px");
  5008. }
  5009. // 箭头居中
  5010. else {
  5011. /////////////////////// 重新定位气泡 ///////////////////////
  5012. var flashMsgDomLeft = this.settingFlashMsgLeft(flashDom, flashDomWidth, elWidth, elLeft);
  5013. var arrowLeft = elLeft - flashMsgDomLeft + (elWidth / 2);
  5014. $(arrorwsDom).css("left", arrowLeft + "px");
  5015. }
  5016. },
  5017. settingFlashMsgLeft: function (flashDom, flashDomWidth, elWidth, elLeft) {
  5018. var flashMsgDomLeft = elLeft - ((flashDomWidth - elWidth) / 2);
  5019. // 超出了屏幕左边,向右移动
  5020. if (flashMsgDomLeft < 0) {
  5021. flashMsgDomLeft = 6;
  5022. }
  5023. // 超出屏幕右边,向左移动
  5024. else if ((flashMsgDomLeft + flashDomWidth) > window.innerWidth) {
  5025. flashMsgDomLeft -= ((flashMsgDomLeft + flashDomWidth) - window.innerWidth);
  5026. }
  5027. $(flashDom).css("left", flashMsgDomLeft);
  5028. return flashMsgDomLeft;
  5029. },
  5030. clearFlashMsg: function (setting) {
  5031. window.clearTimeout(wd.flashMsg.timeout);
  5032. wd.flashMsg.timeout = undefined;
  5033. $("#flashmsgtipsId").remove(); // 移除掉之前的
  5034. if (setting && setting.end) {
  5035. setting.end();
  5036. }
  5037. },
  5038. getFlashDivTemplate: function (setting, elTop, elLeft, arrorwsClassName, arrowsStyle, flashMsgClassName) {
  5039. var html = this.flashDivTemplate.replace("{position}", "zindex:" + setting.zindex + ";");
  5040. html = html.replace("{arrorwsClassName}", arrorwsClassName);
  5041. html = html.replace("{arrorwsStyle}", arrowsStyle);
  5042. html = html.replace("{msg}", setting.msg);
  5043. html = html.replace("{flashMsgClassName}", flashMsgClassName);
  5044. return html;
  5045. },
  5046. isNull: function (obj) {
  5047. switch (typeof obj) {
  5048. case 'undefined':
  5049. return true;
  5050. case 'string':
  5051. if (obj.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true;
  5052. break;
  5053. case 'boolean':
  5054. if (!obj) return true;
  5055. break;
  5056. case 'number':
  5057. if (0 === obj || isNaN(obj)) return true;
  5058. break;
  5059. case 'object':
  5060. if (null === obj || obj.length === 0) return true;
  5061. for (var i in obj) {
  5062. return false;
  5063. }
  5064. return true;
  5065. }
  5066. return false;
  5067. },
  5068. notNull: function (obj) {
  5069. return !(this.isNull(obj));
  5070. },
  5071. validation: function (setting) {
  5072. if (this.isNull(setting)) {
  5073. console.error("flashMsg 未获取到 setting!");
  5074. return false;
  5075. }
  5076. if (this.isNull(setting.el)) {
  5077. console.error("flashMsg Setting [el] 属性不能为空 ");
  5078. return false;
  5079. }
  5080. if (this.isNull(setting.msg)) {
  5081. console.error("flashMsg Setting [msg] 属性不能为空 ");
  5082. return false;
  5083. }
  5084. return true;
  5085. },
  5086. getAbsolute: function (reference, target) {
  5087. var result = {
  5088. left: -target.clientLeft,
  5089. top: -target.clientTop
  5090. }
  5091. var node = target;
  5092. while (node != reference && node != document) {
  5093. result.left = result.left + node.offsetLeft + node.clientLeft;
  5094. result.top = result.top + node.offsetTop + node.clientTop;
  5095. node = node.parentNode;
  5096. }
  5097. if (isNaN(reference.scrollLeft)) {
  5098. result.right = document.documentElement.scrollWidth - result.left;
  5099. result.bottom = document.documentElement.scrollHeight - result.top;
  5100. } else {
  5101. result.right = reference.scrollWidth - result.left;
  5102. result.bottom = reference.scrollHeight - result.top;
  5103. }
  5104. return result;
  5105. }
  5106. }
  5107. //隐藏的元素
  5108. wd.display._lockScreenElement = null;
  5109. //有值表示正在执行lockScreen,unlockScreen
  5110. wd.display._lockScreenWaitting = null;
  5111. /**
  5112. * 锁屏
  5113. */
  5114. wd.display.lockScreen = function () {
  5115. "use strict";
  5116. if (wd.display._lockScreenWaitting) return;
  5117. wd.display._lockScreenWaitting = 0;
  5118. $.post("/service?ssServ=lockScreen", {}, function (result) {
  5119. if (wd.display._lockScreenElement) return;
  5120. wd.display._lockScreenElement = $("body > * :visible");
  5121. wd.display._lockScreenElement.hide();
  5122. $("body").append("<div class=\"lockscreenMask\" style=\"position: absolute;left: 0px;top: 0px;width: 100%;height: 100%;background-color: black;z-index: 99;\"></div>");
  5123. }, "json");
  5124. wd.display._lockScreenWaitting = null;
  5125. }
  5126. /**
  5127. * 解锁屏
  5128. */
  5129. wd.display.unlockScreen = function () {
  5130. "use strict";
  5131. if (wd.display._lockScreenWaitting) return;
  5132. wd.display._lockScreenWaitting = 1;
  5133. $.post("/service?ssServ=unlockScreen", {}, function (result) {
  5134. if (!wd.display._lockScreenElement) return;
  5135. wd.display._lockScreenElement.show();
  5136. wd.display._lockScreenElement = null;
  5137. $(".lockscreenMask").remove();
  5138. }, "json");
  5139. wd.display._lockScreenWaitting = null;
  5140. }
  5141. window.enrolDateList = window.enrolDateList || {};
  5142. wd.display.initEnrolDate=function(nameee,mode){
  5143. var hiddenEle=document.querySelector("[name="+nameee+"][type=hidden]");
  5144. if("play"==mode){
  5145. if(!hiddenEle.value)return;
  5146. var year=parseInt( hiddenEle.value.split("-")[0]);
  5147. var month=parseInt( hiddenEle.value.split("-")[1]);
  5148. $(hiddenEle).before('<span>'+year+'年('+(month<=6?'春季':'秋季')+')</span>');
  5149. return;
  5150. }
  5151. function editEnrolDate(name){
  5152. var THIS=this;
  5153. this.onchange=null;
  5154. this.getValue=null;
  5155. this.setValue=null;
  5156. this.container=null;
  5157. var hiddenEle=document.querySelector("[name="+name+"][type=hidden]");
  5158. this.element=hiddenEle;
  5159. var yyy=document.querySelector("[name="+name+"_year]");
  5160. var mmm=document.querySelector("[name="+name+"_month]");
  5161. wd.display.filterInputBox(name+"_year",name+"_month");
  5162. var placeholder=hiddenEle.getAttribute("placeholder");
  5163. if(placeholder){
  5164. yyy.setAttribute("placeholder",placeholder);
  5165. }else{//样式特殊处理
  5166. yyy.style.width="30px";
  5167. }
  5168. this.container=yyy.parentNode;
  5169. this.container.style.display="inline";
  5170. var width=hiddenEle.getAttribute("width");
  5171. if(width)yyy.style.width=width;
  5172. this._initYear=function(y){
  5173. yyy.value=y;
  5174. }
  5175. this._initMonth=function(m){
  5176. /* 改,规范 wdValue= 命名。Lin
  5177. $("[name="+name+"_month][type=button][wdValue="+(m<=6?3:9)+"]").trigger("click");
  5178. */ $("[name="+name+"_month][type=button][ssVal="+(m<=6?3:9)+"]").trigger("click");
  5179. }
  5180. var year,month;
  5181. //默认值为当前时间
  5182. if("0"==hiddenEle.value){
  5183. year=new Date().getUTCFullYear();
  5184. month=new Date().getMonth()+1;
  5185. }else if(hiddenEle.value&&hiddenEle.value.split("-").length>0){
  5186. year=parseInt( hiddenEle.value.split("-")[0]);
  5187. month=parseInt( hiddenEle.value.split("-")[1]);
  5188. }else{
  5189. //默认秋季
  5190. month=9;
  5191. }
  5192. if(year){
  5193. this._initYear(year);
  5194. }
  5195. if(month){
  5196. this._initMonth(month);
  5197. }
  5198. function RebuildingValue(){
  5199. var yy=document.querySelector("[name="+name+"_year]").value;
  5200. var mm=document.querySelector("[name="+name+"_month][type=hidden]").value;
  5201. var hiddenvalue="";
  5202. if(yy&&mm){hiddenvalue=yy+"-0"+mm+"-01"}
  5203. console.log(hiddenvalue);
  5204. document.querySelector("[name="+name+"][type=hidden]").value=hiddenvalue;
  5205. if(THIS.onchange)THIS.onchange();
  5206. }
  5207. RebuildingValue();
  5208. $("[name="+name+"_month][type=button]").on("click",RebuildingValue)
  5209. $("[name="+name+"_year][type=text]").on("click",function(){
  5210. wd.edit.datePicker({dateFmt:'yyyy',onpicked:RebuildingValue,oncleared:RebuildingValue,el:this});
  5211. });
  5212. this.setValue=function(v){
  5213. var v_year=v.split("-")[0];
  5214. var v_month=v.split("-")[1];
  5215. THIS._initYear(v_year);
  5216. THIS._initMonth(v_month);
  5217. }
  5218. this.getValue=function(){
  5219. return THIS.element.value;
  5220. }
  5221. }
  5222. if(window.enrolDateList[nameee])return;
  5223. window.enrolDateList[nameee]=new editEnrolDate(nameee);
  5224. }
  5225. window.defaultValueList = window.defaultValueList || {};
  5226. wd.display.inputDefaultValue=function(name,param){
  5227. //xq[rxnd];
  5228. param=param.replace(/]$/,"");
  5229. var pp=param.split(/\[/);
  5230. var dictName=pp[0];
  5231. var dictParam=pp[1];
  5232. if(window.defaultValueList[name])return;
  5233. window.defaultValueList[name]=new (function(name,n,p){
  5234. var THIS=this;
  5235. this.name=name;
  5236. this.dict=n;
  5237. this.dictParam=p;
  5238. this.dictItem=wd.display.getInputBox(p);
  5239. this._change=function(){
  5240. console.log(THIS);
  5241. var v=THIS.dictItem.getValue();
  5242. $.ajax({
  5243. url: "/service?ssServ=defaultValueTranslate",
  5244. data: {
  5245. dict: THIS.dict,
  5246. param: "{"+THIS.dictParam+":"+v+"}"
  5247. },
  5248. async:true,
  5249. dataType: "json",
  5250. success: function (data) {
  5251. wd.display.getInputBox(THIS.name).setValue(data.result);
  5252. }
  5253. });
  5254. }
  5255. this.dictItem.setChange(this._change);
  5256. if(!wd.display.getInputBox(name).getValue()){
  5257. this._change();
  5258. }
  5259. })(name,dictName,dictParam);
  5260. }
  5261. //下载文件
  5262. wd.display.downloadFile=function(path,downloadName){
  5263. var download=downloadName?("download=\""+downloadName+"\""):"";
  5264. $('<a '+download+' href="'+path+'"><span></span></a>').find("span").trigger("click");
  5265. //关闭圈圈
  5266. wd.display.closeLoad();
  5267. //ScreenOver层移除
  5268. $("#ScreenOver").remove();
  5269. }
  5270. //首页图标
  5271. wd.display.setHomeIconName=function(name){
  5272. var ele =wd.topWindow.document.getElementById('mbwzbj');
  5273. if (ele != null&&name) {
  5274. ele.innerHTML =name;
  5275. }
  5276. }
  5277. /**
  5278. *
  5279. * 弹出右键菜单
  5280. *
  5281. * param {
  5282. * leftClick:true//左击弹菜单
  5283. * }
  5284. *
  5285. * wd.display.showContextMenu("body",[{text:"图片",func:function(element){}}]);
  5286. */
  5287. wd.display.showContextMenu=function(selecter,datas,param){
  5288. var options= $.extend({},{leftClick:false},param)
  5289. for(var i=0;i<datas.length;i++){
  5290. datas[i].value=i;
  5291. }
  5292. var id="what_menu"+new Date().getTime();
  5293. var dom = wd.display.initSelectOption(id);
  5294. wd.display.buildSelectOption(dom,datas, "value", "text", null, false);
  5295. $("body").append(dom);
  5296. var $dom=$(dom).css({position:"absolute"}).hide();
  5297. var triggerElement;
  5298. $dom.on("click",".popupList",function(){
  5299. var v=$(this).attr("value");
  5300. datas[v].func.call(triggerElement,triggerElement);
  5301. $dom.hide();
  5302. return false;
  5303. })
  5304. var eventName=options.leftClick?"contextmenu click":"contextmenu";
  5305. $(document).on(eventName,selecter,function(){
  5306. var offset=$(this).offset();
  5307. dom.style.left=(offset.left+window.event.offsetX)+"px";
  5308. dom.style.top =(offset.top+window.event.offsetY)+"px";
  5309. $(dom).show();
  5310. triggerElement=this;
  5311. return false;
  5312. })
  5313. $(document).on("click",function(){
  5314. $dom.hide();
  5315. })
  5316. $(".content-div,.list-div").scroll(function(){
  5317. $dom.hide();
  5318. })
  5319. }