index.js 283 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821
  1. ///<jscompress sourcefile="Banner.js" />
  2. //电脑端banner滑块控件命名空间
  3. Namespace.register("U.MD.UI.slider");
  4. /**
  5. 电脑端banner滑块控件
  6. */
  7. /**
  8. @box {object} 存放控件的div的id
  9. @imgarr {array} 存放图片的数组
  10. @speed {string} 轮播速度
  11. @cut {bool} 判断左右切换按钮是否出现
  12. @dot {bool} 判断小圆点是否出现
  13. @cb {回调callback} 引用方法
  14. **/
  15. U.MD.UI.slider = function (box, imgarr, attr) {
  16. //定义传输进来的参数
  17. var _speed = attr.speed;
  18. var _arrow = attr.arrow;
  19. var _dot = attr.dot;
  20. var _moveFun = attr.moveFun;
  21. //快速创建存放图片的ul
  22. var _sliderimgul = $$("ul", { className: 'U_MD_UI_slider_ImgList' }, box);
  23. //在数组的第一个插入最后一张图片
  24. imgarr.unshift(imgarr[imgarr.length - 1]);
  25. //在arrImg[]最后放第一张图片
  26. imgarr.push(imgarr[1]);
  27. //for循环创建需要的li
  28. for (i = 0; i < imgarr.length; i++) {
  29. var _sliderimgli = $$("li", { className: '' }, _sliderimgul),
  30. _sliderImg = $$("img", { className: '', src: imgarr[i] }, _sliderimgli); //"onerror": U.MD.C.imgError,
  31. }
  32. //快速创建存放左右按钮的ul
  33. var _sliderbtnul = $$("ul", { className: 'U_MD_UI_slider_Btn' }, box),
  34. _sliderbtnlil = $$("li", { className: 'U_MD_UI_slider_Left', innerHTML: '<' }, _sliderbtnul),
  35. _sliderbtnlir = $$("li", { className: 'U_MD_UI_slider_Right', innerHTML: '>' }, _sliderbtnul);
  36. //快速创建存放小圆点的ul
  37. var _sliderpointul = $$("ul", { className: 'U_MD_UI_slider_Point' }, box);
  38. //快速创建li,li的长度为图片的减两张(补图法)
  39. for (i = 0; i < imgarr.length - 3; i++) {
  40. //第一个li时,定义第一个li的class
  41. if (i == 0) {
  42. $$("li", { className: 'U_MD_UI_slider_On' }, _sliderpointul)[0];
  43. }
  44. $$("li", { className: '' }, _sliderpointul)[i];
  45. }
  46. //定义父元素的宽度
  47. var _boxidwidth = box.offsetWidth;
  48. //定义父元素的高度
  49. var _boxidheight = box.offsetHeight;
  50. //定义class为U_MD_UI_slider_ImgList
  51. var _sliderimglist = box.getElementsByClassName("U_MD_UI_slider_ImgList")[0];
  52. var _sliderimgli = _sliderimglist.getElementsByTagName("li");
  53. //定义class为U_MD_UI_slider_Btn
  54. var _sliderbtn = document.getElementsByClassName("U_MD_UI_slider_Btn")[0];
  55. //定义class为U_MD_UI_slider_Point
  56. var _sliderpoint = box.getElementsByClassName('U_MD_UI_slider_Point')[0];
  57. //定义class为_sliderbtn的所有li
  58. var _btnli = _sliderbtn.getElementsByTagName("li");
  59. //定义class为_sliderimglist的li长度
  60. var _listlen = _sliderimglist.getElementsByTagName("li").length;
  61. //定义图片索引为1
  62. var _listindex = 1;
  63. //定义_sliderpoint里的li
  64. var _pointdot = _sliderpoint.getElementsByTagName("li");
  65. //定义_pointdot.length
  66. var _dotlen = _pointdot.length;
  67. //定义小圆点索引为0
  68. var _dotindex = 0;
  69. //初始化timer
  70. var timer = null;
  71. //如果obj.dot为true则显示小圆点
  72. if (_dot) {
  73. _sliderpoint.style.display = "block";
  74. } else {
  75. _sliderpoint.style.display = "none";
  76. }
  77. /** Banner宽度和高度跟随父元素 **/
  78. //定义_sliderimglist里的li
  79. var _sliderli = _sliderimglist.getElementsByTagName("li");
  80. //所有图片的高宽等于盒子
  81. for (var i = 0; i < _sliderli.length; i++) {
  82. _sliderli[i].style.width = _boxidwidth + "px";
  83. _sliderli[i].style.height = _boxidheight + "px";
  84. }
  85. //存放图片的ul的总宽度(盒子长度*图片数量)
  86. _sliderimglist.style.width = (_boxidwidth * imgarr.length) + "px";
  87. //第一张图片的位置
  88. _sliderimglist.style.left = -_boxidwidth + "px";
  89. //左右切换按钮宽度跟随盒子宽度
  90. _sliderbtn.style.width = _boxidwidth + "px";
  91. /** 鼠标停留计时器停止或启动、左右按钮显示 **/
  92. //鼠标停留
  93. box.onmouseover = function () {
  94. //如果obj.cut为true则显示按钮
  95. if (_arrow) {
  96. _sliderbtn.style.display = "block";
  97. } else {
  98. _sliderbtn.style.display = "none";
  99. }
  100. //清除计时器
  101. clearInterval(timer);
  102. }
  103. //鼠标离开
  104. box.onmouseout = function () {
  105. _sliderbtn.style.display = "none";
  106. //启动计时器
  107. timer = setInterval(auto, _speed);
  108. }
  109. //定义当前时间
  110. var sTime = new Date();
  111. //左边按钮
  112. _btnli[0].onclick = function () {
  113. //定义点击后的时间
  114. var nTime = new Date();
  115. //点击后时间距离下次点击要大于500ms才能继续下次点击
  116. if (nTime - sTime > 500) {
  117. //图片索引和小圆点索引减少
  118. _listindex--;
  119. _dotindex--;
  120. if (_listindex == 0) {
  121. //调用move函数
  122. move(_sliderimglist, { left: -_boxidwidth * _listindex }, function () {
  123. _listindex = _listlen - 2;
  124. this.style.left = -_listindex * _boxidwidth + "px";
  125. });
  126. } else {
  127. move(_sliderimglist, { left: -_boxidwidth * _listindex });
  128. }
  129. //小圆点移动
  130. _dotindex = _dotindex == -1 ? _dotlen - 1 : _dotindex;
  131. moveBtn(_dotindex);
  132. _moveFun && _moveFun(_dotindex + 1);
  133. }
  134. sTime = new Date();
  135. }
  136. //右边按钮
  137. _btnli[1].onclick = function () {
  138. //定义点击后的时间
  139. var nTime = new Date();
  140. //点击后时间距离下次点击要大于500ms才能继续下次点击
  141. if (nTime - sTime > 500) {
  142. //图片索引和小圆点索引增加
  143. _listindex++;
  144. _dotindex++;
  145. //小圆点索引清零
  146. _dotindex = _dotindex % _dotlen;
  147. //图片到最后一张时索引清零重新计算
  148. if (_listindex == _listlen - 1) {
  149. move(_sliderimglist, { left: -_boxidwidth * _listindex }, function () {
  150. _listindex = 1;
  151. this.style.left = -_listindex * _boxidwidth + "px";
  152. });
  153. } else {
  154. move(_sliderimglist, { left: -_boxidwidth * _listindex });
  155. }
  156. //小圆点移动
  157. moveBtn(_dotindex);
  158. _moveFun && _moveFun(_dotindex + 1);
  159. }
  160. sTime = new Date();
  161. }
  162. //定义自动轮播
  163. timer = setInterval(auto, _speed);
  164. if (_dotindex == 0) {
  165. console.log(_dotindex + 1);
  166. }
  167. //自动轮播
  168. function auto() {
  169. /* for (var i = 0; i < _sliderimgli.length; i++) {
  170. _sliderimgli[i]._listindex = i;
  171. //点击小圆点
  172. //_listindex = this._listindex;
  173. console.log(_listindex+1);
  174. }*/
  175. //图片索引和小圆点索引
  176. _listindex = ++_listindex % _listlen;
  177. _dotindex++;
  178. //小圆点索引清零
  179. _dotindex = _dotindex % _dotlen;
  180. //图片到最后一张时索引清零重新计算
  181. if (_listindex == _listlen - 1) {
  182. move(_sliderimglist, { left: -_boxidwidth * _listindex }, function () {
  183. _listindex = 1;
  184. this.style.left = -_listindex * _boxidwidth + "px";
  185. });
  186. } else {
  187. move(_sliderimglist, { left: -_boxidwidth * _listindex });
  188. }
  189. moveBtn(_dotindex);
  190. _moveFun && _moveFun(_dotindex + 1);
  191. }
  192. //遍历小圆点
  193. for (var i = 0; i < _dotlen; i++) {
  194. _pointdot[i]._listindex = i;
  195. //点击小圆点
  196. _pointdot[i].onclick = function () {
  197. _dotindex = this._listindex;
  198. _listindex = _dotindex + 1;
  199. move(_sliderimglist, { left: -_boxidwidth * _listindex });
  200. moveBtn(_dotindex);
  201. //console.log(_dotindex);
  202. }
  203. }
  204. //小圆点样式
  205. function moveBtn(_dotindex) {
  206. for (var j = 0; j < _dotlen; j++) {
  207. _pointdot[j].className = "";
  208. }
  209. _pointdot[_dotindex].className = "U_MD_UI_slider_On";
  210. }
  211. }
  212. /*
  213. 切换过程函数
  214. @dom {object} 需要移动的对象
  215. @json {Array}向某个方向移动的距离
  216. @callback {回调callback}
  217. */
  218. function move(dom, json, callback) {
  219. //清除计时器
  220. clearInterval(dom.timer);
  221. dom.timer = setInterval(function () {
  222. //true这个计时器用来标记json中所有的attr已到达target目标
  223. var mark = true;
  224. for (var attr in json) {
  225. var cur = null;
  226. if (attr == "opacity") {
  227. cur = getStyle(dom, attr) * 100;
  228. } else {
  229. cur = parseInt(getStyle(dom, attr)) || 0;
  230. }
  231. var target = json[attr];
  232. // console.log(target);
  233. // console.log(cur);
  234. var speed = (target - cur) * .2;
  235. speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
  236. if (cur != target) {
  237. if (attr == "opacity") {
  238. dom.style.filter = "alpha(opacity = " + (cur + speed) + ")"; //ie
  239. dom.style[attr] = (cur + speed) / 100; //0~1
  240. } else {
  241. dom.style[attr] = cur + speed + "px";
  242. }
  243. //false表明当前的这个attr没有达到目标
  244. mark = false;
  245. }
  246. //console.log(cur);
  247. //console.log(1);
  248. }
  249. if (mark) {
  250. clearInterval(dom.timer);
  251. callback && callback.call(dom);
  252. }
  253. }, 100 / 3);
  254. }
  255. function getStyle(dom, attr) {
  256. return dom.currentStyle ? dom.currentStyle[attr] : getComputedStyle(dom, null)[attr];
  257. };
  258. ///<jscompress sourcefile="Calendar.js" />
  259. Namespace.register("U.MD.UI.calendar");
  260. /**
  261. * 日历控件调用API函数
  262. * @param el 对象元素
  263. * @param parentnode 添加到的父元素
  264. * @param datetimeboolean 【boolean】是否显示选择时分秒功能
  265. */
  266. U.MD.UI.Calendar = U.MD.UI.calendar = function (el, parentnode, datetimeboolean) {
  267. if (!el)
  268. return
  269. if(typeof datetimeboolean == 'boolean' && datetimeboolean == false){
  270. U.MD.UI.calendar.datetimeformat = datetimeboolean
  271. }else{
  272. U.MD.UI.calendar.datetimeformat = true;
  273. }
  274. U.MD.UI.calendar.create(el, parentnode);
  275. }
  276. U.MD.UI.calendar.NOW = new Date(); /*获取当天时间*/
  277. U.MD.UI.calendar.CURRENTYEAR = U.MD.UI.calendar.NOW.getFullYear(); /*今年*/
  278. U.MD.UI.calendar.CURRENTMONTH = U.MD.UI.calendar.NOW.getMonth(); /*今月*/
  279. U.MD.UI.calendar.CURRENTDAY = U.MD.UI.calendar.NOW.getDate(); /*今日*/
  280. U.MD.UI.calendar.year = U.MD.UI.calendar.CURRENTYEAR; /*可变年*/
  281. U.MD.UI.calendar.month = U.MD.UI.calendar.CURRENTMONTH; /*可变月*/
  282. U.MD.UI.calendar.day = U.MD.UI.calendar.CURRENTDAY; /*可变日*/
  283. U.MD.UI.calendar.hour = '00'; /*时*/
  284. U.MD.UI.calendar.minute = '00'; /*分*/
  285. U.MD.UI.calendar.second = '00'; /*秒*/
  286. U.MD.UI.calendar.datetimeformat = true; /*是否以时分秒时间格式输出*/
  287. U.MD.UI.calendar.fouseinp = null; /*当前聚焦的input*/
  288. U.MD.UI.calendar.board = null; /*最外层div*/
  289. U.MD.UI.calendar.tit = null; /*日期标题*/
  290. U.MD.UI.calendar.mark = 1; /*标记量*/
  291. U.MD.UI.calendar.template = [ /*html模板块*/
  292. /*功能*/
  293. '<div class="U_MD_UI_calendar_features">' +
  294. '<div class="U_MD_UI_calendar_closeBtn" id="U_MD_UI_calendar_closeBtn">关闭</div>' +
  295. '<div class="U_MD_UI_calendar_features_a">' +
  296. '<div class="U_MD_UI_calendar_prev U_MD_UI_calendar_btn" id="prevDate"></div>' +
  297. '<div class="U_MD_UI_calendar_tit" id="calendar_tit"></div>' +
  298. '<input type="text" id="calendar_tit_btn" style="display: none;">' +
  299. '<div class="U_MD_UI_calendar_next U_MD_UI_calendar_btn" id="nextDate"></div>' +
  300. '</div>' +
  301. '<i></i>' +
  302. '</div>',
  303. /*星期*/
  304. '<div id="calendar_day">' +
  305. '<ul class="U_MD_UI_calendar_week">' +
  306. '<li>日</li>' +
  307. '<li>一</li>' +
  308. '<li>二</li>' +
  309. '<li>三</li>' +
  310. '<li>四</li>' +
  311. '<li>五</li>' +
  312. '<li>六</li>' +
  313. '</ul>' +
  314. '<ul class="U_MD_UI_calendar_c" id="calendar_week_c"></ul>' +
  315. '</div>',
  316. /*选择月*/
  317. '<div class="U_MD_UI_calendar_month" id="calendar_month" style="display: none">' +
  318. '<ul class="U_MD_UI_calendar_month_c">' +
  319. '<li><span>1月</span></li>' +
  320. '<li><span>2月</span></li>' +
  321. '<li><span>3月</span></li>' +
  322. '<li><span>4月</span></li>' +
  323. '<li><span>5月</span></li>' +
  324. '<li><span>6月</span></li>' +
  325. '<li><span>7月</span></li>' +
  326. '<li><span>8月</span></li>' +
  327. '<li><span>9月</span></li>' +
  328. '<li><span>10月</span></li>' +
  329. '<li><span>11月</span></li>' +
  330. '<li><span>12月</span></li>' +
  331. '</ul>' +
  332. '</div>',
  333. /*选择年*/
  334. '<div id="calendar_year" class="U_MD_UI_calendar_month" style="display: none">' +
  335. '<ul class="U_MD_UI_calendar_month_c">' +
  336. '<li></li>' +
  337. '<li></li>' +
  338. '<li></li>' +
  339. '<li></li>' +
  340. '<li></li>' +
  341. '<li></li>' +
  342. '<li></li>' +
  343. '<li></li>' +
  344. '<li></li>' +
  345. '<li></li>' +
  346. '<li></li>' +
  347. '<li></li>' +
  348. '</ul>' +
  349. '</div>',
  350. /*选择时间*/
  351. '<span id="U_MD_UI_calendar_timeText" class="U_MD_UI_calendar_timeText">选择时间</span>' +
  352. '<div class="U_MD_UI_calendar_timeBox">' +
  353. '<div id="U_MD_UI_calendar_clearText" class="U_MD_UI_calendar_timeBtn">清空</div>' +
  354. '<div id="U_MD_UI_calendar_nowTime" class="U_MD_UI_calendar_timeBtn">现在</div>' +
  355. '<div id="U_MD_UI_calendar_okBtn" class="U_MD_UI_calendar_timeBtn">确定</div>' +
  356. '</div>',
  357. /*选择时间内容*/
  358. '<div id="calendar_timeChoose" class="U_MD_UI_calendar_timeChoose" style="display: none">' +
  359. '</div>'
  360. ];
  361. /**
  362. * 创建日历的壳
  363. * @param els 对象元素
  364. * @param els 父元素
  365. */
  366. U.MD.UI.calendar.create = function (els, parentnode) {
  367. if (els == U.MD.UI.calendar.fouseinp && U.MD.UI.calendar.board.style.display == 'block')
  368. return
  369. if (parentnode && U.MD.UI.calendar.board) {
  370. U.MD.UI.calendar.board.parentNode.removeChild(U.MD.UI.calendar.board);
  371. U.MD.UI.calendar.board = null;
  372. }
  373. var _top = document.documentElement.scrollTop || document.body.scrollTop,
  374. _left = document.documentElement.scrollLeft || document.body.scrollLeft;
  375. var _offsetHtml = [Math.abs(els.getBoundingClientRect().left) + _left, Math.abs(els.getBoundingClientRect().top) + _top]; /*获取元素相对于html文档的距离*/
  376. U.MD.UI.calendar.fouseinp = els; /*当前聚焦的input*/
  377. if (!U.MD.UI.calendar.board) { /*判断是否有创建日历内容*/
  378. U.MD.UI.calendar.showBoard(els, _offsetHtml, parentnode); /*创建日历内容*/
  379. } else {
  380. U.MD.UI.calendar.resetData(_offsetHtml);
  381. }
  382. U.MD.UI.calendar.showDay(); /*日期显示*/
  383. }
  384. /**
  385. * 时分秒模板控制
  386. * @param that 对象元素
  387. * @param text 改变的文字
  388. */
  389. U.MD.UI.calendar.toggleChooseText = function (that) {
  390. var _child = U.selectEl('.U_MD_UI_calendar_c_a')[0].children, //模板元素
  391. _len = _child.length; //长度
  392. if (that.innerText == '返回日期') { //点击的字
  393. U.MD.UI.calendar.changeDisplay(_lastTemplate, _child[_len - 1]); //切换模板
  394. that.innerText = "选择时间"; //改变文字
  395. U.selectEl(that).removeClass("U_MD_UI_calendar_timeTextClick"); //删除选中class
  396. return; //调出函数
  397. }
  398. for (var i = 0; i < _len - 1; i++) { //循环模板
  399. _child[i].style.display != 'none' && (_child[i].style.display = 'none', _lastTemplate = _child[i]); //隐藏
  400. }
  401. _child[_len - 1].style.display = 'block'; //显示选择时分秒模板
  402. that.innerText = "返回日期"; //改变文字
  403. U.selectEl(that).addClass("U_MD_UI_calendar_timeTextClick"); //添加class
  404. }
  405. /**
  406. * 数据重置
  407. * @param offsethtml 偏移量
  408. */
  409. U.MD.UI.calendar.resetData = function (offsethtml) {
  410. U.MD.UI.calendar.board.style.display = 'block'; /*让日历显示*/
  411. U.MD.UI.calendar.mark = 1;
  412. U.selectEl('#calendar_day')[0].style.display = 'block';
  413. U.selectEl('#calendar_month')[0].style.display = 'none';
  414. U.selectEl('#calendar_year')[0].style.display = 'none';
  415. U.MD.UI.calendar.board.style.left = offsethtml[0] + 'px'; /*改变日历显示的x轴*/
  416. U.MD.UI.calendar.board.style.top = offsethtml[1] + U.MD.UI.calendar.fouseinp.clientHeight + 10 + 'px'; /*改变日历显示的y轴*/
  417. U.MD.UI.calendar.year = U.MD.UI.calendar.CURRENTYEAR;
  418. U.MD.UI.calendar.month = U.MD.UI.calendar.CURRENTMONTH;
  419. U.MD.UI.calendar.ChooseDefault(true);
  420. }
  421. /**
  422. * 创建时间选择模块
  423. * @param addel 添加父元素
  424. */
  425. U.MD.UI.calendar.createChooseTime = function (addel) {
  426. var _dataObj = [["时", "分", "秒"], [24, 60, 60], ["hour", "minute", "second"]],
  427. _lastTemplate;
  428. var _ct = $$('div', { id: 'calendar_time', className: 'U_MD_UI_calendar_time', innerHTML: U.MD.UI.calendar.template[4] }, U.MD.UI.calendar.board);
  429. for (var i = 0; i < _dataObj[0].length; i++) {
  430. var _row = $$('div', { className: "U_MD_UI_calendar_timeRow" }, addel);
  431. $$('span', { className: "U_MD_UI_calendar_timeRowText", innerText: _dataObj[0][i] }, _row);
  432. var _rowCon = $$('div', { className: "U_MD_UI_calendar_timeRowCon" }, _row),
  433. _ul = $$('ul', { className: "U_MD_UI_calendar_timeRowUl", name: _dataObj[2][i] }, _rowCon);
  434. for (var j = 0; j < _dataObj[1][i]; j++) {
  435. var _text = j.toString().length == 1 ? '0' + j : j;
  436. $$('li', { innerText: _text, onclick: function () {
  437. var _parentUl = this.parentNode,
  438. _activeLi = _parentUl.querySelector('.U_MD_UI_calendar_timeRowActive');
  439. U.selectEl(_activeLi).removeClass('U_MD_UI_calendar_timeRowActive');
  440. U.selectEl(this).addClass('U_MD_UI_calendar_timeRowActive');
  441. switch (_parentUl.name) {
  442. case 'hour': U.MD.UI.calendar.hour = this.innerText; break;
  443. case 'minute': U.MD.UI.calendar.minute = this.innerText; break;
  444. case 'second': U.MD.UI.calendar.second = this.innerText; break;
  445. }
  446. }
  447. }, _ul);
  448. }
  449. }
  450. if (!U.MD.UI.calendar.datetimeformat) {
  451. _ct.style.display = 'none';
  452. }
  453. U.selectEl('#U_MD_UI_calendar_timeText')[0].onclick = function () { //绑定进入选择时分秒的模块时间
  454. U.MD.UI.calendar.toggleChooseText(this)
  455. }
  456. U.selectEl('#U_MD_UI_calendar_clearText')[0].onclick = function () { //绑定清空事件
  457. U.MD.UI.calendar.fouseinp.value ? U.MD.UI.calendar.fouseinp.value = '' : U.MD.UI.calendar.fouseinp.innerText = '';
  458. U.MD.UI.calendar.ChooseDefault(true);
  459. U.MD.UI.calendar.board.style.display = 'none';
  460. }
  461. U.selectEl('#U_MD_UI_calendar_nowTime')[0].onclick = function () { //绑定输出今天事件
  462. U.MD.UI.calendar.outPutDate(true);
  463. }
  464. U.selectEl('#U_MD_UI_calendar_okBtn')[0].onclick = function () { //绑定确定事件
  465. U.MD.UI.calendar.outPutDate(false);
  466. }
  467. }
  468. /**
  469. * 创建日历
  470. * @param input 当前聚焦的input
  471. * @param offsetHtml 元素相对于html文档的距离
  472. */
  473. U.MD.UI.calendar.showBoard = function (input, offsetHtml, parentnode) {
  474. var _template = U.MD.UI.calendar.template, /*转局部变量*/
  475. _parentNode = parentnode || document.body,
  476. _templateHTML = _template[1] + _template[2] + _template[3] + _template[5];
  477. if (!parentnode) {
  478. U.MD.UI.calendar.board = $$('div', { "className": "U_MD_UI_calendar_bigboard", style: { left: offsetHtml[0] + "px", top: offsetHtml[1] + input.clientHeight + 10 + "px"} }, _parentNode); /*创建日历元素*/
  479. } else {
  480. U.MD.UI.calendar.board = $$('div', { "className": "U_MD_UI_calendar_bigboard" }, parentnode);
  481. }
  482. U.MD.UI.calendar.board.innerHTML = _template[0]; /*给上html模板的第一个*/
  483. _dayC = $$('div', { "className": 'U_MD_UI_calendar_c_a', innerHTML: _templateHTML }, U.MD.UI.calendar.board); /*创建剩下的内容,把html模板内容丢进去*/
  484. U.MD.UI.calendar.tit = U.selectEl('#calendar_tit')[0]; /*获取日历标题*/
  485. _mc = U.selectEl('#calendar_month > ul > li'); /*获取选择月模块的li*/
  486. _titInp = U.selectEl('#calendar_tit_btn')[0]; /*获取日历标题的input*/
  487. _timer = null; /*定义一个定时器*/
  488. U.MD.UI.calendar.createChooseTime($('#calendar_timeChoose')[0]);
  489. U.MD.UI.calendar.tit.onclick = function () { /*给日历标题绑定点击事件*/
  490. clearTimeout(_timer); /*清除定时器*/
  491. if (U.MD.UI.calendar.mark == 1) { /*标记数是1*/
  492. U.MD.UI.calendar.tit.innerText = U.MD.UI.calendar.year; /*日历标题赋值可变月*/
  493. U.MD.UI.calendar.changeDisplay($('#calendar_month')[0], U.selectEl('#calendar_day')[0]); /*选择月显示,选择天隐藏*/
  494. U.MD.UI.calendar.mark = 2; /*标记数赋值2,以表示当前停留在选择月模块*/
  495. U.MD.UI.calendar.ChooseDefault();
  496. } else if (U.MD.UI.calendar.mark == 2) { /*标记数是2*/
  497. _timer = setTimeout(function () { /*赋值一个定时器*/
  498. U.MD.UI.calendar.changeDisplay($('#calendar_year')[0], U.selectEl('#calendar_month')[0]); /*选择年显示,选择月隐藏*/
  499. U.MD.UI.calendar.dateTenYear(); /*调用显示10年内容函数*/
  500. U.MD.UI.calendar.mark = 3; /*标记数复制3,以表示档期那停球在选择年模块*/
  501. U.MD.UI.calendar.ChooseDefault();
  502. }, 250); /*0.25秒后执行*/
  503. }
  504. }
  505. U.MD.UI.calendar.tit.ondblclick = function () { /*给日历标题绑定双击事件*/
  506. clearTimeout(_timer); /*清除定时器,防止进入单击事件*/
  507. if (U.MD.UI.calendar.mark === 2) { /*标记数是2*/
  508. _obj = U.MD.UI.calendar.changeDisplay(_titInp, this, 'inline-block'); /*日历标题文本框显示,日历标题隐藏*/
  509. _obj[0].value = this.innerText; /*把日历title赋值给编辑input*/
  510. _obj[0].focus(); /*编辑input给上聚焦*/
  511. }
  512. }
  513. _titInp.onkeydown = function (e) { /*给日历标题文本框一个键盘事件*/
  514. switch (e.keyCode) {
  515. case 13: /*编辑input 回车来更改内容*/
  516. var _arr2 = U.MD.UI.calendar.changeDisplay(U.MD.UI.calendar.tit, this, 'inline-block'); /*显示日历title, 隐藏编辑input*/
  517. _arr2[0].innerText = U.MD.UI.calendar.year = !isNaN(parseInt(this.value)) ? parseInt(this.value) : U.MD.UI.calendar.CURRENTYEAR; /*把编辑input的内容赋值给日历title*/
  518. break;
  519. }
  520. };
  521. _titInp.onblur = function () { /*给日历标题文本框一个失去焦点*/
  522. var _arr3 = U.MD.UI.calendar.changeDisplay(U.MD.UI.calendar.tit, this, 'inline-block'); /*同上*/
  523. _arr3[0].innerText = U.MD.UI.calendar.year = !isNaN(parseInt(this.value)) ? parseInt(this.value) : U.MD.UI.calendar.CURRENTYEAR;
  524. }
  525. U.selectEl('#prevDate')[0].onclick = function () { /*给向左的小三角绑定点击事件*/
  526. if (U.MD.UI.calendar.mark == 1) { _lessNum = -1 } /*标记数是1,-1月*/
  527. else if (U.MD.UI.calendar.mark == 2) { _lessNum = -12 } /*标记数是2,-12月*/
  528. else if (U.MD.UI.calendar.mark == 3) { _lessNum = -120 }; /*标记数是3, -120月*/
  529. U.MD.UI.calendar.fullDate(_lessNum, false);
  530. };
  531. U.selectEl('#nextDate')[0].onclick = function () { /*给向右的小三角绑定点击事件*/
  532. if (U.MD.UI.calendar.mark == 1) { _addNum = 1 } /*标记数是1,+1月*/
  533. else if (U.MD.UI.calendar.mark == 2) { _addNum = 12 } /*标记数是1,+12月*/
  534. else if (U.MD.UI.calendar.mark == 3) { _addNum = 120 }; /*标记数是1,+120月*/
  535. U.MD.UI.calendar.fullDate(_addNum, true);
  536. };
  537. for (var i = 0; i < _mc.length; i++) { /*给选择月的模块li循环*/
  538. _mc[i].onclick = function () { /*给每个绑定一个点击事件*/
  539. U.MD.UI.calendar.changeDisplay($('#calendar_day')[0], U.selectEl('#calendar_month')[0]); /*选择天显示,选择月隐藏*/
  540. U.MD.UI.calendar.month = parseInt(this.innerText) - 1; /*赋值选的月*/
  541. U.MD.UI.calendar.showDay(); /*刷新数据*/
  542. U.MD.UI.calendar.mark = 1; /*标记量赋值1*/
  543. }
  544. }
  545. U.selectEl('#U_MD_UI_calendar_closeBtn')[0].onclick = function () { /*给关闭按钮绑定一个事件*/
  546. U.UF.EV.stopBubble();
  547. U.MD.UI.calendar.board.style.display = 'none'; /*让日历空间隐藏*/
  548. }
  549. }
  550. /**
  551. * 创建或更新选择天模块的内容
  552. */
  553. U.MD.UI.calendar.showDay = function () { /*显示日期*/
  554. _monthFristDay = new Date(U.MD.UI.calendar.year, U.MD.UI.calendar.month, 1).getDay(); /*当月第一天的星期*/
  555. _lastMonthDay = new Date(U.MD.UI.calendar.year, U.MD.UI.calendar.month, 0).getDate(); /*上个月的最后一天*/
  556. _fullDay = new Date(U.MD.UI.calendar.year, U.MD.UI.calendar.month + 1, 0).getDate(); /*当月总天数*/
  557. _totalDay = (_t = _monthFristDay + _fullDay) % 7 === 0 ? _t : _t + (7 - _t % 7); /*当月总共需要显示天数*/
  558. _dayC = U.selectEl('#calendar_week_c')[0];
  559. _dayC.innerHTML = '';
  560. for (var _i = 0; _i < _totalDay; _i++) {
  561. _li = $$('li', {}, _dayC);
  562. if (_i < _monthFristDay) { /*如果小于当月第一天的星期,这里显示的是上月最后几天的号显示*/
  563. $$('span', { "className": 'U_MD_UI_calendar_unavailable', innerText: (_lastMonthDay - _monthFristDay + _i + 1) }, _li);
  564. } else if (_i < (_fullDay + _monthFristDay)) { /*如果小于(当月总天数 + 当月第一天的星期)*/
  565. var _d = _i - _monthFristDay + 1, _week = new Date(U.MD.UI.calendar.year, U.MD.UI.calendar.month, _d).getDay(), _today = U.MD.UI.calendar.NOW.getDate() === _d && (U.MD.UI.calendar.CURRENTMONTH === U.MD.UI.calendar.month && U.MD.UI.calendar.CURRENTYEAR === U.MD.UI.calendar.year);
  566. _dayV = _d;
  567. if (_week === 6 || _week === 0) { /*如果是周末字体显示为红色,否则给黑色*/
  568. _today ? $$('span', { "className": 'U_MD_UI_calendar_day U_MD_UI_calendar_today U_MD_UI_calendar_weekend', innerText: _d, "onclick": function () { U.MD.UI.calendar.day = this.innerText; U.MD.UI.calendar.outPutDate() } }, _li) : $$('span', { "className": 'U_MD_UI_calendar_day U_MD_UI_calendar_weekend', innerText: _d, "onclick": function () { U.MD.UI.calendar.day = this.innerText; U.MD.UI.calendar.outPutDate() } }, _li);
  569. } else if (_today) { /*如果是今天,打重点*/
  570. $$('span', { "className": 'U_MD_UI_calendar_day U_MD_UI_calendar_today', innerText: _d, "onclick": function () { U.MD.UI.calendar.day = this.innerText; U.MD.UI.calendar.outPutDate() } }, _li)
  571. } else { /*默认样式*/
  572. $$('span', { "className": 'U_MD_UI_calendar_day', innerText: _d, "onclick": function () { U.MD.UI.calendar.day = this.innerText; U.MD.UI.calendar.outPutDate() } }, _li)
  573. }
  574. } else { /*显示下个月的星期,给上字体是灰色的样式*/
  575. $$('span', { "className": 'U_MD_UI_calendar_unavailable', innerText: (_i - (_fullDay + _monthFristDay) + 1) }, _li)
  576. }
  577. }
  578. U.MD.UI.calendar.tit.innerText = U.MD.UI.calendar.year + '-' + (U.MD.UI.calendar.month + 1) + '月'; /*转换格式,然后丢到日历标题文本框里*/
  579. }
  580. /**
  581. * 年月控制器
  582. * @param num 需要减的月数
  583. * @param check 如果是true表示点击了向右的小三角,是false表示点击了向左的小三角
  584. */
  585. U.MD.UI.calendar.fullDate = function (num, check) {
  586. var _year = (_n = Math.abs(num) / 12) >= 1 ? _n >>> 0 : 0, /*如果月份/12大于1,也就是超过12月或者说1年, _n>>>0取出整数部分*/
  587. _month = Math.abs(num) % 12; /*月份膜上12剩下的就是月份*/
  588. !check && (_month = -_month);
  589. !check && (_year = -_year);
  590. U.MD.UI.calendar.month += _month; /*月份加一或减一*/
  591. U.MD.UI.calendar.year += _year; /*年份加一或减一*/
  592. if (check) {
  593. if (U.MD.UI.calendar.month > 11) { /*如果月份大于11*/
  594. U.MD.UI.calendar.month = 0; /*月份清空*/
  595. U.MD.UI.calendar.year++; /*年份加一*/
  596. }
  597. } else {
  598. if (U.MD.UI.calendar.month < 0) { /*如果月份小于0*/
  599. U.MD.UI.calendar.month = 11; /*可变月赋值11,即表示12月*/
  600. U.MD.UI.calendar.year--; /*可变年减一*/
  601. }
  602. }
  603. if (U.MD.UI.calendar.mark == 1) { U.MD.UI.calendar.showDay() }; /*更新日期显示*/
  604. if (U.MD.UI.calendar.mark == 2) { U.MD.UI.calendar.tit.innerText = U.MD.UI.calendar.year }; /*标记数是2,即代表在选择月模块,*/
  605. if (U.MD.UI.calendar.mark == 3) { U.MD.UI.calendar.dateTenYear() }; /*标记数是3,即代表在选择年模块,*/
  606. }
  607. /**
  608. * 转换输出格式
  609. * @param symbol 分割符号
  610. * @param isnow 【boolean】 是否获取当前时间
  611. * @returns {*} 返回字符串
  612. */
  613. U.MD.UI.calendar.formartDate = function (symbol, isnow) {
  614. var _symbol, y, m, d, h, m, s;
  615. _symbol = symbol || '-'
  616. y = isnow ? U.MD.UI.calendar.CURRENTYEAR : U.MD.UI.calendar.year;
  617. m = isnow ? U.MD.UI.calendar.CURRENTMONTH + 1 : U.MD.UI.calendar.month + 1;
  618. d = isnow ? U.MD.UI.calendar.CURRENTDAY : U.MD.UI.calendar.day;
  619. m = (m.toString())[1] ? m : '0' + m;
  620. d = (d.toString())[1] ? d : '0' + d;
  621. var _dateStr = y + _symbol + m + _symbol + d;
  622. if (typeof U.MD.UI.calendar.datetimeformat == 'boolean' && U.MD.UI.calendar.datetimeformat) {
  623. if (isnow) {
  624. var _nowDate = new Date();
  625. U.MD.UI.calendar.hour = _nowDate.getHours();
  626. U.MD.UI.calendar.minute = _nowDate.getMinutes();
  627. U.MD.UI.calendar.second = _nowDate.getSeconds();
  628. }
  629. h = (U.MD.UI.calendar.hour.toString())[1] ? U.MD.UI.calendar.hour : '0' + U.MD.UI.calendar.hour;
  630. m = (U.MD.UI.calendar.minute.toString())[1] ? U.MD.UI.calendar.minute : '0' + U.MD.UI.calendar.minute;
  631. s = (U.MD.UI.calendar.second.toString())[1] ? U.MD.UI.calendar.second : '0' + U.MD.UI.calendar.second;
  632. _dateStr += " " + h + ":" + m + ":" + s;
  633. }
  634. return _dateStr;
  635. }
  636. /**
  637. * 创建选择天时需要循环绑定的函数
  638. */
  639. /*
  640. U.MD.UI.calendar.outPutDate = function () {
  641. if (U.MD.UI.calendar.fouseinp.value) {
  642. U.MD.UI.calendar.fouseinp.value = U.MD.UI.calendar.formartDate(U.MD.UI.calendar.year, U.MD.UI.calendar.month + 1, this.innerText);
  643. } else {
  644. U.MD.UI.calendar.fouseinp.innerText = U.MD.UI.calendar.formartDate(U.MD.UI.calendar.year, U.MD.UI.calendar.month + 1, this.innerText);
  645. }
  646. U.MD.UI.calendar.board.style.display = 'none';
  647. }
  648. */
  649. /**
  650. * 创建选择天时需要循环绑定的函数
  651. */
  652. U.MD.UI.calendar.outPutDate = function (isNow) {
  653. if (U.MD.UI.calendar.fouseinp.tagName === 'INPUT') {
  654. U.MD.UI.calendar.fouseinp.value = U.MD.UI.calendar.formartDate('-', isNow); /*选择天后进入转换年月日输入格式函数*/
  655. } else {
  656. U.MD.UI.calendar.fouseinp.innerText = U.MD.UI.calendar.formartDate('-', isNow); /*选择天后进入转换年月日输入格式函数*/
  657. }
  658. U.MD.UI.calendar.CheckedDay && U.MD.UI.calendar.CheckedDay();
  659. U.MD.UI.calendar.board.style.display = 'none'; /*隐藏日历控件*/
  660. }
  661. /**
  662. * 显示与隐藏
  663. * @param blockEl 需要显示的元素
  664. * @param noneEl 需要隐藏的元素
  665. * @param val 显示的方式
  666. * @returns {*[]} 返回数组[显示元素,隐藏元素]
  667. */
  668. U.MD.UI.calendar.changeDisplay = function (blockEl, noneEl, val) {
  669. val = val || 'block'; /*默认block*/
  670. if (blockEl && typeof blockEl === 'object') { blockEl.setAttribute('style', 'display:' + val) } /*如果blockEL存在且blockEl是个对象,进行属性的赋值*/
  671. if (noneEl && typeof noneEl === 'object') { noneEl.setAttribute('style', 'display:none') }; /*如果noneEl存在且noneEl是个对象,进行属性的赋值*/
  672. return [blockEl, noneEl];
  673. }
  674. /**
  675. * 更新选择年的模块内容
  676. */
  677. U.MD.UI.calendar.dateTenYear = function () {
  678. _yearArr = U.selectEl('#calendar_year > ul > li'); /*获取选择年模块里的li*/
  679. _startYear = U.MD.UI.calendar.year - (U.MD.UI.calendar.year % 10); /**/
  680. for (var i = 0; i < _yearArr.length; i++) {
  681. _yearArr[i].onclick = function () {
  682. U.MD.UI.calendar.mark = 2; /*标记数赋值2*/
  683. U.MD.UI.calendar.year = parseInt(this.innerText); /*修改年的的值*/
  684. U.MD.UI.calendar.changeDisplay($('#calendar_month')[0], U.selectEl('#calendar_year')[0]); /*显示选择月板块,隐藏选择年的板块*/
  685. U.MD.UI.calendar.tit.innerText = this.innerText; /*改变日历title显示格式*/
  686. }
  687. _yearArr[i].innerHTML = ''; /*清空li里面的内容*/
  688. if (i == 0 || i == _yearArr.length - 1) { /*头尾年*/
  689. $$('span', { "className": "U_MD_UI_calendar_unavailable", innerText: (_startYear + i - 1) }, _yearArr[i]);
  690. } else if ((_startYear + i - 1) === U.MD.UI.calendar.CURRENTYEAR) { /*当前年*/
  691. $$('span', { style: { "background-color": "#eed1bc" }, innerText: (_startYear + i - 1) }, _yearArr[i])
  692. } else { /*默认输出*/
  693. $$('span', { innerText: (_startYear + i - 1) }, _yearArr[i])
  694. }
  695. }
  696. U.MD.UI.calendar.tit.innerText = (t = (U.MD.UI.calendar.year - (U.MD.UI.calendar.year % 10))) + '-' + (t + 9); /*改变日历title显示格式*/
  697. }
  698. /**
  699. * 时分秒数据初始化
  700. * @param deafultflag 【boolean】是否初始化数据
  701. */
  702. U.MD.UI.calendar.ChooseDefault = function (deafultflag) {
  703. if (U.MD.UI.calendar.datetimeformat) { //判断是否显示时分秒模板
  704. if (deafultflag) { //是否初始化数据
  705. U.MD.UI.calendar.hour = '00'; //重置
  706. U.MD.UI.calendar.minute = '00'; //重置
  707. U.MD.UI.calendar.second = '00'; //重置
  708. U.selectEl(U.MD.UI.calendar.board).find('.U_MD_UI_calendar_timeRowActive').removeClass('U_MD_UI_calendar_timeRowActive'); //清除选中的样式
  709. !$('#U_MD_UI_calendar_timeText').length && U.MD.UI.calendar.createChooseTime($('#calendar_timeChoose')[0]); //是否有加载时分秒模块
  710. }
  711. U.selectEl('#calendar_time')[0].style.display = "block"; //显示选择时间的功能区
  712. U.selectEl('#calendar_timeChoose')[0].style.display = 'none'; //隐藏选择时分秒选择区
  713. U.selectEl('#U_MD_UI_calendar_timeText')[0].innerText = "选择时间"; //重置
  714. U.selectEl('#U_MD_UI_calendar_timeText').removeClass("U_MD_UI_calendar_timeTextClick"); //重置
  715. } else {
  716. U.selectEl('#calendar_time')[0].style.display = 'none'; //重置
  717. U.selectEl('#calendar_timeChoose')[0].style.display = 'none'; //重置
  718. }
  719. }
  720. U.MD.UI.calendar.SetCallBack = function (funcname, func) {
  721. if (typeof func != 'function' || !"CheckedDay ".match(funcname + ' '))
  722. return 0;
  723. U.MD.UI.calendar[funcname] = func
  724. };
  725. ///<jscompress sourcefile="City.js" />
  726. Namespace.register("U.MD.UI.city");
  727. /**
  728. * [Control description] 城市控件接口
  729. * @param {[html元素]} element [需要使用城市控件的元素(默认放置到element下面)]
  730. */
  731. U.MD.UI.city = function (element) {
  732. U.UF.EV.stopBubble(); //阻止事件冒泡 防止被body的事件覆盖
  733. if (!element || !element.tagName) { //如果element存在tagName 则一定是html元素 否则不执行城市控件
  734. return;
  735. }
  736. if (_cityBox = U.selectEl("#U_MD_UI_city_cityBox")[0]) {
  737. var _rect = element.getBoundingClientRect();
  738. _cityBox.style.top = _rect.top + _rect.height + document.documentElement.scrollTop + "px";
  739. //调整控件的top位置
  740. _cityBox.style.left = _rect.left + document.documentElement.scrollLeft + "px";
  741. //调整控件的left位置
  742. U.selectEl(_cityBox).removeClass("U_MD_UI_city_hidden");
  743. //删除掉hidden的class名(显示城市控件) 目的: 去除掉display为none的样式
  744. U.MD.UI.city.Attr.inputNode = element; //获取最终结果的表单元素 可能会不同 因此 inputNode需要重新赋值
  745. return;
  746. }
  747. var _city = U.MD.UI.city; //简写命名空间
  748. _city.create(element); //将控件html代码添加到body上 并调整控件位置
  749. _city.Attr = { //存放节点 与 变量 的json对象
  750. "inputNode": element //判断是哪个表单点击的 为赋值所用
  751. };
  752. _city.init(); //函数初始化(添加js功能)
  753. };
  754. U.MD.UI.city.Attr = {}; //存放元素与变量的json全局变量 未赋值
  755. U.MD.UI.city.usedCity = null; //存放常用市数据的变量
  756. U.MD.UI.city.province = null; //存放省数据的变量
  757. U.MD.UI.city.city = {}; //存放市数据的变量
  758. U.MD.UI.city.area = {}; //存放区数据的变量
  759. U.MD.UI.city.htmlTemplate = ' <ul class="U_MD_UI_city_menuBox"> <!--控件的头部-->\n' +
  760. '\n' +
  761. ' <!--U_MD_UI_city_menuChecked 选中菜单的按钮时所用的"className":红色-->\n' +
  762. ' <!--U_MD_UI_city_filled 表示待填写class 为增删class占位置 防出错 以下都是-->\n' +
  763. ' <!--U_MD_UI_city_menuoChecked 选择城市后所添加的class 红色小圆点-->\n' +
  764. ' <li id="U_MD_UI_city_usedCityMenu" data-city-mark="U_MD_UI_city_usedCityCont" class="U_MD_UI_city_menuChecked" data-city-res="">\n' +
  765. ' <span>常用市</span>\n' +
  766. ' </li>\n' +
  767. '\n' +
  768. ' <li id="U_MD_UI_city_provinceMenu" data-city-mark="U_MD_UI_city_provinceCont" class="U_MD_UI_city_filled" data-city-res="">\n' +
  769. ' <span>省/直辖市</span>\n' +
  770. ' </li>\n' +
  771. '\n' +
  772. ' <li id="U_MD_UI_city_cityMenu" data-city-mark="U_MD_UI_city_cityCont" class="U_MD_UI_city_filled U_MD_UI_city_hidden" data-city-res="">\n' +
  773. ' <span>请选择</span>\n' +
  774. ' </li>\n' +
  775. '\n' +
  776. ' <li id="U_MD_UI_city_areaMenu" data-city-mark="U_MD_UI_city_areaCont" class="U_MD_UI_city_filled U_MD_UI_city_hidden" data-city-res="">\n' +
  777. ' <span>请选择</span>\n' +
  778. ' </li>\n' +
  779. ' </ul>\n' +
  780. '\n' +
  781. '\n' +
  782. ' <!--以下为主要内容区域-->\n' +
  783. ' <!-- ----------------------------------------------------------------------------- -->\n' +
  784. ' <ul id="U_MD_UI_city_usedCityCont" class="U_MD_UI_city_filled U_MD_UI_city_Cont"> <!-- &lt;!&ndash;常用城市盒子节点&ndash;&gt; -->\n' +
  785. ' <li id="U_MD_UI_city_liTemplate"><span>光明新区</span></li>\n' +
  786. ' <!-- U_MD_UI_city_liTemplate 为内容区域的li的模板 可无视 已display为none -->\n' +
  787. ' <!--U_MD_UI_city_Cont_ochecked 选中城市的按钮时所用的"className":红色-->\n' +
  788. ' </ul>\n' +
  789. '\n' +
  790. '\n' +
  791. ' <ul class="U_MD_UI_city_filled U_MD_UI_city_Cont U_MD_UI_city_hidden" id="U_MD_UI_city_provinceCont"> <!-- &lt;!&ndash;存放省的盒子节点&ndash;&gt; -->\n' +
  792. ' </ul>\n' +
  793. '\n' +
  794. '\n' +
  795. ' <ul class="U_MD_UI_city_filled U_MD_UI_city_Cont U_MD_UI_city_hidden" id="U_MD_UI_city_cityCont"> <!-- &lt;!&ndash;存放市的盒子节点&ndash;&gt; -->\n' +
  796. ' </ul>\n' +
  797. '\n' +
  798. '\n' +
  799. ' <ul class="U_MD_UI_city_filled U_MD_UI_city_Cont U_MD_UI_city_hidden" id="U_MD_UI_city_areaCont"> <!-- &lt;!&ndash;存放地区的盒子节点&ndash;&gt; -->\n' +
  800. ' </ul>';
  801. //html代码
  802. /**
  803. * 添加html代码,并且判断html代码是否存在 若存在 则不添加
  804. * @param {[html元素]} element [需要使用城市控件的元素(默认放置到element下面)]
  805. */
  806. U.MD.UI.city.create = function (element) {
  807. var _cityBox = $$("div", { id: 'U_MD_UI_city_cityBox', className: 'U_MD_UI_city_cityBox U_MD_UI_city_hidden' }, document.body);
  808. _cityBox.innerHTML += U.MD.UI.city.htmlTemplate;
  809. var _rect = element.getBoundingClientRect();
  810. _cityBox.style.top = _rect.top + _rect.height + document.documentElement.scrollTop + "px";
  811. //调整控件的top位置
  812. _cityBox.style.left = _rect.left + document.documentElement.scrollLeft + "px";
  813. //调整控件的left位置
  814. U.MD.UI.city.Attr.inputNode = element;
  815. //获取最终结果的表单元素 可能会不同 因此 inputNode需要重新赋值
  816. U.selectEl(_cityBox).removeClass("U_MD_UI_city_hidden");
  817. //删除掉hidden的class名(显示城市控件) 目的: 去除掉display为none的样式
  818. };
  819. /**
  820. * 函数初始化
  821. */
  822. U.MD.UI.city.init = function () {
  823. var _city = U.MD.UI.city; //简写命名空间
  824. _city.getUsedCity(); //获取常用市所有数据
  825. _city.inputEvent(); //添加监听事件: 点击表单显示城市控件并发送后台请求数据 与 点击body区域隐藏城市控件
  826. _city.menuEvent(); //添加监听事件: 点击菜单显示对应的内容
  827. };
  828. /**
  829. * 为表单添加点击事件
  830. */
  831. U.MD.UI.city.inputEvent = function () {
  832. var _city = U.MD.UI.city; //简写命名空间
  833. var _attr = _city.Attr; //简写全局属性json名
  834. var _hidden = "U_MD_UI_city_hidden"; //class样式名 由于太长赋值给变量 _hidden 控制元素display的样式
  835. var _cityBox = U.selectEl("#U_MD_UI_city_cityBox")[0]; //城市控件总盒子节点
  836. U.selectEl(document).bind('click', function () { //点击body时 隐藏城市控件
  837. U.selectEl(_cityBox).addClass(_hidden);
  838. //添加掉hidden的class名 目的: 添加display为none的样式
  839. }, false);
  840. U.selectEl(_cityBox).bind('click', function (e) { //防止点击城市控件时 被body的事件覆盖而隐藏 因此加上防止冒泡处理
  841. U.UF.EV.stopBubble(e);
  842. //阻止事件冒泡
  843. });
  844. U.selectEl("#U_MD_UI_city_areaCont")[0].onclick = function () {
  845. if ($("#U_MD_UI_city_areaCont")[0]) {
  846. U.selectEl("#U_MD_UI_city_cityBox")[0].style.display = "none";
  847. }
  848. }
  849. };
  850. /**
  851. * 为每个菜单添加点击事件
  852. */
  853. U.MD.UI.city.menuEvent = function () {
  854. var _city = U.MD.UI.city; //简写命名空间
  855. var _attr = _city.Attr; //简写全局属性json名
  856. var _menuAllNode = U.selectEl("[data-city-mark]"); //所有菜单节点;
  857. var _hidden = "U_MD_UI_city_hidden"; //class样式名 由于太长赋值给变量 _hidden 控制元素display的样式
  858. for (var i = 0, len = _menuAllNode.length; i < len; i++) { //循环所有菜单元素
  859. var _el = _menuAllNode[i]; //获取每个菜单 赋值给变量el
  860. U.selectEl(_el).bind('click', function () { //添加点击事件
  861. _city.menuClassControl(this, "U_MD_UI_city_menuChecked", "data-city-mark", _hidden); //为每个菜单添加对应每个区域的事件
  862. });
  863. if (_el.id === "U_MD_UI_city_provinceMenu") { //如果点击的是 省/直辖市 菜单 则获取对应的数据
  864. U.selectEl(_el).bind('click', function () {
  865. _city.getProvince(); //省/直辖市菜单的点击事件 获取数据
  866. })
  867. }
  868. }
  869. };
  870. /**
  871. * 获取数据常用市的所有数据
  872. */
  873. U.MD.UI.city.getUsedCity = function () {
  874. var _city = U.MD.UI.city; //简写命名空间
  875. var _attr = _city.Attr; //简写全局属性json名
  876. var _usedCityMenu = U.selectEl("#U_MD_UI_city_usedCityMenu")[0]; //常用市菜单按钮
  877. var _liTemplate = U.selectEl("#U_MD_UI_city_liTemplate")[0]; //要clone的li的模板
  878. var _usedCityCont = U.selectEl("#U_MD_UI_city_usedCityCont")[0]; //常用市内容区域
  879. if (!_city.usedCity) { //如果 常用市(_city.usedCity) 无数据 则发送请求到后台获取数据 并打印出来
  880. U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Controls", "City_UsedCity"], function (r) {
  881. _city.usedCity = r.value;
  882. _city.allDataPrint(_usedCityMenu, _city.usedCity, _liTemplate, "usedCity", _usedCityCont); //打印数据
  883. });
  884. }
  885. };
  886. /**
  887. * 获取省/直辖市的所有数据
  888. */
  889. U.MD.UI.city.getProvince = function () {
  890. var _city = U.MD.UI.city; //简写命名空间
  891. var _attr = _city.Attr; //简写全局属性json名
  892. var _provinceMenu = U.selectEl("#U_MD_UI_city_provinceMenu")[0]; //省菜单按钮
  893. var _liTemplate = U.selectEl("#U_MD_UI_city_liTemplate")[0]; //要clone的li的模板
  894. var _provinceCont = U.selectEl("#U_MD_UI_city_provinceCont")[0]; //省内容区域
  895. if (!_city.province) { //如果 省/直辖市(_city.province) 无数据 则发送请求到后台获取数据 并打印出来
  896. U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Controls", "City_Province"], function (r) {
  897. _city.province = r.value;
  898. _city.allDataPrint(_provinceMenu, _city.province, _liTemplate, "province", _provinceCont); //打印数据
  899. });
  900. }
  901. };
  902. /**
  903. * 通过code 获取市的所有数据
  904. * @param code 省级的id
  905. */
  906. U.MD.UI.city.getCity = function (code) {
  907. var _city = U.MD.UI.city; //简写命名空间
  908. var _attr = _city.Attr; //简写全局属性json名
  909. var _cityMenu = U.selectEl("#U_MD_UI_city_cityMenu")[0]; //市菜单按钮
  910. var _liTemplate = U.selectEl("#U_MD_UI_city_liTemplate")[0]; //要clone的li的模板
  911. var _cityCont = U.selectEl("#U_MD_UI_city_cityCont")[0]; //市内容区域
  912. var _hidden = "U_MD_UI_city_hidden"; //class样式名 由于太长赋值给变量 _hidden 控制元素display的样式
  913. if (!_city.city[code]) { //_city.city = json 而_city.city[code]则是对应的数组值 例如:我点击广东后 获取到了广东的id 则我要通过 广东的id 获取下级的市数据 因此如果json中没有该值 则向后台发送请求获取
  914. _city.menuClassControl(_cityMenu, "U_MD_UI_city_menuChecked", "data-city-mark", _hidden); //相当于点击菜单 将城市的菜单于内容 "先"显示出来 再加载数据 防止多次点击
  915. U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Controls", "City_PidFind", code, 1], function (r) {
  916. _city.city[code] = r.value;
  917. //_city.city = {}
  918. //r.value = [{},{},{}]
  919. //为了能判断该code下是否有数据 因此需要在_city.city下添加一个 以code为键名 r.value为值的数组
  920. //例如:_city.city = {} code = 123 r.value = [{a:1},{a:1},{a:1}] 最后会变成 _city.city = {123:[{a:1},{a:1},{a:1}]}
  921. _city.allDataPrint(_cityMenu, _city.city[code], _liTemplate, "city", _cityCont); //打印数据
  922. });
  923. } else { //如果json下有数据 则直接打印该数据
  924. _city.menuClassControl(_cityMenu, "U_MD_UI_city_menuChecked", "data-city-mark", _hidden); //相当于点击菜单 将城市的菜单与内容区域 显示出来
  925. _city.allDataPrint(_cityMenu, _city.city[code], _liTemplate, "city", _cityCont); //打印数据
  926. }
  927. };
  928. /**
  929. * 通过code 获取区级的所有数据 函数的意思可参看上面getCity的注释
  930. * @param code 参数为市级的id
  931. */
  932. U.MD.UI.city.getarea = function (code) {
  933. var _city = U.MD.UI.city; //简写命名空间
  934. var _attr = _city.Attr; //简写全局属性json名
  935. var _areaMenu = U.selectEl("#U_MD_UI_city_areaMenu")[0]; //区菜单按钮
  936. var _hidden = "U_MD_UI_city_hidden"; //class样式名 由于太长赋值给变量 _hidden 控制元素display的样式
  937. var _liTemplate = U.selectEl("#U_MD_UI_city_liTemplate")[0]; //要clone的li的模板
  938. var _areaCont = U.selectEl("#U_MD_UI_city_areaCont")[0]; //区内容区域
  939. if (!_city.area[code]) {
  940. _city.menuClassControl(_areaMenu, "U_MD_UI_city_menuChecked", "data-city-mark", _hidden); //相当于点击菜单 将城市的菜单于内容 "先"显示出来 再加载数据 防止多次点击
  941. U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Controls", "City_PidFind", code, 2], function (r) {
  942. _city.area[code] = r.value;
  943. _city.allDataPrint(_areaMenu, _city.area[code], _liTemplate, "area", _areaCont);
  944. });
  945. } else {
  946. _city.menuClassControl(_areaMenu, "U_MD_UI_city_menuChecked", "data-city-mark", _hidden); //相当于点击菜单 将城市的菜单于内容 "先"显示出来 再加载数据 防止多次点击
  947. _city.allDataPrint(_areaMenu, _city.area[code], _liTemplate, "area", _areaCont);
  948. }
  949. };
  950. /**
  951. * 打印传过来的数组json数据
  952. * @param {[type]} menu [与之对应的菜单元素]
  953. * @param {[type]} data [是一个数组json]
  954. * @param {[type]} template [是一个li模板 clone用的]
  955. * @param {[type]} type [数据类型("province"、"usedCity"....) 为判断所用]
  956. * @param {[type]} parent [父节点("cityCont,areaCont...") 也叫做内容区域 ]
  957. */
  958. U.MD.UI.city.allDataPrint = function (menu, data, template, type, parent) {
  959. var _city = U.MD.UI.city; //简写命名空间
  960. var _attr = _city.Attr; //简写全局属性json名
  961. var _usedCityMenu = U.selectEl("#U_MD_UI_city_usedCityMenu")[0]; //常用市菜单按钮
  962. var _provinceMenu = U.selectEl("#U_MD_UI_city_provinceMenu")[0]; //省菜单按钮
  963. var _len = data.length; //数组json的长度
  964. var _menu = menu; //菜单元素 赋值给 _menu变量
  965. for (var i = 0; i < _len; i++) {
  966. // 遍历 data数据(数组json)
  967. var _span = _city.dataPrint(data[i], template, type, parent);
  968. //单个数据打印 PS:由于data是一个 数组json([{a:1},{a:2},{a:3}]) 因此 需要将获取对应的数据 并添加在 对应的 parent(内容区域) 上
  969. _span.onclick = function () {
  970. var _type = U.selectEl(this).attr("data-city-type");
  971. //获取点击的span标签的属于哪一类型 (比如: 点击省的数据 是 province 市的数据 则时 city)
  972. var _code = U.selectEl(this).attr("data-city-code");
  973. //获取数据编码 为寻找下一层所用
  974. U.selectEl(_menu.children[0]).addClass("U_MD_UI_city_menuoChecked");
  975. //点击后为 对应的相对应的菜单添加红色小圆点样式 例如:点击省/直辖市菜单下的 广东后 省/直辖市就会多一个红色小圆点的样式
  976. _menu.children[0].innerText = this.innerText;
  977. //改变对应菜单的名字为:点击数据的值 例如:点击"省/直辖市"菜单 下的广东 则 菜单的名字则变为 广东 PS: children[0] 为 li下的span标签
  978. U.selectEl(_menu).attr("data-city-res", this.innerText);
  979. //给自定义属性 data-city-res 添加为: 点击数据的值 PS: 为获取最终值给表单所用
  980. _city.contClassControl(this, "U_MD_UI_city_Cont_ochecked");
  981. //给所选的内容数据添加红色背景 并且删除同一内容区域拥有红色背景的其他元素
  982. switch (_type) {
  983. //此处为 判断 点击 各类型数据需要做的动作 type为判断哪种类型 比如: type值为 "province" 则是 省/直辖市菜单下的 数据 点击这些数据后 就是要做的事情
  984. case "province":
  985. _city.getCity(_code);
  986. //将数据的 code 值传入给 城市函数 来获取城市数据 PS: 获取市的数据需要获取他们的parentid 而code则是他们的parentid
  987. _city.initAllClass(_usedCityMenu);
  988. //点击省/直辖市下的数据的话 则初始化 常用市菜单 与 相对应的内容区域样式
  989. break;
  990. case "usedCity":
  991. if (this.innerText === "重庆") { //由于重庆这个城市比较特殊 因此需要在常用市那将重庆转为省数据
  992. _city.getCity(_code);
  993. } else {
  994. _city.getarea(_code);
  995. }
  996. //在将数据的 code 值传入给 城市函数 来获取城市数据 PS: 获取市的数据需要获取他们的parentid 而code则是他们的parentid
  997. _city.initAllClass(_provinceMenu);
  998. //点击常用市下的数据的话 则初始化 省/直辖市菜单 与 相对应的内容区域样式
  999. break;
  1000. case "city":
  1001. _city.getarea(_code);
  1002. //在将数据的 code 值传入给 区函数 来获取区数据 PS: 获取区的数据需要获取他们的parentid 而code则是他们的parentid
  1003. break;
  1004. case "area":
  1005. _city.getRes("data-city-res");
  1006. //由于该控件是 省-市-区 因此 当点击区里的数据时 则调用获取最终值的函数
  1007. break;
  1008. }
  1009. }
  1010. }
  1011. };
  1012. /**
  1013. * 打印单个数据api(创建节点,赋id 赋innerText 等等)
  1014. * @param {[json对象]} data [json对象的数据]
  1015. * @param {[元素]} template [需要clone的li模板]
  1016. * @param {[字符串]} type [属于哪种城市类型]
  1017. * @param {[元素]} parent [父节点]
  1018. * @return {[元素]} [克隆完后的一条li下的span节点]
  1019. */
  1020. U.MD.UI.city.dataPrint = function (data, template, type, parent) {
  1021. var _city = U.MD.UI.city; //简写命名空间
  1022. var _liNode = _city.clone(template), //克隆已建好的li模板
  1023. _spanNode = _liNode.children[0]; //获取li的span节点
  1024. var _shortName = data.short_name; //获取城市名字缩写
  1025. var _name = data.name; //获取名字全称
  1026. _liNode.id = type + data.id; //添加id
  1027. _spanNode.innerText = _shortName; //添加文字内容
  1028. if (_shortName === "北京" || _shortName === "上海" || _shortName === "天津" || _shortName === "重庆") {//由于这4个城市的 缩写 和省的名字相同 因此 需要将数据名 改成name 详见数据库
  1029. if (parent.id === "U_MD_UI_city_cityCont") {
  1030. _spanNode.innerText = _name; //添加文字内容
  1031. }
  1032. }
  1033. if (parent.id === "U_MD_UI_city_areaCont") { //由于区级数据库 的缩写少了一个区 例如:显示出来的 龙岗区 被缩成 龙岗 因此需要将值等于他们的全称
  1034. _spanNode.innerText = _name; //添加文字内容
  1035. }
  1036. _spanNode.id = "span_" + type + data.id;
  1037. U.selectEl(_spanNode).attr("data-city-code", data.id); //添加自定义属性 编号
  1038. U.selectEl(_spanNode).attr("data-city-type", type); //添加自定义属性 类型
  1039. parent.appendChild(_liNode); //添加到parent节点上
  1040. return _spanNode; //返回该元素
  1041. };
  1042. /**
  1043. * 添加选中时的class 并删除已有该class的元素
  1044. * @param {[元素]} el [点击菜单的元素]
  1045. * @param {[字符串]} cs [选中菜单时的class]
  1046. * @param {[字符串]} dataattr [菜单的自定义属性 与 对应内容区域的id相同]
  1047. * @param {[字符串]} hiddenCs [对应内容区域的class]
  1048. */
  1049. U.MD.UI.city.menuClassControl = function (el, cs, dataattr, hiddenCs) {
  1050. var _city = U.MD.UI.city; //简写命名空间
  1051. var _attr = _city.Attr; //简写全局属性json名
  1052. var _cityMenu = U.selectEl("#U_MD_UI_city_cityMenu")[0]; //市菜单按钮
  1053. var _areaMenu = U.selectEl("#U_MD_UI_city_areaMenu")[0]; //区菜单按钮
  1054. var _cityCont = U.selectEl("#U_MD_UI_city_cityCont")[0]; //市内容区域
  1055. var _areaCont = U.selectEl("#U_MD_UI_city_areaCont")[0]; //区内容区域
  1056. var _oEl = U.selectEl("." + cs)[0];
  1057. //找到拥有该class的元素
  1058. if (_oEl) { U.selectEl(_oEl).removeClass(cs) };
  1059. //如果找的到该元素 则删除此元素的class
  1060. U.selectEl(el).addClass(cs);
  1061. //为el元素添加该class
  1062. var _oElCont = U.selectEl("#" + U.selectEl(_oEl).attr(dataattr))[0];
  1063. //找到拥有该class的菜单元素的自定义属性的值 并找到对应区域块的元素(区域块元素的id 与 自定义属性的值相等)
  1064. var _elCont = U.selectEl("#" + U.selectEl(el).attr(dataattr))[0];
  1065. //同上 找到点击菜单元素的自定义属性的值
  1066. U.selectEl(_oElCont).addClass(hiddenCs);
  1067. //添加名为hiddenCs 的className (添加与删除 display为none)
  1068. U.selectEl(_elCont).removeClass(hiddenCs);
  1069. //elCont元素的display为block
  1070. var _id = el.id;
  1071. switch (_id) { //以下为点击菜单时所作出的不同执行命令
  1072. case "U_MD_UI_city_usedCityMenu":
  1073. case "U_MD_UI_city_provinceMenu": //当为菜单常用市 或者 省直辖市时 将区 与 市菜单 与对应内容区域 清空初始化
  1074. U.selectEl(_cityMenu).addClass(hiddenCs);
  1075. U.selectEl(_areaMenu).addClass(hiddenCs);
  1076. U.selectEl(_cityCont).addClass(hiddenCs);
  1077. U.selectEl(_areaCont).addClass(hiddenCs);
  1078. _cityMenu.children[0].innerText = "请选择";
  1079. _areaMenu.children[0].innerText = "请选择";
  1080. _cityCont.innerHTML = "";
  1081. _areaCont.innerHTML = "";
  1082. U.selectEl(_cityMenu).attr("data-city-res", "");
  1083. U.selectEl(_areaMenu).attr("data-city-res", "");
  1084. break;
  1085. case "U_MD_UI_city_cityMenu": //当为市菜单时 将 区菜单 与对应内容区域 清空初始化
  1086. U.selectEl(el).removeClass(hiddenCs);
  1087. U.selectEl(_areaMenu).addClass(hiddenCs);
  1088. U.selectEl(_areaCont).addClass(hiddenCs);
  1089. _areaMenu.children[0].innerText = "请选择";
  1090. _areaCont.innerHTML = "";
  1091. break;
  1092. case "U_MD_UI_city_areaMenu":
  1093. U.selectEl(el).removeClass(hiddenCs);
  1094. break;
  1095. }
  1096. };
  1097. /**
  1098. * 内容区域的class 的控制函数 PS:添加红色背景的样式
  1099. * @param {[type]} el [所选中的数据元素]
  1100. * @param {[type]} ocheckcs [所需要对el添加的样式]
  1101. */
  1102. U.MD.UI.city.contClassControl = function (el, ocheckcs) {
  1103. var _city = U.MD.UI.city; //简写命名空间
  1104. var _oEls = U.selectEl("." + ocheckcs);
  1105. //找到拥有该class的所有元素
  1106. var _type = U.selectEl(el).attr("data-city-type");
  1107. //获取他们的该元素的类型
  1108. for (var i = 0, len = _oEls.length; i < len; i++) { //遍历oEls
  1109. var _otype = U.selectEl(_oEls[i]).attr("data-city-type");
  1110. if (_oEls[i] && _otype === _type) {
  1111. //如果找的到该元素 并且还是同一内容区域的元素 则删除他的class 例如:(市内容区域下)点击深圳后 在点广州 则 广州的背景颜色为红色 深圳的背景颜色为初始颜色
  1112. U.selectEl(_oEls[i]).removeClass(ocheckcs)
  1113. }
  1114. }
  1115. U.selectEl(el).addClass(ocheckcs);
  1116. //为el元素添加该class
  1117. };
  1118. /**
  1119. * 此函数专门为 初始化 常用市 或者 省/直辖市的样式而写的 例如:点击常用市下的数据后 省/直辖市的菜单与对应的内容 样式初始化为不选中
  1120. * @param el 只能放 常用市菜单(元素) 和 省/直辖市菜单(元素)
  1121. */
  1122. U.MD.UI.city.initAllClass = function (el) {
  1123. var _city = U.MD.UI.city; //简写命名空间
  1124. el.className = "U_MD_UI_city_filled"; //将菜单li的样式初始化 U_MD_UI_city_filled无样式属性 摆设占位置用
  1125. el.children[0].className = ""; //将li里的span样式也初始化
  1126. U.selectEl(el).attr("data-city-res", ""); //将span的自定义属性也初始化
  1127. var oEl = U.selectEl(".U_MD_UI_city_Cont_ochecked"); //获取内容区域中被选中的span元素
  1128. for (var i = 0; i < oEl.length; i++) {
  1129. U.selectEl(oEl[i]).removeClass("U_MD_UI_city_Cont_ochecked"); //判断是否存在此元素 如果存在 则删除被选中的样式
  1130. }
  1131. if (el.id === "U_MD_UI_city_provinceMenu") { //比如: 点完省/直辖市内容区域的数据时 传过来的el则会是常用市菜单元素 然后常用市菜单的innerText则会初始化回常用市
  1132. el.children[0].innerText = "省/直辖市";
  1133. }
  1134. if (el.id === "U_MD_UI_city_usedCityMenu") { //同上
  1135. el.children[0].innerText = "常用市";
  1136. }
  1137. };
  1138. /**
  1139. * 通过获取自定义属性的值 查出最终值
  1140. * @param dataattr 自定义属性的名字
  1141. */
  1142. U.MD.UI.city.getRes = function (dataattr) {
  1143. var _city = U.MD.UI.city; //简写命名空间
  1144. var _attr = _city.Attr; //简写全局属性json名
  1145. var _inputNode = _attr.inputNode;
  1146. var _cityBox = U.selectEl("#U_MD_UI_city_cityBox")[0]; //城市控件总盒子节点
  1147. var _hidden = "U_MD_UI_city_hidden"; //class样式名 由于太长赋值给变量 _hidden 控制元素display的样式
  1148. var resAll = U.selectEl("[" + dataattr + "]"); //获取所有拥有该自定义属性的元素 得到一个数组
  1149. var _arr = []; //声明一个空数组 存放最终值
  1150. for (var i = 0, len = resAll.length; i < len; i++) { //遍历所有自定义元素
  1151. var _val = U.selectEl(resAll[i]).attr(dataattr); //获取他们的自定义值
  1152. if (_val) { //判断值是否存在
  1153. _arr.push(_val); //若存在 则将最终值依次添加到arr数组里
  1154. }
  1155. }
  1156. _inputNode.value = (_arr.join("-")); //最后分割数组用“-” 隔开 添加到表单上
  1157. U.selectEl(_cityBox).addClass(_hidden); //最后隐藏控件
  1158. };
  1159. U.MD.UI.city.clone = function (ele) { //克隆节点
  1160. var node = ele.cloneNode();
  1161. var child = ele.children;
  1162. for (var i = 0; i < child.length; i++) {
  1163. var childNode = child[i].cloneNode();
  1164. node.appendChild(childNode);
  1165. }
  1166. return node;
  1167. };;
  1168. ///<jscompress sourcefile="Color.js" />
  1169. //色板
  1170. Namespace.register("U.MD.UI.ColorPicker");
  1171. /**
  1172. * 创建颜色选区
  1173. * @barelement [object] 要插入表格的地方
  1174. * @ callfun [fun] 点击事件
  1175. */
  1176. U.MD.UI.colorPicker = U.MD.UI.ColorPicker = function (barelement, callfun) {
  1177. var div = $$("div", {
  1178. style: {
  1179. width: "180px",
  1180. height: "140px",
  1181. border: "1px solid #CDCDCD",
  1182. backgroundColor: " #FFF",
  1183. padding: "10px 10px 10px 5px",
  1184. zIndex: 1
  1185. }
  1186. , "className": "MD_ColorPicker"
  1187. }, barelement); //创建外部div对象
  1188. var _i,
  1189. _colorarea = [ //字体颜色区域
  1190. "#ffffff",
  1191. "#ffccc9",
  1192. "#ffce93",
  1193. "#fffc9e",
  1194. "#ffffc7",
  1195. "#9aff99",
  1196. "#96fffb",
  1197. "#cdffff",
  1198. "#cbcefb",
  1199. "#cfcfcf",
  1200. "#fd6864",
  1201. "#fe996b",
  1202. "#fffe65",
  1203. "#fcff2f",
  1204. "#67fd9a",
  1205. "#38fff8",
  1206. "#68fdff",
  1207. "#9698ed",
  1208. "#c0c0c0",
  1209. "#fe0000",
  1210. "#f8a102",
  1211. "#ffcc67",
  1212. "#f8ff00",
  1213. "#34ff34",
  1214. "#68cbd0",
  1215. "#34cdf9",
  1216. "#6665cd",
  1217. "#9b9b9b",
  1218. "#cb0000",
  1219. "#f56b00",
  1220. "#ffcb2f",
  1221. "#ffc702",
  1222. "#32cb00",
  1223. "#00d2cb",
  1224. "#3166ff",
  1225. "#6434fc",
  1226. "#656565",
  1227. "#9a0000",
  1228. "#ce6301",
  1229. "#cd9934",
  1230. "#999903",
  1231. "#009901",
  1232. "#329a9d",
  1233. "#3531ff",
  1234. "#6200c9",
  1235. "#343434",
  1236. "#680100",
  1237. "#963400",
  1238. "#986536",
  1239. "#646809",
  1240. "#036400",
  1241. "#34696d",
  1242. "#00009b",
  1243. "#303498",
  1244. "#000000",
  1245. "#330001",
  1246. "#643403",
  1247. "#663234",
  1248. "#343300",
  1249. "#013300",
  1250. "#003532",
  1251. "#010066",
  1252. "#340096"];
  1253. var button; //定义一个变量
  1254. for (_i = 0; _i < _colorarea.length; _i++) {//创建循环,循环对象为创建的数组
  1255. button = $$('button', {
  1256. style: {
  1257. background: _colorarea[_i],
  1258. width: "15px",
  1259. height: "15px",
  1260. float: "left",
  1261. margin: "5px 0 0 5px",
  1262. border: " 1px solid transparent"
  1263. }
  1264. }, div); //创建button对象
  1265. button.onclick = function (e) {
  1266. div.style.display = 'none' /*选择完色块后隐藏色板*/
  1267. U.UF.EV.stopBubble(e); /*阻止事件冒泡*/
  1268. callfun(this.style.background);
  1269. } //设置点击事件
  1270. }
  1271. U.selectEl(document).bind('click', function () {/*绑定事件*/
  1272. if (div.style.display != 'none') /*点击别的地方隐藏*/
  1273. div.style.display = 'none'
  1274. });
  1275. U.UF.EV.stopBubble();
  1276. return div; //返回div对象
  1277. };
  1278. ///<jscompress sourcefile="Common.js" />
  1279. //工具空间,宝航字体、字号。。。
  1280. //字体
  1281. Namespace.register("U.MD.UI.Font");
  1282. //字号
  1283. Namespace.register("U.MD.UI.WordSize");
  1284. /*
  1285. * 字体选择框生成方法
  1286. */
  1287. U.MD.UI.Font = function () {
  1288. var font = $$("select", { style: { fontFamily: "宋体", fontSize: "16px" }, "className": "MD_fontFamily" }); //创建select对象
  1289. $$("option", { value: "宋体", style: { fontFamily: "宋体" }, innerHTML: "宋体" }, font); //定义option对象宋体,附属select
  1290. $$("option", { value: "sans-serif", style: { fontFamily: "sans-serif" }, innerHTML: "sans-serif" }, font); //定义option对象sans-serif,附属select
  1291. $$("option", { value: "微软雅黑", style: { fontFamily: "微软雅黑" }, innerHTML: "微软雅黑" }, font); //定义option对象微软雅黑,附属select
  1292. $$("option", { value: "楷体", style: { fontFamily: "楷体" }, innerHTML: "楷体" }, font); //定义option对象楷体,附属select
  1293. $$("option", { value: "黑体", style: { fontFamily: "黑体" }, innerHTML: "黑体" }, font); //定义option对象黑体,附属select
  1294. $$("option", { value: "隶书", style: { fontFamily: "隶书" }, innerHTML: "隶书" }, font); //定义option对象隶书,附属select
  1295. $$("option", { value: "andale mono", style: { fontFamily: "andale mono" }, innerHTML: "andale mono" }, font); //定义option对象andale mono,附属select
  1296. $$("option", { value: "arial black", style: { fontFamily: "arial black" }, innerHTML: "arial black" }, font); //定义option对象arial black,附属select
  1297. return font; //返回select对象
  1298. }
  1299. /*
  1300. * 字号选择框生成方法
  1301. */
  1302. U.MD.UI.WordSize = function () {
  1303. var fontsize = $$("select", { "className": "MD_fontSize" }); //创建select对象
  1304. $$("option", { value: "56px", style: { fontSize: "14px" }, innerHTML: "初号" }, fontsize); //定义option对象初号,附属select
  1305. $$("option", { value: "48px", style: { fontSize: "14px" }, innerHTML: "小初" }, fontsize); //定义option对象小初,附属select
  1306. $$("option", { value: "34.7px", style: { fontSize: "14px" }, innerHTML: "一号" }, fontsize); //定义option对象一号,附属select
  1307. $$("option", { value: "32px", style: { fontSize: "14px" }, innerHTML: "小一" }, fontsize); //定义option对象小一,附属select
  1308. $$("option", { value: "29.3px", style: { fontSize: "14px" }, innerHTML: "二号" }, fontsize); //定义option对象二号,附属select
  1309. $$("option", { value: "24px", style: { fontSize: "14px" }, innerHTML: "小二" }, fontsize); //定义option对象小二,附属select
  1310. $$("option", { value: "21.3px", style: { fontSize: "14px" }, innerHTML: "三号" }, fontsize); //定义option对象三号,附属select
  1311. $$("option", { value: "20px", style: { fontSize: "14px" }, innerHTML: "小三" }, fontsize); //定义option对象小三,附属select
  1312. $$("option", { value: "18.7px", style: { fontSize: "14px" }, innerHTML: "四号" }, fontsize); //定义option对象四号,附属select
  1313. $$("option", { value: "16px", style: { fontSize: "14px" }, innerHTML: "小四" }, fontsize); //定义option对象小四,附属select
  1314. $$("option", { value: "14px", style: { fontSize: "14px" }, innerHTML: "五号" }, fontsize); //定义option对象五号,附属select
  1315. $$("option", { value: "12px", style: { fontSize: "14px" }, innerHTML: "小五" }, fontsize); //定义option对象小五,附属select
  1316. $$("option", { value: "10px", style: { fontSize: "14px" }, innerHTML: "10" }, fontsize); //定义option对象10px,附属select
  1317. $$("option", { value: "12px", style: { fontSize: "14px" }, innerHTML: "12" }, fontsize); //定义option对象12px,附属select
  1318. $$("option", { value: "14px", style: { fontSize: "14px" }, innerHTML: "14" }, fontsize); //定义option对象14px,附属select
  1319. $$("option", { value: "16px", style: { fontSize: "14px" }, innerHTML: "16" }, fontsize); //定义option对象16px,附属select
  1320. $$("option", { value: "18px", style: { fontSize: "14px" }, innerHTML: "18" }, fontsize); //定义option对象18px,附属select
  1321. $$("option", { value: "20px", style: { fontSize: "14px" }, innerHTML: "20" }, fontsize); //定义option对象20px,附属select
  1322. $$("option", { value: "22px", style: { fontSize: "14px" }, innerHTML: "22" }, fontsize); //定义option对象22px,附属select
  1323. $$("option", { value: "24px", style: { fontSize: "14px" }, innerHTML: "24" }, fontsize); //定义option对象24px,附属select
  1324. $$("option", { value: "26px", style: { fontSize: "14px" }, innerHTML: "26" }, fontsize); //定义option对象26px,附属select
  1325. $$("option", { value: "28px", style: { fontSize: "14px" }, innerHTML: "28" }, fontsize); //定义option对象28px,附属select
  1326. $$("option", { value: "36px", style: { fontSize: "14px" }, innerHTML: "36" }, fontsize); //定义option对象36px,附属select
  1327. $$("option", { value: "42px", style: { fontSize: "14px" }, innerHTML: "42" }, fontsize); //定义option对象42px,附属select
  1328. $$("option", { value: "48px", style: { fontSize: "14px" }, innerHTML: "48" }, fontsize); //定义option对象48px,附属select
  1329. $$("option", { value: "72px", style: { fontSize: "14px" }, innerHTML: "72" }, fontsize); //定义option对象72px,附属select
  1330. return fontsize; //返回select对象
  1331. };
  1332. ///<jscompress sourcefile="Dialog.js" />
  1333. //#region alert弹窗代码、confirm对话框
  1334. //UI窗体区域
  1335. Namespace.register("U.UF.UI") //窗体的命名空间
  1336. //#region 对话框
  1337. /**
  1338. * 创建对话框
  1339. * @content {string/elemnet} 内容
  1340. * @determineFun {function} 确认回调函数
  1341. * @cancelFun {function} 取消回调函数
  1342. */
  1343. U.UF.UI.Confirm = U.UF.UI.confirm = function (content, determineFun, cancelFun) {
  1344. //创建对话框主体元素
  1345. var _confirm = $$("div", { "style": { "cssText": "width: 100%; background: rgb(255,255,255);overflow:hidden; "} });
  1346. //创建内容区域
  1347. var _content = $$("div", { "style": { "cssText": "width: 100%;"} }, _confirm);
  1348. //判断内容是否为元素
  1349. if (U.UF.C.isElement(content)) {
  1350. //如果为元素则动态添加到对话框中
  1351. U.selectEl(_content).append(content);
  1352. } else {
  1353. _content.style.cssText = "text-align: center; margin: 10px;";
  1354. //如果为文字则修改inerHTML。
  1355. _content.innerHTML = content || '内容';
  1356. }
  1357. //创建页脚部分
  1358. var _footer = $$("div", { "style": { "cssText": "height:28px; margin:14px 0;"} }, _confirm);
  1359. //创建确定按钮 绑定点击事件,默认点击后执行关闭窗体函数
  1360. $$("div", {
  1361. "style": {
  1362. "cssText": "text-align: center; color: rgb(255,255,255); width: 92px; line-height:28px; background: rgb(48,126,208); border-radius: 5px;float: right; margin-right:29px; "
  1363. },
  1364. innerHTML: "确定",
  1365. onclick: function () {
  1366. var _bool = true;
  1367. if (U.UF.C.isFunction(determineFun)) {
  1368. _bool = determineFun(); //判断是否存在回调 有则执行。
  1369. }
  1370. if (_bool !== false) {
  1371. U.UF.F.closeWindow(_form.form); //关闭窗口函数
  1372. }
  1373. }
  1374. }, _footer);
  1375. //创建取消按钮 绑定点击事件,默认点击后执行关闭窗体函数
  1376. $$("div", {
  1377. "style": {
  1378. "cssText": "text-align: center; color: rgb(255,255,255); width: 92px; line-height:28px; background: rgb(48,126,208); border-radius: 5px;background: rgb(170,170,170); float: right; margin-right:21px;margin-left:29px;"
  1379. },
  1380. "innerHTML": "取消",
  1381. "onclick": function () {
  1382. U.UF.C.isFunction(cancelFun) && cancelFun(); //判断是否存在回调 有则执行。
  1383. U.UF.F.closeWindow(_form.form); //关闭窗口函数
  1384. }
  1385. }, _footer);
  1386. //调用Uform窗体创建函数将主体内容添加到窗体中
  1387. var _form = new U.UF.UI.form(
  1388. "提示",
  1389. _confirm,
  1390. {
  1391. "style": {
  1392. "cssText": "font-size: 14px; background: rgb(255,255,255); width: 310px; position: fixed; box-shadow: 0 0 10px 3px rgb(0,0,0); border-radius: 5px;"
  1393. }
  1394. },
  1395. {
  1396. "istop": true,
  1397. "isenlarge": false,
  1398. "isstretching": false,
  1399. "isnarrow": false
  1400. },
  1401. {
  1402. "style": {
  1403. "cssText": " background: rgb(59,88,120); padding: 5px; color: rgb(255,255,255); "
  1404. }
  1405. });
  1406. return _form;
  1407. }
  1408. /**
  1409. * 创建提示框
  1410. * @content {string/elemnet} 内容
  1411. * @callBackFun {function} 回调函数
  1412. */
  1413. U.UF.UI.Dialog = U.UF.UI.Dialog = function (content, callBackFun) {
  1414. var _dialog = $$("div", { "style": { "cssText": "width: 100%; background: #fff; overflow:hidden; "} }); //创建提示框主体
  1415. var _content = $$("div", { "style": { "cssText": "text-align: center; margin: 30px 20px 30px 20px; "} }, _dialog); //创建内容区域
  1416. //判断内容是否为元素
  1417. if (U.UF.C.isElement(content)) {
  1418. U.selectEl(_content).append(content); //如果为元素则动态添加到对话框中
  1419. } else {
  1420. _content.innerHTML = content || '内容'; //如果为文字则修改inerHTML。
  1421. }
  1422. //创建页脚部分
  1423. var footer = $$("div", { "style": { "cssText": "height:45px;"} }, _dialog);
  1424. //调用Uform窗体创建函数将主体内容添加到窗体中
  1425. var _form = new U.UF.UI.form("提示框", _dialog,
  1426. {
  1427. "style": {
  1428. "cssText": "font-size: 14px; width: 300px; background:#fff; position: fixed; top: 100px; left: 40%; box-shadow: 0 0 10px 3px black; border-radius: 5px;"
  1429. }
  1430. },
  1431. null,
  1432. {
  1433. "style": { "cssText": "background: #3b5878; padding: 10px; color:#fff;" }
  1434. });
  1435. //创建确定按钮 并绑定点击函数,默认点击后执行关闭窗体函数
  1436. $$("div", {
  1437. "style": {
  1438. "cssText": "text-align: center; color: #fff; width: 30%; padding: 5px; background: #307ed0; border-radius: 5px;float: right; margin: 0 12px 12px 0;"
  1439. },
  1440. innerHTML: "确定", // 绑定innerHTML
  1441. onclick: function () {
  1442. U.UF.C.isFunction(callBackFun) && callBackFun(); //判断是否存在回调 有则执行。
  1443. U.UF.F.closeWindow(_form.form); //关闭窗口函数
  1444. }
  1445. }, footer);
  1446. }
  1447. //#endregion
  1448. //#region alert
  1449. /*
  1450. 创建点击确认对话框
  1451. */
  1452. U.UF.UI.alertClick = function (content, attr) {
  1453. //创建点击确认对话框的主体区域
  1454. var _content = $$("div", { "class": "USBalert_text", "style": { width: "100%"} });
  1455. //判断内容是否为元素
  1456. if (U.UF.C.isElement(content)) {
  1457. //如果为元素则动态添加到对话框中
  1458. U.selectEl(_content).append(content);
  1459. }
  1460. else {
  1461. $$("div", { "style": { cssText: "text-align:center;padding:10px; margin:10px auto; word-break:break-word;" }, innerHTML: content || '内容' }, _content);
  1462. }
  1463. //创建页脚
  1464. var _footer = $$("div", { "class": "USBalert_onclicks", style: { height: "43px"} }, _content);
  1465. //调用Uform窗体创建函数将主体内容添加到窗体中
  1466. var _form = new U.UF.UI.form("提示框", _content,
  1467. {
  1468. "style": {
  1469. "cssText": "font-size: 16px; width:320px; background: rgb(255,255,255);box-shadow: 0 0 10px 3px rgb(0,0,0); border-radius: 5px;"
  1470. }
  1471. },
  1472. {
  1473. "isnarrow": false,
  1474. "isenlarge": false,
  1475. isstretching: false
  1476. },
  1477. {
  1478. "style": {
  1479. "cssText": "background: rgb(59,88,120); padding: 10px; color: rgb(255,255,255);"
  1480. }
  1481. });
  1482. //创建确定按钮 并绑定点击函数,默认点击后执行关闭窗体函数
  1483. $$("div", { "style": { "cssText": "text-align: center; color: #fff; width: 30%;max-width:150px; padding: 5px; background: #307ed0; border-radius: 5px;float: right; margin: 0 12px 12px 0;" }, innerHTML: "确定", onclick: function () { U.UF.F.closeWindow(_form.form); } }, _footer);
  1484. }
  1485. /**
  1486. * 创建对话框
  1487. */
  1488. U.Alert = U.alert = function (c, t) {
  1489. !t ? t = 3000 : "";
  1490. var bg = $$("div", {
  1491. "style": {
  1492. "cssText": "padding: 12px 25px 12px 25px;font-size: 16px;max-width:300px;min-width:100px;color: rgba(255,255,255,1);background: rgba(0,0,0,0.75);border-radius: 10px;position: fixed;top:20%;left:0px;right:0px;margin:0px auto;text-align:center; word-break: break-word; "
  1493. //white-space: nowrap; -o-text-overflow: ellipsis; text-overflow: ellipsis;
  1494. },
  1495. innerHTML: c
  1496. }, document.body);
  1497. U.UF.F.topWindow(bg);
  1498. setTimeout(function () {
  1499. bg.parentNode.removeChild(bg);
  1500. }, t);
  1501. }
  1502. //#endregion
  1503. //#endregion
  1504. ;
  1505. ///<jscompress sourcefile="Email.js" />
  1506. //电脑端banner滑块控件命名空间
  1507. Namespace.register("U.MD.UI.email");
  1508. /**
  1509. 电脑端banner滑块控件
  1510. */
  1511. U.MD.UI.email = function () {
  1512. };
  1513. ///<jscompress sourcefile="Face.js" />
  1514. //PC端表情包
  1515. Namespace.register("U.MD.UI.face");
  1516. /*
  1517. ** 添加表情包
  1518. ** @param {element} button 插入表情包的元素
  1519. ** @param {element} el 输入框的元素
  1520. */
  1521. U.MD.UI.face = function (button, el) {
  1522. var i, _el1, _el2;
  1523. if ($("#U_MD_UI_face")[0]) {//判断是否存在表情包
  1524. if ($("#U_MD_UI_face")[0].style.display == "none") {//如果存在,判断是否隐藏
  1525. U.selectEl("#U_MD_UI_face")[0].style.display = "block"; //如果隐藏 则显示表情包
  1526. } else {
  1527. U.selectEl("#U_MD_UI_face")[0].style.display = "none"; //否则,隐藏
  1528. }
  1529. } else {//不存在表情包,创建表情包
  1530. var _el = $$("div", { "style": { "position": "relative"} }, U.selectEl(button)[0]); //创建表情包的总样式
  1531. _el1 = $$("div", { "id": "U_MD_UI_face", "className": "U_MD_UI_face", "onmousedown": U.UF.EV.stopBubble }, _el); //创建表情包的阻止冒泡事件
  1532. _el2 = $$("div", { "className": "U_MD_UI_face_H" }, _el1); //创建存放表情的父级元素
  1533. for (i = 0; i <= 104; i++) {//循环打印所有的表情包 共104个
  1534. $$("button", {
  1535. "className": "U_MD_UI_face_C", "style": { "opacity": "0" }, "onclick": U.UF.C.closure(function (i) {
  1536. U.UF.EV.stopBubble();
  1537. U.MD.UI.face.printEmoticon(_el1, i, U.UF.E.getRangeAt(), el)
  1538. }, [i])
  1539. }, _el2); //创建单个表情,并且给每个表情赋值一个点击事件,参数为表情框元素,第几个表情,光标位置,输入框的位置,点击后打印表情到输入框的位置
  1540. }
  1541. //获取整个body部分的点击事件
  1542. U.selectEl('body').unbind('click', U.MD.UI.face.externalClick);
  1543. U.selectEl('body').bind('click', U.MD.UI.face.externalClick);
  1544. }
  1545. el.focus();
  1546. };
  1547. U.MD.UI.face.externalClick = function (e) {
  1548. if (window.event.srcElement.tagName != "BUTTON" && U.selectEl("#U_MD_UI_face")[0]) {//判断点击的是否是发送表情的按钮
  1549. U.selectEl("#U_MD_UI_face")[0].style.display = "none"; //如果不是,则隐藏掉表情包
  1550. }
  1551. }
  1552. /* 点击表情框处理
  1553. *
  1554. * @param {element} el1 表情框元素
  1555. * @param {number} i 第几个表情。通过i的值代表是哪个表情
  1556. * @param {range} range 光标的位置,先获取光标对象,然后通过光标对象获取光标位置
  1557. * @param {element}
  1558. 对应路径 /img/ChatingFaceGif/[face](i).gif
  1559. */
  1560. U.MD.UI.face.printEmoticon = function (el1, i, range, el) {
  1561. var _imageurl = "/img/ChatingFaceGif/[face](" + i + ").gif"; //表情路径
  1562. if (!range) {
  1563. $$("img", { "onerror": U.MD.C.imgError, "src": _imageurl, "contentEditable": "true" }, U.selectEl(el)[0]);
  1564. } else {
  1565. var img = '<img contentEditable="true" src="' + _imageurl + '">';
  1566. U.UF.E.addRange(img, null, true);
  1567. }
  1568. U.selectEl(el1)[0].style.display = "none";
  1569. }
  1570. ;
  1571. ///<jscompress sourcefile="Form.js" />
  1572. //#region 窗体
  1573. //UI窗体区域
  1574. Namespace.register("U.UF.UI") //窗体的命名空间
  1575. //#region 窗体
  1576. /** 初始化uform窗体,创建一个窗体,调用方式如下
  1577. * new new U.UF.UI.form(
  1578. * "测试内容",
  1579. * "中间内容",
  1580. * { "style": { "width": "570px", "height": "80%", "maxHeight": "700px"} },
  1581. * );
  1582. * @param string 头部标题 必填
  1583. * @param string|element 中间区域的内容 必填
  1584. * @param object 窗体的属性 {id :"1", style:{"width":"100px", "height":"100px"}} 选填 有默认的属性,原函数有注释
  1585. * @param object 窗体功能的属性 { istop: true, isdrag: true, isstretching:true,isenlarge:true,isnarrow:true,isclose:true } 选填
  1586. * @param object 头部的属性 {style:{"width":"100px"}} 选填 有默认的属性,原函数有注释
  1587. * @param object 内容的属性 { style:{"height":"100px"}} 选填 有默认属性,原函数有注释
  1588. * @param object 关闭、放大、缩小按钮区域的属性设置 { "style":{"left":"100px"}} 选填,有默认属性,原函数有注释
  1589. * @param element 窗体追加到制定的元素 选填 有默认的属性,原函数有注释
  1590. */
  1591. U.UF.UI.form = function (title, content, formattr, formfun, headattr, contentattr, headbottomattr, parentel) {
  1592. var _this = this;
  1593. //所有的窗体中找到是否已经创建的窗体
  1594. if (formattr && U.UF.UI.form.allForm[formattr.id]) {
  1595. var _this = U.UF.UI.form.allForm[formattr.id]; //得到原来的窗体
  1596. }
  1597. //初始化未赋值,用到的变量
  1598. else {
  1599. //设置窗体唯一的识别
  1600. this.id = formattr && formattr.id ? formattr.id : Guid.newGuid();
  1601. //初始化成功后添加到所有窗体管理的对象中,以便于用户查找窗体和管理
  1602. U.UF.UI.form.allForm[this.id] = this;
  1603. }
  1604. _this.form; //窗体
  1605. _this.header; //头部
  1606. _this.middle; //中间区域
  1607. _this.title = title; //窗体的标题
  1608. _this.content = content; //需要插入的元素,包含div和iframe等元素,以前站外应用的功能是靠这个方式去实现的
  1609. _this.formattr = formattr; //窗体的属性
  1610. _this.headattr = headattr; //头部的属性
  1611. _this.contentattr = contentattr; //内容的属性
  1612. _this.headbottomattr = headbottomattr; //头部功能区域整体的属性设置
  1613. //下面是用户功能处理包含是否允许一直置顶、是否允许拖动、是否拉伸、是否允许放大、是否允许缩小、是否允许关闭
  1614. //如果用户没有传入功能处理
  1615. if (formfun == null) {
  1616. formfun = {}; //初始化一个功能处理类
  1617. }
  1618. _this.istop = null;
  1619. if (formfun.istop != null) {//是否允许一直置顶
  1620. _this.istop = formfun.istop;
  1621. }
  1622. _this.isdrag = true;
  1623. if (formfun.isdrag != null) { //是否允许拖动
  1624. _this.isdrag = formfun.isdrag; //是否允许拖动
  1625. }
  1626. _this.isstretching = true;
  1627. if (formfun.isstretching != null) {//是否拉伸
  1628. _this.isstretching = formfun.isstretching;
  1629. }
  1630. _this.isenlarge = true;
  1631. if (formfun.isenlarge != null) { //是否允许放大
  1632. _this.isenlarge = formfun.isenlarge;
  1633. }
  1634. _this.isnarrow = true;
  1635. if (formfun.isnarrow != null) {//是否允许缩小
  1636. _this.isnarrow = formfun.isnarrow; //是否允许缩小
  1637. }
  1638. _this.isclose = true;
  1639. _this.closecallback = formfun.closecallback; //关闭回调
  1640. if (formfun.isclose != null) {//是否允许关闭
  1641. _this.isclose = formfun.isclose; //是否允许关闭
  1642. }
  1643. _this.parentel = parentel || document.body; //窗体添加到制定的元素处理
  1644. _this.create(); //重新添加处理
  1645. return _this; //返回处理
  1646. }
  1647. //所有给给创建的窗体管理
  1648. U.UF.UI.form.allForm = {};
  1649. //窗体的方法
  1650. U.UF.UI.form.prototype = {
  1651. /** 初始化uform窗体
  1652. */
  1653. create: function () {
  1654. var i, //用于循环
  1655. _resizefun,
  1656. _formel, //窗体元素
  1657. _headel, //窗体头部元素
  1658. _contentel, //内容区域的元素
  1659. _contentchildel, //内容区域的
  1660. _stretchingel, //拉伸元素
  1661. _stretchinginfo, //拉伸的信息
  1662. _headbottom, //头部按钮区域
  1663. _enlargeel, //放大按钮
  1664. _mousedown, //
  1665. _formattr = this.formattr || {}, //窗体属性
  1666. _headattr = this.headattr || {}, //头部属性
  1667. _contentattr = this.contentattr || {}, //内容的属性
  1668. _replaceel = U.UF.UI.form.allForm[_formattr.id] ? U.UF.UI.form.allForm[_formattr.id].form : null //得到之前创建的窗体,如果窗体存在,那么下面创建后直接替换
  1669. ;
  1670. //窗体的统一属性设置,默认属性
  1671. if (_formattr.style) {
  1672. _formattr.style.cssText = _formattr.style.cssText || "";
  1673. _formattr.style.cssText = "width: 70%; position: fixed; border: 1px solid #444; background-color: #fff; z-index: 10; border-radius: 1px; overflow: hidden; -moz-box-shadow:0 0 30px 5px #555; -webkit-box-shadow:0 0 30px 5px #555; box-shadow:0 0 30px 5px #555; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius:5px;" + _formattr.style.cssText;
  1674. }
  1675. else {
  1676. _formattr.style = {
  1677. cssText: "width: 70%; position: fixed; border: 1px solid #444; background-color: #fff; z-index: 10; border-radius: 1px; overflow: hidden; -moz-box-shadow:0 0 30px 5px #555; -webkit-box-shadow:0 0 30px 5px #555; box-shadow:0 0 30px 5px #555; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius:5px;"
  1678. };
  1679. }
  1680. _formattr.close = U.UF.C.apply(this, function () { //关闭窗体;
  1681. U.UF.F.closeWindow(this.form); //关闭窗体
  1682. });
  1683. _formattr.usform = "true"; //设置窗体的属性,作为窗体的识别,有助于调用的用户通过js找到所有的窗体
  1684. _formattr.id = _formattr.id || ""; //窗体的id
  1685. _formattr.style = _formattr.style || {}; //窗体的样式
  1686. if (_formattr.onresize) {
  1687. _resizefun = _formattr.onresize;
  1688. _mousedown = _formattr.onmousedown;
  1689. _formattr.onresize = U.UF.C.apply(this, function () { //当窗体大小发生变化的处理
  1690. this.size(); //大小变化处理
  1691. if (_resizefun) {
  1692. _resizefun(); //大小变化回调
  1693. }
  1694. });
  1695. _formattr.onmousedown = U.UF.C.apply(this, function () {
  1696. //窗体点击置顶的处理
  1697. if (this.istop !== false) {
  1698. this.top(); //大小变化处理
  1699. }
  1700. if (_mousedown) {
  1701. _mousedown(); //大小变化回调
  1702. }
  1703. });
  1704. }
  1705. else if (_formattr.onresize !== false) {
  1706. _formattr.onresize = U.UF.C.apply(this, function () { //当窗体大小发生变化的处理
  1707. this.size(); //大小变化处理
  1708. });
  1709. }
  1710. //创建大窗体,设置窗体属性
  1711. var _formel = $$("div", this.formattr);
  1712. //判断是否允许一直置顶
  1713. if (this.istop === true) {
  1714. _formel.style.zIndex = "9999";
  1715. _formel["__top__"] = "false"; //设置不允许点击切换置顶
  1716. }
  1717. else if (this.istop === false) {
  1718. _formel["__top__"] = "false"; //设置不允许点击切换置顶
  1719. }
  1720. this.form = _formel; //窗体全局变量设置
  1721. //如果用户设置了false,那么就不加载头部
  1722. if (this.title !== false) {
  1723. //窗体头部属性统一设置
  1724. if (_headattr.style) {
  1725. _headattr.style.cssText = _headattr.style.cssText || "";
  1726. _headattr.style.cssText = "text-indent: 10px; color: White; line-height: inherit; font-size: 14px; height: 30px; line-height: 30px; background-color: #2967A7; overflow: hidden; color: White; font-size: 14px; overflow: hidden; " + _headattr.style.cssText;
  1727. }
  1728. else {
  1729. _headattr.style = {
  1730. cssText: "text-indent: 10px; color: White; line-height: inherit; font-size: 14px; height: 30px; line-height: 30px; background-color: #2967A7; overflow: hidden; color: White; font-size: 14px; overflow: hidden; "
  1731. }
  1732. }
  1733. //设置头部有拖拽事件
  1734. if (this.isdrag) { //判断是否允许拖动窗体
  1735. _headattr.onmousedown = function () {
  1736. U.UF.F.drag(_formel); //拖动事件调用
  1737. };
  1738. }
  1739. //创建头部区域
  1740. _headel = $$("div", _headattr, _formel);
  1741. //如果是字符串的处理
  1742. if (U.UF.C.isString(this.title)) {
  1743. _headel.innerHTML = this.title;
  1744. }
  1745. //如果中间区域是元素的处理
  1746. else if (U.UF.C.isElement(this.title)) {
  1747. _headel.appendChild(this.title); //添加所选元素
  1748. }
  1749. this.header = _headel; //设置中间的全局变量
  1750. }
  1751. //创建中间
  1752. _contentel = $$("div", { "style": { "cssText": "width: 100%; height:100%; position: relative;"} }, _formel);
  1753. //中间的内容
  1754. _contentattr.usbody = "true";
  1755. //窗体头部属性统一设置
  1756. if (_contentattr.style) {
  1757. _contentattr.style.cssText = _contentattr.style.cssText || "";
  1758. //_contentattr.style.cssText = "text-align: left; overflow: auto;" + _contentattr.style.cssText;
  1759. _contentattr.style.cssText = "text-align: left; overflow: hidden;" + _contentattr.style.cssText;
  1760. }
  1761. else {
  1762. _contentattr.style = {
  1763. cssText: "text-align: left; overflow: auto;"
  1764. };
  1765. }
  1766. //创建中间内容元素
  1767. _contentchildel = $$("div", _contentattr, _contentel);
  1768. //如果是字符串的处理
  1769. if (U.UF.C.isString(this.content)) {
  1770. _contentchildel.innerHTML = this.content;
  1771. }
  1772. //如果中间区域是元素的处理
  1773. else if (U.UF.C.isElement(this.content)) {
  1774. _contentchildel.appendChild(this.content); //添加所选元素
  1775. }
  1776. this.middle = _contentchildel; //中间的内容
  1777. //在头部不存在的情况下,设置中间内容可以拖动
  1778. if (this.title === false && this.isdrag) {
  1779. _contentel.onmousedown = function () {
  1780. U.UF.F.drag(_formel); //拖动事件调用
  1781. };
  1782. }
  1783. //设置拉伸处理
  1784. if (this.isstretching !== false) {
  1785. //创建窗体拉伸
  1786. _stretchingel = $$("div", { style: { "cssText": "display: block;"} }, _formel);
  1787. //拉伸的信息 key代表样式的结尾,value代表拉伸的方向
  1788. _stretchinginfo = {
  1789. "top": "cursor: n-resize; left: 0px; top: 0px; width: 100%; height: 5px;",
  1790. "rightTop": "cursor: ne-resize; right: -2px; top: -2px; width: 12px; height: 12px;",
  1791. "leftTop": "cursor: nw-resize; top: 0px; left: 0px; width: 12px; height: 12px;",
  1792. "left": "cursor: w-resize; left: 0px; top: 0px; width: 5px; height: 100%;",
  1793. "right": "cursor: e-resize; right: 0px; top: 0px; width: 5px; height: 100%;",
  1794. "bottom": "cursor: s-resize; left: 0px; bottom: 0px; width: 100%; height: 5px;",
  1795. "leftBottom": "cursor: sw-resize; left: -2px; bottom: -2px; width: 12px; height: 12px;",
  1796. "rightBottom": "cursor: se-resize; right: -2px; bottom: -2px; width: 12px; height: 12px;"
  1797. }
  1798. //循环创建拉伸条,包含上、下、左、右、上左、下左、上右、下右
  1799. for (i in _stretchinginfo) {
  1800. $$("div", {
  1801. "style": {
  1802. "cssText": "position: absolute; overflow: hidden; display: block; z-index: 10;" + _stretchinginfo[i]
  1803. },
  1804. "onmousedown": U.UF.C.closure(function (scope, typename) {
  1805. //拉伸函数的调用
  1806. U.UF.F.stretching(_formel, typename, U.UF.C.apply(scope, scope.size));
  1807. }, [this, i])
  1808. }, _stretchingel);
  1809. }
  1810. }
  1811. //头部功能区域
  1812. if (this.title !== false) {
  1813. _headbottom = $$("div", {
  1814. "style": { "cssText": "position: absolute; top: 3px; right: 0px; width: 80px; display: table-cell; vertical-align: middle;" }
  1815. }, _formel);
  1816. }
  1817. if (this.isclose !== false) {
  1818. //关闭窗体的按钮
  1819. $$("div", {
  1820. "style": {
  1821. "cssText": "background-image:url(/img/close.png); _background-image:url(/img/close.png);width: 20px; height: 20px; background-position: -120px -61px; background-size: 100%; float: right; margin-right: 3px; cursor: pointer;"
  1822. },
  1823. "title": "点击关闭",
  1824. "onmousedown": U.UF.EV.stopBubble,
  1825. "onclick": U.UF.C.apply(this, function () {
  1826. U.UF.F.closeWindow(this.form); //调用窗体关闭函数
  1827. try {
  1828. //关闭任务栏处理
  1829. if (U.MD.D.T.taskbar.close) {
  1830. U.MD.D.T.taskbar.close({ "forms": _formel });
  1831. U.MD.N.urlWrite("", "可可乐博信息化桌面");
  1832. }
  1833. }
  1834. catch (e) {
  1835. }
  1836. //回调处理
  1837. if (U.UF.C.isFunction(this.closecallback)) {
  1838. this.closecallback();
  1839. }
  1840. })
  1841. }, _headbottom);
  1842. }
  1843. //是否允许放大
  1844. if (this.isenlarge !== false) {
  1845. //放大按钮
  1846. _enlargeel = $$("div", {
  1847. "style": {
  1848. "cssText": "background-image:url(/img/max.png); _background-image:url(/img/max.png);background-position: -598px -240px; background-size: 100%; float: right; margin-right: 7px; width: 20px; height: 20px; cursor: pointer;"
  1849. },
  1850. "title": "最大化",
  1851. "onmousedown": U.UF.EV.stopBubble,
  1852. //最大化点击事件处理
  1853. "onclick": function () {
  1854. U.UF.F.windowZooming(_formel); //调用窗体最大化函数
  1855. }
  1856. }, _headbottom);
  1857. //如果有head头部的处理
  1858. if (_headel) {
  1859. //头部双击放大缩小处理处理
  1860. _headel.ondblclick = U.UF.C.apply(_headel, function () {
  1861. //判断双击的元素是否在头部导航上,否则如果头部上有其他的按钮什么的双击了,也会触发放大方法
  1862. if (event.srcElement == this || U.UF.EL.isChild(this, event.srcElement)) {
  1863. _enlargeel.onclick(); //放大的处理
  1864. }
  1865. });
  1866. }
  1867. }
  1868. //是否允许最小化
  1869. if (this.isnarrow !== false) {
  1870. //最小化的按钮处理
  1871. $$("div", {
  1872. "style": {
  1873. "cssText": "background-image:url(/img/min.png); _background-image:url(/img/min.png);background-position: -617px -240px; background-size: 100%; float: right; margin-right: 10px; width: 20px; height: 20px; cursor: pointer;"
  1874. },
  1875. "title": "最小化",
  1876. "onmousedown": U.UF.EV.stopBubble,
  1877. "onclick": function () {
  1878. U.UF.F.windowMinimize(_formel); //窗体最小化处理
  1879. }
  1880. }, _headbottom);
  1881. }
  1882. //如果窗体已经创建,那么直接替换
  1883. if (_replaceel && _replaceel.parentNode != null) {
  1884. _replaceel.parentNode.replaceChild(_formel, _replaceel);
  1885. }
  1886. //元素添加到制定的元素中
  1887. else {
  1888. this.parentel.appendChild(_formel);
  1889. }
  1890. //如果没有设置top和left那么居中弹出
  1891. if (_formel.style.top == "" && _formel.style.left == "" && _formel.style.right == "" && _formel.style.bottom == "") {
  1892. //居中置顶弹出
  1893. U.UF.F.windowTopCenter(_formel);
  1894. }
  1895. //否则置顶
  1896. else {
  1897. U.UF.F.topWindow(_formel);
  1898. }
  1899. //初始化的时候默认设置大小
  1900. this.size();
  1901. },
  1902. /** 窗体每一次点击置顶
  1903. */
  1904. top: function () {
  1905. U.UF.F.topWindow(this.form); //点击置顶的处理
  1906. },
  1907. /** 窗体大小处理
  1908. */
  1909. size: function () {
  1910. var _headheight = 0; //head头部的高度
  1911. //如果存在head头部,那么获取head头部处理
  1912. if (this.header) {
  1913. _headheight = this.header.clientHeight;
  1914. }
  1915. //设置窗体content区域大小设置
  1916. if (this.header) {
  1917. this.middle.style.height = this.form.clientHeight - this.header.clientHeight + "px";
  1918. } else {
  1919. this.middle.style.height = this.form.clientHeight + "px";
  1920. }
  1921. }
  1922. }
  1923. /** 窗体大小处理
  1924. */
  1925. U.UF.UI.form.windowResize = function () {
  1926. var i,
  1927. _style,
  1928. _bodywidth = US.width, //获取原本在窗体大小没有变化前的width
  1929. _bodyheight = US.height, //获取原本在窗体大小没有变化前的height
  1930. _sizeinfo, //大小信息
  1931. _width, //长度
  1932. _height, //高度
  1933. _formel, //窗体元素
  1934. _forms = U.UF.UI.form.allForm //获取所有的窗体
  1935. ;
  1936. //循环所有的窗体
  1937. for (i in _forms) {
  1938. _formel = _forms[i].form; //获取窗体的处理
  1939. if ($(_formel).css("display") != "none") { //判断窗体是否隐藏
  1940. _style = {}; //设置位置
  1941. _width = U.selectEl(_formel).css("width"); //获取窗体的长
  1942. _height = U.selectEl(_formel).css("height"); //获取窗体的宽
  1943. //计算位置,如果有百分比,则按照百分比的方式进行计算,否则,得到百分比。
  1944. _width = _width.indexOf("%") > -1 ? _width.toInt() / 100 : _formel.offsetWidth / _bodywidth;
  1945. _height = _height.indexOf("%") > -1 ? _height.toInt() / 100 : _formel.offsetWidth / _bodyheight;
  1946. //设置位置,如果没有右对齐,则设置左对齐
  1947. if (_formel.style.right == "" || _formel.style.right == "auto") {
  1948. _style.left = _formel.offsetLeft + (document.body.offsetWidth - _bodywidth) * ((1 - _width) / 2) + "px";
  1949. }
  1950. //如果没有下对齐,则设置上对齐
  1951. if (_formel.style.bottom == "" || _formel.style.bottom == "auto") {
  1952. _style.top = _formel.offsetTop + (document.body.offsetHeight - _bodyheight) * ((1 - _height) / 2) + "px";
  1953. }
  1954. //设置值
  1955. U.selectEl(_formel).addAttrArray({ "style": _style });
  1956. }
  1957. }
  1958. }
  1959. /** 关闭所有的窗体
  1960. */
  1961. U.UF.UI.form.closeWindows = function () {
  1962. var i;
  1963. for (i in U.UF.UI.form.allForm) {
  1964. if (U.UF.UI.form.allForm[i].isclose) {
  1965. U.UF.UI.form.allForm[i].form.close();
  1966. }
  1967. }
  1968. }
  1969. //#endregion
  1970. //#endregion;
  1971. ///<jscompress sourcefile="Music.js" />
  1972. Namespace.register("U.MD.UI.music");
  1973. /**
  1974. * [Control description] 音乐控件总函数
  1975. * @param {[type]} musicList [数组json 格式请看文档]
  1976. * @param {[type]} index [需要播放第几首歌(索引)]
  1977. * @param {[type]} autoplay [是否自动播放] 可填可不填 默认 false
  1978. * @param {[type]} parentEl 所需要添加到的父元素 可填可不填 默认document.body
  1979. */
  1980. U.MD.UI.music = function (musicList, index, autoplay, parentEl) {
  1981. var _music = U.MD.UI.music; //简写命名空间
  1982. var _musicBox;
  1983. if (_musicBox = U.selectEl("#U_MD_UI_music_musicBox")[0]) {
  1984. // U.selectEl(_musicBox).removeClass('U_MD_UI_music_hidden');
  1985. // var _attr = _music.Attr; //简写全局属性json名
  1986. // var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  1987. // _attr.musicList = musicList; //全局赋值
  1988. // _attr.musicIndex = index; //全局赋值
  1989. // _audio[0].src = musicList[index].src; //添加音乐路径
  1990. // var _Name = U.selectEl("#U_MD_UI_music_Name"); //音乐名字节点
  1991. // _Name[0].innerText = musicList[index].title; //音乐名字赋值
  1992. _musicBox.remove();
  1993. }
  1994. _music.create(parentEl); //创建音乐控件
  1995. _music.Attr = { //存放全局属性
  1996. 'musicList': musicList, //所有数据
  1997. 'musicIndex': index, //当前数据索引
  1998. 'autoplay': autoplay, //第一首是否自动播放
  1999. 'currentTime': null, //音乐当前时间未赋值
  2000. 'endTime': null //音乐结束时间未赋值
  2001. };
  2002. _music.init(); //初始化函数
  2003. };
  2004. U.MD.UI.music.Attr = null; //存放元素与变量的json全局变量 未赋值
  2005. U.MD.UI.music.htmlTemplate = ' <div class="U_MD_UI_music_leftCont">\n' +
  2006. ' <div class="U_MD_UI_music_CoverBox">\n' +
  2007. ' <img src="/img/Controls/Audio/pc/电脑图标.png" alt="" id="U_MD_UI_music_Cover">\n' +
  2008. ' </div> <!-- 音乐封面图片 -->\n' +
  2009. ' </div>\n' +
  2010. ' <div class="U_MD_UI_music_rightCont">\n' +
  2011. ' <div class="U_MD_UI_music_Name" id="U_MD_UI_music_Name"></div> <!-- 音乐名字 -->\n' +
  2012. ' <div class="U_MD_UI_music_leftBtn" id="U_MD_UI_music_leftBtn"></div> <!-- 左按钮 -->\n' +
  2013. ' <div class="U_MD_UI_music_pauseBtn U_MD_UI_music_playBtn" id="U_MD_UI_music_playBtn"></div> <!-- 播放/暂停 按钮 -->\n' +
  2014. ' <div class="U_MD_UI_music_rightBtn" id="U_MD_UI_music_rightBtn"></div> <!-- 右按钮 -->\n' +
  2015. ' <div class="U_MD_UI_music_soundOpen" id="U_MD_UI_music_soundSwitch"></div> <!-- 声音开关按钮 -->\n' +
  2016. ' <div class="U_MD_UI_music_soundBox" id="U_MD_UI_music_soundBox"> <!-- 声音条盒子节点 -->\n' +
  2017. ' <div class="U_MD_UI_music_soundBar" id="U_MD_UI_music_soundBar" style="width: 31px;"></div> <!-- 声音条 -->\n' +
  2018. ' <div class="U_MD_UI_music_soundBall" id="U_MD_UI_music_soundBall" style="left: 31px;"></div> <!-- 声音球 -->\n' +
  2019. ' </div>\n' +
  2020. ' <div class="U_MD_UI_music_listBtn"></div> <!-- 右上角的列表按钮 -->\n' +
  2021. ' <div class="U_MD_UI_music_shrinkBtn" id="U_MD_UI_music_shrinkBtn"></div> <!-- 右上角的缩小按钮 -->\n' +
  2022. ' <div class="U_MD_UI_music_closeBtn" id="U_MD_UI_music_closeBtn"></div> <!-- 右上角的关闭按钮 -->\n' +
  2023. ' </div>\n' +
  2024. ' <div class="U_MD_UI_music_progressBox" id="U_MD_UI_music_progressBox"> <!-- 时间条盒子节点 -->\n' +
  2025. ' <div class="U_MD_UI_music_progressBar" id="U_MD_UI_music_progressBar" style="width: 0.64px;"></div> <!-- 时间条 -->\n' +
  2026. ' <div class="U_MD_UI_music_progressBall" id="U_MD_UI_music_progressBall" style="left: 0.64px;"></div> <!-- 时间球 -->\n' +
  2027. ' </div>\n' +
  2028. ' <audio id="U_MD_UI_music_audio" autoplay="" src=""></audio>';
  2029. /**
  2030. * 添加音乐控件html代码 并且判断是否存在html 防止多次添加
  2031. */
  2032. U.MD.UI.music.create = function (parentEl) {
  2033. var _parentEl = parentEl || document.body;
  2034. var _formclass = { "style": { "border": "none" }, "id": "U_MD_UI_music_musicBox", "className": "U_MD_UI_music_musicBox" };
  2035. var _formattr = { isclose: false, isstretching: false, isenlarge: false, isnarrow: false };
  2036. var _headclass = { "style": { "height": "13px", "background-color": "#cc5b5b"} };
  2037. U.MD.UI.music.player = new U.UF.UI.form(false, U.MD.UI.music.htmlTemplate, _formclass, _formattr, _headclass);
  2038. U.selectEl("#U_MD_UI_music_musicBox")[0].style.overflow = "";
  2039. // U.UF.F.windowMinimize(_formel);
  2040. };
  2041. /**
  2042. * 音乐控件初始化
  2043. */
  2044. U.MD.UI.music.init = function () {
  2045. var _music = U.MD.UI.music; //简写命名空间
  2046. var _attr = _music.Attr; //简写全局属性json名
  2047. var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  2048. var _musicList = _attr.musicList; //音乐列表数组
  2049. var _musicIndex = _attr.musicIndex; //需要播放的音乐(数组中的第index个)
  2050. _audio[0].src = _musicList[_musicIndex].src; //添加音乐路径
  2051. var _playBtn = U.selectEl("#U_MD_UI_music_playBtn"); //暂停播放按钮节点
  2052. var _Name = U.selectEl("#U_MD_UI_music_Name"); //音乐名字节点
  2053. var _corver = U.selectEl("#U_MD_UI_music_Cover"); //封面图片节点
  2054. if (!_attr.autoplay) { //若autoplay属性 = false 则第一首音乐暂停
  2055. _audio[0].pause();
  2056. }
  2057. _music.openBtnEvent(); //按钮点击开关 音乐控件隐藏
  2058. _music.shrinkBtnEvent(); //缩小事件绑定
  2059. _music.soundControl(); //声音控制器
  2060. _music.playEvent(); //音乐播放与暂停控制器
  2061. _music.switchMusic(); //切换音乐按钮
  2062. _music.progressControl(); //音乐进度条控制器*/
  2063. _audio.bind('durationchange', function () { //当音乐时长已改变时 给节点赋值
  2064. _attr.endTime = this.duration; //总时长赋值
  2065. _musicIndex = _attr.musicIndex; //音乐索引位置重赋值
  2066. _Name[0].innerText = _musicList[_musicIndex].title; //音乐名字赋值
  2067. });
  2068. _audio.bind("ended", function () { //音乐结束后切换下一首
  2069. _musicIndex = _attr.musicIndex; //由于_attr.musicIndex是一个变量 因此 需要重新赋值
  2070. var _listLength = _musicList.length - 1; //获取数组中音乐的长度
  2071. if (_musicIndex === _listLength) { //当音乐在数组中为最后一首时 下一首则为第一首 也就是索引 0
  2072. _attr.musicIndex = 0;
  2073. _musicIndex = _attr.musicIndex;
  2074. _audio[0].src = _musicList[_musicIndex].src;
  2075. } else { //否则则索引+1
  2076. _attr.musicIndex++;
  2077. _musicIndex = _attr.musicIndex;
  2078. _audio[0].src = _musicList[_musicIndex].src;
  2079. }
  2080. });
  2081. };
  2082. /**
  2083. * 关闭按钮点击事件
  2084. */
  2085. U.MD.UI.music.openBtnEvent = function () {
  2086. var _music = U.MD.UI.music; //简写命名空间
  2087. // var _attr = _music.Attr; //简写全局属性json名
  2088. // var _musicBox = U.selectEl("#U_MD_UI_music_musicBox"); //获取音乐控件盒子
  2089. // var _closeBtn = U.selectEl("#U_MD_UI_music_closeBtn"); //获取关闭按钮 在控件里 右上角的 叉叉
  2090. U.selectEl("#U_MD_UI_music_closeBtn").bind('click', function () {
  2091. var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  2092. if (!_audio[0].paused) {
  2093. U.selectEl("#U_MD_UI_music_playBtn").addClass('U_MD_UI_music_playBtn'); //暂停音乐并修改图标
  2094. _audio[0].pause();
  2095. }
  2096. U.UF.F.closeWindow(_music.player.form); //调用窗体关闭函数
  2097. U.selectEl('#U_MD_D_T_taskbar_music').remove();
  2098. // _musicBox.addClass("U_MD_UI_music_hidden"); //点击关闭按钮后 隐藏音乐控件
  2099. // _musicBox.addClass("U_MD_UI_music_hidden"); //点击关闭按钮后 隐藏音乐控件
  2100. });
  2101. };
  2102. /**
  2103. * 缩小按钮事件绑定
  2104. */
  2105. U.MD.UI.music.shrinkBtnEvent = function () {
  2106. U.selectEl('#U_MD_UI_music_shrinkBtn').bind('click', function () {
  2107. U.UF.F.windowMinimize(U.MD.UI.music.player.form); //窗体最小化处理
  2108. });
  2109. };
  2110. /**
  2111. * 播放/暂停 的点击事件
  2112. */
  2113. U.MD.UI.music.playEvent = function () {
  2114. var _music = U.MD.UI.music; //简写命名空间
  2115. var _attr = _music.Attr; //简写全局属性json名
  2116. var _playbtn = U.selectEl("#U_MD_UI_music_playBtn"); //暂停/播放 按钮
  2117. var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  2118. _playbtn.bind('click', function () {
  2119. if (!_audio[0].paused) { //如在 无暂停状态(播放状态)
  2120. _playbtn.addClass('U_MD_UI_music_playBtn'); //暂停音乐并修改图标
  2121. _audio[0].pause();
  2122. } else { //否则则时 暂停状态时
  2123. _playbtn.removeClass('U_MD_UI_music_playBtn');
  2124. _audio[0].play(); //播放音乐并修改图标
  2125. }
  2126. });
  2127. };
  2128. /**
  2129. * 音乐按钮切换(上一首 下一首)
  2130. */
  2131. U.MD.UI.music.switchMusic = function () {
  2132. var _music = U.MD.UI.music; //简写命名空间
  2133. var _attr = _music.Attr; //简写全局属性json名
  2134. var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  2135. var _rightBtn = U.selectEl("#U_MD_UI_music_rightBtn"); //获取下一首的按钮
  2136. var _leftBtn = U.selectEl("#U_MD_UI_music_leftBtn"); //获取上一首的按钮
  2137. var _musicList = _attr.musicList; //获取音乐数组数据
  2138. var _musicIndex = _attr.musicIndex; //获取当前需要播放音乐 的数组索引
  2139. var _listLength = _musicList.length - 1; //获取音乐的数量
  2140. _rightBtn.bind('click', function () { //当点击右边(下一首)的按钮时
  2141. _musicIndex = _attr.musicIndex; //由于_attr.musicIndex是一个变量 因此 需要重新赋值
  2142. if (_musicIndex === _listLength) { //如果当前的歌曲是最后一首时
  2143. _attr.musicIndex = 0; //则条转到第一首歌
  2144. _musicIndex = _attr.musicIndex; //给全局属性赋值
  2145. _audio[0].src = _musicList[_musicIndex].src; //并修改音乐路径
  2146. } else { //否则跳转到下一首歌
  2147. _attr.musicIndex++; //数组索引加1
  2148. _musicIndex = _attr.musicIndex; //给全局属性赋值
  2149. _audio[0].src = _musicList[_musicIndex].src; //并修改音乐路径
  2150. }
  2151. });
  2152. _leftBtn.bind('click', function () { //同上 此处是左按钮(上一首)
  2153. _musicIndex = _attr.musicIndex; //由于_attr.musicIndex是一个变量 因此 需要重新赋值
  2154. if (_musicIndex === 0) {
  2155. _attr.musicIndex = _listLength;
  2156. _musicIndex = _attr.musicIndex;
  2157. _audio[0].src = _musicList[_musicIndex].src;
  2158. } else {
  2159. _attr.musicIndex--;
  2160. _musicIndex = _attr.musicIndex;
  2161. _audio[0].src = _musicList[_musicIndex].src;
  2162. }
  2163. });
  2164. };
  2165. /**
  2166. * 声音事件控制 总函数
  2167. */
  2168. U.MD.UI.music.soundControl = function () {
  2169. var _music = U.MD.UI.music; //简写命名空间
  2170. var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  2171. var _soundBox = U.selectEl("#U_MD_UI_music_soundBox"); //声音盒子节点
  2172. var _soundBall = U.selectEl("#U_MD_UI_music_soundBall"); //音量球
  2173. var _soundBar = U.selectEl("#U_MD_UI_music_soundBar"); //声音条
  2174. var _boxWidth = _soundBox[0].clientWidth; //获取盒子宽度 = 声音球位置的最大值
  2175. var _volume = 0.5; //声音初始大小
  2176. var _soundSwitch = U.selectEl("#U_MD_UI_music_soundSwitch"); //声音开关图标
  2177. _audio[0].volume = _volume; //给audio标签添加声音
  2178. _soundBall[0].style.left = (_boxWidth * _volume) + "px"; //调整音量球位置 = 总宽度*百分比
  2179. _soundBar[0].style.width = (_boxWidth * _volume) + "px"; //调整声音条宽度 = 总宽度*百分比
  2180. _soundSwitch.bind('click', function () { //声音开关控制函数
  2181. _music.toggleClass(this, 'U_MD_UI_music_soundClose'); //每点击一次 切换样式
  2182. if ($(this).hasClass('U_MD_UI_music_soundClose')) { //判断如果样式为关闭时(静音状态)
  2183. this._volume = _audio[0].volume; //记录原有的声音值
  2184. this._soundBallX = parseFloat(_soundBall.css("left")); //获取音量球的 left值
  2185. this._soundBarW = parseFloat(_soundBar.css("width")); //获取音量条的 宽
  2186. _soundBall[0].style.left = 0; //音量球的left为0
  2187. _soundBar[0].style.width = 0; //音量条的宽为 0
  2188. _audio[0].volume = 0; //audio声音也为0
  2189. } else { //播放状态
  2190. if (!this._volume) { //如果this._volume不存在 则声音赋值时会报错
  2191. return;
  2192. }
  2193. _audio[0].volume = this._volume; //在点一遍开关后 复原到之前记录的值
  2194. _soundBall[0].style.left = this._soundBallX + "px"; //给音量球的left赋值
  2195. _soundBar[0].style.width = this._soundBarW + "px"; //给音量条的宽赋值
  2196. }
  2197. });
  2198. _soundBox.bind('mousedown', function (e) { //点击进度条后 音量球跳转到鼠标点击位置 并且声音跟随增大或减小
  2199. var _boxLeft = _music.getOffsetLeft(this); //body距离盒子左端的left值 = 声音球left的最小值
  2200. var _boxRight = _boxLeft + _boxWidth; //body距离盒子右端的left值 = 声音球left的最大值
  2201. var _mouseX = e.pageX; //获取鼠标按下时的X坐标
  2202. _mouseX = Math.max(_mouseX, _boxLeft); //mouseX 与 boxLeft距离不能小于0 因此 获取两数最大值 原因:声音不能小于0
  2203. _mouseX = Math.min(_mouseX, _boxRight); //mouseX 与 boxRight因此 获取两数最大值 原因:声音不能大于1
  2204. var _dis = _mouseX - _boxLeft; //鼠标划过的距离
  2205. _volume = Math.round(parseFloat(_dis / _boxWidth) * 100) / 100; //距离相对于盒子宽度的值 = 声音百分比大小(此处为保留两位小数点)
  2206. _soundBall[0].style.left = (_boxWidth * _volume) + "px"; //音量球left值 改变成 = 总宽*百分比
  2207. _soundBar[0].style.width = (_boxWidth * _volume) + "px"; //音量条width 改变成 = 总宽*百分比
  2208. _audio[0].volume = _volume; //改变audio标签值
  2209. if (_audio[0].volume <= 0) { //如果声音小于=0 时 则改变成 静音状态时的样式 否则则是非静音状态样式
  2210. _soundSwitch.addClass('U_MD_UI_music_soundClose');
  2211. } else {
  2212. _soundSwitch.removeClass('U_MD_UI_music_soundClose');
  2213. }
  2214. });
  2215. _soundBall.bind('mousedown', function (e) { //音量球拖拽效果
  2216. U.UF.EV.stopBubble(e); //阻止冒泡
  2217. var _oMouseX = e.pageX; //获取鼠标按下时的X坐标
  2218. var _soundDrapMove = function (e) { //拖拽时移动用的函数
  2219. U.UF.EV.stopDefault(e); //取消默认拖拽
  2220. var _mouseX = e.pageX; //鼠标移动时的x坐标
  2221. var _dis = _mouseX - _oMouseX + _oX; //移动的距离
  2222. _dis = Math.max(0, _dis); //限制音量球left不得小于0
  2223. _dis = Math.min(_boxWidth, _dis); //限制音量球left不得大于盒子宽度
  2224. _soundBall[0].style.left = _dis + "px"; //音量球位置
  2225. _soundBar[0].style.width = _dis + "px"; //音量条宽度
  2226. _volume = Math.round(parseFloat(_dis / _boxWidth) * 100) / 100; //声音球距离盒子宽度的left值 = 声音百分比大小(此处为保留两位小数点)
  2227. _audio[0].volume = _volume; //音乐的声音赋值
  2228. if (_audio[0].volume <= 0) { //判断声音小于0则改成静音图标
  2229. _soundSwitch.addClass('U_MD_UI_music_soundClose');
  2230. } else { //否则该成非静音图标
  2231. _soundSwitch.removeClass('U_MD_UI_music_soundClose');
  2232. }
  2233. };
  2234. var _soundDragUp = function () { //拖拽时松开用的函数
  2235. U.selectEl(document).unbind('mousemove', _soundDrapMove);
  2236. U.selectEl(document).unbind('mouseup', _soundDragUp);
  2237. };
  2238. var _oX = parseFloat(_soundBall.css("left")); //获取鼠标按下时音量球的坐标
  2239. U.selectEl(document).bind('mousemove', _soundDrapMove);
  2240. U.selectEl(document).bind('mouseup', _soundDragUp)
  2241. });
  2242. };
  2243. /**
  2244. * 进度条控制 事件总函数
  2245. */
  2246. U.MD.UI.music.progressControl = function () {
  2247. var _music = U.MD.UI.music; //简写命名空间
  2248. var _attr = _music.Attr; //简写全局属性json名
  2249. var _audio = U.selectEl("#U_MD_UI_music_audio"); //audio标签
  2250. var _progressBox = U.selectEl("#U_MD_UI_music_progressBox"); //时间盒子节点
  2251. var _progressBall = U.selectEl("#U_MD_UI_music_progressBall"); //时间球
  2252. var _progressBar = U.selectEl("#U_MD_UI_music_progressBar"); //时间条
  2253. var _playbtn = U.selectEl("#U_MD_UI_music_playBtn"); //播放/暂停 按钮
  2254. var _boxWidth = _progressBox[0].clientWidth; //时间盒子宽度 = 时间球位置的最大值
  2255. var _barFlag = true, _currentTime; //声明两个全局变量 为更新时间条所用
  2256. _audio.bind('timeupdate', function () {
  2257. if (!this.paused) { //如在 无暂停状态(播放状态)
  2258. _playbtn.removeClass('U_MD_UI_music_playBtn'); //修改成 播放时用的图标
  2259. } else { //否则 为暂停状态
  2260. _playbtn.addClass('U_MD_UI_music_playBtn'); //修改成暂停用的图标
  2261. }
  2262. if (_barFlag) { //barFlag = true 为 时间球不在拖拽状态时
  2263. _currentTime = this.currentTime; //获取音乐当前播放时间
  2264. var _speed = Math.round(parseFloat(_currentTime / _attr.endTime) * 10000) / 10000; //_speed = 当前时间相对于总时长的 百分比
  2265. _progressBall[0].style.left = (_boxWidth * _speed) + "px"; //时间球的left = _speed(百分比)*总宽度
  2266. _progressBar[0].style.width = (_boxWidth * _speed) + "px"; //时间条的width = _speed(百分比)*总宽度
  2267. }
  2268. });
  2269. _progressBox.bind('mousedown', function (e) { //点击进度条后 时间球跳转到鼠标点击位置 时间跟随改变
  2270. var _boxLeft = _music.getOffsetLeft(this); //body距离盒子左端的left值 = 时间球left的最小值
  2271. var _boxRight = _boxLeft + _boxWidth; //body距离盒子右端的left值 = 时间球left的最大值
  2272. var _mouseX = e.pageX; //获取鼠标按下时的X坐标
  2273. _mouseX = Math.max(_mouseX, _boxLeft); //mouseX 与 boxLeft距离不能小于0 因此 获取两数最大值 原因:声音不能小于0
  2274. _mouseX = Math.min(_mouseX, _boxRight); //mouseX 与 boxRight因此 获取两数最大值 原因:声音不能大于1
  2275. var _dis = _mouseX - _boxLeft; //鼠标划过的距离
  2276. _speed = Math.round(parseFloat(_dis / _boxWidth) * 10000) / 10000; //时间球距离盒子宽度的left值 = 时间当前值/总时长(此处为保留4位小数点)
  2277. _progressBall[0].style.left = (_boxWidth * _speed) + "px";
  2278. _progressBar[0].style.width = (_boxWidth * _speed) + "px";
  2279. _audio[0].currentTime = _attr.endTime * _speed;
  2280. });
  2281. _progressBall.bind('mousedown', function (e) { //时间球拖拽效果
  2282. _barFlag = false; //拖拽时 时间球跟随声音播放向前移动状态暂时屏蔽 详细见 timeupdate监听
  2283. U.UF.EV.stopBubble(e); //阻止冒泡
  2284. var _oMouseX = e.pageX; //获取鼠标按下时的X坐标
  2285. var _progressDrapMove = function (e) { //拖拽移动时的函数
  2286. U.UF.EV.stopDefault(e); //取消默认拖拽
  2287. var _mouseX = e.pageX; //鼠标移动时的x坐标
  2288. var _dis = _mouseX - _oMouseX + _oX; //移动的距离
  2289. _dis = Math.max(0, _dis); //限制音量球left不得小于0
  2290. _dis = Math.min(_boxWidth, _dis); //限制音量球left不得大于盒子宽度
  2291. _progressBall[0].style.left = _dis + "px"; //音量球位置
  2292. _progressBar[0].style.width = _dis + "px"; //音量条宽度
  2293. _speed = Math.round(parseFloat(_dis / _boxWidth) * 10000) / 10000; //时间球距离盒子宽度的left值 = 时间当前值/总时长(此处为保留4位小数点)
  2294. _progressBall[0].style.left = (_boxWidth * _speed) + "px"; //时间球的left = 总宽*百分比
  2295. _progressBar[0].style.width = (_boxWidth * _speed) + "px"; //时间条的width = 总宽*百分比
  2296. _currentTime = _attr.endTime * _speed; //当前时间 = 音乐总时长*百分比
  2297. };
  2298. var _progressDragUp = function () { //拖拽松开后的函数
  2299. _barFlag = true; //拖拽后松开时 时间球跟随声音播放向前移动
  2300. _audio[0].currentTime = _currentTime; //当前重新赋值
  2301. U.selectEl(document).unbind('mousemove', _progressDrapMove); //删除 mousemove的监听事件
  2302. U.selectEl(document).unbind('mouseup', _progressDragUp); //删除mouseup的监听事件
  2303. };
  2304. var _oX = parseFloat(_progressBall.css("left")); //获取鼠标按下时音量球的坐标
  2305. U.selectEl(document).bind('mousemove', _progressDrapMove);
  2306. U.selectEl(document).bind('mouseup', _progressDragUp)
  2307. });
  2308. };
  2309. U.MD.UI.music.getOffsetLeft = function (obj) {
  2310. var tmp = obj.offsetLeft;
  2311. var val = obj.offsetParent;
  2312. while (val != null) {
  2313. tmp += val.offsetLeft;
  2314. val = val.offsetParent;
  2315. }
  2316. return tmp;
  2317. };
  2318. U.MD.UI.music.secondToDate = function (result) {
  2319. var m = Math.floor((result / 60 % 60));
  2320. var s = Math.floor((result % 60));
  2321. if (m < 10) {
  2322. m = "0" + m;
  2323. }
  2324. if (s < 10) {
  2325. s = "0" + s;
  2326. }
  2327. return result = m + ":" + s;
  2328. };
  2329. U.MD.UI.music.toggleClass = function (ele, cls) { //如果存在(不存在),就删除(添加)一个样式
  2330. if ($(ele).hasClass(cls)) {
  2331. U.selectEl(ele).removeClass(cls);
  2332. } else {
  2333. U.selectEl(ele).addClass(cls);
  2334. }
  2335. };;
  2336. ///<jscompress sourcefile="Page.js" />
  2337. //窗体功能命名空间
  2338. Namespace.register("U.UF.P");
  2339. /*
  2340. * 作用:给不同的域添加this的指定方向
  2341. * @param {function} fun 执行函数
  2342. * @param {array} arr 执行函数的参数数组
  2343. * @param {element} el 用于指向域
  2344. */
  2345. U.UF.P.apply = function (fun, arr, el) {
  2346. return function () {
  2347. fun.apply(el, arr);
  2348. }
  2349. }
  2350. U.UF.P.pagepId = 0; //全局变量 分页控件数量
  2351. /*
  2352. ** @param {element} el 需要插入分页控件的位置
  2353. ** @param {number} num 数据的数量
  2354. ** @param {number} pagenum 一页中数据量的多少
  2355. ** @param {number} page 显示当前是第几页
  2356. ** @param {function} fun 回调函数
  2357. */
  2358. U.UF.P.PPage = U.UF.P.page = function (el, num, pagenum, page, fun) {
  2359. this.PageNum = 0; // 全局变量 当前页
  2360. this.Index = 0; //全局变量 索引
  2361. this.Pageall = 0; //全局变量 总页数
  2362. this.init(el, num, pagenum, page, fun); //初始化函数
  2363. }
  2364. U.UF.P.page.prototype = {
  2365. init: function (el, num, pagenum, page, fun) {
  2366. this.PageNum = page; //获取当前页面
  2367. this.Index = page - 1; //获取当前页码的索引
  2368. var _el = U.selectEl(el)[0]; //获取需要插入分页控件的元素
  2369. var _pagesum = Math.ceil(num / pagenum); //获取总页数,数据的数量/一页中的数量,向上取整
  2370. this.Pageall = _pagesum; //获取总页数
  2371. //判断是否拥有分页控件
  2372. if (_el.getElementsByClassName('U_MD_F_Y')[0]) {
  2373. return false; //有的话就不添加新的分页控件
  2374. }
  2375. U.UF.P.pagepId++;
  2376. var _page = $$("div", { "className": "U_MD_F_Y" }, _el); //创建分页控件的整体部分
  2377. var _pagenode = $$("div", { "className": "U_MD_F_YL" }, _page); //创建分页控件的父级
  2378. var _firstEle = $$("div", { "className": "U_MD_F_YLO U_MD_F_Y_Button", "innerHTML": "首页", "title": "首页", "pid": U.UF.P.pagepId + "1" }, _pagenode); //创建分页的首页功能
  2379. var _previousEle = $$("div", { "className": "U_MD_F_YLT U_MD_F_Y_Button", "title": "上一页", "pid": U.UF.P.pagepId + "3" }, _pagenode); //创建分页的上一页功能
  2380. var _pagenum = $$("div", { "className": "U_MD_F_YN" }, _pagenode); //创建中间页码数的整体 , "style": { "cssText": "float:left"}
  2381. var _startpage;
  2382. var _endpage = Math.min(_pagesum, Math.max(page + 5, 10));
  2383. for (_startpage = Math.max(1, Math.min(page - 5, _pagesum - 10)); _startpage <= _endpage; _startpage++) {
  2384. (function (i, el) {
  2385. //创建中间的页码数,最高十页的页码数
  2386. //"className": "list" + U.UF.P.pagepId,
  2387. //"style": { "text-align": "center", "line-height": "31px;" },
  2388. var _centerEle = $$("div", {
  2389. "innerHTML": i, "pid": U.UF.P.pagepId + "5"
  2390. }, _pagenum); //创建中间的页码数
  2391. i == page && (_centerEle.className = "U_MD_F_Y_Button_Active");
  2392. _centerEle.onclick = U.UF.P.apply(function (i) {//给每一个页码数添加一个点击事件
  2393. U.UF.P.centerEle(el, _centerEle); //实现点击页码进行跳转
  2394. }, [_startpage], el)
  2395. })(_startpage, this);
  2396. }
  2397. // var j = 0;
  2398. // for (j; j < _forpagesum && i <= _pagesum; j++) {//循环有多少个页码,并且进行创建
  2399. // (function (i, el) {
  2400. // //创建中间的页码数,最高十页的页码数
  2401. // //"className": "list" + U.UF.P.pagepId,
  2402. // //"style": { "text-align": "center", "line-height": "31px;" },
  2403. // var _centerEle = $$("div", {
  2404. // "innerHTML": i, "pid": U.UF.P.pagepId + "5"
  2405. // }, _pagenum); //创建中间的页码数
  2406. // i == page && (_centerEle.className = "U_MD_F_Y_Button_Active");
  2407. // _centerEle.onclick = U.UF.P.apply(function (i) {//给每一个页码数添加一个点击事件
  2408. // U.UF.P.centerEle(el, _centerEle); //实现点击页码进行跳转
  2409. // }, [i], el)
  2410. // })(i, this);
  2411. // i++;
  2412. // }
  2413. var _nextEle = $$("div", { "className": "U_MD_F_YLS U_MD_F_Y_Button", "title": "下一页", "pid": U.UF.P.pagepId + "4" }, _pagenode); //创建下一页功能
  2414. var _lastEle = $$("div", { "className": "U_MD_F_YLF U_MD_F_Y_Button", "innerHTML": "尾页", "title": "尾页", "pid": U.UF.P.pagepId + "2" }, _pagenode); //创建尾页功能
  2415. var _pages = $$("div", { "className": "U_MD_F_YR" }, _page); //创建跳转页面的整体
  2416. // var _pagesk = $$("div", { "className": "U_MD_F_YRL" }, _pages); //创建跳转页面的父级
  2417. $$("span", { "innerHTML": "到" }, _pages); //创建跳转元素
  2418. // var _pagejump = $$("div", {}, _pages); //创建页码输入框的父级
  2419. var _input = $$("input", { "type": "text" }, _pages); //创建页码输入框
  2420. $$("span", { "innerHTML": "页" }, _pages); //创建跳转元素
  2421. var _rightEle = $$("div", { "className": "U_MD_F_YRZ", "pid": U.UF.P.pagepId + "6", "innerHTML": "确定" }, _pages); //创建确定按钮
  2422. if (this.PageNum < _pagesum + 1) {//获取当前页面是否小于总页数
  2423. var _list = U.selectEl(".list" + U.UF.P.pagepId); //获取所有的中间页码数
  2424. for (var j = 1; j < _list.length + 1; j++) {//循环所有的中间页码数
  2425. if (this.PageNum == j) {//判断当前页码数是否等于中间页码数的一个
  2426. U.selectEl(_list[this.PageNum - 1]).addClass("U_MD_F_Y_Button_Active");
  2427. }
  2428. }
  2429. }
  2430. _firstEle.onclick = U.UF.P.apply(this.fPage, [_firstEle, _pagesum, fun], this); //首页功能
  2431. _previousEle.onclick = U.UF.P.apply(this.fPage, [_previousEle, _pagesum, fun], this); //上一页功能
  2432. //中间点击页码跳转功能 参数一:el 指向U.UF.P.page这个域 参数二:el1 点击中间页码的元素
  2433. U.UF.P.centerEle = function (el, el1) {
  2434. U.UF.P.apply(el.fPage, [el1, _pagesum, fun], el)(); //执行点击中间页码的功能
  2435. }
  2436. _nextEle.onclick = U.UF.P.apply(this.fPage, [_nextEle, _pagesum, fun], this); //下一页功能
  2437. _lastEle.onclick = U.UF.P.apply(this.fPage, [_lastEle, _pagesum, fun], this); //尾页功能
  2438. _rightEle.onclick = U.UF.P.apply(this.fPage, [_rightEle, _pagesum, fun, _input], this); //跳页功能
  2439. _input.onkeyup = function () {//做一个键盘按下的功能
  2440. if (event.keyCode == "13") {//判断是否是回车键
  2441. _rightEle.onclick(); //如果是回车键,则 执行确定按钮功能
  2442. }
  2443. }
  2444. },
  2445. /*
  2446. ** 作用:用于首页 上一页 下一页 尾页 输入框跳转 点击中间页码数的功能实现
  2447. ** @param {element} el 获取当前元素
  2448. ** @param {number} pagesum 总页数
  2449. ** @param {function} fun 回调函数
  2450. ** @param {element} input 获取输入框的元素
  2451. */
  2452. fPage: function (el, pagesum, fun, input) {
  2453. _el1 = el.pid; //获取点击元素的pid,用于判断是首页 上一页 下一页 尾页 输入框跳转 点击中间页码数的功能
  2454. _el = _el1.charAt(_el1.length - 1); //截取pid最后一个数字,用于判断是首页 上一页 下一页 尾页 输入框跳转 点击中间页码数的功能
  2455. if (_el == 5) {//判断是否是点击中间页码
  2456. _list = U.selectEl($(el).Parent()).Parent().children[2].children; //获取点击中间页码的该元素的所有页码元素
  2457. } else if (_el == 6) {//判断是否是确定或者是回车按钮的点击
  2458. _list = U.selectEl($(el).Parent()).Parent().children[0].children[2].children; //获取确定或回车按钮的点击的该元素的所有页码元素
  2459. } else {//如果既不是中间页码,也不是回车或者是确定按钮的点击
  2460. _list = U.selectEl(el).Parent().children[2].children; //获取该元素所有的页码元素
  2461. }
  2462. U.selectEl(".U_MD_F_Y_Button_Active").removeClass("U_MD_F_Y_Button_Active"); //清空所有页码的点击样式
  2463. if (_el == 1) {//pid为1时,执行首页的功能
  2464. if (this.Index == 0) { this.Index++ } //判断当前索引是否为0,如果是 则执行索引++
  2465. if (this.PageNum > 1) {//判断当前页数是否大于1
  2466. U.selectEl(_list[0]).addClass("U_MD_F_Y_Button_Active");
  2467. this.Index = 0; //获取索引为0
  2468. this.PageNum = 1//获取当前页数为1
  2469. this.pagefun(this.PageNum, _list); //执行页码跳转功能
  2470. fun(this.PageNum); //执行数据的跳转 this.PageNum 当前页数
  2471. return;
  2472. }
  2473. U.selectEl(_list[--this.Index]).addClass("U_MD_F_Y_Button_Active");
  2474. }
  2475. else if (_el == 2) {//pid为2时,执行尾页功能
  2476. if (this.PageNum < this.Pageall) {//判断当前页码是否小于总页数
  2477. this.Index = pagesum; //获取索引值为总页数
  2478. this.PageNum = this.Pageall; //获取全局变量的当前页为总页数
  2479. this.pagefun(this.PageNum, _list); //执行页码跳转功能
  2480. fun(this.PageNum); //执行数据的跳转 this.PageNum 当前页数
  2481. return
  2482. } else {
  2483. U.selectEl(_list[this.Index]).addClass("U_MD_F_Y_Button_Active");
  2484. }
  2485. }
  2486. else if (_el == 3) {//pid为3时,执行上一页功能
  2487. if (this.Index > 0) {//判断当前索引是否大于0
  2488. U.selectEl(_list[--this.Index]).addClass("U_MD_F_Y_Button_Active"); //获取当前页的上一个页码的点击样式
  2489. this.PageNum--; //并且当前页减一
  2490. this.pagefun(this.PageNum, _list); //执行页码跳转功能
  2491. fun(this.PageNum); //执行数据的跳转 this.PageNum 当前页数
  2492. return
  2493. } else { // 判断第一页
  2494. U.selectEl(_list[this.Index]).addClass("U_MD_F_Y_Button_Active");
  2495. }
  2496. }
  2497. else if (_el == 4) {//pid为4时,执行下一页功能
  2498. if (this.PageNum < this.Pageall) {//判断当前页码是否小于总页数
  2499. U.selectEl(_list[++this.Index]).addClass("U_MD_F_Y_Button_Active"); //获取当前页的下一个页码的点击样式
  2500. this.PageNum++; //并且当前页码加一
  2501. this.pagefun(this.PageNum, _list); //执行页码跳转功能
  2502. fun(this.PageNum); //执行数据的跳转 this.PageNum 当前页数
  2503. return
  2504. } else {// 判断最后一页
  2505. U.selectEl(_list[this.Index]).addClass("U_MD_F_Y_Button_Active"); //获取最后一页的点击样式
  2506. }
  2507. } else if (_el == 5) {//pid为5时,执行点击中间页码跳转功能
  2508. this.pagefun(el, _list); //执行页码跳转功能
  2509. fun(this.PageNum); //执行数据的跳转 this.PageNum 当前页数
  2510. return
  2511. } else if (_el == 6) {//pid为6时,执行输入框功能
  2512. var _number = new RegExp("^[0-9]*$")//写一个正则表达式,只能够输入数字
  2513. if (input.value.match(_number)) {//判断输入的是否是数字
  2514. if (input.value >= 1 && input.value <= this.Pageall) {//判断输入的数字是否大于等于1,并且,输入的数字小于等于总页数
  2515. this.PageNum = input.value; //输入的值为当前页码数
  2516. this.pagefun(this.PageNum, _list); //执行页码跳转功能
  2517. fun(this.PageNum); //执行数据的跳转 this.PageNum 当前页数
  2518. } else {//如果输入的不是数字
  2519. U.alert("无效的输入"); //则弹窗提示
  2520. U.selectEl(_list[this.Index]).addClass("U_MD_F_Y_Button_Active"); //并且点击样式不改变
  2521. }
  2522. }
  2523. }
  2524. },
  2525. /*
  2526. ** 作用:用于首页、上一页、下一页、尾页、输入框、点击页码进行页码跳转的功能
  2527. ** @param {element} el 当前页码数
  2528. */
  2529. pagefun: function (el, list) {
  2530. var _list = list; //获取所有的中间页码数
  2531. var elNum = parseInt(el.innerHTML) || el; // 获取当前点击页码
  2532. U.selectEl(".U_MD_F_Y_Button_Active").removeClass("U_MD_F_Y_Button_Active"); //清空所有的中间页码数的点击样式
  2533. var _listLength = Math.ceil(_list.length / 2); // 获取页码长度的一半
  2534. var Index; // 记录点击时的页码的索引
  2535. var preIndex = this.Index; // 上一个页码索引
  2536. var difference = null; // 计算当前页码跟所点击的页码的差异
  2537. var lastPage = parseInt($(_list)[$(_list).length - 1].innerText); // 当前页码的最后一个数的页码
  2538. //判断当前点击页码是否小于页码长度的一半,或者当前点击页码大于当前页码的最后一个数的页码减去页码长度的一半并且当前点击页码小于等于总页码数
  2539. if (!(elNum < _listLength || (elNum > this.Pageall - _listLength && elNum <= this.Pageall))) {//这里有个取反
  2540. // 点击页码中间以后的页码处理 例如 1 2 3 4 .... 8 9 则 5以后的页码点击处理事件
  2541. //判断当前页码的最后一个数除以当前点击页码,向上取整,是否小于当前页码的最后一个数减去当前点击页码,并且索引值不为0
  2542. if (!(Math.ceil(lastPage / elNum) < lastPage - elNum) && this.Index != 0) {//这里有一个取反
  2543. difference = elNum - parseInt(_list[_listLength - 1].innerText); // 计算差异
  2544. [ ].__proto__.forEach.apply($(_list), [function (value, index, ar) {//forEach循环数组,循环所有获取到的中间页码数,并且获取数组中的每一个元素的索引
  2545. value.innerText = parseInt(value.innerText) + difference; // 跟中间的值进行比较
  2546. } ])
  2547. this.Index = _listLength - 1; // 记录索引
  2548. } else {
  2549. // 向页码中间以前的页码点击处理事件
  2550. difference = elNum - parseInt(_list[_listLength - 1].innerText); //计算当前页码跟所点击的页码的差异
  2551. [ ].__proto__.forEach.apply($(_list), [function (value, index, ar) {//forEach循环数组,循环所有获取到的中间页码数,并且获取数组中的每一个元素的索引
  2552. value.innerText = parseInt(value.innerText) + difference; // 跟中间的值进行比较
  2553. } ])
  2554. this.Index = _listLength - 1; // 记录索引
  2555. }
  2556. } else if (elNum > this.Pageall - _listLength && elNum <= this.Pageall) { // 最大页码设置
  2557. var elthis = this;
  2558. [ ].__proto__.forEach.apply($(_list), [
  2559. function (value, index, ar) {//forEach循环数组,循环所有获取到的中间页码数,并且获取数组中的每一个元素的索引
  2560. value.innerText = elthis.Pageall + 1 - ar.length + index;
  2561. } ])
  2562. } else if (elNum < _listLength) { // 最小页码设置
  2563. [ ].__proto__.forEach.apply($(_list), [function (value, index, ar) {//forEach循环数组,循环所有获取到的中间页码数,并且获取数组中的每一个元素的索引
  2564. value.innerText = index + 1; // 跟中间的值进行比较
  2565. } ])
  2566. }
  2567. // 页码点击处理事件
  2568. [ ].__proto__.forEach.apply(_list, [function (value, index, ar) {//forEach循环数组,循环所有获取到的中间页码数,并且获取数组中的每一个元素的索引
  2569. if (parseInt(value.innerHTML) == elNum) {//判断循环出来的元素的值是否为当前点击页码
  2570. Index = index;
  2571. } //获取索引
  2572. } ])
  2573. this.Index = Index; //获取当前索引
  2574. this.PageNum = elNum; // 修改当前页数
  2575. U.selectEl(_list[this.Index]).addClass("U_MD_F_Y_Button_Active"); //并且点击样式不改变
  2576. }
  2577. };
  2578. ///<jscompress sourcefile="Picture.js" />
  2579. Namespace.register("U.MD.UI.picture");
  2580. /**
  2581. * 图片控件调用接口函数
  2582. * @arr {Array || Object} 图片信息数组
  2583. * 形如:
  2584. * ['//img/1.jpg',
  2585. * '//img/2.jpg',
  2586. * '//img/3.jpg',
  2587. * '//img/4.jpg',
  2588. * '//img/5.jpeg',
  2589. * '//img/6.jpg']
  2590. */
  2591. U.MD.UI.picture = function (arr, startPicNum) {
  2592. if ($('#U_MD_UI_PictureForm')[0]) { /*判断窗体是否存在*/
  2593. if ($('#U_MD_UI_PictureForm')[0].style.display === 'none') /*重新将窗体显示到页面中*/
  2594. U.selectEl('#U_MD_UI_PictureForm')[0].style.display = 'block';
  2595. U.MD.UI.picture.DIVBOX = {
  2596. "USERPICS": arr,
  2597. "PICAREA": U.selectEl('#U_MD_UI_Picture_picArea')[0], /*获取拖拽的元素*/
  2598. "PICBOX": U.selectEl('#U_MD_UI_Picture_picBox')[0], /*获取控件最外层元素*/
  2599. 'FA': U.selectEl('#U_MD_UI_Picture_fa')[0] /*获取功能栏目元素*/
  2600. };
  2601. U.MD.UI.picture.initloadPic(arr, startPicNum)
  2602. return;
  2603. }
  2604. if (!arr.length)
  2605. return
  2606. U.MD.UI.picture.create(arr, startPicNum); /*创建控件的内容*/
  2607. U.MD.UI.picture.DIVBOX.PICAREA.onmousedown = function (e) { U.MD.UI.picture.mDown(U.MD.UI.picture.DIVBOX.PICAREA, U.MD.UI.picture.DIVBOX.PICBOX, e) }
  2608. U.MD.UI.picture.wheel(); /*定义滚轮事件*/
  2609. }
  2610. /*定义功能栏目的图片*/
  2611. U.MD.UI.picture.FA = [
  2612. { src: "/img/pictureView/add.png", id: "U_MD_UI_Picture_add" }, //放大按钮图片素材
  2613. {src: "/img/pictureView/narrow.png", id: "U_MD_UI_Picture_narrow" }, //缩小按钮图片素材
  2614. {src: "/img/pictureView/prev.png", id: "U_MD_UI_Picture_prev" }, //上一张按钮图片素材
  2615. {src: "/img/pictureView/next.png", id: "U_MD_UI_Picture_next" }, //下一张按钮图片素材
  2616. {src: "/img/pictureView/turnLeft.png", id: "U_MD_UI_Picture_turnLeft" }, //左旋转按钮图片素材
  2617. {src: "/img/pictureView/turnRight.png", id: "U_MD_UI_Picture_turnRight"} //右旋转按钮图片素材
  2618. ];
  2619. U.MD.UI.picture.picnumber = 0; /*定义图片数*/
  2620. U.MD.UI.picture.rotatenum = 0; /*定义旋转数*/
  2621. U.MD.UI.picture.originalSize = [] /*定义原始图片尺寸大小的数组*/
  2622. U.MD.UI.picture.pics = []; /*定义存放图片的数组*/
  2623. U.MD.UI.picture.scalingvalue = 50; /*定义缩放大小单位:px*/
  2624. U.MD.UI.picture.focuspicsrc = ''; /*当前图片的src*/
  2625. U.MD.UI.picture.focuspicsize = ''; /*当前图片的文件大小*/
  2626. /**
  2627. * 图片控件创建函数
  2628. * @arr {Array || Object} 图片信息数组
  2629. */
  2630. U.MD.UI.picture.create = function (arr, startPicNum) {
  2631. var _c = $$('div', { style: { height: "100%", "overflow": "hidden" }, id: "U_MD_UI_Picture_bossBox" }); /*创建控件最外层元素*/
  2632. var _box = $$('div', { id: "U_MD_UI_Picture_picBox", className: 'U_MD_UI_Picture_picBox' }, _c);
  2633. $$('div', { id: 'U_MD_UI_Picture_picArea', className: 'U_MD_UI_Picture_picArea' }, _box); /*创建控件第二层元素,也是拖拽时所要触发的元素*/
  2634. var _functionalarea = $$('div', { style: { height: "60px", width: "100%", position: "absolute", bottom: "0", "background-color": "#ffffff", "text-align": "center" }, id: "U_MD_UI_Picture_fa" }, _c); /*创建控件的功能栏目*/
  2635. new U.UF.UI.form(
  2636. "<span id='U_MD_UI_Picture_imgInfo'></span> - <span id='U_MD_UI_Picture_r'>100%</span>",
  2637. _c,
  2638. { style: { width: document.documentElement.clientWidth / 1.5 + 'px', height: document.documentElement.clientHeight / 1.5 + 'px', position: "absolute" }, id: "U_MD_UI_PictureForm" },
  2639. { isdrag: true, isstretching: true, isenlarge: true, isclose: true, isnarrow: true },
  2640. { style: { "padding": "10px", "background-color": "#22508c"} }
  2641. ); /*调用窗体*/
  2642. _box.style.height = _box.clientHeight - 60 + 'px'; /*让可拖拽区域的宽-60px*/
  2643. // 全局属性
  2644. U.MD.UI.picture.DIVBOX = {
  2645. "USERPICS": arr,
  2646. "PICAREA": U.selectEl('#U_MD_UI_Picture_picArea')[0], /*获取拖拽的元素*/
  2647. "PICBOX": U.selectEl('#U_MD_UI_Picture_picBox')[0], /*获取控件最外层元素*/
  2648. 'FA': U.selectEl('#U_MD_UI_Picture_fa')[0] /*获取功能栏目元素*/
  2649. };
  2650. /*创建功能栏目子节点*/
  2651. var _oDiv = $$('div', { style: { display: "inline-block", "line-height": "40px", "margin-top": "10px"} }, U.MD.UI.picture.DIVBOX.FA);
  2652. /*循环功能栏目里面的图片*/
  2653. for (var j = 0; j < U.MD.UI.picture.FA.length; j++) {
  2654. /*创建span*/
  2655. var _span = $$('span', { style: { "background-image": "url(" + U.MD.UI.picture.FA[j].src + ")", width: "40px", height: "40px", display: "inline-block", margin: "0 15px" }, id: U.MD.UI.picture.FA[j].id }, _oDiv);
  2656. }
  2657. U.MD.UI.picture.initloadPic(null, startPicNum);
  2658. /*给上放大的点击事件*/
  2659. U.selectEl('#U_MD_UI_Picture_add')[0].onclick = U.UF.C.apply(this, function () {
  2660. this.changeSize(U.MD.UI.picture.scalingvalue, U.MD.UI.picture.rotatenum)
  2661. });
  2662. /*给上缩小的点击事件*/
  2663. U.selectEl('#U_MD_UI_Picture_narrow')[0].onclick = U.UF.C.apply(this, function () {
  2664. this.changeSize(-U.MD.UI.picture.scalingvalue, U.MD.UI.picture.rotatenum)
  2665. });
  2666. /*给上上一张图片的点击事件*/
  2667. U.selectEl('#U_MD_UI_Picture_prev')[0].onclick = U.UF.C.apply(this, function () {
  2668. this.prevPic(0)
  2669. });
  2670. /*给上下一张图片的点击事件*/
  2671. U.selectEl('#U_MD_UI_Picture_next')[0].onclick = U.UF.C.apply(this, function () {
  2672. this.prevPic(1)
  2673. });
  2674. /*给上左旋转的点击事件*/
  2675. U.selectEl('#U_MD_UI_Picture_turnLeft')[0].onclick = U.UF.C.apply(this, function () {
  2676. this.turn(1)
  2677. });
  2678. /*给上有旋转的点击事件*/
  2679. U.selectEl('#U_MD_UI_Picture_turnRight')[0].onclick = U.UF.C.apply(this, function () {
  2680. this.turn(0)
  2681. });
  2682. _c.onresize = function () {
  2683. _box.style.height = _c.clientHeight - 60 + 'px';
  2684. };
  2685. _box.onresize = function () {
  2686. U.MD.UI.picture.checkHeight();
  2687. }
  2688. }
  2689. U.MD.UI.picture.initloadPic = function (arr, startPicNum) {
  2690. if (arr) {
  2691. U.MD.UI.picture.DIVBOX.PICAREA.innerHTML = "";
  2692. U.MD.UI.picture.DIVBOX.PICAREA.style = null;
  2693. U.MD.UI.picture.picnumber = startPicNum || 0; /*定义图片数*/
  2694. U.MD.UI.picture.rotatenum = 0; /*定义旋转数*/
  2695. U.MD.UI.picture.DIVBOX.USERPICS = arr
  2696. } else {
  2697. U.MD.UI.picture.picnumber = startPicNum >= 0 ? startPicNum : 0;
  2698. }
  2699. //调用创建方法
  2700. U.MD.UI.picture.createPic();
  2701. /*获取所有的图片并赋值*/
  2702. U.MD.UI.picture.pics = U.selectEl('#U_MD_UI_Picture_picArea > ul > li > img');
  2703. U.MD.UI.picture.pics[U.MD.UI.picture.picnumber].onload = U.UF.C.apply(this, function () {
  2704. /*获取当前图片的原始大小并赋值*/
  2705. this.originalSize = this.getImgNaturalDimensions(U.MD.UI.picture.pics[U.MD.UI.picture.picnumber]);
  2706. /*调整大小,位置*/
  2707. this.checkHeight();
  2708. });
  2709. }
  2710. U.MD.UI.picture.createPic = function () {
  2711. /*创建ul*/
  2712. var _ul = $$('ul', { id: "ul" }, U.MD.UI.picture.DIVBOX.PICAREA);
  2713. /*循环数据源*/
  2714. for (var i = 0; i < U.MD.UI.picture.DIVBOX.USERPICS.length; i++) {
  2715. /*创建li*/
  2716. var _li = $$('li', {}, _ul);
  2717. if (typeof U.MD.UI.picture.DIVBOX.USERPICS[i] === 'object') {
  2718. /*如果是第一张,初始化控件一般都是第一张显示*/
  2719. if (i === U.MD.UI.picture.picnumber) {
  2720. $$('img', { "onerror": U.MD.C.imgError, src: U.MD.UI.picture.DIVBOX.USERPICS[i].src }, _li);
  2721. U.MD.UI.picture.focuspicsrc = U.MD.UI.picture.DIVBOX.USERPICS[i].src;
  2722. if (U.MD.UI.picture.DIVBOX.USERPICS[i].size)
  2723. U.MD.UI.picture.focuspicsize = U.MD.UI.picture.DIVBOX.USERPICS[i].size;
  2724. } else {
  2725. $$('img', { "onerror": U.MD.C.imgError, src: U.MD.UI.picture.DIVBOX.USERPICS[i].src, style: { display: "none"} }, _li);
  2726. }
  2727. } else if (typeof U.MD.UI.picture.DIVBOX.USERPICS[i] === 'string') {
  2728. if (i === U.MD.UI.picture.picnumber) {
  2729. /*如果是第一张,初始化控件一般都是第一张显示*/
  2730. $$('img', { "onerror": U.MD.C.imgError, src: U.MD.UI.picture.DIVBOX.USERPICS[i] }, _li);
  2731. U.MD.UI.picture.focuspicsrc = U.MD.UI.picture.DIVBOX.USERPICS[i];
  2732. }
  2733. else {
  2734. $$('img', { "onerror": U.MD.C.imgError, src: U.MD.UI.picture.DIVBOX.USERPICS[i], style: { display: "none"} }, _li);
  2735. }
  2736. }
  2737. }
  2738. }
  2739. /**
  2740. * 旋转检测
  2741. * @param num 为整数
  2742. * 如果是0也就是false,调用右旋转。如果是1也就是true,调用左旋转。因为有万恶的ie8,所以要滤镜旋转 0-0°,1-90°,2-180°,3-270°,如果需要任意角度旋转去学习阵矩。
  2743. *
  2744. */
  2745. U.MD.UI.picture.turn = function (num) {
  2746. /*判断是左旋,还是右旋,为什么要这么打应该晓得吧*/
  2747. if (num) {
  2748. U.MD.UI.picture.rotatenum--;
  2749. U.MD.UI.picture.rotatenum < 0 ? U.MD.UI.picture.rotatenum = 3 : U.MD.UI.picture.rotatenum;
  2750. } else {
  2751. U.MD.UI.picture.rotatenum++;
  2752. U.MD.UI.picture.rotatenum > 3 ? U.MD.UI.picture.rotatenum = 0 : U.MD.UI.picture.rotatenum;
  2753. }
  2754. U.MD.UI.picture.rotating();
  2755. }
  2756. /**
  2757. * 执行旋转
  2758. */
  2759. U.MD.UI.picture.rotating = function () {
  2760. /*定义常规游览器旋转属性字符*/
  2761. var val = "rotate(" + U.MD.UI.picture.rotatenum * 90 + "deg)";
  2762. /*U.MD.UI.picture.rotatenum % 2 !== 0 判断是否选转90°或者270°*/
  2763. if (U.MD.UI.picture.rotatenum % 2 !== 0) {
  2764. /*赋值大小,-20px是为了留间隙*/
  2765. U.MD.UI.picture.DIVBOX.PICAREA.style.width = U.MD.UI.picture.DIVBOX.PICBOX.clientHeight - 20 + 'px';
  2766. /*开始旋转*/
  2767. U.MD.UI.picture.compatibleRotate(U.MD.UI.picture.DIVBOX.PICAREA, val);
  2768. /*调整位置*/
  2769. U.MD.UI.picture.DIVBOX.PICAREA.style.top = (U.MD.UI.picture.DIVBOX.PICAREA.clientWidth / 2 - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight / 2) + 10 + 'px';
  2770. /*调整位置,以至于中心缩放*/
  2771. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 2 - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth / 2 + 'px';
  2772. /*检测是否是ie8 or ie7*/
  2773. if ((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) == "8.") || (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i) == "7.")) {
  2774. U.MD.UI.picture.DIVBOX.PICAREA.style.top = "10px";
  2775. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 2 - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight / 2 + 'px';
  2776. }
  2777. } else {
  2778. /*清空拖拽元素的style*/
  2779. U.MD.UI.picture.DIVBOX.PICAREA.setAttribute('style', '');
  2780. /*开始旋转*/
  2781. U.MD.UI.picture.compatibleRotate(U.MD.UI.picture.DIVBOX.PICAREA, val);
  2782. /*改变长度*/
  2783. U.MD.UI.picture.DIVBOX.PICAREA.style.width = U.MD.UI.picture.originalSize[0] > U.MD.UI.picture.DIVBOX.PICAREA.clientWidth + 150 ? '1290px' : U.MD.UI.picture.DIVBOX.PICAREA.clientWidth + 150;
  2784. /*调整图片大小*/
  2785. U.MD.UI.picture.checkHeight();
  2786. }
  2787. /*改变左上角的title的缩放比*/
  2788. U.selectEl('#U_MD_UI_Picture_r')[0].innerText = Math.round((U.MD.UI.picture.DIVBOX.PICAREA.clientHeight / U.MD.UI.picture.originalSize[1]) * 100) + '%';
  2789. }
  2790. /**
  2791. * 兼容旋转
  2792. * @param el 旋转的元素
  2793. * @param val 旋转的属性值
  2794. */
  2795. U.MD.UI.picture.compatibleRotate = function (el, val) {
  2796. //定义属性
  2797. el.style.webkitTransform = val;
  2798. el.style.MozTransform = val;
  2799. el.style.mturnsTransform = val;
  2800. el.style.OTransform = val;
  2801. el.style.transform = val;
  2802. /*检测是否是ie8 or ie7*/
  2803. if ((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) == "8.") || (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i) == "7."))
  2804. el.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(rotation=" + Math.abs(U.MD.UI.picture.rotatenum) + ")";
  2805. }
  2806. /**
  2807. * 图片切换
  2808. * @param num 整数orTRUE,FALSE
  2809. * true代表下一张,false代表上一张
  2810. */
  2811. U.MD.UI.picture.prevPic = function (num) {
  2812. /*在切换图片先把正在显示的图片隐藏掉*/
  2813. U.MD.UI.picture.pics[U.MD.UI.picture.picnumber].style.display = 'none';
  2814. if (num) {
  2815. /*图片位置数++*/
  2816. U.MD.UI.picture.picnumber++;
  2817. /*如果是最后一张,跳到第一张*/
  2818. if (U.MD.UI.picture.picnumber > U.MD.UI.picture.pics.length - 1)
  2819. U.MD.UI.picture.picnumber = 0;
  2820. } else {
  2821. /*图片位置数--*/
  2822. U.MD.UI.picture.picnumber--;
  2823. /*如果是第一张,跳到最后一张*/
  2824. if (U.MD.UI.picture.picnumber < 0)
  2825. U.MD.UI.picture.picnumber = U.MD.UI.picture.pics.length - 1;
  2826. }
  2827. if (U.MD.UI.picture.DIVBOX.USERPICS[U.MD.UI.picture.picnumber].size)
  2828. U.MD.UI.picture.focuspicsize = U.MD.UI.picture.DIVBOX.USERPICS[U.MD.UI.picture.picnumber].size;
  2829. if (U.MD.UI.picture.DIVBOX.USERPICS[U.MD.UI.picture.picnumber].src)
  2830. U.MD.UI.picture.focuspicsrc = U.MD.UI.picture.DIVBOX.USERPICS[U.MD.UI.picture.picnumber].src;
  2831. /*显示需要显示的图片*/
  2832. U.MD.UI.picture.pics[U.MD.UI.picture.picnumber].style.display = 'block';
  2833. /*获取该图片的初始大小*/
  2834. U.MD.UI.picture.originalSize = U.MD.UI.picture.getImgNaturalDimensions(U.MD.UI.picture.pics[U.MD.UI.picture.picnumber]);
  2835. /*清空拖拽元素的style值*/
  2836. U.MD.UI.picture.DIVBOX.PICAREA.setAttribute('style', '');
  2837. /*调整大小,位置*/
  2838. U.MD.UI.picture.checkHeight();
  2839. /*旋转数初始0*/
  2840. U.MD.UI.picture.rotatenum = 0;
  2841. }
  2842. /**
  2843. * 功能:调整图片的大小,图片居中显示,改变左上角的title缩放比例
  2844. */
  2845. U.MD.UI.picture.checkHeight = function () {
  2846. /*长宽比例*/
  2847. var _proportion = U.MD.UI.picture.originalSize[0] / U.MD.UI.picture.originalSize[1];
  2848. /*如果原始图片的宽比显示框的宽要大,进行调整*/
  2849. if (U.MD.UI.picture.originalSize[1] > U.MD.UI.picture.DIVBOX.PICBOX.clientHeight - 40 || U.MD.UI.picture.originalSize[0] > U.MD.UI.picture.DIVBOX.PICBOX.clientWidth) {
  2850. /*-40px上下留白*/
  2851. U.MD.UI.picture.DIVBOX.PICAREA.style.width = Math.floor((U.MD.UI.picture.DIVBOX.PICBOX.clientHeight - 40) * _proportion) + 'px';
  2852. } else {
  2853. /*原比例显示*/
  2854. U.MD.UI.picture.DIVBOX.PICAREA.style.width = U.MD.UI.picture.originalSize[0] + 'px';
  2855. //U.MD.UI.picture.DIVBOX.PICAREA.style.height = U.MD.UI.picture.originalSize[1] + 'px';
  2856. }
  2857. /*居中显示*/
  2858. U.MD.UI.picture.DIVBOX.PICAREA.style.left = (U.MD.UI.picture.DIVBOX.PICBOX.clientWidth - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth) / 2 + 'px';
  2859. U.MD.UI.picture.DIVBOX.PICAREA.style.top = (U.MD.UI.picture.DIVBOX.PICBOX.clientHeight - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 + 'px';
  2860. if (typeof U.MD.UI.picture.DIVBOX.USERPICS[0] === 'object')
  2861. U.selectEl('#U_MD_UI_Picture_imgInfo')[0].innerText = U.MD.UI.picture.focuspicsrc.toLowerCase().split('/').splice(-1)[0] + "(" + U.MD.UI.picture.originalSize[0] + "*" + U.MD.UI.picture.originalSize[1] + "px " + U.MD.UI.picture.focuspicsize + ")";
  2862. else if (typeof U.MD.UI.picture.DIVBOX.USERPICS[0] === 'string')
  2863. U.selectEl('#U_MD_UI_Picture_imgInfo')[0].innerText = U.MD.UI.picture.DIVBOX.USERPICS[U.MD.UI.picture.picnumber].toLowerCase().split('/').splice(-1)[0] + "(" + U.MD.UI.picture.originalSize[0] + "*" + U.MD.UI.picture.originalSize[1] + "px)";
  2864. U.selectEl('#U_MD_UI_Picture_r')[0].innerText = Math.round((U.MD.UI.picture.DIVBOX.PICAREA.clientHeight / U.MD.UI.picture.originalSize[1]) * 100) + '%';
  2865. }
  2866. /**
  2867. * 获取图片的原来的大小
  2868. * @param img
  2869. * @returns {*[]} 返回值1:原始长度,值2:原始宽度
  2870. */
  2871. U.MD.UI.picture.getImgNaturalDimensions = function (img) {
  2872. var nWidth, nHeight;
  2873. if (img.naturalWidth) { // 现代浏览器
  2874. nWidth = img.naturalWidth;
  2875. nHeight = img.naturalHeight
  2876. } else { // IE6/7/8
  2877. var image = new Image();
  2878. image.src = img.src;
  2879. nWidth = image.width;
  2880. nHeight = image.height;
  2881. }
  2882. return [nWidth, nHeight]
  2883. }
  2884. /**
  2885. * 拖拽
  2886. * @param dragEl 拖拽的元素
  2887. * @param bossEl 拖拽限制的范围元素
  2888. */
  2889. U.MD.UI.picture.drag = function (dragEl, bossEl) {
  2890. dragEl.onmousedown = function (e) {
  2891. U.MD.UI.picture.mDown(dragEl, bossEl, e)
  2892. }
  2893. }
  2894. /**
  2895. * 点击图片所触发的事件
  2896. * @param {[object]} dragEl [拖拽的元素]
  2897. * @param {[object]} bossEl [拖拽限制的范围元素]
  2898. * @param {[event]} e []
  2899. */
  2900. U.MD.UI.picture.mDown = function (dragEl, bossEl, e) {
  2901. e = e || window.event;
  2902. /*定义拖拽元素到父级的X距离*/
  2903. var _distanceX = e.clientX - dragEl.offsetLeft;
  2904. /*定义拖拽元素到父级的Y距离*/
  2905. var _distanceY = e.clientY - dragEl.offsetTop;
  2906. bossEl.onmousemove = function (e) {
  2907. U.MD.UI.picture.mMove(dragEl, bossEl, _distanceX, _distanceY, e);
  2908. }
  2909. /*鼠标放开,移除事件*/
  2910. bossEl.onmouseup = function (e) {
  2911. bossEl.onmousemove = null;
  2912. bossEl.onmouseup = null;
  2913. };
  2914. /*禁用默认事件*/
  2915. if (e.preventDefault) {
  2916. /*常规游览器*/
  2917. e.preventDefault();
  2918. } else {
  2919. /*ie8*/
  2920. dragEl.ondragstart = function () {
  2921. return false;
  2922. };
  2923. dragEl.onselectstart = function () {
  2924. return false;
  2925. };
  2926. }
  2927. }
  2928. /**
  2929. * 点击拖动图片时触发的事件
  2930. * @param {[object]} dragEl [拖拽的元素]
  2931. * @param {[object]} bossEl [拖拽限制的范围元素]
  2932. * @param {[object]} _distanceX [拖拽元素到父级的X距离]
  2933. * @param {[object]} _distanceY [拖拽元素到父级的Y距离]
  2934. * @param {[event]} e []
  2935. */
  2936. U.MD.UI.picture.mMove = function (dragEl, bossEl, _distanceX, _distanceY, e) {
  2937. e = e || window.event;
  2938. /*移动距离*/
  2939. var _left = e.clientX - _distanceX,
  2940. _top = e.clientY - _distanceY;
  2941. /*判断是否是最顶部,默认显示窗体宽的1/8*/
  2942. _left = U.MD.UI.picture.rotatenum % 2 === 0 ? Math.min(bossEl.clientWidth - bossEl.clientWidth / 8, _left) : Math.min(bossEl.clientWidth - bossEl.clientWidth / 8 - dragEl.clientWidth / 2 + dragEl.clientHeight / 2, _left);
  2943. /*判断是否是最底部,默认显示窗体宽的1/8*/
  2944. _left = U.MD.UI.picture.rotatenum % 2 === 0 ? Math.max(-dragEl.clientWidth + bossEl.clientWidth / 8, _left) : Math.max(-dragEl.clientWidth + bossEl.clientWidth / 8 + dragEl.clientWidth / 2 - dragEl.clientHeight / 2, _left);
  2945. /*判断是否是最左部,默认显示窗体长的1/8*/
  2946. _top = U.MD.UI.picture.rotatenum % 2 === 0 ? Math.min(bossEl.clientHeight - bossEl.clientHeight / 8, _top) : Math.min(bossEl.clientHeight - bossEl.clientHeight / 8 + (dragEl.clientWidth - dragEl.clientHeight) / 2, _top);
  2947. /*判断是否是最右部,默认显示窗体长的1/8*/
  2948. _top = U.MD.UI.picture.rotatenum % 2 === 0 ? Math.max(-dragEl.clientHeight + bossEl.clientHeight / 8, _top) : Math.max(-dragEl.clientHeight + bossEl.clientHeight / 8 - (dragEl.clientWidth - dragEl.clientHeight) / 2, _top);
  2949. /*赋值*/
  2950. dragEl.style.left = _left + 'px';
  2951. dragEl.style.top = _top + 'px';
  2952. }
  2953. /**
  2954. * 滚轮事件
  2955. */
  2956. U.MD.UI.picture.wheel = function () {
  2957. U.MD.UI.picture.DIVBOX.PICBOX.onmousewheel = function () {
  2958. this.getWheelDalta()
  2959. } .bind(this);
  2960. }
  2961. /**
  2962. * 滚轮事件
  2963. * @param e
  2964. */
  2965. U.MD.UI.picture.getWheelDalta = function (e) {
  2966. e = e || window.event;
  2967. var delta = 0;
  2968. // delta的返回值为正时,表示向前滚动;delta的返回值为负时,表示向后滚动;
  2969. if (e.wheelDelta) {
  2970. // IE中,鼠标滚轮信息存放在wheelDelta属性中;向前滚动时,wheelDelta的值是120的倍数;向后滚动时,wheelDelta的值是-120的倍数;
  2971. delta = e.wheelDelta / 120;
  2972. if (window.opera) delta = -delta;
  2973. } else if (e.detail) {
  2974. // Firefox的鼠标滚轮信息存放在detail属性中;向前滚动,detail的值是-3的倍数;向后滚动,detail的值是3的倍数;
  2975. delta = -e.detail / 3;
  2976. }
  2977. // 执行滚轮事件函数
  2978. if (delta > 0) {
  2979. U.MD.UI.picture.changeSize(U.MD.UI.picture.scalingvalue);
  2980. } else {
  2981. U.MD.UI.picture.changeSize(-U.MD.UI.picture.scalingvalue);
  2982. }
  2983. // 阻止默认行为,防止当页面本身就存在滚动条时出现的异常
  2984. prevent(event);
  2985. function prevent(evt) {
  2986. if (evt.preventDefault) {
  2987. evt.preventDefault();
  2988. } else {
  2989. evt.returnValue = false;
  2990. }
  2991. }
  2992. }
  2993. /**
  2994. * 改变图片大小
  2995. * @param multiple 缩放大小
  2996. */
  2997. U.MD.UI.picture.changeSize = function (multiple) {
  2998. /*添加缩放后, 添加缩放前的宽, 添加缩放前的长*/
  2999. var _addOver, _afterH, _afterW;
  3000. /*赋值*/
  3001. _afterH = U.MD.UI.picture.DIVBOX.PICAREA.clientHeight;
  3002. _afterW = U.MD.UI.picture.DIVBOX.PICAREA.clientWidth;
  3003. _addOver = U.MD.UI.picture.DIVBOX.PICAREA.clientWidth + multiple;
  3004. /*最小缩放长400px*/
  3005. if ((_addOver / U.MD.UI.picture.originalSize[0]) * 100 < 20 && _addOver < 200) {
  3006. return;
  3007. } else if (((U.MD.UI.picture.DIVBOX.PICAREA.clientHeight + multiple) / U.MD.UI.picture.originalSize[1]) * 100 > 1000) { /*最大缩放1000%*/
  3008. return
  3009. }
  3010. /*赋值长*/
  3011. U.MD.UI.picture.DIVBOX.PICAREA.style.width = _addOver + 'px';
  3012. /*中心缩放*/
  3013. U.MD.UI.picture.DIVBOX.PICAREA.style.top = U.MD.UI.picture.DIVBOX.PICAREA.offsetTop - (U.MD.UI.picture.DIVBOX.PICAREA.clientHeight - _afterH) / 2 + 'px';
  3014. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft - multiple / 2 + 'px';
  3015. /*ie8,7,中心缩放位移*/
  3016. if (((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/8./i) == "8.") || (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.match(/7./i) == "7.")) && U.MD.UI.picture.rotatenum % 2 !== 0) {
  3017. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 2 - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight / 2 + 'px';
  3018. U.MD.UI.picture.DIVBOX.PICAREA.style.top = U.MD.UI.picture.DIVBOX.PICBOX.clientHeight / 2 - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth / 2 + 'px';
  3019. }
  3020. /*下面都是防止缩放时偏移到窗体外面*/
  3021. var topY = U.MD.UI.picture.DIVBOX.PICAREA.clientHeight + U.MD.UI.picture.DIVBOX.PICAREA.offsetTop <= U.MD.UI.picture.DIVBOX.PICBOX.clientHeight / 8 ||
  3022. ((U.MD.UI.picture.DIVBOX.PICAREA.clientWidth - (U.MD.UI.picture.DIVBOX.PICAREA.clientWidth - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 + U.MD.UI.picture.DIVBOX.PICAREA.offsetTop <= U.MD.UI.picture.DIVBOX.PICBOX.clientHeight / 8) && U.MD.UI.picture.rotatenum % 2 !== 0),
  3023. bottomY = U.MD.UI.picture.DIVBOX.PICAREA.offsetTop >= U.MD.UI.picture.DIVBOX.PICBOX.clientHeight - U.MD.UI.picture.DIVBOX.PICBOX.clientHeight / 8 ||
  3024. ((Math.abs(U.MD.UI.picture.DIVBOX.PICBOX.clientHeight - (U.MD.UI.picture.DIVBOX.PICAREA.clientWidth - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 - U.MD.UI.picture.DIVBOX.PICAREA.offsetTop) <= U.MD.UI.picture.DIVBOX.PICBOX.clientHeight / 8) && U.MD.UI.picture.rotatenum % 2 !== 0),
  3025. leftX = U.MD.UI.picture.DIVBOX.PICAREA.clientWidth + U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft <= U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 8 ||
  3026. (U.MD.UI.picture.DIVBOX.PICAREA.clientHeight + (U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft + (U.MD.UI.picture.DIVBOX.PICAREA.clientWidth - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight / 2) <= U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 8 && U.MD.UI.picture.rotatenum % 2 !== 0),
  3027. rightX = U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft >= U.MD.UI.picture.DIVBOX.PICBOX.clientWidth - U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 8 ||
  3028. ((U.MD.UI.picture.DIVBOX.PICBOX.clientWidth - (U.MD.UI.picture.DIVBOX.PICAREA.clientWidth - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 - U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft) <= U.MD.UI.picture.DIVBOX.PICBOX.clientWidth / 8 && U.MD.UI.picture.rotatenum % 2 !== 0);
  3029. if (topY) {
  3030. if (U.MD.UI.picture.rotatenum % 2 === 0) {
  3031. U.MD.UI.picture.DIVBOX.PICAREA.style.top = U.MD.UI.picture.DIVBOX.PICAREA.offsetTop + (_afterH - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 + 'px';
  3032. } else {
  3033. U.MD.UI.picture.DIVBOX.PICAREA.style.top = U.MD.UI.picture.DIVBOX.PICAREA.offsetTop + (_afterW - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth) / 2 + 'px';
  3034. }
  3035. }
  3036. if (bottomY) {
  3037. if (U.MD.UI.picture.rotatenum % 2 === 0) {
  3038. U.MD.UI.picture.DIVBOX.PICAREA.style.top = U.MD.UI.picture.DIVBOX.PICAREA.offsetTop - (_afterH - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 + 'px';
  3039. } else {
  3040. U.MD.UI.picture.DIVBOX.PICAREA.style.top = U.MD.UI.picture.DIVBOX.PICAREA.offsetTop - (_afterW - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth) / 2 + 'px';
  3041. }
  3042. }
  3043. if (leftX) {
  3044. if (U.MD.UI.picture.rotatenum % 2 === 0) {
  3045. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft + (_afterW - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth) / 2 + 'px';
  3046. } else {
  3047. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft + (_afterH - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 + 'px';
  3048. }
  3049. }
  3050. if (rightX) {
  3051. if (U.MD.UI.picture.rotatenum % 2 === 0) {
  3052. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft - (_afterW - U.MD.UI.picture.DIVBOX.PICAREA.clientWidth) / 2 + 'px';
  3053. } else {
  3054. U.MD.UI.picture.DIVBOX.PICAREA.style.left = U.MD.UI.picture.DIVBOX.PICAREA.offsetLeft - (_afterH - U.MD.UI.picture.DIVBOX.PICAREA.clientHeight) / 2 + 'px';
  3055. }
  3056. }
  3057. U.selectEl('#U_MD_UI_Picture_r')[0].innerText = Math.floor((U.MD.UI.picture.DIVBOX.PICAREA.clientWidth / U.MD.UI.picture.originalSize[0]) * 100) + '%';
  3058. }
  3059. ;
  3060. ///<jscompress sourcefile="Video.js" />
  3061. Namespace.register("U.MD.UI.video"); //注册命名空间
  3062. /**
  3063. * 创建视频
  3064. * @param src 资源地址
  3065. * @param width 视频宽度
  3066. * @param height 视频高度
  3067. * @param autoplay 是否自动播放
  3068. * @param parent 生成在哪个元素
  3069. */
  3070. U.MD.UI.video = function (src, width, height, autoplay, parent) {
  3071. var _autoplay = autoplay || false; //检测自动播放
  3072. var _intervalTemp = null; //用于记录interval的值
  3073. var _volumeTemp = null; //用于记录临时音量(静音与取消静音用)
  3074. var _moving = false; //记录是否有移动
  3075. var _tempHeight = ""; //全屏恢复的临时高度
  3076. var _tempWidth = ""; //全屏恢复的临时宽度
  3077. var _fullscreen = false; //记录是否处于全屏状态
  3078. /*生成元素*/
  3079. var _els = U.MD.UI.video.appendEle(src, width, height, _autoplay, parent);
  3080. /*添加事件*/
  3081. U.MD.UI.video.addEvent(_els, _intervalTemp, _volumeTemp, _moving, height, width, _fullscreen);
  3082. return _els;
  3083. };
  3084. /**
  3085. * 生成元素
  3086. * @param src 视频资源地址
  3087. * @param width 视频宽度
  3088. * @param height 视频高度
  3089. * @param autoplay 是否自动播放
  3090. * @param parent 父元素
  3091. */
  3092. U.MD.UI.video.appendEle = function (src, width, height, autoplay, parent) {
  3093. var els = {};
  3094. //包括视频和控制器的大div
  3095. els.videoDiv = $$("div", { "className": "U_MD_UI_video_VideoDiv", "style": { "width": width + "px", "height": height + "px"} }, parent);
  3096. //视频主体
  3097. els.video = $$("video", {
  3098. "src": src, //视频资源地址
  3099. "className": "U_MD_UI_video_VideoMain", //视频class
  3100. "autoplay": autoplay, //是否自动播放
  3101. "preload": "auto"//是否预加载(默认自动)
  3102. }, els.videoDiv);
  3103. //控制器主体
  3104. els.controls = $$("div", { "className": "U_MD_UI_video_VideoControls" }, els.videoDiv);
  3105. //暂停/播放按钮
  3106. els.playPauseBtn = $$("div", { "className": "U_MD_UI_video_PlayPauseButton U_MD_UI_video_PlayIcon" }, els.controls);
  3107. //显示当前时间的div
  3108. els.currentTimeDiv = $$("div", { "className": "U_MD_UI_video_Time", "innerHTML": "00:00" }, els.controls);
  3109. //进度条
  3110. els.progress = $$("div", { "className": "U_MD_UI_video_Progress" }, els.controls);
  3111. //进度条实际进度
  3112. els.progressCurrentTime = $$("div", { "className": "U_MD_UI_video_ProgressCurrentTime" }, els.progress);
  3113. //进度条上的圆点
  3114. els.progressCircle = $$("div", { "className": "U_MD_UI_video_ProgressCircle" }, els.progressCurrentTime);
  3115. //显示实际时间的div
  3116. els.DurationDiv = $$("div", {
  3117. "className": "U_MD_UI_video_Time", //设置class
  3118. "innerHTML": "00:00", //设置默认值
  3119. "onselectstart": "return false;"//禁止选择
  3120. }, els.controls);
  3121. //音量按钮
  3122. els.soundControls = $$("div", { "className": "U_MD_UI_video_SoundControls" }, els.controls);
  3123. //音量
  3124. els.soundProgress = $$("div", { "className": "U_MD_UI_video_SoundProgress" }, els.controls);
  3125. //真实音量
  3126. els.soundProgressCurrent = $$("div", { "className": "U_MD_UI_video_SoundProgressCurrent", "style": { "width": "100%"} }, els.soundProgress); //设置class
  3127. //全屏按钮
  3128. els.fullScreenBtn = $$("div", { "className": "U_MD_UI_video_FullScreen" }, els.controls);
  3129. return els;
  3130. };
  3131. /**
  3132. * 给元素添加事件
  3133. * @param els 传入所有元素
  3134. * @param intervalTemp 传入intervalTemp
  3135. * @param volumeTemp 传入volumeTemp
  3136. * @param moving 传入moving
  3137. * @param tempHeight 传入tempHeight
  3138. * @param tempWidth 传入tempWidth
  3139. * @param fullscreen 传入fullscreen
  3140. */
  3141. U.MD.UI.video.addEvent = function (els, intervalTemp, volumeTemp, moving, tempHeight, tempWidth, fullscreen) {
  3142. //给暂停/播放按钮添加事件
  3143. els.playPauseBtn.onclick = function (event) {
  3144. U.MD.UI.playPauseBtnClick(event, els);
  3145. };
  3146. if (els.videoDiv.onwebkitfullscreenchange !== undefined) {//设置全屏状态事件(webkit)
  3147. els.videoDiv.onwebkitfullscreenchange = function () {
  3148. var rtn = U.MD.UI.video.fullscreenChange(fullscreen, tempHeight, tempWidth, els);
  3149. fullscreen = rtn[0];
  3150. tempHeight = rtn[1];
  3151. tempWidth = rtn[2];
  3152. }
  3153. }
  3154. else if (els.videoDiv.onfullscreenchange !== undefined) {//设置全屏状态事件(w3)
  3155. els.videoDiv.onfullscreenchange = function () {
  3156. var rtn = U.MD.UI.video.fullscreenChange(fullscreen, tempHeight, tempWidth, els); //设置全屏状态事件(w3)
  3157. fullscreen = rtn[0];
  3158. tempHeight = rtn[1];
  3159. tempWidth = rtn[2];
  3160. }
  3161. } else if (els.videoDiv.onmozfullscreenchange !== undefined) {//设置全屏状态事件(moz)
  3162. els.videoDiv.onmozfullscreenchange = function () {
  3163. var rtn = U.MD.UI.video.fullscreenChange(fullscreen, tempHeight, tempWidth, els);
  3164. fullscreen = rtn[0];
  3165. tempHeight = rtn[1];
  3166. tempWidth = rtn[2];
  3167. }
  3168. }
  3169. /**
  3170. * 全屏按钮单击事件
  3171. */
  3172. els.fullScreenBtn.onclick = function () {
  3173. U.MD.UI.video.fullscreenClick(fullscreen, els);
  3174. };
  3175. /**
  3176. * 进度条圆点按下事件
  3177. * @param event 按下事件
  3178. */
  3179. els.progressCircle.onmousedown = function (event) {
  3180. U.MD.UI.video.circleMove(event, moving, els);
  3181. };
  3182. /**
  3183. * 音量条鼠标按下事件
  3184. * @param event 事件
  3185. */
  3186. els.soundProgress.onmousedown = function (event) {
  3187. U.MD.UI.video.soundProgressMove(event, els, moving); //执行soundProgressMove函数
  3188. };
  3189. /**
  3190. * 进度条鼠标按下事件
  3191. * @param event 事件
  3192. */
  3193. els.progress.onmousedown = function (event) {
  3194. U.MD.UI.video.progressMove(event, els, moving); //进度条按下移动函数(点击进度条除圆点以外的地方)
  3195. };
  3196. /**
  3197. * 视频暂停事件,用于设置暂停按钮与停止刷新
  3198. */
  3199. els.video.onpause = function () {
  3200. els.playPauseBtn.className = "U_MD_UI_video_PlayPauseButton U_MD_UI_video_PlayIcon"; //设置暂停按钮的icon(修改class)
  3201. clearInterval(intervalTemp); //清除刷新的interval
  3202. };
  3203. /**
  3204. * 视频播放事件,用于设置播放按钮与启动刷新
  3205. */
  3206. els.video.onplay = function () {
  3207. els.playPauseBtn.className = "U_MD_UI_video_PlayPauseButton U_MD_UI_video_PauseIcon"; //设置开始按钮的icon(修改class)
  3208. intervalTemp = U.MD.UI.video.setInterval(moving, els); //启动刷新
  3209. };
  3210. /**
  3211. * 视频可以播放,刷新数据
  3212. */
  3213. els.video.oncanplay = function () {
  3214. U.MD.UI.video.flushInfo(moving, els.currentTimeDiv, els.DurationDiv, els.progressCurrentTime, els.soundProgressCurrent, els.video); //刷新信息
  3215. };
  3216. /**
  3217. * 静音按钮事件函数
  3218. */
  3219. els.soundControls.onclick = function () {
  3220. volumeTemp = U.MD.UI.video.muteClick(els, volumeTemp, moving);
  3221. };
  3222. /**
  3223. * 控制栏显示/隐藏控制
  3224. */
  3225. els.videoDiv.onclick = function () {
  3226. //U.MD.UI.video.displayControls(event, els);
  3227. };
  3228. };
  3229. /**
  3230. * 让控制栏可以隐藏
  3231. * @param event 视频点击事件
  3232. * @param els 元素集合
  3233. */
  3234. U.MD.UI.video.displayControls = function (event, els) {
  3235. var _target = event.target; //获取目标
  3236. if (_target === els.video || _target === els.videoDiv) {//判断目标点击后是否可以隐藏/显示
  3237. if (els.controls.style.display === "none") {//如果已设置隐藏状态则显示
  3238. els.controls.style.display = "block";
  3239. } else {//否则隐藏控制栏
  3240. els.controls.style.display = "none";
  3241. }
  3242. }
  3243. };
  3244. U.MD.UI.playPauseBtnClick = function (event, els) {
  3245. var _el = event.target; //获取到按钮本身
  3246. if (_el.className === "U_MD_UI_video_PlayPauseButton U_MD_UI_video_PlayIcon") {//暂停状态
  3247. els.video.play(); //开始播放
  3248. }
  3249. else {//播放状态
  3250. els.video.pause(); //暂停播放
  3251. }
  3252. };
  3253. /**
  3254. * 静音按钮
  3255. * @param els 元素集合
  3256. * @param volumeTemp 临时记录音量
  3257. * @param moving 记录是否正在移动(刷新数据用)
  3258. * @returns {*} 返回volumeTemp
  3259. */
  3260. U.MD.UI.video.muteClick = function (els, volumeTemp, moving) {
  3261. if (els.video.volume !== 0) {//音量非零,静音
  3262. volumeTemp = els.video.volume; //记录当前音量
  3263. els.video.volume = 0; //静音
  3264. U.MD.UI.video.flushInfo(moving, els.currentTimeDiv, els.DurationDiv, els.progressCurrentTime, els.soundProgressCurrent, els.video); //刷新信息
  3265. } else if (els.video.volume === 0 && volumeTemp !== null) {//如果音量等于0(即静音),且用户没有按过静音键
  3266. els.video.volume = volumeTemp; //设置音量
  3267. volumeTemp = null; //将变量值重置
  3268. U.MD.UI.video.flushInfo(moving, els.currentTimeDiv, els.DurationDiv, els.progressCurrentTime, els.soundProgressCurrent, els.video); //刷新信息
  3269. }
  3270. return volumeTemp; //返回volumeTemp
  3271. };
  3272. /**
  3273. * 全屏按钮点击事件
  3274. * @param fullscreen 是否全屏
  3275. * @param els 元素集合
  3276. */
  3277. U.MD.UI.video.fullscreenClick = function (fullscreen, els) {
  3278. if (!fullscreen) {//如果没全屏
  3279. if (els.videoDiv.requestFullScreen) {//请求全屏(w3)
  3280. els.videoDiv.requestFullScreen(); //请求全屏(w3)
  3281. }
  3282. else if (els.videoDiv.webkitRequestFullScreen) {//请求全屏(webkit)
  3283. els.videoDiv.webkitRequestFullScreen(); //请求全屏(webkit)
  3284. }
  3285. else if (els.videoDiv.mozRequestFullScreen) {//请求全屏(moz)
  3286. els.videoDiv.mozRequestFullScreen(); //请求全屏(moz)
  3287. }
  3288. } else {//如果已全屏
  3289. if (document.exitFullScreen) {//取消全屏(w3)
  3290. document.exitFullScreen(); //取消全屏(w3)
  3291. }
  3292. else if (document.webkitCancelFullScreen) {//取消全屏(webkit)
  3293. document.webkitCancelFullScreen(); //取消全屏(webkit)
  3294. }
  3295. else if (document.webkitExitFullscreen) {//取消全屏(webkit)
  3296. document.webkitExitFullscreen(); //取消全屏(webkit)
  3297. }
  3298. else if (document.mozExitFullScreen) {//取消全屏(moz)
  3299. document.mozExitFullScreen(); //取消全屏(moz)
  3300. }
  3301. }
  3302. };
  3303. /**
  3304. * 全屏状态改变事件
  3305. * @param fullscreen 记录是否全屏
  3306. * @param tempHeight 临时高度
  3307. * @param tempWidth 临时宽度
  3308. * @param els 元素集合
  3309. * @returns {*[]} 返回部分改变后的变量
  3310. */
  3311. U.MD.UI.video.fullscreenChange = function (fullscreen, tempHeight, tempWidth, els) {
  3312. if (!fullscreen) {//如果没全屏,则进行全屏准备操作
  3313. //tempHeight = els.videoDiv.offsetHeight + "px";//备份视频div高度
  3314. //tempWidth = els.videoDiv.offsetWidth + "px";//备份视频div宽度
  3315. els.videoDiv.style.height = "100vh"; //100vh为覆盖整个页面
  3316. els.videoDiv.style.width = "100vw"; //100vw为覆盖整个页面
  3317. els.videoDiv.style.position = "absolute"; //将视频设置绝对定位
  3318. els.videoDiv.style.top = "0"; //移动到最上
  3319. els.videoDiv.style.left = "0"; //移动到最左
  3320. els.videoDiv.style.zIndex = "999"; //设置zIndex最高
  3321. } else {//退出全屏
  3322. els.videoDiv.style.height = tempHeight + "px"; //恢复高度
  3323. els.videoDiv.style.width = tempWidth + "px"; //恢复宽度
  3324. els.videoDiv.style.position = ""; //清除绝对定位
  3325. els.videoDiv.style.top = ""; //清除top属性
  3326. els.videoDiv.style.left = ""; //清除left属性
  3327. els.videoDiv.style.zIndex = ""; //清除zIndex属性
  3328. }
  3329. fullscreen = !fullscreen; //设置全屏状态
  3330. return [fullscreen, tempHeight, tempWidth];
  3331. };
  3332. /**
  3333. * 时间格式化(数字秒转换成00:00的格式)
  3334. * @param time 待转换的时间(秒) 例:30
  3335. * @returns {string} 返回的时间 例:00:30
  3336. */
  3337. U.MD.UI.video.timeFormat = function (time) {
  3338. var _sec = parseInt(time % 60); //计算秒
  3339. var _min = parseInt(parseInt(time) / 60); //计算分钟
  3340. (_sec < 10) ? _sec = "0" + _sec : _sec; //秒补零
  3341. (_min < 10) ? _min = "0" + _min : _min; //分钟补零
  3342. return _min + ":" + _sec; //返回生成的时间
  3343. };
  3344. /**
  3345. * 刷新数据
  3346. * @param moving 是否正在移动(用于判断要不要刷新)
  3347. * @param currentTimeDiv 当前时间元素
  3348. * @param DurationDiv 视频总长度元素
  3349. * @param progressCurrentTime 进度条当前长度
  3350. * @param soundProgressCurrent 音量当前长度
  3351. * @param video 视频元素
  3352. */
  3353. U.MD.UI.video.flushInfo = function (moving, currentTimeDiv, DurationDiv, progressCurrentTime, soundProgressCurrent, video) {
  3354. if (moving) return; //如果在拖动则不刷新
  3355. currentTimeDiv.innerHTML = U.MD.UI.video.timeFormat(video.currentTime); //当前时间刷新
  3356. DurationDiv.innerHTML = U.MD.UI.video.timeFormat(video.duration); //视频总长度刷新
  3357. progressCurrentTime.style.width = video.currentTime / video.duration * 100 + "%"; //进度条刷新
  3358. soundProgressCurrent.style.width = video.volume * 100 + "%"; //音量刷新
  3359. };
  3360. /**
  3361. * 获取当前元素左边到屏幕最左边的距离
  3362. * @param el 元素
  3363. * @returns {number} 返回距离(不包括单位)
  3364. */
  3365. U.MD.UI.video.getScreenLeft = function (el) {
  3366. var _rtnLeft = el.offsetLeft; //定义一个左边长度
  3367. var _parent = el.offsetParent; //定义这个元素的父元素
  3368. while (_parent != null) {//如果父元素不为空,则进入循环
  3369. _rtnLeft += _parent.offsetLeft; //记录左边距离
  3370. _parent = _parent.offsetParent; //重新定义父元素
  3371. }
  3372. return _rtnLeft; //返回距离
  3373. };
  3374. /**
  3375. * 循环刷新信息
  3376. * @param _moving 是否正在移动
  3377. * @param _els 元素
  3378. * @returns {number} interval
  3379. */
  3380. U.MD.UI.video.setInterval = function (_moving, _els) {
  3381. return setInterval(function () {//设置定时器
  3382. U.MD.UI.video.flushInfo(_moving, _els.currentTimeDiv, _els.DurationDiv, _els.progressCurrentTime, _els.soundProgressCurrent, _els.video); //刷新信息
  3383. }, 500); //每半秒刷新一次
  3384. };
  3385. /**
  3386. * 进度条(圆点)移动事件函数
  3387. * @param event 鼠标按下事件
  3388. * @param moving 是否正在移动
  3389. * @param els 元素
  3390. */
  3391. U.MD.UI.video.circleMove = function (event, moving, els) {//进度条移动函数(圆点)
  3392. moving = true; //设置移动状态
  3393. var _e = event; //读取event
  3394. var _content = event.currentTarget; //获取目标
  3395. var _startX = _e.pageX; //设置一个开始的x点
  3396. var _currentProgress = _content.parentElement; //获取当前进度条元素
  3397. var _progress = _currentProgress.parentElement; //获取进度条元素
  3398. els.videoDiv.onmousemove = function (e) {
  3399. if (e.pageX - U.MD.UI.video.getScreenLeft(_progress) < 0 || e.pageX - U.MD.UI.video.getScreenLeft(_progress) > _progress.offsetWidth) {//如果鼠标位置不在有效范围内则不继续
  3400. return;
  3401. }
  3402. var _iL = e.pageX - _startX; //移动的距离
  3403. //根据实际进度与进度条长度对比进行判断
  3404. if (!(_currentProgress.offsetWidth + _iL > _progress.offsetWidth || _currentProgress.offsetWidth + _iL < 0) && (e.currentTarget.children[0].offsetWidth <= e.currentTarget.children[0].offsetWidth)) {
  3405. //设置进度条位置
  3406. _currentProgress.style.width = (_currentProgress.offsetWidth + _iL) / _progress.offsetWidth * 100 + "%";
  3407. //设置视频位置
  3408. els.video.currentTime = (_currentProgress.offsetWidth + _iL) / _progress.offsetWidth * els.video.duration;
  3409. }
  3410. _startX = e.pageX; //重置开始的x点
  3411. };
  3412. els.videoDiv.onmouseup = function () {//清除事件
  3413. moving = false; //恢复移动状态
  3414. els.videoDiv.onmousemove = function () {//清除移动事件
  3415. };
  3416. els.videoDiv.onmouseup = function () {//清除mouseup事件
  3417. };
  3418. };
  3419. };
  3420. /**
  3421. * 声音进度条拖动函数
  3422. * @param event 事件
  3423. * @param els 元素集合
  3424. * @param moving 是否正在移动
  3425. */
  3426. U.MD.UI.video.soundProgressMove = function (event, els, moving) {//注释见move函数
  3427. event.preventDefault(); //取消事件的默认动作
  3428. var _e = event; //声明event
  3429. var _content = event.currentTarget; //获取soundprogress
  3430. var _startX = _e.pageX; //设置一个开始的x点
  3431. var _currentSound = els.soundProgressCurrent; //当前的音量条元素
  3432. var _x = event.offsetX; //获取现在鼠标相对于音量条的x点
  3433. var _length = _content.offsetWidth; //获取音量条的长度
  3434. els.video.volume = _x / _length; //设置视频音量
  3435. U.MD.UI.video.flushInfo(moving, els.currentTimeDiv, els.DurationDiv, els.progressCurrentTime, els.soundProgressCurrent, els.video); //刷新信息
  3436. /**
  3437. * mousemove函数
  3438. * @param e 事件
  3439. */
  3440. els.videoDiv.onmousemove = function (e) {
  3441. if (e.pageX - U.MD.UI.video.getScreenLeft(els.soundProgress) < 0 || e.pageX - U.MD.UI.video.getScreenLeft(els.soundProgress) > els.soundProgress.offsetWidth) {//如果鼠标位置不在有效范围内则不继续
  3442. return; //返回
  3443. }
  3444. var _iL = e.pageX - _startX; //移动的长度
  3445. if (!(_currentSound.offsetWidth + _iL > _content.offsetWidth || _currentSound.offsetWidth + _iL < 0)) {//判断是否应该移动
  3446. _currentSound.style.width = (_currentSound.offsetWidth + _iL) / _content.offsetWidth * 100 + "%"; //设置样式(进度条长度)
  3447. els.video.volume = _currentSound.offsetWidth / _content.offsetWidth; //设置音量
  3448. }
  3449. _startX = e.pageX; //重置开始的x点
  3450. };
  3451. els.videoDiv.onmouseup = function (e) {
  3452. els.videoDiv.onmousemove = function () {//清除mousemove事件
  3453. };
  3454. els.videoDiv.onmouseup = function () {//清除mouseup事件
  3455. };
  3456. };
  3457. };
  3458. /**
  3459. * 进度条拖动函数
  3460. * @param event 事件
  3461. * @param els 元素集合
  3462. * @param moving 是否正在移动
  3463. */
  3464. U.MD.UI.video.progressMove = function (event, els, moving) {//部分注释见move函数
  3465. event.preventDefault(); //清除默认事件
  3466. if (event.target.className === "U_MD_UI_video_ProgressCircle") {//如果class是圆点的话返回
  3467. return;
  3468. }
  3469. var _e = event; //记录event
  3470. var _content = event.currentTarget; //获取进度条元素
  3471. var _startX = _e.pageX; //定义起点
  3472. var _currentProgress = els.progressCurrentTime; //定义进度条(当前)元素
  3473. var _x = event.layerX || event.offsetX; //鼠标点击的点
  3474. var _length = _content.offsetWidth; //进度条长度
  3475. els.video.currentTime = els.video.duration * (_x / _length); //计算出百分比并设置时间
  3476. U.MD.UI.video.flushInfo(moving, els.currentTimeDiv, els.DurationDiv, els.progressCurrentTime, els.soundProgressCurrent, els.video); //刷新信息
  3477. els.videoDiv.onmousemove = function (e) {//鼠标移动事件
  3478. if (e.pageX - U.MD.UI.video.getScreenLeft(els.progress) < 0 || e.pageX - U.MD.UI.video.getScreenLeft(els.progress) > els.progress.offsetWidth) {//鼠标不在范围内则不继续
  3479. return;
  3480. }
  3481. moving = true; //设置移动状态
  3482. var _iL = e.pageX - _startX; //移动的长度
  3483. if (!(_currentProgress.offsetWidth + _iL > els.progress.offsetWidth || _currentProgress.offsetWidth + _iL < 0)) {//判断加上移动距离后是否合理
  3484. _currentProgress.style.width = (_currentProgress.offsetWidth + _iL) / els.progress.offsetWidth * 100 + "%"; //设置当前进度条的样式(宽度)
  3485. els.video.currentTime = (_currentProgress.offsetWidth + _iL) / els.progress.offsetWidth * els.video.duration; //设置视频现在播放时间
  3486. }
  3487. _startX = e.pageX; //重新设置开始的点
  3488. };
  3489. els.videoDiv.onmouseup = function () {//鼠标点击事件
  3490. moving = false; //设置移动状态
  3491. U.MD.UI.video.flushInfo(moving, els.currentTimeDiv, els.DurationDiv, els.progressCurrentTime, els.soundProgressCurrent, els.video); //刷新信息
  3492. els.videoDiv.onmousemove = function () {//清除事件
  3493. };
  3494. els.videoDiv.onmouseup = function () {//清除事件
  3495. };
  3496. };
  3497. };
  3498. ;
  3499. ///<jscompress sourcefile="BTree.js" />
  3500. Namespace.register("U.MD.UI.BTree");
  3501. //json要求:
  3502. //里面需要包含id,name,deep(依赖),img_url(显示图片源),child(附属目录),为一个数值,每一个值为一个json,child的格式也是一样
  3503. //案例
  3504. // [{ id: "1", name: "文件夹", deep: 0, img_url: 'http://api.1473.cn/Uform/Image/tree/folder.png',
  3505. //child: [{ id: "2", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png",
  3506. // child: [{ id: "5", name: "文件夹", deep: 2, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  3507. // },
  3508. //{ id: "3", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png" },
  3509. //{ id: "4", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  3510. //}]
  3511. //var json = [{ id: "1", name: "文件夹", deep: 0, img_url: 'http://api.1473.cn/Uform/Image/tree/folder.png',
  3512. // child: [{ id: "2", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png",
  3513. // child: [{ id: "5", name: "文件夹", deep: 2, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  3514. // },
  3515. // { id: "3", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png" },
  3516. //{ id: "4", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  3517. //},{ id: "6", name: "文件夹", deep: 0, img_url: 'http://api.1473.cn/Uform/Image/tree/folder.png', child: [{ id: "8", name: "文件夹", deep: 6, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png",
  3518. // child: [{ id: "9", name: "文件夹", deep: 8, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  3519. // },
  3520. // { id: "10", name: "文件夹", deep: 6, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png" },
  3521. //{ id: "11", name: "文件夹", deep: 6, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]},{ id: "7", name: "文件夹", deep: 0, img_url: 'http://api.1473.cn/Uform/Image/tree/folder.png',}];
  3522. /*
  3523. 开始方法一,用来生成树和后台管理页面
  3524. arr {arr} 要解析的json arr对象
  3525. bookfun {function} 点击事件
  3526. dateDeleteFun {function} date的删除方法
  3527. dateUpdateFun {function} date的修改方法
  3528. dateInsertFun {function} date的添加方法
  3529. tree {object} 右侧要插入后台li的地方
  3530. directory {object} 要插入后台li的地方
  3531. list {object} 左侧放添加标签的的地方
  3532. listimg {String} 后台页面的img
  3533. deteimg {String} 是否启用删除标签的图片
  3534. upimg {String} 是否启用修改标签的图片
  3535. */
  3536. U.MD.UI.BTree = function (arr, bookfun, dateDeleteFun, dateUpdateFun, dateInsertFun, tree, directory, list, listimg, deteimg, upimg) {
  3537. U.MD.UI.BTree.jsonStartLeft(arr, tree[0], bookfun); //调用方法,生成树状图
  3538. U.MD.UI.BTree.jsonStartRight(tree[1], bookfun, dateDeleteFun, dateUpdateFun, dateInsertFun, directory, list, listimg, deteimg, upimg); //调用方法,生成管理页面
  3539. }
  3540. /*
  3541. 将二维数组转化为列表的方法
  3542. json {arr} 数据源json里面需要包含id,name,deep(依赖),img_url(显示图片源),child(附属目录),外部是数组
  3543. tree {object} 要插入列表的地方
  3544. bookfun {function} 没一行的点击事件
  3545. */
  3546. U.MD.UI.BTree.treeCreate = function (json, tree, onclickfun) {
  3547. for (var _i = 0; _i < json.length; _i++) { //创建循环,解析json数组,得到每一个json
  3548. var _ul = $$("ul", { className: "U_MD_UI_Tree_a " + json[_i].parentID }, tree); //创建var对象,在tree中创建ul
  3549. var _li = $$("li", { id: json[_i].id, parentid: json[_i].parentid, className: "U_MD_UI_Tree_listyle", parentid: json[_i].id, deep: json[_i].deep }, _ul); //创建var对象,在ul中创建li,id为a+jsonid
  3550. var _img = $$("img", { "onerror": U.MD.C.imgError, src: json[_i].img_url, className: "U_MD_UI_Tree_imgstyle" }, _li); //创建var对象,在li中创建img
  3551. var _span = $$("span", { innerHTML: json[_i].name, className: "spanstyle" }, _li); //创建var对象,在li中创建span,内容为json的name
  3552. _ul.style.display = "none";
  3553. if (json[_i].deep == "1") { _ul.style.display = "block" } //进行判断,判断是否为一级目录,不是的先隐藏
  3554. _img.aa = false; //定义img的一个变量,用来控制列表的展开和关闭
  3555. var _liobj = document.getElementsByClassName("U_MD_UI_Tree_a " + json[_i].parentID)[0]; //定义一个let对象为获取到的对应的li对象
  3556. _ul.style.display = _liobj.style.display; //如果是展开状态,显示ul
  3557. _li.onclick = function () {//定义li的点击事件
  3558. onclickfun(this); //执行bookconlick函数,改变book对象的内容
  3559. _liobj = document.getElementsByClassName("U_MD_UI_Tree_a " + this.parentid);
  3560. if (_img.aa === true) { //如果img.aa等于true
  3561. _img.aa = false; //修改img.aa对象为false
  3562. for (var _ii = 0; _ii < _liobj.length; _ii++) { //定义循环,循环对象为获取到的li对象集合
  3563. _liobj[_ii].style.display = "none"; //将集合隐藏
  3564. }
  3565. } else { //如果img.aa等于false
  3566. _img.aa = true; //修改img.aa等于true
  3567. for (var _ii = 0; _ii < _liobj.length; _ii++) { //定义循环,循环对象为获取到的li对象集合
  3568. _liobj[_ii].style.display = "block"; //将集合显示
  3569. }
  3570. }
  3571. }
  3572. if (json[_i].child) {
  3573. U.MD.UI.BTree.treeCreate(json[_i].child, _ul, onclickfun); //重新调用函数,参数为child的对象数组,ul对象,20的边距值,隐藏,改变的book对象
  3574. }
  3575. }
  3576. }
  3577. /*
  3578. 在json中查找指定id下的child
  3579. json {arr} 要查找的arr对象
  3580. parentID {String} 要查找的id
  3581. */
  3582. U.MD.UI.BTree.JsonSelect = function (json, parentID) {
  3583. var _json = []; //创建一个变量_json,来接收筛选后的json
  3584. for (var _i = 0; _i < json.length; _i++) {//创建循环,循环对象为json
  3585. if (parentID == 0) { //判断parentID是否为0,如果是
  3586. return json; //返回json
  3587. } //如果不是
  3588. if (json[_i].id == parentID) {//判断json中各个对象的id是否与parentID相等,如果是
  3589. _json = json[_i].child; //变量_json等于json中对应对象的child值
  3590. return _json; //返回变量_json
  3591. } //如果不是
  3592. if (json[_i].child) { //判断json中对象是否有child值,如果有
  3593. var _return = U.MD.UI.BTree.JsonSelect(json[_i].child, parentID); //定义变量_return 值为调用方法本身的返回值
  3594. }
  3595. }
  3596. return _return; //返回_return
  3597. }
  3598. /*
  3599. 创建查询管理目录的方法
  3600. json {arr} 要解析的json arr对象
  3601. tree {object} 左侧要插入后台li的地方
  3602. list {object} 左侧放添加标签的的地方
  3603. jsonpid {String} 添加标签的深度
  3604. jsondelete {function} json的删除方法
  3605. jsonupdate {function} json的修改方法
  3606. jsonadd {function} json的添加方法
  3607. deteurl {String} 是否启用删除标签的图片
  3608. upurl {String} 是否启用修改标签的图片
  3609. i {String} tree的对象值,控制下一级
  3610. j {String} tree的对象值,控制上一级
  3611. */
  3612. U.MD.UI.BTree.DirectoryCreate = function (json, tree, list, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i, j) {
  3613. if (i == 0) { //判断是否载入第一层,如果是
  3614. list[1].style.display = "none"; //隐藏二级目录
  3615. list[2].style.display = "none"; //隐藏三级目录
  3616. } else { //如果不是载入第一层目录
  3617. list[2].style.display = "none"; //将三级目录隐藏
  3618. list[i].style.display = "block"; //显示对应级目录
  3619. }
  3620. var _buttonText = "修改"; //定义变量_buttonText,代表修改按钮的默认值
  3621. var _button1Text = "删除"; //定义变量_button1Text,代表删除按钮的默认值
  3622. if (deteurl && upurl) { //进行判断,是否提供默认按钮,如果不是
  3623. _buttonText = ""; //消除_buttonText
  3624. _button1Text = ""; //消除_button1Text
  3625. }
  3626. tree[i].innerHTML = ""; //将tree中的内容清空
  3627. list[i].parentID = jsonpid; //给list定义一个变量
  3628. list[i].deep = i + 1; //给list定义深度变量
  3629. if (j) { //判断是否有输入上一级
  3630. tree[j].innerHTML = ""; //如果有,清空上一级
  3631. }
  3632. if (json) { //如果json存在
  3633. for (var _i = 0; _i < json.length; _i++) { //创建循环,循环对象为json
  3634. var _ul = $$("ul", { className: "U_MD_UI_Tree_styleul", parentid: json[_i].parentID, deep: json[_i].deep }, tree[i]); //创建在tree中创建ul
  3635. var _li = $$("li", { className: "U_MD_UI_Tree_styleli", innerHTML: json[_i].name, parentid: json[_i].id }, _ul); //创建li在tree的下一级中,css为styleli
  3636. var _button = $$("input", { type: "button", pid: json[_i].id, parentid: json[_i].parentID, innerHTML: _buttonText, className: "U_MD_UI_Tree_button" }, _ul); //创建修改button在在li中,css为stylebutton
  3637. var _button1 = $$("input", { type: "button", pid: json[_i].id, parentid: json[_i].parentID, innerHTML: _button1Text, className: "U_MD_UI_Tree_button1" }, _ul); //创建删除button在在li中,css为stylebutton
  3638. //创建删除button在在li中,css为stylebutton
  3639. _button.onclick = function () { //给修改按钮定义onclick事件
  3640. jsonupdate(this, tree, list, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i); //事件为调用jsonupdate方法,输入this为变量
  3641. }
  3642. _button1.onclick = function () { //给删除按钮定义oncick事件
  3643. jsondelete(this, tree, list, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i); //事件为调用jsondelete方法,输入this为变量
  3644. }
  3645. _li.onclick = function () { //给li定义onclick事件
  3646. if (j) { //判断j是否存在,如果存在
  3647. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, this.parentid), tree, list, this.parentid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, j); //调用方法,创建下一级的下一级目录
  3648. } else { //如果不存在
  3649. if (i == 2) { //判断是否到三级目录
  3650. } else { //如果还没到
  3651. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, this.parentid), tree, list, this.parentid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 1, 2); //调用方法,创建下一级的下一级目录
  3652. }
  3653. }
  3654. }
  3655. }
  3656. }
  3657. var add = U.selectEl(".U_MD_UI_Tree_add");
  3658. if (add[i]) { //进行判断,当添加标签已存在时
  3659. list[i].removeChild(add[i]); //销毁添加标签
  3660. }
  3661. var _div = $$("div", { className: "U_MD_UI_Tree_add", innerHTML: "添加新分类" }, list[i]); //创建添加标签
  3662. _div.onclick = function () { //设置添加标签的点击事件
  3663. jsonadd(this, tree, list, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i); //调用添加方法,进行添加
  3664. }
  3665. }
  3666. /*
  3667. 在json中插入json的方法
  3668. json {arr} 要被插入的json对象
  3669. addjson {json} 要查入的json对象
  3670. */
  3671. U.MD.UI.BTree.jsonAdd = function (json, addjson) {
  3672. var _addid = addjson.parentID; //定义要目的地id,等于插入json的parentID值
  3673. if (_addid == "0") { //进行判断,判断目的地id是否在第一层(0)
  3674. json[json.length] = addjson; //如果在,直接在json的第一层中加入要插入的json
  3675. return json; //结束方法,返回json对象
  3676. }
  3677. for (var _i = 0; _i < json.length; _i++) { //创建循环,解析json数组,得到每一个json
  3678. if (json[_i].id == _addid) { //进行判断,判断json的id是否等于获取到的目的地id,如果是
  3679. if (json[_i].child) { //进行判断,判断json的child有没有值
  3680. json[_i].child[json[_i].child.length] = addjson; //如果有,就在其中添加插入对象
  3681. return json; //结束方法,返回json对象
  3682. } else {//如果json中没有child
  3683. json[_i].child = [];
  3684. json[_i].child[json[_i].child.length] = addjson; //将json的child等于插入的对象
  3685. return json; //结束方法,返回json对象
  3686. }
  3687. }
  3688. if (json[_i].child) { //如果json的id不与目的地id相等且json中存在child
  3689. var _return = U.MD.UI.BTree.jsonAdd(json[_i].child, addjson); //定义函数,调用自己,变量为json的child,要插入的json
  3690. json[_i].child = _return; //json的child等于返回的json
  3691. }
  3692. }
  3693. return json; //返回json对象
  3694. }
  3695. /*
  3696. 开始方法二,生成后台管理页面
  3697. arr {arr} 要解析的json arr对象
  3698. bookfun {function} 点击事件
  3699. jsonDeleteFun {function} json的删除方法
  3700. jsonUpdateFun {function} json的修改方法
  3701. jsonInsertFun {function} json的添加方法
  3702. tree {object} 右侧要插入后台li的地方
  3703. directory {object} 要插入后台li的地方
  3704. mulu {object} 左侧放添加标签的的地方
  3705. muluimg {String} 后台页面的img
  3706. deteimg {String} 是否启用删除标签的图片
  3707. upimg {String} 是否启用修改标签的图片
  3708. */
  3709. U.MD.UI.BTree.jsonStartA = function (arr, bookfun, jsonDeleteFun, jsonUpdateFun, jsonInsertFun, tree, directory, mulu, muluimg, deteimg, upimg) {
  3710. json = []; //将外变量josn清空
  3711. var _json = arr; //定义局部变量_json,值为r
  3712. for (var _i = 0; _i < _json.length; _i++) { //定义循环,循环对象为
  3713. U.MD.UI.BTree.jsonAdd(json, _json[_i]); //运行函数,生成json
  3714. }
  3715. tree.innerHTML = ""; //清空tree的内容
  3716. U.MD.UI.BTree.jsonStartRight(tree, bookfun, jsonDeleteFun, jsonUpdateFun, jsonInsertFun, directory, mulu, muluimg, deteimg, upimg); //调用方法,生成管理页面
  3717. }
  3718. /*
  3719. 生成后台管理页面及管理页面li
  3720. tree {object} 右侧要插入后台li的地方
  3721. bookfun {function} 点击事件
  3722. jsonDeleteFun {function} json的删除方法
  3723. jsonUpdateFun {function} json的修改方法
  3724. jsonInsertFun {function} json的添加方法
  3725. directory {object} 要插入后台li的地方
  3726. mulu {object} 左侧放添加标签的的地方
  3727. muluimg {String} 后台页面的img
  3728. deteimg {String} 是否启用删除标签的图片
  3729. upimg {String} 是否启用修改标签的图片
  3730. */
  3731. U.MD.UI.BTree.jsonStartRight = function (tree, bookfun, jsonDeleteFun, jsonUpdateFun, jsonInsertFun, directory, mulu, muluimg, deteimg, upimg) {
  3732. var _ul = $$("ul", { className: "U_MD_UI_Tree_a " }, tree); //创建对象,在tree中创建ul
  3733. var _li = $$("li", { className: "U_MD_UI_Tree_listyle", yid: "1" }, _ul); //创建对象,在ul中创建li,id为a+jsonid
  3734. var _img = $$("img", { "onerror": U.MD.C.imgError, src: muluimg, className: "U_MD_UI_Tree_imgstyle" }, _li); //创建对象,在li中创建img
  3735. var _span = $$("span", { innerHTML: "目录管理", className: "U_MD_UI_Tree_spanstyle" }, _li); //创建对象 在li中创建span
  3736. _li.onclick = function () { //设置li的点击事件
  3737. bookfun(this); //先执行点击事件
  3738. U.MD.UI.BTree.DirectoryCreate(json, directory, mulu, 0, //运行方法,生成后台页面
  3739. function (objects, tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i) {
  3740. var _ret = jsonDeleteFun(objects.pid); //运行删除方法
  3741. if (_ret) {//如果返回了方法
  3742. json = U.MD.UI.BTree.jsonDelete(json, objects.pid); //运行方法,修改json
  3743. var _id = U.selectEl("#" + objects.pid)[0]; //获取修改对象
  3744. if (_id) { _id.parentNode.remove(); } //如果有对象,修删除
  3745. if (i == 1) {
  3746. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, objects.parentid), tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 1, 2);
  3747. } //刷新二级页面
  3748. if (i == 2) {
  3749. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, objects.parentid), tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 2);
  3750. } //刷新三级页面
  3751. if (i == 0) {
  3752. U.MD.UI.BTree.DirectoryCreate(json, tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 0);
  3753. } //修改一级页面
  3754. }
  3755. },
  3756. function (objects, tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i) {
  3757. var _ret = jsonUpdateFun(U.MD.UI.BTree.jsonSelectA(json, objects.pid)); //运行修改方法
  3758. json = U.MD.UI.BTree.jsonUpdate(json, _ret); //运行方法,修改json
  3759. var _id = U.selectEl("#" + objects.pid)[0]; //获取修改对象
  3760. if (_id) {
  3761. _id.childNodes[0].src = _ret.img_url; //修改对象
  3762. _id.childNodes[1].innerHTML = _ret.name; //修改对象
  3763. }
  3764. if (i == 1) {
  3765. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, objects.parentid), tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 1, 2);
  3766. } //刷新二级页面
  3767. if (i == 2) {
  3768. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, objects.parentid), tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 2);
  3769. } //刷新三级页面
  3770. if (i == 0) {
  3771. U.MD.UI.BTree.DirectoryCreate(json, tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 0);
  3772. } //修改一级页面
  3773. },
  3774. function (objects, tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, i) {
  3775. var _json = {}; //定义变量
  3776. _json.parentID = objects.parentNode.parentID; //获取添加的parentid
  3777. _json.deep = objects.parentNode.deep; //获取添加的deep
  3778. var _ret = jsonInsertFun(_json); //运行添加方法
  3779. var _post; //定义局部对象
  3780. if (_ret) {//如果有返回值
  3781. _post = U.selectEl(".U_MD_UI_Tree_a")[1];
  3782. if (_post) {//判断前台树是否存在
  3783. if (_ret.parentID == 0) {//如果要插入的是一级目录
  3784. _post = U.selectEl(".U_MD_UI_Tree_a")[0].parentNode; //获取一级对象
  3785. } else {
  3786. _post = U.selectEl("#" + _ret.parentID)[0].parentNode; //获取对应对象
  3787. }
  3788. _js = []; //定义局部对象
  3789. _js[0] = _ret; //给对象定值
  3790. U.MD.UI.BTree.treeCreate(_js, _post, bookfun); //创建li
  3791. }
  3792. json = U.MD.UI.BTree.jsonAdd(json, _ret); //刷新json
  3793. if (i == 1) {
  3794. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, _json.parentID), tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 1, 2);
  3795. } //刷新二级页面
  3796. if (i == 2) {
  3797. U.MD.UI.BTree.DirectoryCreate(U.MD.UI.BTree.JsonSelect(json, _json.parentID), tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 2);
  3798. } //刷新三级页面
  3799. if (i == 0) {
  3800. U.MD.UI.BTree.DirectoryCreate(json, tree, mulu, jsonpid, jsondelete, jsonupdate, jsonadd, deteurl, upurl, 0);
  3801. } //修改一级页面
  3802. }
  3803. }, deteimg, upimg, 0); //调用方法,生成一级目录
  3804. }
  3805. }
  3806. /*
  3807. 生成左边树状图的方法
  3808. arr {arr} 要处理的arrjson对象
  3809. tree {object} 要插入树状图的地方
  3810. bookfun {function} 点击事件
  3811. */
  3812. U.MD.UI.BTree.jsonStartLeft = function (arr, tree, bookfun) {
  3813. json = []; //将外变量josn清空
  3814. var _json = arr; //定义局部变量_json,值为r
  3815. for (var _i = 0; _i < _json.length; _i++) { //定义循环,循环对象为
  3816. U.MD.UI.BTree.jsonAdd(json, _json[_i]); //运行函数,生成json
  3817. }
  3818. tree.innerHTML = ""; //清空tree的内容
  3819. U.MD.UI.BTree.treeCreate(json, tree, bookfun); //运行方法,在tree中生成树状图
  3820. }
  3821. /*
  3822. json的删除方法
  3823. json {arr} 要处理的arrjson对象
  3824. pid {String} 要删除的id
  3825. */
  3826. U.MD.UI.BTree.jsonDelete = function (json, pid) {
  3827. for (var _i = 0; _i < json.length; _i++) {//定义循环,循环对象为json
  3828. if (json[_i].id == pid) {//进行判断,判断json[_i]是否为目标pid
  3829. json.splice(_i, 1); //删除
  3830. return json; //返回json
  3831. } else {
  3832. if (json[_i].child) {//如果有child
  3833. json[_i].child = U.MD.UI.BTree.jsonDelete(json[_i].child, pid); //重复调用方法
  3834. }
  3835. }
  3836. }
  3837. return json; //返回json
  3838. }
  3839. /*
  3840. json的搜索方法
  3841. json {arr} 要处理的arrjson对象
  3842. id {String} 要删除的id
  3843. */
  3844. U.MD.UI.BTree.jsonSelectA = function (json, id) {
  3845. for (var _i = 0; _i < json.length; _i++) {//定义循环,循环对象为json
  3846. if (json[_i].id == id) {//进行判断,判断json[_i]是否为目标pid
  3847. return json[_i]; //返回目标
  3848. }
  3849. if (json[_i].child) {//如果有child
  3850. var _return = U.MD.UI.BTree.jsonSelectA(json[_i].child, id); //重复调用方法
  3851. if (_return) {//当返回有值
  3852. return _return; //返回结果
  3853. }
  3854. }
  3855. }
  3856. return false;
  3857. }
  3858. /*
  3859. json的修改方法
  3860. json {arr} 要处理的arrjson对象
  3861. upjson {json}要插入的json
  3862. */
  3863. U.MD.UI.BTree.jsonUpdate = function (json, upjson) {
  3864. for (var _i = 0; _i < json.length; _i++) {//定义循环,循环对象为json
  3865. if (json[_i].id == upjson.id) {//进行判断,判断json[_i]是否为目标pid
  3866. json[_i] = upjson; //进行替换
  3867. return json; //返回json
  3868. }
  3869. if (json[_i].child) {//如果有child
  3870. var _return = U.MD.UI.BTree.jsonUpdate(json[_i].child, upjson); //重复调用方法
  3871. if (_return) {//当返回有值
  3872. json[_i].child = _return;
  3873. return json; //返回结果
  3874. }
  3875. }
  3876. }
  3877. return false;
  3878. }
  3879. /*
  3880. 搜索arr中最高的id方法
  3881. arr {arr} 要搜索的arr对象
  3882. */
  3883. U.MD.UI.BTree.createID = function (arr) {
  3884. var _return = 0; //定义变量
  3885. for (var _i = 0; _i < arr.length; _i++) {//定义循环,循环对象为arr
  3886. if (parseInt(arr[_i].id) > _return) {//进行判断,如果arr的id比_return大
  3887. _return = parseInt(arr[_i].id); //修改_return的值
  3888. }
  3889. }
  3890. return _return; //返回变量
  3891. };
  3892. ///<jscompress sourcefile="Editor.js" />
  3893. //编辑器
  3894. Namespace.register("U.MD.UI.editor");
  3895. /* 默认编辑器,嵌入到指定元素内
  3896. * @param parent {element} 创建在指定的父亲元素
  3897. * @param callback {function} 非必传 操作处理函数
  3898. * 操作处理函数 该函数默认第一个参数为操作记录。
  3899. * 格式形如 : { updateLine : [修改行ID, 修改行ID,], addLine : [添加行ID], deleteLine : [删除行ID] }
  3900. * */
  3901. U.MD.UI.Editor = U.MD.UI.editor = function (parent, callback) {
  3902. U.UF.DL.asynLoadCss({ "rel": "stylesheet", "type": "text/css", "href": "/css/Controls/Complex/Editor.css" });
  3903. // parent.innerHTML = ''; //清空区域内容
  3904. //!$(parent).find($('.editorBar'))[0] ? "" : U.selectEl('.editorBar').remove();
  3905. //_div = $$("div", { "className": "editorBar" }, parent);
  3906. //创建div
  3907. U.MD.UI.editor.createEditor(parent);
  3908. //创建编辑区域
  3909. U.UF.E.initEditor($('.editor', parent)[0], callback);
  3910. //初始化编辑区域
  3911. U.MD.UI.editor.EditorEventBind(parent);
  3912. //绑定事件
  3913. U.MD.UI.editor.operateJson.editor = U.selectEl('.editor', parent)[0];
  3914. //把编辑区域赋值给editor
  3915. return U.MD.UI.editor.operateJson;
  3916. //返回可操作集合
  3917. }
  3918. U.MD.UI.editor.operateJson = {
  3919. /*
  3920. * U.MD.UI.editor.loadContent 加载编辑器内容
  3921. * param1 text(str) 需要加载的文本内容
  3922. * */
  3923. loadContent: function (text) {
  3924. this.editor.focus();
  3925. U.UF.E.onpaste(null, this.editor, text);
  3926. // var _div = $$("div", { innerHTML: text, style: { display: "none"} }, document.body);
  3927. // var _pdiv = U.UF.E.unifiedFormat(_div);
  3928. // var _range = U.UF.E.getRangeAt();
  3929. // var _block = U.UF.E.getLineElement(_range.startContainer);
  3930. // for (var i = 0; i < _pdiv.children.length; i++) {
  3931. // _block.parentElement.appendChild(_pdiv.children[i]);
  3932. // }
  3933. // U.selectEl(_block).remove();
  3934. // U.selectEl(_div).remove();
  3935. },
  3936. /*
  3937. * U.MD.UI.editor.getContent 得到编辑器内容
  3938. * */
  3939. getContent: function () {
  3940. return this.editor.innerHTML;
  3941. //直接返回编辑区域的内容
  3942. }
  3943. };
  3944. /*
  3945. U.MD.UI.editor.CreateEditor 创建HTML内容
  3946. param1 parent(elemt)父元素
  3947. */
  3948. U.MD.UI.editor.createEditor = function (parent) {
  3949. parent.innerHTML =
  3950. "<div class='toolbar' style=\"width: 788px;background-color: #f5f5f5;border: 1px solid #c7d3e1;line-height: 0;padding: 6px;height: 25px;\">\n" +
  3951. " <button class=\"last\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/left.png') no-repeat center;\">\n" +
  3952. " </button>\n" +
  3953. " <button class=\"future\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/right.png') no-repeat center;\">\n" +
  3954. " </button>\n" +
  3955. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  3956. "\n" +
  3957. " </i>\n" +
  3958. "<div class='setFont' style='float: left;margin: 0 3px;position: relative;padding:0px'></div>" +
  3959. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  3960. "\n" +
  3961. " </i>\n" +
  3962. "<div class='setSize' style='float: left;margin: 0 3px;position: relative;padding:0px'></div>" +
  3963. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  3964. "\n" +
  3965. " </i>\n" +
  3966. " <label style=\"float: left;margin: 0 3px;position: relative;\">\n" +
  3967. " <button class=\"pic\" style=\"outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/pic.png') no-repeat center;\">\n" +
  3968. " </button>\n" +
  3969. " <input multiple accept='image/*' type='file' class='picUpload' style='display: none;' />\n" + //onchange='U.UF.E.picture(this)'
  3970. " </label>\n" +
  3971. " <label style=\"float: left;margin: 0 3px;position: relative;\">\n" +
  3972. " <button class=\"attachment\" style=\"outline: none;cursor: pointer;border: 1px solid transparent;width: 25px;height: 25px;background: url(/img/YS2017.png) no-repeat;background-position: -1054px -593.5px;\"></button>\n" +
  3973. " <input multiple=\"\" type=\"file\" class=\"attachmentUpload\" style=\"display: none;\">\n" + //accept=\"image/*\"
  3974. " </label>\n" +
  3975. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  3976. "\n" +
  3977. " </i>\n" +
  3978. " <div style=\"float: left;margin: 0 3px;position: relative;padding:0px\">\n" +
  3979. " <button class=\"fontColor\" style=\"outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/fontColor.png') no-repeat center;\">\n" +
  3980. " </button>\n" +
  3981. " <div class='fontColorBar colorBar' style='display:none;position: absolute;'>\n" +
  3982. " </div>\n" +
  3983. " </div>\n" +
  3984. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  3985. "\n" +
  3986. " </i>\n" +
  3987. " <div style=\"float: left;margin: 0 3px;position: relative;padding:0px\">\n" +
  3988. " <button class=\"backgroundColor\" style=\"outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/blockColor.png') no-repeat center;\">\n" +
  3989. " </button>\n" +
  3990. " <div class='backgroundColorBar colorBar' style='display:none;position: absolute;'>\n" +
  3991. " </div>\n" +
  3992. " </div>\n" +
  3993. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  3994. "\n" +
  3995. " </i>\n" +
  3996. " <button class=\"bIcon\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/strong.png') no-repeat center;\">\n" +
  3997. " </button>\n" +
  3998. " <button class=\"iIcon\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/i.png') no-repeat center;\">\n" +
  3999. " </button>\n" +
  4000. " <button class=\"UIcon\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/x.png') no-repeat center;\">\n" +
  4001. " </button>\n" +
  4002. " <button class=\"SIcon\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/-S-.png') no-repeat center;\">\n" +
  4003. " </button>\n" +
  4004. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\">\n" +
  4005. "\n" +
  4006. " </i>\n" +
  4007. " <button class=\"textLeft\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/textLeft.png') no-repeat center;\">\n" +
  4008. " </button>\n" +
  4009. " <button class=\"textCenter\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/textCenter.png') no-repeat center;\">\n" +
  4010. " </button>\n" +
  4011. " <button class=\"textRight\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/textRight.png') no-repeat center;\">\n" +
  4012. " </button>\n" +
  4013. " <i style=\"display: inline-block;width: 1px;height: 22px;background-color: #bcbcbc;float: left;margin: 0 3px;position: relative;\" >\n" +
  4014. "\n" +
  4015. " </i>\n" +
  4016. " <button class=\"a\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/a.png') no-repeat center;\">\n" +
  4017. " </button>\n" +
  4018. " <button class=\"b\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/b.png') no-repeat center;\">\n" +
  4019. " </button>\n" +
  4020. " <button class=\"c\" style=\"float: left;margin: 0 3px;position: relative;outline: none;cursor: pointer;border: 1px solid transparent;height: 25px;width: 25px;background: url('/EditorImage/c.png') no-repeat center;\">\n" +
  4021. " </button>\n" +
  4022. " </div>\n" +
  4023. " <div class=\"editor\" contenteditable=\"true\" style=\"width: 800px;min-height: 300px;border: 1px solid #E6E5E5;overflow: auto;\">\n" +
  4024. " </div>";
  4025. U.selectEl('input.picUpload[type="file"]', parent)[0].onchange = function () {
  4026. U.UF.E.picture(this, U.selectEl('.editor', parent)[0])
  4027. }
  4028. U.selectEl('input.attachmentUpload[type="file"]', parent)[0].onchange = function () {
  4029. U.UF.E.attachment(this, U.selectEl('.editor', parent)[0])
  4030. }
  4031. };
  4032. /*
  4033. U.MD.UI.editor.EditorEventBind 创建绑定事件
  4034. param1 parent(elemt) 范围
  4035. */
  4036. U.MD.UI.editor.EditorEventBind = function (parent) {
  4037. //绑定图片拉伸
  4038. // U.UF.E.key($('.editor', parent));
  4039. //绑定键盘事件
  4040. var _font = U.MD.UI.Font();
  4041. //生成字体下拉框
  4042. _font.style.cssText += "vertical-align: super;";
  4043. var _size = U.MD.UI.WordSize();
  4044. //生成字体大小下拉框
  4045. _size.style.cssText += "vertical-align: super;";
  4046. U.selectEl('.setFont', parent).append(_font);
  4047. _font.onchange = function () {
  4048. U.UF.E.setRangeStyle({ 'font-family': _font.value });
  4049. };
  4050. //设置字体样式
  4051. U.selectEl('.setSize', parent).append(_size);
  4052. _size.onchange = function () {
  4053. U.UF.E.setRangeStyle({ 'font-size': _size.value });
  4054. };
  4055. //设置图片上传点击
  4056. U.selectEl('.pic', parent)[0].onclick = function () {
  4057. U.selectEl('.picUpload', parent)[0].click();
  4058. };
  4059. //设置附件上传点击
  4060. U.selectEl('.attachment', parent)[0].onclick = function () {
  4061. U.selectEl('.attachmentUpload', parent)[0].click();
  4062. };
  4063. //图片点击
  4064. U.selectEl('.bIcon', parent)[0].onclick = function () {
  4065. U.UF.E.setRangeStyle({ 'font-weight': 'bold' });
  4066. };
  4067. //加粗
  4068. U.selectEl('.iIcon', parent)[0].onclick = function () {
  4069. U.UF.E.setRangeStyle({ 'font-style': 'italic' });
  4070. };
  4071. //斜体
  4072. U.selectEl('.UIcon', parent)[0].onclick = function () {
  4073. U.UF.E.setRangeStyle({ 'text-decoration': 'underline' });
  4074. };
  4075. //下划线
  4076. U.selectEl('.SIcon', parent)[0].onclick = function () {
  4077. U.UF.E.setRangeStyle({ 'text-decoration': 'line-through' });
  4078. };
  4079. //删除线
  4080. U.selectEl('.fontColor', parent).bind('click', function () {
  4081. //修改字体颜色
  4082. if ($('.fontColorBar', parent).css('display') == "none") {
  4083. U.MD.UI.colorPicker($('.fontColorBar', parent)[0], function (r) {
  4084. U.selectEl('.MD_ColorPicker', U.selectEl('.fontColorBar', parent)[0]).remove();
  4085. U.selectEl('.fontColorBar', parent).hide();
  4086. U.UF.E.setRangeStyle({ 'color': r });
  4087. });
  4088. U.selectEl('.fontColorBar', parent).show();
  4089. }
  4090. });
  4091. U.selectEl('.backgroundColor', parent).bind('click', function () {
  4092. //修改背景颜色
  4093. if ($('.backgroundColorBar', parent).css('display') == "none") {
  4094. U.MD.UI.colorPicker($('.backgroundColorBar', parent)[0], function (r) {
  4095. U.selectEl('.MD_ColorPicker', U.selectEl('.backgroundColorBar', parent)[0]).remove();
  4096. U.selectEl('.backgroundColorBar', parent).hide();
  4097. U.UF.E.setRangeStyle({ 'backgroundColor': r });
  4098. });
  4099. U.selectEl('.backgroundColorBar', parent).show();
  4100. }
  4101. });
  4102. // U.selectEl('.upload', parent)[0].onchange = function () {
  4103. // U.UF.E.picture(this);
  4104. //// 上传图片
  4105. // var _this = this;
  4106. // U.UF.UP.inputUpload([_this], 'http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=FA92AAC5-4134-449F-9659-0DC12F4F68E9', function (r) {
  4107. // var img = '<img style="max-width: 80%;" src="http://fs.1473.cn/' + r.value[0] + '">';
  4108. // U.UF.E.addRange(img);
  4109. // _this.value = '';
  4110. // });
  4111. // }
  4112. /*$('.editor', parent)[0].onpaste = function (e) {
  4113. //绑定粘贴
  4114. var _text = e.clipboardData.getData('text/html') || event.clipboardData.getData("text/plain");
  4115. var _div = $$("div", { innerHTML: _text, style: { display: "none"} }, document.body);
  4116. U.UF.E.unifiedFormat(_div);
  4117. document.body.removeChild(_div);
  4118. };*/
  4119. U.selectEl('.a', parent).bind('click', function () {
  4120. U.UF.E.addHref();
  4121. });
  4122. //添加a标签
  4123. U.selectEl('.c', parent).bind('click', function () {
  4124. U.UF.E.clearStyle(U.UF.E.getRangeAt());
  4125. });
  4126. //清除格式
  4127. U.selectEl('.textLeft', parent).bind('click', function () {
  4128. U.UF.E.setLineStyle({ 'text-align': 'left' });
  4129. });
  4130. //居左
  4131. U.selectEl('.textCenter', parent).bind('click', function () {
  4132. U.UF.E.setLineStyle({ 'text-align': 'center' });
  4133. });
  4134. //居中
  4135. U.selectEl('.textRight', parent).bind('click', function () {
  4136. U.UF.E.setLineStyle({ 'text-align': 'right' });
  4137. });
  4138. //居右
  4139. };
  4140. /**
  4141. * 下拉框
  4142. * @param choosecon 【object】必选 若需要value值使用集合({'11111111':'aaaaaaaa','2222222':'bbbbbbbb','33333333':'cccccccc'})键名为value值
  4143. * @param selattr 【object】必选 设置最外层div的属性值
  4144. * @param optionevent 【function】必选 给每个选择区域的点击后回调函数,参数一:value值或者文本值
  4145. * @param parentnode 【element】可选 添加到里面的元素
  4146. * @returns {*} 【element】 返回出创建好的下拉控件
  4147. * @constructor
  4148. */
  4149. U.MD.UI.editor.Select = function (choosecon, selattr, optionevent, parentnode) {
  4150. var _id = "";
  4151. selattr.id && (_id = selattr.id) && (delete selattr.id);
  4152. var _selectEl = $$('div', { id: _id }, parentnode || null), //创建最外层
  4153. _value = $$('div', selattr, _selectEl),
  4154. _textarea = $$('div', {}, _value); //创建最第二层
  4155. $$('div', { style: { cssText: 'border-width: 6px 4px; border-style: solid; border-color: rgb(166, 178, 192) transparent transparent; width: 0; position: absolute; right: 4px; top: 50%; margin-top: -3px'} }, _value); //小三角
  4156. //_text = $$('div', { style: { cssText: "padding-left: 6px; overflow: hidden; height:100%;cursor: pointer;"} }, _textarea), //创建显示文本内容div
  4157. var _con = $$('div', {
  4158. datacontent: '',
  4159. style: { cssText: 'display: none;position: absolute; margin-top:-1px; min-width: 100%; max-width: 280px; max-height: 200px ;border: 1px solid silver; overflow-x: hidden; cursor: pointer;' }
  4160. }, _selectEl), //创建选择区域
  4161. _range;
  4162. /*默认属性*/
  4163. // !selattr.style.border ? _selectEl.style.border = '1px solid #000' : '';
  4164. // !selattr.style.background ? _selectEl.style.background = '#fff' : '';
  4165. // !selattr.style.width ? _selectEl.style.width = "122px" : '';
  4166. // !selattr.style.height ? _selectEl.style.height = '24px' : '';
  4167. (selattr.style && !selattr.style.position) ? _selectEl.style.position = 'relative' : '';
  4168. (selattr.style && !selattr.style.textIndent) ? _textarea.style.textIndent = '6px' : '';
  4169. // !selattr.style.overflow ? _selectEl.style.overflow = 'hidden' : '';
  4170. _textarea.style.whiteSpace = 'pre';
  4171. _textarea.style.overflow = 'hidden'
  4172. _textarea.style.width = _selectEl.offsetWidth - 15 + "px";
  4173. for (var i in choosecon) { //循环集合
  4174. $$('div', {
  4175. value: i, innerText: choosecon[i], //创建选择内容
  4176. style: { cssText: 'padding: 4px 6px; background: #fff' },
  4177. onmouseover: function () { /*绑定光标移入事件*/
  4178. this.style.background = '#ccc'
  4179. },
  4180. onmouseout: function () { /*绑定光标移除事件*/
  4181. this.style.background = '#fff'
  4182. }, onclick: function () { /*绑定点击事件*/
  4183. _textarea.innerText = this.innerText; /*改变问题*/
  4184. U.UF.E.reSelectRange(_range) /*重新聚焦光标*/
  4185. optionevent(this.value || this.innerText); /*回调*/
  4186. }
  4187. }, _con);
  4188. }
  4189. for (var i in choosecon) {// 第一个及默认值
  4190. _textarea.innerText = choosecon[i];
  4191. break;
  4192. }
  4193. _textarea.style.lineHeight = parseInt(_textarea.style.height) + 'px'; //使显示文本居中
  4194. _selectEl.onclick = function () { //绑定点击事件
  4195. var _el = this.querySelector('div[datacontent]');
  4196. U.UF.E.reSelectRange(_range) /*重新聚焦光标*/
  4197. _el.style.display === 'block' ? _el.style.display = 'none' : _el.style.display = 'block'; /*显示隐藏*/
  4198. };
  4199. U.selectEl(document).bind('click', function () { /*绑定事件*/
  4200. if (_con.style.display != 'none')
  4201. _con.style.display = 'none'
  4202. if ($(".BD_BorderPicker")[0]) {
  4203. if ($(".BD_BorderPicker")[0].style.display != 'none')
  4204. U.selectEl(".BD_BorderPicker")[0].style.display = 'none'
  4205. }
  4206. }, false);
  4207. U.selectEl(_selectEl).bind('click', function (e) { /*绑定事件*/
  4208. U.UF.EV.stopBubble(e);
  4209. //阻止事件冒泡
  4210. });
  4211. _selectEl.onmousedown = function () { /*绑定事件*/
  4212. _range = U.UF.E.getRangeAt() /*获取光标位置*/
  4213. }
  4214. return _selectEl; //返回创建元素
  4215. };
  4216. ;
  4217. ///<jscompress sourcefile="Excel.js" />
  4218. //excel控件
  4219. Namespace.register("U.MD.UI.excel");;
  4220. ///<jscompress sourcefile="Reply.js" />
  4221. Namespace.register("U.MD.R");
  4222. /**
  4223. * 评论控件全局变量
  4224. * PID // 项目id,请查看api文档说明,找到你所在项目的id。
  4225. * AID // 对应的文章id,获取url网址的主机,加上url网址的目录,形成的文章id。
  4226. * URL // 文章对应的url地址。
  4227. * PageIndex // 当前页数
  4228. * PageSize // 一页请求数
  4229. * AllCount // 此文章对应的有多少数据
  4230. * */
  4231. U.MD.R.data = {
  4232. PID: "",
  4233. AID: "",
  4234. URL: "",
  4235. PageIndex: 1,
  4236. PageSize: 20,
  4237. AllCount: "",
  4238. CB: null
  4239. }
  4240. /**
  4241. * 评论控件初始化函数,调用函数
  4242. * @param {object} 参数。
  4243. * obj={
  4244. * pid // 项目id,请查看api文档说明,找到你所在项目的id。
  4245. * type //引用方式为弹窗还是嵌入式,true 为嵌入式方式,false 为窗体。
  4246. * el // 评论控件追加的元素。注意:当控件为嵌入式时,才需要填写此参数,如果为弹窗时,不需要填写此参数。
  4247. * }
  4248. */
  4249. U.MD.R.reply = function (obj) {
  4250. //alert();
  4251. //定义变量,获取调用方式、控件追加的元素、以及项目id.
  4252. U.MD.R.login.cookieLogin(function () {
  4253. var _type = obj.type,
  4254. _el = obj.el,
  4255. _cb = obj.cb;
  4256. U.MD.R.data.PID = obj.pid; //项目id全局设置
  4257. U.MD.R.data.AID = U.MD.R.reply.getUrlHash(); //文章id全局设置
  4258. U.MD.R.data.URL = U.MD.R.reply.getUrl(); //文章url全局设置
  4259. U.MD.R.data.CB = _cb;
  4260. //调用类型判断
  4261. if (!_type) {//如果调用方式是窗体,那么先创建一个窗体,并且重新更新变量_el的值。
  4262. _el = new U.UF.UI.form('', $$("div"), {
  4263. "style": {
  4264. "width": "800px",
  4265. "height": "800px"
  4266. }
  4267. }).content;
  4268. }
  4269. U.MD.R.reply.init(_el); //控件初始化
  4270. U.UF.DL.asynLoadCss({
  4271. "href": "/css/Controls/Basic/Picture.css",
  4272. type: "text/css",
  4273. rel: "stylesheet"
  4274. }); //动态添加css文件
  4275. U.UF.DL.asynLoadJs({ type: "text/javascript", src: "/js/Controls/Basic/Picture.js" });
  4276. }); //cookie自动登录
  4277. }
  4278. /**
  4279. * 评论控件初始化函数,调用函数
  4280. * @param {element} 追加元素
  4281. */
  4282. U.MD.R.reply.init = function (el) {
  4283. var _pageindex = U.MD.R.data.PageIndex, //当前页数
  4284. _pagesize = U.MD.R.data.PageSize; //一页请求数
  4285. U.MD.R.initPrintHtml(el); //创建基础html
  4286. U.MD.R.getReplyData(_pageindex, _pagesize, function (data) {//获取评论数据
  4287. U.MD.R.data.AllCount = data[0][0] ? Math.ceil(data[0][0].allcount / U.MD.R.data.PageSize) : ""; //取数完成之后进行将页数全局赋值给id。
  4288. U.MD.R.printComment($("#U_MD_R_content_user_comment")[0], 1, data, false, false, false); //打印数据
  4289. U.MD.R.initLoadMoreBtn(data[0]); //创建
  4290. });
  4291. }
  4292. /**
  4293. * 获取url地址
  4294. */
  4295. U.MD.R.reply.getUrl = function () {
  4296. return window.location.href;
  4297. }
  4298. /**
  4299. * 获取url网址的主机,加上url网址的目录
  4300. */
  4301. U.MD.R.reply.getUrlHash = function () {
  4302. return U.UF.EC.SparkMD5.hash(window.location.href);
  4303. }
  4304. /**
  4305. * 获取评论数据
  4306. * @param {number} 页码数
  4307. * @param {number} 一页的请求量
  4308. * @param {function} 回调函数
  4309. */
  4310. U.MD.R.getReplyData = function (pageindex, pagesize, cb) {
  4311. U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Reply", "test", U.MD.R.data.AID, "1", "", pageindex, pagesize], function (r) {//获取数据
  4312. cb && cb(r.value); //执行回调函数,并且返回数据。
  4313. });
  4314. }
  4315. /**
  4316. * 初始化创建回复元素
  4317. * @param {element} 追加元素
  4318. */
  4319. U.MD.R.initPrintHtml = function (el) {
  4320. var _el = el,
  4321. _comment,
  4322. _content,
  4323. _content_operation,
  4324. _userhead,
  4325. _headimg,
  4326. _operation,
  4327. _username,
  4328. _editorbox,
  4329. _bottom,
  4330. _picturewarp,
  4331. _picture,
  4332. _clear,
  4333. _emoji_frame,
  4334. _input,
  4335. _button,
  4336. _img_warp,
  4337. _box;
  4338. _comment = $$("div", { "className": "U_MD_R_comment" }, _el); //创建最外成元素
  4339. _content = $$("div", { "className": "U_MD_R_content" }, _comment); //创建评论内容元素最外元素
  4340. _content_operation = $$("div", { "className": "U_MD_R_content_operation" }, _content); //创建用户评论区域最外成元素
  4341. _userhead = $$("div", { className: "U_MD_R_content_operation_userhead U_MD_R_Reply_Header" }, _content_operation); //创建头像最外成元素
  4342. _headimg = $$("img", {//创建头像img元素
  4343. "className": "img",
  4344. "src": "/img/UserHead/UseHead.jpg",
  4345. "onerror": function () { this.src = '/img/UserHead/UseHead.jpg' }
  4346. }, _userhead);
  4347. _operation = $$("div", {
  4348. "className": "U_MD_R_content_operation_right",
  4349. style: { width: "calc(100% - 40px - 20px )" }
  4350. }, _content_operation); //创建内容框架div
  4351. U.selectEl(_operation).attr({
  4352. "data-RPID": null,
  4353. "data-RD": 1,
  4354. "data-RPUID": null
  4355. });
  4356. _username = $$("div", {//创建用户名元素
  4357. "innerHTML": "登录/注册",
  4358. "className": "U_MD_R_content_operation_userlogin U_MD_R_Reply_Name"
  4359. }, _operation);
  4360. //判断是否登录
  4361. if (US.userInfo.UserId) {//已登录
  4362. _username.innerHTML = US.userInfo.UserName; //设置用户名
  4363. _headimg.src = 'http://fs.1473.cn/' + US.userInfo.UserThumbnailImageHead; //设置头像
  4364. }
  4365. else {//未登录
  4366. _username.onclick = function () {
  4367. U.MD.R.login();
  4368. }
  4369. }
  4370. _editorbox = $$("div", {
  4371. "id": "editorbox",
  4372. "className": "U_MD_R_Reply_Content",
  4373. "contenteditable": "true",
  4374. "style": { "min-height": "100px", "background": "#fff", "border": "1px solid black" }
  4375. }, _operation)//创建编辑器容器
  4376. var _scrolltop = document.documentElement.scrollTop;
  4377. U.UF.E.initEditor(_editorbox); //调用函数
  4378. document.documentElement.scrollTop = _scrolltop;
  4379. _bottom = $$("div", { "className": "U_MD_R_content_operation_right_bottom" }, _operation); //创建用户评论底部区域
  4380. $$("div", {//创建表情包按钮
  4381. "className": "U_MD_R_content_operation_right_bottom_emoji",
  4382. "onclick": function () {
  4383. U.UF.EV.stopBubble();
  4384. U.MD.UI.face(this, U.selectEl('#editorbox')[0]);
  4385. //$(this)[0].append($("#U_MD_UI_face")[0]);
  4386. //$(this)[0].append($("#U_MD_UI_face")[0]);
  4387. U.selectEl("#U_MD_UI_face").css({ "position": "relative", "height": "140px", "overflow-y": "scroll", "top": "-150px", "width": "450px", "display": "block" });
  4388. }
  4389. }, _bottom);
  4390. _picturewarp = $$("div", { "className": "U_MD_R_content_operation_right_bottom_picturewarp" }, _bottom); //图片最外成
  4391. _picture = $$("img", { src: "/img/reply/img.png" }, _picturewarp);
  4392. _input = $$("input", { "type": "file" }, _picturewarp); //上传
  4393. _button = $$("div", {
  4394. "className": "U_MD_R_content_operation_right_bottom_release",
  4395. "innerHTML": "发表评论"
  4396. }, _bottom); //内容发布
  4397. _button.onclick = function () {
  4398. if ($(".U_MD_R_Reply_Content")[0].textContent != '' || U.selectEl(".U_MD_R_Reply_Content")[0].innerHTML != '') {
  4399. U.MD.R.release(_operation, 1, false, 1);
  4400. } else {
  4401. U.alert("评论不能为空!");
  4402. }
  4403. }
  4404. _img_warp = $$("div", { "className": "U_MD_R_content_operation_right_bottom_imgloadbox U_MD_R_Reply_Image" }, _operation); //图片加载
  4405. _box = $$("div", { "className": "U_MD_R_content_comment", "id": "U_MD_R_content_user_comment" }, _content); //内容盒子
  4406. _input.onchange = function () {
  4407. U.MD.R.uploadImages(this, _img_warp);
  4408. }
  4409. U.MD.R.data.CB && U.MD.R.data.CB();
  4410. }
  4411. /**
  4412. * 创建加载更多按钮
  4413. */
  4414. U.MD.R.initLoadMoreBtn = function (data) {
  4415. var _btn = $$("div", { "className": "U_MD_R_content_loading" }, U.selectEl(".U_MD_R_comment")[0]);
  4416. if (data.length > 0) {
  4417. if (U.MD.R.data.PageIndex < U.MD.R.data.AllCount) {
  4418. _btn.innerHTML = "点击加载更多评论";
  4419. _btn.onclick = function () {
  4420. var _pageindex = ++U.MD.R.data.PageIndex,
  4421. _pagesize = U.MD.R.data.PageSize;
  4422. if (U.MD.R.data.PageIndex <= U.MD.R.data.AllCount) {
  4423. U.MD.R.getReplyData(_pageindex, _pagesize, function (data) {//获取评论数据
  4424. U.MD.R.data.AllCount = Math.ceil(data[0][0].allcount / U.MD.R.data.PageSize);
  4425. U.MD.R.printComment($("#U_MD_R_content_user_comment")[0], 1, data, false, false, false); //打印数据
  4426. });
  4427. }
  4428. else {
  4429. U.selectEl(_btn).hide();
  4430. }
  4431. }
  4432. }
  4433. }
  4434. else {
  4435. // _btn.innerHTML = "还没有人评论";
  4436. }
  4437. }
  4438. /**
  4439. * 打印一级评论
  4440. * @param {object} 评论数据
  4441. * @param {element} 追加元素
  4442. * @param {number} 用于判断层级而显示指定内容
  4443. * @param {boolean}元素插入类型
  4444. * @param {boolean} 是否需要回复功能,默认为false
  4445. * @param {boolean} 是否需要查看更多,用于区分设置查看更多类型
  4446. */
  4447. U.MD.R.printComment = function (el, type, data, appendtype, isreply, readmore) {
  4448. var _count = U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Reply", "Reply_SelectTypeReplyEnable", U.MD.R.data.PID]);
  4449. if (_count.value[0].ProjectReplyEnable == 1) {
  4450. var _el = el,
  4451. _type = type,
  4452. _data = data,
  4453. _appendtype = appendtype,
  4454. _isreply = isreply,
  4455. _readmore = readmore,
  4456. _shownum;
  4457. for (var i = 0; i < data[0].length; i++) {//遍历评论数据
  4458. if (readmore) {
  4459. _shownum = data[0][i].TopReplyNum;
  4460. }
  4461. else {
  4462. _shownum = U.Json.select(_data[2], { ReplyID: _data[0][i].ReplyID }).length > 0 ? U.Json.select(_data[2], { ReplyID: _data[0][i].ReplyID })[0].AllReplyNum : "0"; //评论子集(所有子集)的评论数
  4463. }
  4464. U.MD.R.printCommentHtml(_el, _type, {
  4465. rid: _data[0][i].ReplyID, //评论id
  4466. rpid: _data[0][i].ReplyParentID, //评论父级id
  4467. deep: _data[0][i].ReplyDeep, //评论深度
  4468. topid: _data[0][i].ReplyID, //评论顶级id
  4469. uid: _data[0][i].UserID, //评论用户id
  4470. un: _data[0][i].UserName, //评论用户名
  4471. tx: _data[0][i].ReplyUserThumbnailImageHead, //评论用户头像
  4472. time: _data[0][i].ReplyAddTime, //评论时间
  4473. content: _data[0][i].ReplyContent, //评论内容
  4474. shownum: _shownum,
  4475. likesnum: _type == 2 ? U.Json.select(_data[4], { ReplyID: _data[0][i].ReplyID })[0]:U.Json.select(_data[1], { ReplyID: _data[0][i].ReplyID })[0]
  4476. }, _appendtype, _isreply, _readmore);
  4477. }
  4478. } else {
  4479. var _btn = $$("div", { "className": "U_MD_R_content_loading" }, U.selectEl(".U_MD_R_comment")[0]);
  4480. _btn.innerHTML = "该评论系统已关闭";
  4481. U.selectEl("#U_MD_R_content_loading")[0].innerHTML = '';
  4482. }
  4483. }
  4484. /**
  4485. * 打印二级评论,用于区分用户点击回复或者查看更多。
  4486. * @param {sring} 评论id
  4487. * @param {boolean} 是否需要查看更多,用于区分设置查看更多类型
  4488. */
  4489. U.MD.R.viewComment = function (rid, type) {
  4490. if (US.userInfo.UserId) {
  4491. var
  4492. _rid = rid, //父级id
  4493. _form, //窗体变量
  4494. _data, //数据
  4495. _firstbox, //一级评论内容区域
  4496. _secondbox, //二级评论内容区域
  4497. _thirdbox, //三级评论内容区域
  4498. _type = type;
  4499. _form = new U.UF.UI.form('', $$("div", { "style": { "padding": "20px"} }), {
  4500. "style": {
  4501. "width": "800px",
  4502. "height": "600px"
  4503. }
  4504. });
  4505. U.A.Request("http://cd.1473.cn/php", ["db.1473.cn", "UseStudio_Reply", "Reply_SelectThisReply", _rid], function (r) {//根据评论id,获取此评论,此评论点赞数,以及子目录下所有的评论还有点赞数
  4506. _data = r.value;
  4507. U.MD.R.printComment(_form.content, 2, _data, true, true, true); //打印一级目录
  4508. if (_type) {
  4509. U.selectEl(_form.content).find(".U_MD_R_content_box_content_edit").show();
  4510. }
  4511. _firstbox = $$("div", { "className": "U_MD_R_content_warp_box" }, _form.content);
  4512. //创建二级目录
  4513. for (var i = 0; i < _data[1].length; i++) {
  4514. _secondbox = U.MD.R.printCommentHtml(_firstbox, 2, {
  4515. rid: _data[1][i].ReplyID,
  4516. rpid: _data[1][i].ReplyParentID,
  4517. deep: _data[1][i].ReplyDeep,
  4518. topid: _data[1][i].ReplyTopID,
  4519. uid: _data[1][i].UserID,
  4520. tx: _data[1][i].ReplyUserThumbnailImageHead,
  4521. un: _data[1][i].UserName,
  4522. time: _data[1][i].ReplyAddTime,
  4523. content: _data[1][i].ReplyContent,
  4524. likesnum: U.Json.select(_data[3], { ReplyID: _data[1][i].ReplyID })[0]
  4525. }, false, true, true);
  4526. //创建三级以下目录(包括三级)
  4527. _thirdbox = $$("div", { "className": "U_MD_R_content_warp_box" }, _secondbox);
  4528. U.selectEl(_thirdbox).attr({ "data-replyid": _data[1][i].ReplyID });
  4529. for (var j = 0; j < _data[2].length; j++) {
  4530. if (_data[1][i].ReplyID == _data[2][j].ReplyParentID) {
  4531. U.MD.R.printCommentHtml(_thirdbox, 3, {
  4532. rid: _data[2][j].ReplyID,
  4533. rpid: _data[2][j].ReplyParentID,
  4534. deep: _data[2][j].ReplyDeep,
  4535. topid: _data[2][j].ReplyTopID,
  4536. uid: _data[2][j].UserID,
  4537. tx: _data[2][j].ReplyUserThumbnailImageHead,
  4538. un: _data[2][j].UserName,
  4539. time: _data[2][j].ReplyAddTime,
  4540. content: _data[2][j].ReplyContent,
  4541. likesnum: U.Json.select(_data[3], { ReplyID: _data[2][j].ReplyID })[0],
  4542. replyinfo: {
  4543. uid: _data[2][j].uid, //评论的用户id
  4544. un: _data[2][j].un, //评论的用户名
  4545. tx: _data[2][j].tx//评论的头像
  4546. }
  4547. }, false, true, true);
  4548. }
  4549. }
  4550. }
  4551. });
  4552. }
  4553. else {
  4554. U.Alert("请先登录");
  4555. }
  4556. }
  4557. /**
  4558. * 打印评论数据内容
  4559. * @param {object} 评论数据
  4560. * @param {element} 追加元素
  4561. * @param {object} 用于判断层级而显示指定内容
  4562. * object={
  4563. * rid,//评论id
  4564. * rpid,//评论父级id
  4565. * deep,//评论深度
  4566. * topid,//评论顶级id
  4567. * uid,//评论用户id
  4568. * un,//评论用户名
  4569. * tx,//评论用户头像
  4570. * time,//评论时间
  4571. * content,//评论内容
  4572. * likesnum,//评论点赞数
  4573. * shownum,//评论子集(所有子集)的评论数
  4574. * }
  4575. * @param {boolean} 元素插入类型
  4576. * @param {boolean} 是否需要回复功能,默认为false
  4577. * @param {boolean} 是否需要查看更多,用于区分设置查看更多类型
  4578. */
  4579. U.MD.R.printCommentHtml = function (el, type, data, appendtype, isreply, readmore) {
  4580. var _data = data,
  4581. _el = el,
  4582. _type = type,
  4583. // _eltype = obj.eltype ? obj.eltype : false,
  4584. // _showmore = obj.showmore,
  4585. _rid = _data.rid, //评论id
  4586. _rpid = _data.rpid, //评论父级id
  4587. _deep = _data.deep, //评论顶级id
  4588. _topid = _data.topid, //评论顶级id
  4589. _uid = _data.uid, //评论用户id
  4590. _tx = _data.tx, //评论用户名
  4591. _un = _data.un, //评论用户头像
  4592. _time = _data.time, //评论时间
  4593. _datacontent = _data.content, //评论内容
  4594. _likesnumjson = _data.likesnum, //点赞数
  4595. _showmoretxtjson = _data.shownum, //评论子集(所有子集)的评论数
  4596. _replyinfo_uid = _data.replyinfo ? _data.replyinfo.uid : "", //评论的用户id
  4597. _replyinfo_un = _data.replyinfo ? _data.replyinfo.un : "", //评论的用户名
  4598. _replyinfo_tx = _data.replyinfo ? _data.replyinfo.tx : "", //评论的头像
  4599. _appendtype = appendtype, //评论插入的方式,如果为true,那么就插入到所有评论的第一个(用于以及评论和二级评论),如果为false,那么就插入到最后一个
  4600. _isreply = isreply, //点击回复按钮,是否是弹出回复框,还是弹出查看更多,默认为false,
  4601. _readmore = readmore, //点击获取是
  4602. _box, //评论最外层元素
  4603. _info, //评论内层元素
  4604. _head, //评论用户头像最外层
  4605. _headimg, //评论用户头像
  4606. _content, //评论头像右侧内容
  4607. _content_top, //评论右侧内容-头部用户名区域
  4608. _username, //评论右侧内容-头部用户名区域-用户名
  4609. _commenttime, //评论右侧内容-头部用户名区域-评论时间
  4610. _text,
  4611. _content_bottom, //评论右侧内容-底部区域
  4612. _likeswarp, //评论右侧内容-底部区域-点赞最外层
  4613. _likesimg, //评论右侧内容-底部区域-点赞图片
  4614. _likesnum, //评论右侧内容-底部区域-点赞数
  4615. _replywarp, //评论右侧内容-底部区域-回复最外层
  4616. _showmorewarp, //评论右侧内容-底部区域-查看更多最外层
  4617. _showmoretext, //评论右侧内容-底部区域-查看更多文字元素
  4618. _position,
  4619. _contenteditable, //创建子集评论-评论操作区域最外层
  4620. _bottom, //创建子集评论-评论操作区域内层
  4621. _picturewarp, //创建子集评论-评论操作区域-图片最外层
  4622. _picture, //创建子集评论-评论操作区域-图片元素
  4623. _input, //创建子集评论-评论操作区域-上传input
  4624. _button, //创建子集评论-评论操作区域-发布按钮
  4625. _img_warp, //创建子集评论-评论操作区域-图片显示区域
  4626. _childrenbox; //用于存放子集评论
  4627. _box = $$("div", { "className": "U_MD_R_content_box" }); //创建内容盒子
  4628. if (_appendtype) { //判断插入类型是否为true,如果为true,那么就插入到所有评论的第一个(用于以及评论和二级评论),如果为false,那么就插入到最后一个
  4629. U.selectEl(_el).append(_box, 0, U.selectEl(_el)[0].firstChild);
  4630. }
  4631. else {//如果为false,那么就插入到最后一个
  4632. U.selectEl(_el).append(_box);
  4633. }
  4634. _info = $$("div", { "className": "U_MD_R_content_box_warp" }, _box); //创建信息div
  4635. U.selectEl(_info).attr({//给评论内层设置评论id、评论父级id、评论深度、评论顶级id、评论用户id。用于回复时获取信息。
  4636. "data-rid": _rid, //评论id
  4637. "data-RPID": _rpid, //评论父级id
  4638. "data-RD": _deep, //评论深度
  4639. "data-RBID": _topid, //评论顶级id
  4640. "data-RPUID": _uid//评论用户id
  4641. });
  4642. _head = $$("div", { "className": "U_MD_R_content_box_userhead" }, _info); //评论用户头像最外层
  4643. _headimg = $$("img", {//评论用户头像
  4644. "src": _tx,
  4645. onerror: "U.MD.R.imgError(this)"
  4646. }, _head);
  4647. _content = $$("div", {//评论头像右侧内容
  4648. "className": "U_MD_R_content_box_content",
  4649. style: { width: "calc(100% - 40px - 20px )" }
  4650. }, _info); //创建右侧div
  4651. _content_top = $$("div", { "className": "U_MD_R_content_box_content_top" }, _content); //评论右侧内容-头部用户名区域
  4652. _username = $$("div", {//评论右侧内容-头部用户名区域-用户名
  4653. "className": "U_MD_R_content_box_content_top_name",
  4654. "innerHTML": _un
  4655. }, _content_top);
  4656. if (_type == 3) {//如果为三级目录以下,那么就修改显示的用户名
  4657. _username.innerHTML = _un + '回复@' + _replyinfo_un;
  4658. }
  4659. _commenttime = $$("div", {//评论右侧内容-头部用户名区域-评论时间
  4660. "className": "U_MD_R_content_box_content_top_time",
  4661. "innerHTML": _time
  4662. }, _content_top);
  4663. _text = $$("div", { "className": "U_MD_R_content_box_content_text", "innerHTML": _datacontent }, _content); //创建内容区域
  4664. if ($(_text).find("img").length > 0) {
  4665. U.selectEl(_text).find("img")[0].onclick = function () {
  4666. // U.MD.UI.picture([this.src, this.src, this.src], 2);
  4667. U.MD.UI.picture([this.src], 0);
  4668. U.selectEl("#U_MD_UI_PictureForm").css("position", "fixed");
  4669. U.UF.F.topWindow($('#U_MD_UI_PictureForm')[0], true);
  4670. }
  4671. }
  4672. _content_bottom = $$("div", { "className": "U_MD_R_content_box_content_bottom" }, _content); //评论右侧内容-底部区域
  4673. _likeswarp = $$("div", { "className": "U_MD_R_content_box_content_bottom_likeswarp" }, _content_bottom); //评论右侧内容-底部区域-点赞最外层
  4674. _likeswarp.onclick = function () {//设置点赞事件
  4675. U.MD.R.like(this, _rid, US.userInfo.UserId);
  4676. }
  4677. _likesimg = $$("img", { "src": "/img/reply/NOFabulous.png" }, _likeswarp); //评论右侧内容-底部区域-点赞图片
  4678. _likesnum = $$("div", {//评论右侧内容-底部区域-点赞数
  4679. "className": "U_MD_R_content_box_content_bottom_likeswarp_text",
  4680. "innerHTML": 0
  4681. }, _likeswarp);
  4682. if (_likesnumjson) {//如果有点赞数据,那么修改点赞数,并且修改图片。
  4683. _likesnum.innerHTML = _likesnumjson.ReplyNum;
  4684. U.A.Request("http://cd.1473.cn/net", ["db.1473.cn", "UseStudio_Reply", "Reply_SelectRepeatLikes_Moblie", _rid, US.userInfo.UserId], function (r) {
  4685. if (r.value[0].mode == 1) {
  4686. _likesimg.src = "/img/reply/NOFabulous.png";
  4687. }else if (r.value[0].mode == 0) {
  4688. _likesimg.src = "/img/reply/Fabulous.png";
  4689. } else {
  4690. _likesimg.src = "/img/reply/NOFabulous.png";
  4691. }
  4692. })
  4693. //_likesimg.src = "/img/reply/Fabulous.png";
  4694. }
  4695. _replywarp = $$("div", { "className": "U_MD_R_content_box_content_bottom_replywarp" }, _content_bottom); //评论右侧内容-底部区域-回复最外层
  4696. if (_readmore) {//点击回复按钮,是否是弹出回复框,还是弹出查看更多,默认为false。如果为true,在元素下方显示出评论操作元素。
  4697. _replywarp.onclick = function () {
  4698. U.MD.R.subsetReply(this);
  4699. }
  4700. }
  4701. else {
  4702. _replywarp.onclick = function () {//如果为false,弹出一个窗体。
  4703. U.MD.R.viewComment(_rid, true);
  4704. }
  4705. }
  4706. $$("img", {//创建回复图片
  4707. "src": "/img/reply/reply.png"
  4708. }, _replywarp);
  4709. $$("div", {//创建回复按钮
  4710. "innerHTML": "回复",
  4711. "className": "U_MD_R_content_box_content_bottom_replywarp_text"
  4712. }, _replywarp);
  4713. if (_type == 1) {//如果类型为1,并且点击回复后弹出窗体的,那么显示查看更多。
  4714. _showmorewarp = $$("div", { "className": "U_MD_R_content_box_content_bottom_showmorewarp" }, _content_bottom);
  4715. $$("img", {
  4716. "src": "/img/reply/list.png"
  4717. }, _showmorewarp);
  4718. _showmoretext = $$("div", {
  4719. "className": "U_MD_R_content_box_content_bottom_showmore_text"
  4720. }, _showmorewarp);
  4721. if (_readmore) {
  4722. _showmoretext.className = "U_MD_R_content_box_content_bottom_showmore_text U_MD_R_content_box_content_bottom_showmore_text_secondary"
  4723. _showmoretext.innerHTML = _showmoretxtjson ? "共有(" + "<span>" + _showmoretxtjson + "</span>" + ")条评论" : "没有评论(" + "<span>0</span>" + ")";
  4724. }
  4725. else {
  4726. _showmoretext.className = "U_MD_R_content_box_content_bottom_showmore_text U_MD_R_content_box_content_bottom_showmore_text_important"
  4727. _showmoretext.innerHTML = _showmoretxtjson ? "查看更多(" + "<span>" + _showmoretxtjson + "</span>" + ")" : "查看更多(" + "<span>" + 0 + "</span>" + ")";
  4728. _showmorewarp.onclick = function () {
  4729. U.MD.R.viewComment(_rid, false);
  4730. }
  4731. }
  4732. }
  4733. if (_type == 1 && !readmore && U.selectEl(".U_MD_R_content_loading")[0]) {
  4734. if (U.MD.R.data.PageIndex < U.MD.R.data.AllCount) {
  4735. U.selectEl(".U_MD_R_content_loading")[0].innerHTML = "点击加载更多评论";
  4736. }
  4737. else {
  4738. U.selectEl(".U_MD_R_content_loading").hide();
  4739. }
  4740. }
  4741. if (_type == 2 || _type == 3 || (_type == 1 && readmore)) {//如果是2级和3级以下,那么就创建操作区域。
  4742. _contenteditable = $$("div", {//创建子集评论-评论操作区域最外层
  4743. "className": "U_MD_R_content_box_content_edit",
  4744. "style": { "display": "none" }
  4745. }, _content);
  4746. _replyinput = $$("div", { "className": "U_MD_R_Reply_Content", "contenteditable": "true" }, _contenteditable); //创建回复元素
  4747. _bottom = $$("div", { "className": "U_MD_R_content_operation_right_bottom" }, _contenteditable); //创建子集评论-评论操作区域内层
  4748. $$("div", {//创建表情包按钮
  4749. "className": "U_MD_R_content_operation_right_bottom_emoji",
  4750. "onclick": function () {
  4751. U.UF.EV.stopBubble();
  4752. U.MD.UI.face(this, _replyinput);
  4753. U.selectEl(this)[0].append($("#U_MD_UI_face")[0]);
  4754. U.selectEl("#U_MD_UI_face").css({ "position": "relative", "height": "140px", "overflow-y": "scroll", "top": "-150px", "width": "450px", "display": "block" });
  4755. }
  4756. }, _bottom);
  4757. _picturewarp = $$("div", { "className": "U_MD_R_content_operation_right_bottom_picturewarp" }, _bottom); //创建子集评论-评论操作区域-图片最外层
  4758. _picture = $$("img", { src: "/img/reply/img.png" }, _picturewarp); //创建子集评论-评论操作区域-图片元素
  4759. _input = $$("input", { "type": "file" }, _picturewarp); //创建子集评论-评论操作区域-上传input
  4760. _input.onchange = function () {//赋予上传事件
  4761. U.MD.R.uploadImages(this, _img_warp);
  4762. }
  4763. _button = $$("div", {////创建子集评论-评论操作区域-发布按钮
  4764. "className": "U_MD_R_content_operation_right_bottom_release",
  4765. "innerHTML": "发表评论"
  4766. }, _bottom); //内容发布
  4767. _button.onclick = function () {//赋予时间
  4768. if (_type == 1) {
  4769. _position = 2;
  4770. }
  4771. else if (_type == 2) {
  4772. _position = 3;
  4773. }
  4774. else if (_type == 3) {
  4775. _position = 4;
  4776. }
  4777. U.MD.R.release(_info, _type, false, _position);
  4778. }
  4779. _img_warp = $$("div", { "className": "U_MD_R_content_operation_right_bottom_imgloadbox U_MD_R_Reply_Image" }, _contenteditable); //创建子集评论-评论操作区域-图片显示区域
  4780. if (_type != 3) {
  4781. _childrenbox = $$("div", { "className": "U_MD_R_content_comment" }, _box); //内容盒子
  4782. }
  4783. return _childrenbox; //返回元素
  4784. }
  4785. }
  4786. /**
  4787. * 图片上传函数
  4788. * @param {element} input 元素
  4789. * @param {element} 上传成功后,图片插入的位置。
  4790. */
  4791. U.MD.R.uploadImages = function (input, el) {
  4792. var _el = el, _imgwarp, _img, _filetype, _imgtype = /.*(jpg|png|gif|jpeg|JPG|PNG|GIF|JPEG)$/;
  4793. U.selectEl(_el)[0].innerHTML = "";
  4794. _imgwarp = $$("div", {}, _el);
  4795. _img = $$("img", {//创建img
  4796. "src": "/img/Reply/loading.gif",
  4797. "style": { "width": "100px", "height": "100px", "margin-right": "10px" }
  4798. }, _imgwarp);
  4799. U.UF.UP.inputUpload([input], "http://disk.1473.cn/USUpfile.ashx?typename=UseStudioEditor&UserId=FA92AAC5-4134-449F-9659-0DC12F4F68E9", function (r) {
  4800. _filetype = r.value[0].split(".")[1];
  4801. if (_filetype.match(_imgtype)) {//如果获取的文件是符合的文件类型进行上传
  4802. U.selectEl(_imgwarp).remove();
  4803. _imgwarp = $$("div", { "className": "U_MD_R_content_operation_right_bottom_imgloadbox_warp" }, _el);
  4804. $$("img", { "src": "http://fs.1473.cn/" + r.value[0] }, _imgwarp); //创建img
  4805. $$("div", { "className": "closebtn", "onclick": "U.MD.R.uploadImages.close(this)" }, _imgwarp);
  4806. U.alert("上传成功");
  4807. } else {//否则提醒用户选择上传图片文件
  4808. U.alert("请上传图片文件");
  4809. return;
  4810. }
  4811. }, []);
  4812. }
  4813. /**
  4814. * 图片关闭函数
  4815. * @param {element} 事件源
  4816. */
  4817. U.MD.R.uploadImages.close = function (el) {
  4818. U.selectEl(el).Parent().remove();
  4819. }
  4820. /**
  4821. * 二级以下(包括二级、三级等等)评论点击回复后显示隐藏操作区域
  4822. * @param {element} 事件源
  4823. */
  4824. U.MD.R.subsetReply = function (el) {
  4825. // U.selectEl(el)
  4826. var _el = U.selectEl($(el).Parent(2)).find(".U_MD_R_content_box_content_edit");
  4827. if (_el[0].style.display == "block") {
  4828. _el.hide();
  4829. }
  4830. else {
  4831. _el.show();
  4832. }
  4833. }
  4834. /**
  4835. * 发表评论插入函数
  4836. */
  4837. U.MD.R.release = function (el, type, isreply, position) {//发表评论函数
  4838. if (US.userInfo.UserId) {
  4839. var _el = el,
  4840. _type = type,
  4841. _isreply = isreply,
  4842. _position = position,
  4843. _content = U.selectEl(_el).find(".U_MD_R_Reply_Content")[0],
  4844. _imgwarp = U.selectEl(_el).find(".U_MD_R_Reply_Image"),
  4845. _uid = US.userInfo.UserId,
  4846. _un = US.userInfo.UserName,
  4847. _utx = "http://fs.1473.cn/" + US.userInfo.UserImageHead,
  4848. _box;
  4849. if (_content.innerHTML.trim() != "" || _imgwarp.find("img").length > 0) {
  4850. var _rid = Guid.newGuid(),
  4851. _rpid = U.selectEl(el).attr("data-rid"),
  4852. _pid = U.MD.R.data.PID,
  4853. _aid = U.MD.R.data.AID,
  4854. _rc = "",
  4855. _rip = US.userInfo.RegisterIP,
  4856. _url = U.MD.R.data.URL,
  4857. _ra = null,
  4858. _rd = U.selectEl(el).attr("data-rd"),
  4859. _rbid = U.selectEl(el).attr("data-rbid"),
  4860. _rpuid = U.selectEl(el).attr("data-rpuid"),
  4861. _re = 1;
  4862. if (position == 1) {
  4863. _rd = 1;
  4864. }
  4865. else if (position == 2 || position == 3) {
  4866. _rd = parseInt($(el).attr("data-rd")) + 1;
  4867. }
  4868. else {
  4869. _rd = 3;
  4870. _rpid = U.selectEl(el).attr("data-rpid");
  4871. }
  4872. if ($(_imgwarp).find("img").length > 0) {
  4873. _rc = _content.innerHTML.trim() + _imgwarp.find("img")[0].outerHTML;
  4874. }
  4875. else {
  4876. _rc = _content.innerHTML;
  4877. }
  4878. U.A.Request("http://cd.1473.cn/net", ["db.1473.cn", "UseStudio_Reply", "Reply_InsertReply", _rid, _rpid, _pid, _aid, _uid, _un, _utx, _rc, _rip, _url, _ra, _rd, _rpuid, _re, U.MD.R.getNowFormatDate()], function (r) {
  4879. var _data = r.value[0], _appendtype, _readmore,
  4880. _more = U.selectEl("div[data-rid='" + _data.ReplyParentID + "']").find(".U_MD_R_content_box_content_bottom_showmore_text_important span")[0],
  4881. _more1 = U.selectEl("div[data-rid='" + _data.ReplyParentID + "']").find(".U_MD_R_content_box_content_bottom_showmore_text_secondary span")[0];
  4882. U.selectEl(_el).find(".U_MD_R_Reply_Content")[0].innerHTML = "";
  4883. U.UF.E.initEditor($(_el).find(".U_MD_R_Reply_Content")[0]); //调用函数
  4884. U.selectEl(_el).find(".U_MD_R_Reply_Image")[0].innerHTML = "";
  4885. if (_position == 1) {
  4886. _readmore = false;
  4887. _appendtype = true;
  4888. _el = U.selectEl("#U_MD_R_content_user_comment")[0];
  4889. }
  4890. else {
  4891. _readmore = true;
  4892. _val = _more.innerText;
  4893. // _val1 = _more1.innerText;
  4894. if (_position == 2) {
  4895. _el = U.selectEl(_el).Parent().nextSibling;
  4896. _type = 2;
  4897. _appendtype = true;
  4898. }
  4899. if (_position == 3) {
  4900. if ($($(_el)[0].nextSibling).find(".U_MD_R_content_warp_box").length > 0) {
  4901. _el = U.selectEl($(_el)[0].nextSibling).find(".U_MD_R_content_warp_box");
  4902. }
  4903. else {
  4904. _el = $$("div", { "className": "U_MD_R_content_warp_box" }, U.selectEl($(_el)[0].nextSibling)[0]);
  4905. //$(_el).attr({"data-replyid": _data[1][i].ReplyID});
  4906. }
  4907. _type = 2;
  4908. }
  4909. if (_position == 4) {
  4910. _el = U.selectEl($(_el).Parent()).Parent();
  4911. _type = 3;
  4912. }
  4913. _more.innerText = ++_val;
  4914. //_more1.innerText = ++_val1;
  4915. U.selectEl($(_content).Parent()).hide();
  4916. }
  4917. var _box = U.MD.R.printCommentHtml(_el, _type, {
  4918. rid: _data.ReplyID,
  4919. rpid: _data.ReplyParentID,
  4920. deep: _data.ReplyDeep,
  4921. topid: _data.ReplyTopID,
  4922. uid: _data.UserID,
  4923. tx: _data.ReplyUserThumbnailImageHead,
  4924. un: _data.UserName,
  4925. time: U.MD.R.getNowFormatDate() + '.0',
  4926. content: _data.ReplyContent,
  4927. replyinfo: {
  4928. uid: _data.uid, //评论的用户id
  4929. un: _data.un, //评论的用户名
  4930. tx: _data.tx//评论的头像
  4931. }
  4932. }, _appendtype, _isreply, _readmore);
  4933. // if (_position == 3) {
  4934. // var _box1 = $$("div", {"className": "U_MD_R_content_warp_box"}, _box);
  4935. // U.selectEl(_box1).attr({"data-replyid": _data[1][i].ReplyID});
  4936. // }
  4937. U.alert("评论成功");
  4938. }
  4939. );
  4940. }
  4941. else {
  4942. U.alert("请输入评论内容");
  4943. }
  4944. }
  4945. else {
  4946. U.Alert("请先登录");
  4947. }
  4948. }
  4949. /**
  4950. * 点赞函数
  4951. * @param {element} 事件源
  4952. * @param {string} 评论id
  4953. * @param {string} 用户id
  4954. */
  4955. U.MD.R.like = function (e, rid, uid) {
  4956. if (US.userInfo.UserId) {
  4957. var _el = e, _rid = rid, _uid = uid;
  4958. U.A.Request("http://cd.1473.cn/net", ["db.1473.cn", "UseStudio_Reply", "Reply_SelectRepeatLikes", _rid, _uid], function (r) {
  4959. var _img = U.selectEl(_el).find("img")[0],
  4960. _text = U.selectEl(_el).find(".U_MD_R_content_box_content_bottom_likeswarp_text")[0],
  4961. _val = parseInt(_text.innerHTML);
  4962. if (r.value[0].mode == 0) {
  4963. _img.src = "/img/reply/NOFabulous.png";
  4964. _text.innerHTML = --_val;
  4965. }
  4966. else {
  4967. _img.src = "/img/reply/Fabulous.png";
  4968. _text.innerHTML = ++_val;
  4969. }
  4970. });
  4971. }
  4972. else {
  4973. U.Alert("请先登录");
  4974. }
  4975. }
  4976. /**
  4977. * 图片错误所执行的函数
  4978. * @param {element} 事件源
  4979. */
  4980. U.MD.R.imgError = function (el) {
  4981. U.selectEl(el)[0].src = "/img/UserHead/UseHead.jpg";
  4982. }
  4983. /**
  4984. * 函数作用:调用登录函数
  4985. */
  4986. U.MD.R.login = function () {
  4987. if ($("#U_MD_HomeC_Pop")[0]) {
  4988. U.UF.F.windowTopCenter($("#U_MD_HomeC_Pop")[0]);
  4989. }
  4990. else {
  4991. U.UF.CD.loadPageCrossDomain(function () { });
  4992. U.MD.U.L.setLoginCallBack(function () {
  4993. U.MD.R.login.cb();
  4994. });
  4995. }
  4996. }
  4997. /**
  4998. * cookie登录,如果登录成功,则修改头像以及用户名
  4999. */
  5000. U.MD.R.login.cookieLogin = function (cb) {
  5001. if (U.UF.Cookie.get("usestudiosso") && U.UF.Cookie.get("usestudiosso", "userid")[0]) {
  5002. U.UF.CD.loadPageCrossDomain(function () {
  5003. U.MD.U.L.loginCallBack = function () {
  5004. cb && cb();
  5005. U.selectEl(".U_MD_R_content_operation_userhead img")[0].src = 'http://fs.1473.cn/' + US.userInfo.UserThumbnailImageHead; //用户登录后的操作
  5006. U.selectEl(".U_MD_R_content_operation_userlogin")[0].innerHTML = US.userInfo.UserName; //设置登录用户头像,登录用户名等操作
  5007. }
  5008. });
  5009. } else {
  5010. cb && cb();
  5011. }
  5012. }
  5013. /**
  5014. * 登录之后的回调函数
  5015. */
  5016. U.MD.R.login.cb = function () {
  5017. U.selectEl(".U_MD_R_content_operation_userhead img")[0].src = 'http://fs.1473.cn/' + US.userInfo.UserThumbnailImageHead; //用户登录后的操作
  5018. U.selectEl(".U_MD_R_content_operation_userlogin")[0].innerHTML = US.userInfo.UserName; //设置登录用户头像,登录用户名等操作
  5019. }
  5020. //获取当前时间
  5021. U.MD.R.getNowFormatDate = function () {
  5022. var date = new Date();
  5023. var seperator1 = "-";
  5024. var seperator2 = ":";
  5025. var month = date.getMonth() + 1;
  5026. var strDate = date.getDate();
  5027. if (month >= 1 && month <= 9) {
  5028. month = "0" + month;
  5029. }
  5030. if (strDate >= 0 && strDate <= 9) {
  5031. strDate = "0" + strDate;
  5032. }
  5033. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  5034. + " " + date.getHours() + seperator2 + date.getMinutes()
  5035. + seperator2 + date.getSeconds();
  5036. return currentdate;
  5037. }
  5038. ;
  5039. ///<jscompress sourcefile="Table.js" />
  5040. Namespace.register("U.MD.UI.table");
  5041. /*
  5042. 表格控件的基础函数
  5043. param1 datasource 数据源是一个object类型数组。
  5044. param2 titles 标题是一个json类型数据
  5045. param3 css 样式是一个json类型数据
  5046. param4 parent 父元素
  5047. */
  5048. U.MD.UI.table = function (datasource, titles, css, parent) {
  5049. U.MD.UI.table.thead(datasource, titles, css, parent);
  5050. //创建表格
  5051. }
  5052. /*
  5053. 表格控件的头部函数
  5054. param1 {json} datasource 数据源是一个object类型数组。
  5055. param2 {json} titles 标题是一个json类型数据
  5056. param3 {json} css 宽度是一个json类型数据
  5057. param4 {element} parent 父元素
  5058. param5 {number} index 默认页面
  5059. param6 {number} prows 页面
  5060. */
  5061. U.MD.UI.table.thead = function (datasource, titles, css, parent, index, prows) {
  5062. if (!index) {
  5063. //index默认为一
  5064. index = 1;
  5065. //prwos默认为数据源的长度
  5066. prows = datasource.length;
  5067. }
  5068. var _table, _thead, _tr, _tbody;
  5069. //申明变量
  5070. _table = $$("table", { style: {
  5071. "text-align":"center",
  5072. "position": "relative",
  5073. "width": " 100%",
  5074. "border-collapse": " collapse",
  5075. "border-width": " 1px",
  5076. "border-style": " solid",
  5077. "border-color": " rgb(213, 213, 213)",
  5078. "border-image": " initial",
  5079. "display": "table"} }, parent);
  5080. //创建table标签
  5081. _thead = $$("thead", {}, _table);
  5082. //创建thead标签
  5083. _tr = $$("tr", {}, _thead);
  5084. //创建tr标签
  5085. for (var num in titles) {
  5086. //遍历titles
  5087. if (typeof titles[num] === "object") {
  5088. //判断是否有绑定事件
  5089. $$("th", { innerHTML: titles[num].name, style: {
  5090. "cssText": css[num],
  5091. "padding": "10px 0",
  5092. "font-weight": "normal",
  5093. "border": "1px solid #d5d5d5"
  5094. }, id: "th" }, _tr);
  5095. //生成th
  5096. } else {
  5097. $$("th", { innerHTML: titles[num], style: {
  5098. "cssText": css[num],
  5099. "padding": "10px 0",
  5100. "font-weight": "normal",
  5101. "border": "1px solid #d5d5d5"
  5102. }, id: "th" }, _tr);
  5103. //生成th
  5104. }
  5105. }
  5106. _tbody = $$("tbody", { style: { cssText: "width:100%;" }, id: "tbody" }, _table);
  5107. //生成tbody
  5108. U.MD.UI.table.tbody(_tbody, datasource, titles, css, index, prows);
  5109. //运行tbody函数
  5110. return _tbody;
  5111. //返回tbody
  5112. }
  5113. /*
  5114. 表格控件的身体函数
  5115. param1 {element} parent 父元素,表格生成的地方
  5116. param2 {json} datasource 数据源是一个object类型数组。
  5117. param3 {json} titles 标题是一个json类型数据
  5118. param4 {json} css 宽度是一个json类型数据
  5119. param5 {number} index 默认页面
  5120. param6 {number} prows 页面行数
  5121. */
  5122. U.MD.UI.table.tbody = function (parent, datasource, titles, css, index, prows) {
  5123. var _tr, _td, _div, _neirong;
  5124. //申明变量
  5125. for (var num = (index - 1) * prows; num < index * prows && num < datasource.length; num++) {
  5126. //建立一个循环,以(index - 1) * prows为初始值,index * prows为终点进行循环
  5127. if (num % 2 != 0) {
  5128. //判断table列表的行数是否是单数
  5129. _tr = $$("tr", { style: { cssText: "background-color: #FFF;" }, id: "tr" }, parent);
  5130. //行数是单的背景颜色是白色
  5131. } else {
  5132. _tr = $$("tr", { style: { cssText: "background-color: #dde4ee;" }, id: "tr" }, parent);
  5133. //行数是双的背景颜色是#dde4ee
  5134. }
  5135. for (var name in titles) {
  5136. //遍历titles
  5137. _td = $$("td", { id: "td" }, _tr);
  5138. //生成td
  5139. if (titles[name].content) {
  5140. for (var k = 0; k < titles[name].content.length; k++) {
  5141. //遍历添加的元素
  5142. _div = U.MD.UI.table.printDiv(_td, titles[name].content[k]);
  5143. //生成div
  5144. if (titles[name].content[k].onclick) {
  5145. U.MD.UI.table.onclick(_div, datasource[num], titles[name].content[k].onclick);
  5146. }
  5147. //添加点击事件
  5148. }
  5149. } else {
  5150. _div = $$("div", { innerHTML: datasource[num][name], style: { "overflow": "hidden", "cssText": css[name]} }, _td);
  5151. if (titles[name].id) {//判断是否需要给td添加id
  5152. _div.id = datasource[num][titles[name].id];
  5153. }
  5154. }
  5155. }
  5156. }
  5157. }
  5158. /*
  5159. 表格控件的分页表格函数
  5160. param1 {json} datasource 数据源 json
  5161. param2 {json} titles 标题是一个json类型数据
  5162. param3 {json} css 宽度是一个json类型数据
  5163. param4 {number} prows 页面行数 int
  5164. param5 {number} index 默认页面 int
  5165. param6 {element} parent 父元素
  5166. */
  5167. U.MD.UI.table.pageTable = function (datasource, titles, css, prows, index, parent) {
  5168. var _div = $$("div", { "style": {
  5169. "left": "0px",
  5170. "right": "0px",
  5171. "width": "100%",
  5172. "margin": "0 auto",
  5173. "top": "200px" }
  5174. }, parent);
  5175. //生成一个大div放表格和分页
  5176. var _tdiv = $$("div", {}, _div);
  5177. //生成一个div 放表格
  5178. var _tbody = U.MD.UI.table.thead(datasource, titles, css, _tdiv, index, prows);
  5179. //生成表格,放_tdiv里
  5180. var _pdiv = $$("div", { "style": {"width": "650px", "margin": "20px auto 0 auto"}}, _div); //生成一个div 放分页按钮
  5181. new U.UF.P.page(_pdiv, datasource.length, prows, index, function (page) {
  5182. //生成分页控件,当点击其他页面是触发匿名波函数
  5183. U.MD.UI.table.delChild(_tbody);
  5184. //当点击下一页时,首先删除tbody 下全部子元
  5185. U.MD.UI.table.tbody(_tbody, datasource, titles, css, page, prows);
  5186. //生成tbody
  5187. });
  5188. }
  5189. /*
  5190. 删除子元素函数
  5191. param {element}obj 删除子元素的函数
  5192. */
  5193. U.MD.UI.table.delChild = function (obj) {
  5194. for (var num = obj.children.length - 1; num >= 0; num--) {
  5195. //得到元素底下的全部子元素
  5196. obj.removeChild(obj.children[num])
  5197. //删除子元素
  5198. }
  5199. }
  5200. /*
  5201. 点击事件函数
  5202. param1 {element} obj 点击事件的触发对象
  5203. param2 {json} datasource 展示的数据
  5204. */
  5205. U.MD.UI.table.onclick = function (obj, datasource, fun) {
  5206. obj.onclick = function () {
  5207. //绑定事件
  5208. fun(datasource);
  5209. }
  5210. }
  5211. /*
  5212. 打印div
  5213. param2 {sting || element} content 生成内容(字符串或者元素)
  5214. param1 {element} parent 生成的父元素
  5215. */
  5216. U.MD.UI.table.printDiv = function (parent, content) {
  5217. var _div;
  5218. //判断content类型是否是字符串
  5219. if (typeof content.name == "string") {
  5220. //是字符串的生成div,打印内容
  5221. _div = $$("div", { "innerHTML": content.name }, parent);
  5222. }
  5223. //如果content类型是object类型
  5224. if (typeof content.name == "object") {
  5225. //就克隆Contet
  5226. var _dd = content.name.cloneNode(true);
  5227. parent.appendChild(_dd);
  5228. _div = _dd;
  5229. }
  5230. return _div;
  5231. };
  5232. ///<jscompress sourcefile="Tree.js" />
  5233. Namespace.register("U.MD.UI.Tree");
  5234. //json要求:
  5235. //里面需要包含id,name,deep(依赖),img_url(显示图片源),child(附属目录),为一个数值,每一个值为一个json,child的格式也是一样
  5236. //案例
  5237. // [{ id: "1", name: "文件夹", deep: 0, img_url: 'http://api.1473.cn/Uform/Image/tree/folder.png',
  5238. //child: [{ id: "2", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png",
  5239. // child: [{ id: "5", name: "文件夹", deep: 2, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  5240. // },
  5241. //{ id: "3", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png" },
  5242. //{ id: "4", name: "文件夹", deep: 1, img_url: "http://api.1473.cn/Uform/Image/tree/folder.png"}]
  5243. //}]
  5244. /*
  5245. 将二维数组转化为列表的方法
  5246. arr {arr} 数据源json里面需要包含id,name,deep(依赖),img_url(显示图片源),child(附属目录),外部是数组
  5247. tree {object} 要插入列表的地方
  5248. bookfun {function} 每一行目录的点击事件
  5249. leftfun {function} 右键事件
  5250. */
  5251. U.MD.UI.Tree = function (arr, treeaction, bookfun, leftfun) {
  5252. json = []; //将外变量josn清空
  5253. var _json = arr; //定义局部变量_json,值为r
  5254. for (var _i = 0; _i < _json.length; _i++) { //定义循环,循环对象为
  5255. U.MD.UI.Tree.jsonAdd(json, _json[_i]); //运行函数,生成json
  5256. }
  5257. treeaction.innerHTML = ""; //清空tree的内容
  5258. U.MD.UI.Tree.treeCreate(json, treeaction, bookfun); //运行方法,在tree中生成树状图
  5259. treeaction.oncontextmenu = function (e) {
  5260. e.preventDefault(); //去掉默认的contextmenu事件,否则会和右键事件同时出现。
  5261. };
  5262. treeaction.onmousedown = function (e) { //设置树状图的右键点击事件
  5263. if (e.button == 2) {
  5264. leftfun(e, bookfun); //运行右键事件
  5265. }
  5266. }
  5267. }
  5268. /*
  5269. 将二维数组转化为列表的方法
  5270. json {arr} 数据源json里面需要包含id,name,deep(依赖),img_url(显示图片源),child(附属目录),外部是数组
  5271. tree {object} 要插入列表的地方
  5272. bookfun {function} 没一行的点击事件
  5273. */
  5274. U.MD.UI.Tree.treeCreate = function (json, tree, onclickfun) {
  5275. for (var _i = 0; _i < json.length; _i++) { //创建循环,解析json数组,得到每一个json
  5276. var _ul = $$("ul", { className: "U_MD_UI_Tree_a " + json[_i].parentID }, tree); //创建var对象,在tree中创建ul
  5277. var _li = $$("li", { id: json[_i].id, parentid: json[_i].parentid, className: "U_MD_UI_Tree_listyle", parentid: json[_i].id, deep: json[_i].deep }, _ul); //创建var对象,在ul中创建li,id为a+jsonid
  5278. var _img = $$("img", { "onerror": U.MD.C.imgError, src: json[_i].img_url, className: "U_MD_UI_Tree_imgstyle" }, _li); //创建var对象,在li中创建img
  5279. var _span = $$("span", { innerHTML: json[_i].name, className: "spanstyle" }, _li); //创建var对象,在li中创建span,内容为json的name
  5280. _ul.style.display = "none";
  5281. if (json[_i].deep == "1") { _ul.style.display = "block" } //进行判断,判断是否为一级目录,不是的先隐藏
  5282. _img.aa = false; //定义img的一个变量,用来控制列表的展开和关闭
  5283. var _liobj = document.getElementsByClassName("U_MD_UI_Tree_a " + json[_i].parentID)[0]; //定义一个let对象为获取到的对应的li对象
  5284. _ul.style.display = _liobj.style.display; //如果是展开状态,显示ul
  5285. _li.onclick = function () {//定义li的点击事件
  5286. onclickfun(this); //执行bookconlick函数,改变book对象的内容
  5287. _liobj = document.getElementsByClassName("U_MD_UI_Tree_a " + this.parentid);
  5288. if (_img.aa === true) { //如果img.aa等于true
  5289. _img.aa = false; //修改img.aa对象为false
  5290. for (var _ii = 0; _ii < _liobj.length; _ii++) { //定义循环,循环对象为获取到的li对象集合
  5291. _liobj[_ii].style.display = "none"; //将集合隐藏
  5292. }
  5293. } else { //如果img.aa等于false
  5294. _img.aa = true; //修改img.aa等于true
  5295. for (var _ii = 0; _ii < _liobj.length; _ii++) { //定义循环,循环对象为获取到的li对象集合
  5296. _liobj[_ii].style.display = "block"; //将集合显示
  5297. }
  5298. }
  5299. }
  5300. if (json[_i].child) {
  5301. U.MD.UI.Tree.treeCreate(json[_i].child, _ul, onclickfun); //重新调用函数,参数为child的对象数组,ul对象,20的边距值,隐藏,改变的book对象
  5302. }
  5303. }
  5304. }
  5305. /*
  5306. 在json中插入json的方法
  5307. json {arr} 要被插入的json对象
  5308. addjson {json} 要查入的json对象
  5309. */
  5310. U.MD.UI.Tree.jsonAdd = function (json, addjson) {
  5311. var _addid = addjson.parentID; //定义要目的地id,等于插入json的parentID值
  5312. if (_addid == "0") { //进行判断,判断目的地id是否在第一层(0)
  5313. json[json.length] = addjson; //如果在,直接在json的第一层中加入要插入的json
  5314. return json; //结束方法,返回json对象
  5315. }
  5316. for (var _i = 0; _i < json.length; _i++) { //创建循环,解析json数组,得到每一个json
  5317. if (json[_i].id == _addid) { //进行判断,判断json的id是否等于获取到的目的地id,如果是
  5318. if (json[_i].child) { //进行判断,判断json的child有没有值
  5319. json[_i].child[json[_i].child.length] = addjson; //如果有,就在其中添加插入对象
  5320. return json; //结束方法,返回json对象
  5321. } else {//如果json中没有child
  5322. json[_i].child = [];
  5323. json[_i].child[json[_i].child.length] = addjson; //将json的child等于插入的对象
  5324. return json; //结束方法,返回json对象
  5325. }
  5326. }
  5327. if (json[_i].child) { //如果json的id不与目的地id相等且json中存在child
  5328. var _return = U.MD.UI.Tree.jsonAdd(json[_i].child, addjson); //定义函数,调用自己,变量为json的child,要插入的json
  5329. json[_i].child = _return; //json的child等于返回的json
  5330. }
  5331. }
  5332. return json; //返回json对象
  5333. }
  5334. /*
  5335. rightButton {object} 要插入li的右键对象
  5336. e {json} 点击事件的信息
  5337. */
  5338. U.MD.UI.Tree.rightOnclick = function (rightButton, e) {
  5339. var _li = $$("li", { className: "U_MD_UI_Tree_rightli", innerHTML: "新建文件夹", parentid: e.path[1].parentid, deep: parseInt(e.path[1].deep) + 1 }, rightButton); //在右键菜单中添加li
  5340. var _li1 = $$("li", { className: "U_MD_UI_Tree_rightli", innerHTML: "重命名", parentid: e.path[1].parentid, deep: parseInt(e.path[1].deep) + 1 }, rightButton); //在右键菜单中添加li
  5341. var _li2 = $$("li", { className: "U_MD_UI_Tree_rightli", innerHTML: "删除", parentid: e.path[1].parentid, deep: parseInt(e.path[1].deep + 1) }, rightButton); //在右键菜单中添加li
  5342. var _return = [];
  5343. _return[0] = _li;
  5344. _return[1] = _li1;
  5345. _return[2] = _li2;
  5346. return _return;
  5347. }
  5348. /*
  5349. 搜索arr中最高的id方法
  5350. arr {arr} 要搜索的arr对象
  5351. */
  5352. U.MD.UI.Tree.createID = function (arr) {
  5353. var _return = 0; //定义变量
  5354. for (var _i = 0; _i < arr.length; _i++) {//定义循环,循环对象为arr
  5355. if (parseInt(arr[_i].id) > _return) {//进行判断,如果arr的id比_return大
  5356. _return = parseInt(arr[_i].id); //修改_return的值
  5357. }
  5358. }
  5359. return _return; //返回变量
  5360. }
  5361. ;
  5362. ///<jscompress sourcefile="Txt.js" />
  5363. //编辑器
  5364. Namespace.register("U.MD.UI.txt");;
  5365. ///<jscompress sourcefile="Upload.js" />
  5366. ;