ueditor.all.min-1.js 695 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329
  1. /*!
  2. * UEditor
  3. * version: ueditor
  4. * build: Wed Dec 26 2018 17:24:52 GMT+0800 (CST)
  5. */
  6. !(function () {
  7. function getListener(a, b, c) {
  8. var d
  9. return (
  10. (b = b.toLowerCase()),
  11. (d = a.__allListeners || (c && (a.__allListeners = {}))) &&
  12. (d[b] || (c && (d[b] = [])))
  13. )
  14. }
  15. function getDomNode(a, b, c, d, e, f) {
  16. var g,
  17. h = d && a[b]
  18. for (!h && (h = a[c]); !h && (g = (g || a).parentNode); ) {
  19. if ('BODY' == g.tagName || (f && !f(g))) return null
  20. h = g[c]
  21. }
  22. return h && e && !e(h) ? getDomNode(h, b, c, !1, e) : h
  23. }
  24. UEDITOR_CONFIG = window.UEDITOR_CONFIG || {}
  25. var baidu = window.baidu || {}
  26. ;(window.baidu = baidu),
  27. (window.UE = baidu.editor = window.UE || {}),
  28. (UE.plugins = {}),
  29. (UE.commands = {}),
  30. (UE.instants = {}),
  31. (UE.I18N = {}),
  32. (UE._customizeUI = {}),
  33. (UE.version = '1.4.3')
  34. var dom = (UE.dom = {}),
  35. browser = (UE.browser = (function () {
  36. var a = navigator.userAgent.toLowerCase(),
  37. b = window.opera,
  38. c = {
  39. ie: /(msie\s|trident.*rv:)([\w.]+)/.test(a),
  40. opera: !!b && b.version,
  41. webkit: a.indexOf(' applewebkit/') > -1,
  42. mac: a.indexOf('macintosh') > -1,
  43. quirks: 'BackCompat' == document.compatMode
  44. }
  45. c.gecko = 'Gecko' == navigator.product && !c.webkit && !c.opera && !c.ie
  46. var d = 0
  47. if (c.ie) {
  48. var e = a.match(/(?:msie\s([\w.]+))/),
  49. f = a.match(/(?:trident.*rv:([\w.]+))/)
  50. ;(d =
  51. e && f && e[1] && f[1]
  52. ? Math.max(1 * e[1], 1 * f[1])
  53. : e && e[1]
  54. ? 1 * e[1]
  55. : f && f[1]
  56. ? 1 * f[1]
  57. : 0),
  58. (c.ie11Compat = 11 == document.documentMode),
  59. (c.ie9Compat = 9 == document.documentMode),
  60. (c.ie8 = !!document.documentMode),
  61. (c.ie8Compat = 8 == document.documentMode),
  62. (c.ie7Compat =
  63. (7 == d && !document.documentMode) || 7 == document.documentMode),
  64. (c.ie6Compat = d < 7 || c.quirks),
  65. (c.ie9above = d > 8),
  66. (c.ie9below = d < 9),
  67. (c.ie11above = d > 10),
  68. (c.ie11below = d < 11)
  69. }
  70. if (c.gecko) {
  71. var g = a.match(/rv:([\d\.]+)/)
  72. g &&
  73. ((g = g[1].split('.')),
  74. (d = 1e4 * g[0] + 100 * (g[1] || 0) + 1 * (g[2] || 0)))
  75. }
  76. return (
  77. /chrome\/(\d+\.\d)/i.test(a) && (c.chrome = +RegExp.$1),
  78. /(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(a) &&
  79. !/chrome/i.test(a) &&
  80. (c.safari = +(RegExp.$1 || RegExp.$2)),
  81. c.opera && (d = parseFloat(b.version())),
  82. c.webkit && (d = parseFloat(a.match(/ applewebkit\/(\d+)/)[1])),
  83. (c.version = d),
  84. (c.isCompatible =
  85. !c.mobile &&
  86. ((c.ie && d >= 6) ||
  87. (c.gecko && d >= 10801) ||
  88. (c.opera && d >= 9.5) ||
  89. (c.air && d >= 1) ||
  90. (c.webkit && d >= 522) ||
  91. !1)),
  92. c
  93. )
  94. })()),
  95. ie = browser.ie,
  96. webkit = browser.webkit,
  97. gecko = browser.gecko,
  98. opera = browser.opera,
  99. utils = (UE.utils = {
  100. each: function (a, b, c) {
  101. if (null != a)
  102. if (a.length === +a.length) {
  103. for (var d = 0, e = a.length; d < e; d++)
  104. if (b.call(c, a[d], d, a) === !1) return !1
  105. } else
  106. for (var f in a)
  107. if (a.hasOwnProperty(f) && b.call(c, a[f], f, a) === !1) return !1
  108. },
  109. makeInstance: function (a) {
  110. var b = new Function()
  111. return (b.prototype = a), (a = new b()), (b.prototype = null), a
  112. },
  113. extend: function (a, b, c) {
  114. if (b) for (var d in b) (c && a.hasOwnProperty(d)) || (a[d] = b[d])
  115. return a
  116. },
  117. extend2: function (a) {
  118. for (var b = arguments, c = 1; c < b.length; c++) {
  119. var d = b[c]
  120. for (var e in d) a.hasOwnProperty(e) || (a[e] = d[e])
  121. }
  122. return a
  123. },
  124. inherits: function (a, b) {
  125. var c = a.prototype,
  126. d = utils.makeInstance(b.prototype)
  127. return utils.extend(d, c, !0), (a.prototype = d), (d.constructor = a)
  128. },
  129. bind: function (a, b) {
  130. return function () {
  131. return a.apply(b, arguments)
  132. }
  133. },
  134. defer: function (a, b, c) {
  135. var d
  136. return function () {
  137. c && clearTimeout(d), (d = setTimeout(a, b))
  138. }
  139. },
  140. indexOf: function (a, b, c) {
  141. var d = -1
  142. return (
  143. (c = this.isNumber(c) ? c : 0),
  144. this.each(a, function (a, e) {
  145. if (e >= c && a === b) return (d = e), !1
  146. }),
  147. d
  148. )
  149. },
  150. removeItem: function (a, b) {
  151. for (var c = 0, d = a.length; c < d; c++)
  152. a[c] === b && (a.splice(c, 1), c--)
  153. },
  154. trim: function (a) {
  155. return a.replace(/(^[ \t\n\r]+)|([ \t\n\r]+$)/g, '')
  156. },
  157. listToMap: function (a) {
  158. if (!a) return {}
  159. a = utils.isArray(a) ? a : a.split(',')
  160. for (var b, c = 0, d = {}; (b = a[c++]); ) d[b.toUpperCase()] = d[b] = 1
  161. return d
  162. },
  163. unhtml: function (a, b) {
  164. return a
  165. ? a.replace(
  166. b || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g,
  167. function (a, b) {
  168. return b
  169. ? a
  170. : {
  171. '<': '&lt;',
  172. '&': '&amp;',
  173. '"': '&quot;',
  174. '>': '&gt;',
  175. "'": '&#39;'
  176. }[a]
  177. }
  178. )
  179. : ''
  180. },
  181. unhtmlForUrl: function (a, b) {
  182. return a
  183. ? a.replace(b || /[<">']/g, function (a) {
  184. return {
  185. '<': '&lt;',
  186. '&': '&amp;',
  187. '"': '&quot;',
  188. '>': '&gt;',
  189. "'": '&#39;'
  190. }[a]
  191. })
  192. : ''
  193. },
  194. html: function (a) {
  195. return a
  196. ? a.replace(/&((g|l|quo)t|amp|#39|nbsp);/g, function (a) {
  197. return {
  198. '&lt;': '<',
  199. '&amp;': '&',
  200. '&quot;': '"',
  201. '&gt;': '>',
  202. '&#39;': "'",
  203. '&nbsp;': ' '
  204. }[a]
  205. })
  206. : ''
  207. },
  208. cssStyleToDomStyle: (function () {
  209. var a = document.createElement('div').style,
  210. b = {
  211. float:
  212. void 0 != a.cssFloat
  213. ? 'cssFloat'
  214. : void 0 != a.styleFloat
  215. ? 'styleFloat'
  216. : 'float'
  217. }
  218. return function (a) {
  219. return (
  220. b[a] ||
  221. (b[a] = a.toLowerCase().replace(/-./g, function (a) {
  222. return a.charAt(1).toUpperCase()
  223. }))
  224. )
  225. }
  226. })(),
  227. loadFile: (function () {
  228. function a(a, c) {
  229. try {
  230. for (var d, e = 0; (d = b[e++]); )
  231. if (d.doc === a && d.url == (c.src || c.href)) return d
  232. } catch (f) {
  233. return null
  234. }
  235. }
  236. var b = []
  237. return function (c, d, e) {
  238. var f = a(c, d)
  239. if (f) return void (f.ready ? e && e() : f.funs.push(e))
  240. if ((b.push({ doc: c, url: d.src || d.href, funs: [e] }), !c.body)) {
  241. var g = []
  242. for (var h in d) 'tag' != h && g.push(h + '="' + d[h] + '"')
  243. return void c.write(
  244. '<' + d.tag + ' ' + g.join(' ') + ' ></' + d.tag + '>'
  245. )
  246. }
  247. if (!d.id || !c.getElementById(d.id)) {
  248. var i = c.createElement(d.tag)
  249. delete d.tag
  250. for (var h in d) i.setAttribute(h, d[h])
  251. ;(i.onload = i.onreadystatechange =
  252. function () {
  253. if (
  254. !this.readyState ||
  255. /loaded|complete/.test(this.readyState)
  256. ) {
  257. if (((f = a(c, d)), f.funs.length > 0)) {
  258. f.ready = 1
  259. for (var b; (b = f.funs.pop()); ) b()
  260. }
  261. i.onload = i.onreadystatechange = null
  262. }
  263. }),
  264. (i.onerror = function () {
  265. throw Error(
  266. 'The load ' +
  267. (d.href || d.src) +
  268. ' fails,check the url settings of file ueditor.config.js '
  269. )
  270. }),
  271. c.getElementsByTagName('head')[0].appendChild(i)
  272. }
  273. }
  274. })(),
  275. isEmptyObject: function (a) {
  276. if (null == a) return !0
  277. if (this.isArray(a) || this.isString(a)) return 0 === a.length
  278. for (var b in a) if (a.hasOwnProperty(b)) return !1
  279. return !0
  280. },
  281. fixColor: function (a, b) {
  282. if (/color/i.test(a) && /rgba?/.test(b)) {
  283. var c = b.split(',')
  284. if (c.length > 3) return ''
  285. b = '#'
  286. for (var d, e = 0; (d = c[e++]); )
  287. (d = parseInt(d.replace(/[^\d]/gi, ''), 10).toString(16)),
  288. (b += 1 == d.length ? '0' + d : d)
  289. b = b.toUpperCase()
  290. }
  291. return b
  292. },
  293. optCss: function (a) {
  294. function b(a, b) {
  295. if (!a) return ''
  296. var c = a.top,
  297. d = a.bottom,
  298. e = a.left,
  299. f = a.right,
  300. g = ''
  301. if (c && e && d && f)
  302. g +=
  303. ';' +
  304. b +
  305. ':' +
  306. (c == d && d == e && e == f
  307. ? c
  308. : c == d && e == f
  309. ? c + ' ' + e
  310. : e == f
  311. ? c + ' ' + e + ' ' + d
  312. : c + ' ' + f + ' ' + d + ' ' + e) +
  313. ';'
  314. else for (var h in a) g += ';' + b + '-' + h + ':' + a[h] + ';'
  315. return g
  316. }
  317. var c, d
  318. return (
  319. (a = a.replace(
  320. /(padding|margin|border)\-([^:]+):([^;]+);?/gi,
  321. function (a, b, e, f) {
  322. if (1 == f.split(' ').length)
  323. switch (b) {
  324. case 'padding':
  325. return !c && (c = {}), (c[e] = f), ''
  326. case 'margin':
  327. return !d && (d = {}), (d[e] = f), ''
  328. case 'border':
  329. return 'initial' == f ? '' : a
  330. }
  331. return a
  332. }
  333. )),
  334. (a += b(c, 'padding') + b(d, 'margin')),
  335. a
  336. .replace(/^[ \n\r\t;]*|[ \n\r\t]*$/, '')
  337. .replace(/;([ \n\r\t]+)|\1;/g, ';')
  338. .replace(/(&((l|g)t|quot|#39))?;{2,}/g, function (a, b) {
  339. return b ? b + ';;' : ';'
  340. })
  341. )
  342. },
  343. clone: function (a, b) {
  344. var c
  345. b = b || {}
  346. for (var d in a)
  347. a.hasOwnProperty(d) &&
  348. ((c = a[d]),
  349. 'object' == typeof c
  350. ? ((b[d] = utils.isArray(c) ? [] : {}), utils.clone(a[d], b[d]))
  351. : (b[d] = c))
  352. return b
  353. },
  354. transUnitToPx: function (a) {
  355. if (!/(pt|cm)/.test(a)) return a
  356. var b
  357. switch (
  358. (a.replace(/([\d.]+)(\w+)/, function (c, d, e) {
  359. ;(a = d), (b = e)
  360. }),
  361. b)
  362. ) {
  363. case 'cm':
  364. a = 25 * parseFloat(a)
  365. break
  366. case 'pt':
  367. a = Math.round((96 * parseFloat(a)) / 72)
  368. }
  369. return a + (a ? 'px' : '')
  370. },
  371. domReady: (function () {
  372. function a(a) {
  373. a.isReady = !0
  374. for (var c; (c = b.pop()); c());
  375. }
  376. var b = []
  377. return function (c, d) {
  378. d = d || window
  379. var e = d.document
  380. c && b.push(c),
  381. 'complete' === e.readyState
  382. ? a(e)
  383. : (e.isReady && a(e),
  384. browser.ie && 11 != browser.version
  385. ? (!(function () {
  386. if (!e.isReady) {
  387. try {
  388. e.documentElement.doScroll('left')
  389. } catch (b) {
  390. return void setTimeout(arguments.callee, 0)
  391. }
  392. a(e)
  393. }
  394. })(),
  395. d.attachEvent('onload', function () {
  396. a(e)
  397. }))
  398. : (e.addEventListener(
  399. 'DOMContentLoaded',
  400. function () {
  401. e.removeEventListener(
  402. 'DOMContentLoaded',
  403. arguments.callee,
  404. !1
  405. ),
  406. a(e)
  407. },
  408. !1
  409. ),
  410. d.addEventListener(
  411. 'load',
  412. function () {
  413. a(e)
  414. },
  415. !1
  416. )))
  417. }
  418. })(),
  419. cssRule:
  420. browser.ie && 11 != browser.version
  421. ? function (a, b, c) {
  422. var d, e
  423. if (void 0 === b || (b && b.nodeType && 9 == b.nodeType)) {
  424. if (
  425. ((c = b && b.nodeType && 9 == b.nodeType ? b : c || document),
  426. (d = c.indexList || (c.indexList = {})),
  427. (e = d[a]),
  428. void 0 !== e)
  429. )
  430. return c.styleSheets[e].cssText
  431. } else {
  432. if (
  433. ((c = c || document),
  434. (d = c.indexList || (c.indexList = {})),
  435. (e = d[a]),
  436. '' === b)
  437. )
  438. return (
  439. void 0 !== e &&
  440. ((c.styleSheets[e].cssText = ''), delete d[a], !0)
  441. )
  442. void 0 !== e
  443. ? (sheetStyle = c.styleSheets[e])
  444. : ((sheetStyle = c.createStyleSheet(
  445. '',
  446. (e = c.styleSheets.length)
  447. )),
  448. (d[a] = e)),
  449. (sheetStyle.cssText = b)
  450. }
  451. }
  452. : function (a, b, c) {
  453. var d
  454. return void 0 === b || (b && b.nodeType && 9 == b.nodeType)
  455. ? ((c = b && b.nodeType && 9 == b.nodeType ? b : c || document),
  456. (d = c.getElementById(a)),
  457. d ? d.innerHTML : void 0)
  458. : ((c = c || document),
  459. (d = c.getElementById(a)),
  460. '' === b
  461. ? !!d && (d.parentNode.removeChild(d), !0)
  462. : void (d
  463. ? (d.innerHTML = b)
  464. : ((d = c.createElement('style')),
  465. (d.id = a),
  466. (d.innerHTML = b),
  467. c.getElementsByTagName('head')[0].appendChild(d))))
  468. },
  469. sort: function (a, b) {
  470. b =
  471. b ||
  472. function (a, b) {
  473. return a.localeCompare(b)
  474. }
  475. for (var c = 0, d = a.length; c < d; c++)
  476. for (var e = c, f = a.length; e < f; e++)
  477. if (b(a[c], a[e]) > 0) {
  478. var g = a[c]
  479. ;(a[c] = a[e]), (a[e] = g)
  480. }
  481. return a
  482. },
  483. serializeParam: function (a) {
  484. var b = []
  485. for (var c in a)
  486. if ('method' != c && 'timeout' != c && 'async' != c)
  487. if (
  488. 'function' != (typeof a[c]).toLowerCase() &&
  489. 'object' != (typeof a[c]).toLowerCase()
  490. )
  491. b.push(encodeURIComponent(c) + '=' + encodeURIComponent(a[c]))
  492. else if (utils.isArray(a[c]))
  493. for (var d = 0; d < a[c].length; d++)
  494. b.push(
  495. encodeURIComponent(c) + '[]=' + encodeURIComponent(a[c][d])
  496. )
  497. return b.join('&')
  498. },
  499. formatUrl: function (a) {
  500. var b = a.replace(/&&/g, '&')
  501. return (
  502. (b = b.replace(/\?&/g, '?')),
  503. (b = b.replace(/&$/g, '')),
  504. (b = b.replace(/&#/g, '#')),
  505. (b = b.replace(/&+/g, '&'))
  506. )
  507. },
  508. isCrossDomainUrl: function (a) {
  509. var b = document.createElement('a')
  510. return (
  511. (b.href = a),
  512. browser.ie && (b.href = b.href),
  513. !(
  514. b.protocol == location.protocol &&
  515. b.hostname == location.hostname &&
  516. (b.port == location.port ||
  517. ('80' == b.port && '' == location.port) ||
  518. ('' == b.port && '80' == location.port))
  519. )
  520. )
  521. },
  522. clearEmptyAttrs: function (a) {
  523. for (var b in a) '' === a[b] && delete a[b]
  524. return a
  525. },
  526. str2json: function (a) {
  527. return utils.isString(a)
  528. ? window.JSON
  529. ? JSON.parse(a)
  530. : new Function('return ' + utils.trim(a || ''))()
  531. : null
  532. },
  533. json2str: (function () {
  534. function a(a) {
  535. return (
  536. /["\\\x00-\x1f]/.test(a) &&
  537. (a = a.replace(/["\\\x00-\x1f]/g, function (a) {
  538. var b = e[a]
  539. return b
  540. ? b
  541. : ((b = a.charCodeAt()),
  542. '\\u00' +
  543. Math.floor(b / 16).toString(16) +
  544. (b % 16).toString(16))
  545. })),
  546. '"' + a + '"'
  547. )
  548. }
  549. function b(a) {
  550. var b,
  551. c,
  552. d,
  553. e = ['['],
  554. f = a.length
  555. for (c = 0; c < f; c++)
  556. switch (((d = a[c]), typeof d)) {
  557. case 'undefined':
  558. case 'function':
  559. case 'unknown':
  560. break
  561. default:
  562. b && e.push(','), e.push(utils.json2str(d)), (b = 1)
  563. }
  564. return e.push(']'), e.join('')
  565. }
  566. function c(a) {
  567. return a < 10 ? '0' + a : a
  568. }
  569. function d(a) {
  570. return (
  571. '"' +
  572. a.getFullYear() +
  573. '-' +
  574. c(a.getMonth() + 1) +
  575. '-' +
  576. c(a.getDate()) +
  577. 'T' +
  578. c(a.getHours()) +
  579. ':' +
  580. c(a.getMinutes()) +
  581. ':' +
  582. c(a.getSeconds()) +
  583. '"'
  584. )
  585. }
  586. if (window.JSON) return JSON.stringify
  587. var e = {
  588. '\b': '\\b',
  589. '\t': '\\t',
  590. '\n': '\\n',
  591. '\f': '\\f',
  592. '\r': '\\r',
  593. '"': '\\"',
  594. '\\': '\\\\'
  595. }
  596. return function (c) {
  597. switch (typeof c) {
  598. case 'undefined':
  599. return 'undefined'
  600. case 'number':
  601. return isFinite(c) ? String(c) : 'null'
  602. case 'string':
  603. return a(c)
  604. case 'boolean':
  605. return String(c)
  606. default:
  607. if (null === c) return 'null'
  608. if (utils.isArray(c)) return b(c)
  609. if (utils.isDate(c)) return d(c)
  610. var e,
  611. f,
  612. g = ['{'],
  613. h = utils.json2str
  614. for (var i in c)
  615. if (Object.prototype.hasOwnProperty.call(c, i))
  616. switch (((f = c[i]), typeof f)) {
  617. case 'undefined':
  618. case 'unknown':
  619. case 'function':
  620. break
  621. default:
  622. e && g.push(','), (e = 1), g.push(h(i) + ':' + h(f))
  623. }
  624. return g.push('}'), g.join('')
  625. }
  626. }
  627. })()
  628. })
  629. utils.each(
  630. ['String', 'Function', 'Array', 'Number', 'RegExp', 'Object', 'Date'],
  631. function (a) {
  632. UE.utils['is' + a] = function (b) {
  633. return Object.prototype.toString.apply(b) == '[object ' + a + ']'
  634. }
  635. }
  636. )
  637. var EventBase = (UE.EventBase = function () {})
  638. EventBase.prototype = {
  639. addListener: function (a, b) {
  640. a = utils.trim(a).split(/\s+/)
  641. for (var c, d = 0; (c = a[d++]); ) getListener(this, c, !0).push(b)
  642. },
  643. on: function (a, b) {
  644. return this.addListener(a, b)
  645. },
  646. off: function (a, b) {
  647. return this.removeListener(a, b)
  648. },
  649. trigger: function () {
  650. return this.fireEvent.apply(this, arguments)
  651. },
  652. removeListener: function (a, b) {
  653. a = utils.trim(a).split(/\s+/)
  654. for (var c, d = 0; (c = a[d++]); )
  655. utils.removeItem(getListener(this, c) || [], b)
  656. },
  657. fireEvent: function () {
  658. var a = arguments[0]
  659. a = utils.trim(a).split(' ')
  660. for (var b, c = 0; (b = a[c++]); ) {
  661. var d,
  662. e,
  663. f,
  664. g = getListener(this, b)
  665. if (g)
  666. for (f = g.length; f--; )
  667. if (g[f]) {
  668. if (((e = g[f].apply(this, arguments)), e === !0)) return e
  669. void 0 !== e && (d = e)
  670. }
  671. ;(e = this['on' + b.toLowerCase()]) && (d = e.apply(this, arguments))
  672. }
  673. return d
  674. }
  675. }
  676. var dtd = (dom.dtd = (function () {
  677. function a(a) {
  678. for (var b in a) a[b.toUpperCase()] = a[b]
  679. return a
  680. }
  681. var b = utils.extend2,
  682. c = a({ isindex: 1, fieldset: 1 }),
  683. d = a({ input: 1, button: 1, select: 1, textarea: 1, label: 1 }),
  684. e = b(a({ a: 1 }), d),
  685. f = b({ iframe: 1 }, e),
  686. g = a({
  687. hr: 1,
  688. ul: 1,
  689. menu: 1,
  690. div: 1,
  691. blockquote: 1,
  692. noscript: 1,
  693. table: 1,
  694. center: 1,
  695. address: 1,
  696. dir: 1,
  697. pre: 1,
  698. h5: 1,
  699. dl: 1,
  700. h4: 1,
  701. noframes: 1,
  702. h6: 1,
  703. ol: 1,
  704. h1: 1,
  705. h3: 1,
  706. h2: 1
  707. }),
  708. h = a({ ins: 1, del: 1, script: 1, style: 1 }),
  709. i = b(
  710. a({
  711. b: 1,
  712. acronym: 1,
  713. bdo: 1,
  714. var: 1,
  715. '#': 1,
  716. abbr: 1,
  717. code: 1,
  718. br: 1,
  719. i: 1,
  720. cite: 1,
  721. kbd: 1,
  722. u: 1,
  723. strike: 1,
  724. s: 1,
  725. tt: 1,
  726. strong: 1,
  727. q: 1,
  728. samp: 1,
  729. em: 1,
  730. dfn: 1,
  731. span: 1
  732. }),
  733. h
  734. ),
  735. j = b(
  736. a({
  737. sub: 1,
  738. img: 1,
  739. embed: 1,
  740. object: 1,
  741. sup: 1,
  742. basefont: 1,
  743. map: 1,
  744. applet: 1,
  745. font: 1,
  746. big: 1,
  747. small: 1
  748. }),
  749. i
  750. ),
  751. k = b(a({ p: 1 }), j),
  752. l = b(a({ iframe: 1 }), j, d),
  753. m = a({
  754. img: 1,
  755. embed: 1,
  756. noscript: 1,
  757. br: 1,
  758. kbd: 1,
  759. center: 1,
  760. button: 1,
  761. basefont: 1,
  762. h5: 1,
  763. h4: 1,
  764. samp: 1,
  765. h6: 1,
  766. ol: 1,
  767. h1: 1,
  768. h3: 1,
  769. h2: 1,
  770. form: 1,
  771. font: 1,
  772. '#': 1,
  773. select: 1,
  774. menu: 1,
  775. ins: 1,
  776. abbr: 1,
  777. label: 1,
  778. code: 1,
  779. table: 1,
  780. script: 1,
  781. cite: 1,
  782. input: 1,
  783. iframe: 1,
  784. strong: 1,
  785. textarea: 1,
  786. noframes: 1,
  787. big: 1,
  788. small: 1,
  789. span: 1,
  790. hr: 1,
  791. sub: 1,
  792. bdo: 1,
  793. var: 1,
  794. div: 1,
  795. object: 1,
  796. sup: 1,
  797. strike: 1,
  798. dir: 1,
  799. map: 1,
  800. dl: 1,
  801. applet: 1,
  802. del: 1,
  803. isindex: 1,
  804. fieldset: 1,
  805. ul: 1,
  806. b: 1,
  807. acronym: 1,
  808. a: 1,
  809. blockquote: 1,
  810. i: 1,
  811. u: 1,
  812. s: 1,
  813. tt: 1,
  814. address: 1,
  815. q: 1,
  816. pre: 1,
  817. p: 1,
  818. em: 1,
  819. dfn: 1
  820. }),
  821. n = b(a({ a: 0 }), l),
  822. o = a({ tr: 1 }),
  823. p = a({ '#': 1 }),
  824. q = b(a({ param: 1 }), m),
  825. r = b(a({ form: 1 }), c, f, g, k),
  826. s = a({ li: 1, ol: 1, ul: 1 }),
  827. t = a({ style: 1, script: 1 }),
  828. u = a({ base: 1, link: 1, meta: 1, title: 1 }),
  829. v = b(u, t),
  830. w = a({ head: 1, body: 1 }),
  831. x = a({ html: 1 }),
  832. y = a({
  833. address: 1,
  834. blockquote: 1,
  835. center: 1,
  836. dir: 1,
  837. div: 1,
  838. dl: 1,
  839. fieldset: 1,
  840. form: 1,
  841. h1: 1,
  842. h2: 1,
  843. h3: 1,
  844. h4: 1,
  845. h5: 1,
  846. h6: 1,
  847. hr: 1,
  848. isindex: 1,
  849. menu: 1,
  850. noframes: 1,
  851. ol: 1,
  852. p: 1,
  853. pre: 1,
  854. table: 1,
  855. ul: 1
  856. }),
  857. z = a({
  858. area: 1,
  859. base: 1,
  860. basefont: 1,
  861. br: 1,
  862. col: 1,
  863. command: 1,
  864. dialog: 1,
  865. embed: 1,
  866. hr: 1,
  867. img: 1,
  868. input: 1,
  869. isindex: 1,
  870. keygen: 1,
  871. link: 1,
  872. meta: 1,
  873. param: 1,
  874. source: 1,
  875. track: 1,
  876. wbr: 1
  877. })
  878. return a({
  879. $nonBodyContent: b(x, w, u),
  880. $block: y,
  881. $inline: n,
  882. $inlineWithA: b(a({ a: 1 }), n),
  883. $body: b(a({ script: 1, style: 1 }), y),
  884. $cdata: a({ script: 1, style: 1 }),
  885. $empty: z,
  886. $nonChild: a({ iframe: 1, textarea: 1 }),
  887. $listItem: a({ dd: 1, dt: 1, li: 1 }),
  888. $list: a({ ul: 1, ol: 1, dl: 1 }),
  889. $isNotEmpty: a({
  890. table: 1,
  891. ul: 1,
  892. ol: 1,
  893. dl: 1,
  894. iframe: 1,
  895. area: 1,
  896. base: 1,
  897. col: 1,
  898. hr: 1,
  899. img: 1,
  900. embed: 1,
  901. input: 1,
  902. link: 1,
  903. meta: 1,
  904. param: 1,
  905. h1: 1,
  906. h2: 1,
  907. h3: 1,
  908. h4: 1,
  909. h5: 1,
  910. h6: 1
  911. }),
  912. $removeEmpty: a({
  913. a: 1,
  914. abbr: 1,
  915. acronym: 1,
  916. address: 1,
  917. b: 1,
  918. bdo: 1,
  919. big: 1,
  920. cite: 1,
  921. code: 1,
  922. del: 1,
  923. dfn: 1,
  924. em: 1,
  925. font: 1,
  926. i: 1,
  927. ins: 1,
  928. label: 1,
  929. kbd: 1,
  930. q: 1,
  931. s: 1,
  932. samp: 1,
  933. small: 1,
  934. span: 1,
  935. strike: 1,
  936. strong: 1,
  937. sub: 1,
  938. sup: 1,
  939. tt: 1,
  940. u: 1,
  941. var: 1
  942. }),
  943. $removeEmptyBlock: a({ p: 1, div: 1 }),
  944. $tableContent: a({
  945. caption: 1,
  946. col: 1,
  947. colgroup: 1,
  948. tbody: 1,
  949. td: 1,
  950. tfoot: 1,
  951. th: 1,
  952. thead: 1,
  953. tr: 1,
  954. table: 1
  955. }),
  956. $notTransContent: a({ pre: 1, script: 1, style: 1, textarea: 1 }),
  957. html: w,
  958. head: v,
  959. style: p,
  960. script: p,
  961. body: r,
  962. base: {},
  963. link: {},
  964. meta: {},
  965. title: p,
  966. col: {},
  967. tr: a({ td: 1, th: 1 }),
  968. img: {},
  969. embed: {},
  970. colgroup: a({ thead: 1, col: 1, tbody: 1, tr: 1, tfoot: 1 }),
  971. noscript: r,
  972. td: r,
  973. br: {},
  974. th: r,
  975. center: r,
  976. kbd: n,
  977. button: b(k, g),
  978. basefont: {},
  979. h5: n,
  980. h4: n,
  981. samp: n,
  982. h6: n,
  983. ol: s,
  984. h1: n,
  985. h3: n,
  986. option: p,
  987. h2: n,
  988. form: b(c, f, g, k),
  989. select: a({ optgroup: 1, option: 1 }),
  990. font: n,
  991. ins: n,
  992. menu: s,
  993. abbr: n,
  994. label: n,
  995. table: a({
  996. thead: 1,
  997. col: 1,
  998. tbody: 1,
  999. tr: 1,
  1000. colgroup: 1,
  1001. caption: 1,
  1002. tfoot: 1
  1003. }),
  1004. code: n,
  1005. tfoot: o,
  1006. cite: n,
  1007. li: r,
  1008. input: {},
  1009. iframe: r,
  1010. strong: n,
  1011. textarea: p,
  1012. noframes: r,
  1013. big: n,
  1014. small: n,
  1015. span: a({
  1016. '#': 1,
  1017. br: 1,
  1018. b: 1,
  1019. strong: 1,
  1020. u: 1,
  1021. i: 1,
  1022. em: 1,
  1023. sub: 1,
  1024. sup: 1,
  1025. strike: 1,
  1026. span: 1
  1027. }),
  1028. hr: n,
  1029. dt: n,
  1030. sub: n,
  1031. optgroup: a({ option: 1 }),
  1032. param: {},
  1033. bdo: n,
  1034. var: n,
  1035. div: r,
  1036. object: q,
  1037. sup: n,
  1038. dd: r,
  1039. strike: n,
  1040. area: {},
  1041. dir: s,
  1042. map: b(a({ area: 1, form: 1, p: 1 }), c, h, g),
  1043. applet: q,
  1044. dl: a({ dt: 1, dd: 1 }),
  1045. del: n,
  1046. isindex: {},
  1047. fieldset: b(a({ legend: 1 }), m),
  1048. thead: o,
  1049. ul: s,
  1050. acronym: n,
  1051. b: n,
  1052. a: b(a({ a: 1 }), l),
  1053. blockquote: b(a({ td: 1, tr: 1, tbody: 1, li: 1 }), r),
  1054. caption: n,
  1055. i: n,
  1056. u: n,
  1057. tbody: o,
  1058. s: n,
  1059. address: b(f, k),
  1060. tt: n,
  1061. legend: n,
  1062. q: n,
  1063. pre: b(i, e),
  1064. p: b(a({ a: 1 }), n),
  1065. em: n,
  1066. dfn: n
  1067. })
  1068. })()),
  1069. attrFix =
  1070. ie && browser.version < 9
  1071. ? {
  1072. tabindex: 'tabIndex',
  1073. readonly: 'readOnly',
  1074. for: 'htmlFor',
  1075. class: 'className',
  1076. maxlength: 'maxLength',
  1077. cellspacing: 'cellSpacing',
  1078. cellpadding: 'cellPadding',
  1079. rowspan: 'rowSpan',
  1080. colspan: 'colSpan',
  1081. usemap: 'useMap',
  1082. frameborder: 'frameBorder'
  1083. }
  1084. : { tabindex: 'tabIndex', readonly: 'readOnly' },
  1085. styleBlock = utils.listToMap([
  1086. '-webkit-box',
  1087. '-moz-box',
  1088. 'block',
  1089. 'list-item',
  1090. 'table',
  1091. 'table-row-group',
  1092. 'table-header-group',
  1093. 'table-footer-group',
  1094. 'table-row',
  1095. 'table-column-group',
  1096. 'table-column',
  1097. 'table-cell',
  1098. 'table-caption'
  1099. ]),
  1100. domUtils = (dom.domUtils = {
  1101. NODE_ELEMENT: 1,
  1102. NODE_DOCUMENT: 9,
  1103. NODE_TEXT: 3,
  1104. NODE_COMMENT: 8,
  1105. NODE_DOCUMENT_FRAGMENT: 11,
  1106. POSITION_IDENTICAL: 0,
  1107. POSITION_DISCONNECTED: 1,
  1108. POSITION_FOLLOWING: 2,
  1109. POSITION_PRECEDING: 4,
  1110. POSITION_IS_CONTAINED: 8,
  1111. POSITION_CONTAINS: 16,
  1112. fillChar: ie && '6' == browser.version ? '\ufeff' : '​',
  1113. keys: {
  1114. 8: 1,
  1115. 46: 1,
  1116. 16: 1,
  1117. 17: 1,
  1118. 18: 1,
  1119. 37: 1,
  1120. 38: 1,
  1121. 39: 1,
  1122. 40: 1,
  1123. 13: 1
  1124. },
  1125. getPosition: function (a, b) {
  1126. if (a === b) return 0
  1127. var c,
  1128. d = [a],
  1129. e = [b]
  1130. for (c = a; (c = c.parentNode); ) {
  1131. if (c === b) return 10
  1132. d.push(c)
  1133. }
  1134. for (c = b; (c = c.parentNode); ) {
  1135. if (c === a) return 20
  1136. e.push(c)
  1137. }
  1138. if ((d.reverse(), e.reverse(), d[0] !== e[0])) return 1
  1139. for (var f = -1; f++, d[f] === e[f]; );
  1140. for (a = d[f], b = e[f]; (a = a.nextSibling); ) if (a === b) return 4
  1141. return 2
  1142. },
  1143. getNodeIndex: function (a, b) {
  1144. for (var c = a, d = 0; (c = c.previousSibling); )
  1145. b && 3 == c.nodeType
  1146. ? c.nodeType != c.nextSibling.nodeType && d++
  1147. : d++
  1148. return d
  1149. },
  1150. inDoc: function (a, b) {
  1151. return 10 == domUtils.getPosition(a, b)
  1152. },
  1153. findParent: function (a, b, c) {
  1154. if (a && !domUtils.isBody(a))
  1155. for (a = c ? a : a.parentNode; a; ) {
  1156. if (!b || b(a) || domUtils.isBody(a))
  1157. return b && !b(a) && domUtils.isBody(a) ? null : a
  1158. a = a.parentNode
  1159. }
  1160. return null
  1161. },
  1162. findParentByTagName: function (a, b, c, d) {
  1163. return (
  1164. (b = utils.listToMap(utils.isArray(b) ? b : [b])),
  1165. domUtils.findParent(
  1166. a,
  1167. function (a) {
  1168. return b[a.tagName] && !(d && d(a))
  1169. },
  1170. c
  1171. )
  1172. )
  1173. },
  1174. findParents: function (a, b, c, d) {
  1175. for (
  1176. var e = b && ((c && c(a)) || !c) ? [a] : [];
  1177. (a = domUtils.findParent(a, c));
  1178. )
  1179. e.push(a)
  1180. return d ? e : e.reverse()
  1181. },
  1182. insertAfter: function (a, b) {
  1183. return a.nextSibling
  1184. ? a.parentNode.insertBefore(b, a.nextSibling)
  1185. : a.parentNode.appendChild(b)
  1186. },
  1187. remove: function (a, b) {
  1188. var c,
  1189. d = a.parentNode
  1190. if (d) {
  1191. if (b && a.hasChildNodes())
  1192. for (; (c = a.firstChild); ) d.insertBefore(c, a)
  1193. d.removeChild(a)
  1194. }
  1195. return a
  1196. },
  1197. getNextDomNode: function (a, b, c, d) {
  1198. return getDomNode(a, 'firstChild', 'nextSibling', b, c, d)
  1199. },
  1200. getPreDomNode: function (a, b, c, d) {
  1201. return getDomNode(a, 'lastChild', 'previousSibling', b, c, d)
  1202. },
  1203. isBookmarkNode: function (a) {
  1204. return 1 == a.nodeType && a.id && /^_baidu_bookmark_/i.test(a.id)
  1205. },
  1206. getWindow: function (a) {
  1207. var b = a.ownerDocument || a
  1208. return b.defaultView || b.parentWindow
  1209. },
  1210. getCommonAncestor: function (a, b) {
  1211. if (a === b) return a
  1212. for (var c = [a], d = [b], e = a, f = -1; (e = e.parentNode); ) {
  1213. if (e === b) return e
  1214. c.push(e)
  1215. }
  1216. for (e = b; (e = e.parentNode); ) {
  1217. if (e === a) return e
  1218. d.push(e)
  1219. }
  1220. for (c.reverse(), d.reverse(); f++, c[f] === d[f]; );
  1221. return 0 == f ? null : c[f - 1]
  1222. },
  1223. clearEmptySibling: function (a, b, c) {
  1224. function d(a, b) {
  1225. for (
  1226. var c;
  1227. a &&
  1228. !domUtils.isBookmarkNode(a) &&
  1229. (domUtils.isEmptyInlineElement(a) ||
  1230. !new RegExp('[^\t\n\r' + domUtils.fillChar + ']').test(
  1231. a.nodeValue
  1232. ));
  1233. )
  1234. (c = a[b]), domUtils.remove(a), (a = c)
  1235. }
  1236. !b && d(a.nextSibling, 'nextSibling'),
  1237. !c && d(a.previousSibling, 'previousSibling')
  1238. },
  1239. split: function (a, b) {
  1240. var c = a.ownerDocument
  1241. if (browser.ie && b == a.nodeValue.length) {
  1242. var d = c.createTextNode('')
  1243. return domUtils.insertAfter(a, d)
  1244. }
  1245. var e = a.splitText(b)
  1246. if (browser.ie8) {
  1247. var f = c.createTextNode('')
  1248. domUtils.insertAfter(e, f), domUtils.remove(f)
  1249. }
  1250. return e
  1251. },
  1252. isWhitespace: function (a) {
  1253. return !new RegExp('[^ \t\n\r' + domUtils.fillChar + ']').test(
  1254. a.nodeValue
  1255. )
  1256. },
  1257. getXY: function (a) {
  1258. for (var b = 0, c = 0; a.offsetParent; )
  1259. (c += a.offsetTop), (b += a.offsetLeft), (a = a.offsetParent)
  1260. return { x: b, y: c }
  1261. },
  1262. on: function (a, b, c) {
  1263. var d = utils.isArray(b) ? b : utils.trim(b).split(/\s+/),
  1264. e = d.length
  1265. if (e)
  1266. for (; e--; )
  1267. if (((b = d[e]), a.addEventListener)) a.addEventListener(b, c, !1)
  1268. else {
  1269. c._d || (c._d = { els: [] })
  1270. var f = b + c.toString(),
  1271. g = utils.indexOf(c._d.els, a)
  1272. ;(c._d[f] && g != -1) ||
  1273. (g == -1 && c._d.els.push(a),
  1274. c._d[f] ||
  1275. (c._d[f] = function (a) {
  1276. return c.call(a.srcElement, a || window.event)
  1277. }),
  1278. a.attachEvent('on' + b, c._d[f]))
  1279. }
  1280. a = null
  1281. },
  1282. un: function (a, b, c) {
  1283. var d = utils.isArray(b) ? b : utils.trim(b).split(/\s+/),
  1284. e = d.length
  1285. if (e)
  1286. for (; e--; )
  1287. if (((b = d[e]), a.removeEventListener))
  1288. a.removeEventListener(b, c, !1)
  1289. else {
  1290. var f = b + c.toString()
  1291. try {
  1292. a.detachEvent('on' + b, c._d ? c._d[f] : c)
  1293. } catch (g) {}
  1294. if (c._d && c._d[f]) {
  1295. var h = utils.indexOf(c._d.els, a)
  1296. h != -1 && c._d.els.splice(h, 1),
  1297. 0 == c._d.els.length && delete c._d[f]
  1298. }
  1299. }
  1300. },
  1301. isSameElement: function (a, b) {
  1302. if (a.tagName != b.tagName) return !1
  1303. var c = a.attributes,
  1304. d = b.attributes
  1305. if (!ie && c.length != d.length) return !1
  1306. for (var e, f, g = 0, h = 0, i = 0; (e = c[i++]); ) {
  1307. if ('style' == e.nodeName) {
  1308. if ((e.specified && g++, domUtils.isSameStyle(a, b))) continue
  1309. return !1
  1310. }
  1311. if (ie) {
  1312. if (!e.specified) continue
  1313. g++, (f = d.getNamedItem(e.nodeName))
  1314. } else f = b.attributes[e.nodeName]
  1315. if (!f.specified || e.nodeValue != f.nodeValue) return !1
  1316. }
  1317. if (ie) {
  1318. for (i = 0; (f = d[i++]); ) f.specified && h++
  1319. if (g != h) return !1
  1320. }
  1321. return !0
  1322. },
  1323. isSameStyle: function (a, b) {
  1324. var c = a.style.cssText
  1325. .replace(/( ?; ?)/g, ';')
  1326. .replace(/( ?: ?)/g, ':'),
  1327. d = b.style.cssText.replace(/( ?; ?)/g, ';').replace(/( ?: ?)/g, ':')
  1328. if (browser.opera) {
  1329. if (((c = a.style), (d = b.style), c.length != d.length)) return !1
  1330. for (var e in c)
  1331. if (!/^(\d+|csstext)$/i.test(e) && c[e] != d[e]) return !1
  1332. return !0
  1333. }
  1334. if (!c || !d) return c == d
  1335. if (((c = c.split(';')), (d = d.split(';')), c.length != d.length))
  1336. return !1
  1337. for (var f, g = 0; (f = c[g++]); )
  1338. if (utils.indexOf(d, f) == -1) return !1
  1339. return !0
  1340. },
  1341. isBlockElm: function (a) {
  1342. return (
  1343. 1 == a.nodeType &&
  1344. (dtd.$block[a.tagName] ||
  1345. styleBlock[domUtils.getComputedStyle(a, 'display')]) &&
  1346. !dtd.$nonChild[a.tagName]
  1347. )
  1348. },
  1349. isBody: function (a) {
  1350. return a && 1 == a.nodeType && 'body' == a.tagName.toLowerCase()
  1351. },
  1352. breakParent: function (a, b) {
  1353. var c,
  1354. d,
  1355. e,
  1356. f = a,
  1357. g = a
  1358. do {
  1359. for (
  1360. f = f.parentNode,
  1361. d
  1362. ? ((c = f.cloneNode(!1)),
  1363. c.appendChild(d),
  1364. (d = c),
  1365. (c = f.cloneNode(!1)),
  1366. c.appendChild(e),
  1367. (e = c))
  1368. : ((d = f.cloneNode(!1)), (e = d.cloneNode(!1)));
  1369. (c = g.previousSibling);
  1370. )
  1371. d.insertBefore(c, d.firstChild)
  1372. for (; (c = g.nextSibling); ) e.appendChild(c)
  1373. g = f
  1374. } while (b !== f)
  1375. return (
  1376. (c = b.parentNode),
  1377. c.insertBefore(d, b),
  1378. c.insertBefore(e, b),
  1379. c.insertBefore(a, e),
  1380. domUtils.remove(b),
  1381. a
  1382. )
  1383. },
  1384. isEmptyInlineElement: function (a) {
  1385. if (1 != a.nodeType || !dtd.$removeEmpty[a.tagName]) return 0
  1386. for (a = a.firstChild; a; ) {
  1387. if (domUtils.isBookmarkNode(a)) return 0
  1388. if (
  1389. (1 == a.nodeType && !domUtils.isEmptyInlineElement(a)) ||
  1390. (3 == a.nodeType && !domUtils.isWhitespace(a))
  1391. )
  1392. return 0
  1393. a = a.nextSibling
  1394. }
  1395. return 1
  1396. },
  1397. trimWhiteTextNode: function (a) {
  1398. function b(b) {
  1399. for (
  1400. var c;
  1401. (c = a[b]) && 3 == c.nodeType && domUtils.isWhitespace(c);
  1402. )
  1403. a.removeChild(c)
  1404. }
  1405. b('firstChild'), b('lastChild')
  1406. },
  1407. mergeChild: function (a, b, c) {
  1408. for (
  1409. var d,
  1410. e = domUtils.getElementsByTagName(a, a.tagName.toLowerCase()),
  1411. f = 0;
  1412. (d = e[f++]);
  1413. )
  1414. if (d.parentNode && !domUtils.isBookmarkNode(d))
  1415. if ('span' != d.tagName.toLowerCase())
  1416. domUtils.isSameElement(a, d) && domUtils.remove(d, !0)
  1417. else {
  1418. if (
  1419. a === d.parentNode &&
  1420. (domUtils.trimWhiteTextNode(a), 1 == a.childNodes.length)
  1421. ) {
  1422. ;(a.style.cssText = d.style.cssText + ';' + a.style.cssText),
  1423. domUtils.remove(d, !0)
  1424. continue
  1425. }
  1426. if (
  1427. ((d.style.cssText = a.style.cssText + ';' + d.style.cssText), c)
  1428. ) {
  1429. var g = c.style
  1430. if (g) {
  1431. g = g.split(';')
  1432. for (var h, i = 0; (h = g[i++]); )
  1433. d.style[utils.cssStyleToDomStyle(h.split(':')[0])] =
  1434. h.split(':')[1]
  1435. }
  1436. }
  1437. domUtils.isSameStyle(d, a) && domUtils.remove(d, !0)
  1438. }
  1439. },
  1440. getElementsByTagName: function (a, b, c) {
  1441. if (c && utils.isString(c)) {
  1442. var d = c
  1443. c = function (a) {
  1444. return domUtils.hasClass(a, d)
  1445. }
  1446. }
  1447. b = utils
  1448. .trim(b)
  1449. .replace(/[ ]{2,}/g, ' ')
  1450. .split(' ')
  1451. for (var e, f = [], g = 0; (e = b[g++]); )
  1452. for (var h, i = a.getElementsByTagName(e), j = 0; (h = i[j++]); )
  1453. (c && !c(h)) || f.push(h)
  1454. return f
  1455. },
  1456. mergeToParent: function (a) {
  1457. for (var b = a.parentNode; b && dtd.$removeEmpty[b.tagName]; ) {
  1458. if (b.tagName == a.tagName || 'A' == b.tagName) {
  1459. if (
  1460. (domUtils.trimWhiteTextNode(b),
  1461. ('SPAN' == b.tagName && !domUtils.isSameStyle(b, a)) ||
  1462. ('A' == b.tagName && 'SPAN' == a.tagName))
  1463. ) {
  1464. if (b.childNodes.length > 1 || b !== a.parentNode) {
  1465. ;(a.style.cssText = b.style.cssText + ';' + a.style.cssText),
  1466. (b = b.parentNode)
  1467. continue
  1468. }
  1469. ;(b.style.cssText += ';' + a.style.cssText),
  1470. 'A' == b.tagName && (b.style.textDecoration = 'underline')
  1471. }
  1472. if ('A' != b.tagName) {
  1473. b === a.parentNode && domUtils.remove(a, !0)
  1474. break
  1475. }
  1476. }
  1477. b = b.parentNode
  1478. }
  1479. },
  1480. mergeSibling: function (a, b, c) {
  1481. function d(a, b, c) {
  1482. var d
  1483. if (
  1484. (d = c[a]) &&
  1485. !domUtils.isBookmarkNode(d) &&
  1486. 1 == d.nodeType &&
  1487. domUtils.isSameElement(c, d)
  1488. ) {
  1489. for (; d.firstChild; )
  1490. 'firstChild' == b
  1491. ? c.insertBefore(d.lastChild, c.firstChild)
  1492. : c.appendChild(d.firstChild)
  1493. domUtils.remove(d)
  1494. }
  1495. }
  1496. !b && d('previousSibling', 'firstChild', a),
  1497. !c && d('nextSibling', 'lastChild', a)
  1498. },
  1499. unSelectable:
  1500. (ie && browser.ie9below) || browser.opera
  1501. ? function (a) {
  1502. ;(a.onselectstart = function () {
  1503. return !1
  1504. }),
  1505. (a.onclick =
  1506. a.onkeyup =
  1507. a.onkeydown =
  1508. function () {
  1509. return !1
  1510. }),
  1511. (a.unselectable = 'on'),
  1512. a.setAttribute('unselectable', 'on')
  1513. for (var b, c = 0; (b = a.all[c++]); )
  1514. switch (b.tagName.toLowerCase()) {
  1515. case 'iframe':
  1516. case 'textarea':
  1517. case 'input':
  1518. case 'select':
  1519. break
  1520. default:
  1521. ;(b.unselectable = 'on'),
  1522. a.setAttribute('unselectable', 'on')
  1523. }
  1524. }
  1525. : function (a) {
  1526. a.style.MozUserSelect =
  1527. a.style.webkitUserSelect =
  1528. a.style.msUserSelect =
  1529. a.style.KhtmlUserSelect =
  1530. 'none'
  1531. },
  1532. removeAttributes: function (a, b) {
  1533. b = utils.isArray(b)
  1534. ? b
  1535. : utils
  1536. .trim(b)
  1537. .replace(/[ ]{2,}/g, ' ')
  1538. .split(' ')
  1539. for (var c, d = 0; (c = b[d++]); ) {
  1540. switch ((c = attrFix[c] || c)) {
  1541. case 'className':
  1542. a[c] = ''
  1543. break
  1544. case 'style':
  1545. a.style.cssText = ''
  1546. var e = a.getAttributeNode('style')
  1547. !browser.ie && e && a.removeAttributeNode(e)
  1548. }
  1549. a.removeAttribute(c)
  1550. }
  1551. },
  1552. createElement: function (a, b, c) {
  1553. return domUtils.setAttributes(a.createElement(b), c)
  1554. },
  1555. setAttributes: function (a, b) {
  1556. for (var c in b)
  1557. if (b.hasOwnProperty(c)) {
  1558. var d = b[c]
  1559. switch (c) {
  1560. case 'class':
  1561. a.className = d
  1562. break
  1563. case 'style':
  1564. a.style.cssText = a.style.cssText + ';' + d
  1565. break
  1566. case 'innerHTML':
  1567. a[c] = d
  1568. break
  1569. case 'value':
  1570. a.value = d
  1571. break
  1572. default:
  1573. a.setAttribute(attrFix[c] || c, d)
  1574. }
  1575. }
  1576. return a
  1577. },
  1578. getComputedStyle: function (a, b) {
  1579. var c = 'width height top left'
  1580. if (c.indexOf(b) > -1)
  1581. return (
  1582. a[
  1583. 'offset' +
  1584. b.replace(/^\w/, function (a) {
  1585. return a.toUpperCase()
  1586. })
  1587. ] + 'px'
  1588. )
  1589. if (
  1590. (3 == a.nodeType && (a = a.parentNode),
  1591. browser.ie &&
  1592. browser.version < 9 &&
  1593. 'font-size' == b &&
  1594. !a.style.fontSize &&
  1595. !dtd.$empty[a.tagName] &&
  1596. !dtd.$nonChild[a.tagName])
  1597. ) {
  1598. var d = a.ownerDocument.createElement('span')
  1599. ;(d.style.cssText = 'padding:0;border:0;font-family:simsun;'),
  1600. (d.innerHTML = '.'),
  1601. a.appendChild(d)
  1602. var e = d.offsetHeight
  1603. return a.removeChild(d), (d = null), e + 'px'
  1604. }
  1605. try {
  1606. var f =
  1607. domUtils.getStyle(a, b) ||
  1608. (window.getComputedStyle
  1609. ? domUtils
  1610. .getWindow(a)
  1611. .getComputedStyle(a, '')
  1612. .getPropertyValue(b)
  1613. : (a.currentStyle || a.style)[utils.cssStyleToDomStyle(b)])
  1614. } catch (g) {
  1615. return ''
  1616. }
  1617. return utils.transUnitToPx(utils.fixColor(b, f))
  1618. },
  1619. removeClasses: function (a, b) {
  1620. b = utils.isArray(b)
  1621. ? b
  1622. : utils
  1623. .trim(b)
  1624. .replace(/[ ]{2,}/g, ' ')
  1625. .split(' ')
  1626. for (var c, d = 0, e = a.className; (c = b[d++]); )
  1627. e = e.replace(new RegExp('\\b' + c + '\\b'), '')
  1628. ;(e = utils.trim(e).replace(/[ ]{2,}/g, ' ')),
  1629. e ? (a.className = e) : domUtils.removeAttributes(a, ['class'])
  1630. },
  1631. addClass: function (a, b) {
  1632. if (a) {
  1633. b = utils
  1634. .trim(b)
  1635. .replace(/[ ]{2,}/g, ' ')
  1636. .split(' ')
  1637. for (var c, d = 0, e = a.className; (c = b[d++]); )
  1638. new RegExp('\\b' + c + '\\b').test(e) || (e += ' ' + c)
  1639. a.className = utils.trim(e)
  1640. }
  1641. },
  1642. hasClass: function (a, b) {
  1643. if (utils.isRegExp(b)) return b.test(a.className)
  1644. b = utils
  1645. .trim(b)
  1646. .replace(/[ ]{2,}/g, ' ')
  1647. .split(' ')
  1648. for (var c, d = 0, e = a.className; (c = b[d++]); )
  1649. if (!new RegExp('\\b' + c + '\\b', 'i').test(e)) return !1
  1650. return d - 1 == b.length
  1651. },
  1652. preventDefault: function (a) {
  1653. a.preventDefault ? a.preventDefault() : (a.returnValue = !1)
  1654. },
  1655. removeStyle: function (a, b) {
  1656. browser.ie
  1657. ? ('color' == b && (b = '(^|;)' + b),
  1658. (a.style.cssText = a.style.cssText.replace(
  1659. new RegExp(b + '[^:]*:[^;]+;?', 'ig'),
  1660. ''
  1661. )))
  1662. : a.style.removeProperty
  1663. ? a.style.removeProperty(b)
  1664. : a.style.removeAttribute(utils.cssStyleToDomStyle(b)),
  1665. a.style.cssText || domUtils.removeAttributes(a, ['style'])
  1666. },
  1667. getStyle: function (a, b) {
  1668. var c = a.style[utils.cssStyleToDomStyle(b)]
  1669. return utils.fixColor(b, c)
  1670. },
  1671. setStyle: function (a, b, c) {
  1672. ;(a.style[utils.cssStyleToDomStyle(b)] = c),
  1673. utils.trim(a.style.cssText) || this.removeAttributes(a, 'style')
  1674. },
  1675. setStyles: function (a, b) {
  1676. for (var c in b) b.hasOwnProperty(c) && domUtils.setStyle(a, c, b[c])
  1677. },
  1678. removeDirtyAttr: function (a) {
  1679. for (var b, c = 0, d = a.getElementsByTagName('*'); (b = d[c++]); )
  1680. b.removeAttribute('_moz_dirty')
  1681. a.removeAttribute('_moz_dirty')
  1682. },
  1683. getChildCount: function (a, b) {
  1684. var c = 0,
  1685. d = a.firstChild
  1686. for (
  1687. b =
  1688. b ||
  1689. function () {
  1690. return 1
  1691. };
  1692. d;
  1693. )
  1694. b(d) && c++, (d = d.nextSibling)
  1695. return c
  1696. },
  1697. isEmptyNode: function (a) {
  1698. return (
  1699. !a.firstChild ||
  1700. 0 ==
  1701. domUtils.getChildCount(a, function (a) {
  1702. return (
  1703. !domUtils.isBr(a) &&
  1704. !domUtils.isBookmarkNode(a) &&
  1705. !domUtils.isWhitespace(a)
  1706. )
  1707. })
  1708. )
  1709. },
  1710. clearSelectedArr: function (a) {
  1711. for (var b; (b = a.pop()); ) domUtils.removeAttributes(b, ['class'])
  1712. },
  1713. scrollToView: function (a, b, c) {
  1714. var d = function () {
  1715. var a = b.document,
  1716. c = 'CSS1Compat' == a.compatMode
  1717. return {
  1718. width:
  1719. (c ? a.documentElement.clientWidth : a.body.clientWidth) || 0,
  1720. height:
  1721. (c ? a.documentElement.clientHeight : a.body.clientHeight) || 0
  1722. }
  1723. },
  1724. e = function (a) {
  1725. if ('pageXOffset' in a)
  1726. return { x: a.pageXOffset || 0, y: a.pageYOffset || 0 }
  1727. var b = a.document
  1728. return {
  1729. x: b.documentElement.scrollLeft || b.body.scrollLeft || 0,
  1730. y: b.documentElement.scrollTop || b.body.scrollTop || 0
  1731. }
  1732. },
  1733. f = d().height,
  1734. g = f * -1 + c
  1735. g += a.offsetHeight || 0
  1736. var h = domUtils.getXY(a)
  1737. g += h.y
  1738. var i = e(b).y
  1739. ;(g > i || g < i - f) && b.scrollTo(0, g + (g < 0 ? -20 : 20))
  1740. },
  1741. isBr: function (a) {
  1742. return 1 == a.nodeType && 'BR' == a.tagName
  1743. },
  1744. isFillChar: function (a, b) {
  1745. if (3 != a.nodeType) return !1
  1746. var c = a.nodeValue
  1747. return b
  1748. ? new RegExp('^' + domUtils.fillChar).test(c)
  1749. : !c.replace(new RegExp(domUtils.fillChar, 'g'), '').length
  1750. },
  1751. isStartInblock: function (a) {
  1752. var b,
  1753. c = a.cloneRange(),
  1754. d = 0,
  1755. e = c.startContainer
  1756. if (1 == e.nodeType && e.childNodes[c.startOffset]) {
  1757. e = e.childNodes[c.startOffset]
  1758. for (var f = e.previousSibling; f && domUtils.isFillChar(f); )
  1759. (e = f), (f = f.previousSibling)
  1760. }
  1761. for (
  1762. this.isFillChar(e, !0) &&
  1763. 1 == c.startOffset &&
  1764. (c.setStartBefore(e), (e = c.startContainer));
  1765. e && domUtils.isFillChar(e);
  1766. )
  1767. (b = e), (e = e.previousSibling)
  1768. for (
  1769. b && (c.setStartBefore(b), (e = c.startContainer)),
  1770. 1 == e.nodeType &&
  1771. domUtils.isEmptyNode(e) &&
  1772. 1 == c.startOffset &&
  1773. c.setStart(e, 0).collapse(!0);
  1774. !c.startOffset;
  1775. ) {
  1776. if (
  1777. ((e = c.startContainer),
  1778. domUtils.isBlockElm(e) || domUtils.isBody(e))
  1779. ) {
  1780. d = 1
  1781. break
  1782. }
  1783. var g,
  1784. f = c.startContainer.previousSibling
  1785. if (f) {
  1786. for (; f && domUtils.isFillChar(f); )
  1787. (g = f), (f = f.previousSibling)
  1788. g ? c.setStartBefore(g) : c.setStartBefore(c.startContainer)
  1789. } else c.setStartBefore(c.startContainer)
  1790. }
  1791. return d && !domUtils.isBody(c.startContainer) ? 1 : 0
  1792. },
  1793. isEmptyBlock: function (a, b) {
  1794. if (a) {
  1795. if (1 != a.nodeType) return 0
  1796. if (
  1797. ((b = b || new RegExp('[  \t\r\n' + domUtils.fillChar + ']', 'g')),
  1798. a[browser.ie ? 'innerText' : 'textContent'].replace(b, '').length >
  1799. 0)
  1800. )
  1801. return 0
  1802. for (var c in dtd.$isNotEmpty)
  1803. if (a.getElementsByTagName(c).length) return 0
  1804. return 1
  1805. }
  1806. },
  1807. setViewportOffset: function (a, b) {
  1808. var c = 0 | parseInt(a.style.left),
  1809. d = 0 | parseInt(a.style.top),
  1810. e = a.getBoundingClientRect(),
  1811. f = b.left - e.left,
  1812. g = b.top - e.top
  1813. f && (a.style.left = c + f + 'px'), g && (a.style.top = d + g + 'px')
  1814. },
  1815. fillNode: function (a, b) {
  1816. var c = browser.ie
  1817. ? a.createTextNode(domUtils.fillChar)
  1818. : a.createElement('br')
  1819. ;(b.innerHTML = ''), b.appendChild(c)
  1820. },
  1821. moveChild: function (a, b, c) {
  1822. for (; a.firstChild; )
  1823. c && b.firstChild
  1824. ? b.insertBefore(a.lastChild, b.firstChild)
  1825. : b.appendChild(a.firstChild)
  1826. },
  1827. hasNoAttributes: function (a) {
  1828. return browser.ie
  1829. ? /^<\w+\s*?>/.test(a.outerHTML)
  1830. : 0 == a.attributes.length
  1831. },
  1832. isCustomeNode: function (a) {
  1833. return 1 == a.nodeType && a.getAttribute('_ue_custom_node_')
  1834. },
  1835. isTagNode: function (a, b) {
  1836. return (
  1837. 1 == a.nodeType && new RegExp('\\b' + a.tagName + '\\b', 'i').test(b)
  1838. )
  1839. },
  1840. filterNodeList: function (a, b, c) {
  1841. var d = []
  1842. if (!utils.isFunction(b)) {
  1843. var e = b
  1844. b = function (a) {
  1845. return (
  1846. utils.indexOf(
  1847. utils.isArray(e) ? e : e.split(' '),
  1848. a.tagName.toLowerCase()
  1849. ) != -1
  1850. )
  1851. }
  1852. }
  1853. return (
  1854. utils.each(a, function (a) {
  1855. b(a) && d.push(a)
  1856. }),
  1857. 0 == d.length ? null : 1 != d.length && c ? d : d[0]
  1858. )
  1859. },
  1860. isInNodeEndBoundary: function (a, b) {
  1861. var c = a.startContainer
  1862. if (3 == c.nodeType && a.startOffset != c.nodeValue.length) return 0
  1863. if (1 == c.nodeType && a.startOffset != c.childNodes.length) return 0
  1864. for (; c !== b; ) {
  1865. if (c.nextSibling) return 0
  1866. c = c.parentNode
  1867. }
  1868. return 1
  1869. },
  1870. isBoundaryNode: function (a, b) {
  1871. for (var c; !domUtils.isBody(a); )
  1872. if (((c = a), (a = a.parentNode), c !== a[b])) return !1
  1873. return !0
  1874. },
  1875. fillHtml: browser.ie11below ? '&nbsp;' : '<br/>'
  1876. }),
  1877. fillCharReg = new RegExp(domUtils.fillChar, 'g')
  1878. !(function () {
  1879. function a(a) {
  1880. a.collapsed =
  1881. a.startContainer &&
  1882. a.endContainer &&
  1883. a.startContainer === a.endContainer &&
  1884. a.startOffset == a.endOffset
  1885. }
  1886. function b(a) {
  1887. return (
  1888. !a.collapsed &&
  1889. 1 == a.startContainer.nodeType &&
  1890. a.startContainer === a.endContainer &&
  1891. a.endOffset - a.startOffset == 1
  1892. )
  1893. }
  1894. function c(b, c, d, e) {
  1895. return (
  1896. 1 == c.nodeType &&
  1897. (dtd.$empty[c.tagName] || dtd.$nonChild[c.tagName]) &&
  1898. ((d = domUtils.getNodeIndex(c) + (b ? 0 : 1)), (c = c.parentNode)),
  1899. b
  1900. ? ((e.startContainer = c),
  1901. (e.startOffset = d),
  1902. e.endContainer || e.collapse(!0))
  1903. : ((e.endContainer = c),
  1904. (e.endOffset = d),
  1905. e.startContainer || e.collapse(!1)),
  1906. a(e),
  1907. e
  1908. )
  1909. }
  1910. function d(a, b) {
  1911. var c,
  1912. d,
  1913. e = a.startContainer,
  1914. f = a.endContainer,
  1915. g = a.startOffset,
  1916. h = a.endOffset,
  1917. i = a.document,
  1918. j = i.createDocumentFragment()
  1919. if (
  1920. (1 == e.nodeType &&
  1921. (e = e.childNodes[g] || (c = e.appendChild(i.createTextNode('')))),
  1922. 1 == f.nodeType &&
  1923. (f = f.childNodes[h] || (d = f.appendChild(i.createTextNode('')))),
  1924. e === f && 3 == e.nodeType)
  1925. )
  1926. return (
  1927. j.appendChild(i.createTextNode(e.substringData(g, h - g))),
  1928. b && (e.deleteData(g, h - g), a.collapse(!0)),
  1929. j
  1930. )
  1931. for (
  1932. var k,
  1933. l,
  1934. m = j,
  1935. n = domUtils.findParents(e, !0),
  1936. o = domUtils.findParents(f, !0),
  1937. p = 0;
  1938. n[p] == o[p];
  1939. )
  1940. p++
  1941. for (var q, r = p; (q = n[r]); r++) {
  1942. for (
  1943. k = q.nextSibling,
  1944. q == e
  1945. ? c ||
  1946. (3 == a.startContainer.nodeType
  1947. ? (m.appendChild(i.createTextNode(e.nodeValue.slice(g))),
  1948. b && e.deleteData(g, e.nodeValue.length - g))
  1949. : m.appendChild(b ? e : e.cloneNode(!0)))
  1950. : ((l = q.cloneNode(!1)), m.appendChild(l));
  1951. k && k !== f && k !== o[r];
  1952. )
  1953. (q = k.nextSibling), m.appendChild(b ? k : k.cloneNode(!0)), (k = q)
  1954. m = l
  1955. }
  1956. ;(m = j),
  1957. n[p] || (m.appendChild(n[p - 1].cloneNode(!1)), (m = m.firstChild))
  1958. for (var s, r = p; (s = o[r]); r++) {
  1959. if (
  1960. ((k = s.previousSibling),
  1961. s == f
  1962. ? d ||
  1963. 3 != a.endContainer.nodeType ||
  1964. (m.appendChild(i.createTextNode(f.substringData(0, h))),
  1965. b && f.deleteData(0, h))
  1966. : ((l = s.cloneNode(!1)), m.appendChild(l)),
  1967. r != p || !n[p])
  1968. )
  1969. for (; k && k !== e; )
  1970. (s = k.previousSibling),
  1971. m.insertBefore(b ? k : k.cloneNode(!0), m.firstChild),
  1972. (k = s)
  1973. m = l
  1974. }
  1975. return (
  1976. b &&
  1977. a
  1978. .setStartBefore(o[p] ? (n[p] ? o[p] : n[p - 1]) : o[p - 1])
  1979. .collapse(!0),
  1980. c && domUtils.remove(c),
  1981. d && domUtils.remove(d),
  1982. j
  1983. )
  1984. }
  1985. function e(a, b) {
  1986. try {
  1987. if (g && domUtils.inDoc(g, a))
  1988. if (g.nodeValue.replace(fillCharReg, '').length)
  1989. g.nodeValue = g.nodeValue.replace(fillCharReg, '')
  1990. else {
  1991. var c = g.parentNode
  1992. for (
  1993. domUtils.remove(g);
  1994. c &&
  1995. domUtils.isEmptyInlineElement(c) &&
  1996. (browser.safari
  1997. ? !(domUtils.getPosition(c, b) & domUtils.POSITION_CONTAINS)
  1998. : !c.contains(b));
  1999. )
  2000. (g = c.parentNode), domUtils.remove(c), (c = g)
  2001. }
  2002. } catch (d) {}
  2003. }
  2004. function f(a, b) {
  2005. var c
  2006. for (a = a[b]; a && domUtils.isFillChar(a); )
  2007. (c = a[b]), domUtils.remove(a), (a = c)
  2008. }
  2009. var g,
  2010. h = 0,
  2011. i = domUtils.fillChar,
  2012. j = (dom.Range = function (a) {
  2013. var b = this
  2014. ;(b.startContainer =
  2015. b.startOffset =
  2016. b.endContainer =
  2017. b.endOffset =
  2018. null),
  2019. (b.document = a),
  2020. (b.collapsed = !0)
  2021. })
  2022. j.prototype = {
  2023. cloneContents: function () {
  2024. return this.collapsed ? null : d(this, 0)
  2025. },
  2026. deleteContents: function () {
  2027. var a
  2028. return (
  2029. this.collapsed || d(this, 1),
  2030. browser.webkit &&
  2031. ((a = this.startContainer),
  2032. 3 != a.nodeType ||
  2033. a.nodeValue.length ||
  2034. (this.setStartBefore(a).collapse(!0), domUtils.remove(a))),
  2035. this
  2036. )
  2037. },
  2038. extractContents: function () {
  2039. return this.collapsed ? null : d(this, 2)
  2040. },
  2041. setStart: function (a, b) {
  2042. return c(!0, a, b, this)
  2043. },
  2044. setEnd: function (a, b) {
  2045. return c(!1, a, b, this)
  2046. },
  2047. setStartAfter: function (a) {
  2048. return this.setStart(a.parentNode, domUtils.getNodeIndex(a) + 1)
  2049. },
  2050. setStartBefore: function (a) {
  2051. return this.setStart(a.parentNode, domUtils.getNodeIndex(a))
  2052. },
  2053. setEndAfter: function (a) {
  2054. return this.setEnd(a.parentNode, domUtils.getNodeIndex(a) + 1)
  2055. },
  2056. setEndBefore: function (a) {
  2057. return this.setEnd(a.parentNode, domUtils.getNodeIndex(a))
  2058. },
  2059. setStartAtFirst: function (a) {
  2060. return this.setStart(a, 0)
  2061. },
  2062. setStartAtLast: function (a) {
  2063. return this.setStart(
  2064. a,
  2065. 3 == a.nodeType ? a.nodeValue.length : a.childNodes.length
  2066. )
  2067. },
  2068. setEndAtFirst: function (a) {
  2069. return this.setEnd(a, 0)
  2070. },
  2071. setEndAtLast: function (a) {
  2072. return this.setEnd(
  2073. a,
  2074. 3 == a.nodeType ? a.nodeValue.length : a.childNodes.length
  2075. )
  2076. },
  2077. selectNode: function (a) {
  2078. return this.setStartBefore(a).setEndAfter(a)
  2079. },
  2080. selectNodeContents: function (a) {
  2081. return this.setStart(a, 0).setEndAtLast(a)
  2082. },
  2083. cloneRange: function () {
  2084. var a = this
  2085. return new j(a.document)
  2086. .setStart(a.startContainer, a.startOffset)
  2087. .setEnd(a.endContainer, a.endOffset)
  2088. },
  2089. collapse: function (a) {
  2090. var b = this
  2091. return (
  2092. a
  2093. ? ((b.endContainer = b.startContainer),
  2094. (b.endOffset = b.startOffset))
  2095. : ((b.startContainer = b.endContainer),
  2096. (b.startOffset = b.endOffset)),
  2097. (b.collapsed = !0),
  2098. b
  2099. )
  2100. },
  2101. shrinkBoundary: function (a) {
  2102. function b(a) {
  2103. return (
  2104. 1 == a.nodeType &&
  2105. !domUtils.isBookmarkNode(a) &&
  2106. !dtd.$empty[a.tagName] &&
  2107. !dtd.$nonChild[a.tagName]
  2108. )
  2109. }
  2110. for (
  2111. var c, d = this, e = d.collapsed;
  2112. 1 == d.startContainer.nodeType &&
  2113. (c = d.startContainer.childNodes[d.startOffset]) &&
  2114. b(c);
  2115. )
  2116. d.setStart(c, 0)
  2117. if (e) return d.collapse(!0)
  2118. if (!a)
  2119. for (
  2120. ;
  2121. 1 == d.endContainer.nodeType &&
  2122. d.endOffset > 0 &&
  2123. (c = d.endContainer.childNodes[d.endOffset - 1]) &&
  2124. b(c);
  2125. )
  2126. d.setEnd(c, c.childNodes.length)
  2127. return d
  2128. },
  2129. getCommonAncestor: function (a, c) {
  2130. var d = this,
  2131. e = d.startContainer,
  2132. f = d.endContainer
  2133. return e === f
  2134. ? a && b(this) && ((e = e.childNodes[d.startOffset]), 1 == e.nodeType)
  2135. ? e
  2136. : c && 3 == e.nodeType
  2137. ? e.parentNode
  2138. : e
  2139. : domUtils.getCommonAncestor(e, f)
  2140. },
  2141. trimBoundary: function (a) {
  2142. this.txtToElmBoundary()
  2143. var b = this.startContainer,
  2144. c = this.startOffset,
  2145. d = this.collapsed,
  2146. e = this.endContainer
  2147. if (3 == b.nodeType) {
  2148. if (0 == c) this.setStartBefore(b)
  2149. else if (c >= b.nodeValue.length) this.setStartAfter(b)
  2150. else {
  2151. var f = domUtils.split(b, c)
  2152. b === e
  2153. ? this.setEnd(f, this.endOffset - c)
  2154. : b.parentNode === e && (this.endOffset += 1),
  2155. this.setStartBefore(f)
  2156. }
  2157. if (d) return this.collapse(!0)
  2158. }
  2159. return (
  2160. a ||
  2161. ((c = this.endOffset),
  2162. (e = this.endContainer),
  2163. 3 == e.nodeType &&
  2164. (0 == c
  2165. ? this.setEndBefore(e)
  2166. : (c < e.nodeValue.length && domUtils.split(e, c),
  2167. this.setEndAfter(e)))),
  2168. this
  2169. )
  2170. },
  2171. txtToElmBoundary: function (a) {
  2172. function b(a, b) {
  2173. var c = a[b + 'Container'],
  2174. d = a[b + 'Offset']
  2175. 3 == c.nodeType &&
  2176. (d
  2177. ? d >= c.nodeValue.length &&
  2178. a[
  2179. 'set' +
  2180. b.replace(/(\w)/, function (a) {
  2181. return a.toUpperCase()
  2182. }) +
  2183. 'After'
  2184. ](c)
  2185. : a[
  2186. 'set' +
  2187. b.replace(/(\w)/, function (a) {
  2188. return a.toUpperCase()
  2189. }) +
  2190. 'Before'
  2191. ](c))
  2192. }
  2193. return (
  2194. (!a && this.collapsed) || (b(this, 'start'), b(this, 'end')), this
  2195. )
  2196. },
  2197. insertNode: function (a) {
  2198. var b = a,
  2199. c = 1
  2200. 11 == a.nodeType && ((b = a.firstChild), (c = a.childNodes.length)),
  2201. this.trimBoundary(!0)
  2202. var d = this.startContainer,
  2203. e = this.startOffset,
  2204. f = d.childNodes[e]
  2205. return (
  2206. f ? d.insertBefore(a, f) : d.appendChild(a),
  2207. b.parentNode === this.endContainer &&
  2208. (this.endOffset = this.endOffset + c),
  2209. this.setStartBefore(b)
  2210. )
  2211. },
  2212. setCursor: function (a, b) {
  2213. return this.collapse(!a).select(b)
  2214. },
  2215. createBookmark: function (a, b) {
  2216. var c,
  2217. d = this.document.createElement('span')
  2218. return (
  2219. (d.style.cssText = 'display:none;line-height:0px;'),
  2220. d.appendChild(this.document.createTextNode('‍')),
  2221. (d.id = '_baidu_bookmark_start_' + (b ? '' : h++)),
  2222. this.collapsed ||
  2223. ((c = d.cloneNode(!0)),
  2224. (c.id = '_baidu_bookmark_end_' + (b ? '' : h++))),
  2225. this.insertNode(d),
  2226. c && this.collapse().insertNode(c).setEndBefore(c),
  2227. this.setStartAfter(d),
  2228. { start: a ? d.id : d, end: c ? (a ? c.id : c) : null, id: a }
  2229. )
  2230. },
  2231. moveToBookmark: function (a) {
  2232. var b = a.id ? this.document.getElementById(a.start) : a.start,
  2233. c = a.end && a.id ? this.document.getElementById(a.end) : a.end
  2234. return (
  2235. this.setStartBefore(b),
  2236. domUtils.remove(b),
  2237. c ? (this.setEndBefore(c), domUtils.remove(c)) : this.collapse(!0),
  2238. this
  2239. )
  2240. },
  2241. enlarge: function (a, b) {
  2242. var c,
  2243. d,
  2244. e = domUtils.isBody,
  2245. f = this.document.createTextNode('')
  2246. if (a) {
  2247. for (
  2248. d = this.startContainer,
  2249. 1 == d.nodeType
  2250. ? d.childNodes[this.startOffset]
  2251. ? (c = d = d.childNodes[this.startOffset])
  2252. : (d.appendChild(f), (c = d = f))
  2253. : (c = d);
  2254. ;
  2255. ) {
  2256. if (domUtils.isBlockElm(d)) {
  2257. for (d = c; (c = d.previousSibling) && !domUtils.isBlockElm(c); )
  2258. d = c
  2259. this.setStartBefore(d)
  2260. break
  2261. }
  2262. ;(c = d), (d = d.parentNode)
  2263. }
  2264. for (
  2265. d = this.endContainer,
  2266. 1 == d.nodeType
  2267. ? ((c = d.childNodes[this.endOffset])
  2268. ? d.insertBefore(f, c)
  2269. : d.appendChild(f),
  2270. (c = d = f))
  2271. : (c = d);
  2272. ;
  2273. ) {
  2274. if (domUtils.isBlockElm(d)) {
  2275. for (d = c; (c = d.nextSibling) && !domUtils.isBlockElm(c); )
  2276. d = c
  2277. this.setEndAfter(d)
  2278. break
  2279. }
  2280. ;(c = d), (d = d.parentNode)
  2281. }
  2282. f.parentNode === this.endContainer && this.endOffset--,
  2283. domUtils.remove(f)
  2284. }
  2285. if (!this.collapsed) {
  2286. for (
  2287. ;
  2288. !(
  2289. 0 != this.startOffset ||
  2290. (b && b(this.startContainer)) ||
  2291. e(this.startContainer)
  2292. );
  2293. )
  2294. this.setStartBefore(this.startContainer)
  2295. for (
  2296. ;
  2297. !(
  2298. this.endOffset !=
  2299. (1 == this.endContainer.nodeType
  2300. ? this.endContainer.childNodes.length
  2301. : this.endContainer.nodeValue.length) ||
  2302. (b && b(this.endContainer)) ||
  2303. e(this.endContainer)
  2304. );
  2305. )
  2306. this.setEndAfter(this.endContainer)
  2307. }
  2308. return this
  2309. },
  2310. enlargeToBlockElm: function (a) {
  2311. for (; !domUtils.isBlockElm(this.startContainer); )
  2312. this.setStartBefore(this.startContainer)
  2313. if (!a)
  2314. for (; !domUtils.isBlockElm(this.endContainer); )
  2315. this.setEndAfter(this.endContainer)
  2316. return this
  2317. },
  2318. adjustmentBoundary: function () {
  2319. if (!this.collapsed) {
  2320. for (
  2321. ;
  2322. !domUtils.isBody(this.startContainer) &&
  2323. this.startOffset ==
  2324. this.startContainer[
  2325. 3 == this.startContainer.nodeType ? 'nodeValue' : 'childNodes'
  2326. ].length &&
  2327. this.startContainer[
  2328. 3 == this.startContainer.nodeType ? 'nodeValue' : 'childNodes'
  2329. ].length;
  2330. )
  2331. this.setStartAfter(this.startContainer)
  2332. for (
  2333. ;
  2334. !domUtils.isBody(this.endContainer) &&
  2335. !this.endOffset &&
  2336. this.endContainer[
  2337. 3 == this.endContainer.nodeType ? 'nodeValue' : 'childNodes'
  2338. ].length;
  2339. )
  2340. this.setEndBefore(this.endContainer)
  2341. }
  2342. return this
  2343. },
  2344. applyInlineStyle: function (a, b, c) {
  2345. if (this.collapsed) return this
  2346. this.trimBoundary()
  2347. .enlarge(!1, function (a) {
  2348. return 1 == a.nodeType && domUtils.isBlockElm(a)
  2349. })
  2350. .adjustmentBoundary()
  2351. for (
  2352. var d,
  2353. e,
  2354. f = this.createBookmark(),
  2355. g = f.end,
  2356. h = function (a) {
  2357. return 1 == a.nodeType
  2358. ? 'br' != a.tagName.toLowerCase()
  2359. : !domUtils.isWhitespace(a)
  2360. },
  2361. i = domUtils.getNextDomNode(f.start, !1, h),
  2362. j = this.cloneRange();
  2363. i && domUtils.getPosition(i, g) & domUtils.POSITION_PRECEDING;
  2364. )
  2365. if (3 == i.nodeType || dtd[a][i.tagName]) {
  2366. for (
  2367. j.setStartBefore(i), d = i;
  2368. d && (3 == d.nodeType || dtd[a][d.tagName]) && d !== g;
  2369. )
  2370. (e = d),
  2371. (d = domUtils.getNextDomNode(
  2372. d,
  2373. 1 == d.nodeType,
  2374. null,
  2375. function (b) {
  2376. return dtd[a][b.tagName]
  2377. }
  2378. ))
  2379. var k,
  2380. l = j.setEndAfter(e).extractContents()
  2381. if (c && c.length > 0) {
  2382. var m, n
  2383. n = m = c[0].cloneNode(!1)
  2384. for (var o, p = 1; (o = c[p++]); )
  2385. m.appendChild(o.cloneNode(!1)), (m = m.firstChild)
  2386. k = m
  2387. } else k = j.document.createElement(a)
  2388. b && domUtils.setAttributes(k, b),
  2389. k.appendChild(l),
  2390. j.insertNode(c ? n : k)
  2391. var q
  2392. if (
  2393. ('span' == a &&
  2394. b.style &&
  2395. /text\-decoration/.test(b.style) &&
  2396. (q = domUtils.findParentByTagName(k, 'a', !0))
  2397. ? (domUtils.setAttributes(q, b),
  2398. domUtils.remove(k, !0),
  2399. (k = q))
  2400. : (domUtils.mergeSibling(k), domUtils.clearEmptySibling(k)),
  2401. domUtils.mergeChild(k, b),
  2402. (i = domUtils.getNextDomNode(k, !1, h)),
  2403. domUtils.mergeToParent(k),
  2404. d === g)
  2405. )
  2406. break
  2407. } else i = domUtils.getNextDomNode(i, !0, h)
  2408. return this.moveToBookmark(f)
  2409. },
  2410. removeInlineStyle: function (a) {
  2411. if (this.collapsed) return this
  2412. ;(a = utils.isArray(a) ? a : [a]),
  2413. this.shrinkBoundary().adjustmentBoundary()
  2414. for (var b = this.startContainer, c = this.endContainer; ; ) {
  2415. if (1 == b.nodeType) {
  2416. if (utils.indexOf(a, b.tagName.toLowerCase()) > -1) break
  2417. if ('body' == b.tagName.toLowerCase()) {
  2418. b = null
  2419. break
  2420. }
  2421. }
  2422. b = b.parentNode
  2423. }
  2424. for (;;) {
  2425. if (1 == c.nodeType) {
  2426. if (utils.indexOf(a, c.tagName.toLowerCase()) > -1) break
  2427. if ('body' == c.tagName.toLowerCase()) {
  2428. c = null
  2429. break
  2430. }
  2431. }
  2432. c = c.parentNode
  2433. }
  2434. var d,
  2435. e,
  2436. f = this.createBookmark()
  2437. b &&
  2438. ((e = this.cloneRange().setEndBefore(f.start).setStartBefore(b)),
  2439. (d = e.extractContents()),
  2440. e.insertNode(d),
  2441. domUtils.clearEmptySibling(b, !0),
  2442. b.parentNode.insertBefore(f.start, b)),
  2443. c &&
  2444. ((e = this.cloneRange().setStartAfter(f.end).setEndAfter(c)),
  2445. (d = e.extractContents()),
  2446. e.insertNode(d),
  2447. domUtils.clearEmptySibling(c, !1, !0),
  2448. c.parentNode.insertBefore(f.end, c.nextSibling))
  2449. for (
  2450. var g,
  2451. h = domUtils.getNextDomNode(f.start, !1, function (a) {
  2452. return 1 == a.nodeType
  2453. });
  2454. h && h !== f.end;
  2455. )
  2456. (g = domUtils.getNextDomNode(h, !0, function (a) {
  2457. return 1 == a.nodeType
  2458. })),
  2459. utils.indexOf(a, h.tagName.toLowerCase()) > -1 &&
  2460. domUtils.remove(h, !0),
  2461. (h = g)
  2462. return this.moveToBookmark(f)
  2463. },
  2464. getClosedNode: function () {
  2465. var a
  2466. if (!this.collapsed) {
  2467. var c = this.cloneRange().adjustmentBoundary().shrinkBoundary()
  2468. if (b(c)) {
  2469. var d = c.startContainer.childNodes[c.startOffset]
  2470. d &&
  2471. 1 == d.nodeType &&
  2472. (dtd.$empty[d.tagName] || dtd.$nonChild[d.tagName]) &&
  2473. (a = d)
  2474. }
  2475. }
  2476. return a
  2477. },
  2478. select: browser.ie
  2479. ? function (a, b) {
  2480. var c
  2481. this.collapsed || this.shrinkBoundary()
  2482. var d = this.getClosedNode()
  2483. if (d && !b) {
  2484. try {
  2485. ;(c = this.document.body.createControlRange()),
  2486. c.addElement(d),
  2487. c.select()
  2488. } catch (h) {}
  2489. return this
  2490. }
  2491. var j,
  2492. k = this.createBookmark(),
  2493. l = k.start
  2494. if (
  2495. ((c = this.document.body.createTextRange()),
  2496. c.moveToElementText(l),
  2497. c.moveStart('character', 1),
  2498. this.collapsed)
  2499. ) {
  2500. if (!a && 3 != this.startContainer.nodeType) {
  2501. var m = this.document.createTextNode(i),
  2502. n = this.document.createElement('span')
  2503. n.appendChild(this.document.createTextNode(i)),
  2504. l.parentNode.insertBefore(n, l),
  2505. l.parentNode.insertBefore(m, l),
  2506. e(this.document, m),
  2507. (g = m),
  2508. f(n, 'previousSibling'),
  2509. f(l, 'nextSibling'),
  2510. c.moveStart('character', -1),
  2511. c.collapse(!0)
  2512. }
  2513. } else {
  2514. var o = this.document.body.createTextRange()
  2515. ;(j = k.end), o.moveToElementText(j), c.setEndPoint('EndToEnd', o)
  2516. }
  2517. this.moveToBookmark(k), n && domUtils.remove(n)
  2518. try {
  2519. c.select()
  2520. } catch (h) {}
  2521. return this
  2522. }
  2523. : function (a) {
  2524. function b(a) {
  2525. function b(b, c, d) {
  2526. 3 == b.nodeType &&
  2527. b.nodeValue.length < c &&
  2528. (a[d + 'Offset'] = b.nodeValue.length)
  2529. }
  2530. b(a.startContainer, a.startOffset, 'start'),
  2531. b(a.endContainer, a.endOffset, 'end')
  2532. }
  2533. var c,
  2534. d = domUtils.getWindow(this.document),
  2535. h = d.getSelection()
  2536. if ((browser.gecko ? this.document.body.focus() : d.focus(), h)) {
  2537. if ((h.removeAllRanges(), this.collapsed && !a)) {
  2538. var j = this.startContainer,
  2539. k = j
  2540. 1 == j.nodeType && (k = j.childNodes[this.startOffset]),
  2541. (3 == j.nodeType && this.startOffset) ||
  2542. (k
  2543. ? k.previousSibling && 3 == k.previousSibling.nodeType
  2544. : j.lastChild && 3 == j.lastChild.nodeType) ||
  2545. ((c = this.document.createTextNode(i)),
  2546. this.insertNode(c),
  2547. e(this.document, c),
  2548. f(c, 'previousSibling'),
  2549. f(c, 'nextSibling'),
  2550. (g = c),
  2551. this.setStart(c, browser.webkit ? 1 : 0).collapse(!0))
  2552. }
  2553. var l = this.document.createRange()
  2554. if (
  2555. this.collapsed &&
  2556. browser.opera &&
  2557. 1 == this.startContainer.nodeType
  2558. ) {
  2559. var k = this.startContainer.childNodes[this.startOffset]
  2560. if (k) {
  2561. for (
  2562. ;
  2563. k &&
  2564. domUtils.isBlockElm(k) &&
  2565. 1 == k.nodeType &&
  2566. k.childNodes[0];
  2567. )
  2568. k = k.childNodes[0]
  2569. k && this.setStartBefore(k).collapse(!0)
  2570. } else
  2571. (k = this.startContainer.lastChild),
  2572. k && domUtils.isBr(k) && this.setStartBefore(k).collapse(!0)
  2573. }
  2574. b(this),
  2575. l.setStart(this.startContainer, this.startOffset),
  2576. l.setEnd(this.endContainer, this.endOffset),
  2577. h.addRange(l)
  2578. }
  2579. return this
  2580. },
  2581. scrollToView: function (a, b) {
  2582. a = a ? window : domUtils.getWindow(this.document)
  2583. var c = this,
  2584. d = c.document.createElement('span')
  2585. return (
  2586. (d.innerHTML = '&nbsp;'),
  2587. c.cloneRange().insertNode(d),
  2588. domUtils.scrollToView(d, a, b),
  2589. domUtils.remove(d),
  2590. c
  2591. )
  2592. },
  2593. inFillChar: function () {
  2594. var a = this.startContainer
  2595. return !(
  2596. !this.collapsed ||
  2597. 3 != a.nodeType ||
  2598. a.nodeValue.replace(new RegExp('^' + domUtils.fillChar), '').length +
  2599. 1 !=
  2600. a.nodeValue.length
  2601. )
  2602. },
  2603. createAddress: function (a, b) {
  2604. function c(a) {
  2605. for (
  2606. var c,
  2607. d = a ? e.startContainer : e.endContainer,
  2608. f = domUtils.findParents(d, !0, function (a) {
  2609. return !domUtils.isBody(a)
  2610. }),
  2611. g = [],
  2612. h = 0;
  2613. (c = f[h++]);
  2614. )
  2615. g.push(domUtils.getNodeIndex(c, b))
  2616. var i = 0
  2617. if (b)
  2618. if (3 == d.nodeType) {
  2619. for (var j = d.previousSibling; j && 3 == j.nodeType; )
  2620. (i += j.nodeValue.replace(fillCharReg, '').length),
  2621. (j = j.previousSibling)
  2622. i += a ? e.startOffset : e.endOffset
  2623. } else if ((d = d.childNodes[a ? e.startOffset : e.endOffset]))
  2624. i = domUtils.getNodeIndex(d, b)
  2625. else {
  2626. d = a ? e.startContainer : e.endContainer
  2627. for (var k = d.firstChild; k; )
  2628. if (domUtils.isFillChar(k)) k = k.nextSibling
  2629. else if ((i++, 3 == k.nodeType))
  2630. for (; k && 3 == k.nodeType; ) k = k.nextSibling
  2631. else k = k.nextSibling
  2632. }
  2633. else
  2634. i = a ? (domUtils.isFillChar(d) ? 0 : e.startOffset) : e.endOffset
  2635. return i < 0 && (i = 0), g.push(i), g
  2636. }
  2637. var d = {},
  2638. e = this
  2639. return (
  2640. (d.startAddress = c(!0)),
  2641. a || (d.endAddress = e.collapsed ? [].concat(d.startAddress) : c()),
  2642. d
  2643. )
  2644. },
  2645. moveToAddress: function (a, b) {
  2646. function c(a, b) {
  2647. for (
  2648. var c, e, f, g = d.document.body, h = 0, i = a.length;
  2649. h < i;
  2650. h++
  2651. )
  2652. if (((f = a[h]), (c = g), (g = g.childNodes[f]), !g)) {
  2653. e = f
  2654. break
  2655. }
  2656. b
  2657. ? g
  2658. ? d.setStartBefore(g)
  2659. : d.setStart(c, e)
  2660. : g
  2661. ? d.setEndBefore(g)
  2662. : d.setEnd(c, e)
  2663. }
  2664. var d = this
  2665. return c(a.startAddress, !0), !b && a.endAddress && c(a.endAddress), d
  2666. },
  2667. equals: function (a) {
  2668. for (var b in this)
  2669. if (this.hasOwnProperty(b) && this[b] !== a[b]) return !1
  2670. return !0
  2671. },
  2672. traversal: function (a, b) {
  2673. if (this.collapsed) return this
  2674. for (
  2675. var c = this.createBookmark(),
  2676. d = c.end,
  2677. e = domUtils.getNextDomNode(c.start, !1, b);
  2678. e &&
  2679. e !== d &&
  2680. domUtils.getPosition(e, d) & domUtils.POSITION_PRECEDING;
  2681. ) {
  2682. var f = domUtils.getNextDomNode(e, !1, b)
  2683. a(e), (e = f)
  2684. }
  2685. return this.moveToBookmark(c)
  2686. }
  2687. }
  2688. })(),
  2689. (function () {
  2690. function a(a, b) {
  2691. var c = domUtils.getNodeIndex
  2692. ;(a = a.duplicate()), a.collapse(b)
  2693. var d = a.parentElement()
  2694. if (!d.hasChildNodes()) return { container: d, offset: 0 }
  2695. for (
  2696. var e,
  2697. f,
  2698. g = d.children,
  2699. h = a.duplicate(),
  2700. i = 0,
  2701. j = g.length - 1,
  2702. k = -1;
  2703. i <= j;
  2704. ) {
  2705. ;(k = Math.floor((i + j) / 2)), (e = g[k]), h.moveToElementText(e)
  2706. var l = h.compareEndPoints('StartToStart', a)
  2707. if (l > 0) j = k - 1
  2708. else {
  2709. if (!(l < 0)) return { container: d, offset: c(e) }
  2710. i = k + 1
  2711. }
  2712. }
  2713. if (k == -1) {
  2714. if (
  2715. (h.moveToElementText(d),
  2716. h.setEndPoint('StartToStart', a),
  2717. (f = h.text.replace(/(\r\n|\r)/g, '\n').length),
  2718. (g = d.childNodes),
  2719. !f)
  2720. )
  2721. return (
  2722. (e = g[g.length - 1]),
  2723. { container: e, offset: e.nodeValue.length }
  2724. )
  2725. for (var m = g.length; f > 0; ) f -= g[--m].nodeValue.length
  2726. return { container: g[m], offset: -f }
  2727. }
  2728. if (
  2729. (h.collapse(l > 0),
  2730. h.setEndPoint(l > 0 ? 'StartToStart' : 'EndToStart', a),
  2731. (f = h.text.replace(/(\r\n|\r)/g, '\n').length),
  2732. !f)
  2733. )
  2734. return dtd.$empty[e.tagName] || dtd.$nonChild[e.tagName]
  2735. ? { container: d, offset: c(e) + (l > 0 ? 0 : 1) }
  2736. : { container: e, offset: l > 0 ? 0 : e.childNodes.length }
  2737. for (; f > 0; )
  2738. try {
  2739. var n = e
  2740. ;(e = e[l > 0 ? 'previousSibling' : 'nextSibling']),
  2741. (f -= e.nodeValue.length)
  2742. } catch (o) {
  2743. return { container: d, offset: c(n) }
  2744. }
  2745. return { container: e, offset: l > 0 ? -f : e.nodeValue.length + f }
  2746. }
  2747. function b(b, c) {
  2748. if (b.item) c.selectNode(b.item(0))
  2749. else {
  2750. var d = a(b, !0)
  2751. c.setStart(d.container, d.offset),
  2752. 0 != b.compareEndPoints('StartToEnd', b) &&
  2753. ((d = a(b, !1)), c.setEnd(d.container, d.offset))
  2754. }
  2755. return c
  2756. }
  2757. function c(a) {
  2758. var b
  2759. try {
  2760. b = a.getNative().createRange()
  2761. } catch (c) {
  2762. return null
  2763. }
  2764. var d = b.item ? b.item(0) : b.parentElement()
  2765. return (d.ownerDocument || d) === a.document ? b : null
  2766. }
  2767. var d = (dom.Selection = function (a) {
  2768. var b,
  2769. d = this
  2770. ;(d.document = a),
  2771. browser.ie9below &&
  2772. ((b = domUtils.getWindow(a).frameElement),
  2773. domUtils.on(b, 'beforedeactivate', function () {
  2774. d._bakIERange = d.getIERange()
  2775. }),
  2776. domUtils.on(b, 'activate', function () {
  2777. try {
  2778. !c(d) && d._bakIERange && d._bakIERange.select()
  2779. } catch (a) {}
  2780. d._bakIERange = null
  2781. })),
  2782. (b = a = null)
  2783. })
  2784. d.prototype = {
  2785. rangeInBody: function (a, b) {
  2786. var c =
  2787. browser.ie9below || b
  2788. ? a.item
  2789. ? a.item()
  2790. : a.parentElement()
  2791. : a.startContainer
  2792. return c === this.document.body || domUtils.inDoc(c, this.document)
  2793. },
  2794. getNative: function () {
  2795. var a = this.document
  2796. try {
  2797. return a
  2798. ? browser.ie9below
  2799. ? a.selection
  2800. : domUtils.getWindow(a).getSelection()
  2801. : null
  2802. } catch (b) {
  2803. return null
  2804. }
  2805. },
  2806. getIERange: function () {
  2807. var a = c(this)
  2808. return !a && this._bakIERange ? this._bakIERange : a
  2809. },
  2810. cache: function () {
  2811. this.clear(),
  2812. (this._cachedRange = this.getRange()),
  2813. (this._cachedStartElement = this.getStart()),
  2814. (this._cachedStartElementPath = this.getStartElementPath())
  2815. },
  2816. getStartElementPath: function () {
  2817. if (this._cachedStartElementPath) return this._cachedStartElementPath
  2818. var a = this.getStart()
  2819. return a ? domUtils.findParents(a, !0, null, !0) : []
  2820. },
  2821. clear: function () {
  2822. this._cachedStartElementPath =
  2823. this._cachedRange =
  2824. this._cachedStartElement =
  2825. null
  2826. },
  2827. isFocus: function () {
  2828. try {
  2829. if (browser.ie9below) {
  2830. var a = c(this)
  2831. return !(!a || !this.rangeInBody(a))
  2832. }
  2833. return !!this.getNative().rangeCount
  2834. } catch (b) {
  2835. return !1
  2836. }
  2837. },
  2838. getRange: function () {
  2839. function a(a) {
  2840. for (
  2841. var b = c.document.body.firstChild, d = a.collapsed;
  2842. b && b.firstChild;
  2843. )
  2844. a.setStart(b, 0), (b = b.firstChild)
  2845. a.startContainer || a.setStart(c.document.body, 0),
  2846. d && a.collapse(!0)
  2847. }
  2848. var c = this
  2849. if (null != c._cachedRange) return this._cachedRange
  2850. var d = new baidu.editor.dom.Range(c.document)
  2851. if (browser.ie9below) {
  2852. var e = c.getIERange()
  2853. if (e)
  2854. try {
  2855. b(e, d)
  2856. } catch (f) {
  2857. a(d)
  2858. }
  2859. else a(d)
  2860. } else {
  2861. var g = c.getNative()
  2862. if (g && g.rangeCount) {
  2863. var h = g.getRangeAt(0),
  2864. i = g.getRangeAt(g.rangeCount - 1)
  2865. d
  2866. .setStart(h.startContainer, h.startOffset)
  2867. .setEnd(i.endContainer, i.endOffset),
  2868. d.collapsed &&
  2869. domUtils.isBody(d.startContainer) &&
  2870. !d.startOffset &&
  2871. a(d)
  2872. } else {
  2873. if (
  2874. this._bakRange &&
  2875. domUtils.inDoc(this._bakRange.startContainer, this.document)
  2876. )
  2877. return this._bakRange
  2878. a(d)
  2879. }
  2880. }
  2881. return (this._bakRange = d)
  2882. },
  2883. getStart: function () {
  2884. if (this._cachedStartElement) return this._cachedStartElement
  2885. var a,
  2886. b,
  2887. c,
  2888. d,
  2889. e = browser.ie9below ? this.getIERange() : this.getRange()
  2890. if (browser.ie9below) {
  2891. if (!e) return this.document.body.firstChild
  2892. if (e.item) return e.item(0)
  2893. for (
  2894. a = e.duplicate(),
  2895. a.text.length > 0 && a.moveStart('character', 1),
  2896. a.collapse(1),
  2897. b = a.parentElement(),
  2898. d = c = e.parentElement();
  2899. (c = c.parentNode);
  2900. )
  2901. if (c == b) {
  2902. b = d
  2903. break
  2904. }
  2905. } else if (
  2906. (e.shrinkBoundary(),
  2907. (b = e.startContainer),
  2908. 1 == b.nodeType &&
  2909. b.hasChildNodes() &&
  2910. (b =
  2911. b.childNodes[Math.min(b.childNodes.length - 1, e.startOffset)]),
  2912. 3 == b.nodeType)
  2913. )
  2914. return b.parentNode
  2915. return b
  2916. },
  2917. getText: function () {
  2918. var a, b
  2919. return this.isFocus() && (a = this.getNative())
  2920. ? ((b = browser.ie9below ? a.createRange() : a.getRangeAt(0)),
  2921. browser.ie9below ? b.text : b.toString())
  2922. : ''
  2923. },
  2924. clearRange: function () {
  2925. this.getNative()[browser.ie9below ? 'empty' : 'removeAllRanges']()
  2926. }
  2927. }
  2928. })(),
  2929. (function () {
  2930. function a(a, b) {
  2931. var c
  2932. if (b.textarea)
  2933. if (utils.isString(b.textarea)) {
  2934. for (
  2935. var d, e = 0, f = domUtils.getElementsByTagName(a, 'textarea');
  2936. (d = f[e++]);
  2937. )
  2938. if (d.id == 'ueditor_textarea_' + b.options.textarea) {
  2939. c = d
  2940. break
  2941. }
  2942. } else c = b.textarea
  2943. c ||
  2944. (a.appendChild(
  2945. (c = domUtils.createElement(document, 'textarea', {
  2946. name: b.options.textarea,
  2947. id: 'ueditor_textarea_' + b.options.textarea,
  2948. style: 'display:none'
  2949. }))
  2950. ),
  2951. (b.textarea = c)),
  2952. !c.getAttribute('name') && c.setAttribute('name', b.options.textarea),
  2953. (c.value = b.hasContents()
  2954. ? b.options.allHtmlEnabled
  2955. ? b.getAllHtml()
  2956. : b.getContent(null, null, !0)
  2957. : '')
  2958. }
  2959. function b(a) {
  2960. for (var b in a) return b
  2961. }
  2962. function c(a) {
  2963. ;(a.langIsReady = !0), a.fireEvent('langReady')
  2964. }
  2965. var d,
  2966. e = 0,
  2967. f = (UE.Editor = function (a) {
  2968. var d = this
  2969. ;(d.uid = e++),
  2970. EventBase.call(d),
  2971. (d.commands = {}),
  2972. (d.options = utils.extend(
  2973. utils.clone(a || {}),
  2974. UEDITOR_CONFIG,
  2975. !0
  2976. )),
  2977. (d.shortcutkeys = {}),
  2978. (d.inputRules = []),
  2979. (d.outputRules = []),
  2980. d.setOpt(f.defaultOptions(d)),
  2981. d.loadServerConfig(),
  2982. utils.isEmptyObject(UE.I18N)
  2983. ? utils.loadFile(
  2984. document,
  2985. {
  2986. src:
  2987. d.options.langPath +
  2988. d.options.lang +
  2989. '/' +
  2990. d.options.lang +
  2991. '.js',
  2992. tag: 'script',
  2993. type: 'text/javascript',
  2994. defer: 'defer'
  2995. },
  2996. function () {
  2997. UE.plugin.load(d), c(d)
  2998. }
  2999. )
  3000. : ((d.options.lang = b(UE.I18N)), UE.plugin.load(d), c(d)),
  3001. (UE.instants['ueditorInstant' + d.uid] = d)
  3002. })
  3003. ;(f.prototype = {
  3004. registerCommand: function (a, b) {
  3005. this.commands[a] = b
  3006. },
  3007. ready: function (a) {
  3008. var b = this
  3009. a && (b.isReady ? a.apply(b) : b.addListener('ready', a))
  3010. },
  3011. setOpt: function (a, b) {
  3012. var c = {}
  3013. utils.isString(a) ? (c[a] = b) : (c = a),
  3014. utils.extend(this.options, c, !0)
  3015. },
  3016. getOpt: function (a) {
  3017. return this.options[a]
  3018. },
  3019. destroy: function () {
  3020. var a = this
  3021. a.fireEvent('destroy')
  3022. var b = a.container.parentNode,
  3023. c = a.textarea
  3024. c
  3025. ? (c.style.display = '')
  3026. : ((c = document.createElement('textarea')),
  3027. b.parentNode.insertBefore(c, b)),
  3028. (c.style.width = a.iframe.offsetWidth + 'px'),
  3029. (c.style.height = a.iframe.offsetHeight + 'px'),
  3030. (c.value = a.getContent()),
  3031. (c.id = a.key),
  3032. (b.innerHTML = ''),
  3033. domUtils.remove(b)
  3034. var d = a.key
  3035. for (var e in a) a.hasOwnProperty(e) && delete this[e]
  3036. UE.delEditor(d)
  3037. },
  3038. render: function (a) {
  3039. var b = this,
  3040. c = b.options,
  3041. d = function (b) {
  3042. return parseInt(domUtils.getComputedStyle(a, b))
  3043. }
  3044. if ((utils.isString(a) && (a = document.getElementById(a)), a)) {
  3045. c.initialFrameWidth
  3046. ? (c.minFrameWidth = c.initialFrameWidth)
  3047. : (c.minFrameWidth = c.initialFrameWidth = a.offsetWidth),
  3048. c.initialFrameHeight
  3049. ? (c.minFrameHeight = c.initialFrameHeight)
  3050. : (c.initialFrameHeight = c.minFrameHeight = a.offsetHeight),
  3051. (a.style.width = /%$/.test(c.initialFrameWidth)
  3052. ? '100%'
  3053. : c.initialFrameWidth -
  3054. d('padding-left') -
  3055. d('padding-right') +
  3056. 'px'),
  3057. (a.style.height = /%$/.test(c.initialFrameHeight)
  3058. ? '100%'
  3059. : c.initialFrameHeight -
  3060. d('padding-top') -
  3061. d('padding-bottom') +
  3062. 'px'),
  3063. (a.style.zIndex = c.zIndex)
  3064. var e =
  3065. (ie && browser.version < 9 ? '' : '<!DOCTYPE html>') +
  3066. "<html xmlns='http://www.w3.org/1999/xhtml' class='view' ><head><style type='text/css'>.view{padding:0;word-wrap:break-word;cursor:text;height:90%;}\nbody{margin:8px;font-family:sans-serif;font-size:16px;}p{margin:5px 0;}</style>" +
  3067. (c.iframeCssUrl
  3068. ? "<link rel='stylesheet' type='text/css' href='" +
  3069. utils.unhtml(c.iframeCssUrl) +
  3070. "'/>"
  3071. : '') +
  3072. (c.initialStyle ? '<style>' + c.initialStyle + '</style>' : '') +
  3073. "</head><body class='view' ></body><script type='text/javascript' " +
  3074. (ie ? "defer='defer'" : '') +
  3075. " id='_initialScript'>setTimeout(function(){editor = window.parent.UE.instants['ueditorInstant" +
  3076. b.uid +
  3077. "'];editor._setup(document);},0);var _tmpScript = document.getElementById('_initialScript');_tmpScript.parentNode.removeChild(_tmpScript);</script></html>"
  3078. a.appendChild(
  3079. domUtils.createElement(document, 'iframe', {
  3080. id: 'ueditor_' + b.uid,
  3081. width: '100%',
  3082. height: '100%',
  3083. frameborder: '0',
  3084. src:
  3085. 'javascript:void(function(){document.open();' +
  3086. (c.customDomain && document.domain != location.hostname
  3087. ? 'document.domain="' + document.domain + '";'
  3088. : '') +
  3089. 'document.write("' +
  3090. e +
  3091. '");document.close();}())'
  3092. })
  3093. ),
  3094. (a.style.overflow = 'hidden'),
  3095. setTimeout(function () {
  3096. ;/%$/.test(c.initialFrameWidth) &&
  3097. (c.minFrameWidth = c.initialFrameWidth = a.offsetWidth),
  3098. /%$/.test(c.initialFrameHeight) &&
  3099. ((c.minFrameHeight = c.initialFrameHeight = a.offsetHeight),
  3100. (a.style.height = c.initialFrameHeight + 'px'))
  3101. })
  3102. }
  3103. },
  3104. _setup: function (b) {
  3105. var c = this,
  3106. d = c.options
  3107. ie
  3108. ? ((b.body.disabled = !0),
  3109. (b.body.contentEditable = !0),
  3110. (b.body.disabled = !1))
  3111. : (b.body.contentEditable = !0),
  3112. (b.body.spellcheck = !1),
  3113. (c.document = b),
  3114. (c.window = b.defaultView || b.parentWindow),
  3115. (c.iframe = c.window.frameElement),
  3116. (c.body = b.body),
  3117. (c.selection = new dom.Selection(b))
  3118. var e
  3119. browser.gecko &&
  3120. (e = this.selection.getNative()) &&
  3121. e.removeAllRanges(),
  3122. this._initEvents()
  3123. for (
  3124. var f = this.iframe.parentNode;
  3125. !domUtils.isBody(f);
  3126. f = f.parentNode
  3127. )
  3128. if ('FORM' == f.tagName) {
  3129. ;(c.form = f),
  3130. c.options.autoSyncData
  3131. ? domUtils.on(c.window, 'blur', function () {
  3132. a(f, c)
  3133. })
  3134. : domUtils.on(f, 'submit', function () {
  3135. a(this, c)
  3136. })
  3137. break
  3138. }
  3139. if (d.initialContent)
  3140. if (d.autoClearinitialContent) {
  3141. var g = c.execCommand
  3142. ;(c.execCommand = function () {
  3143. return (
  3144. c.fireEvent('firstBeforeExecCommand'), g.apply(c, arguments)
  3145. )
  3146. }),
  3147. this._setDefaultContent(d.initialContent)
  3148. } else this.setContent(d.initialContent, !1, !0)
  3149. domUtils.isEmptyNode(c.body) &&
  3150. (c.body.innerHTML = '<p>' + (browser.ie ? '' : '<br/>') + '</p>'),
  3151. d.focus &&
  3152. setTimeout(function () {
  3153. c.focus(c.options.focusInEnd),
  3154. !c.options.autoClearinitialContent && c._selectionChange()
  3155. }, 0),
  3156. c.container || (c.container = this.iframe.parentNode),
  3157. d.fullscreen && c.ui && c.ui.setFullScreen(!0)
  3158. try {
  3159. c.document.execCommand('2D-position', !1, !1)
  3160. } catch (h) {}
  3161. try {
  3162. c.document.execCommand('enableInlineTableEditing', !1, !1)
  3163. } catch (h) {}
  3164. try {
  3165. c.document.execCommand('enableObjectResizing', !1, !1)
  3166. } catch (h) {}
  3167. c._bindshortcutKeys(),
  3168. (c.isReady = 1),
  3169. c.fireEvent('ready'),
  3170. d.onready && d.onready.call(c),
  3171. browser.ie9below ||
  3172. domUtils.on(c.window, ['blur', 'focus'], function (a) {
  3173. if ('blur' == a.type) {
  3174. c._bakRange = c.selection.getRange()
  3175. try {
  3176. ;(c._bakNativeRange = c.selection
  3177. .getNative()
  3178. .getRangeAt(0)),
  3179. c.selection.getNative().removeAllRanges()
  3180. } catch (a) {
  3181. c._bakNativeRange = null
  3182. }
  3183. } else
  3184. try {
  3185. c._bakRange && c._bakRange.select()
  3186. } catch (a) {}
  3187. }),
  3188. browser.gecko &&
  3189. browser.version <= 10902 &&
  3190. ((c.body.contentEditable = !1),
  3191. setTimeout(function () {
  3192. c.body.contentEditable = !0
  3193. }, 100),
  3194. setInterval(function () {
  3195. c.body.style.height = c.iframe.offsetHeight - 20 + 'px'
  3196. }, 100)),
  3197. !d.isShow && c.setHide(),
  3198. d.readonly && c.setDisabled()
  3199. },
  3200. sync: function (b) {
  3201. var c = this,
  3202. d = b
  3203. ? document.getElementById(b)
  3204. : domUtils.findParent(
  3205. c.iframe.parentNode,
  3206. function (a) {
  3207. return 'FORM' == a.tagName
  3208. },
  3209. !0
  3210. )
  3211. d && a(d, c)
  3212. },
  3213. setHeight: function (a, b) {
  3214. a !== parseInt(this.iframe.parentNode.style.height) &&
  3215. (this.iframe.parentNode.style.height = a + 'px'),
  3216. !b &&
  3217. (this.options.minFrameHeight = this.options.initialFrameHeight =
  3218. a),
  3219. (this.body.style.height = a + 'px'),
  3220. !b && this.trigger('setHeight')
  3221. },
  3222. addshortcutkey: function (a, b) {
  3223. var c = {}
  3224. b ? (c[a] = b) : (c = a), utils.extend(this.shortcutkeys, c)
  3225. },
  3226. _bindshortcutKeys: function () {
  3227. var a = this,
  3228. b = this.shortcutkeys
  3229. a.addListener('keydown', function (c, d) {
  3230. var e = d.keyCode || d.which
  3231. for (var f in b)
  3232. for (var g, h = b[f].split(','), i = 0; (g = h[i++]); ) {
  3233. g = g.split(':')
  3234. var j = g[0],
  3235. k = g[1]
  3236. ;(/^(ctrl)(\+shift)?\+(\d+)$/.test(j.toLowerCase()) ||
  3237. /^(\d+)$/.test(j)) &&
  3238. ((('ctrl' == RegExp.$1 ? d.ctrlKey || d.metaKey : 0) &&
  3239. ('' != RegExp.$2 ? d[RegExp.$2.slice(1) + 'Key'] : 1) &&
  3240. e == RegExp.$3) ||
  3241. e == RegExp.$1) &&
  3242. (a.queryCommandState(f, k) != -1 && a.execCommand(f, k),
  3243. domUtils.preventDefault(d))
  3244. }
  3245. })
  3246. },
  3247. getContent: function (a, b, c, d, e) {
  3248. var f = this
  3249. if (
  3250. (a && utils.isFunction(a) && ((b = a), (a = '')),
  3251. b ? !b() : !this.hasContents())
  3252. )
  3253. return ''
  3254. f.fireEvent('beforegetcontent')
  3255. var g = UE.htmlparser(f.body.innerHTML, d)
  3256. return (
  3257. f.filterOutputRule(g),
  3258. f.fireEvent('aftergetcontent', a, g),
  3259. g.toHtml(e)
  3260. )
  3261. },
  3262. getAllHtml: function () {
  3263. var a = this,
  3264. b = []
  3265. if (
  3266. (a.fireEvent('getAllHtml', b), browser.ie && browser.version > 8)
  3267. ) {
  3268. var c = ''
  3269. utils.each(a.document.styleSheets, function (a) {
  3270. c += a.href
  3271. ? '<link rel="stylesheet" type="text/css" href="' +
  3272. a.href +
  3273. '" />'
  3274. : '<style>' + a.cssText + '</style>'
  3275. }),
  3276. utils.each(
  3277. a.document.getElementsByTagName('script'),
  3278. function (a) {
  3279. c += a.outerHTML
  3280. }
  3281. )
  3282. }
  3283. return (
  3284. '<html><head>' +
  3285. (a.options.charset
  3286. ? '<meta http-equiv="Content-Type" content="text/html; charset=' +
  3287. a.options.charset +
  3288. '"/>'
  3289. : '') +
  3290. (c || a.document.getElementsByTagName('head')[0].innerHTML) +
  3291. b.join('\n') +
  3292. '</head><body ' +
  3293. (ie && browser.version < 9 ? 'class="view"' : '') +
  3294. '>' +
  3295. a.getContent(null, null, !0) +
  3296. '</body></html>'
  3297. )
  3298. },
  3299. getPlainTxt: function () {
  3300. var a = new RegExp(domUtils.fillChar, 'g'),
  3301. b = this.body.innerHTML.replace(/[\n\r]/g, '')
  3302. return (
  3303. (b = b
  3304. .replace(/<(p|div)[^>]*>(<br\/?>|&nbsp;)<\/\1>/gi, '\n')
  3305. .replace(/<br\/?>/gi, '\n')
  3306. .replace(/<[^>\/]+>/g, '')
  3307. .replace(/(\n)?<\/([^>]+)>/g, function (a, b, c) {
  3308. return dtd.$block[c] ? '\n' : b ? b : ''
  3309. })),
  3310. b
  3311. .replace(a, '')
  3312. .replace(/\u00a0/g, ' ')
  3313. .replace(/&nbsp;/g, ' ')
  3314. )
  3315. },
  3316. getContentTxt: function () {
  3317. var a = new RegExp(domUtils.fillChar, 'g')
  3318. return this.body[browser.ie ? 'innerText' : 'textContent']
  3319. .replace(a, '')
  3320. .replace(/\u00a0/g, ' ')
  3321. },
  3322. setContent: function (b, c, d) {
  3323. function e(a) {
  3324. return 'DIV' == a.tagName && a.getAttribute('cdata_tag')
  3325. }
  3326. var f = this
  3327. f.fireEvent('beforesetcontent', b)
  3328. var g = UE.htmlparser(b)
  3329. if (
  3330. (f.filterInputRule(g),
  3331. (b = g.toHtml()),
  3332. (f.body.innerHTML = (c ? f.body.innerHTML : '') + b),
  3333. 'p' == f.options.enterTag)
  3334. ) {
  3335. var h,
  3336. i = this.body.firstChild
  3337. if (
  3338. !i ||
  3339. (1 == i.nodeType &&
  3340. (dtd.$cdata[i.tagName] || e(i) || domUtils.isCustomeNode(i)) &&
  3341. i === this.body.lastChild)
  3342. )
  3343. this.body.innerHTML =
  3344. '<p>' +
  3345. (browser.ie ? '&nbsp;' : '<br/>') +
  3346. '</p>' +
  3347. this.body.innerHTML
  3348. else
  3349. for (var j = f.document.createElement('p'); i; ) {
  3350. for (
  3351. ;
  3352. i &&
  3353. (3 == i.nodeType ||
  3354. (1 == i.nodeType &&
  3355. dtd.p[i.tagName] &&
  3356. !dtd.$cdata[i.tagName]));
  3357. )
  3358. (h = i.nextSibling), j.appendChild(i), (i = h)
  3359. if (j.firstChild) {
  3360. if (!i) {
  3361. f.body.appendChild(j)
  3362. break
  3363. }
  3364. i.parentNode.insertBefore(j, i),
  3365. (j = f.document.createElement('p'))
  3366. }
  3367. i = i.nextSibling
  3368. }
  3369. }
  3370. f.fireEvent('aftersetcontent'),
  3371. f.fireEvent('contentchange'),
  3372. !d && f._selectionChange(),
  3373. (f._bakRange = f._bakIERange = f._bakNativeRange = null)
  3374. var k
  3375. browser.gecko &&
  3376. (k = this.selection.getNative()) &&
  3377. k.removeAllRanges(),
  3378. f.options.autoSyncData && f.form && a(f.form, f)
  3379. },
  3380. focus: function (a) {
  3381. try {
  3382. var b = this,
  3383. c = b.selection.getRange()
  3384. if (a) {
  3385. var d = b.body.lastChild
  3386. d &&
  3387. 1 == d.nodeType &&
  3388. !dtd.$empty[d.tagName] &&
  3389. (domUtils.isEmptyBlock(d)
  3390. ? c.setStartAtFirst(d)
  3391. : c.setStartAtLast(d),
  3392. c.collapse(!0)),
  3393. c.setCursor(!0)
  3394. } else {
  3395. if (
  3396. !c.collapsed &&
  3397. domUtils.isBody(c.startContainer) &&
  3398. 0 == c.startOffset
  3399. ) {
  3400. var d = b.body.firstChild
  3401. d &&
  3402. 1 == d.nodeType &&
  3403. !dtd.$empty[d.tagName] &&
  3404. c.setStartAtFirst(d).collapse(!0)
  3405. }
  3406. c.select(!0)
  3407. }
  3408. this.fireEvent('focus selectionchange')
  3409. } catch (e) {}
  3410. },
  3411. isFocus: function () {
  3412. return this.selection.isFocus()
  3413. },
  3414. blur: function () {
  3415. var a = this.selection.getNative()
  3416. if (a.empty && browser.ie) {
  3417. var b = document.body.createTextRange()
  3418. b.moveToElementText(document.body),
  3419. b.collapse(!0),
  3420. b.select(),
  3421. a.empty()
  3422. } else a.removeAllRanges()
  3423. },
  3424. _initEvents: function () {
  3425. var a = this,
  3426. b = a.document,
  3427. c = a.window
  3428. ;(a._proxyDomEvent = utils.bind(a._proxyDomEvent, a)),
  3429. domUtils.on(
  3430. b,
  3431. [
  3432. 'click',
  3433. 'contextmenu',
  3434. 'mousedown',
  3435. 'keydown',
  3436. 'keyup',
  3437. 'keypress',
  3438. 'mouseup',
  3439. 'mouseover',
  3440. 'mouseout',
  3441. 'selectstart'
  3442. ],
  3443. a._proxyDomEvent
  3444. ),
  3445. domUtils.on(c, ['focus', 'blur'], a._proxyDomEvent),
  3446. domUtils.on(a.body, 'drop', function (b) {
  3447. browser.gecko && b.stopPropagation && b.stopPropagation(),
  3448. a.fireEvent('contentchange')
  3449. }),
  3450. domUtils.on(b, ['mouseup', 'keydown'], function (b) {
  3451. ;('keydown' == b.type &&
  3452. (b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)) ||
  3453. (2 != b.button && a._selectionChange(250, b))
  3454. })
  3455. },
  3456. _proxyDomEvent: function (a) {
  3457. return (
  3458. this.fireEvent(
  3459. 'before' + a.type.replace(/^on/, '').toLowerCase()
  3460. ) !== !1 &&
  3461. this.fireEvent(a.type.replace(/^on/, ''), a) !== !1 &&
  3462. this.fireEvent('after' + a.type.replace(/^on/, '').toLowerCase())
  3463. )
  3464. },
  3465. _selectionChange: function (a, b) {
  3466. var c,
  3467. e,
  3468. f = this,
  3469. g = !1
  3470. if (browser.ie && browser.version < 9 && b && 'mouseup' == b.type) {
  3471. var h = this.selection.getRange()
  3472. h.collapsed || ((g = !0), (c = b.clientX), (e = b.clientY))
  3473. }
  3474. clearTimeout(d),
  3475. (d = setTimeout(function () {
  3476. if (f.selection && f.selection.getNative()) {
  3477. var a
  3478. if (g && 'None' == f.selection.getNative().type) {
  3479. a = f.document.body.createTextRange()
  3480. try {
  3481. a.moveToPoint(c, e)
  3482. } catch (d) {
  3483. a = null
  3484. }
  3485. }
  3486. var h
  3487. a &&
  3488. ((h = f.selection.getIERange),
  3489. (f.selection.getIERange = function () {
  3490. return a
  3491. })),
  3492. f.selection.cache(),
  3493. h && (f.selection.getIERange = h),
  3494. f.selection._cachedRange &&
  3495. f.selection._cachedStartElement &&
  3496. (f.fireEvent('beforeselectionchange'),
  3497. f.fireEvent('selectionchange', !!b),
  3498. f.fireEvent('afterselectionchange'),
  3499. f.selection.clear())
  3500. }
  3501. }, a || 50))
  3502. },
  3503. _callCmdFn: function (a, b) {
  3504. var c,
  3505. d,
  3506. e = b[0].toLowerCase()
  3507. return (
  3508. (c = this.commands[e] || UE.commands[e]),
  3509. (d = c && c[a]),
  3510. (c && d) || 'queryCommandState' != a
  3511. ? d
  3512. ? d.apply(this, b)
  3513. : void 0
  3514. : 0
  3515. )
  3516. },
  3517. execCommand: function (a) {
  3518. a = a.toLowerCase()
  3519. var b,
  3520. c = this,
  3521. d = c.commands[a] || UE.commands[a]
  3522. return d && d.execCommand
  3523. ? (d.notNeedUndo || c.__hasEnterExecCommand
  3524. ? ((b = this._callCmdFn('execCommand', arguments)),
  3525. !c.__hasEnterExecCommand &&
  3526. !d.ignoreContentChange &&
  3527. !c._ignoreContentChange &&
  3528. c.fireEvent('contentchange'))
  3529. : ((c.__hasEnterExecCommand = !0),
  3530. c.queryCommandState.apply(c, arguments) != -1 &&
  3531. (c.fireEvent('saveScene'),
  3532. c.fireEvent.apply(
  3533. c,
  3534. ['beforeexeccommand', a].concat(arguments)
  3535. ),
  3536. (b = this._callCmdFn('execCommand', arguments)),
  3537. c.fireEvent.apply(
  3538. c,
  3539. ['afterexeccommand', a].concat(arguments)
  3540. ),
  3541. c.fireEvent('saveScene')),
  3542. (c.__hasEnterExecCommand = !1)),
  3543. !c.__hasEnterExecCommand &&
  3544. !d.ignoreContentChange &&
  3545. !c._ignoreContentChange &&
  3546. c._selectionChange(),
  3547. b)
  3548. : null
  3549. },
  3550. queryCommandState: function (a) {
  3551. return this._callCmdFn('queryCommandState', arguments)
  3552. },
  3553. queryCommandValue: function (a) {
  3554. return this._callCmdFn('queryCommandValue', arguments)
  3555. },
  3556. hasContents: function (a) {
  3557. if (a)
  3558. for (var b, c = 0; (b = a[c++]); )
  3559. if (this.document.getElementsByTagName(b).length > 0) return !0
  3560. if (!domUtils.isEmptyBlock(this.body)) return !0
  3561. for (a = ['div'], c = 0; (b = a[c++]); )
  3562. for (
  3563. var d, e = domUtils.getElementsByTagName(this.document, b), f = 0;
  3564. (d = e[f++]);
  3565. )
  3566. if (domUtils.isCustomeNode(d)) return !0
  3567. return !1
  3568. },
  3569. reset: function () {
  3570. this.fireEvent('reset')
  3571. },
  3572. setEnabled: function () {
  3573. var a,
  3574. b = this
  3575. if ('false' == b.body.contentEditable) {
  3576. ;(b.body.contentEditable = !0), (a = b.selection.getRange())
  3577. try {
  3578. a.moveToBookmark(b.lastBk), delete b.lastBk
  3579. } catch (c) {
  3580. a.setStartAtFirst(b.body).collapse(!0)
  3581. }
  3582. a.select(!0),
  3583. b.bkqueryCommandState &&
  3584. ((b.queryCommandState = b.bkqueryCommandState),
  3585. delete b.bkqueryCommandState),
  3586. b.bkqueryCommandValue &&
  3587. ((b.queryCommandValue = b.bkqueryCommandValue),
  3588. delete b.bkqueryCommandValue),
  3589. b.fireEvent('selectionchange')
  3590. }
  3591. },
  3592. enable: function () {
  3593. return this.setEnabled()
  3594. },
  3595. setDisabled: function (a) {
  3596. var b = this
  3597. ;(a = a ? (utils.isArray(a) ? a : [a]) : []),
  3598. 'true' == b.body.contentEditable &&
  3599. (b.lastBk ||
  3600. (b.lastBk = b.selection.getRange().createBookmark(!0)),
  3601. (b.body.contentEditable = !1),
  3602. (b.bkqueryCommandState = b.queryCommandState),
  3603. (b.bkqueryCommandValue = b.queryCommandValue),
  3604. (b.queryCommandState = function (c) {
  3605. return utils.indexOf(a, c) != -1
  3606. ? b.bkqueryCommandState.apply(b, arguments)
  3607. : -1
  3608. }),
  3609. (b.queryCommandValue = function (c) {
  3610. return utils.indexOf(a, c) != -1
  3611. ? b.bkqueryCommandValue.apply(b, arguments)
  3612. : null
  3613. }),
  3614. b.fireEvent('selectionchange'))
  3615. },
  3616. disable: function (a) {
  3617. return this.setDisabled(a)
  3618. },
  3619. _setDefaultContent: (function () {
  3620. function a() {
  3621. var b = this
  3622. b.document.getElementById('initContent') &&
  3623. ((b.body.innerHTML = '<p>' + (ie ? '' : '<br/>') + '</p>'),
  3624. b.removeListener('firstBeforeExecCommand focus', a),
  3625. setTimeout(function () {
  3626. b.focus(), b._selectionChange()
  3627. }, 0))
  3628. }
  3629. return function (b) {
  3630. var c = this
  3631. ;(c.body.innerHTML = '<p id="initContent">' + b + '</p>'),
  3632. c.addListener('firstBeforeExecCommand focus', a)
  3633. }
  3634. })(),
  3635. setShow: function () {
  3636. var a = this,
  3637. b = a.selection.getRange()
  3638. if ('none' == a.container.style.display) {
  3639. try {
  3640. b.moveToBookmark(a.lastBk), delete a.lastBk
  3641. } catch (c) {
  3642. b.setStartAtFirst(a.body).collapse(!0)
  3643. }
  3644. setTimeout(function () {
  3645. b.select(!0)
  3646. }, 100),
  3647. (a.container.style.display = '')
  3648. }
  3649. },
  3650. show: function () {
  3651. return this.setShow()
  3652. },
  3653. setHide: function () {
  3654. var a = this
  3655. a.lastBk || (a.lastBk = a.selection.getRange().createBookmark(!0)),
  3656. (a.container.style.display = 'none')
  3657. },
  3658. hide: function () {
  3659. return this.setHide()
  3660. },
  3661. getLang: function (a) {
  3662. if (!this.options) return ''
  3663. var b = UE.I18N[this.options.lang]
  3664. if (!b) throw Error('not import language file')
  3665. a = (a || '').split('.')
  3666. for (var c, d = 0; (c = a[d++]) && ((b = b[c]), b); );
  3667. return b
  3668. },
  3669. getContentLength: function (a, b) {
  3670. var c = this.getContent(!1, !1, !0).length
  3671. if (a) {
  3672. ;(b = (b || []).concat(['hr', 'img', 'iframe'])),
  3673. (c = this.getContentTxt().replace(/[\t\r\n]+/g, '').length)
  3674. for (var d, e = 0; (d = b[e++]); )
  3675. c += this.document.getElementsByTagName(d).length
  3676. }
  3677. return c
  3678. },
  3679. addInputRule: function (a) {
  3680. this.inputRules.push(a)
  3681. },
  3682. filterInputRule: function (a) {
  3683. for (var b, c = 0; (b = this.inputRules[c++]); ) b.call(this, a)
  3684. },
  3685. addOutputRule: function (a) {
  3686. this.outputRules.push(a)
  3687. },
  3688. filterOutputRule: function (a) {
  3689. for (var b, c = 0; (b = this.outputRules[c++]); ) b.call(this, a)
  3690. },
  3691. getActionUrl: function (a) {
  3692. var b = this.getOpt(a) || a,
  3693. c = this.getOpt('imageUrl'),
  3694. d = this.getOpt('serverUrl')
  3695. return (
  3696. !d &&
  3697. c &&
  3698. (d = c.replace(/^(.*[\/]).+([\.].+)$/, '$1controller$2')),
  3699. d
  3700. ? ((d =
  3701. d +
  3702. (d.indexOf('?') == -1 ? '?' : '&') +
  3703. 'action=' +
  3704. (b || '')),
  3705. utils.formatUrl(d))
  3706. : ''
  3707. )
  3708. }
  3709. }),
  3710. utils.inherits(f, EventBase)
  3711. })(),
  3712. (UE.Editor.defaultOptions = function (a) {
  3713. var b = a.options.UEDITOR_HOME_URL
  3714. return {
  3715. isShow: !0,
  3716. initialContent: '',
  3717. initialStyle: '',
  3718. autoClearinitialContent: !1,
  3719. iframeCssUrl: b + 'themes/iframe.css',
  3720. textarea: 'editorValue',
  3721. focus: !1,
  3722. focusInEnd: !0,
  3723. autoClearEmptyNode: !0,
  3724. fullscreen: !1,
  3725. readonly: !1,
  3726. zIndex: 999,
  3727. imagePopup: !0,
  3728. enterTag: 'p',
  3729. customDomain: !1,
  3730. lang: 'zh-cn',
  3731. langPath: b + 'lang/',
  3732. theme: 'default',
  3733. themePath: b + 'themes/',
  3734. allHtmlEnabled: !1,
  3735. scaleEnabled: !1,
  3736. tableNativeEditInFF: !1,
  3737. autoSyncData: !0,
  3738. fileNameFormat: '{time}{rand:6}'
  3739. }
  3740. }),
  3741. (function () {
  3742. ;(UE.Editor.prototype.loadServerConfig = function () {
  3743. function showErrorMsg(a) {
  3744. console && console.error(a)
  3745. }
  3746. var me = this
  3747. setTimeout(function () {
  3748. try {
  3749. me.options.imageUrl &&
  3750. me.setOpt(
  3751. 'serverUrl',
  3752. me.options.imageUrl.replace(
  3753. /^(.*[\/]).+([\.].+)$/,
  3754. '$1controller$2'
  3755. )
  3756. )
  3757. var configUrl = me.getActionUrl('config'),
  3758. isJsonp = utils.isCrossDomainUrl(configUrl)
  3759. ;(me._serverConfigLoaded = !1),
  3760. configUrl &&
  3761. UE.ajax.request(configUrl, {
  3762. method: 'GET',
  3763. dataType: isJsonp ? 'jsonp' : '',
  3764. onsuccess: function (r) {
  3765. try {
  3766. var config = isJsonp
  3767. ? r
  3768. : eval('(' + r.responseText + ')')
  3769. utils.extend(me.options, config),
  3770. me.fireEvent('serverConfigLoaded'),
  3771. (me._serverConfigLoaded = !0)
  3772. } catch (e) {
  3773. showErrorMsg(me.getLang('loadconfigFormatError'))
  3774. }
  3775. },
  3776. onerror: function () {
  3777. showErrorMsg(me.getLang('loadconfigHttpError'))
  3778. }
  3779. })
  3780. } catch (e) {
  3781. showErrorMsg(me.getLang('loadconfigError'))
  3782. }
  3783. })
  3784. }),
  3785. (UE.Editor.prototype.isServerConfigLoaded = function () {
  3786. var a = this
  3787. return a._serverConfigLoaded || !1
  3788. }),
  3789. (UE.Editor.prototype.afterConfigReady = function (a) {
  3790. if (a && utils.isFunction(a)) {
  3791. var b = this,
  3792. c = function () {
  3793. a.apply(b, arguments), b.removeListener('serverConfigLoaded', c)
  3794. }
  3795. b.isServerConfigLoaded()
  3796. ? a.call(b, 'serverConfigLoaded')
  3797. : b.addListener('serverConfigLoaded', c)
  3798. }
  3799. })
  3800. })(),
  3801. (UE.ajax = (function () {
  3802. function a(a) {
  3803. var b = []
  3804. for (var c in a)
  3805. if (
  3806. 'method' != c &&
  3807. 'timeout' != c &&
  3808. 'async' != c &&
  3809. 'dataType' != c &&
  3810. 'callback' != c &&
  3811. void 0 != a[c] &&
  3812. null != a[c]
  3813. )
  3814. if (
  3815. 'function' != (typeof a[c]).toLowerCase() &&
  3816. 'object' != (typeof a[c]).toLowerCase()
  3817. )
  3818. b.push(encodeURIComponent(c) + '=' + encodeURIComponent(a[c]))
  3819. else if (utils.isArray(a[c]))
  3820. for (var d = 0; d < a[c].length; d++)
  3821. b.push(
  3822. encodeURIComponent(c) + '[]=' + encodeURIComponent(a[c][d])
  3823. )
  3824. return b.join('&')
  3825. }
  3826. function b(b, c) {
  3827. var d = f(),
  3828. e = !1,
  3829. g = {
  3830. method: 'POST',
  3831. timeout: 5e3,
  3832. async: !0,
  3833. data: {},
  3834. onsuccess: function () {},
  3835. onerror: function () {}
  3836. }
  3837. if (('object' == typeof b && ((c = b), (b = c.url)), d && b)) {
  3838. var h = c ? utils.extend(g, c) : g,
  3839. i = a(h)
  3840. utils.isEmptyObject(h.data) || (i += (i ? '&' : '') + a(h.data))
  3841. var j = setTimeout(function () {
  3842. 4 != d.readyState && ((e = !0), d.abort(), clearTimeout(j))
  3843. }, h.timeout),
  3844. k = h.method.toUpperCase(),
  3845. l =
  3846. b +
  3847. (b.indexOf('?') == -1 ? '?' : '&') +
  3848. ('POST' == k ? '' : i + '&noCache=' + +new Date())
  3849. d.open(k, l, h.async),
  3850. (d.onreadystatechange = function () {
  3851. 4 == d.readyState &&
  3852. (e || 200 != d.status ? h.onerror(d) : h.onsuccess(d))
  3853. }),
  3854. 'POST' == k
  3855. ? (d.setRequestHeader(
  3856. 'Content-Type',
  3857. 'application/x-www-form-urlencoded'
  3858. ),
  3859. d.send(i))
  3860. : d.send(null)
  3861. }
  3862. }
  3863. function c(b, c) {
  3864. function d(a, b, c) {
  3865. a.setAttribute('type', 'text/javascript'),
  3866. a.setAttribute('defer', 'defer'),
  3867. c && a.setAttribute('charset', c),
  3868. a.setAttribute('src', b),
  3869. document.getElementsByTagName('head')[0].appendChild(a)
  3870. }
  3871. function e(a) {
  3872. return function () {
  3873. try {
  3874. if (a) k.onerror && k.onerror()
  3875. else
  3876. try {
  3877. clearTimeout(g), i.apply(window, arguments)
  3878. } catch (b) {}
  3879. } catch (c) {
  3880. k.onerror && k.onerror.call(window, c)
  3881. } finally {
  3882. k.oncomplete && k.oncomplete.apply(window, arguments),
  3883. j.parentNode && j.parentNode.removeChild(j),
  3884. (window[f] = null)
  3885. try {
  3886. delete window[f]
  3887. } catch (b) {}
  3888. }
  3889. }
  3890. }
  3891. var f,
  3892. g,
  3893. h,
  3894. i = c.onsuccess || function () {},
  3895. j = document.createElement('SCRIPT'),
  3896. k = c || {},
  3897. l = k.charset,
  3898. m = k.jsonp || 'callback',
  3899. n = k.timeOut || 0,
  3900. o = new RegExp('(\\?|&)' + m + '=([^&]*)')
  3901. utils.isFunction(i)
  3902. ? ((f =
  3903. 'bd__editor__' +
  3904. Math.floor(2147483648 * Math.random()).toString(36)),
  3905. (window[f] = e(0)))
  3906. : utils.isString(i)
  3907. ? (f = i)
  3908. : (h = o.exec(b)) && (f = h[2]),
  3909. (b = b.replace(o, '$1' + m + '=' + f)),
  3910. b.search(o) < 0 &&
  3911. (b += (b.indexOf('?') < 0 ? '?' : '&') + m + '=' + f)
  3912. var p = a(c)
  3913. utils.isEmptyObject(c.data) || (p += (p ? '&' : '') + a(c.data)),
  3914. p && (b = b.replace(/\?/, '?' + p + '&')),
  3915. (j.onerror = e(1)),
  3916. n && (g = setTimeout(e(1), n)),
  3917. d(j, b, l)
  3918. }
  3919. var d = 'XMLHttpRequest()'
  3920. try {
  3921. new ActiveXObject('Msxml2.XMLHTTP'),
  3922. (d = "ActiveXObject('Msxml2.XMLHTTP')")
  3923. } catch (e) {
  3924. try {
  3925. new ActiveXObject('Microsoft.XMLHTTP'),
  3926. (d = "ActiveXObject('Microsoft.XMLHTTP')")
  3927. } catch (e) {}
  3928. }
  3929. var f = new Function('return new ' + d)
  3930. return {
  3931. request: function (a, d) {
  3932. d && 'jsonp' == d.dataType ? c(a, d) : b(a, d)
  3933. },
  3934. getJSONP: function (a, b, d) {
  3935. var e = { data: b, oncomplete: d }
  3936. c(a, e)
  3937. }
  3938. }
  3939. })())
  3940. var filterWord = (UE.filterWord = (function () {
  3941. function a(a) {
  3942. return /(class="?Mso|style="[^"]*\bmso\-|w:WordDocument|<(v|o):|lang=)/gi.test(
  3943. a
  3944. )
  3945. }
  3946. function b(a) {
  3947. return (a = a.replace(/[\d.]+\w+/g, function (a) {
  3948. return utils.transUnitToPx(a)
  3949. }))
  3950. }
  3951. function c(a) {
  3952. return a
  3953. .replace(/[\t\r\n]+/g, ' ')
  3954. .replace(/<!--[\s\S]*?-->/gi, '')
  3955. .replace(/<v:shape [^>]*>[\s\S]*?.<\/v:shape>/gi, function (a) {
  3956. if (browser.opera) return ''
  3957. try {
  3958. if (/Bitmap/i.test(a)) return ''
  3959. var c = a.match(/width:([ \d.]*p[tx])/i)[1],
  3960. d = a.match(/height:([ \d.]*p[tx])/i)[1],
  3961. e = a.match(/src=\s*"([^"]*)"/i)[1]
  3962. return (
  3963. '<img width="' +
  3964. b(c) +
  3965. '" height="' +
  3966. b(d) +
  3967. '" src="' +
  3968. e +
  3969. '" />'
  3970. )
  3971. } catch (f) {
  3972. return ''
  3973. }
  3974. })
  3975. .replace(/<\/?div[^>]*>/g, '')
  3976. .replace(/v:\w+=(["']?)[^'"]+\1/g, '')
  3977. .replace(
  3978. /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|xml|meta|link|style|\w+:\w+)(?=[\s\/>]))[^>]*>/gi,
  3979. ''
  3980. )
  3981. .replace(
  3982. /<p [^>]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,
  3983. '<p><strong>$1</strong></p>'
  3984. )
  3985. .replace(
  3986. /\s+(class|lang|align)\s*=\s*(['"]?)([\w-]+)\2/gi,
  3987. function (a, b, c, d) {
  3988. return 'class' == b && 'MsoListParagraph' == d ? a : ''
  3989. }
  3990. )
  3991. .replace(/<(font|span)[^>]*>(\s*)<\/\1>/gi, function (a, b, c) {
  3992. return c.replace(/[\t\r\n ]+/g, ' ')
  3993. })
  3994. .replace(
  3995. /(<[a-z][^>]*)\sstyle=(["'])([^\2]*?)\2/gi,
  3996. function (a, c, d, e) {
  3997. for (
  3998. var f,
  3999. g = [],
  4000. h = e
  4001. .replace(/^\s+|\s+$/, '')
  4002. .replace(/&#39;/g, "'")
  4003. .replace(/&quot;/gi, "'")
  4004. .replace(/[\d.]+(cm|pt)/g, function (a) {
  4005. return utils.transUnitToPx(a)
  4006. })
  4007. .split(/;\s*/g),
  4008. i = 0;
  4009. (f = h[i]);
  4010. i++
  4011. ) {
  4012. var j,
  4013. k,
  4014. l = f.split(':')
  4015. if (2 == l.length) {
  4016. if (
  4017. ((j = l[0].toLowerCase()),
  4018. (k = l[1].toLowerCase()),
  4019. (/^(background)\w*/.test(j) &&
  4020. 0 == k.replace(/(initial|\s)/g, '').length) ||
  4021. (/^(margin)\w*/.test(j) && /^0\w+$/.test(k)))
  4022. )
  4023. continue
  4024. switch (j) {
  4025. case 'mso-padding-alt':
  4026. case 'mso-padding-top-alt':
  4027. case 'mso-padding-right-alt':
  4028. case 'mso-padding-bottom-alt':
  4029. case 'mso-padding-left-alt':
  4030. case 'mso-margin-alt':
  4031. case 'mso-margin-top-alt':
  4032. case 'mso-margin-right-alt':
  4033. case 'mso-margin-bottom-alt':
  4034. case 'mso-margin-left-alt':
  4035. case 'mso-height':
  4036. case 'mso-width':
  4037. case 'mso-vertical-align-alt':
  4038. ;/<table/.test(c) ||
  4039. (g[i] = j.replace(/^mso-|-alt$/g, '') + ':' + b(k))
  4040. continue
  4041. case 'horiz-align':
  4042. g[i] = 'text-align:' + k
  4043. continue
  4044. case 'vert-align':
  4045. g[i] = 'vertical-align:' + k
  4046. continue
  4047. case 'font-color':
  4048. case 'mso-foreground':
  4049. g[i] = 'color:' + k
  4050. continue
  4051. case 'mso-background':
  4052. case 'mso-highlight':
  4053. g[i] = 'background:' + k
  4054. continue
  4055. case 'mso-default-height':
  4056. g[i] = 'min-height:' + b(k)
  4057. continue
  4058. case 'mso-default-width':
  4059. g[i] = 'min-width:' + b(k)
  4060. continue
  4061. case 'mso-padding-between-alt':
  4062. g[i] = 'border-collapse:separate;border-spacing:' + b(k)
  4063. continue
  4064. case 'text-line-through':
  4065. ;('single' != k && 'double' != k) ||
  4066. (g[i] = 'text-decoration:line-through')
  4067. continue
  4068. case 'mso-zero-height':
  4069. 'yes' == k && (g[i] = 'display:none')
  4070. continue
  4071. case 'margin':
  4072. if (!/[1-9]/.test(k)) continue
  4073. }
  4074. if (
  4075. /^(mso|column|font-emph|lang|layout|line-break|list-image|nav|panose|punct|row|ruby|sep|size|src|tab-|table-border|text-(?:decor|trans)|top-bar|version|vnd|word-break)/.test(
  4076. j
  4077. ) ||
  4078. (/text\-indent|padding|margin/.test(j) && /\-[\d.]+/.test(k))
  4079. )
  4080. continue
  4081. g[i] = j + ':' + l[1]
  4082. }
  4083. }
  4084. return (
  4085. c +
  4086. (g.length
  4087. ? ' style="' + g.join(';').replace(/;{2,}/g, ';') + '"'
  4088. : '')
  4089. )
  4090. }
  4091. )
  4092. }
  4093. return function (b) {
  4094. return a(b) ? c(b) : b
  4095. }
  4096. })())
  4097. !(function () {
  4098. function a(a, b, c) {
  4099. return a.push(n), b + (c ? 1 : -1)
  4100. }
  4101. function b(a, b) {
  4102. for (var c = 0; c < b; c++) a.push(m)
  4103. }
  4104. function c(g, h, i, j) {
  4105. switch (g.type) {
  4106. case 'root':
  4107. for (var k, l = 0; (k = g.children[l++]); )
  4108. i &&
  4109. 'element' == k.type &&
  4110. !dtd.$inlineWithA[k.tagName] &&
  4111. l > 1 &&
  4112. (a(h, j, !0), b(h, j)),
  4113. c(k, h, i, j)
  4114. break
  4115. case 'text':
  4116. d(g, h)
  4117. break
  4118. case 'element':
  4119. e(g, h, i, j)
  4120. break
  4121. case 'comment':
  4122. f(g, h, i)
  4123. }
  4124. return h
  4125. }
  4126. function d(a, b) {
  4127. 'pre' == a.parentNode.tagName
  4128. ? b.push(a.data)
  4129. : b.push(
  4130. l[a.parentNode.tagName]
  4131. ? utils.html(a.data)
  4132. : a.data.replace(/[ ]{2}/g, ' &nbsp;')
  4133. )
  4134. }
  4135. function e(d, e, f, g) {
  4136. var h = ''
  4137. if (d.attrs) {
  4138. h = []
  4139. var i = d.attrs
  4140. for (var j in i)
  4141. h.push(
  4142. j +
  4143. (void 0 !== i[j]
  4144. ? '="' +
  4145. (k[j]
  4146. ? utils.html(i[j]).replace(/["]/g, function (a) {
  4147. return '&quot;'
  4148. })
  4149. : utils.unhtml(i[j])) +
  4150. '"'
  4151. : '')
  4152. )
  4153. h = h.join(' ')
  4154. }
  4155. if (
  4156. (e.push(
  4157. '<' +
  4158. d.tagName +
  4159. (h ? ' ' + h : '') +
  4160. (dtd.$empty[d.tagName] ? '/' : '') +
  4161. '>'
  4162. ),
  4163. f &&
  4164. !dtd.$inlineWithA[d.tagName] &&
  4165. 'pre' != d.tagName &&
  4166. d.children &&
  4167. d.children.length &&
  4168. ((g = a(e, g, !0)), b(e, g)),
  4169. d.children && d.children.length)
  4170. )
  4171. for (var l, m = 0; (l = d.children[m++]); )
  4172. f &&
  4173. 'element' == l.type &&
  4174. !dtd.$inlineWithA[l.tagName] &&
  4175. m > 1 &&
  4176. (a(e, g), b(e, g)),
  4177. c(l, e, f, g)
  4178. dtd.$empty[d.tagName] ||
  4179. (f &&
  4180. !dtd.$inlineWithA[d.tagName] &&
  4181. 'pre' != d.tagName &&
  4182. d.children &&
  4183. d.children.length &&
  4184. ((g = a(e, g)), b(e, g)),
  4185. e.push('</' + d.tagName + '>'))
  4186. }
  4187. function f(a, b) {
  4188. b.push('<!--' + a.data + '-->')
  4189. }
  4190. function g(a, b) {
  4191. var c
  4192. if ('element' == a.type && a.getAttr('id') == b) return a
  4193. if (a.children && a.children.length)
  4194. for (var d, e = 0; (d = a.children[e++]); ) if ((c = g(d, b))) return c
  4195. }
  4196. function h(a, b, c) {
  4197. if (
  4198. ('element' == a.type && a.tagName == b && c.push(a),
  4199. a.children && a.children.length)
  4200. )
  4201. for (var d, e = 0; (d = a.children[e++]); ) h(d, b, c)
  4202. }
  4203. function i(a, b) {
  4204. if (a.children && a.children.length)
  4205. for (var c, d = 0; (c = a.children[d]); )
  4206. i(c, b),
  4207. c.parentNode &&
  4208. (c.children && c.children.length && b(c), c.parentNode && d++)
  4209. else b(a)
  4210. }
  4211. var j = (UE.uNode = function (a) {
  4212. ;(this.type = a.type),
  4213. (this.data = a.data),
  4214. (this.tagName = a.tagName),
  4215. (this.parentNode = a.parentNode),
  4216. (this.attrs = a.attrs || {}),
  4217. (this.children = a.children)
  4218. }),
  4219. k = { href: 1, src: 1, _src: 1, _href: 1, cdata_data: 1 },
  4220. l = { style: 1, script: 1 },
  4221. m = ' ',
  4222. n = '\n'
  4223. ;(j.createElement = function (a) {
  4224. return /[<>]/.test(a)
  4225. ? UE.htmlparser(a).children[0]
  4226. : new j({ type: 'element', children: [], tagName: a })
  4227. }),
  4228. (j.createText = function (a, b) {
  4229. return new UE.uNode({
  4230. type: 'text',
  4231. data: b ? a : utils.unhtml(a || '')
  4232. })
  4233. }),
  4234. (j.prototype = {
  4235. toHtml: function (a) {
  4236. var b = []
  4237. return c(this, b, a, 0), b.join('')
  4238. },
  4239. innerHTML: function (a) {
  4240. if ('element' != this.type || dtd.$empty[this.tagName]) return this
  4241. if (utils.isString(a)) {
  4242. if (this.children)
  4243. for (var b, c = 0; (b = this.children[c++]); ) b.parentNode = null
  4244. this.children = []
  4245. for (var b, d = UE.htmlparser(a), c = 0; (b = d.children[c++]); )
  4246. this.children.push(b), (b.parentNode = this)
  4247. return this
  4248. }
  4249. var d = new UE.uNode({ type: 'root', children: this.children })
  4250. return d.toHtml()
  4251. },
  4252. innerText: function (a, b) {
  4253. if ('element' != this.type || dtd.$empty[this.tagName]) return this
  4254. if (a) {
  4255. if (this.children)
  4256. for (var c, d = 0; (c = this.children[d++]); ) c.parentNode = null
  4257. return (
  4258. (this.children = []), this.appendChild(j.createText(a, b)), this
  4259. )
  4260. }
  4261. return this.toHtml().replace(/<[^>]+>/g, '')
  4262. },
  4263. getData: function () {
  4264. return 'element' == this.type ? '' : this.data
  4265. },
  4266. firstChild: function () {
  4267. return this.children ? this.children[0] : null
  4268. },
  4269. lastChild: function () {
  4270. return this.children ? this.children[this.children.length - 1] : null
  4271. },
  4272. previousSibling: function () {
  4273. for (var a, b = this.parentNode, c = 0; (a = b.children[c]); c++)
  4274. if (a === this) return 0 == c ? null : b.children[c - 1]
  4275. },
  4276. nextSibling: function () {
  4277. for (var a, b = this.parentNode, c = 0; (a = b.children[c++]); )
  4278. if (a === this) return b.children[c]
  4279. },
  4280. replaceChild: function (a, b) {
  4281. if (this.children) {
  4282. a.parentNode && a.parentNode.removeChild(a)
  4283. for (var c, d = 0; (c = this.children[d]); d++)
  4284. if (c === b)
  4285. return (
  4286. this.children.splice(d, 1, a),
  4287. (b.parentNode = null),
  4288. (a.parentNode = this),
  4289. a
  4290. )
  4291. }
  4292. },
  4293. appendChild: function (a) {
  4294. if (
  4295. 'root' == this.type ||
  4296. ('element' == this.type && !dtd.$empty[this.tagName])
  4297. ) {
  4298. this.children || (this.children = []),
  4299. a.parentNode && a.parentNode.removeChild(a)
  4300. for (var b, c = 0; (b = this.children[c]); c++)
  4301. if (b === a) {
  4302. this.children.splice(c, 1)
  4303. break
  4304. }
  4305. return this.children.push(a), (a.parentNode = this), a
  4306. }
  4307. },
  4308. insertBefore: function (a, b) {
  4309. if (this.children) {
  4310. a.parentNode && a.parentNode.removeChild(a)
  4311. for (var c, d = 0; (c = this.children[d]); d++)
  4312. if (c === b)
  4313. return this.children.splice(d, 0, a), (a.parentNode = this), a
  4314. }
  4315. },
  4316. insertAfter: function (a, b) {
  4317. if (this.children) {
  4318. a.parentNode && a.parentNode.removeChild(a)
  4319. for (var c, d = 0; (c = this.children[d]); d++)
  4320. if (c === b)
  4321. return (
  4322. this.children.splice(d + 1, 0, a), (a.parentNode = this), a
  4323. )
  4324. }
  4325. },
  4326. removeChild: function (a, b) {
  4327. if (this.children)
  4328. for (var c, d = 0; (c = this.children[d]); d++)
  4329. if (c === a) {
  4330. if (
  4331. (this.children.splice(d, 1),
  4332. (c.parentNode = null),
  4333. b && c.children && c.children.length)
  4334. )
  4335. for (var e, f = 0; (e = c.children[f]); f++)
  4336. this.children.splice(d + f, 0, e), (e.parentNode = this)
  4337. return c
  4338. }
  4339. },
  4340. getAttr: function (a) {
  4341. return this.attrs && this.attrs[a.toLowerCase()]
  4342. },
  4343. setAttr: function (a, b) {
  4344. if (!a) return void delete this.attrs
  4345. if ((this.attrs || (this.attrs = {}), utils.isObject(a)))
  4346. for (var c in a)
  4347. a[c] ? (this.attrs[c.toLowerCase()] = a[c]) : delete this.attrs[c]
  4348. else b ? (this.attrs[a.toLowerCase()] = b) : delete this.attrs[a]
  4349. },
  4350. getIndex: function () {
  4351. for (var a, b = this.parentNode, c = 0; (a = b.children[c]); c++)
  4352. if (a === this) return c
  4353. return -1
  4354. },
  4355. getNodeById: function (a) {
  4356. var b
  4357. if (this.children && this.children.length)
  4358. for (var c, d = 0; (c = this.children[d++]); )
  4359. if ((b = g(c, a))) return b
  4360. },
  4361. getNodesByTagName: function (a) {
  4362. a = utils
  4363. .trim(a)
  4364. .replace(/[ ]{2,}/g, ' ')
  4365. .split(' ')
  4366. var b = [],
  4367. c = this
  4368. return (
  4369. utils.each(a, function (a) {
  4370. if (c.children && c.children.length)
  4371. for (var d, e = 0; (d = c.children[e++]); ) h(d, a, b)
  4372. }),
  4373. b
  4374. )
  4375. },
  4376. getStyle: function (a) {
  4377. var b = this.getAttr('style')
  4378. if (!b) return ''
  4379. var c = new RegExp('(^|;)\\s*' + a + ':([^;]+)', 'i'),
  4380. d = b.match(c)
  4381. return d && d[0] ? d[2] : ''
  4382. },
  4383. setStyle: function (a, b) {
  4384. function c(a, b) {
  4385. var c = new RegExp('(^|;)\\s*' + a + ':([^;]+;?)', 'gi')
  4386. ;(d = d.replace(c, '$1')),
  4387. b && (d = a + ':' + utils.unhtml(b) + ';' + d)
  4388. }
  4389. var d = this.getAttr('style')
  4390. if ((d || (d = ''), utils.isObject(a))) for (var e in a) c(e, a[e])
  4391. else c(a, b)
  4392. this.setAttr('style', utils.trim(d))
  4393. },
  4394. traversal: function (a) {
  4395. return this.children && this.children.length && i(this, a), this
  4396. }
  4397. })
  4398. })()
  4399. var htmlparser = (UE.htmlparser = function (a, b) {
  4400. function c(a, b) {
  4401. if (m[a.tagName]) {
  4402. var c = k.createElement(m[a.tagName])
  4403. a.appendChild(c), c.appendChild(k.createText(b)), (a = c)
  4404. } else a.appendChild(k.createText(b))
  4405. }
  4406. function d(a, b, c) {
  4407. var e
  4408. if ((e = l[b])) {
  4409. for (var f, h = a; 'root' != h.type; ) {
  4410. if (
  4411. utils.isArray(e)
  4412. ? utils.indexOf(e, h.tagName) != -1
  4413. : e == h.tagName
  4414. ) {
  4415. ;(a = h), (f = !0)
  4416. break
  4417. }
  4418. h = h.parentNode
  4419. }
  4420. f || (a = d(a, utils.isArray(e) ? e[0] : e))
  4421. }
  4422. var i = new k({
  4423. parentNode: a,
  4424. type: 'element',
  4425. tagName: b.toLowerCase(),
  4426. children: dtd.$empty[b] ? null : []
  4427. })
  4428. if (c) {
  4429. for (var m, n = {}; (m = g.exec(c)); )
  4430. n[m[1].toLowerCase()] = j[m[1].toLowerCase()]
  4431. ? m[2] || m[3] || m[4]
  4432. : utils.unhtml(m[2] || m[3] || m[4])
  4433. i.attrs = n
  4434. }
  4435. return a.children.push(i), dtd.$empty[b] ? a : i
  4436. }
  4437. function e(a, b) {
  4438. a.children.push(new k({ type: 'comment', data: b, parentNode: a }))
  4439. }
  4440. var f =
  4441. /<(?:(?:\/([^>]+)>)|(?:!--([\S|\s]*?)-->)|(?:([^\s\/<>]+)\s*((?:(?:"[^"]*")|(?:'[^']*')|[^"'<>])*)\/?>))/g,
  4442. g =
  4443. /([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,
  4444. h = {
  4445. b: 1,
  4446. code: 1,
  4447. i: 1,
  4448. u: 1,
  4449. strike: 1,
  4450. s: 1,
  4451. tt: 1,
  4452. strong: 1,
  4453. q: 1,
  4454. samp: 1,
  4455. em: 1,
  4456. span: 1,
  4457. sub: 1,
  4458. img: 1,
  4459. sup: 1,
  4460. font: 1,
  4461. big: 1,
  4462. small: 1,
  4463. iframe: 1,
  4464. a: 1,
  4465. br: 1,
  4466. pre: 1
  4467. }
  4468. ;(a = a.replace(new RegExp(domUtils.fillChar, 'g'), '')),
  4469. b ||
  4470. (a = a.replace(
  4471. new RegExp(
  4472. '[\\r\\t\\n' +
  4473. (b ? '' : ' ') +
  4474. ']*</?(\\w+)\\s*(?:[^>]*)>[\\r\\t\\n' +
  4475. (b ? '' : ' ') +
  4476. ']*',
  4477. 'g'
  4478. ),
  4479. function (a, c) {
  4480. return c && h[c.toLowerCase()]
  4481. ? a.replace(/(^[\n\r]+)|([\n\r]+$)/g, '')
  4482. : a
  4483. .replace(new RegExp('^[\\r\\n' + (b ? '' : ' ') + ']+'), '')
  4484. .replace(new RegExp('[\\r\\n' + (b ? '' : ' ') + ']+$'), '')
  4485. }
  4486. ))
  4487. for (
  4488. var i,
  4489. j = { href: 1, src: 1 },
  4490. k = UE.uNode,
  4491. l = {
  4492. td: 'tr',
  4493. tr: ['tbody', 'thead', 'tfoot'],
  4494. tbody: 'table',
  4495. th: 'tr',
  4496. thead: 'table',
  4497. tfoot: 'table',
  4498. caption: 'table',
  4499. li: ['ul', 'ol'],
  4500. dt: 'dl',
  4501. dd: 'dl',
  4502. option: 'select'
  4503. },
  4504. m = { ol: 'li', ul: 'li' },
  4505. n = 0,
  4506. o = 0,
  4507. p = new k({ type: 'root', children: [] }),
  4508. q = p;
  4509. (i = f.exec(a));
  4510. ) {
  4511. n = i.index
  4512. try {
  4513. if ((n > o && c(q, a.slice(o, n)), i[3]))
  4514. dtd.$cdata[q.tagName]
  4515. ? c(q, i[0])
  4516. : (q = d(q, i[3].toLowerCase(), i[4]))
  4517. else if (i[1]) {
  4518. if ('root' != q.type)
  4519. if (dtd.$cdata[q.tagName] && !dtd.$cdata[i[1]]) c(q, i[0])
  4520. else {
  4521. for (
  4522. var r = q;
  4523. 'element' == q.type && q.tagName != i[1].toLowerCase();
  4524. )
  4525. if (((q = q.parentNode), 'root' == q.type))
  4526. throw ((q = r), 'break')
  4527. q = q.parentNode
  4528. }
  4529. } else i[2] && e(q, i[2])
  4530. } catch (s) {}
  4531. o = f.lastIndex
  4532. }
  4533. return o < a.length && c(q, a.slice(o)), p
  4534. }),
  4535. filterNode = (UE.filterNode = (function () {
  4536. function a(b, c) {
  4537. switch (b.type) {
  4538. case 'text':
  4539. break
  4540. case 'element':
  4541. var d
  4542. if ((d = c[b.tagName]))
  4543. if ('-' === d) b.parentNode.removeChild(b)
  4544. else if (utils.isFunction(d)) {
  4545. var e = b.parentNode,
  4546. f = b.getIndex()
  4547. if ((d(b), b.parentNode)) {
  4548. if (b.children)
  4549. for (var g, h = 0; (g = b.children[h]); )
  4550. a(g, c), g.parentNode && h++
  4551. } else
  4552. for (var g, h = f; (g = e.children[h]); )
  4553. a(g, c), g.parentNode && h++
  4554. } else {
  4555. var i = d.$
  4556. if (i && b.attrs) {
  4557. var j,
  4558. k = {}
  4559. for (var l in i) {
  4560. if (
  4561. ((j = b.getAttr(l)), 'style' == l && utils.isArray(i[l]))
  4562. ) {
  4563. var m = []
  4564. utils.each(i[l], function (a) {
  4565. var c
  4566. ;(c = b.getStyle(a)) && m.push(a + ':' + c)
  4567. }),
  4568. (j = m.join(';'))
  4569. }
  4570. j && (k[l] = j)
  4571. }
  4572. b.attrs = k
  4573. }
  4574. if (b.children)
  4575. for (var g, h = 0; (g = b.children[h]); )
  4576. a(g, c), g.parentNode && h++
  4577. }
  4578. else if (dtd.$cdata[b.tagName]) b.parentNode.removeChild(b)
  4579. else {
  4580. var e = b.parentNode,
  4581. f = b.getIndex()
  4582. b.parentNode.removeChild(b, !0)
  4583. for (var g, h = f; (g = e.children[h]); )
  4584. a(g, c), g.parentNode && h++
  4585. }
  4586. break
  4587. case 'comment':
  4588. b.parentNode.removeChild(b)
  4589. }
  4590. }
  4591. return function (b, c) {
  4592. if (utils.isEmptyObject(c)) return b
  4593. var d
  4594. ;(d = c['-']) &&
  4595. utils.each(d.split(' '), function (a) {
  4596. c[a] = '-'
  4597. })
  4598. for (var e, f = 0; (e = b.children[f]); ) a(e, c), e.parentNode && f++
  4599. return b
  4600. }
  4601. })())
  4602. UE.plugin = (function () {
  4603. var a = {}
  4604. return {
  4605. register: function (b, c, d, e) {
  4606. d && utils.isFunction(d) && ((e = d), (d = null)),
  4607. (a[b] = { optionName: d || b, execFn: c, afterDisabled: e })
  4608. },
  4609. load: function (b) {
  4610. utils.each(a, function (a) {
  4611. var c = a.execFn.call(b)
  4612. b.options[a.optionName] !== !1
  4613. ? c &&
  4614. utils.each(c, function (a, c) {
  4615. switch (c.toLowerCase()) {
  4616. case 'shortcutkey':
  4617. b.addshortcutkey(a)
  4618. break
  4619. case 'bindevents':
  4620. utils.each(a, function (a, c) {
  4621. b.addListener(c, a)
  4622. })
  4623. break
  4624. case 'bindmultievents':
  4625. utils.each(utils.isArray(a) ? a : [a], function (a) {
  4626. var c = utils.trim(a.type).split(/\s+/)
  4627. utils.each(c, function (c) {
  4628. b.addListener(c, a.handler)
  4629. })
  4630. })
  4631. break
  4632. case 'commands':
  4633. utils.each(a, function (a, c) {
  4634. b.commands[c] = a
  4635. })
  4636. break
  4637. case 'outputrule':
  4638. b.addOutputRule(a)
  4639. break
  4640. case 'inputrule':
  4641. b.addInputRule(a)
  4642. break
  4643. case 'defaultoptions':
  4644. b.setOpt(a)
  4645. }
  4646. })
  4647. : a.afterDisabled && a.afterDisabled.call(b)
  4648. }),
  4649. utils.each(UE.plugins, function (a) {
  4650. a.call(b)
  4651. })
  4652. },
  4653. run: function (b, c) {
  4654. var d = a[b]
  4655. d && d.exeFn.call(c)
  4656. }
  4657. }
  4658. })()
  4659. var keymap = (UE.keymap = {
  4660. Backspace: 8,
  4661. Tab: 9,
  4662. Enter: 13,
  4663. Shift: 16,
  4664. Control: 17,
  4665. Alt: 18,
  4666. CapsLock: 20,
  4667. Esc: 27,
  4668. Spacebar: 32,
  4669. PageUp: 33,
  4670. PageDown: 34,
  4671. End: 35,
  4672. Home: 36,
  4673. Left: 37,
  4674. Up: 38,
  4675. Right: 39,
  4676. Down: 40,
  4677. Insert: 45,
  4678. Del: 46,
  4679. NumLock: 144,
  4680. Cmd: 91,
  4681. '=': 187,
  4682. '-': 189,
  4683. b: 66,
  4684. i: 73,
  4685. z: 90,
  4686. y: 89,
  4687. v: 86,
  4688. x: 88,
  4689. s: 83,
  4690. n: 78
  4691. }),
  4692. LocalStorage = (UE.LocalStorage = (function () {
  4693. function a() {
  4694. var a = document.createElement('div')
  4695. return (
  4696. (a.style.display = 'none'),
  4697. a.addBehavior
  4698. ? (a.addBehavior('#default#userdata'),
  4699. {
  4700. getItem: function (b) {
  4701. var d = null
  4702. try {
  4703. document.body.appendChild(a),
  4704. a.load(c),
  4705. (d = a.getAttribute(b)),
  4706. document.body.removeChild(a)
  4707. } catch (e) {}
  4708. return d
  4709. },
  4710. setItem: function (b, d) {
  4711. document.body.appendChild(a),
  4712. a.setAttribute(b, d),
  4713. a.save(c),
  4714. document.body.removeChild(a)
  4715. },
  4716. removeItem: function (b) {
  4717. document.body.appendChild(a),
  4718. a.removeAttribute(b),
  4719. a.save(c),
  4720. document.body.removeChild(a)
  4721. }
  4722. })
  4723. : null
  4724. )
  4725. }
  4726. var b = window.localStorage || a() || null,
  4727. c = 'localStorage'
  4728. return {
  4729. saveLocalData: function (a, c) {
  4730. return !(!b || !c) && (b.setItem(a, c), !0)
  4731. },
  4732. getLocalData: function (a) {
  4733. return b ? b.getItem(a) : null
  4734. },
  4735. removeItem: function (a) {
  4736. b && b.removeItem(a)
  4737. }
  4738. }
  4739. })())
  4740. !(function () {
  4741. var a = 'ueditor_preference'
  4742. ;(UE.Editor.prototype.setPreferences = function (b, c) {
  4743. var d = {}
  4744. utils.isString(b) ? (d[b] = c) : (d = b)
  4745. var e = LocalStorage.getLocalData(a)
  4746. e && (e = utils.str2json(e)) ? utils.extend(e, d) : (e = d),
  4747. e && LocalStorage.saveLocalData(a, utils.json2str(e))
  4748. }),
  4749. (UE.Editor.prototype.getPreferences = function (b) {
  4750. var c = LocalStorage.getLocalData(a)
  4751. return c && (c = utils.str2json(c)) ? (b ? c[b] : c) : null
  4752. }),
  4753. (UE.Editor.prototype.removePreferences = function (b) {
  4754. var c = LocalStorage.getLocalData(a)
  4755. c && (c = utils.str2json(c)) && ((c[b] = void 0), delete c[b]),
  4756. c && LocalStorage.saveLocalData(a, utils.json2str(c))
  4757. })
  4758. })(),
  4759. (UE.plugins.defaultfilter = function () {
  4760. var a = this
  4761. a.setOpt({ allowDivTransToP: !0, disabledTableInTable: !0 }),
  4762. a.addInputRule(function (b) {
  4763. function c(a) {
  4764. for (; a && 'element' == a.type; ) {
  4765. if ('td' == a.tagName) return !0
  4766. a = a.parentNode
  4767. }
  4768. return !1
  4769. }
  4770. var d,
  4771. e = this.options.allowDivTransToP
  4772. b.traversal(function (b) {
  4773. if ('element' == b.type) {
  4774. if (
  4775. !dtd.$cdata[b.tagName] &&
  4776. a.options.autoClearEmptyNode &&
  4777. dtd.$inline[b.tagName] &&
  4778. !dtd.$empty[b.tagName] &&
  4779. (!b.attrs || utils.isEmptyObject(b.attrs))
  4780. )
  4781. return void (b.firstChild()
  4782. ? 'span' != b.tagName ||
  4783. (b.attrs && !utils.isEmptyObject(b.attrs)) ||
  4784. b.parentNode.removeChild(b, !0)
  4785. : b.parentNode.removeChild(b))
  4786. switch (b.tagName) {
  4787. case 'style':
  4788. case 'script':
  4789. b.setAttr({
  4790. cdata_tag: b.tagName,
  4791. cdata_data: b.innerHTML() || '',
  4792. _ue_custom_node_: 'true'
  4793. }),
  4794. (b.tagName = 'div'),
  4795. b.innerHTML('')
  4796. break
  4797. case 'a':
  4798. ;(d = b.getAttr('href')) && b.setAttr('_href', d)
  4799. break
  4800. case 'img':
  4801. if ((d = b.getAttr('src')) && /^data:/.test(d)) {
  4802. b.parentNode.removeChild(b)
  4803. break
  4804. }
  4805. b.setAttr('_src', b.getAttr('src'))
  4806. break
  4807. case 'span':
  4808. browser.webkit &&
  4809. (d = b.getStyle('white-space')) &&
  4810. /nowrap|normal/.test(d) &&
  4811. (b.setStyle('white-space', ''),
  4812. a.options.autoClearEmptyNode &&
  4813. utils.isEmptyObject(b.attrs) &&
  4814. b.parentNode.removeChild(b, !0)),
  4815. (d = b.getAttr('id')),
  4816. d &&
  4817. /^_baidu_bookmark_/i.test(d) &&
  4818. b.parentNode.removeChild(b)
  4819. break
  4820. case 'p':
  4821. ;(d = b.getAttr('align')) &&
  4822. (b.setAttr('align'), b.setStyle('text-align', d)),
  4823. utils.each(b.children, function (a) {
  4824. if ('element' == a.type && 'p' == a.tagName) {
  4825. var c = a.nextSibling()
  4826. b.parentNode.insertAfter(a, b)
  4827. for (var d = a; c; ) {
  4828. var e = c.nextSibling()
  4829. b.parentNode.insertAfter(c, d), (d = c), (c = e)
  4830. }
  4831. return !1
  4832. }
  4833. }),
  4834. b.firstChild() ||
  4835. b.innerHTML(browser.ie ? '&nbsp;' : '<br/>')
  4836. break
  4837. case 'div':
  4838. if (b.getAttr('cdata_tag')) break
  4839. if (
  4840. ((d = b.getAttr('class')), d && /^line number\d+/.test(d))
  4841. )
  4842. break
  4843. if (!e) break
  4844. for (
  4845. var f, g = UE.uNode.createElement('p');
  4846. (f = b.firstChild());
  4847. )
  4848. 'text' != f.type && UE.dom.dtd.$block[f.tagName]
  4849. ? g.firstChild()
  4850. ? (b.parentNode.insertBefore(g, b),
  4851. (g = UE.uNode.createElement('p')))
  4852. : b.parentNode.insertBefore(f, b)
  4853. : g.appendChild(f)
  4854. g.firstChild() && b.parentNode.insertBefore(g, b),
  4855. b.parentNode.removeChild(b)
  4856. break
  4857. case 'dl':
  4858. b.tagName = 'ul'
  4859. break
  4860. case 'dt':
  4861. case 'dd':
  4862. b.tagName = 'li'
  4863. break
  4864. case 'li':
  4865. var h = b.getAttr('class')
  4866. ;(h && /list\-/.test(h)) || b.setAttr()
  4867. var i = b.getNodesByTagName('ol ul')
  4868. UE.utils.each(i, function (a) {
  4869. b.parentNode.insertAfter(a, b)
  4870. })
  4871. break
  4872. case 'td':
  4873. case 'th':
  4874. case 'caption':
  4875. ;(b.children && b.children.length) ||
  4876. b.appendChild(
  4877. browser.ie11below
  4878. ? UE.uNode.createText(' ')
  4879. : UE.uNode.createElement('br')
  4880. )
  4881. break
  4882. case 'table':
  4883. a.options.disabledTableInTable &&
  4884. c(b) &&
  4885. (b.parentNode.insertBefore(
  4886. UE.uNode.createText(b.innerText()),
  4887. b
  4888. ),
  4889. b.parentNode.removeChild(b))
  4890. }
  4891. }
  4892. })
  4893. }),
  4894. a.addOutputRule(function (b) {
  4895. var c
  4896. b.traversal(function (b) {
  4897. if ('element' == b.type) {
  4898. if (
  4899. a.options.autoClearEmptyNode &&
  4900. dtd.$inline[b.tagName] &&
  4901. !dtd.$empty[b.tagName] &&
  4902. (!b.attrs || utils.isEmptyObject(b.attrs))
  4903. )
  4904. return void (b.firstChild()
  4905. ? 'span' != b.tagName ||
  4906. (b.attrs && !utils.isEmptyObject(b.attrs)) ||
  4907. b.parentNode.removeChild(b, !0)
  4908. : b.parentNode.removeChild(b))
  4909. switch (b.tagName) {
  4910. case 'div':
  4911. ;(c = b.getAttr('cdata_tag')) &&
  4912. ((b.tagName = c),
  4913. b.appendChild(UE.uNode.createText(b.getAttr('cdata_data'))),
  4914. b.setAttr({
  4915. cdata_tag: '',
  4916. cdata_data: '',
  4917. _ue_custom_node_: ''
  4918. }))
  4919. break
  4920. case 'a':
  4921. ;(c = b.getAttr('_href')) &&
  4922. b.setAttr({ href: utils.html(c), _href: '' })
  4923. break
  4924. case 'span':
  4925. ;(c = b.getAttr('id')),
  4926. c &&
  4927. /^_baidu_bookmark_/i.test(c) &&
  4928. b.parentNode.removeChild(b)
  4929. break
  4930. case 'img':
  4931. ;(c = b.getAttr('_src')) &&
  4932. b.setAttr({ src: b.getAttr('_src'), _src: '' })
  4933. }
  4934. }
  4935. })
  4936. })
  4937. }),
  4938. (UE.commands.inserthtml = {
  4939. execCommand: function (a, b, c) {
  4940. var d,
  4941. e,
  4942. f = this
  4943. if (b && f.fireEvent('beforeinserthtml', b) !== !0) {
  4944. if (
  4945. ((d = f.selection.getRange()),
  4946. (e = d.document.createElement('div')),
  4947. (e.style.display = 'inline'),
  4948. !c)
  4949. ) {
  4950. var g = UE.htmlparser(b)
  4951. f.options.filterRules && UE.filterNode(g, f.options.filterRules),
  4952. f.filterInputRule(g),
  4953. (b = g.toHtml())
  4954. }
  4955. if (((e.innerHTML = utils.trim(b)), !d.collapsed)) {
  4956. var h = d.startContainer
  4957. if (
  4958. (domUtils.isFillChar(h) && d.setStartBefore(h),
  4959. (h = d.endContainer),
  4960. domUtils.isFillChar(h) && d.setEndAfter(h),
  4961. d.txtToElmBoundary(),
  4962. d.endContainer &&
  4963. 1 == d.endContainer.nodeType &&
  4964. ((h = d.endContainer.childNodes[d.endOffset]),
  4965. h && domUtils.isBr(h) && d.setEndAfter(h)),
  4966. 0 == d.startOffset &&
  4967. ((h = d.startContainer),
  4968. domUtils.isBoundaryNode(h, 'firstChild') &&
  4969. ((h = d.endContainer),
  4970. d.endOffset ==
  4971. (3 == h.nodeType
  4972. ? h.nodeValue.length
  4973. : h.childNodes.length) &&
  4974. domUtils.isBoundaryNode(h, 'lastChild') &&
  4975. ((f.body.innerHTML =
  4976. '<p>' + (browser.ie ? '' : '<br/>') + '</p>'),
  4977. d.setStart(f.body.firstChild, 0).collapse(!0)))),
  4978. !d.collapsed && d.deleteContents(),
  4979. 1 == d.startContainer.nodeType)
  4980. ) {
  4981. var i,
  4982. j = d.startContainer.childNodes[d.startOffset]
  4983. if (
  4984. j &&
  4985. domUtils.isBlockElm(j) &&
  4986. (i = j.previousSibling) &&
  4987. domUtils.isBlockElm(i)
  4988. ) {
  4989. for (
  4990. d.setEnd(i, i.childNodes.length).collapse();
  4991. j.firstChild;
  4992. )
  4993. i.appendChild(j.firstChild)
  4994. domUtils.remove(j)
  4995. }
  4996. }
  4997. }
  4998. var j,
  4999. k,
  5000. i,
  5001. l,
  5002. m,
  5003. n = 0
  5004. d.inFillChar() &&
  5005. ((j = d.startContainer),
  5006. domUtils.isFillChar(j)
  5007. ? (d.setStartBefore(j).collapse(!0), domUtils.remove(j))
  5008. : domUtils.isFillChar(j, !0) &&
  5009. ((j.nodeValue = j.nodeValue.replace(fillCharReg, '')),
  5010. d.startOffset--,
  5011. d.collapsed && d.collapse(!0)))
  5012. var o = domUtils.findParentByTagName(d.startContainer, 'li', !0)
  5013. if (o) {
  5014. for (var p, q; (j = e.firstChild); ) {
  5015. for (
  5016. ;
  5017. j &&
  5018. (3 == j.nodeType ||
  5019. !domUtils.isBlockElm(j) ||
  5020. 'HR' == j.tagName);
  5021. )
  5022. (p = j.nextSibling),
  5023. d.insertNode(j).collapse(),
  5024. (q = j),
  5025. (j = p)
  5026. if (j)
  5027. if (/^(ol|ul)$/i.test(j.tagName)) {
  5028. for (; j.firstChild; )
  5029. (q = j.firstChild),
  5030. domUtils.insertAfter(o, j.firstChild),
  5031. (o = o.nextSibling)
  5032. domUtils.remove(j)
  5033. } else {
  5034. var r
  5035. ;(p = j.nextSibling),
  5036. (r = f.document.createElement('li')),
  5037. domUtils.insertAfter(o, r),
  5038. r.appendChild(j),
  5039. (q = j),
  5040. (j = p),
  5041. (o = r)
  5042. }
  5043. }
  5044. ;(o = domUtils.findParentByTagName(d.startContainer, 'li', !0)),
  5045. domUtils.isEmptyBlock(o) && domUtils.remove(o),
  5046. q && d.setStartAfter(q).collapse(!0).select(!0)
  5047. } else {
  5048. for (; (j = e.firstChild); ) {
  5049. if (n) {
  5050. for (
  5051. var s = f.document.createElement('p');
  5052. j && (3 == j.nodeType || !dtd.$block[j.tagName]);
  5053. )
  5054. (m = j.nextSibling), s.appendChild(j), (j = m)
  5055. s.firstChild && (j = s)
  5056. }
  5057. if (
  5058. (d.insertNode(j),
  5059. (m = j.nextSibling),
  5060. !n &&
  5061. j.nodeType == domUtils.NODE_ELEMENT &&
  5062. domUtils.isBlockElm(j) &&
  5063. ((k = domUtils.findParent(j, function (a) {
  5064. return domUtils.isBlockElm(a)
  5065. })),
  5066. k &&
  5067. 'body' != k.tagName.toLowerCase() &&
  5068. (!dtd[k.tagName][j.nodeName] || j.parentNode !== k)))
  5069. ) {
  5070. if (dtd[k.tagName][j.nodeName])
  5071. for (l = j.parentNode; l !== k; ) (i = l), (l = l.parentNode)
  5072. else i = k
  5073. domUtils.breakParent(j, i || l)
  5074. var i = j.previousSibling
  5075. domUtils.trimWhiteTextNode(i),
  5076. i.childNodes.length || domUtils.remove(i),
  5077. !browser.ie &&
  5078. (p = j.nextSibling) &&
  5079. domUtils.isBlockElm(p) &&
  5080. p.lastChild &&
  5081. !domUtils.isBr(p.lastChild) &&
  5082. p.appendChild(f.document.createElement('br')),
  5083. (n = 1)
  5084. }
  5085. var p = j.nextSibling
  5086. if (!e.firstChild && p && domUtils.isBlockElm(p)) {
  5087. d.setStart(p, 0).collapse(!0)
  5088. break
  5089. }
  5090. d.setEndAfter(j).collapse()
  5091. }
  5092. if (
  5093. ((j = d.startContainer),
  5094. m && domUtils.isBr(m) && domUtils.remove(m),
  5095. domUtils.isBlockElm(j) && domUtils.isEmptyNode(j))
  5096. )
  5097. if ((m = j.nextSibling))
  5098. domUtils.remove(j),
  5099. 1 == m.nodeType &&
  5100. dtd.$block[m.tagName] &&
  5101. d.setStart(m, 0).collapse(!0).shrinkBoundary()
  5102. else
  5103. try {
  5104. j.innerHTML = browser.ie ? domUtils.fillChar : '<br/>'
  5105. } catch (t) {
  5106. d.setStartBefore(j), domUtils.remove(j)
  5107. }
  5108. try {
  5109. d.select(!0)
  5110. } catch (t) {}
  5111. }
  5112. setTimeout(function () {
  5113. ;(d = f.selection.getRange()),
  5114. d.scrollToView(
  5115. f.autoHeightEnabled,
  5116. f.autoHeightEnabled ? domUtils.getXY(f.iframe).y : 0
  5117. ),
  5118. f.fireEvent('afterinserthtml', b)
  5119. }, 200)
  5120. }
  5121. }
  5122. }),
  5123. (UE.plugins.autotypeset = function () {
  5124. function a(a, b) {
  5125. return a && 3 != a.nodeType
  5126. ? domUtils.isBr(a)
  5127. ? 1
  5128. : a && a.parentNode && l[a.tagName.toLowerCase()]
  5129. ? (g && g.contains(a)) || a.getAttribute('pagebreak')
  5130. ? 0
  5131. : b
  5132. ? !domUtils.isEmptyBlock(a)
  5133. : domUtils.isEmptyBlock(
  5134. a,
  5135. new RegExp('[\\s' + domUtils.fillChar + ']', 'g')
  5136. )
  5137. : void 0
  5138. : 0
  5139. }
  5140. function b(a) {
  5141. a.style.cssText ||
  5142. (domUtils.removeAttributes(a, ['style']),
  5143. 'span' == a.tagName.toLowerCase() &&
  5144. domUtils.hasNoAttributes(a) &&
  5145. domUtils.remove(a, !0))
  5146. }
  5147. function c(c, f) {
  5148. var h,
  5149. l = this
  5150. if (f) {
  5151. if (!i.pasteFilter) return
  5152. ;(h = l.document.createElement('div')), (h.innerHTML = f.html)
  5153. } else h = l.document.body
  5154. for (
  5155. var m, n = domUtils.getElementsByTagName(h, '*'), o = 0;
  5156. (m = n[o++]);
  5157. )
  5158. if (l.fireEvent('excludeNodeinautotype', m) !== !0) {
  5159. if (
  5160. (i.clearFontSize &&
  5161. m.style.fontSize &&
  5162. (domUtils.removeStyle(m, 'font-size'), b(m)),
  5163. i.clearFontFamily &&
  5164. m.style.fontFamily &&
  5165. (domUtils.removeStyle(m, 'font-family'), b(m)),
  5166. a(m))
  5167. ) {
  5168. if (i.mergeEmptyline)
  5169. for (
  5170. var p, q = m.nextSibling, r = domUtils.isBr(m);
  5171. a(q) &&
  5172. ((p = q),
  5173. (q = p.nextSibling),
  5174. !r || (q && (!q || domUtils.isBr(q))));
  5175. )
  5176. domUtils.remove(p)
  5177. if (
  5178. i.removeEmptyline &&
  5179. domUtils.inDoc(m, h) &&
  5180. !k[m.parentNode.tagName.toLowerCase()]
  5181. ) {
  5182. if (
  5183. domUtils.isBr(m) &&
  5184. ((q = m.nextSibling), q && !domUtils.isBr(q))
  5185. )
  5186. continue
  5187. domUtils.remove(m)
  5188. continue
  5189. }
  5190. }
  5191. if (
  5192. (a(m, !0) &&
  5193. 'SPAN' != m.tagName &&
  5194. (i.indent && (m.style.textIndent = i.indentValue),
  5195. i.textAlign && (m.style.textAlign = i.textAlign)),
  5196. i.removeClass && m.className && !j[m.className.toLowerCase()])
  5197. ) {
  5198. if (g && g.contains(m)) continue
  5199. domUtils.removeAttributes(m, ['class'])
  5200. }
  5201. if (
  5202. i.imageBlockLine &&
  5203. 'img' == m.tagName.toLowerCase() &&
  5204. !m.getAttribute('emotion')
  5205. )
  5206. if (f) {
  5207. var s = m
  5208. switch (i.imageBlockLine) {
  5209. case 'left':
  5210. case 'right':
  5211. case 'none':
  5212. for (
  5213. var p, t, q, u = s.parentNode;
  5214. dtd.$inline[u.tagName] || 'A' == u.tagName;
  5215. )
  5216. u = u.parentNode
  5217. if (
  5218. ((p = u),
  5219. 'P' == p.tagName &&
  5220. 'center' == domUtils.getStyle(p, 'text-align') &&
  5221. !domUtils.isBody(p) &&
  5222. 1 ==
  5223. domUtils.getChildCount(p, function (a) {
  5224. return (
  5225. !domUtils.isBr(a) && !domUtils.isWhitespace(a)
  5226. )
  5227. }))
  5228. )
  5229. if (
  5230. ((t = p.previousSibling),
  5231. (q = p.nextSibling),
  5232. t &&
  5233. q &&
  5234. 1 == t.nodeType &&
  5235. 1 == q.nodeType &&
  5236. t.tagName == q.tagName &&
  5237. domUtils.isBlockElm(t))
  5238. ) {
  5239. for (t.appendChild(p.firstChild); q.firstChild; )
  5240. t.appendChild(q.firstChild)
  5241. domUtils.remove(p), domUtils.remove(q)
  5242. } else domUtils.setStyle(p, 'text-align', '')
  5243. domUtils.setStyle(s, 'float', i.imageBlockLine)
  5244. break
  5245. case 'center':
  5246. if ('center' != l.queryCommandValue('imagefloat')) {
  5247. for (
  5248. u = s.parentNode,
  5249. domUtils.setStyle(s, 'float', 'none'),
  5250. p = s;
  5251. u &&
  5252. 1 ==
  5253. domUtils.getChildCount(u, function (a) {
  5254. return (
  5255. !domUtils.isBr(a) && !domUtils.isWhitespace(a)
  5256. )
  5257. }) &&
  5258. (dtd.$inline[u.tagName] || 'A' == u.tagName);
  5259. )
  5260. (p = u), (u = u.parentNode)
  5261. var v = l.document.createElement('p')
  5262. domUtils.setAttributes(v, { style: 'text-align:center' }),
  5263. p.parentNode.insertBefore(v, p),
  5264. v.appendChild(p),
  5265. domUtils.setStyle(p, 'float', '')
  5266. }
  5267. }
  5268. } else {
  5269. var w = l.selection.getRange()
  5270. w.selectNode(m).select(),
  5271. l.execCommand('imagefloat', i.imageBlockLine)
  5272. }
  5273. i.removeEmptyNode &&
  5274. i.removeTagNames[m.tagName.toLowerCase()] &&
  5275. domUtils.hasNoAttributes(m) &&
  5276. domUtils.isEmptyBlock(m) &&
  5277. domUtils.remove(m)
  5278. }
  5279. if (i.tobdc) {
  5280. var x = UE.htmlparser(h.innerHTML)
  5281. x.traversal(function (a) {
  5282. 'text' == a.type && (a.data = e(a.data))
  5283. }),
  5284. (h.innerHTML = x.toHtml())
  5285. }
  5286. if (i.bdc2sb) {
  5287. var x = UE.htmlparser(h.innerHTML)
  5288. x.traversal(function (a) {
  5289. 'text' == a.type && (a.data = d(a.data))
  5290. }),
  5291. (h.innerHTML = x.toHtml())
  5292. }
  5293. f && (f.html = h.innerHTML)
  5294. }
  5295. function d(a) {
  5296. for (var b = '', c = 0; c < a.length; c++) {
  5297. var d = a.charCodeAt(c)
  5298. b +=
  5299. d >= 65281 && d <= 65373
  5300. ? String.fromCharCode(a.charCodeAt(c) - 65248)
  5301. : 12288 == d
  5302. ? String.fromCharCode(a.charCodeAt(c) - 12288 + 32)
  5303. : a.charAt(c)
  5304. }
  5305. return b
  5306. }
  5307. function e(a) {
  5308. a = utils.html(a)
  5309. for (var b = '', c = 0; c < a.length; c++)
  5310. b +=
  5311. 32 == a.charCodeAt(c)
  5312. ? String.fromCharCode(12288)
  5313. : a.charCodeAt(c) < 127
  5314. ? String.fromCharCode(a.charCodeAt(c) + 65248)
  5315. : a.charAt(c)
  5316. return b
  5317. }
  5318. function f() {
  5319. var a = h.getPreferences('autotypeset')
  5320. utils.extend(h.options.autotypeset, a)
  5321. }
  5322. this.setOpt({
  5323. autotypeset: {
  5324. mergeEmptyline: !0,
  5325. removeClass: !0,
  5326. removeEmptyline: !1,
  5327. textAlign: 'left',
  5328. imageBlockLine: 'center',
  5329. pasteFilter: !1,
  5330. clearFontSize: !1,
  5331. clearFontFamily: !1,
  5332. removeEmptyNode: !1,
  5333. removeTagNames: utils.extend({ div: 1 }, dtd.$removeEmpty),
  5334. indent: !1,
  5335. indentValue: '2em',
  5336. bdc2sb: !1,
  5337. tobdc: !1
  5338. }
  5339. })
  5340. var g,
  5341. h = this,
  5342. i = h.options.autotypeset,
  5343. j = { selectTdClass: 1, pagebreak: 1, anchorclass: 1 },
  5344. k = { li: 1 },
  5345. l = {
  5346. div: 1,
  5347. p: 1,
  5348. blockquote: 1,
  5349. center: 1,
  5350. h1: 1,
  5351. h2: 1,
  5352. h3: 1,
  5353. h4: 1,
  5354. h5: 1,
  5355. h6: 1,
  5356. span: 1
  5357. }
  5358. i &&
  5359. (f(),
  5360. i.pasteFilter && h.addListener('beforepaste', c),
  5361. (h.commands.autotypeset = {
  5362. execCommand: function () {
  5363. h.removeListener('beforepaste', c),
  5364. i.pasteFilter && h.addListener('beforepaste', c),
  5365. c.call(h)
  5366. }
  5367. }))
  5368. }),
  5369. UE.plugin.register('autosubmit', function () {
  5370. return {
  5371. shortcutkey: { autosubmit: 'ctrl+13' },
  5372. commands: {
  5373. autosubmit: {
  5374. execCommand: function () {
  5375. var a = this,
  5376. b = domUtils.findParentByTagName(a.iframe, 'form', !1)
  5377. if (b) {
  5378. if (a.fireEvent('beforesubmit') === !1) return
  5379. a.sync(), b.submit()
  5380. }
  5381. }
  5382. }
  5383. }
  5384. }
  5385. }),
  5386. UE.plugin.register('background', function () {
  5387. function a(a) {
  5388. var b = {},
  5389. c = a.split(';')
  5390. return (
  5391. utils.each(c, function (a) {
  5392. var c = a.indexOf(':'),
  5393. d = utils.trim(a.substr(0, c)).toLowerCase()
  5394. d && (b[d] = utils.trim(a.substr(c + 1) || ''))
  5395. }),
  5396. b
  5397. )
  5398. }
  5399. function b(a) {
  5400. if (a) {
  5401. var b = []
  5402. for (var c in a) a.hasOwnProperty(c) && b.push(c + ':' + a[c] + '; ')
  5403. utils.cssRule(
  5404. e,
  5405. b.length ? 'body{' + b.join('') + '}' : '',
  5406. d.document
  5407. )
  5408. } else utils.cssRule(e, '', d.document)
  5409. }
  5410. var c,
  5411. d = this,
  5412. e = 'editor_background',
  5413. f = new RegExp('body[\\s]*\\{(.+)\\}', 'i'),
  5414. g = d.hasContents
  5415. return (
  5416. (d.hasContents = function () {
  5417. return !!d.queryCommandValue('background') || g.apply(d, arguments)
  5418. }),
  5419. {
  5420. bindEvents: {
  5421. getAllHtml: function (a, b) {
  5422. var c = this.body,
  5423. e = domUtils.getComputedStyle(c, 'background-image'),
  5424. f = ''
  5425. f =
  5426. e.indexOf(d.options.imagePath) > 0
  5427. ? e
  5428. .substring(e.indexOf(d.options.imagePath), e.length - 1)
  5429. .replace(/"|\(|\)/gi, '')
  5430. : 'none' != e
  5431. ? e.replace(/url\("?|"?\)/gi, '')
  5432. : ''
  5433. var g = '<style type="text/css">body{',
  5434. h = {
  5435. 'background-color':
  5436. domUtils.getComputedStyle(c, 'background-color') ||
  5437. '#ffffff',
  5438. 'background-image': f ? 'url(' + f + ')' : '',
  5439. 'background-repeat':
  5440. domUtils.getComputedStyle(c, 'background-repeat') || '',
  5441. 'background-position': browser.ie
  5442. ? domUtils.getComputedStyle(c, 'background-position-x') +
  5443. ' ' +
  5444. domUtils.getComputedStyle(c, 'background-position-y')
  5445. : domUtils.getComputedStyle(c, 'background-position'),
  5446. height: domUtils.getComputedStyle(c, 'height')
  5447. }
  5448. for (var i in h)
  5449. h.hasOwnProperty(i) && (g += i + ':' + h[i] + '; ')
  5450. ;(g += '}</style> '), b.push(g)
  5451. },
  5452. aftersetcontent: function () {
  5453. 0 == c && b()
  5454. }
  5455. },
  5456. inputRule: function (d) {
  5457. ;(c = !1),
  5458. utils.each(d.getNodesByTagName('p'), function (d) {
  5459. var e = d.getAttr('data-background')
  5460. e && ((c = !0), b(a(e)), d.parentNode.removeChild(d))
  5461. })
  5462. },
  5463. outputRule: function (a) {
  5464. var b = this,
  5465. c = (utils.cssRule(e, b.document) || '')
  5466. .replace(/[\n\r]+/g, '')
  5467. .match(f)
  5468. c &&
  5469. a.appendChild(
  5470. UE.uNode.createElement(
  5471. '<p style="display:none;" data-background="' +
  5472. utils.trim(c[1].replace(/"/g, '').replace(/[\s]+/g, ' ')) +
  5473. '"><br/></p>'
  5474. )
  5475. )
  5476. },
  5477. commands: {
  5478. background: {
  5479. execCommand: function (a, c) {
  5480. b(c)
  5481. },
  5482. queryCommandValue: function () {
  5483. var b = this,
  5484. c = (utils.cssRule(e, b.document) || '')
  5485. .replace(/[\n\r]+/g, '')
  5486. .match(f)
  5487. return c ? a(c[1]) : null
  5488. },
  5489. notNeedUndo: !0
  5490. }
  5491. }
  5492. }
  5493. )
  5494. }),
  5495. (UE.commands.imagefloat = {
  5496. execCommand: function (a, b) {
  5497. var c = this,
  5498. d = c.selection.getRange()
  5499. if (!d.collapsed) {
  5500. var e = d.getClosedNode()
  5501. if (e && 'IMG' == e.tagName)
  5502. switch (b) {
  5503. case 'left':
  5504. case 'right':
  5505. case 'none':
  5506. for (
  5507. var f, g, h, i = e.parentNode;
  5508. dtd.$inline[i.tagName] || 'A' == i.tagName;
  5509. )
  5510. i = i.parentNode
  5511. if (
  5512. ((f = i),
  5513. 'P' == f.tagName &&
  5514. 'center' == domUtils.getStyle(f, 'text-align'))
  5515. ) {
  5516. if (
  5517. !domUtils.isBody(f) &&
  5518. 1 ==
  5519. domUtils.getChildCount(f, function (a) {
  5520. return !domUtils.isBr(a) && !domUtils.isWhitespace(a)
  5521. })
  5522. )
  5523. if (
  5524. ((g = f.previousSibling),
  5525. (h = f.nextSibling),
  5526. g &&
  5527. h &&
  5528. 1 == g.nodeType &&
  5529. 1 == h.nodeType &&
  5530. g.tagName == h.tagName &&
  5531. domUtils.isBlockElm(g))
  5532. ) {
  5533. for (g.appendChild(f.firstChild); h.firstChild; )
  5534. g.appendChild(h.firstChild)
  5535. domUtils.remove(f), domUtils.remove(h)
  5536. } else domUtils.setStyle(f, 'text-align', '')
  5537. d.selectNode(e).select()
  5538. }
  5539. domUtils.setStyle(e, 'float', 'none' == b ? '' : b),
  5540. 'none' == b && domUtils.removeAttributes(e, 'align')
  5541. break
  5542. case 'center':
  5543. if ('center' != c.queryCommandValue('imagefloat')) {
  5544. for (
  5545. i = e.parentNode,
  5546. domUtils.setStyle(e, 'float', ''),
  5547. domUtils.removeAttributes(e, 'align'),
  5548. f = e;
  5549. i &&
  5550. 1 ==
  5551. domUtils.getChildCount(i, function (a) {
  5552. return !domUtils.isBr(a) && !domUtils.isWhitespace(a)
  5553. }) &&
  5554. (dtd.$inline[i.tagName] || 'A' == i.tagName);
  5555. )
  5556. (f = i), (i = i.parentNode)
  5557. d.setStartBefore(f).setCursor(!1),
  5558. (i = c.document.createElement('div')),
  5559. i.appendChild(f),
  5560. domUtils.setStyle(f, 'float', ''),
  5561. c.execCommand(
  5562. 'insertHtml',
  5563. '<p id="_img_parent_tmp" style="text-align:center">' +
  5564. i.innerHTML +
  5565. '</p>'
  5566. ),
  5567. (f = c.document.getElementById('_img_parent_tmp')),
  5568. f.removeAttribute('id'),
  5569. (f = f.firstChild),
  5570. d.selectNode(f).select(),
  5571. (h = f.parentNode.nextSibling),
  5572. h && domUtils.isEmptyNode(h) && domUtils.remove(h)
  5573. }
  5574. }
  5575. }
  5576. },
  5577. queryCommandValue: function () {
  5578. var a,
  5579. b,
  5580. c = this.selection.getRange()
  5581. return c.collapsed
  5582. ? 'none'
  5583. : ((a = c.getClosedNode()),
  5584. a && 1 == a.nodeType && 'IMG' == a.tagName
  5585. ? ((b =
  5586. domUtils.getComputedStyle(a, 'float') ||
  5587. a.getAttribute('align')),
  5588. 'none' == b &&
  5589. (b =
  5590. 'center' ==
  5591. domUtils.getComputedStyle(a.parentNode, 'text-align')
  5592. ? 'center'
  5593. : b),
  5594. { left: 1, right: 1, center: 1 }[b] ? b : 'none')
  5595. : 'none')
  5596. },
  5597. queryCommandState: function () {
  5598. var a,
  5599. b = this.selection.getRange()
  5600. return b.collapsed
  5601. ? -1
  5602. : ((a = b.getClosedNode()),
  5603. a && 1 == a.nodeType && 'IMG' == a.tagName ? 0 : -1)
  5604. }
  5605. }),
  5606. (UE.commands.insertimage = {
  5607. execCommand: function (a, b) {
  5608. function c(a) {
  5609. utils.each(
  5610. 'width,height,border,hspace,vspace'.split(','),
  5611. function (b) {
  5612. a[b] && (a[b] = parseInt(a[b], 10) || 0)
  5613. }
  5614. ),
  5615. utils.each('src,_src'.split(','), function (b) {
  5616. a[b] && (a[b] = utils.unhtmlForUrl(a[b]))
  5617. }),
  5618. utils.each('title,alt'.split(','), function (b) {
  5619. a[b] && (a[b] = utils.unhtml(a[b]))
  5620. })
  5621. }
  5622. if (((b = utils.isArray(b) ? b : [b]), b.length)) {
  5623. var d = this,
  5624. e = d.selection.getRange(),
  5625. f = e.getClosedNode()
  5626. if (d.fireEvent('beforeinsertimage', b) !== !0) {
  5627. if (
  5628. !f ||
  5629. !/img/i.test(f.tagName) ||
  5630. ('edui-faked-video' == f.className &&
  5631. f.className.indexOf('edui-upload-video') == -1) ||
  5632. f.getAttribute('word_img')
  5633. ) {
  5634. var g,
  5635. h = [],
  5636. i = ''
  5637. if (((g = b[0]), 1 == b.length))
  5638. c(g),
  5639. (i =
  5640. '<img src="' +
  5641. g.src +
  5642. '" ' +
  5643. (g._src ? ' _src="' + g._src + '" ' : '') +
  5644. (g.width ? 'width="' + g.width + '" ' : '') +
  5645. (g.height ? ' height="' + g.height + '" ' : '') +
  5646. ('left' == g.floatStyle || 'right' == g.floatStyle
  5647. ? ' style="float:' + g.floatStyle + ';"'
  5648. : '') +
  5649. (g.title && '' != g.title
  5650. ? ' title="' + g.title + '"'
  5651. : '') +
  5652. (g.border && '0' != g.border
  5653. ? ' border="' + g.border + '"'
  5654. : '') +
  5655. (g.alt && '' != g.alt ? ' alt="' + g.alt + '"' : '') +
  5656. (g.hspace && '0' != g.hspace
  5657. ? ' hspace = "' + g.hspace + '"'
  5658. : '') +
  5659. (g.vspace && '0' != g.vspace
  5660. ? ' vspace = "' + g.vspace + '"'
  5661. : '') +
  5662. '/>'),
  5663. 'center' == g.floatStyle &&
  5664. (i = '<p style="text-align: center">' + i + '</p>'),
  5665. h.push(i)
  5666. else
  5667. for (var j = 0; (g = b[j++]); )
  5668. c(g),
  5669. (i =
  5670. '<p ' +
  5671. ('center' == g.floatStyle
  5672. ? 'style="text-align: center" '
  5673. : '') +
  5674. '><img src="' +
  5675. g.src +
  5676. '" ' +
  5677. (g.width ? 'width="' + g.width + '" ' : '') +
  5678. (g._src ? ' _src="' + g._src + '" ' : '') +
  5679. (g.height ? ' height="' + g.height + '" ' : '') +
  5680. ' style="' +
  5681. (g.floatStyle && 'center' != g.floatStyle
  5682. ? 'float:' + g.floatStyle + ';'
  5683. : '') +
  5684. (g.border || '') +
  5685. '" ' +
  5686. (g.title ? ' title="' + g.title + '"' : '') +
  5687. ' /></p>'),
  5688. h.push(i)
  5689. d.execCommand('insertHtml', h.join(''))
  5690. } else {
  5691. var k = b.shift(),
  5692. l = k.floatStyle
  5693. delete k.floatStyle,
  5694. domUtils.setAttributes(f, k),
  5695. d.execCommand('imagefloat', l),
  5696. b.length > 0 &&
  5697. (e.setStartAfter(f).setCursor(!1, !0),
  5698. d.execCommand('insertimage', b))
  5699. }
  5700. d.fireEvent('afterinsertimage', b)
  5701. }
  5702. }
  5703. }
  5704. }),
  5705. (UE.plugins.justify = function () {
  5706. var a = domUtils.isBlockElm,
  5707. b = { left: 1, right: 1, center: 1, justify: 1 },
  5708. c = function (b, c) {
  5709. var d = b.createBookmark(),
  5710. e = function (a) {
  5711. return 1 == a.nodeType
  5712. ? 'br' != a.tagName.toLowerCase() && !domUtils.isBookmarkNode(a)
  5713. : !domUtils.isWhitespace(a)
  5714. }
  5715. b.enlarge(!0)
  5716. for (
  5717. var f,
  5718. g = b.createBookmark(),
  5719. h = domUtils.getNextDomNode(g.start, !1, e),
  5720. i = b.cloneRange();
  5721. h &&
  5722. !(domUtils.getPosition(h, g.end) & domUtils.POSITION_FOLLOWING);
  5723. )
  5724. if (3 != h.nodeType && a(h)) h = domUtils.getNextDomNode(h, !0, e)
  5725. else {
  5726. for (i.setStartBefore(h); h && h !== g.end && !a(h); )
  5727. (f = h),
  5728. (h = domUtils.getNextDomNode(h, !1, null, function (b) {
  5729. return !a(b)
  5730. }))
  5731. i.setEndAfter(f)
  5732. var j = i.getCommonAncestor()
  5733. if (!domUtils.isBody(j) && a(j))
  5734. domUtils.setStyles(
  5735. j,
  5736. utils.isString(c) ? { 'text-align': c } : c
  5737. ),
  5738. (h = j)
  5739. else {
  5740. var k = b.document.createElement('p')
  5741. domUtils.setStyles(
  5742. k,
  5743. utils.isString(c) ? { 'text-align': c } : c
  5744. )
  5745. var l = i.extractContents()
  5746. k.appendChild(l), i.insertNode(k), (h = k)
  5747. }
  5748. h = domUtils.getNextDomNode(h, !1, e)
  5749. }
  5750. return b.moveToBookmark(g).moveToBookmark(d)
  5751. }
  5752. UE.commands.justify = {
  5753. execCommand: function (a, b) {
  5754. var d,
  5755. e = this.selection.getRange()
  5756. return (
  5757. e.collapsed &&
  5758. ((d = this.document.createTextNode('p')), e.insertNode(d)),
  5759. c(e, b),
  5760. d && (e.setStartBefore(d).collapse(!0), domUtils.remove(d)),
  5761. e.select(),
  5762. !0
  5763. )
  5764. },
  5765. queryCommandValue: function () {
  5766. var a = this.selection.getStart(),
  5767. c = domUtils.getComputedStyle(a, 'text-align')
  5768. return b[c] ? c : 'left'
  5769. },
  5770. queryCommandState: function () {
  5771. var a = this.selection.getStart(),
  5772. b =
  5773. a && domUtils.findParentByTagName(a, ['td', 'th', 'caption'], !0)
  5774. return b ? -1 : 0
  5775. }
  5776. }
  5777. }),
  5778. (UE.plugins.font = function () {
  5779. function a(a) {
  5780. for (
  5781. var b;
  5782. (b = a.parentNode) &&
  5783. 'SPAN' == b.tagName &&
  5784. 1 ==
  5785. domUtils.getChildCount(b, function (a) {
  5786. return !domUtils.isBookmarkNode(a) && !domUtils.isBr(a)
  5787. });
  5788. )
  5789. (b.style.cssText += a.style.cssText), domUtils.remove(a, !0), (a = b)
  5790. }
  5791. function b(a, b, c) {
  5792. if (
  5793. g[b] &&
  5794. (a.adjustmentBoundary(),
  5795. !a.collapsed && 1 == a.startContainer.nodeType)
  5796. ) {
  5797. var d = a.startContainer.childNodes[a.startOffset]
  5798. if (d && domUtils.isTagNode(d, 'span')) {
  5799. var e = a.createBookmark()
  5800. utils.each(domUtils.getElementsByTagName(d, 'span'), function (a) {
  5801. a.parentNode &&
  5802. !domUtils.isBookmarkNode(a) &&
  5803. (('backcolor' == b &&
  5804. domUtils
  5805. .getComputedStyle(a, 'background-color')
  5806. .toLowerCase() === c) ||
  5807. (domUtils.removeStyle(a, g[b]),
  5808. 0 == a.style.cssText.replace(/^\s+$/, '').length &&
  5809. domUtils.remove(a, !0)))
  5810. }),
  5811. a.moveToBookmark(e)
  5812. }
  5813. }
  5814. }
  5815. function c(c, d, e) {
  5816. var f,
  5817. g = c.collapsed,
  5818. h = c.createBookmark()
  5819. if (g)
  5820. for (f = h.start.parentNode; dtd.$inline[f.tagName]; )
  5821. f = f.parentNode
  5822. else f = domUtils.getCommonAncestor(h.start, h.end)
  5823. utils.each(domUtils.getElementsByTagName(f, 'span'), function (b) {
  5824. if (b.parentNode && !domUtils.isBookmarkNode(b)) {
  5825. if (/\s*border\s*:\s*none;?\s*/i.test(b.style.cssText))
  5826. return void (/^\s*border\s*:\s*none;?\s*$/.test(b.style.cssText)
  5827. ? domUtils.remove(b, !0)
  5828. : domUtils.removeStyle(b, 'border'))
  5829. if (
  5830. (/border/i.test(b.style.cssText) &&
  5831. 'SPAN' == b.parentNode.tagName &&
  5832. /border/i.test(b.parentNode.style.cssText) &&
  5833. (b.style.cssText = b.style.cssText.replace(
  5834. /border[^:]*:[^;]+;?/gi,
  5835. ''
  5836. )),
  5837. 'fontborder' != d || 'none' != e)
  5838. )
  5839. for (
  5840. var c = b.nextSibling;
  5841. c && 1 == c.nodeType && 'SPAN' == c.tagName;
  5842. )
  5843. if (domUtils.isBookmarkNode(c) && 'fontborder' == d)
  5844. b.appendChild(c), (c = b.nextSibling)
  5845. else {
  5846. if (
  5847. (c.style.cssText == b.style.cssText &&
  5848. (domUtils.moveChild(c, b), domUtils.remove(c)),
  5849. b.nextSibling === c)
  5850. )
  5851. break
  5852. c = b.nextSibling
  5853. }
  5854. if ((a(b), browser.ie && browser.version > 8)) {
  5855. var f = domUtils.findParent(b, function (a) {
  5856. return (
  5857. 'SPAN' == a.tagName &&
  5858. /background-color/.test(a.style.cssText)
  5859. )
  5860. })
  5861. f &&
  5862. !/background-color/.test(b.style.cssText) &&
  5863. (b.style.backgroundColor = f.style.backgroundColor)
  5864. }
  5865. }
  5866. }),
  5867. c.moveToBookmark(h),
  5868. b(c, d, e)
  5869. }
  5870. var d = this,
  5871. e = {
  5872. forecolor: 'color',
  5873. backcolor: 'background-color',
  5874. fontsize: 'font-size',
  5875. fontfamily: 'font-family',
  5876. underline: 'text-decoration',
  5877. strikethrough: 'text-decoration',
  5878. fontborder: 'border'
  5879. },
  5880. f = { underline: 1, strikethrough: 1, fontborder: 1 },
  5881. g = {
  5882. forecolor: 'color',
  5883. backcolor: 'background-color',
  5884. fontsize: 'font-size',
  5885. fontfamily: 'font-family'
  5886. }
  5887. d.setOpt({
  5888. fontfamily: [
  5889. { name: 'songti', val: '宋体,SimSun' },
  5890. { name: 'yahei', val: '微软雅黑,Microsoft YaHei' },
  5891. { name: 'kaiti', val: '楷体,楷体_GB2312, SimKai' },
  5892. { name: 'heiti', val: '黑体, SimHei' },
  5893. { name: 'lishu', val: '隶书, SimLi' },
  5894. { name: 'andaleMono', val: 'andale mono' },
  5895. { name: 'arial', val: 'arial, helvetica,sans-serif' },
  5896. { name: 'arialBlack', val: 'arial black,avant garde' },
  5897. { name: 'comicSansMs', val: 'comic sans ms' },
  5898. { name: 'impact', val: 'impact,chicago' },
  5899. { name: 'timesNewRoman', val: 'times new roman' }
  5900. ],
  5901. fontsize: [10, 11, 12, 14, 16, 18, 20, 24, 36]
  5902. }),
  5903. d.addInputRule(function (a) {
  5904. utils.each(a.getNodesByTagName('u s del font strike'), function (a) {
  5905. if ('font' == a.tagName) {
  5906. var b = []
  5907. for (var c in a.attrs)
  5908. switch (c) {
  5909. case 'size':
  5910. b.push(
  5911. 'font-size:' +
  5912. ({
  5913. 1: '10',
  5914. 2: '12',
  5915. 3: '16',
  5916. 4: '18',
  5917. 5: '24',
  5918. 6: '32',
  5919. 7: '48'
  5920. }[a.attrs[c]] || a.attrs[c]) +
  5921. 'px'
  5922. )
  5923. break
  5924. case 'color':
  5925. b.push('color:' + a.attrs[c])
  5926. break
  5927. case 'face':
  5928. b.push('font-family:' + a.attrs[c])
  5929. break
  5930. case 'style':
  5931. b.push(a.attrs[c])
  5932. }
  5933. a.attrs = { style: b.join(';') }
  5934. } else {
  5935. var d = 'u' == a.tagName ? 'underline' : 'line-through'
  5936. a.attrs = {
  5937. style: (a.getAttr('style') || '') + 'text-decoration:' + d + ';'
  5938. }
  5939. }
  5940. a.tagName = 'span'
  5941. })
  5942. })
  5943. for (var h in e)
  5944. !(function (a, b) {
  5945. UE.commands[a] = {
  5946. execCommand: function (d, e) {
  5947. e =
  5948. e ||
  5949. (this.queryCommandState(d)
  5950. ? 'none'
  5951. : 'underline' == d
  5952. ? 'underline'
  5953. : 'fontborder' == d
  5954. ? '1px solid #000'
  5955. : 'line-through')
  5956. var g,
  5957. h = this,
  5958. i = this.selection.getRange()
  5959. if ('default' == e)
  5960. i.collapsed &&
  5961. ((g = h.document.createTextNode('font')),
  5962. i.insertNode(g).select()),
  5963. h.execCommand('removeFormat', 'span,a', b),
  5964. g && (i.setStartBefore(g).collapse(!0), domUtils.remove(g)),
  5965. c(i, d, e),
  5966. i.select()
  5967. else if (i.collapsed) {
  5968. var j = domUtils.findParentByTagName(
  5969. i.startContainer,
  5970. 'span',
  5971. !0
  5972. )
  5973. if (
  5974. ((g = h.document.createTextNode('font')),
  5975. !j ||
  5976. j.children.length ||
  5977. j[browser.ie ? 'innerText' : 'textContent'].replace(
  5978. fillCharReg,
  5979. ''
  5980. ).length)
  5981. ) {
  5982. if (
  5983. (i.insertNode(g),
  5984. i.selectNode(g).select(),
  5985. (j = i.document.createElement('span')),
  5986. f[a])
  5987. ) {
  5988. if (domUtils.findParentByTagName(g, 'a', !0))
  5989. return (
  5990. i.setStartBefore(g).setCursor(), void domUtils.remove(g)
  5991. )
  5992. h.execCommand('removeFormat', 'span,a', b)
  5993. }
  5994. if (
  5995. ((j.style.cssText = b + ':' + e),
  5996. g.parentNode.insertBefore(j, g),
  5997. !browser.ie || (browser.ie && 9 == browser.version))
  5998. )
  5999. for (var k = j.parentNode; !domUtils.isBlockElm(k); )
  6000. 'SPAN' == k.tagName &&
  6001. (j.style.cssText =
  6002. k.style.cssText + ';' + j.style.cssText),
  6003. (k = k.parentNode)
  6004. opera
  6005. ? setTimeout(function () {
  6006. i.setStart(j, 0).collapse(!0), c(i, d, e), i.select()
  6007. })
  6008. : (i.setStart(j, 0).collapse(!0), c(i, d, e), i.select())
  6009. } else
  6010. i.insertNode(g),
  6011. f[a] &&
  6012. (i.selectNode(g).select(),
  6013. h.execCommand('removeFormat', 'span,a', b, null),
  6014. (j = domUtils.findParentByTagName(g, 'span', !0)),
  6015. i.setStartBefore(g)),
  6016. j && (j.style.cssText += ';' + b + ':' + e),
  6017. i.collapse(!0).select()
  6018. domUtils.remove(g)
  6019. } else
  6020. f[a] &&
  6021. h.queryCommandValue(a) &&
  6022. h.execCommand('removeFormat', 'span,a', b),
  6023. (i = h.selection.getRange()),
  6024. i.applyInlineStyle('span', { style: b + ':' + e }),
  6025. c(i, d, e),
  6026. i.select()
  6027. return !0
  6028. },
  6029. queryCommandValue: function (a) {
  6030. var c = this.selection.getStart()
  6031. if ('underline' == a || 'strikethrough' == a) {
  6032. for (
  6033. var d, e = c;
  6034. e && !domUtils.isBlockElm(e) && !domUtils.isBody(e);
  6035. ) {
  6036. if (
  6037. 1 == e.nodeType &&
  6038. ((d = domUtils.getComputedStyle(e, b)), 'none' != d)
  6039. )
  6040. return d
  6041. e = e.parentNode
  6042. }
  6043. return 'none'
  6044. }
  6045. if ('fontborder' == a) {
  6046. for (var f, g = c; g && dtd.$inline[g.tagName]; ) {
  6047. if (
  6048. (f = domUtils.getComputedStyle(g, 'border')) &&
  6049. /1px/.test(f) &&
  6050. /solid/.test(f)
  6051. )
  6052. return f
  6053. g = g.parentNode
  6054. }
  6055. return ''
  6056. }
  6057. if ('FontSize' == a) {
  6058. var h = domUtils.getComputedStyle(c, b),
  6059. g = /^([\d\.]+)(\w+)$/.exec(h)
  6060. return g ? Math.floor(g[1]) + g[2] : h
  6061. }
  6062. return domUtils.getComputedStyle(c, b)
  6063. },
  6064. queryCommandState: function (a) {
  6065. if (!f[a]) return 0
  6066. var b = this.queryCommandValue(a)
  6067. return 'fontborder' == a
  6068. ? /1px/.test(b) && /solid/.test(b)
  6069. : 'underline' == a
  6070. ? /underline/.test(b)
  6071. : /line\-through/.test(b)
  6072. }
  6073. }
  6074. })(h, e[h])
  6075. }),
  6076. (UE.plugins.link = function () {
  6077. function a(a) {
  6078. var b = a.startContainer,
  6079. c = a.endContainer
  6080. ;(b = domUtils.findParentByTagName(b, 'a', !0)) && a.setStartBefore(b),
  6081. (c = domUtils.findParentByTagName(c, 'a', !0)) && a.setEndAfter(c)
  6082. }
  6083. function b(b, c, d) {
  6084. var e = b.cloneRange(),
  6085. f = d.queryCommandValue('link')
  6086. a((b = b.adjustmentBoundary()))
  6087. var g = b.startContainer
  6088. if (
  6089. (1 == g.nodeType &&
  6090. f &&
  6091. ((g = g.childNodes[b.startOffset]),
  6092. g &&
  6093. 1 == g.nodeType &&
  6094. 'A' == g.tagName &&
  6095. /^(?:https?|ftp|file)\s*:\s*\/\//.test(
  6096. g[browser.ie ? 'innerText' : 'textContent']
  6097. ) &&
  6098. (g[browser.ie ? 'innerText' : 'textContent'] = utils.html(
  6099. c.textValue || c.href
  6100. ))),
  6101. (e.collapsed && !f) ||
  6102. (b.removeInlineStyle('a'), (e = b.cloneRange())),
  6103. e.collapsed)
  6104. ) {
  6105. var h = b.document.createElement('a'),
  6106. i = ''
  6107. c.textValue
  6108. ? ((i = utils.html(c.textValue)), delete c.textValue)
  6109. : (i = utils.html(c.href)),
  6110. domUtils.setAttributes(h, c),
  6111. (g = domUtils.findParentByTagName(e.startContainer, 'a', !0)),
  6112. g &&
  6113. domUtils.isInNodeEndBoundary(e, g) &&
  6114. b.setStartAfter(g).collapse(!0),
  6115. (h[browser.ie ? 'innerText' : 'textContent'] = i),
  6116. b.insertNode(h).selectNode(h)
  6117. } else b.applyInlineStyle('a', c)
  6118. }
  6119. ;(UE.commands.unlink = {
  6120. execCommand: function () {
  6121. var b,
  6122. c = this.selection.getRange()
  6123. ;(c.collapsed &&
  6124. !domUtils.findParentByTagName(c.startContainer, 'a', !0)) ||
  6125. ((b = c.createBookmark()),
  6126. a(c),
  6127. c.removeInlineStyle('a').moveToBookmark(b).select())
  6128. },
  6129. queryCommandState: function () {
  6130. return !this.highlight && this.queryCommandValue('link') ? 0 : -1
  6131. }
  6132. }),
  6133. (UE.commands.link = {
  6134. execCommand: function (a, c) {
  6135. var d
  6136. c._href && (c._href = utils.unhtml(c._href, /[<">]/g)),
  6137. c.href && (c.href = utils.unhtml(c.href, /[<">]/g)),
  6138. c.textValue &&
  6139. (c.textValue = utils.unhtml(c.textValue, /[<">]/g)),
  6140. b((d = this.selection.getRange()), c, this),
  6141. d.collapse().select(!0)
  6142. },
  6143. queryCommandValue: function () {
  6144. var a,
  6145. b = this.selection.getRange()
  6146. if (!b.collapsed) {
  6147. b.shrinkBoundary()
  6148. var c =
  6149. 3 != b.startContainer.nodeType &&
  6150. b.startContainer.childNodes[b.startOffset]
  6151. ? b.startContainer.childNodes[b.startOffset]
  6152. : b.startContainer,
  6153. d =
  6154. 3 == b.endContainer.nodeType || 0 == b.endOffset
  6155. ? b.endContainer
  6156. : b.endContainer.childNodes[b.endOffset - 1],
  6157. e = b.getCommonAncestor()
  6158. if (
  6159. ((a = domUtils.findParentByTagName(e, 'a', !0)),
  6160. !a && 1 == e.nodeType)
  6161. )
  6162. for (
  6163. var f, g, h, i = e.getElementsByTagName('a'), j = 0;
  6164. (h = i[j++]);
  6165. )
  6166. if (
  6167. ((f = domUtils.getPosition(h, c)),
  6168. (g = domUtils.getPosition(h, d)),
  6169. (f & domUtils.POSITION_FOLLOWING ||
  6170. f & domUtils.POSITION_CONTAINS) &&
  6171. (g & domUtils.POSITION_PRECEDING ||
  6172. g & domUtils.POSITION_CONTAINS))
  6173. ) {
  6174. a = h
  6175. break
  6176. }
  6177. return a
  6178. }
  6179. if (
  6180. ((a = b.startContainer),
  6181. (a = 1 == a.nodeType ? a : a.parentNode),
  6182. a &&
  6183. (a = domUtils.findParentByTagName(a, 'a', !0)) &&
  6184. !domUtils.isInNodeEndBoundary(b, a))
  6185. )
  6186. return a
  6187. },
  6188. queryCommandState: function () {
  6189. var a = this.selection.getRange().getClosedNode(),
  6190. b =
  6191. a &&
  6192. ('edui-faked-video' == a.className ||
  6193. a.className.indexOf('edui-upload-video') != -1)
  6194. return b ? -1 : 0
  6195. }
  6196. })
  6197. }),
  6198. (UE.plugins.insertframe = function () {
  6199. function a() {
  6200. b._iframe && delete b._iframe
  6201. }
  6202. var b = this
  6203. b.addListener('selectionchange', function () {
  6204. a()
  6205. })
  6206. }),
  6207. (UE.commands.scrawl = {
  6208. queryCommandState: function () {
  6209. return browser.ie && browser.version <= 8 ? -1 : 0
  6210. }
  6211. }),
  6212. (UE.plugins.removeformat = function () {
  6213. var a = this
  6214. a.setOpt({
  6215. removeFormatTags:
  6216. 'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var',
  6217. removeFormatAttributes:
  6218. 'class,style,lang,width,height,align,hspace,valign'
  6219. }),
  6220. (a.commands.removeformat = {
  6221. execCommand: function (a, b, c, d, e) {
  6222. function f(a) {
  6223. if (3 == a.nodeType || 'span' != a.tagName.toLowerCase()) return 0
  6224. if (browser.ie) {
  6225. var b = a.attributes
  6226. if (b.length) {
  6227. for (var c = 0, d = b.length; c < d; c++)
  6228. if (b[c].specified) return 0
  6229. return 1
  6230. }
  6231. }
  6232. return !a.attributes.length
  6233. }
  6234. function g(a) {
  6235. var b = a.createBookmark()
  6236. if ((a.collapsed && a.enlarge(!0), !e)) {
  6237. var d = domUtils.findParentByTagName(a.startContainer, 'a', !0)
  6238. d && a.setStartBefore(d),
  6239. (d = domUtils.findParentByTagName(a.endContainer, 'a', !0)),
  6240. d && a.setEndAfter(d)
  6241. }
  6242. for (
  6243. h = a.createBookmark(), p = h.start;
  6244. (i = p.parentNode) && !domUtils.isBlockElm(i);
  6245. )
  6246. domUtils.breakParent(p, i), domUtils.clearEmptySibling(p)
  6247. if (h.end) {
  6248. for (p = h.end; (i = p.parentNode) && !domUtils.isBlockElm(i); )
  6249. domUtils.breakParent(p, i), domUtils.clearEmptySibling(p)
  6250. for (
  6251. var g, l = domUtils.getNextDomNode(h.start, !1, m);
  6252. l && l != h.end;
  6253. )
  6254. (g = domUtils.getNextDomNode(l, !0, m)),
  6255. dtd.$empty[l.tagName.toLowerCase()] ||
  6256. domUtils.isBookmarkNode(l) ||
  6257. (j.test(l.tagName)
  6258. ? c
  6259. ? (domUtils.removeStyle(l, c),
  6260. f(l) &&
  6261. 'text-decoration' != c &&
  6262. domUtils.remove(l, !0))
  6263. : domUtils.remove(l, !0)
  6264. : dtd.$tableContent[l.tagName] ||
  6265. dtd.$list[l.tagName] ||
  6266. (domUtils.removeAttributes(l, k),
  6267. f(l) && domUtils.remove(l, !0))),
  6268. (l = g)
  6269. }
  6270. var n = h.start.parentNode
  6271. !domUtils.isBlockElm(n) ||
  6272. dtd.$tableContent[n.tagName] ||
  6273. dtd.$list[n.tagName] ||
  6274. domUtils.removeAttributes(n, k),
  6275. (n = h.end.parentNode),
  6276. h.end &&
  6277. domUtils.isBlockElm(n) &&
  6278. !dtd.$tableContent[n.tagName] &&
  6279. !dtd.$list[n.tagName] &&
  6280. domUtils.removeAttributes(n, k),
  6281. a.moveToBookmark(h).moveToBookmark(b)
  6282. for (
  6283. var o, p = a.startContainer, q = a.collapsed;
  6284. 1 == p.nodeType &&
  6285. domUtils.isEmptyNode(p) &&
  6286. dtd.$removeEmpty[p.tagName];
  6287. )
  6288. (o = p.parentNode),
  6289. a.setStartBefore(p),
  6290. a.startContainer === a.endContainer && a.endOffset--,
  6291. domUtils.remove(p),
  6292. (p = o)
  6293. if (!q)
  6294. for (
  6295. p = a.endContainer;
  6296. 1 == p.nodeType &&
  6297. domUtils.isEmptyNode(p) &&
  6298. dtd.$removeEmpty[p.tagName];
  6299. )
  6300. (o = p.parentNode),
  6301. a.setEndBefore(p),
  6302. domUtils.remove(p),
  6303. (p = o)
  6304. }
  6305. var h,
  6306. i,
  6307. j = new RegExp(
  6308. '^(?:' +
  6309. (b || this.options.removeFormatTags).replace(/,/g, '|') +
  6310. ')$',
  6311. 'i'
  6312. ),
  6313. k = c
  6314. ? []
  6315. : (d || this.options.removeFormatAttributes).split(','),
  6316. l = new dom.Range(this.document),
  6317. m = function (a) {
  6318. return 1 == a.nodeType
  6319. }
  6320. ;(l = this.selection.getRange()), g(l), l.select()
  6321. }
  6322. })
  6323. }),
  6324. (UE.plugins.blockquote = function () {
  6325. function a(a) {
  6326. return domUtils.filterNodeList(
  6327. a.selection.getStartElementPath(),
  6328. 'blockquote'
  6329. )
  6330. }
  6331. var b = this
  6332. b.commands.blockquote = {
  6333. execCommand: function (b, c) {
  6334. var d = this.selection.getRange(),
  6335. e = a(this),
  6336. f = dtd.blockquote,
  6337. g = d.createBookmark()
  6338. if (e) {
  6339. var h = d.startContainer,
  6340. i = domUtils.isBlockElm(h)
  6341. ? h
  6342. : domUtils.findParent(h, function (a) {
  6343. return domUtils.isBlockElm(a)
  6344. }),
  6345. j = d.endContainer,
  6346. k = domUtils.isBlockElm(j)
  6347. ? j
  6348. : domUtils.findParent(j, function (a) {
  6349. return domUtils.isBlockElm(a)
  6350. })
  6351. ;(i = domUtils.findParentByTagName(i, 'li', !0) || i),
  6352. (k = domUtils.findParentByTagName(k, 'li', !0) || k),
  6353. 'LI' == i.tagName ||
  6354. 'TD' == i.tagName ||
  6355. i === e ||
  6356. domUtils.isBody(i)
  6357. ? domUtils.remove(e, !0)
  6358. : domUtils.breakParent(i, e),
  6359. i !== k &&
  6360. ((e = domUtils.findParentByTagName(k, 'blockquote')),
  6361. e &&
  6362. ('LI' == k.tagName || 'TD' == k.tagName || domUtils.isBody(k)
  6363. ? e.parentNode && domUtils.remove(e, !0)
  6364. : domUtils.breakParent(k, e)))
  6365. for (
  6366. var l,
  6367. m = domUtils.getElementsByTagName(this.document, 'blockquote'),
  6368. n = 0;
  6369. (l = m[n++]);
  6370. )
  6371. l.childNodes.length
  6372. ? domUtils.getPosition(l, i) & domUtils.POSITION_FOLLOWING &&
  6373. domUtils.getPosition(l, k) & domUtils.POSITION_PRECEDING &&
  6374. domUtils.remove(l, !0)
  6375. : domUtils.remove(l)
  6376. } else {
  6377. for (
  6378. var o = d.cloneRange(),
  6379. p =
  6380. 1 == o.startContainer.nodeType
  6381. ? o.startContainer
  6382. : o.startContainer.parentNode,
  6383. q = p,
  6384. r = 1;
  6385. ;
  6386. ) {
  6387. if (domUtils.isBody(p)) {
  6388. q !== p
  6389. ? d.collapsed
  6390. ? (o.selectNode(q), (r = 0))
  6391. : o.setStartBefore(q)
  6392. : o.setStart(p, 0)
  6393. break
  6394. }
  6395. if (!f[p.tagName]) {
  6396. d.collapsed ? o.selectNode(q) : o.setStartBefore(q)
  6397. break
  6398. }
  6399. ;(q = p), (p = p.parentNode)
  6400. }
  6401. if (r)
  6402. for (
  6403. q =
  6404. p =
  6405. p =
  6406. 1 == o.endContainer.nodeType
  6407. ? o.endContainer
  6408. : o.endContainer.parentNode;
  6409. ;
  6410. ) {
  6411. if (domUtils.isBody(p)) {
  6412. q !== p ? o.setEndAfter(q) : o.setEnd(p, p.childNodes.length)
  6413. break
  6414. }
  6415. if (!f[p.tagName]) {
  6416. o.setEndAfter(q)
  6417. break
  6418. }
  6419. ;(q = p), (p = p.parentNode)
  6420. }
  6421. ;(p = d.document.createElement('blockquote')),
  6422. domUtils.setAttributes(p, c),
  6423. p.appendChild(o.extractContents()),
  6424. o.insertNode(p)
  6425. for (
  6426. var s, t = domUtils.getElementsByTagName(p, 'blockquote'), n = 0;
  6427. (s = t[n++]);
  6428. )
  6429. s.parentNode && domUtils.remove(s, !0)
  6430. }
  6431. d.moveToBookmark(g).select()
  6432. },
  6433. queryCommandState: function () {
  6434. return a(this) ? 1 : 0
  6435. }
  6436. }
  6437. }),
  6438. (UE.commands.touppercase = UE.commands.tolowercase =
  6439. {
  6440. execCommand: function (a) {
  6441. var b = this,
  6442. c = b.selection.getRange()
  6443. if (c.collapsed) return c
  6444. for (
  6445. var d = c.createBookmark(),
  6446. e = d.end,
  6447. f = function (a) {
  6448. return !domUtils.isBr(a) && !domUtils.isWhitespace(a)
  6449. },
  6450. g = domUtils.getNextDomNode(d.start, !1, f);
  6451. g &&
  6452. domUtils.getPosition(g, e) & domUtils.POSITION_PRECEDING &&
  6453. (3 == g.nodeType &&
  6454. (g.nodeValue =
  6455. g.nodeValue[
  6456. 'touppercase' == a ? 'toUpperCase' : 'toLowerCase'
  6457. ]()),
  6458. (g = domUtils.getNextDomNode(g, !0, f)),
  6459. g !== e);
  6460. );
  6461. c.moveToBookmark(d).select()
  6462. }
  6463. }),
  6464. (UE.commands.indent = {
  6465. execCommand: function () {
  6466. var a = this,
  6467. b = a.queryCommandState('indent')
  6468. ? '0em'
  6469. : a.options.indentValue || '2em'
  6470. a.execCommand('Paragraph', 'p', { style: 'text-indent:' + b })
  6471. },
  6472. queryCommandState: function () {
  6473. var a = domUtils.filterNodeList(
  6474. this.selection.getStartElementPath(),
  6475. 'p h1 h2 h3 h4 h5 h6'
  6476. )
  6477. return a && a.style.textIndent && parseInt(a.style.textIndent) ? 1 : 0
  6478. }
  6479. }),
  6480. (UE.commands.print = {
  6481. execCommand: function () {
  6482. this.window.print()
  6483. },
  6484. notNeedUndo: 1
  6485. }),
  6486. (UE.commands.preview = {
  6487. execCommand: function () {
  6488. var a = window.open('', '_blank', ''),
  6489. b = a.document
  6490. b.open(),
  6491. b.write(
  6492. '<!DOCTYPE html><html><head><meta charset="utf-8"/><script src="' +
  6493. this.options.UEDITOR_HOME_URL +
  6494. "ueditor.parse.js\"></script><script>setTimeout(function(){uParse('div',{rootPath: '" +
  6495. this.options.UEDITOR_HOME_URL +
  6496. "'})},300)</script></head><body><div>" +
  6497. this.getContent(null, null, !0) +
  6498. '</div></body></html>'
  6499. ),
  6500. b.close()
  6501. },
  6502. notNeedUndo: 1
  6503. }),
  6504. (UE.plugins.selectall = function () {
  6505. var a = this
  6506. ;(a.commands.selectall = {
  6507. execCommand: function () {
  6508. var a = this,
  6509. b = a.body,
  6510. c = a.selection.getRange()
  6511. c.selectNodeContents(b),
  6512. domUtils.isEmptyBlock(b) &&
  6513. (browser.opera &&
  6514. b.firstChild &&
  6515. 1 == b.firstChild.nodeType &&
  6516. c.setStartAtFirst(b.firstChild),
  6517. c.collapse(!0)),
  6518. c.select(!0)
  6519. },
  6520. notNeedUndo: 1
  6521. }),
  6522. a.addshortcutkey({ selectAll: 'ctrl+65' })
  6523. }),
  6524. (UE.plugins.paragraph = function () {
  6525. var a = this,
  6526. b = domUtils.isBlockElm,
  6527. c = ['TD', 'LI', 'PRE'],
  6528. d = function (a, d, e, f) {
  6529. var g,
  6530. h = a.createBookmark(),
  6531. i = function (a) {
  6532. return 1 == a.nodeType
  6533. ? 'br' != a.tagName.toLowerCase() && !domUtils.isBookmarkNode(a)
  6534. : !domUtils.isWhitespace(a)
  6535. }
  6536. a.enlarge(!0)
  6537. for (
  6538. var j,
  6539. k = a.createBookmark(),
  6540. l = domUtils.getNextDomNode(k.start, !1, i),
  6541. m = a.cloneRange();
  6542. l &&
  6543. !(domUtils.getPosition(l, k.end) & domUtils.POSITION_FOLLOWING);
  6544. )
  6545. if (3 != l.nodeType && b(l)) l = domUtils.getNextDomNode(l, !0, i)
  6546. else {
  6547. for (m.setStartBefore(l); l && l !== k.end && !b(l); )
  6548. (j = l),
  6549. (l = domUtils.getNextDomNode(l, !1, null, function (a) {
  6550. return !b(a)
  6551. }))
  6552. m.setEndAfter(j),
  6553. (g = a.document.createElement(d)),
  6554. e &&
  6555. (domUtils.setAttributes(g, e),
  6556. f &&
  6557. 'customstyle' == f &&
  6558. e.style &&
  6559. (g.style.cssText = e.style)),
  6560. g.appendChild(m.extractContents()),
  6561. domUtils.isEmptyNode(g) && domUtils.fillChar(a.document, g),
  6562. m.insertNode(g)
  6563. var n = g.parentNode
  6564. b(n) &&
  6565. !domUtils.isBody(g.parentNode) &&
  6566. utils.indexOf(c, n.tagName) == -1 &&
  6567. ((f && 'customstyle' == f) ||
  6568. (n.getAttribute('dir') &&
  6569. g.setAttribute('dir', n.getAttribute('dir')),
  6570. n.style.cssText &&
  6571. (g.style.cssText = n.style.cssText + ';' + g.style.cssText),
  6572. n.style.textAlign &&
  6573. !g.style.textAlign &&
  6574. (g.style.textAlign = n.style.textAlign),
  6575. n.style.textIndent &&
  6576. !g.style.textIndent &&
  6577. (g.style.textIndent = n.style.textIndent),
  6578. n.style.padding &&
  6579. !g.style.padding &&
  6580. (g.style.padding = n.style.padding)),
  6581. e && /h\d/i.test(n.tagName) && !/h\d/i.test(g.tagName)
  6582. ? (domUtils.setAttributes(n, e),
  6583. f &&
  6584. 'customstyle' == f &&
  6585. e.style &&
  6586. (n.style.cssText = e.style),
  6587. domUtils.remove(g, !0),
  6588. (g = n))
  6589. : domUtils.remove(g.parentNode, !0)),
  6590. (l = utils.indexOf(c, n.tagName) != -1 ? n : g),
  6591. (l = domUtils.getNextDomNode(l, !1, i))
  6592. }
  6593. return a.moveToBookmark(k).moveToBookmark(h)
  6594. }
  6595. a.setOpt('paragraph', {
  6596. p: '',
  6597. h1: '',
  6598. h2: '',
  6599. h3: '',
  6600. h4: '',
  6601. h5: '',
  6602. h6: ''
  6603. }),
  6604. (a.commands.paragraph = {
  6605. execCommand: function (a, b, c, e) {
  6606. var f = this.selection.getRange()
  6607. if (f.collapsed) {
  6608. var g = this.document.createTextNode('p')
  6609. if ((f.insertNode(g), browser.ie)) {
  6610. var h = g.previousSibling
  6611. h && domUtils.isWhitespace(h) && domUtils.remove(h),
  6612. (h = g.nextSibling),
  6613. h && domUtils.isWhitespace(h) && domUtils.remove(h)
  6614. }
  6615. }
  6616. if (
  6617. ((f = d(f, b, c, e)),
  6618. g &&
  6619. (f.setStartBefore(g).collapse(!0),
  6620. (pN = g.parentNode),
  6621. domUtils.remove(g),
  6622. domUtils.isBlockElm(pN) &&
  6623. domUtils.isEmptyNode(pN) &&
  6624. domUtils.fillNode(this.document, pN)),
  6625. browser.gecko && f.collapsed && 1 == f.startContainer.nodeType)
  6626. ) {
  6627. var i = f.startContainer.childNodes[f.startOffset]
  6628. i &&
  6629. 1 == i.nodeType &&
  6630. i.tagName.toLowerCase() == b &&
  6631. f.setStart(i, 0).collapse(!0)
  6632. }
  6633. return f.select(), !0
  6634. },
  6635. queryCommandValue: function () {
  6636. var a = domUtils.filterNodeList(
  6637. this.selection.getStartElementPath(),
  6638. 'p h1 h2 h3 h4 h5 h6'
  6639. )
  6640. return a ? a.tagName.toLowerCase() : ''
  6641. }
  6642. })
  6643. }),
  6644. (function () {
  6645. var a = domUtils.isBlockElm,
  6646. b = function (a) {
  6647. return domUtils.filterNodeList(
  6648. a.selection.getStartElementPath(),
  6649. function (a) {
  6650. return a && 1 == a.nodeType && a.getAttribute('dir')
  6651. }
  6652. )
  6653. },
  6654. c = function (c, d, e) {
  6655. var f,
  6656. g = function (a) {
  6657. return 1 == a.nodeType
  6658. ? !domUtils.isBookmarkNode(a)
  6659. : !domUtils.isWhitespace(a)
  6660. },
  6661. h = b(d)
  6662. if (h && c.collapsed) return h.setAttribute('dir', e), c
  6663. ;(f = c.createBookmark()), c.enlarge(!0)
  6664. for (
  6665. var i,
  6666. j = c.createBookmark(),
  6667. k = domUtils.getNextDomNode(j.start, !1, g),
  6668. l = c.cloneRange();
  6669. k &&
  6670. !(domUtils.getPosition(k, j.end) & domUtils.POSITION_FOLLOWING);
  6671. )
  6672. if (3 != k.nodeType && a(k)) k = domUtils.getNextDomNode(k, !0, g)
  6673. else {
  6674. for (l.setStartBefore(k); k && k !== j.end && !a(k); )
  6675. (i = k),
  6676. (k = domUtils.getNextDomNode(k, !1, null, function (b) {
  6677. return !a(b)
  6678. }))
  6679. l.setEndAfter(i)
  6680. var m = l.getCommonAncestor()
  6681. if (!domUtils.isBody(m) && a(m)) m.setAttribute('dir', e), (k = m)
  6682. else {
  6683. var n = c.document.createElement('p')
  6684. n.setAttribute('dir', e)
  6685. var o = l.extractContents()
  6686. n.appendChild(o), l.insertNode(n), (k = n)
  6687. }
  6688. k = domUtils.getNextDomNode(k, !1, g)
  6689. }
  6690. return c.moveToBookmark(j).moveToBookmark(f)
  6691. }
  6692. UE.commands.directionality = {
  6693. execCommand: function (a, b) {
  6694. var d = this.selection.getRange()
  6695. if (d.collapsed) {
  6696. var e = this.document.createTextNode('d')
  6697. d.insertNode(e)
  6698. }
  6699. return (
  6700. c(d, this, b),
  6701. e && (d.setStartBefore(e).collapse(!0), domUtils.remove(e)),
  6702. d.select(),
  6703. !0
  6704. )
  6705. },
  6706. queryCommandValue: function () {
  6707. var a = b(this)
  6708. return a ? a.getAttribute('dir') : 'ltr'
  6709. }
  6710. }
  6711. })(),
  6712. (UE.plugins.horizontal = function () {
  6713. var a = this
  6714. ;(a.commands.horizontal = {
  6715. execCommand: function (a) {
  6716. var b = this
  6717. if (b.queryCommandState(a) !== -1) {
  6718. b.execCommand('insertHtml', '<hr>')
  6719. var c = b.selection.getRange(),
  6720. d = c.startContainer
  6721. if (1 == d.nodeType && !d.childNodes[c.startOffset]) {
  6722. var e
  6723. ;(e = d.childNodes[c.startOffset - 1]) &&
  6724. 1 == e.nodeType &&
  6725. 'HR' == e.tagName &&
  6726. ('p' == b.options.enterTag
  6727. ? ((e = b.document.createElement('p')),
  6728. c.insertNode(e),
  6729. c.setStart(e, 0).setCursor())
  6730. : ((e = b.document.createElement('br')),
  6731. c.insertNode(e),
  6732. c.setStartBefore(e).setCursor()))
  6733. }
  6734. return !0
  6735. }
  6736. },
  6737. queryCommandState: function () {
  6738. return domUtils.filterNodeList(
  6739. this.selection.getStartElementPath(),
  6740. 'table'
  6741. )
  6742. ? -1
  6743. : 0
  6744. }
  6745. }),
  6746. a.addListener('delkeydown', function (a, b) {
  6747. var c = this.selection.getRange()
  6748. if ((c.txtToElmBoundary(!0), domUtils.isStartInblock(c))) {
  6749. var d = c.startContainer,
  6750. e = d.previousSibling
  6751. if (e && domUtils.isTagNode(e, 'hr'))
  6752. return (
  6753. domUtils.remove(e), c.select(), domUtils.preventDefault(b), !0
  6754. )
  6755. }
  6756. })
  6757. }),
  6758. (UE.commands.time = UE.commands.date =
  6759. {
  6760. execCommand: function (a, b) {
  6761. function c(a, b) {
  6762. var c = ('0' + a.getHours()).slice(-2),
  6763. d = ('0' + a.getMinutes()).slice(-2),
  6764. e = ('0' + a.getSeconds()).slice(-2)
  6765. return (
  6766. (b = b || 'hh:ii:ss'),
  6767. b.replace(/hh/gi, c).replace(/ii/gi, d).replace(/ss/gi, e)
  6768. )
  6769. }
  6770. function d(a, b) {
  6771. var c = ('000' + a.getFullYear()).slice(-4),
  6772. d = c.slice(-2),
  6773. e = ('0' + (a.getMonth() + 1)).slice(-2),
  6774. f = ('0' + a.getDate()).slice(-2)
  6775. return (
  6776. (b = b || 'yyyy-mm-dd'),
  6777. b
  6778. .replace(/yyyy/gi, c)
  6779. .replace(/yy/gi, d)
  6780. .replace(/mm/gi, e)
  6781. .replace(/dd/gi, f)
  6782. )
  6783. }
  6784. var e = new Date()
  6785. this.execCommand('insertHtml', 'time' == a ? c(e, b) : d(e, b))
  6786. }
  6787. }),
  6788. (UE.plugins.rowspacing = function () {
  6789. var a = this
  6790. a.setOpt({
  6791. rowspacingtop: ['5', '10', '15', '20', '25'],
  6792. rowspacingbottom: ['5', '10', '15', '20', '25']
  6793. }),
  6794. (a.commands.rowspacing = {
  6795. execCommand: function (a, b, c) {
  6796. return (
  6797. this.execCommand('paragraph', 'p', {
  6798. style: 'margin-' + c + ':' + b + 'px'
  6799. }),
  6800. !0
  6801. )
  6802. },
  6803. queryCommandValue: function (a, b) {
  6804. var c,
  6805. d = domUtils.filterNodeList(
  6806. this.selection.getStartElementPath(),
  6807. function (a) {
  6808. return domUtils.isBlockElm(a)
  6809. }
  6810. )
  6811. return d
  6812. ? ((c = domUtils
  6813. .getComputedStyle(d, 'margin-' + b)
  6814. .replace(/[^\d]/g, '')),
  6815. c ? c : 0)
  6816. : 0
  6817. }
  6818. })
  6819. }),
  6820. (UE.plugins.lineheight = function () {
  6821. var a = this
  6822. a.setOpt({ lineheight: ['1', '1.5', '1.75', '2', '3', '4', '5'] }),
  6823. (a.commands.lineheight = {
  6824. execCommand: function (a, b) {
  6825. return (
  6826. this.execCommand('paragraph', 'p', {
  6827. style: 'line-height:' + ('1' == b ? 'normal' : b + 'em')
  6828. }),
  6829. !0
  6830. )
  6831. },
  6832. queryCommandValue: function () {
  6833. var a = domUtils.filterNodeList(
  6834. this.selection.getStartElementPath(),
  6835. function (a) {
  6836. return domUtils.isBlockElm(a)
  6837. }
  6838. )
  6839. if (a) {
  6840. var b = domUtils.getComputedStyle(a, 'line-height')
  6841. return 'normal' == b ? 1 : b.replace(/[^\d.]*/gi, '')
  6842. }
  6843. }
  6844. })
  6845. }),
  6846. (UE.plugins.insertcode = function () {
  6847. var a = this
  6848. a.ready(function () {
  6849. utils.cssRule(
  6850. 'pre',
  6851. 'pre{margin:.5em 0;padding:.4em .6em;border-radius:8px;background:#f8f8f8;}',
  6852. a.document
  6853. )
  6854. }),
  6855. a.setOpt('insertcode', {
  6856. as3: 'ActionScript3',
  6857. bash: 'Bash/Shell',
  6858. cpp: 'C/C++',
  6859. css: 'Css',
  6860. cf: 'CodeFunction',
  6861. 'c#': 'C#',
  6862. delphi: 'Delphi',
  6863. diff: 'Diff',
  6864. erlang: 'Erlang',
  6865. groovy: 'Groovy',
  6866. html: 'Html',
  6867. java: 'Java',
  6868. jfx: 'JavaFx',
  6869. js: 'Javascript',
  6870. pl: 'Perl',
  6871. php: 'Php',
  6872. plain: 'Plain Text',
  6873. ps: 'PowerShell',
  6874. python: 'Python',
  6875. ruby: 'Ruby',
  6876. scala: 'Scala',
  6877. sql: 'Sql',
  6878. vb: 'Vb',
  6879. xml: 'Xml'
  6880. }),
  6881. (a.commands.insertcode = {
  6882. execCommand: function (a, b) {
  6883. var c = this,
  6884. d = c.selection.getRange(),
  6885. e = domUtils.findParentByTagName(d.startContainer, 'pre', !0)
  6886. if (e) e.className = 'brush:' + b + ';toolbar:false;'
  6887. else {
  6888. var f = ''
  6889. if (d.collapsed)
  6890. f =
  6891. browser.ie && browser.ie11below
  6892. ? browser.version <= 8
  6893. ? '&nbsp;'
  6894. : ''
  6895. : '<br/>'
  6896. else {
  6897. var g = d.extractContents(),
  6898. h = c.document.createElement('div')
  6899. h.appendChild(g),
  6900. utils.each(
  6901. UE.filterNode(
  6902. UE.htmlparser(h.innerHTML.replace(/[\r\t]/g, '')),
  6903. c.options.filterTxtRules
  6904. ).children,
  6905. function (a) {
  6906. if (
  6907. browser.ie &&
  6908. browser.ie11below &&
  6909. browser.version > 8
  6910. )
  6911. 'element' == a.type
  6912. ? 'br' == a.tagName
  6913. ? (f += '\n')
  6914. : dtd.$empty[a.tagName] ||
  6915. (utils.each(a.children, function (b) {
  6916. 'element' == b.type
  6917. ? 'br' == b.tagName
  6918. ? (f += '\n')
  6919. : dtd.$empty[a.tagName] ||
  6920. (f += b.innerText())
  6921. : (f += b.data)
  6922. }),
  6923. /\n$/.test(f) || (f += '\n'))
  6924. : (f += a.data + '\n'),
  6925. !a.nextSibling() &&
  6926. /\n$/.test(f) &&
  6927. (f = f.replace(/\n$/, ''))
  6928. else if (browser.ie && browser.ie11below)
  6929. 'element' == a.type
  6930. ? 'br' == a.tagName
  6931. ? (f += '<br>')
  6932. : dtd.$empty[a.tagName] ||
  6933. (utils.each(a.children, function (b) {
  6934. 'element' == b.type
  6935. ? 'br' == b.tagName
  6936. ? (f += '<br>')
  6937. : dtd.$empty[a.tagName] ||
  6938. (f += b.innerText())
  6939. : (f += b.data)
  6940. }),
  6941. /br>$/.test(f) || (f += '<br>'))
  6942. : (f += a.data + '<br>'),
  6943. !a.nextSibling() &&
  6944. /<br>$/.test(f) &&
  6945. (f = f.replace(/<br>$/, ''))
  6946. else if (
  6947. ((f +=
  6948. 'element' == a.type
  6949. ? dtd.$empty[a.tagName]
  6950. ? ''
  6951. : a.innerText()
  6952. : a.data),
  6953. !/br\/?\s*>$/.test(f))
  6954. ) {
  6955. if (!a.nextSibling()) return
  6956. f += '<br>'
  6957. }
  6958. }
  6959. )
  6960. }
  6961. c.execCommand(
  6962. 'inserthtml',
  6963. '<pre id="coder"class="brush:' +
  6964. b +
  6965. ';toolbar:false">' +
  6966. f +
  6967. '</pre>',
  6968. !0
  6969. ),
  6970. (e = c.document.getElementById('coder')),
  6971. domUtils.removeAttributes(e, 'id')
  6972. var i = e.previousSibling
  6973. i &&
  6974. ((3 == i.nodeType &&
  6975. 1 == i.nodeValue.length &&
  6976. browser.ie &&
  6977. 6 == browser.version) ||
  6978. domUtils.isEmptyBlock(i)) &&
  6979. domUtils.remove(i)
  6980. var d = c.selection.getRange()
  6981. domUtils.isEmptyBlock(e)
  6982. ? d.setStart(e, 0).setCursor(!1, !0)
  6983. : d.selectNodeContents(e).select()
  6984. }
  6985. },
  6986. queryCommandValue: function () {
  6987. var a = this.selection.getStartElementPath(),
  6988. b = ''
  6989. return (
  6990. utils.each(a, function (a) {
  6991. if ('PRE' == a.nodeName) {
  6992. var c = a.className.match(/brush:([^;]+)/)
  6993. return (b = c && c[1] ? c[1] : ''), !1
  6994. }
  6995. }),
  6996. b
  6997. )
  6998. }
  6999. }),
  7000. a.addInputRule(function (a) {
  7001. utils.each(a.getNodesByTagName('pre'), function (a) {
  7002. var b = a.getNodesByTagName('br')
  7003. if (b.length)
  7004. return void (
  7005. browser.ie &&
  7006. browser.ie11below &&
  7007. browser.version > 8 &&
  7008. utils.each(b, function (a) {
  7009. var b = UE.uNode.createText('\n')
  7010. a.parentNode.insertBefore(b, a), a.parentNode.removeChild(a)
  7011. })
  7012. )
  7013. if (!(browser.ie && browser.ie11below && browser.version > 8)) {
  7014. var c = a.innerText().split(/\n/)
  7015. a.innerHTML(''),
  7016. utils.each(c, function (b) {
  7017. b.length && a.appendChild(UE.uNode.createText(b)),
  7018. a.appendChild(UE.uNode.createElement('br'))
  7019. })
  7020. }
  7021. })
  7022. }),
  7023. a.addOutputRule(function (a) {
  7024. utils.each(a.getNodesByTagName('pre'), function (a) {
  7025. var b = ''
  7026. utils.each(a.children, function (a) {
  7027. b +=
  7028. 'text' == a.type
  7029. ? a.data.replace(/[ ]/g, '&nbsp;').replace(/\n$/, '')
  7030. : 'br' == a.tagName
  7031. ? '\n'
  7032. : dtd.$empty[a.tagName]
  7033. ? a.innerText()
  7034. : ''
  7035. }),
  7036. a.innerText(b.replace(/(&nbsp;|\n)+$/, ''))
  7037. })
  7038. }),
  7039. (a.notNeedCodeQuery = {
  7040. help: 1,
  7041. undo: 1,
  7042. redo: 1,
  7043. source: 1,
  7044. print: 1,
  7045. searchreplace: 1,
  7046. fullscreen: 1,
  7047. preview: 1,
  7048. insertparagraph: 1,
  7049. elementpath: 1,
  7050. insertcode: 1,
  7051. inserthtml: 1,
  7052. selectall: 1
  7053. })
  7054. a.queryCommandState
  7055. ;(a.queryCommandState = function (a) {
  7056. var b = this
  7057. return !b.notNeedCodeQuery[a.toLowerCase()] &&
  7058. b.selection &&
  7059. b.queryCommandValue('insertcode')
  7060. ? -1
  7061. : UE.Editor.prototype.queryCommandState.apply(this, arguments)
  7062. }),
  7063. a.addListener('beforeenterkeydown', function () {
  7064. var b = a.selection.getRange(),
  7065. c = domUtils.findParentByTagName(b.startContainer, 'pre', !0)
  7066. if (c) {
  7067. if (
  7068. (a.fireEvent('saveScene'),
  7069. b.collapsed || b.deleteContents(),
  7070. !browser.ie || browser.ie9above)
  7071. ) {
  7072. var c,
  7073. d = a.document.createElement('br')
  7074. b.insertNode(d).setStartAfter(d).collapse(!0)
  7075. var e = d.nextSibling
  7076. e || (browser.ie && !(browser.version > 10))
  7077. ? b.setStartAfter(d)
  7078. : b.insertNode(d.cloneNode(!1)),
  7079. (c = d.previousSibling)
  7080. for (var f; c; )
  7081. if (
  7082. ((f = c), (c = c.previousSibling), !c || 'BR' == c.nodeName)
  7083. ) {
  7084. c = f
  7085. break
  7086. }
  7087. if (c) {
  7088. for (
  7089. var g = '';
  7090. c &&
  7091. 'BR' != c.nodeName &&
  7092. new RegExp('^[\\s' + domUtils.fillChar + ']*$').test(
  7093. c.nodeValue
  7094. );
  7095. )
  7096. (g += c.nodeValue), (c = c.nextSibling)
  7097. if ('BR' != c.nodeName) {
  7098. var h = c.nodeValue.match(
  7099. new RegExp('^([\\s' + domUtils.fillChar + ']+)')
  7100. )
  7101. h && h[1] && (g += h[1])
  7102. }
  7103. g &&
  7104. ((g = a.document.createTextNode(g)),
  7105. b.insertNode(g).setStartAfter(g))
  7106. }
  7107. b.collapse(!0).select(!0)
  7108. } else if (browser.version > 8) {
  7109. var i = a.document.createTextNode('\n'),
  7110. j = b.startContainer
  7111. if (0 == b.startOffset) {
  7112. var k = j.previousSibling
  7113. if (k) {
  7114. b.insertNode(i)
  7115. var l = a.document.createTextNode(' ')
  7116. b.setStartAfter(i)
  7117. .insertNode(l)
  7118. .setStart(l, 0)
  7119. .collapse(!0)
  7120. .select(!0)
  7121. }
  7122. } else {
  7123. b.insertNode(i).setStartAfter(i)
  7124. var l = a.document.createTextNode(' ')
  7125. ;(j = b.startContainer.childNodes[b.startOffset]),
  7126. j && !/^\n/.test(j.nodeValue) && b.setStartBefore(i),
  7127. b.insertNode(l).setStart(l, 0).collapse(!0).select(!0)
  7128. }
  7129. } else {
  7130. var d = a.document.createElement('br')
  7131. b.insertNode(d),
  7132. b.insertNode(a.document.createTextNode(domUtils.fillChar)),
  7133. b.setStartAfter(d),
  7134. (c = d.previousSibling)
  7135. for (var f; c; )
  7136. if (
  7137. ((f = c), (c = c.previousSibling), !c || 'BR' == c.nodeName)
  7138. ) {
  7139. c = f
  7140. break
  7141. }
  7142. if (c) {
  7143. for (
  7144. var g = '';
  7145. c &&
  7146. 'BR' != c.nodeName &&
  7147. new RegExp('^[ ' + domUtils.fillChar + ']*$').test(
  7148. c.nodeValue
  7149. );
  7150. )
  7151. (g += c.nodeValue), (c = c.nextSibling)
  7152. if ('BR' != c.nodeName) {
  7153. var h = c.nodeValue.match(
  7154. new RegExp('^([ ' + domUtils.fillChar + ']+)')
  7155. )
  7156. h && h[1] && (g += h[1])
  7157. }
  7158. ;(g = a.document.createTextNode(g)),
  7159. b.insertNode(g).setStartAfter(g)
  7160. }
  7161. b.collapse(!0).select()
  7162. }
  7163. return a.fireEvent('saveScene'), !0
  7164. }
  7165. }),
  7166. a.addListener('tabkeydown', function (b, c) {
  7167. var d = a.selection.getRange(),
  7168. e = domUtils.findParentByTagName(d.startContainer, 'pre', !0)
  7169. if (e) {
  7170. if ((a.fireEvent('saveScene'), c.shiftKey));
  7171. else if (d.collapsed) {
  7172. var f = a.document.createTextNode(' ')
  7173. d.insertNode(f).setStartAfter(f).collapse(!0).select(!0)
  7174. } else {
  7175. for (
  7176. var g = d.createBookmark(), h = g.start.previousSibling;
  7177. h;
  7178. ) {
  7179. if (e.firstChild === h && !domUtils.isBr(h)) {
  7180. e.insertBefore(a.document.createTextNode(' '), h)
  7181. break
  7182. }
  7183. if (domUtils.isBr(h)) {
  7184. e.insertBefore(
  7185. a.document.createTextNode(' '),
  7186. h.nextSibling
  7187. )
  7188. break
  7189. }
  7190. h = h.previousSibling
  7191. }
  7192. var i = g.end
  7193. for (
  7194. h = g.start.nextSibling,
  7195. e.firstChild === g.start &&
  7196. e.insertBefore(
  7197. a.document.createTextNode(' '),
  7198. h.nextSibling
  7199. );
  7200. h && h !== i;
  7201. ) {
  7202. if (domUtils.isBr(h) && h.nextSibling) {
  7203. if (h.nextSibling === i) break
  7204. e.insertBefore(
  7205. a.document.createTextNode(' '),
  7206. h.nextSibling
  7207. )
  7208. }
  7209. h = h.nextSibling
  7210. }
  7211. d.moveToBookmark(g).select()
  7212. }
  7213. return a.fireEvent('saveScene'), !0
  7214. }
  7215. }),
  7216. a.addListener('beforeinserthtml', function (a, b) {
  7217. var c = this,
  7218. d = c.selection.getRange(),
  7219. e = domUtils.findParentByTagName(d.startContainer, 'pre', !0)
  7220. if (e) {
  7221. d.collapsed || d.deleteContents()
  7222. var f = ''
  7223. if (browser.ie && browser.version > 8) {
  7224. utils.each(
  7225. UE.filterNode(UE.htmlparser(b), c.options.filterTxtRules)
  7226. .children,
  7227. function (a) {
  7228. 'element' == a.type
  7229. ? 'br' == a.tagName
  7230. ? (f += '\n')
  7231. : dtd.$empty[a.tagName] ||
  7232. (utils.each(a.children, function (b) {
  7233. 'element' == b.type
  7234. ? 'br' == b.tagName
  7235. ? (f += '\n')
  7236. : dtd.$empty[a.tagName] || (f += b.innerText())
  7237. : (f += b.data)
  7238. }),
  7239. /\n$/.test(f) || (f += '\n'))
  7240. : (f += a.data + '\n'),
  7241. !a.nextSibling() &&
  7242. /\n$/.test(f) &&
  7243. (f = f.replace(/\n$/, ''))
  7244. }
  7245. )
  7246. var g = c.document.createTextNode(
  7247. utils.html(f.replace(/&nbsp;/g, ' '))
  7248. )
  7249. d.insertNode(g).selectNode(g).select()
  7250. } else {
  7251. var h = c.document.createDocumentFragment()
  7252. utils.each(
  7253. UE.filterNode(UE.htmlparser(b), c.options.filterTxtRules)
  7254. .children,
  7255. function (a) {
  7256. 'element' == a.type
  7257. ? 'br' == a.tagName
  7258. ? h.appendChild(c.document.createElement('br'))
  7259. : dtd.$empty[a.tagName] ||
  7260. (utils.each(a.children, function (b) {
  7261. 'element' == b.type
  7262. ? 'br' == b.tagName
  7263. ? h.appendChild(c.document.createElement('br'))
  7264. : dtd.$empty[a.tagName] ||
  7265. h.appendChild(
  7266. c.document.createTextNode(
  7267. utils.html(
  7268. b.innerText().replace(/&nbsp;/g, ' ')
  7269. )
  7270. )
  7271. )
  7272. : h.appendChild(
  7273. c.document.createTextNode(
  7274. utils.html(b.data.replace(/&nbsp;/g, ' '))
  7275. )
  7276. )
  7277. }),
  7278. 'BR' != h.lastChild.nodeName &&
  7279. h.appendChild(c.document.createElement('br')))
  7280. : h.appendChild(
  7281. c.document.createTextNode(
  7282. utils.html(a.data.replace(/&nbsp;/g, ' '))
  7283. )
  7284. ),
  7285. a.nextSibling() ||
  7286. 'BR' != h.lastChild.nodeName ||
  7287. h.removeChild(h.lastChild)
  7288. }
  7289. ),
  7290. d.insertNode(h).select()
  7291. }
  7292. return !0
  7293. }
  7294. }),
  7295. a.addListener('keydown', function (a, b) {
  7296. var c = this,
  7297. d = b.keyCode || b.which
  7298. if (40 == d) {
  7299. var e,
  7300. f = c.selection.getRange(),
  7301. g = f.startContainer
  7302. if (
  7303. f.collapsed &&
  7304. (e = domUtils.findParentByTagName(f.startContainer, 'pre', !0)) &&
  7305. !e.nextSibling
  7306. ) {
  7307. for (var h = e.lastChild; h && 'BR' == h.nodeName; )
  7308. h = h.previousSibling
  7309. ;(h === g ||
  7310. (f.startContainer === e &&
  7311. f.startOffset == e.childNodes.length)) &&
  7312. (c.execCommand('insertparagraph'), domUtils.preventDefault(b))
  7313. }
  7314. }
  7315. }),
  7316. a.addListener('delkeydown', function (b, c) {
  7317. var d = this.selection.getRange()
  7318. d.txtToElmBoundary(!0)
  7319. var e = d.startContainer
  7320. if (
  7321. domUtils.isTagNode(e, 'pre') &&
  7322. d.collapsed &&
  7323. domUtils.isStartInblock(d)
  7324. ) {
  7325. var f = a.document.createElement('p')
  7326. return (
  7327. domUtils.fillNode(a.document, f),
  7328. e.parentNode.insertBefore(f, e),
  7329. domUtils.remove(e),
  7330. d.setStart(f, 0).setCursor(!1, !0),
  7331. domUtils.preventDefault(c),
  7332. !0
  7333. )
  7334. }
  7335. })
  7336. }),
  7337. (UE.commands.cleardoc = {
  7338. execCommand: function (a) {
  7339. var b = this,
  7340. c = b.options.enterTag,
  7341. d = b.selection.getRange()
  7342. 'br' == c
  7343. ? ((b.body.innerHTML = '<br/>'), d.setStart(b.body, 0).setCursor())
  7344. : ((b.body.innerHTML = '<p>' + (ie ? '' : '<br/>') + '</p>'),
  7345. d.setStart(b.body.firstChild, 0).setCursor(!1, !0)),
  7346. setTimeout(function () {
  7347. b.fireEvent('clearDoc')
  7348. }, 0)
  7349. }
  7350. }),
  7351. UE.plugin.register('anchor', function () {
  7352. return {
  7353. bindEvents: {
  7354. ready: function () {
  7355. utils.cssRule(
  7356. 'anchor',
  7357. ".anchorclass{background: url('" +
  7358. this.options.themePath +
  7359. this.options.theme +
  7360. "/images/anchor.gif') no-repeat scroll left center transparent;cursor: auto;display: inline-block;height: 16px;width: 15px;}",
  7361. this.document
  7362. )
  7363. }
  7364. },
  7365. outputRule: function (a) {
  7366. utils.each(a.getNodesByTagName('img'), function (a) {
  7367. var b
  7368. ;(b = a.getAttr('anchorname')) &&
  7369. ((a.tagName = 'a'),
  7370. a.setAttr({ anchorname: '', name: b, class: '' }))
  7371. })
  7372. },
  7373. inputRule: function (a) {
  7374. utils.each(a.getNodesByTagName('a'), function (a) {
  7375. var b
  7376. ;(b = a.getAttr('name')) &&
  7377. !a.getAttr('href') &&
  7378. ((a.tagName = 'img'),
  7379. a.setAttr({
  7380. anchorname: a.getAttr('name'),
  7381. class: 'anchorclass'
  7382. }),
  7383. a.setAttr('name'))
  7384. })
  7385. },
  7386. commands: {
  7387. anchor: {
  7388. execCommand: function (a, b) {
  7389. var c = this.selection.getRange(),
  7390. d = c.getClosedNode()
  7391. if (d && d.getAttribute('anchorname'))
  7392. b
  7393. ? d.setAttribute('anchorname', b)
  7394. : (c.setStartBefore(d).setCursor(), domUtils.remove(d))
  7395. else if (b) {
  7396. var e = this.document.createElement('img')
  7397. c.collapse(!0),
  7398. domUtils.setAttributes(e, {
  7399. anchorname: b,
  7400. class: 'anchorclass'
  7401. }),
  7402. c.insertNode(e).setStartAfter(e).setCursor(!1, !0)
  7403. }
  7404. }
  7405. }
  7406. }
  7407. }
  7408. }),
  7409. (UE.plugins.wordcount = function () {
  7410. var a = this
  7411. a.setOpt('wordCount', !0),
  7412. a.addListener('contentchange', function () {
  7413. a.fireEvent('wordcount')
  7414. })
  7415. var b
  7416. a.addListener('ready', function () {
  7417. var a = this
  7418. domUtils.on(a.body, 'keyup', function (c) {
  7419. var d = c.keyCode || c.which,
  7420. e = { 16: 1, 18: 1, 20: 1, 37: 1, 38: 1, 39: 1, 40: 1 }
  7421. d in e ||
  7422. (clearTimeout(b),
  7423. (b = setTimeout(function () {
  7424. a.fireEvent('wordcount')
  7425. }, 200)))
  7426. })
  7427. })
  7428. }),
  7429. (UE.plugins.pagebreak = function () {
  7430. function a(a) {
  7431. if (domUtils.isEmptyBlock(a)) {
  7432. for (
  7433. var b, d = a.firstChild;
  7434. d && 1 == d.nodeType && domUtils.isEmptyBlock(d);
  7435. )
  7436. (b = d), (d = d.firstChild)
  7437. !b && (b = a), domUtils.fillNode(c.document, b)
  7438. }
  7439. }
  7440. function b(a) {
  7441. return (
  7442. a &&
  7443. 1 == a.nodeType &&
  7444. 'HR' == a.tagName &&
  7445. 'pagebreak' == a.className
  7446. )
  7447. }
  7448. var c = this,
  7449. d = ['td']
  7450. c.setOpt('pageBreakTag', '_ueditor_page_break_tag_'),
  7451. c.ready(function () {
  7452. utils.cssRule(
  7453. 'pagebreak',
  7454. '.pagebreak{display:block;clear:both !important;cursor:default !important;width: 100% !important;margin:0;}',
  7455. c.document
  7456. )
  7457. }),
  7458. c.addInputRule(function (a) {
  7459. a.traversal(function (a) {
  7460. if ('text' == a.type && a.data == c.options.pageBreakTag) {
  7461. var b = UE.uNode.createElement(
  7462. '<hr class="pagebreak" noshade="noshade" size="5" style="-webkit-user-select: none;">'
  7463. )
  7464. a.parentNode.insertBefore(b, a), a.parentNode.removeChild(a)
  7465. }
  7466. })
  7467. }),
  7468. c.addOutputRule(function (a) {
  7469. utils.each(a.getNodesByTagName('hr'), function (a) {
  7470. if ('pagebreak' == a.getAttr('class')) {
  7471. var b = UE.uNode.createText(c.options.pageBreakTag)
  7472. a.parentNode.insertBefore(b, a), a.parentNode.removeChild(a)
  7473. }
  7474. })
  7475. }),
  7476. (c.commands.pagebreak = {
  7477. execCommand: function () {
  7478. var e = c.selection.getRange(),
  7479. f = c.document.createElement('hr')
  7480. domUtils.setAttributes(f, {
  7481. class: 'pagebreak',
  7482. noshade: 'noshade',
  7483. size: '5'
  7484. }),
  7485. domUtils.unSelectable(f)
  7486. var g,
  7487. h = domUtils.findParentByTagName(e.startContainer, d, !0),
  7488. i = []
  7489. if (h)
  7490. switch (h.tagName) {
  7491. case 'TD':
  7492. if (((g = h.parentNode), g.previousSibling))
  7493. g.parentNode.insertBefore(f, g),
  7494. (i = domUtils.findParents(f))
  7495. else {
  7496. var j = domUtils.findParentByTagName(g, 'table')
  7497. j.parentNode.insertBefore(f, j),
  7498. (i = domUtils.findParents(f, !0))
  7499. }
  7500. ;(g = i[1]),
  7501. f !== g && domUtils.breakParent(f, g),
  7502. c.fireEvent('afteradjusttable', c.document)
  7503. }
  7504. else {
  7505. if (!e.collapsed) {
  7506. e.deleteContents()
  7507. for (
  7508. var k = e.startContainer;
  7509. !domUtils.isBody(k) &&
  7510. domUtils.isBlockElm(k) &&
  7511. domUtils.isEmptyNode(k);
  7512. )
  7513. e.setStartBefore(k).collapse(!0),
  7514. domUtils.remove(k),
  7515. (k = e.startContainer)
  7516. }
  7517. e.insertNode(f)
  7518. for (var l, g = f.parentNode; !domUtils.isBody(g); )
  7519. domUtils.breakParent(f, g),
  7520. (l = f.nextSibling),
  7521. l && domUtils.isEmptyBlock(l) && domUtils.remove(l),
  7522. (g = f.parentNode)
  7523. l = f.nextSibling
  7524. var m = f.previousSibling
  7525. if ((b(m) ? domUtils.remove(m) : m && a(m), l))
  7526. b(l) ? domUtils.remove(l) : a(l), e.setEndAfter(f).collapse(!1)
  7527. else {
  7528. var n = c.document.createElement('p')
  7529. f.parentNode.appendChild(n),
  7530. domUtils.fillNode(c.document, n),
  7531. e.setStart(n, 0).collapse(!0)
  7532. }
  7533. e.select(!0)
  7534. }
  7535. }
  7536. })
  7537. }),
  7538. UE.plugin.register('wordimage', function () {
  7539. var a = this,
  7540. b = []
  7541. return {
  7542. commands: {
  7543. wordimage: {
  7544. execCommand: function () {
  7545. for (
  7546. var b,
  7547. c = domUtils.getElementsByTagName(a.body, 'img'),
  7548. d = [],
  7549. e = 0;
  7550. (b = c[e++]);
  7551. ) {
  7552. var f = b.getAttribute('word_img')
  7553. f && d.push(f)
  7554. }
  7555. return d
  7556. },
  7557. queryCommandState: function () {
  7558. b = domUtils.getElementsByTagName(a.body, 'img')
  7559. for (var c, d = 0; (c = b[d++]); )
  7560. if (c.getAttribute('word_img')) return 1
  7561. return -1
  7562. },
  7563. notNeedUndo: !0
  7564. }
  7565. },
  7566. inputRule: function (b) {
  7567. utils.each(b.getNodesByTagName('img'), function (b) {
  7568. var c = b.attrs,
  7569. d = parseInt(c.width) < 128 || parseInt(c.height) < 43,
  7570. e = a.options,
  7571. f = e.UEDITOR_HOME_URL + 'themes/default/images/spacer.gif'
  7572. c.src &&
  7573. /^(?:(file:\/+))/.test(c.src) &&
  7574. b.setAttr({
  7575. width: c.width,
  7576. height: c.height,
  7577. alt: c.alt,
  7578. word_img: c.src,
  7579. src: f,
  7580. style:
  7581. 'background:url(' +
  7582. (d
  7583. ? e.themePath + e.theme + '/images/word.gif'
  7584. : e.langPath + e.lang + '/images/localimage.png') +
  7585. ') no-repeat center center;border:1px solid #ddd'
  7586. })
  7587. })
  7588. }
  7589. }
  7590. }),
  7591. (UE.plugins.dragdrop = function () {
  7592. var a = this
  7593. a.ready(function () {
  7594. domUtils.on(this.body, 'dragend', function () {
  7595. var b = a.selection.getRange(),
  7596. c = b.getClosedNode() || a.selection.getStart()
  7597. if (c && 'IMG' == c.tagName) {
  7598. for (
  7599. var d, e = c.previousSibling;
  7600. (d = c.nextSibling) &&
  7601. 1 == d.nodeType &&
  7602. 'SPAN' == d.tagName &&
  7603. !d.firstChild;
  7604. )
  7605. domUtils.remove(d)
  7606. ;((!e || 1 != e.nodeType || domUtils.isEmptyBlock(e)) && e) ||
  7607. (d && (!d || domUtils.isEmptyBlock(d))) ||
  7608. (e && 'P' == e.tagName && !domUtils.isEmptyBlock(e)
  7609. ? (e.appendChild(c),
  7610. domUtils.moveChild(d, e),
  7611. domUtils.remove(d))
  7612. : d &&
  7613. 'P' == d.tagName &&
  7614. !domUtils.isEmptyBlock(d) &&
  7615. d.insertBefore(c, d.firstChild),
  7616. e &&
  7617. 'P' == e.tagName &&
  7618. domUtils.isEmptyBlock(e) &&
  7619. domUtils.remove(e),
  7620. d &&
  7621. 'P' == d.tagName &&
  7622. domUtils.isEmptyBlock(d) &&
  7623. domUtils.remove(d),
  7624. b.selectNode(c).select(),
  7625. a.fireEvent('saveScene'))
  7626. }
  7627. })
  7628. }),
  7629. a.addListener('keyup', function (b, c) {
  7630. var d = c.keyCode || c.which
  7631. if (13 == d) {
  7632. var e,
  7633. f = a.selection.getRange()
  7634. ;(e = domUtils.findParentByTagName(f.startContainer, 'p', !0)) &&
  7635. 'center' == domUtils.getComputedStyle(e, 'text-align') &&
  7636. domUtils.removeStyle(e, 'text-align')
  7637. }
  7638. })
  7639. }),
  7640. (UE.plugins.undo = function () {
  7641. function a(a, b) {
  7642. if (a.length != b.length) return 0
  7643. for (var c = 0, d = a.length; c < d; c++) if (a[c] != b[c]) return 0
  7644. return 1
  7645. }
  7646. function b(b, c) {
  7647. return b.collapsed != c.collapsed
  7648. ? 0
  7649. : a(b.startAddress, c.startAddress) && a(b.endAddress, c.endAddress)
  7650. ? 1
  7651. : 0
  7652. }
  7653. function c() {
  7654. ;(this.list = []),
  7655. (this.index = 0),
  7656. (this.hasUndo = !1),
  7657. (this.hasRedo = !1),
  7658. (this.undo = function () {
  7659. if (this.hasUndo) {
  7660. if (!this.list[this.index - 1] && 1 == this.list.length)
  7661. return void this.reset()
  7662. for (
  7663. ;
  7664. this.list[this.index].content ==
  7665. this.list[this.index - 1].content;
  7666. )
  7667. if ((this.index--, 0 == this.index)) return this.restore(0)
  7668. this.restore(--this.index)
  7669. }
  7670. }),
  7671. (this.redo = function () {
  7672. if (this.hasRedo) {
  7673. for (
  7674. ;
  7675. this.list[this.index].content ==
  7676. this.list[this.index + 1].content;
  7677. )
  7678. if ((this.index++, this.index == this.list.length - 1))
  7679. return this.restore(this.index)
  7680. this.restore(++this.index)
  7681. }
  7682. }),
  7683. (this.restore = function () {
  7684. var a = this.editor,
  7685. b = this.list[this.index],
  7686. c = UE.htmlparser(b.content.replace(h, ''))
  7687. ;(a.options.autoClearEmptyNode = !1),
  7688. a.filterInputRule(c),
  7689. (a.options.autoClearEmptyNode = j),
  7690. (a.document.body.innerHTML = c.toHtml()),
  7691. a.fireEvent('afterscencerestore'),
  7692. browser.ie &&
  7693. utils.each(
  7694. domUtils.getElementsByTagName(a.document, 'td th caption p'),
  7695. function (b) {
  7696. domUtils.isEmptyNode(b) && domUtils.fillNode(a.document, b)
  7697. }
  7698. )
  7699. try {
  7700. var d = new dom.Range(a.document).moveToAddress(b.address)
  7701. d.select(i[d.startContainer.nodeName.toLowerCase()])
  7702. } catch (e) {}
  7703. this.update(), this.clearKey(), a.fireEvent('reset', !0)
  7704. }),
  7705. (this.getScene = function () {
  7706. var a = this.editor,
  7707. b = a.selection.getRange(),
  7708. c = b.createAddress(!1, !0)
  7709. a.fireEvent('beforegetscene')
  7710. var d = UE.htmlparser(a.body.innerHTML)
  7711. ;(a.options.autoClearEmptyNode = !1),
  7712. a.filterOutputRule(d),
  7713. (a.options.autoClearEmptyNode = j)
  7714. var e = d.toHtml()
  7715. return a.fireEvent('aftergetscene'), { address: c, content: e }
  7716. }),
  7717. (this.save = function (a, c) {
  7718. clearTimeout(d)
  7719. var g = this.getScene(c),
  7720. h = this.list[this.index]
  7721. h && h.content != g.content && e.trigger('contentchange'),
  7722. (h &&
  7723. h.content == g.content &&
  7724. (a ? 1 : b(h.address, g.address))) ||
  7725. ((this.list = this.list.slice(0, this.index + 1)),
  7726. this.list.push(g),
  7727. this.list.length > f && this.list.shift(),
  7728. (this.index = this.list.length - 1),
  7729. this.clearKey(),
  7730. this.update())
  7731. }),
  7732. (this.update = function () {
  7733. ;(this.hasRedo = !!this.list[this.index + 1]),
  7734. (this.hasUndo = !!this.list[this.index - 1])
  7735. }),
  7736. (this.reset = function () {
  7737. ;(this.list = []),
  7738. (this.index = 0),
  7739. (this.hasUndo = !1),
  7740. (this.hasRedo = !1),
  7741. this.clearKey()
  7742. }),
  7743. (this.clearKey = function () {
  7744. ;(m = 0), (k = null)
  7745. })
  7746. }
  7747. var d,
  7748. e = this,
  7749. f = e.options.maxUndoCount || 20,
  7750. g = e.options.maxInputCount || 20,
  7751. h = new RegExp(domUtils.fillChar + '|</hr>', 'gi'),
  7752. i = { ol: 1, ul: 1, table: 1, tbody: 1, tr: 1, body: 1 },
  7753. j = e.options.autoClearEmptyNode
  7754. ;(e.undoManger = new c()),
  7755. (e.undoManger.editor = e),
  7756. e.addListener('saveScene', function () {
  7757. var a = Array.prototype.splice.call(arguments, 1)
  7758. this.undoManger.save.apply(this.undoManger, a)
  7759. }),
  7760. e.addListener('reset', function (a, b) {
  7761. b || this.undoManger.reset()
  7762. }),
  7763. (e.commands.redo = e.commands.undo =
  7764. {
  7765. execCommand: function (a) {
  7766. this.undoManger[a]()
  7767. },
  7768. queryCommandState: function (a) {
  7769. return this.undoManger[
  7770. 'has' + ('undo' == a.toLowerCase() ? 'Undo' : 'Redo')
  7771. ]
  7772. ? 0
  7773. : -1
  7774. },
  7775. notNeedUndo: 1
  7776. })
  7777. var k,
  7778. l = { 16: 1, 17: 1, 18: 1, 37: 1, 38: 1, 39: 1, 40: 1 },
  7779. m = 0,
  7780. n = !1
  7781. e.addListener('ready', function () {
  7782. domUtils.on(this.body, 'compositionstart', function () {
  7783. n = !0
  7784. }),
  7785. domUtils.on(this.body, 'compositionend', function () {
  7786. n = !1
  7787. })
  7788. }),
  7789. e.addshortcutkey({ Undo: 'ctrl+90', Redo: 'ctrl+89' })
  7790. var o = !0
  7791. e.addListener('keydown', function (a, b) {
  7792. function c(a) {
  7793. a.undoManger.save(!1, !0), a.fireEvent('selectionchange')
  7794. }
  7795. var e = this,
  7796. f = b.keyCode || b.which
  7797. if (!(l[f] || b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)) {
  7798. if (n) return
  7799. if (!e.selection.getRange().collapsed)
  7800. return e.undoManger.save(!1, !0), void (o = !1)
  7801. 0 == e.undoManger.list.length && e.undoManger.save(!0),
  7802. clearTimeout(d),
  7803. (d = setTimeout(function () {
  7804. if (n)
  7805. var a = setInterval(function () {
  7806. n || (c(e), clearInterval(a))
  7807. }, 300)
  7808. else c(e)
  7809. }, 200)),
  7810. (k = f),
  7811. m++,
  7812. m >= g && c(e)
  7813. }
  7814. }),
  7815. e.addListener('keyup', function (a, b) {
  7816. var c = b.keyCode || b.which
  7817. if (!(l[c] || b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)) {
  7818. if (n) return
  7819. o || (this.undoManger.save(!1, !0), (o = !0))
  7820. }
  7821. }),
  7822. (e.stopCmdUndo = function () {
  7823. e.__hasEnterExecCommand = !0
  7824. }),
  7825. (e.startCmdUndo = function () {
  7826. e.__hasEnterExecCommand = !1
  7827. })
  7828. }),
  7829. UE.plugin.register('copy', function () {
  7830. function a() {
  7831. ZeroClipboard.config({
  7832. debug: !1,
  7833. swfPath:
  7834. b.options.UEDITOR_HOME_URL +
  7835. 'third-party/zeroclipboard/ZeroClipboard.swf'
  7836. })
  7837. var a = (b.zeroclipboard = new ZeroClipboard())
  7838. a.on('copy', function (a) {
  7839. var c = a.client,
  7840. d = b.selection.getRange(),
  7841. e = document.createElement('div')
  7842. e.appendChild(d.cloneContents()),
  7843. c.setText(e.innerText || e.textContent),
  7844. c.setHtml(e.innerHTML),
  7845. d.select()
  7846. }),
  7847. a.on('mouseover mouseout', function (a) {
  7848. var b = a.target
  7849. 'mouseover' == a.type
  7850. ? domUtils.addClass(b, 'edui-state-hover')
  7851. : 'mouseout' == a.type &&
  7852. domUtils.removeClasses(b, 'edui-state-hover')
  7853. }),
  7854. a.on('wrongflash noflash', function () {
  7855. ZeroClipboard.destroy()
  7856. })
  7857. }
  7858. var b = this
  7859. return {
  7860. bindEvents: {
  7861. ready: function () {
  7862. browser.ie ||
  7863. (window.ZeroClipboard
  7864. ? a()
  7865. : utils.loadFile(
  7866. document,
  7867. {
  7868. src:
  7869. b.options.UEDITOR_HOME_URL +
  7870. 'third-party/zeroclipboard/ZeroClipboard.js',
  7871. tag: 'script',
  7872. type: 'text/javascript',
  7873. defer: 'defer'
  7874. },
  7875. function () {
  7876. a()
  7877. }
  7878. ))
  7879. }
  7880. },
  7881. commands: {
  7882. copy: {
  7883. execCommand: function (a) {
  7884. b.document.execCommand('copy') || alert(b.getLang('copymsg'))
  7885. }
  7886. }
  7887. }
  7888. }
  7889. }),
  7890. (UE.plugins.paste = function () {
  7891. function a(a) {
  7892. var b = this.document
  7893. if (!b.getElementById('baidu_pastebin')) {
  7894. var c = this.selection.getRange(),
  7895. d = c.createBookmark(),
  7896. e = b.createElement('div')
  7897. ;(e.id = 'baidu_pastebin'),
  7898. browser.webkit &&
  7899. e.appendChild(
  7900. b.createTextNode(domUtils.fillChar + domUtils.fillChar)
  7901. ),
  7902. b.body.appendChild(e),
  7903. (d.start.style.display = ''),
  7904. (e.style.cssText =
  7905. 'position:absolute;width:1px;height:1px;overflow:hidden;left:-1000px;white-space:nowrap;top:' +
  7906. domUtils.getXY(d.start).y +
  7907. 'px'),
  7908. c.selectNodeContents(e).select(!0),
  7909. setTimeout(function () {
  7910. if (browser.webkit)
  7911. for (
  7912. var f, g = 0, h = b.querySelectorAll('#baidu_pastebin');
  7913. (f = h[g++]);
  7914. ) {
  7915. if (!domUtils.isEmptyNode(f)) {
  7916. e = f
  7917. break
  7918. }
  7919. domUtils.remove(f)
  7920. }
  7921. try {
  7922. e.parentNode.removeChild(e)
  7923. } catch (i) {}
  7924. c.moveToBookmark(d).select(!0), a(e)
  7925. }, 0)
  7926. }
  7927. }
  7928. function b(a) {
  7929. return a.replace(/<(\/?)([\w\-]+)([^>]*)>/gi, function (a, b, c, d) {
  7930. return (
  7931. (c = c.toLowerCase()),
  7932. { img: 1 }[c]
  7933. ? a
  7934. : ((d = d.replace(
  7935. /([\w\-]*?)\s*=\s*(("([^"]*)")|('([^']*)')|([^\s>]+))/gi,
  7936. function (a, b, c) {
  7937. return { src: 1, href: 1, name: 1 }[b.toLowerCase()]
  7938. ? b + '=' + c + ' '
  7939. : ''
  7940. }
  7941. )),
  7942. { span: 1, div: 1 }[c]
  7943. ? ''
  7944. : '<' + b + c + ' ' + utils.trim(d) + '>')
  7945. )
  7946. })
  7947. }
  7948. function c(a) {
  7949. var c
  7950. if (a.firstChild) {
  7951. for (
  7952. var h, i = domUtils.getElementsByTagName(a, 'span'), j = 0;
  7953. (h = i[j++]);
  7954. )
  7955. ('_baidu_cut_start' != h.id && '_baidu_cut_end' != h.id) ||
  7956. domUtils.remove(h)
  7957. if (browser.webkit) {
  7958. for (
  7959. var k, l = a.querySelectorAll('div br'), j = 0;
  7960. (k = l[j++]);
  7961. ) {
  7962. var m = k.parentNode
  7963. 'DIV' == m.tagName &&
  7964. 1 == m.childNodes.length &&
  7965. ((m.innerHTML = '<p><br/></p>'), domUtils.remove(m))
  7966. }
  7967. for (
  7968. var n, o = a.querySelectorAll('#baidu_pastebin'), j = 0;
  7969. (n = o[j++]);
  7970. ) {
  7971. var p = d.document.createElement('p')
  7972. for (n.parentNode.insertBefore(p, n); n.firstChild; )
  7973. p.appendChild(n.firstChild)
  7974. domUtils.remove(n)
  7975. }
  7976. for (var q, r = a.querySelectorAll('meta'), j = 0; (q = r[j++]); )
  7977. domUtils.remove(q)
  7978. var l = a.querySelectorAll('br')
  7979. for (j = 0; (q = l[j++]); )
  7980. /^apple-/i.test(q.className) && domUtils.remove(q)
  7981. }
  7982. if (browser.gecko) {
  7983. var s = a.querySelectorAll('[_moz_dirty]')
  7984. for (j = 0; (q = s[j++]); ) q.removeAttribute('_moz_dirty')
  7985. }
  7986. if (!browser.ie)
  7987. for (
  7988. var q, t = a.querySelectorAll('span.Apple-style-span'), j = 0;
  7989. (q = t[j++]);
  7990. )
  7991. domUtils.remove(q, !0)
  7992. ;(c = a.innerHTML), (c = UE.filterWord(c))
  7993. var u = UE.htmlparser(c)
  7994. if (
  7995. (d.options.filterRules && UE.filterNode(u, d.options.filterRules),
  7996. d.filterInputRule(u),
  7997. browser.webkit)
  7998. ) {
  7999. var v = u.lastChild()
  8000. v && 'element' == v.type && 'br' == v.tagName && u.removeChild(v),
  8001. utils.each(d.body.querySelectorAll('div'), function (a) {
  8002. domUtils.isEmptyBlock(a) && domUtils.remove(a, !0)
  8003. })
  8004. }
  8005. if (
  8006. ((c = { html: u.toHtml() }),
  8007. d.fireEvent('beforepaste', c, u),
  8008. !c.html)
  8009. )
  8010. return
  8011. ;(u = UE.htmlparser(c.html, !0)),
  8012. 1 === d.queryCommandState('pasteplain')
  8013. ? d.execCommand(
  8014. 'insertHtml',
  8015. UE.filterNode(u, d.options.filterTxtRules).toHtml(),
  8016. !0
  8017. )
  8018. : (UE.filterNode(u, d.options.filterTxtRules),
  8019. (e = u.toHtml()),
  8020. (f = c.html),
  8021. (g = d.selection.getRange().createAddress(!0)),
  8022. d.execCommand(
  8023. 'insertHtml',
  8024. d.getOpt('retainOnlyLabelPasted') === !0 ? b(f) : f,
  8025. !0
  8026. )),
  8027. d.fireEvent('afterpaste', c)
  8028. }
  8029. }
  8030. var d = this
  8031. d.setOpt({ retainOnlyLabelPasted: !1 })
  8032. var e, f, g
  8033. d.addListener('pasteTransfer', function (a, c) {
  8034. if (g && e && f && e != f) {
  8035. var h = d.selection.getRange()
  8036. if ((h.moveToAddress(g, !0), !h.collapsed)) {
  8037. for (; !domUtils.isBody(h.startContainer); ) {
  8038. var i = h.startContainer
  8039. if (1 == i.nodeType) {
  8040. if (((i = i.childNodes[h.startOffset]), !i)) {
  8041. h.setStartBefore(h.startContainer)
  8042. continue
  8043. }
  8044. var j = i.previousSibling
  8045. j &&
  8046. 3 == j.nodeType &&
  8047. new RegExp('^[\n\r\t ' + domUtils.fillChar + ']*$').test(
  8048. j.nodeValue
  8049. ) &&
  8050. h.setStartBefore(j)
  8051. }
  8052. if (0 != h.startOffset) break
  8053. h.setStartBefore(h.startContainer)
  8054. }
  8055. for (; !domUtils.isBody(h.endContainer); ) {
  8056. var k = h.endContainer
  8057. if (1 == k.nodeType) {
  8058. if (((k = k.childNodes[h.endOffset]), !k)) {
  8059. h.setEndAfter(h.endContainer)
  8060. continue
  8061. }
  8062. var l = k.nextSibling
  8063. l &&
  8064. 3 == l.nodeType &&
  8065. new RegExp('^[\n\r\t' + domUtils.fillChar + ']*$').test(
  8066. l.nodeValue
  8067. ) &&
  8068. h.setEndAfter(l)
  8069. }
  8070. if (
  8071. h.endOffset !=
  8072. h.endContainer[
  8073. 3 == h.endContainer.nodeType ? 'nodeValue' : 'childNodes'
  8074. ].length
  8075. )
  8076. break
  8077. h.setEndAfter(h.endContainer)
  8078. }
  8079. }
  8080. h.deleteContents(), h.select(!0), (d.__hasEnterExecCommand = !0)
  8081. var m = f
  8082. 2 === c ? (m = b(m)) : c && (m = e),
  8083. d.execCommand('inserthtml', m, !0),
  8084. (d.__hasEnterExecCommand = !1)
  8085. for (
  8086. var n = d.selection.getRange();
  8087. !domUtils.isBody(n.startContainer) &&
  8088. !n.startOffset &&
  8089. n.startContainer[
  8090. 3 == n.startContainer.nodeType ? 'nodeValue' : 'childNodes'
  8091. ].length;
  8092. )
  8093. n.setStartBefore(n.startContainer)
  8094. var o = n.createAddress(!0)
  8095. g.endAddress = o.startAddress
  8096. }
  8097. }),
  8098. d.addListener('ready', function () {
  8099. domUtils.on(d.body, 'cut', function () {
  8100. var a = d.selection.getRange()
  8101. !a.collapsed && d.undoManger && d.undoManger.save()
  8102. }),
  8103. domUtils.on(
  8104. d.body,
  8105. browser.ie || browser.opera ? 'keydown' : 'paste',
  8106. function (b) {
  8107. ;((!browser.ie && !browser.opera) ||
  8108. ((b.ctrlKey || b.metaKey) && '86' == b.keyCode)) &&
  8109. a.call(d, function (a) {
  8110. c(a)
  8111. })
  8112. }
  8113. )
  8114. }),
  8115. (d.commands.paste = {
  8116. execCommand: function (b) {
  8117. browser.ie
  8118. ? (a.call(d, function (a) {
  8119. c(a)
  8120. }),
  8121. d.document.execCommand('paste'))
  8122. : alert(d.getLang('pastemsg'))
  8123. }
  8124. })
  8125. }),
  8126. (UE.plugins.pasteplain = function () {
  8127. var a = this
  8128. a.setOpt({
  8129. pasteplain: !1,
  8130. filterTxtRules: (function () {
  8131. function a(a) {
  8132. ;(a.tagName = 'p'), a.setStyle()
  8133. }
  8134. function b(a) {
  8135. a.parentNode.removeChild(a, !0)
  8136. }
  8137. return {
  8138. '-': 'script style object iframe embed input select',
  8139. p: { $: {} },
  8140. br: { $: {} },
  8141. div: function (a) {
  8142. for (
  8143. var b, c = UE.uNode.createElement('p');
  8144. (b = a.firstChild());
  8145. )
  8146. 'text' != b.type && UE.dom.dtd.$block[b.tagName]
  8147. ? c.firstChild()
  8148. ? (a.parentNode.insertBefore(c, a),
  8149. (c = UE.uNode.createElement('p')))
  8150. : a.parentNode.insertBefore(b, a)
  8151. : c.appendChild(b)
  8152. c.firstChild() && a.parentNode.insertBefore(c, a),
  8153. a.parentNode.removeChild(a)
  8154. },
  8155. ol: b,
  8156. ul: b,
  8157. dl: b,
  8158. dt: b,
  8159. dd: b,
  8160. li: b,
  8161. caption: a,
  8162. th: a,
  8163. tr: a,
  8164. h1: a,
  8165. h2: a,
  8166. h3: a,
  8167. h4: a,
  8168. h5: a,
  8169. h6: a,
  8170. td: function (a) {
  8171. var b = !!a.innerText()
  8172. b &&
  8173. a.parentNode.insertAfter(
  8174. UE.uNode.createText(' &nbsp; &nbsp;'),
  8175. a
  8176. ),
  8177. a.parentNode.removeChild(a, a.innerText())
  8178. }
  8179. }
  8180. })()
  8181. })
  8182. var b = a.options.pasteplain
  8183. a.commands.pasteplain = {
  8184. queryCommandState: function () {
  8185. return b ? 1 : 0
  8186. },
  8187. execCommand: function () {
  8188. b = 0 | !b
  8189. },
  8190. notNeedUndo: 1
  8191. }
  8192. }),
  8193. (UE.plugins.list = function () {
  8194. function a(a) {
  8195. var b = []
  8196. for (var c in a) b.push(c)
  8197. return b
  8198. }
  8199. function b(a) {
  8200. var b = a.className
  8201. return domUtils.hasClass(a, /custom_/)
  8202. ? b.match(/custom_(\w+)/)[1]
  8203. : domUtils.getStyle(a, 'list-style-type')
  8204. }
  8205. function c(a, c) {
  8206. utils.each(domUtils.getElementsByTagName(a, 'ol ul'), function (f) {
  8207. if (domUtils.inDoc(f, a)) {
  8208. var g = f.parentNode
  8209. if (g.tagName == f.tagName) {
  8210. var h = b(f) || ('OL' == f.tagName ? 'decimal' : 'disc'),
  8211. i = b(g) || ('OL' == g.tagName ? 'decimal' : 'disc')
  8212. if (h == i) {
  8213. var l = utils.indexOf(k[f.tagName], h)
  8214. ;(l = l + 1 == k[f.tagName].length ? 0 : l + 1),
  8215. e(f, k[f.tagName][l])
  8216. }
  8217. }
  8218. var m = 0,
  8219. n = 2
  8220. domUtils.hasClass(f, /custom_/)
  8221. ? (/[ou]l/i.test(g.tagName) && domUtils.hasClass(g, /custom_/)) ||
  8222. (n = 1)
  8223. : /[ou]l/i.test(g.tagName) &&
  8224. domUtils.hasClass(g, /custom_/) &&
  8225. (n = 3)
  8226. var o = domUtils.getStyle(f, 'list-style-type')
  8227. o && (f.style.cssText = 'list-style-type:' + o),
  8228. (f.className =
  8229. utils.trim(f.className.replace(/list-paddingleft-\w+/, '')) +
  8230. ' list-paddingleft-' +
  8231. n),
  8232. utils.each(domUtils.getElementsByTagName(f, 'li'), function (a) {
  8233. if ((a.style.cssText && (a.style.cssText = ''), !a.firstChild))
  8234. return void domUtils.remove(a)
  8235. if (a.parentNode === f) {
  8236. if ((m++, domUtils.hasClass(f, /custom_/))) {
  8237. var c = 1,
  8238. d = b(f)
  8239. if ('OL' == f.tagName) {
  8240. if (d)
  8241. switch (d) {
  8242. case 'cn':
  8243. case 'cn1':
  8244. case 'cn2':
  8245. m > 10 && (m % 10 == 0 || (m > 10 && m < 20))
  8246. ? (c = 2)
  8247. : m > 20 && (c = 3)
  8248. break
  8249. case 'num2':
  8250. m > 9 && (c = 2)
  8251. }
  8252. a.className =
  8253. 'list-' + j[d] + m + ' list-' + d + '-paddingleft-' + c
  8254. } else
  8255. a.className =
  8256. 'list-' + j[d] + ' list-' + d + '-paddingleft'
  8257. } else a.className = a.className.replace(/list-[\w\-]+/gi, '')
  8258. var e = a.getAttribute('class')
  8259. null === e ||
  8260. e.replace(/\s/g, '') ||
  8261. domUtils.removeAttributes(a, 'class')
  8262. }
  8263. }),
  8264. !c &&
  8265. d(
  8266. f,
  8267. f.tagName.toLowerCase(),
  8268. b(f) || domUtils.getStyle(f, 'list-style-type'),
  8269. !0
  8270. )
  8271. }
  8272. })
  8273. }
  8274. function d(a, d, e, f) {
  8275. var g = a.nextSibling
  8276. g &&
  8277. 1 == g.nodeType &&
  8278. g.tagName.toLowerCase() == d &&
  8279. (b(g) ||
  8280. domUtils.getStyle(g, 'list-style-type') ||
  8281. ('ol' == d ? 'decimal' : 'disc')) == e &&
  8282. (domUtils.moveChild(g, a),
  8283. 0 == g.childNodes.length && domUtils.remove(g)),
  8284. g && domUtils.isFillChar(g) && domUtils.remove(g)
  8285. var h = a.previousSibling
  8286. h &&
  8287. 1 == h.nodeType &&
  8288. h.tagName.toLowerCase() == d &&
  8289. (b(h) ||
  8290. domUtils.getStyle(h, 'list-style-type') ||
  8291. ('ol' == d ? 'decimal' : 'disc')) == e &&
  8292. domUtils.moveChild(a, h),
  8293. h && domUtils.isFillChar(h) && domUtils.remove(h),
  8294. !f && domUtils.isEmptyBlock(a) && domUtils.remove(a),
  8295. b(a) && c(a.ownerDocument, !0)
  8296. }
  8297. function e(a, b) {
  8298. j[b] && (a.className = 'custom_' + b)
  8299. try {
  8300. domUtils.setStyle(a, 'list-style-type', b)
  8301. } catch (c) {}
  8302. }
  8303. function f(a) {
  8304. var b = a.previousSibling
  8305. b && domUtils.isEmptyBlock(b) && domUtils.remove(b),
  8306. (b = a.nextSibling),
  8307. b && domUtils.isEmptyBlock(b) && domUtils.remove(b)
  8308. }
  8309. function g(a) {
  8310. for (; a && !domUtils.isBody(a); ) {
  8311. if ('TABLE' == a.nodeName) return null
  8312. if ('LI' == a.nodeName) return a
  8313. a = a.parentNode
  8314. }
  8315. }
  8316. var h = this,
  8317. i = { TD: 1, PRE: 1, BLOCKQUOTE: 1 },
  8318. j = {
  8319. cn: 'cn-1-',
  8320. cn1: 'cn-2-',
  8321. cn2: 'cn-3-',
  8322. num: 'num-1-',
  8323. num1: 'num-2-',
  8324. num2: 'num-3-',
  8325. dash: 'dash',
  8326. dot: 'dot'
  8327. }
  8328. h.setOpt({
  8329. autoTransWordToList: !1,
  8330. insertorderedlist: {
  8331. num: '',
  8332. num1: '',
  8333. num2: '',
  8334. cn: '',
  8335. cn1: '',
  8336. cn2: '',
  8337. decimal: '',
  8338. 'lower-alpha': '',
  8339. 'lower-roman': '',
  8340. 'upper-alpha': '',
  8341. 'upper-roman': ''
  8342. },
  8343. insertunorderedlist: {
  8344. circle: '',
  8345. disc: '',
  8346. square: '',
  8347. dash: '',
  8348. dot: ''
  8349. },
  8350. listDefaultPaddingLeft: '30',
  8351. listiconpath: 'http://bs.baidu.com/listicon/',
  8352. maxListLevel: -1,
  8353. disablePInList: !1
  8354. })
  8355. var k = {
  8356. OL: a(h.options.insertorderedlist),
  8357. UL: a(h.options.insertunorderedlist)
  8358. },
  8359. l = h.options.listiconpath
  8360. for (var m in j)
  8361. h.options.insertorderedlist.hasOwnProperty(m) ||
  8362. h.options.insertunorderedlist.hasOwnProperty(m) ||
  8363. delete j[m]
  8364. h.ready(function () {
  8365. var a = []
  8366. for (var b in j) {
  8367. if ('dash' == b || 'dot' == b)
  8368. a.push(
  8369. 'li.list-' + j[b] + '{background-image:url(' + l + j[b] + '.gif)}'
  8370. ),
  8371. a.push(
  8372. 'ul.custom_' +
  8373. b +
  8374. '{list-style:none;}ul.custom_' +
  8375. b +
  8376. ' li{background-position:0 3px;background-repeat:no-repeat}'
  8377. )
  8378. else {
  8379. for (var c = 0; c < 99; c++)
  8380. a.push(
  8381. 'li.list-' +
  8382. j[b] +
  8383. c +
  8384. '{background-image:url(' +
  8385. l +
  8386. 'list-' +
  8387. j[b] +
  8388. c +
  8389. '.gif)}'
  8390. )
  8391. a.push(
  8392. 'ol.custom_' +
  8393. b +
  8394. '{list-style:none;}ol.custom_' +
  8395. b +
  8396. ' li{background-position:0 3px;background-repeat:no-repeat}'
  8397. )
  8398. }
  8399. switch (b) {
  8400. case 'cn':
  8401. a.push('li.list-' + b + '-paddingleft-1{padding-left:25px}'),
  8402. a.push('li.list-' + b + '-paddingleft-2{padding-left:40px}'),
  8403. a.push('li.list-' + b + '-paddingleft-3{padding-left:55px}')
  8404. break
  8405. case 'cn1':
  8406. a.push('li.list-' + b + '-paddingleft-1{padding-left:30px}'),
  8407. a.push('li.list-' + b + '-paddingleft-2{padding-left:40px}'),
  8408. a.push('li.list-' + b + '-paddingleft-3{padding-left:55px}')
  8409. break
  8410. case 'cn2':
  8411. a.push('li.list-' + b + '-paddingleft-1{padding-left:40px}'),
  8412. a.push('li.list-' + b + '-paddingleft-2{padding-left:55px}'),
  8413. a.push('li.list-' + b + '-paddingleft-3{padding-left:68px}')
  8414. break
  8415. case 'num':
  8416. case 'num1':
  8417. a.push('li.list-' + b + '-paddingleft-1{padding-left:25px}')
  8418. break
  8419. case 'num2':
  8420. a.push('li.list-' + b + '-paddingleft-1{padding-left:35px}'),
  8421. a.push('li.list-' + b + '-paddingleft-2{padding-left:40px}')
  8422. break
  8423. case 'dash':
  8424. a.push('li.list-' + b + '-paddingleft{padding-left:35px}')
  8425. break
  8426. case 'dot':
  8427. a.push('li.list-' + b + '-paddingleft{padding-left:20px}')
  8428. }
  8429. }
  8430. a.push('.list-paddingleft-1{padding-left:0}'),
  8431. a.push(
  8432. '.list-paddingleft-2{padding-left:' +
  8433. h.options.listDefaultPaddingLeft +
  8434. 'px}'
  8435. ),
  8436. a.push(
  8437. '.list-paddingleft-3{padding-left:' +
  8438. 2 * h.options.listDefaultPaddingLeft +
  8439. 'px}'
  8440. ),
  8441. utils.cssRule(
  8442. 'list',
  8443. 'ol,ul{margin:0;pading:0;' +
  8444. (browser.ie ? '' : 'width:95%') +
  8445. '}li{clear:both;}' +
  8446. a.join('\n'),
  8447. h.document
  8448. )
  8449. }),
  8450. h.ready(function () {
  8451. domUtils.on(h.body, 'cut', function () {
  8452. setTimeout(function () {
  8453. var a,
  8454. b = h.selection.getRange()
  8455. if (
  8456. !b.collapsed &&
  8457. (a = domUtils.findParentByTagName(
  8458. b.startContainer,
  8459. 'li',
  8460. !0
  8461. )) &&
  8462. !a.nextSibling &&
  8463. domUtils.isEmptyBlock(a)
  8464. ) {
  8465. var c,
  8466. d = a.parentNode
  8467. if ((c = d.previousSibling))
  8468. domUtils.remove(d),
  8469. b.setStartAtLast(c).collapse(!0),
  8470. b.select(!0)
  8471. else if ((c = d.nextSibling))
  8472. domUtils.remove(d),
  8473. b.setStartAtFirst(c).collapse(!0),
  8474. b.select(!0)
  8475. else {
  8476. var e = h.document.createElement('p')
  8477. domUtils.fillNode(h.document, e),
  8478. d.parentNode.insertBefore(e, d),
  8479. domUtils.remove(d),
  8480. b.setStart(e, 0).collapse(!0),
  8481. b.select(!0)
  8482. }
  8483. }
  8484. })
  8485. })
  8486. }),
  8487. h.addListener('beforepaste', function (a, c) {
  8488. var d,
  8489. e = this,
  8490. f = e.selection.getRange(),
  8491. g = UE.htmlparser(c.html, !0)
  8492. if ((d = domUtils.findParentByTagName(f.startContainer, 'li', !0))) {
  8493. var h = d.parentNode,
  8494. i = 'OL' == h.tagName ? 'ul' : 'ol'
  8495. utils.each(g.getNodesByTagName(i), function (c) {
  8496. if (((c.tagName = h.tagName), c.setAttr(), c.parentNode === g))
  8497. a = b(h) || ('OL' == h.tagName ? 'decimal' : 'disc')
  8498. else {
  8499. var d = c.parentNode.getAttr('class')
  8500. ;(a =
  8501. d && /custom_/.test(d)
  8502. ? d.match(/custom_(\w+)/)[1]
  8503. : c.parentNode.getStyle('list-style-type')),
  8504. a || (a = 'OL' == h.tagName ? 'decimal' : 'disc')
  8505. }
  8506. var e = utils.indexOf(k[h.tagName], a)
  8507. c.parentNode !== g &&
  8508. (e = e + 1 == k[h.tagName].length ? 0 : e + 1)
  8509. var f = k[h.tagName][e]
  8510. j[f]
  8511. ? c.setAttr('class', 'custom_' + f)
  8512. : c.setStyle('list-style-type', f)
  8513. })
  8514. }
  8515. c.html = g.toHtml()
  8516. }),
  8517. h.getOpt('disablePInList') === !0 &&
  8518. h.addOutputRule(function (a) {
  8519. utils.each(a.getNodesByTagName('li'), function (a) {
  8520. var b = [],
  8521. c = 0
  8522. utils.each(a.children, function (d) {
  8523. if ('p' == d.tagName) {
  8524. for (var e; (e = d.children.pop()); )
  8525. b.splice(c, 0, e), (e.parentNode = a), (lastNode = e)
  8526. if (
  8527. ((e = b[b.length - 1]),
  8528. !e || 'element' != e.type || 'br' != e.tagName)
  8529. ) {
  8530. var f = UE.uNode.createElement('br')
  8531. ;(f.parentNode = a), b.push(f)
  8532. }
  8533. c = b.length
  8534. }
  8535. }),
  8536. b.length && (a.children = b)
  8537. })
  8538. }),
  8539. h.addInputRule(function (a) {
  8540. function b(a, b) {
  8541. var e = b.firstChild()
  8542. if (
  8543. e &&
  8544. 'element' == e.type &&
  8545. 'span' == e.tagName &&
  8546. /Wingdings|Symbol/.test(e.getStyle('font-family'))
  8547. ) {
  8548. for (var f in d) if (d[f] == e.data) return f
  8549. return 'disc'
  8550. }
  8551. for (var f in c) if (c[f].test(a)) return f
  8552. }
  8553. if (
  8554. (utils.each(a.getNodesByTagName('li'), function (a) {
  8555. for (
  8556. var b, c = UE.uNode.createElement('p'), d = 0;
  8557. (b = a.children[d]);
  8558. )
  8559. 'text' == b.type || dtd.p[b.tagName]
  8560. ? c.appendChild(b)
  8561. : c.firstChild()
  8562. ? (a.insertBefore(c, b),
  8563. (c = UE.uNode.createElement('p')),
  8564. (d += 2))
  8565. : d++
  8566. ;((c.firstChild() && !c.parentNode) || !a.firstChild()) &&
  8567. a.appendChild(c),
  8568. c.firstChild() || c.innerHTML(browser.ie ? '&nbsp;' : '<br/>')
  8569. var e = a.firstChild(),
  8570. f = e.lastChild()
  8571. f && 'text' == f.type && /^\s*$/.test(f.data) && e.removeChild(f)
  8572. }),
  8573. h.options.autoTransWordToList)
  8574. ) {
  8575. var c = {
  8576. num1: /^\d+\)/,
  8577. decimal: /^\d+\./,
  8578. 'lower-alpha': /^[a-z]+\)/,
  8579. 'upper-alpha': /^[A-Z]+\./,
  8580. cn: /^[\u4E00\u4E8C\u4E09\u56DB\u516d\u4e94\u4e03\u516b\u4e5d]+[\u3001]/,
  8581. cn2: /^\([\u4E00\u4E8C\u4E09\u56DB\u516d\u4e94\u4e03\u516b\u4e5d]+\)/
  8582. },
  8583. d = { square: 'n' }
  8584. utils.each(a.getNodesByTagName('p'), function (a) {
  8585. function d(a, b, d) {
  8586. if ('ol' == a.tagName)
  8587. if (browser.ie) {
  8588. var e = b.firstChild()
  8589. 'element' == e.type &&
  8590. 'span' == e.tagName &&
  8591. c[d].test(e.innerText()) &&
  8592. b.removeChild(e)
  8593. } else b.innerHTML(b.innerHTML().replace(c[d], ''))
  8594. else b.removeChild(b.firstChild())
  8595. var f = UE.uNode.createElement('li')
  8596. f.appendChild(b), a.appendChild(f)
  8597. }
  8598. if ('MsoListParagraph' == a.getAttr('class')) {
  8599. a.setStyle('margin', ''),
  8600. a.setStyle('margin-left', ''),
  8601. a.setAttr('class', '')
  8602. var e,
  8603. f = a,
  8604. g = a
  8605. if ('li' != a.parentNode.tagName && (e = b(a.innerText(), a))) {
  8606. var i = UE.uNode.createElement(
  8607. h.options.insertorderedlist.hasOwnProperty(e) ? 'ol' : 'ul'
  8608. )
  8609. for (
  8610. j[e]
  8611. ? i.setAttr('class', 'custom_' + e)
  8612. : i.setStyle('list-style-type', e);
  8613. a && 'li' != a.parentNode.tagName && b(a.innerText(), a);
  8614. )
  8615. (f = a.nextSibling()),
  8616. f || a.parentNode.insertBefore(i, a),
  8617. d(i, a, e),
  8618. (a = f)
  8619. !i.parentNode &&
  8620. a &&
  8621. a.parentNode &&
  8622. a.parentNode.insertBefore(i, a)
  8623. }
  8624. var k = g.firstChild()
  8625. k &&
  8626. 'element' == k.type &&
  8627. 'span' == k.tagName &&
  8628. /^\s*(&nbsp;)+\s*$/.test(k.innerText()) &&
  8629. k.parentNode.removeChild(k)
  8630. }
  8631. })
  8632. }
  8633. }),
  8634. h.addListener('contentchange', function () {
  8635. c(h.document)
  8636. }),
  8637. h.addListener('keydown', function (a, b) {
  8638. function c() {
  8639. b.preventDefault ? b.preventDefault() : (b.returnValue = !1),
  8640. h.fireEvent('contentchange'),
  8641. h.undoManger && h.undoManger.save()
  8642. }
  8643. function d(a, b) {
  8644. for (; a && !domUtils.isBody(a); ) {
  8645. if (b(a)) return null
  8646. if (1 == a.nodeType && /[ou]l/i.test(a.tagName)) return a
  8647. a = a.parentNode
  8648. }
  8649. return null
  8650. }
  8651. var e = b.keyCode || b.which
  8652. if (13 == e && !b.shiftKey) {
  8653. var g = h.selection.getRange(),
  8654. i = domUtils.findParent(
  8655. g.startContainer,
  8656. function (a) {
  8657. return domUtils.isBlockElm(a)
  8658. },
  8659. !0
  8660. ),
  8661. j = domUtils.findParentByTagName(g.startContainer, 'li', !0)
  8662. if (i && 'PRE' != i.tagName && !j) {
  8663. var k = i.innerHTML.replace(
  8664. new RegExp(domUtils.fillChar, 'g'),
  8665. ''
  8666. )
  8667. ;/^\s*1\s*\.[^\d]/.test(k) &&
  8668. ((i.innerHTML = k.replace(/^\s*1\s*\./, '')),
  8669. g.setStartAtLast(i).collapse(!0).select(),
  8670. (h.__hasEnterExecCommand = !0),
  8671. h.execCommand('insertorderedlist'),
  8672. (h.__hasEnterExecCommand = !1))
  8673. }
  8674. var l = h.selection.getRange(),
  8675. m = d(l.startContainer, function (a) {
  8676. return 'TABLE' == a.tagName
  8677. }),
  8678. n = l.collapsed
  8679. ? m
  8680. : d(l.endContainer, function (a) {
  8681. return 'TABLE' == a.tagName
  8682. })
  8683. if (m && n && m === n) {
  8684. if (!l.collapsed) {
  8685. if (
  8686. ((m = domUtils.findParentByTagName(
  8687. l.startContainer,
  8688. 'li',
  8689. !0
  8690. )),
  8691. (n = domUtils.findParentByTagName(l.endContainer, 'li', !0)),
  8692. !m || !n || m !== n)
  8693. ) {
  8694. var o = l.cloneRange(),
  8695. p = o.collapse(!1).createBookmark()
  8696. l.deleteContents(), o.moveToBookmark(p)
  8697. var j = domUtils.findParentByTagName(
  8698. o.startContainer,
  8699. 'li',
  8700. !0
  8701. )
  8702. return f(j), o.select(), void c()
  8703. }
  8704. if (
  8705. (l.deleteContents(),
  8706. (j = domUtils.findParentByTagName(
  8707. l.startContainer,
  8708. 'li',
  8709. !0
  8710. )),
  8711. j && domUtils.isEmptyBlock(j))
  8712. )
  8713. return (
  8714. (v = j.previousSibling),
  8715. (next = j.nextSibling),
  8716. (s = h.document.createElement('p')),
  8717. domUtils.fillNode(h.document, s),
  8718. (q = j.parentNode),
  8719. v && next
  8720. ? (l.setStart(next, 0).collapse(!0).select(!0),
  8721. domUtils.remove(j))
  8722. : ((v || next) && v
  8723. ? j.parentNode.parentNode.insertBefore(
  8724. s,
  8725. q.nextSibling
  8726. )
  8727. : q.parentNode.insertBefore(s, q),
  8728. domUtils.remove(j),
  8729. q.firstChild || domUtils.remove(q),
  8730. l.setStart(s, 0).setCursor()),
  8731. void c()
  8732. )
  8733. }
  8734. if (
  8735. (j = domUtils.findParentByTagName(l.startContainer, 'li', !0))
  8736. ) {
  8737. if (domUtils.isEmptyBlock(j)) {
  8738. p = l.createBookmark()
  8739. var q = j.parentNode
  8740. if (
  8741. (j !== q.lastChild
  8742. ? (domUtils.breakParent(j, q), f(j))
  8743. : (q.parentNode.insertBefore(j, q.nextSibling),
  8744. domUtils.isEmptyNode(q) && domUtils.remove(q)),
  8745. !dtd.$list[j.parentNode.tagName])
  8746. )
  8747. if (domUtils.isBlockElm(j.firstChild))
  8748. domUtils.remove(j, !0)
  8749. else {
  8750. for (
  8751. s = h.document.createElement('p'),
  8752. j.parentNode.insertBefore(s, j);
  8753. j.firstChild;
  8754. )
  8755. s.appendChild(j.firstChild)
  8756. domUtils.remove(j)
  8757. }
  8758. l.moveToBookmark(p).select()
  8759. } else {
  8760. var r = j.firstChild
  8761. if (!r || !domUtils.isBlockElm(r)) {
  8762. var s = h.document.createElement('p')
  8763. for (
  8764. !j.firstChild && domUtils.fillNode(h.document, s);
  8765. j.firstChild;
  8766. )
  8767. s.appendChild(j.firstChild)
  8768. j.appendChild(s), (r = s)
  8769. }
  8770. var t = h.document.createElement('span')
  8771. l.insertNode(t), domUtils.breakParent(t, j)
  8772. var u = t.nextSibling
  8773. ;(r = u.firstChild),
  8774. r ||
  8775. ((s = h.document.createElement('p')),
  8776. domUtils.fillNode(h.document, s),
  8777. u.appendChild(s),
  8778. (r = s)),
  8779. domUtils.isEmptyNode(r) &&
  8780. ((r.innerHTML = ''), domUtils.fillNode(h.document, r)),
  8781. l.setStart(r, 0).collapse(!0).shrinkBoundary().select(),
  8782. domUtils.remove(t)
  8783. var v = u.previousSibling
  8784. v &&
  8785. domUtils.isEmptyBlock(v) &&
  8786. ((v.innerHTML = '<p></p>'),
  8787. domUtils.fillNode(h.document, v.firstChild))
  8788. }
  8789. c()
  8790. }
  8791. }
  8792. }
  8793. if (
  8794. 8 == e &&
  8795. ((l = h.selection.getRange()),
  8796. l.collapsed &&
  8797. domUtils.isStartInblock(l) &&
  8798. ((o = l.cloneRange().trimBoundary()),
  8799. (j = domUtils.findParentByTagName(l.startContainer, 'li', !0)),
  8800. j && domUtils.isStartInblock(o)))
  8801. ) {
  8802. if (
  8803. ((m = domUtils.findParentByTagName(l.startContainer, 'p', !0)),
  8804. m && m !== j.firstChild)
  8805. ) {
  8806. var q = domUtils.findParentByTagName(m, ['ol', 'ul'])
  8807. return (
  8808. domUtils.breakParent(m, q),
  8809. f(m),
  8810. h.fireEvent('contentchange'),
  8811. l.setStart(m, 0).setCursor(!1, !0),
  8812. h.fireEvent('saveScene'),
  8813. void domUtils.preventDefault(b)
  8814. )
  8815. }
  8816. if (j && (v = j.previousSibling)) {
  8817. if (46 == e && j.childNodes.length) return
  8818. if (
  8819. (dtd.$list[v.tagName] && (v = v.lastChild),
  8820. h.undoManger && h.undoManger.save(),
  8821. (r = j.firstChild),
  8822. domUtils.isBlockElm(r))
  8823. )
  8824. if (domUtils.isEmptyNode(r))
  8825. for (
  8826. v.appendChild(r), l.setStart(r, 0).setCursor(!1, !0);
  8827. j.firstChild;
  8828. )
  8829. v.appendChild(j.firstChild)
  8830. else
  8831. (t = h.document.createElement('span')),
  8832. l.insertNode(t),
  8833. domUtils.isEmptyBlock(v) && (v.innerHTML = ''),
  8834. domUtils.moveChild(j, v),
  8835. l.setStartBefore(t).collapse(!0).select(!0),
  8836. domUtils.remove(t)
  8837. else if (domUtils.isEmptyNode(j)) {
  8838. var s = h.document.createElement('p')
  8839. v.appendChild(s), l.setStart(s, 0).setCursor()
  8840. } else
  8841. for (
  8842. l.setEnd(v, v.childNodes.length).collapse().select(!0);
  8843. j.firstChild;
  8844. )
  8845. v.appendChild(j.firstChild)
  8846. return (
  8847. domUtils.remove(j),
  8848. h.fireEvent('contentchange'),
  8849. h.fireEvent('saveScene'),
  8850. void domUtils.preventDefault(b)
  8851. )
  8852. }
  8853. if (j && !j.previousSibling) {
  8854. var q = j.parentNode,
  8855. p = l.createBookmark()
  8856. if (domUtils.isTagNode(q.parentNode, 'ol ul'))
  8857. q.parentNode.insertBefore(j, q),
  8858. domUtils.isEmptyNode(q) && domUtils.remove(q)
  8859. else {
  8860. for (; j.firstChild; )
  8861. q.parentNode.insertBefore(j.firstChild, q)
  8862. domUtils.remove(j),
  8863. domUtils.isEmptyNode(q) && domUtils.remove(q)
  8864. }
  8865. return (
  8866. l.moveToBookmark(p).setCursor(!1, !0),
  8867. h.fireEvent('contentchange'),
  8868. h.fireEvent('saveScene'),
  8869. void domUtils.preventDefault(b)
  8870. )
  8871. }
  8872. }
  8873. }),
  8874. h.addListener('keyup', function (a, c) {
  8875. var e = c.keyCode || c.which
  8876. if (8 == e) {
  8877. var f,
  8878. g = h.selection.getRange()
  8879. ;(f = domUtils.findParentByTagName(
  8880. g.startContainer,
  8881. ['ol', 'ul'],
  8882. !0
  8883. )) &&
  8884. d(
  8885. f,
  8886. f.tagName.toLowerCase(),
  8887. b(f) || domUtils.getComputedStyle(f, 'list-style-type'),
  8888. !0
  8889. )
  8890. }
  8891. }),
  8892. h.addListener('tabkeydown', function () {
  8893. function a(a) {
  8894. if (h.options.maxListLevel != -1) {
  8895. for (var b = a.parentNode, c = 0; /[ou]l/i.test(b.tagName); )
  8896. c++, (b = b.parentNode)
  8897. if (c >= h.options.maxListLevel) return !0
  8898. }
  8899. }
  8900. var c = h.selection.getRange(),
  8901. f = domUtils.findParentByTagName(c.startContainer, 'li', !0)
  8902. if (f) {
  8903. var g
  8904. if (!c.collapsed) {
  8905. h.fireEvent('saveScene'), (g = c.createBookmark())
  8906. for (var i, j, l = 0, m = domUtils.findParents(f); (j = m[l++]); )
  8907. if (domUtils.isTagNode(j, 'ol ul')) {
  8908. i = j
  8909. break
  8910. }
  8911. var n = f
  8912. if (g.end)
  8913. for (
  8914. ;
  8915. n &&
  8916. !(
  8917. domUtils.getPosition(n, g.end) & domUtils.POSITION_FOLLOWING
  8918. );
  8919. )
  8920. if (a(n))
  8921. n = domUtils.getNextDomNode(n, !1, null, function (a) {
  8922. return a !== i
  8923. })
  8924. else {
  8925. var o = n.parentNode,
  8926. p = h.document.createElement(o.tagName),
  8927. q = utils.indexOf(
  8928. k[p.tagName],
  8929. b(o) || domUtils.getComputedStyle(o, 'list-style-type')
  8930. ),
  8931. r = q + 1 == k[p.tagName].length ? 0 : q + 1,
  8932. s = k[p.tagName][r]
  8933. for (
  8934. e(p, s), o.insertBefore(p, n);
  8935. n &&
  8936. !(
  8937. domUtils.getPosition(n, g.end) &
  8938. domUtils.POSITION_FOLLOWING
  8939. );
  8940. ) {
  8941. if (
  8942. ((f = n.nextSibling),
  8943. p.appendChild(n),
  8944. !f || domUtils.isTagNode(f, 'ol ul'))
  8945. ) {
  8946. if (f)
  8947. for (; (f = f.firstChild) && 'LI' != f.tagName; );
  8948. else
  8949. f = domUtils.getNextDomNode(
  8950. n,
  8951. !1,
  8952. null,
  8953. function (a) {
  8954. return a !== i
  8955. }
  8956. )
  8957. break
  8958. }
  8959. n = f
  8960. }
  8961. d(p, p.tagName.toLowerCase(), s), (n = f)
  8962. }
  8963. return (
  8964. h.fireEvent('contentchange'), c.moveToBookmark(g).select(), !0
  8965. )
  8966. }
  8967. if (a(f)) return !0
  8968. var o = f.parentNode,
  8969. p = h.document.createElement(o.tagName),
  8970. q = utils.indexOf(
  8971. k[p.tagName],
  8972. b(o) || domUtils.getComputedStyle(o, 'list-style-type')
  8973. )
  8974. q = q + 1 == k[p.tagName].length ? 0 : q + 1
  8975. var s = k[p.tagName][q]
  8976. if ((e(p, s), domUtils.isStartInblock(c)))
  8977. return (
  8978. h.fireEvent('saveScene'),
  8979. (g = c.createBookmark()),
  8980. o.insertBefore(p, f),
  8981. p.appendChild(f),
  8982. d(p, p.tagName.toLowerCase(), s),
  8983. h.fireEvent('contentchange'),
  8984. c.moveToBookmark(g).select(!0),
  8985. !0
  8986. )
  8987. }
  8988. }),
  8989. (h.commands.insertorderedlist = h.commands.insertunorderedlist =
  8990. {
  8991. execCommand: function (a, c) {
  8992. c ||
  8993. (c =
  8994. 'insertorderedlist' == a.toLowerCase() ? 'decimal' : 'disc')
  8995. var f = this,
  8996. h = this.selection.getRange(),
  8997. j = function (a) {
  8998. return 1 == a.nodeType
  8999. ? 'br' != a.tagName.toLowerCase()
  9000. : !domUtils.isWhitespace(a)
  9001. },
  9002. k = 'insertorderedlist' == a.toLowerCase() ? 'ol' : 'ul',
  9003. l = f.document.createDocumentFragment()
  9004. h.adjustmentBoundary().shrinkBoundary()
  9005. var m,
  9006. n,
  9007. o,
  9008. p,
  9009. q = h.createBookmark(!0),
  9010. r = g(f.document.getElementById(q.start)),
  9011. s = 0,
  9012. t = g(f.document.getElementById(q.end)),
  9013. u = 0
  9014. if (r || t) {
  9015. if (
  9016. (r && (m = r.parentNode),
  9017. q.end || (t = r),
  9018. t && (n = t.parentNode),
  9019. m === n)
  9020. ) {
  9021. for (; r !== t; ) {
  9022. if (
  9023. ((p = r),
  9024. (r = r.nextSibling),
  9025. !domUtils.isBlockElm(p.firstChild))
  9026. ) {
  9027. for (
  9028. var v = f.document.createElement('p');
  9029. p.firstChild;
  9030. )
  9031. v.appendChild(p.firstChild)
  9032. p.appendChild(v)
  9033. }
  9034. l.appendChild(p)
  9035. }
  9036. if (
  9037. ((p = f.document.createElement('span')),
  9038. m.insertBefore(p, t),
  9039. !domUtils.isBlockElm(t.firstChild))
  9040. ) {
  9041. for (v = f.document.createElement('p'); t.firstChild; )
  9042. v.appendChild(t.firstChild)
  9043. t.appendChild(v)
  9044. }
  9045. l.appendChild(t),
  9046. domUtils.breakParent(p, m),
  9047. domUtils.isEmptyNode(p.previousSibling) &&
  9048. domUtils.remove(p.previousSibling),
  9049. domUtils.isEmptyNode(p.nextSibling) &&
  9050. domUtils.remove(p.nextSibling)
  9051. var w =
  9052. b(m) ||
  9053. domUtils.getComputedStyle(m, 'list-style-type') ||
  9054. ('insertorderedlist' == a.toLowerCase()
  9055. ? 'decimal'
  9056. : 'disc')
  9057. if (m.tagName.toLowerCase() == k && w == c) {
  9058. for (
  9059. var x, y = 0, z = f.document.createDocumentFragment();
  9060. (x = l.firstChild);
  9061. )
  9062. if (domUtils.isTagNode(x, 'ol ul')) z.appendChild(x)
  9063. else
  9064. for (; x.firstChild; )
  9065. z.appendChild(x.firstChild), domUtils.remove(x)
  9066. p.parentNode.insertBefore(z, p)
  9067. } else
  9068. (o = f.document.createElement(k)),
  9069. e(o, c),
  9070. o.appendChild(l),
  9071. p.parentNode.insertBefore(o, p)
  9072. return (
  9073. domUtils.remove(p),
  9074. o && d(o, k, c),
  9075. void h.moveToBookmark(q).select()
  9076. )
  9077. }
  9078. if (r) {
  9079. for (; r; ) {
  9080. if (((p = r.nextSibling), domUtils.isTagNode(r, 'ol ul')))
  9081. l.appendChild(r)
  9082. else {
  9083. for (
  9084. var A = f.document.createDocumentFragment(), B = 0;
  9085. r.firstChild;
  9086. )
  9087. domUtils.isBlockElm(r.firstChild) && (B = 1),
  9088. A.appendChild(r.firstChild)
  9089. if (B) l.appendChild(A)
  9090. else {
  9091. var C = f.document.createElement('p')
  9092. C.appendChild(A), l.appendChild(C)
  9093. }
  9094. domUtils.remove(r)
  9095. }
  9096. r = p
  9097. }
  9098. m.parentNode.insertBefore(l, m.nextSibling),
  9099. domUtils.isEmptyNode(m)
  9100. ? (h.setStartBefore(m), domUtils.remove(m))
  9101. : h.setStartAfter(m),
  9102. (s = 1)
  9103. }
  9104. if (t && domUtils.inDoc(n, f.document)) {
  9105. for (r = n.firstChild; r && r !== t; ) {
  9106. if (((p = r.nextSibling), domUtils.isTagNode(r, 'ol ul')))
  9107. l.appendChild(r)
  9108. else {
  9109. for (
  9110. A = f.document.createDocumentFragment(), B = 0;
  9111. r.firstChild;
  9112. )
  9113. domUtils.isBlockElm(r.firstChild) && (B = 1),
  9114. A.appendChild(r.firstChild)
  9115. B
  9116. ? l.appendChild(A)
  9117. : ((C = f.document.createElement('p')),
  9118. C.appendChild(A),
  9119. l.appendChild(C)),
  9120. domUtils.remove(r)
  9121. }
  9122. r = p
  9123. }
  9124. var D = domUtils.createElement(f.document, 'div', {
  9125. tmpDiv: 1
  9126. })
  9127. domUtils.moveChild(t, D),
  9128. l.appendChild(D),
  9129. domUtils.remove(t),
  9130. n.parentNode.insertBefore(l, n),
  9131. h.setEndBefore(n),
  9132. domUtils.isEmptyNode(n) && domUtils.remove(n),
  9133. (u = 1)
  9134. }
  9135. }
  9136. s || h.setStartBefore(f.document.getElementById(q.start)),
  9137. q.end && !u && h.setEndAfter(f.document.getElementById(q.end)),
  9138. h.enlarge(!0, function (a) {
  9139. return i[a.tagName]
  9140. }),
  9141. (l = f.document.createDocumentFragment())
  9142. for (
  9143. var E,
  9144. F = h.createBookmark(),
  9145. G = domUtils.getNextDomNode(F.start, !1, j),
  9146. H = h.cloneRange(),
  9147. I = domUtils.isBlockElm;
  9148. G &&
  9149. G !== F.end &&
  9150. domUtils.getPosition(G, F.end) & domUtils.POSITION_PRECEDING;
  9151. )
  9152. if (3 == G.nodeType || dtd.li[G.tagName]) {
  9153. if (1 == G.nodeType && dtd.$list[G.tagName]) {
  9154. for (; G.firstChild; ) l.appendChild(G.firstChild)
  9155. ;(E = domUtils.getNextDomNode(G, !1, j)),
  9156. domUtils.remove(G),
  9157. (G = E)
  9158. continue
  9159. }
  9160. for (
  9161. E = G, H.setStartBefore(G);
  9162. G && G !== F.end && (!I(G) || domUtils.isBookmarkNode(G));
  9163. )
  9164. (E = G),
  9165. (G = domUtils.getNextDomNode(G, !1, null, function (a) {
  9166. return !i[a.tagName]
  9167. }))
  9168. G &&
  9169. I(G) &&
  9170. ((p = domUtils.getNextDomNode(E, !1, j)),
  9171. p &&
  9172. domUtils.isBookmarkNode(p) &&
  9173. ((G = domUtils.getNextDomNode(p, !1, j)), (E = p))),
  9174. H.setEndAfter(E),
  9175. (G = domUtils.getNextDomNode(E, !1, j))
  9176. var J = h.document.createElement('li')
  9177. if (
  9178. (J.appendChild(H.extractContents()),
  9179. domUtils.isEmptyNode(J))
  9180. ) {
  9181. for (var E = h.document.createElement('p'); J.firstChild; )
  9182. E.appendChild(J.firstChild)
  9183. J.appendChild(E)
  9184. }
  9185. l.appendChild(J)
  9186. } else G = domUtils.getNextDomNode(G, !0, j)
  9187. h.moveToBookmark(F).collapse(!0),
  9188. (o = f.document.createElement(k)),
  9189. e(o, c),
  9190. o.appendChild(l),
  9191. h.insertNode(o),
  9192. d(o, k, c)
  9193. for (
  9194. var x, y = 0, K = domUtils.getElementsByTagName(o, 'div');
  9195. (x = K[y++]);
  9196. )
  9197. x.getAttribute('tmpDiv') && domUtils.remove(x, !0)
  9198. h.moveToBookmark(q).select()
  9199. },
  9200. queryCommandState: function (a) {
  9201. for (
  9202. var b,
  9203. c = 'insertorderedlist' == a.toLowerCase() ? 'ol' : 'ul',
  9204. d = this.selection.getStartElementPath(),
  9205. e = 0;
  9206. (b = d[e++]);
  9207. ) {
  9208. if ('TABLE' == b.nodeName) return 0
  9209. if (c == b.nodeName.toLowerCase()) return 1
  9210. }
  9211. return 0
  9212. },
  9213. queryCommandValue: function (a) {
  9214. for (
  9215. var c,
  9216. d,
  9217. e = 'insertorderedlist' == a.toLowerCase() ? 'ol' : 'ul',
  9218. f = this.selection.getStartElementPath(),
  9219. g = 0;
  9220. (d = f[g++]);
  9221. ) {
  9222. if ('TABLE' == d.nodeName) {
  9223. c = null
  9224. break
  9225. }
  9226. if (e == d.nodeName.toLowerCase()) {
  9227. c = d
  9228. break
  9229. }
  9230. }
  9231. return c
  9232. ? b(c) || domUtils.getComputedStyle(c, 'list-style-type')
  9233. : null
  9234. }
  9235. })
  9236. }),
  9237. (function () {
  9238. var a = {
  9239. textarea: function (a, b) {
  9240. var c = b.ownerDocument.createElement('textarea')
  9241. return (
  9242. (c.style.cssText =
  9243. 'position:absolute;resize:none;width:100%;height:100%;border:0;padding:0;margin:0;overflow-y:auto;'),
  9244. browser.ie &&
  9245. browser.version < 8 &&
  9246. ((c.style.width = b.offsetWidth + 'px'),
  9247. (c.style.height = b.offsetHeight + 'px'),
  9248. (b.onresize = function () {
  9249. ;(c.style.width = b.offsetWidth + 'px'),
  9250. (c.style.height = b.offsetHeight + 'px')
  9251. })),
  9252. b.appendChild(c),
  9253. {
  9254. setContent: function (a) {
  9255. c.value = a
  9256. },
  9257. getContent: function () {
  9258. return c.value
  9259. },
  9260. select: function () {
  9261. var a
  9262. browser.ie
  9263. ? ((a = c.createTextRange()), a.collapse(!0), a.select())
  9264. : (c.setSelectionRange(0, 0), c.focus())
  9265. },
  9266. dispose: function () {
  9267. b.removeChild(c), (b.onresize = null), (c = null), (b = null)
  9268. }
  9269. }
  9270. )
  9271. },
  9272. codemirror: function (a, b) {
  9273. var c = window.CodeMirror(b, {
  9274. mode: 'text/html',
  9275. tabMode: 'indent',
  9276. lineNumbers: !0,
  9277. lineWrapping: !0
  9278. }),
  9279. d = c.getWrapperElement()
  9280. return (
  9281. (d.style.cssText =
  9282. 'position:absolute;left:0;top:0;width:100%;height:100%;font-family:consolas,"Courier new",monospace;font-size:13px;'),
  9283. (c.getScrollerElement().style.cssText =
  9284. 'position:absolute;left:0;top:0;width:100%;height:100%;'),
  9285. c.refresh(),
  9286. {
  9287. getCodeMirror: function () {
  9288. return c
  9289. },
  9290. setContent: function (a) {
  9291. c.setValue(a)
  9292. },
  9293. getContent: function () {
  9294. return c.getValue()
  9295. },
  9296. select: function () {
  9297. c.focus()
  9298. },
  9299. dispose: function () {
  9300. b.removeChild(d), (d = null), (c = null)
  9301. }
  9302. }
  9303. )
  9304. }
  9305. }
  9306. UE.plugins.source = function () {
  9307. function b(b) {
  9308. return a[
  9309. 'codemirror' == f.sourceEditor && window.CodeMirror
  9310. ? 'codemirror'
  9311. : 'textarea'
  9312. ](e, b)
  9313. }
  9314. var c,
  9315. d,
  9316. e = this,
  9317. f = this.options,
  9318. g = !1
  9319. ;(f.sourceEditor = browser.ie
  9320. ? 'textarea'
  9321. : f.sourceEditor || 'codemirror'),
  9322. e.setOpt({ sourceEditorFirst: !1 })
  9323. var h, i, j
  9324. e.commands.source = {
  9325. execCommand: function () {
  9326. if ((g = !g)) {
  9327. ;(j = e.selection.getRange().createAddress(!1, !0)),
  9328. e.undoManger && e.undoManger.save(!0),
  9329. browser.gecko && (e.body.contentEditable = !1),
  9330. (h = e.iframe.style.cssText),
  9331. (e.iframe.style.cssText +=
  9332. 'position:absolute;left:-32768px;top:-32768px;'),
  9333. e.fireEvent('beforegetcontent')
  9334. var a = UE.htmlparser(e.body.innerHTML)
  9335. e.filterOutputRule(a),
  9336. a.traversal(function (a) {
  9337. if ('element' == a.type)
  9338. switch (a.tagName) {
  9339. case 'td':
  9340. case 'th':
  9341. case 'caption':
  9342. a.children &&
  9343. 1 == a.children.length &&
  9344. 'br' == a.firstChild().tagName &&
  9345. a.removeChild(a.firstChild())
  9346. break
  9347. case 'pre':
  9348. a.innerText(a.innerText().replace(/&nbsp;/g, ' '))
  9349. }
  9350. }),
  9351. e.fireEvent('aftergetcontent')
  9352. var f = a.toHtml(!0)
  9353. ;(c = b(e.iframe.parentNode)),
  9354. c.setContent(f),
  9355. (d = e.setContent),
  9356. (e.setContent = function (a) {
  9357. var b = UE.htmlparser(a)
  9358. e.filterInputRule(b), (a = b.toHtml()), c.setContent(a)
  9359. }),
  9360. setTimeout(function () {
  9361. c.select(),
  9362. e.addListener('fullscreenchanged', function () {
  9363. try {
  9364. c.getCodeMirror().refresh()
  9365. } catch (a) {}
  9366. })
  9367. }),
  9368. (i = e.getContent),
  9369. (e.getContent = function () {
  9370. return (
  9371. c.getContent() ||
  9372. '<p>' + (browser.ie ? '' : '<br/>') + '</p>'
  9373. )
  9374. })
  9375. } else {
  9376. e.iframe.style.cssText = h
  9377. var k =
  9378. c.getContent() || '<p>' + (browser.ie ? '' : '<br/>') + '</p>'
  9379. ;(k = k.replace(
  9380. new RegExp('[\\r\\t\\n ]*</?(\\w+)\\s*(?:[^>]*)>', 'g'),
  9381. function (a, b) {
  9382. return b && !dtd.$inlineWithA[b.toLowerCase()]
  9383. ? a.replace(/(^[\n\r\t ]*)|([\n\r\t ]*$)/g, '')
  9384. : a.replace(/(^[\n\r\t]*)|([\n\r\t]*$)/g, '')
  9385. }
  9386. )),
  9387. (e.setContent = d),
  9388. e.setContent(k),
  9389. c.dispose(),
  9390. (c = null),
  9391. (e.getContent = i)
  9392. var l = e.body.firstChild
  9393. if (
  9394. (l ||
  9395. ((e.body.innerHTML =
  9396. '<p>' + (browser.ie ? '' : '<br/>') + '</p>'),
  9397. (l = e.body.firstChild)),
  9398. e.undoManger && e.undoManger.save(!0),
  9399. browser.gecko)
  9400. ) {
  9401. var m = document.createElement('input')
  9402. ;(m.style.cssText = 'position:absolute;left:0;top:-32768px'),
  9403. document.body.appendChild(m),
  9404. (e.body.contentEditable = !1),
  9405. setTimeout(function () {
  9406. domUtils.setViewportOffset(m, { left: -32768, top: 0 }),
  9407. m.focus(),
  9408. setTimeout(function () {
  9409. ;(e.body.contentEditable = !0),
  9410. e.selection.getRange().moveToAddress(j).select(!0),
  9411. domUtils.remove(m)
  9412. })
  9413. })
  9414. } else
  9415. try {
  9416. e.selection.getRange().moveToAddress(j).select(!0)
  9417. } catch (n) {}
  9418. }
  9419. this.fireEvent('sourcemodechanged', g)
  9420. },
  9421. queryCommandState: function () {
  9422. return 0 | g
  9423. },
  9424. notNeedUndo: 1
  9425. }
  9426. var k = e.queryCommandState
  9427. ;(e.queryCommandState = function (a) {
  9428. return (
  9429. (a = a.toLowerCase()),
  9430. g
  9431. ? a in { source: 1, fullscreen: 1 }
  9432. ? 1
  9433. : -1
  9434. : k.apply(this, arguments)
  9435. )
  9436. }),
  9437. 'codemirror' == f.sourceEditor &&
  9438. e.addListener('ready', function () {
  9439. utils.loadFile(
  9440. document,
  9441. {
  9442. src:
  9443. f.codeMirrorJsUrl ||
  9444. f.UEDITOR_HOME_URL + 'third-party/codemirror/codemirror.js',
  9445. tag: 'script',
  9446. type: 'text/javascript',
  9447. defer: 'defer'
  9448. },
  9449. function () {
  9450. f.sourceEditorFirst &&
  9451. setTimeout(function () {
  9452. e.execCommand('source')
  9453. }, 0)
  9454. }
  9455. ),
  9456. utils.loadFile(document, {
  9457. tag: 'link',
  9458. rel: 'stylesheet',
  9459. type: 'text/css',
  9460. href:
  9461. f.codeMirrorCssUrl ||
  9462. f.UEDITOR_HOME_URL + 'third-party/codemirror/codemirror.css'
  9463. })
  9464. })
  9465. }
  9466. })(),
  9467. (UE.plugins.enterkey = function () {
  9468. var a,
  9469. b = this,
  9470. c = b.options.enterTag
  9471. b.addListener('keyup', function (c, d) {
  9472. var e = d.keyCode || d.which
  9473. if (13 == e) {
  9474. var f,
  9475. g = b.selection.getRange(),
  9476. h = g.startContainer
  9477. if (browser.ie) b.fireEvent('saveScene', !0, !0)
  9478. else {
  9479. if (/h\d/i.test(a)) {
  9480. if (browser.gecko) {
  9481. var i = domUtils.findParentByTagName(
  9482. h,
  9483. [
  9484. 'h1',
  9485. 'h2',
  9486. 'h3',
  9487. 'h4',
  9488. 'h5',
  9489. 'h6',
  9490. 'blockquote',
  9491. 'caption',
  9492. 'table'
  9493. ],
  9494. !0
  9495. )
  9496. i || (b.document.execCommand('formatBlock', !1, '<p>'), (f = 1))
  9497. } else if (1 == h.nodeType) {
  9498. var j,
  9499. k = b.document.createTextNode('')
  9500. if (
  9501. (g.insertNode(k),
  9502. (j = domUtils.findParentByTagName(k, 'div', !0)))
  9503. ) {
  9504. for (var l = b.document.createElement('p'); j.firstChild; )
  9505. l.appendChild(j.firstChild)
  9506. j.parentNode.insertBefore(l, j),
  9507. domUtils.remove(j),
  9508. g.setStartBefore(k).setCursor(),
  9509. (f = 1)
  9510. }
  9511. domUtils.remove(k)
  9512. }
  9513. b.undoManger && f && b.undoManger.save()
  9514. }
  9515. browser.opera && g.select()
  9516. }
  9517. }
  9518. }),
  9519. b.addListener('keydown', function (d, e) {
  9520. var f = e.keyCode || e.which
  9521. if (13 == f) {
  9522. if (b.fireEvent('beforeenterkeydown'))
  9523. return void domUtils.preventDefault(e)
  9524. b.fireEvent('saveScene', !0, !0), (a = '')
  9525. var g = b.selection.getRange()
  9526. if (!g.collapsed) {
  9527. var h = g.startContainer,
  9528. i = g.endContainer,
  9529. j = domUtils.findParentByTagName(h, 'td', !0),
  9530. k = domUtils.findParentByTagName(i, 'td', !0)
  9531. if ((j && k && j !== k) || (!j && k) || (j && !k))
  9532. return void (e.preventDefault
  9533. ? e.preventDefault()
  9534. : (e.returnValue = !1))
  9535. }
  9536. if ('p' == c)
  9537. browser.ie ||
  9538. ((h = domUtils.findParentByTagName(
  9539. g.startContainer,
  9540. [
  9541. 'ol',
  9542. 'ul',
  9543. 'p',
  9544. 'h1',
  9545. 'h2',
  9546. 'h3',
  9547. 'h4',
  9548. 'h5',
  9549. 'h6',
  9550. 'blockquote',
  9551. 'caption'
  9552. ],
  9553. !0
  9554. )),
  9555. h || browser.opera
  9556. ? ((a = h.tagName),
  9557. 'p' == h.tagName.toLowerCase() &&
  9558. browser.gecko &&
  9559. domUtils.removeDirtyAttr(h))
  9560. : (b.document.execCommand('formatBlock', !1, '<p>'),
  9561. browser.gecko &&
  9562. ((g = b.selection.getRange()),
  9563. (h = domUtils.findParentByTagName(
  9564. g.startContainer,
  9565. 'p',
  9566. !0
  9567. )),
  9568. h && domUtils.removeDirtyAttr(h))))
  9569. else if (
  9570. (e.preventDefault ? e.preventDefault() : (e.returnValue = !1),
  9571. g.collapsed)
  9572. ) {
  9573. ;(m = g.document.createElement('br')), g.insertNode(m)
  9574. var l = m.parentNode
  9575. l.lastChild === m
  9576. ? (m.parentNode.insertBefore(m.cloneNode(!0), m),
  9577. g.setStartBefore(m))
  9578. : g.setStartAfter(m),
  9579. g.setCursor()
  9580. } else if (
  9581. (g.deleteContents(),
  9582. (h = g.startContainer),
  9583. 1 == h.nodeType && (h = h.childNodes[g.startOffset]))
  9584. ) {
  9585. for (; 1 == h.nodeType; ) {
  9586. if (dtd.$empty[h.tagName])
  9587. return (
  9588. g.setStartBefore(h).setCursor(),
  9589. b.undoManger && b.undoManger.save(),
  9590. !1
  9591. )
  9592. if (!h.firstChild) {
  9593. var m = g.document.createElement('br')
  9594. return (
  9595. h.appendChild(m),
  9596. g.setStart(h, 0).setCursor(),
  9597. b.undoManger && b.undoManger.save(),
  9598. !1
  9599. )
  9600. }
  9601. h = h.firstChild
  9602. }
  9603. h === g.startContainer.childNodes[g.startOffset]
  9604. ? ((m = g.document.createElement('br')),
  9605. g.insertNode(m).setCursor())
  9606. : g.setStart(h, 0).setCursor()
  9607. } else
  9608. (m = g.document.createElement('br')),
  9609. g.insertNode(m).setStartAfter(m).setCursor()
  9610. }
  9611. })
  9612. }),
  9613. (UE.plugins.keystrokes = function () {
  9614. var a = this,
  9615. b = !0
  9616. a.addListener('keydown', function (c, d) {
  9617. var e = d.keyCode || d.which,
  9618. f = a.selection.getRange()
  9619. if (
  9620. !f.collapsed &&
  9621. !(d.ctrlKey || d.shiftKey || d.altKey || d.metaKey) &&
  9622. ((e >= 65 && e <= 90) ||
  9623. (e >= 48 && e <= 57) ||
  9624. (e >= 96 && e <= 111) ||
  9625. { 13: 1, 8: 1, 46: 1 }[e])
  9626. ) {
  9627. var g = f.startContainer
  9628. if (
  9629. (domUtils.isFillChar(g) && f.setStartBefore(g),
  9630. (g = f.endContainer),
  9631. domUtils.isFillChar(g) && f.setEndAfter(g),
  9632. f.txtToElmBoundary(),
  9633. f.endContainer &&
  9634. 1 == f.endContainer.nodeType &&
  9635. ((g = f.endContainer.childNodes[f.endOffset]),
  9636. g && domUtils.isBr(g) && f.setEndAfter(g)),
  9637. 0 == f.startOffset &&
  9638. ((g = f.startContainer),
  9639. domUtils.isBoundaryNode(g, 'firstChild') &&
  9640. ((g = f.endContainer),
  9641. f.endOffset ==
  9642. (3 == g.nodeType
  9643. ? g.nodeValue.length
  9644. : g.childNodes.length) &&
  9645. domUtils.isBoundaryNode(g, 'lastChild'))))
  9646. )
  9647. return (
  9648. a.fireEvent('saveScene'),
  9649. (a.body.innerHTML = '<p>' + (browser.ie ? '' : '<br/>') + '</p>'),
  9650. f.setStart(a.body.firstChild, 0).setCursor(!1, !0),
  9651. void a._selectionChange()
  9652. )
  9653. }
  9654. if (e == keymap.Backspace) {
  9655. if (
  9656. ((f = a.selection.getRange()),
  9657. (b = f.collapsed),
  9658. a.fireEvent('delkeydown', d))
  9659. )
  9660. return
  9661. var h, i
  9662. if (
  9663. (f.collapsed &&
  9664. f.inFillChar() &&
  9665. ((h = f.startContainer),
  9666. domUtils.isFillChar(h)
  9667. ? (f.setStartBefore(h).shrinkBoundary(!0).collapse(!0),
  9668. domUtils.remove(h))
  9669. : ((h.nodeValue = h.nodeValue.replace(
  9670. new RegExp('^' + domUtils.fillChar),
  9671. ''
  9672. )),
  9673. f.startOffset--,
  9674. f.collapse(!0).select(!0))),
  9675. (h = f.getClosedNode()))
  9676. )
  9677. return (
  9678. a.fireEvent('saveScene'),
  9679. f.setStartBefore(h),
  9680. domUtils.remove(h),
  9681. f.setCursor(),
  9682. a.fireEvent('saveScene'),
  9683. void domUtils.preventDefault(d)
  9684. )
  9685. if (
  9686. !browser.ie &&
  9687. ((h = domUtils.findParentByTagName(f.startContainer, 'table', !0)),
  9688. (i = domUtils.findParentByTagName(f.endContainer, 'table', !0)),
  9689. (h && !i) || (!h && i) || h !== i)
  9690. )
  9691. return void d.preventDefault()
  9692. }
  9693. if (e == keymap.Tab) {
  9694. var j = { ol: 1, ul: 1, table: 1 }
  9695. if (a.fireEvent('tabkeydown', d))
  9696. return void domUtils.preventDefault(d)
  9697. var k = a.selection.getRange()
  9698. a.fireEvent('saveScene')
  9699. for (
  9700. var l = 0,
  9701. m = '',
  9702. n = a.options.tabSize || 4,
  9703. o = a.options.tabNode || '&nbsp;';
  9704. l < n;
  9705. l++
  9706. )
  9707. m += o
  9708. var p = a.document.createElement('span')
  9709. if (((p.innerHTML = m + domUtils.fillChar), k.collapsed))
  9710. k.insertNode(p.cloneNode(!0).firstChild).setCursor(!0)
  9711. else {
  9712. var q = function (a) {
  9713. return domUtils.isBlockElm(a) && !j[a.tagName.toLowerCase()]
  9714. }
  9715. if (
  9716. ((h = domUtils.findParent(k.startContainer, q, !0)),
  9717. (i = domUtils.findParent(k.endContainer, q, !0)),
  9718. h && i && h === i)
  9719. )
  9720. k.deleteContents(),
  9721. k.insertNode(p.cloneNode(!0).firstChild).setCursor(!0)
  9722. else {
  9723. var r = k.createBookmark()
  9724. k.enlarge(!0)
  9725. for (
  9726. var s = k.createBookmark(),
  9727. t = domUtils.getNextDomNode(s.start, !1, q);
  9728. t &&
  9729. !(domUtils.getPosition(t, s.end) & domUtils.POSITION_FOLLOWING);
  9730. )
  9731. t.insertBefore(p.cloneNode(!0).firstChild, t.firstChild),
  9732. (t = domUtils.getNextDomNode(t, !1, q))
  9733. k.moveToBookmark(s).moveToBookmark(r).select()
  9734. }
  9735. }
  9736. domUtils.preventDefault(d)
  9737. }
  9738. if (
  9739. browser.gecko &&
  9740. 46 == e &&
  9741. ((k = a.selection.getRange()),
  9742. k.collapsed && ((h = k.startContainer), domUtils.isEmptyBlock(h)))
  9743. ) {
  9744. for (
  9745. var u = h.parentNode;
  9746. 1 == domUtils.getChildCount(u) && !domUtils.isBody(u);
  9747. )
  9748. (h = u), (u = u.parentNode)
  9749. return void (h === u.lastChild && d.preventDefault())
  9750. }
  9751. }),
  9752. a.addListener('keyup', function (a, c) {
  9753. var d,
  9754. e = c.keyCode || c.which,
  9755. f = this
  9756. if (e == keymap.Backspace) {
  9757. if (f.fireEvent('delkeyup')) return
  9758. if (((d = f.selection.getRange()), d.collapsed)) {
  9759. var g,
  9760. h = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
  9761. if (
  9762. (g = domUtils.findParentByTagName(d.startContainer, h, !0)) &&
  9763. domUtils.isEmptyBlock(g)
  9764. ) {
  9765. var i = g.previousSibling
  9766. if (i && 'TABLE' != i.nodeName)
  9767. return (
  9768. domUtils.remove(g),
  9769. void d.setStartAtLast(i).setCursor(!1, !0)
  9770. )
  9771. var j = g.nextSibling
  9772. if (j && 'TABLE' != j.nodeName)
  9773. return (
  9774. domUtils.remove(g),
  9775. void d.setStartAtFirst(j).setCursor(!1, !0)
  9776. )
  9777. }
  9778. if (domUtils.isBody(d.startContainer)) {
  9779. var g = domUtils.createElement(f.document, 'p', {
  9780. innerHTML: browser.ie ? domUtils.fillChar : '<br/>'
  9781. })
  9782. d.insertNode(g).setStart(g, 0).setCursor(!1, !0)
  9783. }
  9784. }
  9785. if (
  9786. !b &&
  9787. (3 == d.startContainer.nodeType ||
  9788. (1 == d.startContainer.nodeType &&
  9789. domUtils.isEmptyBlock(d.startContainer)))
  9790. )
  9791. if (browser.ie) {
  9792. var k = d.document.createElement('span')
  9793. d.insertNode(k).setStartBefore(k).collapse(!0),
  9794. d.select(),
  9795. domUtils.remove(k)
  9796. } else d.select()
  9797. }
  9798. })
  9799. }),
  9800. (UE.plugins.fiximgclick = (function () {
  9801. function a() {
  9802. ;(this.editor = null),
  9803. (this.resizer = null),
  9804. (this.cover = null),
  9805. (this.doc = document),
  9806. (this.prePos = { x: 0, y: 0 }),
  9807. (this.startPos = { x: 0, y: 0 })
  9808. }
  9809. var b = !1
  9810. return (
  9811. (function () {
  9812. var c = [
  9813. [0, 0, -1, -1],
  9814. [0, 0, 0, -1],
  9815. [0, 0, 1, -1],
  9816. [0, 0, -1, 0],
  9817. [0, 0, 1, 0],
  9818. [0, 0, -1, 1],
  9819. [0, 0, 0, 1],
  9820. [0, 0, 1, 1]
  9821. ]
  9822. a.prototype = {
  9823. init: function (a) {
  9824. var b = this
  9825. ;(b.editor = a),
  9826. (b.startPos = this.prePos = { x: 0, y: 0 }),
  9827. (b.dragId = -1)
  9828. var c = [],
  9829. d = (b.cover = document.createElement('div')),
  9830. e = (b.resizer = document.createElement('div'))
  9831. for (
  9832. d.id = b.editor.ui.id + '_imagescale_cover',
  9833. d.style.cssText =
  9834. 'position:absolute;display:none;z-index:' +
  9835. b.editor.options.zIndex +
  9836. ';filter:alpha(opacity=0); opacity:0;background:#CCC;',
  9837. domUtils.on(d, 'mousedown click', function () {
  9838. b.hide()
  9839. }),
  9840. i = 0;
  9841. i < 8;
  9842. i++
  9843. )
  9844. c.push(
  9845. '<span class="edui-editor-imagescale-hand' + i + '"></span>'
  9846. )
  9847. ;(e.id = b.editor.ui.id + '_imagescale'),
  9848. (e.className = 'edui-editor-imagescale'),
  9849. (e.innerHTML = c.join('')),
  9850. (e.style.cssText +=
  9851. ';display:none;border:1px solid #3b77ff;z-index:' +
  9852. b.editor.options.zIndex +
  9853. ';'),
  9854. b.editor.ui.getDom().appendChild(d),
  9855. b.editor.ui.getDom().appendChild(e),
  9856. b.initStyle(),
  9857. b.initEvents()
  9858. },
  9859. initStyle: function () {
  9860. utils.cssRule(
  9861. 'imagescale',
  9862. '.edui-editor-imagescale{display:none;position:absolute;border:1px solid #38B2CE;cursor:hand;-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;}.edui-editor-imagescale span{position:absolute;width:6px;height:6px;overflow:hidden;font-size:0px;display:block;background-color:#3C9DD0;}.edui-editor-imagescale .edui-editor-imagescale-hand0{cursor:nw-resize;top:0;margin-top:-4px;left:0;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand1{cursor:n-resize;top:0;margin-top:-4px;left:50%;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand2{cursor:ne-resize;top:0;margin-top:-4px;left:100%;margin-left:-3px;}.edui-editor-imagescale .edui-editor-imagescale-hand3{cursor:w-resize;top:50%;margin-top:-4px;left:0;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand4{cursor:e-resize;top:50%;margin-top:-4px;left:100%;margin-left:-3px;}.edui-editor-imagescale .edui-editor-imagescale-hand5{cursor:sw-resize;top:100%;margin-top:-3px;left:0;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand6{cursor:s-resize;top:100%;margin-top:-3px;left:50%;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand7{cursor:se-resize;top:100%;margin-top:-3px;left:100%;margin-left:-3px;}'
  9863. )
  9864. },
  9865. initEvents: function () {
  9866. var a = this
  9867. ;(a.startPos.x = a.startPos.y = 0), (a.isDraging = !1)
  9868. },
  9869. _eventHandler: function (a) {
  9870. var c = this
  9871. switch (a.type) {
  9872. case 'mousedown':
  9873. var d,
  9874. d = a.target || a.srcElement
  9875. d.className.indexOf('edui-editor-imagescale-hand') != -1 &&
  9876. c.dragId == -1 &&
  9877. ((c.dragId = d.className.slice(-1)),
  9878. (c.startPos.x = c.prePos.x = a.clientX),
  9879. (c.startPos.y = c.prePos.y = a.clientY),
  9880. domUtils.on(
  9881. c.doc,
  9882. 'mousemove',
  9883. c.proxy(c._eventHandler, c)
  9884. ))
  9885. break
  9886. case 'mousemove':
  9887. c.dragId != -1 &&
  9888. (c.updateContainerStyle(c.dragId, {
  9889. x: a.clientX - c.prePos.x,
  9890. y: a.clientY - c.prePos.y
  9891. }),
  9892. (c.prePos.x = a.clientX),
  9893. (c.prePos.y = a.clientY),
  9894. (b = !0),
  9895. c.updateTargetElement())
  9896. break
  9897. case 'mouseup':
  9898. c.dragId != -1 &&
  9899. (c.updateContainerStyle(c.dragId, {
  9900. x: a.clientX - c.prePos.x,
  9901. y: a.clientY - c.prePos.y
  9902. }),
  9903. c.updateTargetElement(),
  9904. c.target.parentNode && c.attachTo(c.target),
  9905. (c.dragId = -1)),
  9906. domUtils.un(
  9907. c.doc,
  9908. 'mousemove',
  9909. c.proxy(c._eventHandler, c)
  9910. ),
  9911. b && ((b = !1), c.editor.fireEvent('contentchange'))
  9912. }
  9913. },
  9914. updateTargetElement: function () {
  9915. var a = this
  9916. domUtils.setStyles(a.target, {
  9917. width: a.resizer.style.width,
  9918. height: a.resizer.style.height
  9919. }),
  9920. (a.target.width = parseInt(a.resizer.style.width)),
  9921. (a.target.height = parseInt(a.resizer.style.height)),
  9922. a.attachTo(a.target)
  9923. },
  9924. updateContainerStyle: function (a, b) {
  9925. var d,
  9926. e = this,
  9927. f = e.resizer
  9928. 0 != c[a][0] &&
  9929. ((d = parseInt(f.style.left) + b.x),
  9930. (f.style.left = e._validScaledProp('left', d) + 'px')),
  9931. 0 != c[a][1] &&
  9932. ((d = parseInt(f.style.top) + b.y),
  9933. (f.style.top = e._validScaledProp('top', d) + 'px')),
  9934. 0 != c[a][2] &&
  9935. ((d = f.clientWidth + c[a][2] * b.x),
  9936. (f.style.width = e._validScaledProp('width', d) + 'px')),
  9937. 0 != c[a][3] &&
  9938. ((d = f.clientHeight + c[a][3] * b.y),
  9939. (f.style.height = e._validScaledProp('height', d) + 'px'))
  9940. },
  9941. _validScaledProp: function (a, b) {
  9942. var c = this.resizer,
  9943. d = document
  9944. switch (((b = isNaN(b) ? 0 : b), a)) {
  9945. case 'left':
  9946. return b < 0
  9947. ? 0
  9948. : b + c.clientWidth > d.clientWidth
  9949. ? d.clientWidth - c.clientWidth
  9950. : b
  9951. case 'top':
  9952. return b < 0
  9953. ? 0
  9954. : b + c.clientHeight > d.clientHeight
  9955. ? d.clientHeight - c.clientHeight
  9956. : b
  9957. case 'width':
  9958. return b <= 0
  9959. ? 1
  9960. : b + c.offsetLeft > d.clientWidth
  9961. ? d.clientWidth - c.offsetLeft
  9962. : b
  9963. case 'height':
  9964. return b <= 0
  9965. ? 1
  9966. : b + c.offsetTop > d.clientHeight
  9967. ? d.clientHeight - c.offsetTop
  9968. : b
  9969. }
  9970. },
  9971. hideCover: function () {
  9972. this.cover.style.display = 'none'
  9973. },
  9974. showCover: function () {
  9975. var a = this,
  9976. b = domUtils.getXY(a.editor.ui.getDom()),
  9977. c = domUtils.getXY(a.editor.iframe)
  9978. domUtils.setStyles(a.cover, {
  9979. width: a.editor.iframe.offsetWidth + 'px',
  9980. height: a.editor.iframe.offsetHeight + 'px',
  9981. top: c.y - b.y + 'px',
  9982. left: c.x - b.x + 'px',
  9983. position: 'absolute',
  9984. display: ''
  9985. })
  9986. },
  9987. show: function (a) {
  9988. var b = this
  9989. ;(b.resizer.style.display = 'block'),
  9990. a && b.attachTo(a),
  9991. domUtils.on(
  9992. this.resizer,
  9993. 'mousedown',
  9994. b.proxy(b._eventHandler, b)
  9995. ),
  9996. domUtils.on(b.doc, 'mouseup', b.proxy(b._eventHandler, b)),
  9997. b.showCover(),
  9998. b.editor.fireEvent('afterscaleshow', b),
  9999. b.editor.fireEvent('saveScene')
  10000. },
  10001. hide: function () {
  10002. var a = this
  10003. a.hideCover(),
  10004. (a.resizer.style.display = 'none'),
  10005. domUtils.un(
  10006. a.resizer,
  10007. 'mousedown',
  10008. a.proxy(a._eventHandler, a)
  10009. ),
  10010. domUtils.un(a.doc, 'mouseup', a.proxy(a._eventHandler, a)),
  10011. a.editor.fireEvent('afterscalehide', a)
  10012. },
  10013. proxy: function (a, b) {
  10014. return function (c) {
  10015. return a.apply(b || this, arguments)
  10016. }
  10017. },
  10018. attachTo: function (a) {
  10019. var b = this,
  10020. c = (b.target = a),
  10021. d = this.resizer,
  10022. e = domUtils.getXY(c),
  10023. f = domUtils.getXY(b.editor.iframe),
  10024. g = domUtils.getXY(d.parentNode)
  10025. domUtils.setStyles(d, {
  10026. width: c.width + 'px',
  10027. height: c.height + 'px',
  10028. left:
  10029. f.x +
  10030. e.x -
  10031. b.editor.document.body.scrollLeft -
  10032. g.x -
  10033. parseInt(d.style.borderLeftWidth) +
  10034. 'px',
  10035. top:
  10036. f.y +
  10037. e.y -
  10038. b.editor.document.body.scrollTop -
  10039. g.y -
  10040. parseInt(d.style.borderTopWidth) +
  10041. 'px'
  10042. })
  10043. }
  10044. }
  10045. })(),
  10046. function () {
  10047. var b,
  10048. c = this
  10049. c.setOpt('imageScaleEnabled', !0),
  10050. !browser.ie &&
  10051. c.options.imageScaleEnabled &&
  10052. c.addListener('click', function (d, e) {
  10053. var f = c.selection.getRange(),
  10054. g = f.getClosedNode()
  10055. if (
  10056. g &&
  10057. 'IMG' == g.tagName &&
  10058. 'false' != c.body.contentEditable
  10059. ) {
  10060. if (
  10061. g.className.indexOf('edui-faked-music') != -1 ||
  10062. g.getAttribute('anchorname') ||
  10063. domUtils.hasClass(g, 'loadingclass') ||
  10064. domUtils.hasClass(g, 'loaderrorclass')
  10065. )
  10066. return
  10067. if (!b) {
  10068. ;(b = new a()),
  10069. b.init(c),
  10070. c.ui.getDom().appendChild(b.resizer)
  10071. var h,
  10072. i = function (a) {
  10073. b.hide(),
  10074. b.target &&
  10075. c.selection.getRange().selectNode(b.target).select()
  10076. },
  10077. j = function (a) {
  10078. var b = a.target || a.srcElement
  10079. !b ||
  10080. (void 0 !== b.className &&
  10081. b.className.indexOf('edui-editor-imagescale') !=
  10082. -1) ||
  10083. i(a)
  10084. }
  10085. c.addListener('afterscaleshow', function (a) {
  10086. c.addListener('beforekeydown', i),
  10087. c.addListener('beforemousedown', j),
  10088. domUtils.on(document, 'keydown', i),
  10089. domUtils.on(document, 'mousedown', j),
  10090. c.selection.getNative().removeAllRanges()
  10091. }),
  10092. c.addListener('afterscalehide', function (a) {
  10093. c.removeListener('beforekeydown', i),
  10094. c.removeListener('beforemousedown', j),
  10095. domUtils.un(document, 'keydown', i),
  10096. domUtils.un(document, 'mousedown', j)
  10097. var d = b.target
  10098. d.parentNode &&
  10099. c.selection.getRange().selectNode(d).select()
  10100. }),
  10101. domUtils.on(b.resizer, 'mousedown', function (a) {
  10102. c.selection.getNative().removeAllRanges()
  10103. var d = a.target || a.srcElement
  10104. d &&
  10105. d.className.indexOf('edui-editor-imagescale-hand') ==
  10106. -1 &&
  10107. (h = setTimeout(function () {
  10108. b.hide(),
  10109. b.target &&
  10110. c.selection.getRange().selectNode(d).select()
  10111. }, 200))
  10112. }),
  10113. domUtils.on(b.resizer, 'mouseup', function (a) {
  10114. var b = a.target || a.srcElement
  10115. b &&
  10116. b.className.indexOf('edui-editor-imagescale-hand') ==
  10117. -1 &&
  10118. clearTimeout(h)
  10119. })
  10120. }
  10121. b.show(g)
  10122. } else b && 'none' != b.resizer.style.display && b.hide()
  10123. }),
  10124. browser.webkit &&
  10125. c.addListener('click', function (a, b) {
  10126. if (
  10127. 'IMG' == b.target.tagName &&
  10128. 'false' != c.body.contentEditable
  10129. ) {
  10130. var d = new dom.Range(c.document)
  10131. d.selectNode(b.target).select()
  10132. }
  10133. })
  10134. }
  10135. )
  10136. })()),
  10137. UE.plugin.register(
  10138. 'autolink',
  10139. function () {
  10140. var a = 0
  10141. return browser.ie
  10142. ? {}
  10143. : {
  10144. bindEvents: {
  10145. reset: function () {
  10146. a = 0
  10147. },
  10148. keydown: function (a, b) {
  10149. var c = this,
  10150. d = b.keyCode || b.which
  10151. if (32 == d || 13 == d) {
  10152. for (
  10153. var e,
  10154. f,
  10155. g = c.selection.getNative(),
  10156. h = g.getRangeAt(0).cloneRange(),
  10157. i = h.startContainer;
  10158. 1 == i.nodeType &&
  10159. h.startOffset > 0 &&
  10160. (i = h.startContainer.childNodes[h.startOffset - 1]);
  10161. )
  10162. h.setStart(
  10163. i,
  10164. 1 == i.nodeType
  10165. ? i.childNodes.length
  10166. : i.nodeValue.length
  10167. ),
  10168. h.collapse(!0),
  10169. (i = h.startContainer)
  10170. do {
  10171. if (0 == h.startOffset) {
  10172. for (
  10173. i = h.startContainer.previousSibling;
  10174. i && 1 == i.nodeType;
  10175. )
  10176. i = i.lastChild
  10177. if (!i || domUtils.isFillChar(i)) break
  10178. e = i.nodeValue.length
  10179. } else (i = h.startContainer), (e = h.startOffset)
  10180. h.setStart(i, e - 1), (f = h.toString().charCodeAt(0))
  10181. } while (160 != f && 32 != f)
  10182. if (
  10183. h
  10184. .toString()
  10185. .replace(new RegExp(domUtils.fillChar, 'g'), '')
  10186. .match(
  10187. /(?:https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)/i
  10188. )
  10189. ) {
  10190. for (
  10191. ;
  10192. h.toString().length &&
  10193. !/^(?:https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)/i.test(
  10194. h.toString()
  10195. );
  10196. )
  10197. try {
  10198. h.setStart(h.startContainer, h.startOffset + 1)
  10199. } catch (j) {
  10200. for (
  10201. var i = h.startContainer;
  10202. !(next = i.nextSibling);
  10203. ) {
  10204. if (domUtils.isBody(i)) return
  10205. i = i.parentNode
  10206. }
  10207. h.setStart(next, 0)
  10208. }
  10209. if (
  10210. domUtils.findParentByTagName(h.startContainer, 'a', !0)
  10211. )
  10212. return
  10213. var k,
  10214. l = c.document.createElement('a'),
  10215. m = c.document.createTextNode(' ')
  10216. c.undoManger && c.undoManger.save(),
  10217. l.appendChild(h.extractContents()),
  10218. (l.href = l.innerHTML =
  10219. l.innerHTML.replace(/<[^>]+>/g, '')),
  10220. (k = l
  10221. .getAttribute('href')
  10222. .replace(new RegExp(domUtils.fillChar, 'g'), '')),
  10223. (k = /^(?:https?:\/\/)/gi.test(k) ? k : 'http://' + k),
  10224. l.setAttribute('_src', utils.html(k)),
  10225. (l.href = utils.html(k)),
  10226. h.insertNode(l),
  10227. l.parentNode.insertBefore(m, l.nextSibling),
  10228. h.setStart(m, 0),
  10229. h.collapse(!0),
  10230. g.removeAllRanges(),
  10231. g.addRange(h),
  10232. c.undoManger && c.undoManger.save()
  10233. }
  10234. }
  10235. }
  10236. }
  10237. }
  10238. },
  10239. function () {
  10240. function a(a) {
  10241. if (3 == a.nodeType) return null
  10242. if ('A' == a.nodeName) return a
  10243. for (var b = a.lastChild; b; ) {
  10244. if ('A' == b.nodeName) return b
  10245. if (3 == b.nodeType) {
  10246. if (domUtils.isWhitespace(b)) {
  10247. b = b.previousSibling
  10248. continue
  10249. }
  10250. return null
  10251. }
  10252. b = b.lastChild
  10253. }
  10254. }
  10255. var b = { 37: 1, 38: 1, 39: 1, 40: 1, 13: 1, 32: 1 }
  10256. browser.ie &&
  10257. this.addListener('keyup', function (c, d) {
  10258. var e = this,
  10259. f = d.keyCode
  10260. if (b[f]) {
  10261. var g = e.selection.getRange(),
  10262. h = g.startContainer
  10263. if (13 == f) {
  10264. for (; h && !domUtils.isBody(h) && !domUtils.isBlockElm(h); )
  10265. h = h.parentNode
  10266. if (h && !domUtils.isBody(h) && 'P' == h.nodeName) {
  10267. var i = h.previousSibling
  10268. if (i && 1 == i.nodeType) {
  10269. var i = a(i)
  10270. i && !i.getAttribute('_href') && domUtils.remove(i, !0)
  10271. }
  10272. }
  10273. } else if (32 == f)
  10274. 3 == h.nodeType &&
  10275. /^\s$/.test(h.nodeValue) &&
  10276. ((h = h.previousSibling),
  10277. h &&
  10278. 'A' == h.nodeName &&
  10279. !h.getAttribute('_href') &&
  10280. domUtils.remove(h, !0))
  10281. else if (
  10282. ((h = domUtils.findParentByTagName(h, 'a', !0)),
  10283. h && !h.getAttribute('_href'))
  10284. ) {
  10285. var j = g.createBookmark()
  10286. domUtils.remove(h, !0), g.moveToBookmark(j).select(!0)
  10287. }
  10288. }
  10289. })
  10290. }
  10291. ),
  10292. (UE.plugins.autoheight = function () {
  10293. function a() {
  10294. var a = this
  10295. clearTimeout(e),
  10296. f ||
  10297. ((!a.queryCommandState ||
  10298. (a.queryCommandState && 1 != a.queryCommandState('source'))) &&
  10299. (e = setTimeout(function () {
  10300. for (var b = a.body.lastChild; b && 1 != b.nodeType; )
  10301. b = b.previousSibling
  10302. b &&
  10303. 1 == b.nodeType &&
  10304. ((b.style.clear = 'both'),
  10305. (d = Math.max(
  10306. domUtils.getXY(b).y + b.offsetHeight + 25,
  10307. Math.max(h.minFrameHeight, h.initialFrameHeight)
  10308. )),
  10309. d != g &&
  10310. (d !== parseInt(a.iframe.parentNode.style.height) &&
  10311. (a.iframe.parentNode.style.height = d + 'px'),
  10312. (a.body.style.height = d + 'px'),
  10313. (g = d)),
  10314. domUtils.removeStyle(b, 'clear'))
  10315. }, 50)))
  10316. }
  10317. var b = this
  10318. if (
  10319. ((b.autoHeightEnabled = b.options.autoHeightEnabled !== !1),
  10320. b.autoHeightEnabled)
  10321. ) {
  10322. var c,
  10323. d,
  10324. e,
  10325. f,
  10326. g = 0,
  10327. h = b.options
  10328. b.addListener('fullscreenchanged', function (a, b) {
  10329. f = b
  10330. }),
  10331. b.addListener('destroy', function () {
  10332. b.removeListener('contentchange afterinserthtml keyup mouseup', a)
  10333. }),
  10334. (b.enableAutoHeight = function () {
  10335. var b = this
  10336. if (b.autoHeightEnabled) {
  10337. var d = b.document
  10338. ;(b.autoHeightEnabled = !0),
  10339. (c = d.body.style.overflowY),
  10340. (d.body.style.overflowY = 'hidden'),
  10341. b.addListener('contentchange afterinserthtml keyup mouseup', a),
  10342. setTimeout(
  10343. function () {
  10344. a.call(b)
  10345. },
  10346. browser.gecko ? 100 : 0
  10347. ),
  10348. b.fireEvent('autoheightchanged', b.autoHeightEnabled)
  10349. }
  10350. }),
  10351. (b.disableAutoHeight = function () {
  10352. ;(b.body.style.overflowY = c || ''),
  10353. b.removeListener('contentchange', a),
  10354. b.removeListener('keyup', a),
  10355. b.removeListener('mouseup', a),
  10356. (b.autoHeightEnabled = !1),
  10357. b.fireEvent('autoheightchanged', b.autoHeightEnabled)
  10358. }),
  10359. b.on('setHeight', function () {
  10360. b.disableAutoHeight()
  10361. }),
  10362. b.addListener('ready', function () {
  10363. b.enableAutoHeight()
  10364. var c
  10365. domUtils.on(
  10366. browser.ie ? b.body : b.document,
  10367. browser.webkit ? 'dragover' : 'drop',
  10368. function () {
  10369. clearTimeout(c),
  10370. (c = setTimeout(function () {
  10371. a.call(b)
  10372. }, 100))
  10373. }
  10374. )
  10375. var d
  10376. window.onscroll = function () {
  10377. null === d
  10378. ? (d = this.scrollY)
  10379. : 0 == this.scrollY &&
  10380. 0 != d &&
  10381. (b.window.scrollTo(0, 0), (d = null))
  10382. }
  10383. })
  10384. }
  10385. }),
  10386. (UE.plugins.autofloat = function () {
  10387. function a() {
  10388. return UE.ui ? 1 : (alert(g.autofloatMsg), 0)
  10389. }
  10390. function b() {
  10391. var a = document.body.style
  10392. ;(a.backgroundImage = 'url("about:blank")'),
  10393. (a.backgroundAttachment = 'fixed')
  10394. }
  10395. function c() {
  10396. var a = domUtils.getXY(k),
  10397. b = domUtils.getComputedStyle(k, 'position'),
  10398. c = domUtils.getComputedStyle(k, 'left')
  10399. ;(k.style.width = k.offsetWidth + 'px'),
  10400. (k.style.zIndex = 1 * f.options.zIndex + 1),
  10401. k.parentNode.insertBefore(q, k),
  10402. o || (p && browser.ie)
  10403. ? ('absolute' != k.style.position &&
  10404. (k.style.position = 'absolute'),
  10405. (k.style.top =
  10406. (document.body.scrollTop ||
  10407. document.documentElement.scrollTop) -
  10408. l +
  10409. i +
  10410. 'px'))
  10411. : (browser.ie7Compat &&
  10412. r &&
  10413. ((r = !1),
  10414. (k.style.left =
  10415. domUtils.getXY(k).x -
  10416. document.documentElement.getBoundingClientRect().left +
  10417. 2 +
  10418. 'px')),
  10419. 'fixed' != k.style.position &&
  10420. ((k.style.position = 'fixed'),
  10421. (k.style.top = i + 'px'),
  10422. ('absolute' == b || 'relative' == b) &&
  10423. parseFloat(c) &&
  10424. (k.style.left = a.x + 'px')))
  10425. }
  10426. function d() {
  10427. ;(r = !0),
  10428. q.parentNode && q.parentNode.removeChild(q),
  10429. (k.style.cssText = j)
  10430. }
  10431. function e() {
  10432. var a = m(f.container),
  10433. b = f.options.toolbarTopOffset || 0
  10434. a.top < 0 && a.bottom - k.offsetHeight > b ? c() : d()
  10435. }
  10436. var f = this,
  10437. g = f.getLang()
  10438. f.setOpt({ topOffset: 0 })
  10439. var h = f.options.autoFloatEnabled !== !1,
  10440. i = f.options.topOffset
  10441. if (h) {
  10442. var j,
  10443. k,
  10444. l,
  10445. m,
  10446. n = UE.ui.uiUtils,
  10447. o = browser.ie && browser.version <= 6,
  10448. p = browser.quirks,
  10449. q = document.createElement('div'),
  10450. r = !0,
  10451. s = utils.defer(
  10452. function () {
  10453. e()
  10454. },
  10455. browser.ie ? 200 : 100,
  10456. !0
  10457. )
  10458. f.addListener('destroy', function () {
  10459. domUtils.un(window, ['scroll', 'resize'], e),
  10460. f.removeListener('keydown', s)
  10461. }),
  10462. f.addListener('ready', function () {
  10463. if (a(f)) {
  10464. if (!f.ui) return
  10465. ;(m = n.getClientRect),
  10466. (k = f.ui.getDom('toolbarbox')),
  10467. (l = m(k).top),
  10468. (j = k.style.cssText),
  10469. (q.style.height = k.offsetHeight + 'px'),
  10470. o && b(),
  10471. domUtils.on(window, ['scroll', 'resize'], e),
  10472. f.addListener('keydown', s),
  10473. f.addListener('beforefullscreenchange', function (a, b) {
  10474. b && d()
  10475. }),
  10476. f.addListener('fullscreenchanged', function (a, b) {
  10477. b || e()
  10478. }),
  10479. f.addListener('sourcemodechanged', function (a, b) {
  10480. setTimeout(function () {
  10481. e()
  10482. }, 0)
  10483. }),
  10484. f.addListener('clearDoc', function () {
  10485. setTimeout(function () {
  10486. e()
  10487. }, 0)
  10488. })
  10489. }
  10490. })
  10491. }
  10492. }),
  10493. (UE.plugins.video = function () {
  10494. function a(a, b, d, e, f, g, h) {
  10495. ;(a = utils.unhtmlForUrl(a)),
  10496. (f = utils.unhtml(f)),
  10497. (g = utils.unhtml(g).trim()),
  10498. (b = parseInt(b, 10) || 0),
  10499. (d = parseInt(d, 10) || 0)
  10500. var i
  10501. switch (h) {
  10502. case 'image':
  10503. i =
  10504. '<img ' +
  10505. (e ? 'id="' + e + '"' : '') +
  10506. ' width="' +
  10507. b +
  10508. '" height="' +
  10509. d +
  10510. '" _url="' +
  10511. a +
  10512. '" class="' +
  10513. g.replace(/\bvideo-js\b/, '') +
  10514. '" src="' +
  10515. c.options.UEDITOR_HOME_URL +
  10516. 'themes/default/images/spacer.gif" style="background:url(' +
  10517. c.options.UEDITOR_HOME_URL +
  10518. 'themes/default/images/videologo.gif) no-repeat center center; border:1px solid gray;' +
  10519. (f ? 'float:' + f + ';' : '') +
  10520. '" />'
  10521. break
  10522. case 'embed':
  10523. i =
  10524. '<embed type="application/x-shockwave-flash" class="' +
  10525. g +
  10526. '" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' +
  10527. utils.html(a) +
  10528. '" width="' +
  10529. b +
  10530. '" height="' +
  10531. d +
  10532. '"' +
  10533. (f ? ' style="float:' + f + '"' : '') +
  10534. ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >'
  10535. break
  10536. case 'video':
  10537. var j = a.substr(a.lastIndexOf('.') + 1)
  10538. 'ogv' == j && (j = 'ogg'),
  10539. (i =
  10540. '<video' +
  10541. (e ? ' id="' + e + '"' : '') +
  10542. ' class="' +
  10543. g +
  10544. ' video-js" ' +
  10545. (f ? ' style="float:' + f + '"' : '') +
  10546. ' controls preload="none" width="' +
  10547. b +
  10548. '" height="' +
  10549. d +
  10550. '" src="' +
  10551. a +
  10552. '" data-setup="{}"><source src="' +
  10553. a +
  10554. '" type="video/' +
  10555. j +
  10556. '" /></video>')
  10557. }
  10558. return i
  10559. }
  10560. function b(b, c) {
  10561. utils.each(
  10562. b.getNodesByTagName(c ? 'img' : 'embed video'),
  10563. function (b) {
  10564. var d = b.getAttr('class')
  10565. if (d && d.indexOf('edui-faked-video') != -1) {
  10566. var e = a(
  10567. c ? b.getAttr('_url') : b.getAttr('src'),
  10568. b.getAttr('width'),
  10569. b.getAttr('height'),
  10570. null,
  10571. b.getStyle('float') || '',
  10572. d,
  10573. c ? 'embed' : 'image'
  10574. )
  10575. b.parentNode.replaceChild(UE.uNode.createElement(e), b)
  10576. }
  10577. if (d && d.indexOf('edui-upload-video') != -1) {
  10578. var e = a(
  10579. c ? b.getAttr('_url') : b.getAttr('src'),
  10580. b.getAttr('width'),
  10581. b.getAttr('height'),
  10582. null,
  10583. b.getStyle('float') || '',
  10584. d,
  10585. c ? 'video' : 'image'
  10586. )
  10587. b.parentNode.replaceChild(UE.uNode.createElement(e), b)
  10588. }
  10589. }
  10590. )
  10591. }
  10592. var c = this
  10593. c.addOutputRule(function (a) {
  10594. b(a, !0)
  10595. }),
  10596. c.addInputRule(function (a) {
  10597. b(a)
  10598. }),
  10599. (c.commands.insertvideo = {
  10600. execCommand: function (b, d, e) {
  10601. d = utils.isArray(d) ? d : [d]
  10602. for (
  10603. var f, g, h = [], i = 'tmpVedio', j = 0, k = d.length;
  10604. j < k;
  10605. j++
  10606. )
  10607. (g = d[j]),
  10608. (f =
  10609. 'upload' == e
  10610. ? 'edui-upload-video video-js vjs-default-skin'
  10611. : 'edui-faked-video'),
  10612. h.push(
  10613. a(
  10614. g.url,
  10615. g.width || 420,
  10616. g.height || 280,
  10617. i + j,
  10618. null,
  10619. f,
  10620. 'image'
  10621. )
  10622. )
  10623. c.execCommand('inserthtml', h.join(''), !0)
  10624. for (
  10625. var l = this.selection.getRange(), j = 0, k = d.length;
  10626. j < k;
  10627. j++
  10628. ) {
  10629. var m = this.document.getElementById('tmpVedio' + j)
  10630. domUtils.removeAttributes(m, 'id'),
  10631. l.selectNode(m).select(),
  10632. c.execCommand('imagefloat', d[j].align)
  10633. }
  10634. },
  10635. queryCommandState: function () {
  10636. var a = c.selection.getRange().getClosedNode(),
  10637. b =
  10638. a &&
  10639. ('edui-faked-video' == a.className ||
  10640. a.className.indexOf('edui-upload-video') != -1)
  10641. return b ? 1 : 0
  10642. }
  10643. })
  10644. }),
  10645. (function () {
  10646. function a(a) {}
  10647. var b = (UE.UETable = function (a) {
  10648. ;(this.table = a),
  10649. (this.indexTable = []),
  10650. (this.selectedTds = []),
  10651. (this.cellsRange = {}),
  10652. this.update(a)
  10653. })
  10654. ;(b.removeSelectedClass = function (a) {
  10655. utils.each(a, function (a) {
  10656. domUtils.removeClasses(a, 'selectTdClass')
  10657. })
  10658. }),
  10659. (b.addSelectedClass = function (a) {
  10660. utils.each(a, function (a) {
  10661. domUtils.addClass(a, 'selectTdClass')
  10662. })
  10663. }),
  10664. (b.isEmptyBlock = function (a) {
  10665. var b = new RegExp(domUtils.fillChar, 'g')
  10666. if (
  10667. a[browser.ie ? 'innerText' : 'textContent']
  10668. .replace(/^\s*$/, '')
  10669. .replace(b, '').length > 0
  10670. )
  10671. return 0
  10672. for (var c in dtd.$isNotEmpty)
  10673. if (
  10674. dtd.$isNotEmpty.hasOwnProperty(c) &&
  10675. a.getElementsByTagName(c).length
  10676. )
  10677. return 0
  10678. return 1
  10679. }),
  10680. (b.getWidth = function (a) {
  10681. return a ? parseInt(domUtils.getComputedStyle(a, 'width'), 10) : 0
  10682. }),
  10683. (b.getTableCellAlignState = function (a) {
  10684. !utils.isArray(a) && (a = [a])
  10685. var b = {},
  10686. c = ['align', 'valign'],
  10687. d = null,
  10688. e = !0
  10689. return (
  10690. utils.each(a, function (a) {
  10691. return (
  10692. utils.each(c, function (c) {
  10693. if (((d = a.getAttribute(c)), !b[c] && d)) b[c] = d
  10694. else if (!b[c] || d !== b[c]) return (e = !1), !1
  10695. }),
  10696. e
  10697. )
  10698. }),
  10699. e ? b : null
  10700. )
  10701. }),
  10702. (b.getTableItemsByRange = function (a) {
  10703. var b = a.selection.getStart()
  10704. b &&
  10705. b.id &&
  10706. 0 === b.id.indexOf('_baidu_bookmark_start_') &&
  10707. b.nextSibling &&
  10708. (b = b.nextSibling)
  10709. var c = b && domUtils.findParentByTagName(b, ['td', 'th'], !0),
  10710. d = c && c.parentNode,
  10711. e = b && domUtils.findParentByTagName(b, 'caption', !0),
  10712. f = e ? e.parentNode : d && d.parentNode.parentNode
  10713. return { cell: c, tr: d, table: f, caption: e }
  10714. }),
  10715. (b.getUETableBySelected = function (a) {
  10716. var c = b.getTableItemsByRange(a).table
  10717. return c && c.ueTable && c.ueTable.selectedTds.length
  10718. ? c.ueTable
  10719. : null
  10720. }),
  10721. (b.getDefaultValue = function (a, b) {
  10722. var c,
  10723. d,
  10724. e,
  10725. f,
  10726. g = { thin: '0px', medium: '1px', thick: '2px' }
  10727. if (b)
  10728. return (
  10729. (h = b.getElementsByTagName('td')[0]),
  10730. (f = domUtils.getComputedStyle(b, 'border-left-width')),
  10731. (c = parseInt(g[f] || f, 10)),
  10732. (f = domUtils.getComputedStyle(h, 'padding-left')),
  10733. (d = parseInt(g[f] || f, 10)),
  10734. (f = domUtils.getComputedStyle(h, 'border-left-width')),
  10735. (e = parseInt(g[f] || f, 10)),
  10736. { tableBorder: c, tdPadding: d, tdBorder: e }
  10737. )
  10738. ;(b = a.document.createElement('table')),
  10739. (b.insertRow(0).insertCell(0).innerHTML = 'xxx'),
  10740. a.body.appendChild(b)
  10741. var h = b.getElementsByTagName('td')[0]
  10742. return (
  10743. (f = domUtils.getComputedStyle(b, 'border-left-width')),
  10744. (c = parseInt(g[f] || f, 10)),
  10745. (f = domUtils.getComputedStyle(h, 'padding-left')),
  10746. (d = parseInt(g[f] || f, 10)),
  10747. (f = domUtils.getComputedStyle(h, 'border-left-width')),
  10748. (e = parseInt(g[f] || f, 10)),
  10749. domUtils.remove(b),
  10750. { tableBorder: c, tdPadding: d, tdBorder: e }
  10751. )
  10752. }),
  10753. (b.getUETable = function (a) {
  10754. var c = a.tagName.toLowerCase()
  10755. return (
  10756. (a =
  10757. 'td' == c || 'th' == c || 'caption' == c
  10758. ? domUtils.findParentByTagName(a, 'table', !0)
  10759. : a),
  10760. a.ueTable || (a.ueTable = new b(a)),
  10761. a.ueTable
  10762. )
  10763. }),
  10764. (b.cloneCell = function (a, b, c) {
  10765. if (!a || utils.isString(a))
  10766. return this.table.ownerDocument.createElement(a || 'td')
  10767. var d = domUtils.hasClass(a, 'selectTdClass')
  10768. d && domUtils.removeClasses(a, 'selectTdClass')
  10769. var e = a.cloneNode(!0)
  10770. return (
  10771. b && (e.rowSpan = e.colSpan = 1),
  10772. !c && domUtils.removeAttributes(e, 'width height'),
  10773. !c && domUtils.removeAttributes(e, 'style'),
  10774. (e.style.borderLeftStyle = ''),
  10775. (e.style.borderTopStyle = ''),
  10776. (e.style.borderLeftColor = a.style.borderRightColor),
  10777. (e.style.borderLeftWidth = a.style.borderRightWidth),
  10778. (e.style.borderTopColor = a.style.borderBottomColor),
  10779. (e.style.borderTopWidth = a.style.borderBottomWidth),
  10780. d && domUtils.addClass(a, 'selectTdClass'),
  10781. e
  10782. )
  10783. }),
  10784. (b.prototype = {
  10785. getMaxRows: function () {
  10786. for (var a, b = this.table.rows, c = 1, d = 0; (a = b[d]); d++) {
  10787. for (var e, f = 1, g = 0; (e = a.cells[g++]); )
  10788. f = Math.max(e.rowSpan || 1, f)
  10789. c = Math.max(f + d, c)
  10790. }
  10791. return c
  10792. },
  10793. getMaxCols: function () {
  10794. for (
  10795. var a, b = this.table.rows, c = 0, d = {}, e = 0;
  10796. (a = b[e]);
  10797. e++
  10798. ) {
  10799. for (var f, g = 0, h = 0; (f = a.cells[h++]); )
  10800. if (((g += f.colSpan || 1), f.rowSpan && f.rowSpan > 1))
  10801. for (var i = 1; i < f.rowSpan; i++)
  10802. d['row_' + (e + i)]
  10803. ? d['row_' + (e + i)]++
  10804. : (d['row_' + (e + i)] = f.colSpan || 1)
  10805. ;(g += d['row_' + e] || 0), (c = Math.max(g, c))
  10806. }
  10807. return c
  10808. },
  10809. getCellColIndex: function (a) {},
  10810. getHSideCell: function (b, c) {
  10811. try {
  10812. var d,
  10813. e,
  10814. f = this.getCellInfo(b),
  10815. g = this.selectedTds.length,
  10816. h = this.cellsRange
  10817. return (!c && (g ? !h.beginColIndex : !f.colIndex)) ||
  10818. (c &&
  10819. (g
  10820. ? h.endColIndex == this.colsNum - 1
  10821. : f.colIndex == this.colsNum - 1))
  10822. ? null
  10823. : ((d = g ? h.beginRowIndex : f.rowIndex),
  10824. (e = c
  10825. ? g
  10826. ? h.endColIndex + 1
  10827. : f.colIndex + 1
  10828. : g
  10829. ? h.beginColIndex - 1
  10830. : f.colIndex < 1
  10831. ? 0
  10832. : f.colIndex - 1),
  10833. this.getCell(
  10834. this.indexTable[d][e].rowIndex,
  10835. this.indexTable[d][e].cellIndex
  10836. ))
  10837. } catch (i) {
  10838. a(i)
  10839. }
  10840. },
  10841. getTabNextCell: function (a, b) {
  10842. var c,
  10843. d = this.getCellInfo(a),
  10844. e = b || d.rowIndex,
  10845. f = d.colIndex + 1 + (d.colSpan - 1)
  10846. try {
  10847. c = this.getCell(
  10848. this.indexTable[e][f].rowIndex,
  10849. this.indexTable[e][f].cellIndex
  10850. )
  10851. } catch (g) {
  10852. try {
  10853. ;(e = 1 * e + 1),
  10854. (f = 0),
  10855. (c = this.getCell(
  10856. this.indexTable[e][f].rowIndex,
  10857. this.indexTable[e][f].cellIndex
  10858. ))
  10859. } catch (g) {}
  10860. }
  10861. return c
  10862. },
  10863. getVSideCell: function (b, c, d) {
  10864. try {
  10865. var e,
  10866. f,
  10867. g = this.getCellInfo(b),
  10868. h = this.selectedTds.length && !d,
  10869. i = this.cellsRange
  10870. return (!c && 0 == g.rowIndex) ||
  10871. (c &&
  10872. (h
  10873. ? i.endRowIndex == this.rowsNum - 1
  10874. : g.rowIndex + g.rowSpan > this.rowsNum - 1))
  10875. ? null
  10876. : ((e = c
  10877. ? h
  10878. ? i.endRowIndex + 1
  10879. : g.rowIndex + g.rowSpan
  10880. : h
  10881. ? i.beginRowIndex - 1
  10882. : g.rowIndex - 1),
  10883. (f = h ? i.beginColIndex : g.colIndex),
  10884. this.getCell(
  10885. this.indexTable[e][f].rowIndex,
  10886. this.indexTable[e][f].cellIndex
  10887. ))
  10888. } catch (j) {
  10889. a(j)
  10890. }
  10891. },
  10892. getSameEndPosCells: function (b, c) {
  10893. try {
  10894. for (
  10895. var d = 'x' === c.toLowerCase(),
  10896. e =
  10897. domUtils.getXY(b)[d ? 'x' : 'y'] +
  10898. b['offset' + (d ? 'Width' : 'Height')],
  10899. f = this.table.rows,
  10900. g = null,
  10901. h = [],
  10902. i = 0;
  10903. i < this.rowsNum;
  10904. i++
  10905. ) {
  10906. g = f[i].cells
  10907. for (var j, k = 0; (j = g[k++]); ) {
  10908. var l =
  10909. domUtils.getXY(j)[d ? 'x' : 'y'] +
  10910. j['offset' + (d ? 'Width' : 'Height')]
  10911. if (l > e && d) break
  10912. if (
  10913. (b == j || e == l) &&
  10914. (1 == j[d ? 'colSpan' : 'rowSpan'] && h.push(j), d)
  10915. )
  10916. break
  10917. }
  10918. }
  10919. return h
  10920. } catch (m) {
  10921. a(m)
  10922. }
  10923. },
  10924. setCellContent: function (a, b) {
  10925. a.innerHTML = b || (browser.ie ? domUtils.fillChar : '<br />')
  10926. },
  10927. cloneCell: b.cloneCell,
  10928. getSameStartPosXCells: function (b) {
  10929. try {
  10930. for (
  10931. var c,
  10932. d = domUtils.getXY(b).x + b.offsetWidth,
  10933. e = this.table.rows,
  10934. f = [],
  10935. g = 0;
  10936. g < this.rowsNum;
  10937. g++
  10938. ) {
  10939. c = e[g].cells
  10940. for (var h, i = 0; (h = c[i++]); ) {
  10941. var j = domUtils.getXY(h).x
  10942. if (j > d) break
  10943. if (j == d && 1 == h.colSpan) {
  10944. f.push(h)
  10945. break
  10946. }
  10947. }
  10948. }
  10949. return f
  10950. } catch (k) {
  10951. a(k)
  10952. }
  10953. },
  10954. update: function (a) {
  10955. ;(this.table = a || this.table),
  10956. (this.selectedTds = []),
  10957. (this.cellsRange = {}),
  10958. (this.indexTable = [])
  10959. for (
  10960. var b = this.table.rows,
  10961. c = this.getMaxRows(),
  10962. d = c - b.length,
  10963. e = this.getMaxCols();
  10964. d--;
  10965. )
  10966. this.table.insertRow(b.length)
  10967. ;(this.rowsNum = c), (this.colsNum = e)
  10968. for (var f = 0, g = b.length; f < g; f++)
  10969. this.indexTable[f] = new Array(e)
  10970. for (var h, i = 0; (h = b[i]); i++)
  10971. for (var j, k = 0, l = h.cells; (j = l[k]); k++) {
  10972. j.rowSpan > c && (j.rowSpan = c)
  10973. for (
  10974. var m = k, n = j.rowSpan || 1, o = j.colSpan || 1;
  10975. this.indexTable[i][m];
  10976. )
  10977. m++
  10978. for (var p = 0; p < n; p++)
  10979. for (var q = 0; q < o; q++)
  10980. this.indexTable[i + p][m + q] = {
  10981. rowIndex: i,
  10982. cellIndex: k,
  10983. colIndex: m,
  10984. rowSpan: n,
  10985. colSpan: o
  10986. }
  10987. }
  10988. for (p = 0; p < c; p++)
  10989. for (q = 0; q < e; q++)
  10990. void 0 === this.indexTable[p][q] &&
  10991. ((h = b[p]),
  10992. (j = h.cells[h.cells.length - 1]),
  10993. (j = j
  10994. ? j.cloneNode(!0)
  10995. : this.table.ownerDocument.createElement('td')),
  10996. this.setCellContent(j),
  10997. 1 !== j.colSpan && (j.colSpan = 1),
  10998. 1 !== j.rowSpan && (j.rowSpan = 1),
  10999. h.appendChild(j),
  11000. (this.indexTable[p][q] = {
  11001. rowIndex: p,
  11002. cellIndex: j.cellIndex,
  11003. colIndex: q,
  11004. rowSpan: 1,
  11005. colSpan: 1
  11006. }))
  11007. var r = domUtils.getElementsByTagName(this.table, 'td'),
  11008. s = []
  11009. if (
  11010. (utils.each(r, function (a) {
  11011. domUtils.hasClass(a, 'selectTdClass') && s.push(a)
  11012. }),
  11013. s.length)
  11014. ) {
  11015. var t = s[0],
  11016. u = s[s.length - 1],
  11017. v = this.getCellInfo(t),
  11018. w = this.getCellInfo(u)
  11019. ;(this.selectedTds = s),
  11020. (this.cellsRange = {
  11021. beginRowIndex: v.rowIndex,
  11022. beginColIndex: v.colIndex,
  11023. endRowIndex: w.rowIndex + w.rowSpan - 1,
  11024. endColIndex: w.colIndex + w.colSpan - 1
  11025. })
  11026. }
  11027. if (!domUtils.hasClass(this.table.rows[0], 'firstRow')) {
  11028. domUtils.addClass(this.table.rows[0], 'firstRow')
  11029. for (var f = 1; f < this.table.rows.length; f++)
  11030. domUtils.removeClasses(this.table.rows[f], 'firstRow')
  11031. }
  11032. },
  11033. getCellInfo: function (a) {
  11034. if (a)
  11035. for (
  11036. var b = a.cellIndex,
  11037. c = a.parentNode.rowIndex,
  11038. d = this.indexTable[c],
  11039. e = this.colsNum,
  11040. f = b;
  11041. f < e;
  11042. f++
  11043. ) {
  11044. var g = d[f]
  11045. if (g.rowIndex === c && g.cellIndex === b) return g
  11046. }
  11047. },
  11048. getCell: function (a, b) {
  11049. return (a < this.rowsNum && this.table.rows[a].cells[b]) || null
  11050. },
  11051. deleteCell: function (a, b) {
  11052. b = 'number' == typeof b ? b : a.parentNode.rowIndex
  11053. var c = this.table.rows[b]
  11054. c.deleteCell(a.cellIndex)
  11055. },
  11056. getCellsRange: function (a, b) {
  11057. function c(a, b, e, f) {
  11058. var g,
  11059. h,
  11060. i,
  11061. j = a,
  11062. k = b,
  11063. l = e,
  11064. m = f
  11065. if (a > 0)
  11066. for (h = b; h < f; h++)
  11067. (g = d.indexTable[a][h]),
  11068. (i = g.rowIndex),
  11069. i < a && (j = Math.min(i, j))
  11070. if (f < d.colsNum)
  11071. for (i = a; i < e; i++)
  11072. (g = d.indexTable[i][f]),
  11073. (h = g.colIndex + g.colSpan - 1),
  11074. h > f && (m = Math.max(h, m))
  11075. if (e < d.rowsNum)
  11076. for (h = b; h < f; h++)
  11077. (g = d.indexTable[e][h]),
  11078. (i = g.rowIndex + g.rowSpan - 1),
  11079. i > e && (l = Math.max(i, l))
  11080. if (b > 0)
  11081. for (i = a; i < e; i++)
  11082. (g = d.indexTable[i][b]),
  11083. (h = g.colIndex),
  11084. h < b && (k = Math.min(g.colIndex, k))
  11085. return j != a || k != b || l != e || m != f
  11086. ? c(j, k, l, m)
  11087. : {
  11088. beginRowIndex: a,
  11089. beginColIndex: b,
  11090. endRowIndex: e,
  11091. endColIndex: f
  11092. }
  11093. }
  11094. try {
  11095. var d = this,
  11096. e = d.getCellInfo(a)
  11097. if (a === b)
  11098. return {
  11099. beginRowIndex: e.rowIndex,
  11100. beginColIndex: e.colIndex,
  11101. endRowIndex: e.rowIndex + e.rowSpan - 1,
  11102. endColIndex: e.colIndex + e.colSpan - 1
  11103. }
  11104. var f = d.getCellInfo(b),
  11105. g = Math.min(e.rowIndex, f.rowIndex),
  11106. h = Math.min(e.colIndex, f.colIndex),
  11107. i = Math.max(
  11108. e.rowIndex + e.rowSpan - 1,
  11109. f.rowIndex + f.rowSpan - 1
  11110. ),
  11111. j = Math.max(
  11112. e.colIndex + e.colSpan - 1,
  11113. f.colIndex + f.colSpan - 1
  11114. )
  11115. return c(g, h, i, j)
  11116. } catch (k) {}
  11117. },
  11118. getCells: function (a) {
  11119. this.clearSelected()
  11120. for (
  11121. var b,
  11122. c,
  11123. d,
  11124. e = a.beginRowIndex,
  11125. f = a.beginColIndex,
  11126. g = a.endRowIndex,
  11127. h = a.endColIndex,
  11128. i = {},
  11129. j = [],
  11130. k = e;
  11131. k <= g;
  11132. k++
  11133. )
  11134. for (var l = f; l <= h; l++) {
  11135. ;(b = this.indexTable[k][l]), (c = b.rowIndex), (d = b.colIndex)
  11136. var m = c + '|' + d
  11137. if (!i[m]) {
  11138. if (
  11139. ((i[m] = 1),
  11140. c < k ||
  11141. d < l ||
  11142. c + b.rowSpan - 1 > g ||
  11143. d + b.colSpan - 1 > h)
  11144. )
  11145. return null
  11146. j.push(this.getCell(c, b.cellIndex))
  11147. }
  11148. }
  11149. return j
  11150. },
  11151. clearSelected: function () {
  11152. b.removeSelectedClass(this.selectedTds),
  11153. (this.selectedTds = []),
  11154. (this.cellsRange = {})
  11155. },
  11156. setSelected: function (a) {
  11157. var c = this.getCells(a)
  11158. b.addSelectedClass(c), (this.selectedTds = c), (this.cellsRange = a)
  11159. },
  11160. isFullRow: function () {
  11161. var a = this.cellsRange
  11162. return a.endColIndex - a.beginColIndex + 1 == this.colsNum
  11163. },
  11164. isFullCol: function () {
  11165. var a = this.cellsRange,
  11166. b = this.table,
  11167. c = b.getElementsByTagName('th'),
  11168. d = a.endRowIndex - a.beginRowIndex + 1
  11169. return c.length
  11170. ? d == this.rowsNum || d == this.rowsNum - 1
  11171. : d == this.rowsNum
  11172. },
  11173. getNextCell: function (b, c, d) {
  11174. try {
  11175. var e,
  11176. f,
  11177. g = this.getCellInfo(b),
  11178. h = this.selectedTds.length && !d,
  11179. i = this.cellsRange
  11180. return (!c && 0 == g.rowIndex) ||
  11181. (c &&
  11182. (h
  11183. ? i.endRowIndex == this.rowsNum - 1
  11184. : g.rowIndex + g.rowSpan > this.rowsNum - 1))
  11185. ? null
  11186. : ((e = c
  11187. ? h
  11188. ? i.endRowIndex + 1
  11189. : g.rowIndex + g.rowSpan
  11190. : h
  11191. ? i.beginRowIndex - 1
  11192. : g.rowIndex - 1),
  11193. (f = h ? i.beginColIndex : g.colIndex),
  11194. this.getCell(
  11195. this.indexTable[e][f].rowIndex,
  11196. this.indexTable[e][f].cellIndex
  11197. ))
  11198. } catch (j) {
  11199. a(j)
  11200. }
  11201. },
  11202. getPreviewCell: function (b, c) {
  11203. try {
  11204. var d,
  11205. e,
  11206. f = this.getCellInfo(b),
  11207. g = this.selectedTds.length,
  11208. h = this.cellsRange
  11209. return (!c && (g ? !h.beginColIndex : !f.colIndex)) ||
  11210. (c &&
  11211. (g
  11212. ? h.endColIndex == this.colsNum - 1
  11213. : f.rowIndex > this.colsNum - 1))
  11214. ? null
  11215. : ((d = c
  11216. ? g
  11217. ? h.beginRowIndex
  11218. : f.rowIndex < 1
  11219. ? 0
  11220. : f.rowIndex - 1
  11221. : g
  11222. ? h.beginRowIndex
  11223. : f.rowIndex),
  11224. (e = c
  11225. ? g
  11226. ? h.endColIndex + 1
  11227. : f.colIndex
  11228. : g
  11229. ? h.beginColIndex - 1
  11230. : f.colIndex < 1
  11231. ? 0
  11232. : f.colIndex - 1),
  11233. this.getCell(
  11234. this.indexTable[d][e].rowIndex,
  11235. this.indexTable[d][e].cellIndex
  11236. ))
  11237. } catch (i) {
  11238. a(i)
  11239. }
  11240. },
  11241. moveContent: function (a, c) {
  11242. if (!b.isEmptyBlock(c)) {
  11243. if (b.isEmptyBlock(a)) return void (a.innerHTML = c.innerHTML)
  11244. var d = a.lastChild
  11245. for (
  11246. (3 != d.nodeType && dtd.$block[d.tagName]) ||
  11247. a.appendChild(a.ownerDocument.createElement('br'));
  11248. (d = c.firstChild);
  11249. )
  11250. a.appendChild(d)
  11251. }
  11252. },
  11253. mergeRight: function (a) {
  11254. var b = this.getCellInfo(a),
  11255. c = b.colIndex + b.colSpan,
  11256. d = this.indexTable[b.rowIndex][c],
  11257. e = this.getCell(d.rowIndex, d.cellIndex)
  11258. ;(a.colSpan = b.colSpan + d.colSpan),
  11259. a.removeAttribute('width'),
  11260. this.moveContent(a, e),
  11261. this.deleteCell(e, d.rowIndex),
  11262. this.update()
  11263. },
  11264. mergeDown: function (a) {
  11265. var b = this.getCellInfo(a),
  11266. c = b.rowIndex + b.rowSpan,
  11267. d = this.indexTable[c][b.colIndex],
  11268. e = this.getCell(d.rowIndex, d.cellIndex)
  11269. ;(a.rowSpan = b.rowSpan + d.rowSpan),
  11270. a.removeAttribute('height'),
  11271. this.moveContent(a, e),
  11272. this.deleteCell(e, d.rowIndex),
  11273. this.update()
  11274. },
  11275. mergeRange: function () {
  11276. var a = this.cellsRange,
  11277. b = this.getCell(
  11278. a.beginRowIndex,
  11279. this.indexTable[a.beginRowIndex][a.beginColIndex].cellIndex
  11280. )
  11281. if ('TH' == b.tagName && a.endRowIndex !== a.beginRowIndex) {
  11282. var c = this.indexTable,
  11283. d = this.getCellInfo(b)
  11284. ;(b = this.getCell(1, c[1][d.colIndex].cellIndex)),
  11285. (a = this.getCellsRange(
  11286. b,
  11287. this.getCell(
  11288. c[this.rowsNum - 1][d.colIndex].rowIndex,
  11289. c[this.rowsNum - 1][d.colIndex].cellIndex
  11290. )
  11291. ))
  11292. }
  11293. for (var e, f = this.getCells(a), g = 0; (e = f[g++]); )
  11294. e !== b && (this.moveContent(b, e), this.deleteCell(e))
  11295. if (
  11296. ((b.rowSpan = a.endRowIndex - a.beginRowIndex + 1),
  11297. b.rowSpan > 1 && b.removeAttribute('height'),
  11298. (b.colSpan = a.endColIndex - a.beginColIndex + 1),
  11299. b.colSpan > 1 && b.removeAttribute('width'),
  11300. b.rowSpan == this.rowsNum && 1 != b.colSpan && (b.colSpan = 1),
  11301. b.colSpan == this.colsNum && 1 != b.rowSpan)
  11302. ) {
  11303. var h = b.parentNode.rowIndex
  11304. if (this.table.deleteRow)
  11305. for (var g = h + 1, i = h + 1, j = b.rowSpan; g < j; g++)
  11306. this.table.deleteRow(i)
  11307. else
  11308. for (var g = 0, j = b.rowSpan - 1; g < j; g++) {
  11309. var k = this.table.rows[h + 1]
  11310. k.parentNode.removeChild(k)
  11311. }
  11312. b.rowSpan = 1
  11313. }
  11314. this.update()
  11315. },
  11316. insertRow: function (a, b) {
  11317. function c(a, b, c) {
  11318. if (0 == a) {
  11319. var d = c.nextSibling || c.previousSibling,
  11320. e = d.cells[a]
  11321. 'TH' == e.tagName &&
  11322. ((e = b.ownerDocument.createElement('th')),
  11323. e.appendChild(b.firstChild),
  11324. c.insertBefore(e, b),
  11325. domUtils.remove(b))
  11326. } else if ('TH' == b.tagName) {
  11327. var f = b.ownerDocument.createElement('td')
  11328. f.appendChild(b.firstChild),
  11329. c.insertBefore(f, b),
  11330. domUtils.remove(b)
  11331. }
  11332. }
  11333. var d,
  11334. e = this.colsNum,
  11335. f = this.table,
  11336. g = f.insertRow(a),
  11337. h = 'string' == typeof b && 'TH' == b.toUpperCase()
  11338. if (0 == a || a == this.rowsNum)
  11339. for (var i = 0; i < e; i++)
  11340. (d = this.cloneCell(b, !0)),
  11341. this.setCellContent(d),
  11342. d.getAttribute('vAlign') &&
  11343. d.setAttribute('vAlign', d.getAttribute('vAlign')),
  11344. g.appendChild(d),
  11345. h || c(i, d, g)
  11346. else {
  11347. var j = this.indexTable[a]
  11348. for (i = 0; i < e; i++) {
  11349. var k = j[i]
  11350. k.rowIndex < a
  11351. ? ((d = this.getCell(k.rowIndex, k.cellIndex)),
  11352. (d.rowSpan = k.rowSpan + 1))
  11353. : ((d = this.cloneCell(b, !0)),
  11354. this.setCellContent(d),
  11355. g.appendChild(d)),
  11356. h || c(i, d, g)
  11357. }
  11358. }
  11359. return this.update(), g
  11360. },
  11361. deleteRow: function (a) {
  11362. for (
  11363. var b = this.table.rows[a],
  11364. c = this.indexTable[a],
  11365. d = this.colsNum,
  11366. e = 0,
  11367. f = 0;
  11368. f < d;
  11369. ) {
  11370. var g = c[f],
  11371. h = this.getCell(g.rowIndex, g.cellIndex)
  11372. if (h.rowSpan > 1 && g.rowIndex == a) {
  11373. var i = h.cloneNode(!0)
  11374. ;(i.rowSpan = h.rowSpan - 1),
  11375. (i.innerHTML = ''),
  11376. (h.rowSpan = 1)
  11377. var j,
  11378. k = a + 1,
  11379. l = this.table.rows[k],
  11380. m = this.getPreviewMergedCellsNum(k, f) - e
  11381. m < f
  11382. ? ((j = f - m - 1), domUtils.insertAfter(l.cells[j], i))
  11383. : l.cells.length && l.insertBefore(i, l.cells[0]),
  11384. (e += 1)
  11385. }
  11386. f += h.colSpan || 1
  11387. }
  11388. var n = [],
  11389. o = {}
  11390. for (f = 0; f < d; f++) {
  11391. var p = c[f].rowIndex,
  11392. q = c[f].cellIndex,
  11393. r = p + '_' + q
  11394. o[r] || ((o[r] = 1), (h = this.getCell(p, q)), n.push(h))
  11395. }
  11396. var s = []
  11397. utils.each(n, function (a) {
  11398. 1 == a.rowSpan ? a.parentNode.removeChild(a) : s.push(a)
  11399. }),
  11400. utils.each(s, function (a) {
  11401. a.rowSpan--
  11402. }),
  11403. b.parentNode.removeChild(b),
  11404. this.update()
  11405. },
  11406. insertCol: function (a, b, c) {
  11407. function d(a, b, c) {
  11408. if (0 == a) {
  11409. var d = b.nextSibling || b.previousSibling
  11410. 'TH' == d.tagName &&
  11411. ((d = b.ownerDocument.createElement('th')),
  11412. d.appendChild(b.firstChild),
  11413. c.insertBefore(d, b),
  11414. domUtils.remove(b))
  11415. } else if ('TH' == b.tagName) {
  11416. var e = b.ownerDocument.createElement('td')
  11417. e.appendChild(b.firstChild),
  11418. c.insertBefore(e, b),
  11419. domUtils.remove(b)
  11420. }
  11421. }
  11422. var e,
  11423. f,
  11424. g,
  11425. h = this.rowsNum,
  11426. i = 0,
  11427. j = parseInt(
  11428. (this.table.offsetWidth -
  11429. 20 * (this.colsNum + 1) -
  11430. (this.colsNum + 1)) /
  11431. (this.colsNum + 1),
  11432. 10
  11433. ),
  11434. k = 'string' == typeof b && 'TH' == b.toUpperCase()
  11435. if (0 == a || a == this.colsNum)
  11436. for (; i < h; i++)
  11437. (e = this.table.rows[i]),
  11438. (g = e.cells[0 == a ? a : e.cells.length]),
  11439. (f = this.cloneCell(b, !0)),
  11440. this.setCellContent(f),
  11441. f.setAttribute('vAlign', f.getAttribute('vAlign')),
  11442. g && f.setAttribute('width', g.getAttribute('width')),
  11443. a
  11444. ? domUtils.insertAfter(e.cells[e.cells.length - 1], f)
  11445. : e.insertBefore(f, e.cells[0]),
  11446. k || d(i, f, e)
  11447. else
  11448. for (; i < h; i++) {
  11449. var l = this.indexTable[i][a]
  11450. l.colIndex < a
  11451. ? ((f = this.getCell(l.rowIndex, l.cellIndex)),
  11452. (f.colSpan = l.colSpan + 1))
  11453. : ((e = this.table.rows[i]),
  11454. (g = e.cells[l.cellIndex]),
  11455. (f = this.cloneCell(b, !0)),
  11456. this.setCellContent(f),
  11457. f.setAttribute('vAlign', f.getAttribute('vAlign')),
  11458. g && f.setAttribute('width', g.getAttribute('width')),
  11459. g ? e.insertBefore(f, g) : e.appendChild(f)),
  11460. k || d(i, f, e)
  11461. }
  11462. this.update(),
  11463. this.updateWidth(j, c || { tdPadding: 10, tdBorder: 1 })
  11464. },
  11465. updateWidth: function (a, c) {
  11466. var d = this.table,
  11467. e = b.getWidth(d) - 2 * c.tdPadding - c.tdBorder + a
  11468. if (e < d.ownerDocument.body.offsetWidth)
  11469. return void d.setAttribute('width', e)
  11470. var f = domUtils.getElementsByTagName(this.table, 'td th')
  11471. utils.each(f, function (b) {
  11472. b.setAttribute('width', a)
  11473. })
  11474. },
  11475. deleteCol: function (a) {
  11476. for (
  11477. var b = this.indexTable,
  11478. c = this.table.rows,
  11479. d = this.table.getAttribute('width'),
  11480. e = 0,
  11481. f = this.rowsNum,
  11482. g = {},
  11483. h = 0;
  11484. h < f;
  11485. ) {
  11486. var i = b[h],
  11487. j = i[a],
  11488. k = j.rowIndex + '_' + j.colIndex
  11489. if (!g[k]) {
  11490. g[k] = 1
  11491. var l = this.getCell(j.rowIndex, j.cellIndex)
  11492. e ||
  11493. (e = l && parseInt(l.offsetWidth / l.colSpan, 10).toFixed(0)),
  11494. l.colSpan > 1 ? l.colSpan-- : c[h].deleteCell(j.cellIndex),
  11495. (h += j.rowSpan || 1)
  11496. }
  11497. }
  11498. this.table.setAttribute('width', d - e), this.update()
  11499. },
  11500. splitToCells: function (a) {
  11501. var b = this,
  11502. c = this.splitToRows(a)
  11503. utils.each(c, function (a) {
  11504. b.splitToCols(a)
  11505. })
  11506. },
  11507. splitToRows: function (a) {
  11508. var b = this.getCellInfo(a),
  11509. c = b.rowIndex,
  11510. d = b.colIndex,
  11511. e = []
  11512. ;(a.rowSpan = 1), e.push(a)
  11513. for (var f = c, g = c + b.rowSpan; f < g; f++)
  11514. if (f != c) {
  11515. var h = this.table.rows[f],
  11516. i = h.insertCell(d - this.getPreviewMergedCellsNum(f, d))
  11517. ;(i.colSpan = b.colSpan),
  11518. this.setCellContent(i),
  11519. i.setAttribute('vAlign', a.getAttribute('vAlign')),
  11520. i.setAttribute('align', a.getAttribute('align')),
  11521. a.style.cssText && (i.style.cssText = a.style.cssText),
  11522. e.push(i)
  11523. }
  11524. return this.update(), e
  11525. },
  11526. getPreviewMergedCellsNum: function (a, b) {
  11527. for (var c = this.indexTable[a], d = 0, e = 0; e < b; ) {
  11528. var f = c[e].colSpan,
  11529. g = c[e].rowIndex
  11530. ;(d += f - (g == a ? 1 : 0)), (e += f)
  11531. }
  11532. return d
  11533. },
  11534. splitToCols: function (a) {
  11535. var b = (a.offsetWidth / a.colSpan - 22).toFixed(0),
  11536. c = this.getCellInfo(a),
  11537. d = c.rowIndex,
  11538. e = c.colIndex,
  11539. f = []
  11540. ;(a.colSpan = 1), a.setAttribute('width', b), f.push(a)
  11541. for (var g = e, h = e + c.colSpan; g < h; g++)
  11542. if (g != e) {
  11543. var i = this.table.rows[d],
  11544. j = i.insertCell(this.indexTable[d][g].cellIndex + 1)
  11545. if (
  11546. ((j.rowSpan = c.rowSpan),
  11547. this.setCellContent(j),
  11548. j.setAttribute('vAlign', a.getAttribute('vAlign')),
  11549. j.setAttribute('align', a.getAttribute('align')),
  11550. j.setAttribute('width', b),
  11551. a.style.cssText && (j.style.cssText = a.style.cssText),
  11552. 'TH' == a.tagName)
  11553. ) {
  11554. var k = a.ownerDocument.createElement('th')
  11555. k.appendChild(j.firstChild),
  11556. k.setAttribute('vAlign', a.getAttribute('vAlign')),
  11557. (k.rowSpan = j.rowSpan),
  11558. i.insertBefore(k, j),
  11559. domUtils.remove(j)
  11560. }
  11561. f.push(j)
  11562. }
  11563. return this.update(), f
  11564. },
  11565. isLastCell: function (a, b, c) {
  11566. ;(b = b || this.rowsNum), (c = c || this.colsNum)
  11567. var d = this.getCellInfo(a)
  11568. return d.rowIndex + d.rowSpan == b && d.colIndex + d.colSpan == c
  11569. },
  11570. getLastCell: function (a) {
  11571. a = a || this.table.getElementsByTagName('td')
  11572. var b,
  11573. c = (this.getCellInfo(a[0]), this),
  11574. d = a[0],
  11575. e = d.parentNode,
  11576. f = 0,
  11577. g = 0
  11578. return (
  11579. utils.each(a, function (a) {
  11580. a.parentNode == e && (g += a.colSpan || 1),
  11581. (f += a.rowSpan * a.colSpan || 1)
  11582. }),
  11583. (b = f / g),
  11584. utils.each(a, function (a) {
  11585. if (c.isLastCell(a, b, g)) return (d = a), !1
  11586. }),
  11587. d
  11588. )
  11589. },
  11590. selectRow: function (a) {
  11591. var b = this.indexTable[a],
  11592. c = this.getCell(b[0].rowIndex, b[0].cellIndex),
  11593. d = this.getCell(
  11594. b[this.colsNum - 1].rowIndex,
  11595. b[this.colsNum - 1].cellIndex
  11596. ),
  11597. e = this.getCellsRange(c, d)
  11598. this.setSelected(e)
  11599. },
  11600. selectTable: function () {
  11601. var a = this.table.getElementsByTagName('td'),
  11602. b = this.getCellsRange(a[0], a[a.length - 1])
  11603. this.setSelected(b)
  11604. },
  11605. setBackground: function (a, b) {
  11606. if ('string' == typeof b)
  11607. utils.each(a, function (a) {
  11608. a.style.backgroundColor = b
  11609. })
  11610. else if ('object' == typeof b) {
  11611. b = utils.extend({ repeat: !0, colorList: ['#ddd', '#fff'] }, b)
  11612. for (
  11613. var c,
  11614. d = this.getCellInfo(a[0]).rowIndex,
  11615. e = 0,
  11616. f = b.colorList,
  11617. g = function (a, b, c) {
  11618. return a[b] ? a[b] : c ? a[b % a.length] : ''
  11619. },
  11620. h = 0;
  11621. (c = a[h++]);
  11622. ) {
  11623. var i = this.getCellInfo(c)
  11624. c.style.backgroundColor = g(
  11625. f,
  11626. d + e == i.rowIndex ? e : ++e,
  11627. b.repeat
  11628. )
  11629. }
  11630. }
  11631. },
  11632. removeBackground: function (a) {
  11633. utils.each(a, function (a) {
  11634. a.style.backgroundColor = ''
  11635. })
  11636. }
  11637. })
  11638. })(),
  11639. (function () {
  11640. function a(a, c) {
  11641. var d = domUtils.getElementsByTagName(a, 'td th')
  11642. utils.each(d, function (a) {
  11643. a.removeAttribute('width')
  11644. }),
  11645. a.setAttribute('width', b(c, !0, g(c, a)))
  11646. var e = []
  11647. setTimeout(function () {
  11648. utils.each(d, function (a) {
  11649. 1 == a.colSpan && e.push(a.offsetWidth)
  11650. }),
  11651. utils.each(d, function (a, b) {
  11652. 1 == a.colSpan && a.setAttribute('width', e[b] + '')
  11653. })
  11654. }, 0)
  11655. }
  11656. function b(a, b, c) {
  11657. var d = a.body
  11658. return (
  11659. d.offsetWidth -
  11660. (b
  11661. ? 2 * parseInt(domUtils.getComputedStyle(d, 'margin-left'), 10)
  11662. : 0) -
  11663. 2 * c.tableBorder -
  11664. (a.options.offsetWidth || 0)
  11665. )
  11666. }
  11667. function c(a) {
  11668. var b = e(a).cell
  11669. if (b) {
  11670. var c = h(b)
  11671. return c.selectedTds.length ? c.selectedTds : [b]
  11672. }
  11673. return []
  11674. }
  11675. var d = UE.UETable,
  11676. e = function (a) {
  11677. return d.getTableItemsByRange(a)
  11678. },
  11679. f = function (a) {
  11680. return d.getUETableBySelected(a)
  11681. },
  11682. g = function (a, b) {
  11683. return d.getDefaultValue(a, b)
  11684. },
  11685. h = function (a) {
  11686. return d.getUETable(a)
  11687. }
  11688. ;(UE.commands.inserttable = {
  11689. queryCommandState: function () {
  11690. return e(this).table ? -1 : 0
  11691. },
  11692. execCommand: function (a, b) {
  11693. function c(a, b) {
  11694. for (var c = [], d = a.numRows, e = a.numCols, f = 0; f < d; f++) {
  11695. c.push('<tr' + (0 == f ? ' class="firstRow"' : '') + '>')
  11696. for (var g = 0; g < e; g++)
  11697. c.push(
  11698. '<td width="' +
  11699. b +
  11700. '" vAlign="' +
  11701. a.tdvalign +
  11702. '" >' +
  11703. (browser.ie && browser.version < 11
  11704. ? domUtils.fillChar
  11705. : '<br/>') +
  11706. '</td>'
  11707. )
  11708. c.push('</tr>')
  11709. }
  11710. return '<table><tbody>' + c.join('') + '</tbody></table>'
  11711. }
  11712. b ||
  11713. (b = utils.extend(
  11714. {},
  11715. {
  11716. numCols: this.options.defaultCols,
  11717. numRows: this.options.defaultRows,
  11718. tdvalign: this.options.tdvalign
  11719. }
  11720. ))
  11721. var d = this,
  11722. e = this.selection.getRange(),
  11723. f = e.startContainer,
  11724. h =
  11725. domUtils.findParent(
  11726. f,
  11727. function (a) {
  11728. return domUtils.isBlockElm(a)
  11729. },
  11730. !0
  11731. ) || d.body,
  11732. i = g(d),
  11733. j = h.offsetWidth,
  11734. k = Math.floor(j / b.numCols - 2 * i.tdPadding - i.tdBorder)
  11735. !b.tdvalign && (b.tdvalign = d.options.tdvalign),
  11736. d.execCommand('inserthtml', c(b, k))
  11737. }
  11738. }),
  11739. (UE.commands.insertparagraphbeforetable = {
  11740. queryCommandState: function () {
  11741. return e(this).cell ? 0 : -1
  11742. },
  11743. execCommand: function () {
  11744. var a = e(this).table
  11745. if (a) {
  11746. var b = this.document.createElement('p')
  11747. ;(b.innerHTML = browser.ie ? '&nbsp;' : '<br />'),
  11748. a.parentNode.insertBefore(b, a),
  11749. this.selection.getRange().setStart(b, 0).setCursor()
  11750. }
  11751. }
  11752. }),
  11753. (UE.commands.deletetable = {
  11754. queryCommandState: function () {
  11755. var a = this.selection.getRange()
  11756. return domUtils.findParentByTagName(a.startContainer, 'table', !0)
  11757. ? 0
  11758. : -1
  11759. },
  11760. execCommand: function (a, b) {
  11761. var c = this.selection.getRange()
  11762. if (
  11763. (b =
  11764. b ||
  11765. domUtils.findParentByTagName(c.startContainer, 'table', !0))
  11766. ) {
  11767. var d = b.nextSibling
  11768. d ||
  11769. ((d = domUtils.createElement(this.document, 'p', {
  11770. innerHTML: browser.ie ? domUtils.fillChar : '<br/>'
  11771. })),
  11772. b.parentNode.insertBefore(d, b)),
  11773. domUtils.remove(b),
  11774. (c = this.selection.getRange()),
  11775. 3 == d.nodeType ? c.setStartBefore(d) : c.setStart(d, 0),
  11776. c.setCursor(!1, !0),
  11777. this.fireEvent('tablehasdeleted')
  11778. }
  11779. }
  11780. }),
  11781. (UE.commands.cellalign = {
  11782. queryCommandState: function () {
  11783. return c(this).length ? 0 : -1
  11784. },
  11785. execCommand: function (a, b) {
  11786. var d = c(this)
  11787. if (d.length)
  11788. for (var e, f = 0; (e = d[f++]); ) e.setAttribute('align', b)
  11789. }
  11790. }),
  11791. (UE.commands.cellvalign = {
  11792. queryCommandState: function () {
  11793. return c(this).length ? 0 : -1
  11794. },
  11795. execCommand: function (a, b) {
  11796. var d = c(this)
  11797. if (d.length)
  11798. for (var e, f = 0; (e = d[f++]); ) e.setAttribute('vAlign', b)
  11799. }
  11800. }),
  11801. (UE.commands.insertcaption = {
  11802. queryCommandState: function () {
  11803. var a = e(this).table
  11804. return a && 0 == a.getElementsByTagName('caption').length ? 1 : -1
  11805. },
  11806. execCommand: function () {
  11807. var a = e(this).table
  11808. if (a) {
  11809. var b = this.document.createElement('caption')
  11810. ;(b.innerHTML = browser.ie ? domUtils.fillChar : '<br/>'),
  11811. a.insertBefore(b, a.firstChild)
  11812. var c = this.selection.getRange()
  11813. c.setStart(b, 0).setCursor()
  11814. }
  11815. }
  11816. }),
  11817. (UE.commands.deletecaption = {
  11818. queryCommandState: function () {
  11819. var a = this.selection.getRange(),
  11820. b = domUtils.findParentByTagName(a.startContainer, 'table')
  11821. return b
  11822. ? 0 == b.getElementsByTagName('caption').length
  11823. ? -1
  11824. : 1
  11825. : -1
  11826. },
  11827. execCommand: function () {
  11828. var a = this.selection.getRange(),
  11829. b = domUtils.findParentByTagName(a.startContainer, 'table')
  11830. if (b) {
  11831. domUtils.remove(b.getElementsByTagName('caption')[0])
  11832. var c = this.selection.getRange()
  11833. c.setStart(b.rows[0].cells[0], 0).setCursor()
  11834. }
  11835. }
  11836. }),
  11837. (UE.commands.inserttitle = {
  11838. queryCommandState: function () {
  11839. var a = e(this).table
  11840. if (a) {
  11841. var b = a.rows[0]
  11842. return 'th' != b.cells[b.cells.length - 1].tagName.toLowerCase()
  11843. ? 0
  11844. : -1
  11845. }
  11846. return -1
  11847. },
  11848. execCommand: function () {
  11849. var a = e(this).table
  11850. a && h(a).insertRow(0, 'th')
  11851. var b = a.getElementsByTagName('th')[0]
  11852. this.selection.getRange().setStart(b, 0).setCursor(!1, !0)
  11853. }
  11854. }),
  11855. (UE.commands.deletetitle = {
  11856. queryCommandState: function () {
  11857. var a = e(this).table
  11858. if (a) {
  11859. var b = a.rows[0]
  11860. return 'th' == b.cells[b.cells.length - 1].tagName.toLowerCase()
  11861. ? 0
  11862. : -1
  11863. }
  11864. return -1
  11865. },
  11866. execCommand: function () {
  11867. var a = e(this).table
  11868. a && domUtils.remove(a.rows[0])
  11869. var b = a.getElementsByTagName('td')[0]
  11870. this.selection.getRange().setStart(b, 0).setCursor(!1, !0)
  11871. }
  11872. }),
  11873. (UE.commands.inserttitlecol = {
  11874. queryCommandState: function () {
  11875. var a = e(this).table
  11876. if (a) {
  11877. var b = a.rows[a.rows.length - 1]
  11878. return b.getElementsByTagName('th').length ? -1 : 0
  11879. }
  11880. return -1
  11881. },
  11882. execCommand: function (b) {
  11883. var c = e(this).table
  11884. c && h(c).insertCol(0, 'th'), a(c, this)
  11885. var d = c.getElementsByTagName('th')[0]
  11886. this.selection.getRange().setStart(d, 0).setCursor(!1, !0)
  11887. }
  11888. }),
  11889. (UE.commands.deletetitlecol = {
  11890. queryCommandState: function () {
  11891. var a = e(this).table
  11892. if (a) {
  11893. var b = a.rows[a.rows.length - 1]
  11894. return b.getElementsByTagName('th').length ? 0 : -1
  11895. }
  11896. return -1
  11897. },
  11898. execCommand: function () {
  11899. var b = e(this).table
  11900. if (b)
  11901. for (var c = 0; c < b.rows.length; c++)
  11902. domUtils.remove(b.rows[c].children[0])
  11903. a(b, this)
  11904. var d = b.getElementsByTagName('td')[0]
  11905. this.selection.getRange().setStart(d, 0).setCursor(!1, !0)
  11906. }
  11907. }),
  11908. (UE.commands.mergeright = {
  11909. queryCommandState: function (a) {
  11910. var b = e(this),
  11911. c = b.table,
  11912. d = b.cell
  11913. if (!c || !d) return -1
  11914. var f = h(c)
  11915. if (f.selectedTds.length) return -1
  11916. var g = f.getCellInfo(d),
  11917. i = g.colIndex + g.colSpan
  11918. if (i >= f.colsNum) return -1
  11919. var j = f.indexTable[g.rowIndex][i],
  11920. k = c.rows[j.rowIndex].cells[j.cellIndex]
  11921. return k &&
  11922. d.tagName == k.tagName &&
  11923. j.rowIndex == g.rowIndex &&
  11924. j.rowSpan == g.rowSpan
  11925. ? 0
  11926. : -1
  11927. },
  11928. execCommand: function (a) {
  11929. var b = this.selection.getRange(),
  11930. c = b.createBookmark(!0),
  11931. d = e(this).cell,
  11932. f = h(d)
  11933. f.mergeRight(d), b.moveToBookmark(c).select()
  11934. }
  11935. }),
  11936. (UE.commands.mergedown = {
  11937. queryCommandState: function (a) {
  11938. var b = e(this),
  11939. c = b.table,
  11940. d = b.cell
  11941. if (!c || !d) return -1
  11942. var f = h(c)
  11943. if (f.selectedTds.length) return -1
  11944. var g = f.getCellInfo(d),
  11945. i = g.rowIndex + g.rowSpan
  11946. if (i >= f.rowsNum) return -1
  11947. var j = f.indexTable[i][g.colIndex],
  11948. k = c.rows[j.rowIndex].cells[j.cellIndex]
  11949. return k &&
  11950. d.tagName == k.tagName &&
  11951. j.colIndex == g.colIndex &&
  11952. j.colSpan == g.colSpan
  11953. ? 0
  11954. : -1
  11955. },
  11956. execCommand: function () {
  11957. var a = this.selection.getRange(),
  11958. b = a.createBookmark(!0),
  11959. c = e(this).cell,
  11960. d = h(c)
  11961. d.mergeDown(c), a.moveToBookmark(b).select()
  11962. }
  11963. }),
  11964. (UE.commands.mergecells = {
  11965. queryCommandState: function () {
  11966. return f(this) ? 0 : -1
  11967. },
  11968. execCommand: function () {
  11969. var a = f(this)
  11970. if (a && a.selectedTds.length) {
  11971. var b = a.selectedTds[0]
  11972. a.mergeRange()
  11973. var c = this.selection.getRange()
  11974. domUtils.isEmptyBlock(b)
  11975. ? c.setStart(b, 0).collapse(!0)
  11976. : c.selectNodeContents(b),
  11977. c.select()
  11978. }
  11979. }
  11980. }),
  11981. (UE.commands.insertrow = {
  11982. queryCommandState: function () {
  11983. var a = e(this),
  11984. b = a.cell
  11985. return b &&
  11986. ('TD' == b.tagName ||
  11987. ('TH' == b.tagName && a.tr !== a.table.rows[0])) &&
  11988. h(a.table).rowsNum < this.options.maxRowNum
  11989. ? 0
  11990. : -1
  11991. },
  11992. execCommand: function () {
  11993. var a = this.selection.getRange(),
  11994. b = a.createBookmark(!0),
  11995. c = e(this),
  11996. d = c.cell,
  11997. f = c.table,
  11998. g = h(f),
  11999. i = g.getCellInfo(d)
  12000. if (g.selectedTds.length)
  12001. for (
  12002. var j = g.cellsRange,
  12003. k = 0,
  12004. l = j.endRowIndex - j.beginRowIndex + 1;
  12005. k < l;
  12006. k++
  12007. )
  12008. g.insertRow(j.beginRowIndex, d)
  12009. else g.insertRow(i.rowIndex, d)
  12010. a.moveToBookmark(b).select(),
  12011. 'enabled' === f.getAttribute('interlaced') &&
  12012. this.fireEvent('interlacetable', f)
  12013. }
  12014. }),
  12015. (UE.commands.insertrownext = {
  12016. queryCommandState: function () {
  12017. var a = e(this),
  12018. b = a.cell
  12019. return b &&
  12020. 'TD' == b.tagName &&
  12021. h(a.table).rowsNum < this.options.maxRowNum
  12022. ? 0
  12023. : -1
  12024. },
  12025. execCommand: function () {
  12026. var a = this.selection.getRange(),
  12027. b = a.createBookmark(!0),
  12028. c = e(this),
  12029. d = c.cell,
  12030. f = c.table,
  12031. g = h(f),
  12032. i = g.getCellInfo(d)
  12033. if (g.selectedTds.length)
  12034. for (
  12035. var j = g.cellsRange,
  12036. k = 0,
  12037. l = j.endRowIndex - j.beginRowIndex + 1;
  12038. k < l;
  12039. k++
  12040. )
  12041. g.insertRow(j.endRowIndex + 1, d)
  12042. else g.insertRow(i.rowIndex + i.rowSpan, d)
  12043. a.moveToBookmark(b).select(),
  12044. 'enabled' === f.getAttribute('interlaced') &&
  12045. this.fireEvent('interlacetable', f)
  12046. }
  12047. }),
  12048. (UE.commands.deleterow = {
  12049. queryCommandState: function () {
  12050. var a = e(this)
  12051. return a.cell ? 0 : -1
  12052. },
  12053. execCommand: function () {
  12054. var a = e(this).cell,
  12055. b = h(a),
  12056. c = b.cellsRange,
  12057. d = b.getCellInfo(a),
  12058. f = b.getVSideCell(a),
  12059. g = b.getVSideCell(a, !0),
  12060. i = this.selection.getRange()
  12061. if (utils.isEmptyObject(c)) b.deleteRow(d.rowIndex)
  12062. else
  12063. for (var j = c.beginRowIndex; j < c.endRowIndex + 1; j++)
  12064. b.deleteRow(c.beginRowIndex)
  12065. var k = b.table
  12066. if (k.getElementsByTagName('td').length)
  12067. if (
  12068. 1 == d.rowSpan ||
  12069. d.rowSpan == c.endRowIndex - c.beginRowIndex + 1
  12070. )
  12071. (g || f) && i.selectNodeContents(g || f).setCursor(!1, !0)
  12072. else {
  12073. var l = b.getCell(
  12074. d.rowIndex,
  12075. b.indexTable[d.rowIndex][d.colIndex].cellIndex
  12076. )
  12077. l && i.selectNodeContents(l).setCursor(!1, !0)
  12078. }
  12079. else {
  12080. var m = k.nextSibling
  12081. domUtils.remove(k), m && i.setStart(m, 0).setCursor(!1, !0)
  12082. }
  12083. 'enabled' === k.getAttribute('interlaced') &&
  12084. this.fireEvent('interlacetable', k)
  12085. }
  12086. }),
  12087. (UE.commands.insertcol = {
  12088. queryCommandState: function (a) {
  12089. var b = e(this),
  12090. c = b.cell
  12091. return c &&
  12092. ('TD' == c.tagName ||
  12093. ('TH' == c.tagName && c !== b.tr.cells[0])) &&
  12094. h(b.table).colsNum < this.options.maxColNum
  12095. ? 0
  12096. : -1
  12097. },
  12098. execCommand: function (a) {
  12099. var b = this.selection.getRange(),
  12100. c = b.createBookmark(!0)
  12101. if (this.queryCommandState(a) != -1) {
  12102. var d = e(this).cell,
  12103. f = h(d),
  12104. g = f.getCellInfo(d)
  12105. if (f.selectedTds.length)
  12106. for (
  12107. var i = f.cellsRange,
  12108. j = 0,
  12109. k = i.endColIndex - i.beginColIndex + 1;
  12110. j < k;
  12111. j++
  12112. )
  12113. f.insertCol(i.beginColIndex, d)
  12114. else f.insertCol(g.colIndex, d)
  12115. b.moveToBookmark(c).select(!0)
  12116. }
  12117. }
  12118. }),
  12119. (UE.commands.insertcolnext = {
  12120. queryCommandState: function () {
  12121. var a = e(this),
  12122. b = a.cell
  12123. return b && h(a.table).colsNum < this.options.maxColNum ? 0 : -1
  12124. },
  12125. execCommand: function () {
  12126. var a = this.selection.getRange(),
  12127. b = a.createBookmark(!0),
  12128. c = e(this).cell,
  12129. d = h(c),
  12130. f = d.getCellInfo(c)
  12131. if (d.selectedTds.length)
  12132. for (
  12133. var g = d.cellsRange,
  12134. i = 0,
  12135. j = g.endColIndex - g.beginColIndex + 1;
  12136. i < j;
  12137. i++
  12138. )
  12139. d.insertCol(g.endColIndex + 1, c)
  12140. else d.insertCol(f.colIndex + f.colSpan, c)
  12141. a.moveToBookmark(b).select()
  12142. }
  12143. }),
  12144. (UE.commands.deletecol = {
  12145. queryCommandState: function () {
  12146. var a = e(this)
  12147. return a.cell ? 0 : -1
  12148. },
  12149. execCommand: function () {
  12150. var a = e(this).cell,
  12151. b = h(a),
  12152. c = b.cellsRange,
  12153. d = b.getCellInfo(a),
  12154. f = b.getHSideCell(a),
  12155. g = b.getHSideCell(a, !0)
  12156. if (utils.isEmptyObject(c)) b.deleteCol(d.colIndex)
  12157. else
  12158. for (var i = c.beginColIndex; i < c.endColIndex + 1; i++)
  12159. b.deleteCol(c.beginColIndex)
  12160. var j = b.table,
  12161. k = this.selection.getRange()
  12162. if (j.getElementsByTagName('td').length)
  12163. domUtils.inDoc(a, this.document)
  12164. ? k.setStart(a, 0).setCursor(!1, !0)
  12165. : g && domUtils.inDoc(g, this.document)
  12166. ? k.selectNodeContents(g).setCursor(!1, !0)
  12167. : f &&
  12168. domUtils.inDoc(f, this.document) &&
  12169. k.selectNodeContents(f).setCursor(!0, !0)
  12170. else {
  12171. var l = j.nextSibling
  12172. domUtils.remove(j), l && k.setStart(l, 0).setCursor(!1, !0)
  12173. }
  12174. }
  12175. }),
  12176. (UE.commands.splittocells = {
  12177. queryCommandState: function () {
  12178. var a = e(this),
  12179. b = a.cell
  12180. if (!b) return -1
  12181. var c = h(a.table)
  12182. return c.selectedTds.length > 0
  12183. ? -1
  12184. : b && (b.colSpan > 1 || b.rowSpan > 1)
  12185. ? 0
  12186. : -1
  12187. },
  12188. execCommand: function () {
  12189. var a = this.selection.getRange(),
  12190. b = a.createBookmark(!0),
  12191. c = e(this).cell,
  12192. d = h(c)
  12193. d.splitToCells(c), a.moveToBookmark(b).select()
  12194. }
  12195. }),
  12196. (UE.commands.splittorows = {
  12197. queryCommandState: function () {
  12198. var a = e(this),
  12199. b = a.cell
  12200. if (!b) return -1
  12201. var c = h(a.table)
  12202. return c.selectedTds.length > 0 ? -1 : b && b.rowSpan > 1 ? 0 : -1
  12203. },
  12204. execCommand: function () {
  12205. var a = this.selection.getRange(),
  12206. b = a.createBookmark(!0),
  12207. c = e(this).cell,
  12208. d = h(c)
  12209. d.splitToRows(c), a.moveToBookmark(b).select()
  12210. }
  12211. }),
  12212. (UE.commands.splittocols = {
  12213. queryCommandState: function () {
  12214. var a = e(this),
  12215. b = a.cell
  12216. if (!b) return -1
  12217. var c = h(a.table)
  12218. return c.selectedTds.length > 0 ? -1 : b && b.colSpan > 1 ? 0 : -1
  12219. },
  12220. execCommand: function () {
  12221. var a = this.selection.getRange(),
  12222. b = a.createBookmark(!0),
  12223. c = e(this).cell,
  12224. d = h(c)
  12225. d.splitToCols(c), a.moveToBookmark(b).select()
  12226. }
  12227. }),
  12228. (UE.commands.adaptbytext = UE.commands.adaptbywindow =
  12229. {
  12230. queryCommandState: function () {
  12231. return e(this).table ? 0 : -1
  12232. },
  12233. execCommand: function (b) {
  12234. var c = e(this),
  12235. d = c.table
  12236. if (d)
  12237. if ('adaptbywindow' == b) a(d, this)
  12238. else {
  12239. var f = domUtils.getElementsByTagName(d, 'td th')
  12240. utils.each(f, function (a) {
  12241. a.removeAttribute('width')
  12242. }),
  12243. d.removeAttribute('width')
  12244. }
  12245. }
  12246. }),
  12247. (UE.commands.averagedistributecol = {
  12248. queryCommandState: function () {
  12249. var a = f(this)
  12250. return a && (a.isFullRow() || a.isFullCol()) ? 0 : -1
  12251. },
  12252. execCommand: function (a) {
  12253. function b() {
  12254. var a,
  12255. b = e.table,
  12256. c = 0,
  12257. f = 0,
  12258. h = g(d, b)
  12259. if (e.isFullRow()) (c = b.offsetWidth), (f = e.colsNum)
  12260. else
  12261. for (
  12262. var i,
  12263. j = e.cellsRange.beginColIndex,
  12264. k = e.cellsRange.endColIndex,
  12265. l = j;
  12266. l <= k;
  12267. )
  12268. (i = e.selectedTds[l]),
  12269. (c += i.offsetWidth),
  12270. (l += i.colSpan),
  12271. (f += 1)
  12272. return (a = Math.ceil(c / f) - 2 * h.tdBorder - 2 * h.tdPadding)
  12273. }
  12274. function c(a) {
  12275. utils.each(
  12276. domUtils.getElementsByTagName(e.table, 'th'),
  12277. function (a) {
  12278. a.setAttribute('width', '')
  12279. }
  12280. )
  12281. var b = e.isFullRow()
  12282. ? domUtils.getElementsByTagName(e.table, 'td')
  12283. : e.selectedTds
  12284. utils.each(b, function (b) {
  12285. 1 == b.colSpan && b.setAttribute('width', a)
  12286. })
  12287. }
  12288. var d = this,
  12289. e = f(d)
  12290. e && e.selectedTds.length && c(b())
  12291. }
  12292. }),
  12293. (UE.commands.averagedistributerow = {
  12294. queryCommandState: function () {
  12295. var a = f(this)
  12296. return a
  12297. ? a.selectedTds && /th/gi.test(a.selectedTds[0].tagName)
  12298. ? -1
  12299. : a.isFullRow() || a.isFullCol()
  12300. ? 0
  12301. : -1
  12302. : -1
  12303. },
  12304. execCommand: function (a) {
  12305. function b() {
  12306. var a,
  12307. b,
  12308. c = 0,
  12309. f = e.table,
  12310. h = g(d, f),
  12311. i = parseInt(
  12312. domUtils.getComputedStyle(
  12313. f.getElementsByTagName('td')[0],
  12314. 'padding-top'
  12315. )
  12316. )
  12317. if (e.isFullCol()) {
  12318. var j,
  12319. k,
  12320. l = domUtils.getElementsByTagName(f, 'caption'),
  12321. m = domUtils.getElementsByTagName(f, 'th')
  12322. l.length > 0 && (j = l[0].offsetHeight),
  12323. m.length > 0 && (k = m[0].offsetHeight),
  12324. (c = f.offsetHeight - (j || 0) - (k || 0)),
  12325. (b = 0 == m.length ? e.rowsNum : e.rowsNum - 1)
  12326. } else {
  12327. for (
  12328. var n = e.cellsRange.beginRowIndex,
  12329. o = e.cellsRange.endRowIndex,
  12330. p = 0,
  12331. q = domUtils.getElementsByTagName(f, 'tr'),
  12332. r = n;
  12333. r <= o;
  12334. r++
  12335. )
  12336. (c += q[r].offsetHeight), (p += 1)
  12337. b = p
  12338. }
  12339. return (a =
  12340. browser.ie && browser.version < 9
  12341. ? Math.ceil(c / b)
  12342. : Math.ceil(c / b) - 2 * h.tdBorder - 2 * i)
  12343. }
  12344. function c(a) {
  12345. var b = e.isFullCol()
  12346. ? domUtils.getElementsByTagName(e.table, 'td')
  12347. : e.selectedTds
  12348. utils.each(b, function (b) {
  12349. 1 == b.rowSpan && b.setAttribute('height', a)
  12350. })
  12351. }
  12352. var d = this,
  12353. e = f(d)
  12354. e && e.selectedTds.length && c(b())
  12355. }
  12356. }),
  12357. (UE.commands.cellalignment = {
  12358. queryCommandState: function () {
  12359. return e(this).table ? 0 : -1
  12360. },
  12361. execCommand: function (a, b) {
  12362. var c = this,
  12363. d = f(c)
  12364. if (d)
  12365. utils.each(d.selectedTds, function (a) {
  12366. domUtils.setAttributes(a, b)
  12367. })
  12368. else {
  12369. var e = c.selection.getStart(),
  12370. g =
  12371. e &&
  12372. domUtils.findParentByTagName(e, ['td', 'th', 'caption'], !0)
  12373. ;/caption/gi.test(g.tagName)
  12374. ? ((g.style.textAlign = b.align),
  12375. (g.style.verticalAlign = b.vAlign))
  12376. : domUtils.setAttributes(g, b),
  12377. c.selection.getRange().setCursor(!0)
  12378. }
  12379. },
  12380. queryCommandValue: function (a) {
  12381. var b = e(this).cell
  12382. if ((b || (b = c(this)[0]), b)) {
  12383. var d = UE.UETable.getUETable(b).selectedTds
  12384. return !d.length && (d = b), UE.UETable.getTableCellAlignState(d)
  12385. }
  12386. return null
  12387. }
  12388. }),
  12389. (UE.commands.tablealignment = {
  12390. queryCommandState: function () {
  12391. return browser.ie && browser.version < 8
  12392. ? -1
  12393. : e(this).table
  12394. ? 0
  12395. : -1
  12396. },
  12397. execCommand: function (a, b) {
  12398. var c = this,
  12399. d = c.selection.getStart(),
  12400. e = d && domUtils.findParentByTagName(d, ['table'], !0)
  12401. e && e.setAttribute('align', b)
  12402. }
  12403. }),
  12404. (UE.commands.edittable = {
  12405. queryCommandState: function () {
  12406. return e(this).table ? 0 : -1
  12407. },
  12408. execCommand: function (a, b) {
  12409. var c = this.selection.getRange(),
  12410. d = domUtils.findParentByTagName(c.startContainer, 'table')
  12411. if (d) {
  12412. var e = domUtils
  12413. .getElementsByTagName(d, 'td')
  12414. .concat(
  12415. domUtils.getElementsByTagName(d, 'th'),
  12416. domUtils.getElementsByTagName(d, 'caption')
  12417. )
  12418. utils.each(e, function (a) {
  12419. a.style.borderColor = b
  12420. })
  12421. }
  12422. }
  12423. }),
  12424. (UE.commands.edittd = {
  12425. queryCommandState: function () {
  12426. return e(this).table ? 0 : -1
  12427. },
  12428. execCommand: function (a, b) {
  12429. var c = this,
  12430. d = f(c)
  12431. if (d)
  12432. utils.each(d.selectedTds, function (a) {
  12433. a.style.backgroundColor = b
  12434. })
  12435. else {
  12436. var e = c.selection.getStart(),
  12437. g =
  12438. e &&
  12439. domUtils.findParentByTagName(e, ['td', 'th', 'caption'], !0)
  12440. g && (g.style.backgroundColor = b)
  12441. }
  12442. }
  12443. }),
  12444. (UE.commands.settablebackground = {
  12445. queryCommandState: function () {
  12446. return c(this).length > 1 ? 0 : -1
  12447. },
  12448. execCommand: function (a, b) {
  12449. var d, e
  12450. ;(d = c(this)), (e = h(d[0])), e.setBackground(d, b)
  12451. }
  12452. }),
  12453. (UE.commands.cleartablebackground = {
  12454. queryCommandState: function () {
  12455. var a = c(this)
  12456. if (!a.length) return -1
  12457. for (var b, d = 0; (b = a[d++]); )
  12458. if ('' !== b.style.backgroundColor) return 0
  12459. return -1
  12460. },
  12461. execCommand: function () {
  12462. var a = c(this),
  12463. b = h(a[0])
  12464. b.removeBackground(a)
  12465. }
  12466. }),
  12467. (UE.commands.interlacetable = UE.commands.uninterlacetable =
  12468. {
  12469. queryCommandState: function (a) {
  12470. var b = e(this).table
  12471. if (!b) return -1
  12472. var c = b.getAttribute('interlaced')
  12473. return 'interlacetable' == a
  12474. ? 'enabled' === c
  12475. ? -1
  12476. : 0
  12477. : c && 'disabled' !== c
  12478. ? 0
  12479. : -1
  12480. },
  12481. execCommand: function (a, b) {
  12482. var c = e(this).table
  12483. 'interlacetable' == a
  12484. ? (c.setAttribute('interlaced', 'enabled'),
  12485. this.fireEvent('interlacetable', c, b))
  12486. : (c.setAttribute('interlaced', 'disabled'),
  12487. this.fireEvent('uninterlacetable', c))
  12488. }
  12489. }),
  12490. (UE.commands.setbordervisible = {
  12491. queryCommandState: function (a) {
  12492. var b = e(this).table
  12493. return b ? 0 : -1
  12494. },
  12495. execCommand: function () {
  12496. var a = e(this).table
  12497. utils.each(domUtils.getElementsByTagName(a, 'td'), function (a) {
  12498. ;(a.style.borderWidth = '1px'), (a.style.borderStyle = 'solid')
  12499. })
  12500. }
  12501. })
  12502. })(),
  12503. (UE.plugins.table = function () {
  12504. function a(a) {}
  12505. function b(a, b) {
  12506. c(a, 'width', !0), c(a, 'height', !0)
  12507. }
  12508. function c(a, b, c) {
  12509. a.style[b] &&
  12510. (c && a.setAttribute(b, parseInt(a.style[b], 10)), (a.style[b] = ''))
  12511. }
  12512. function d(a) {
  12513. if ('TD' == a.tagName || 'TH' == a.tagName) return a
  12514. var b
  12515. return (b =
  12516. domUtils.findParentByTagName(a, 'td', !0) ||
  12517. domUtils.findParentByTagName(a, 'th', !0))
  12518. ? b
  12519. : null
  12520. }
  12521. function e(a) {
  12522. var b = new RegExp(domUtils.fillChar, 'g')
  12523. if (
  12524. a[browser.ie ? 'innerText' : 'textContent']
  12525. .replace(/^\s*$/, '')
  12526. .replace(b, '').length > 0
  12527. )
  12528. return 0
  12529. for (var c in dtd.$isNotEmpty)
  12530. if (a.getElementsByTagName(c).length) return 0
  12531. return 1
  12532. }
  12533. function f(a) {
  12534. return a.pageX || a.pageY
  12535. ? { x: a.pageX, y: a.pageY }
  12536. : {
  12537. x:
  12538. a.clientX +
  12539. N.document.body.scrollLeft -
  12540. N.document.body.clientLeft,
  12541. y:
  12542. a.clientY +
  12543. N.document.body.scrollTop -
  12544. N.document.body.clientTop
  12545. }
  12546. }
  12547. function g(b) {
  12548. if (!A())
  12549. try {
  12550. var c,
  12551. e = d(b.target || b.srcElement)
  12552. if (
  12553. (R &&
  12554. ((N.body.style.webkitUserSelect = 'none'),
  12555. (Math.abs(V.x - b.clientX) > T ||
  12556. Math.abs(V.y - b.clientY) > T) &&
  12557. (t(), (R = !1), (U = 0), v(b))),
  12558. ca && ha)
  12559. )
  12560. return (
  12561. (U = 0),
  12562. (N.body.style.webkitUserSelect = 'none'),
  12563. N.selection
  12564. .getNative()
  12565. [browser.ie9below ? 'empty' : 'removeAllRanges'](),
  12566. (c = f(b)),
  12567. m(N, !0, ca, c, e),
  12568. void ('h' == ca
  12569. ? (ga.style.left = k(ha, b) + 'px')
  12570. : 'v' == ca && (ga.style.top = l(ha, b) + 'px'))
  12571. )
  12572. if (e) {
  12573. if (N.fireEvent('excludetable', e) === !0) return
  12574. c = f(b)
  12575. var g = n(e, c),
  12576. i = domUtils.findParentByTagName(e, 'table', !0)
  12577. if (j(i, e, b, !0)) {
  12578. if (N.fireEvent('excludetable', i) === !0) return
  12579. N.body.style.cursor =
  12580. 'url(' + N.options.cursorpath + 'h.png),pointer'
  12581. } else if (j(i, e, b)) {
  12582. if (N.fireEvent('excludetable', i) === !0) return
  12583. N.body.style.cursor =
  12584. 'url(' + N.options.cursorpath + 'v.png),pointer'
  12585. } else {
  12586. N.body.style.cursor = 'text'
  12587. ;/\d/.test(g) &&
  12588. ((g = g.replace(/\d/, '')),
  12589. (e = Y(e).getPreviewCell(e, 'v' == g))),
  12590. m(N, !!e && !!g, e ? g : '', c, e)
  12591. }
  12592. } else h(!1, i, N)
  12593. } catch (o) {
  12594. a(o)
  12595. }
  12596. }
  12597. function h(a, b, c) {
  12598. if (a) i(b, c)
  12599. else {
  12600. if (fa) return
  12601. la = setTimeout(function () {
  12602. !fa && ea && ea.parentNode && ea.parentNode.removeChild(ea)
  12603. }, 2e3)
  12604. }
  12605. }
  12606. function i(a, b) {
  12607. function c(c, d) {
  12608. clearTimeout(g),
  12609. (g = setTimeout(function () {
  12610. b.fireEvent('tableClicked', a, d)
  12611. }, 300))
  12612. }
  12613. function d(c) {
  12614. clearTimeout(g)
  12615. var d = Y(a),
  12616. e = a.rows[0].cells[0],
  12617. f = d.getLastCell(),
  12618. h = d.getCellsRange(e, f)
  12619. b.selection.getRange().setStart(e, 0).setCursor(!1, !0),
  12620. d.setSelected(h)
  12621. }
  12622. var e = domUtils.getXY(a),
  12623. f = a.ownerDocument
  12624. if (ea && ea.parentNode) return ea
  12625. ;(ea = f.createElement('div')),
  12626. (ea.contentEditable = !1),
  12627. (ea.innerHTML = ''),
  12628. (ea.style.cssText =
  12629. 'width:15px;height:15px;background-image:url(' +
  12630. b.options.UEDITOR_HOME_URL +
  12631. 'dialogs/table/dragicon.png);position: absolute;cursor:move;top:' +
  12632. (e.y - 15) +
  12633. 'px;left:' +
  12634. e.x +
  12635. 'px;'),
  12636. domUtils.unSelectable(ea),
  12637. (ea.onmouseover = function (a) {
  12638. fa = !0
  12639. }),
  12640. (ea.onmouseout = function (a) {
  12641. fa = !1
  12642. }),
  12643. domUtils.on(ea, 'click', function (a, b) {
  12644. c(b, this)
  12645. }),
  12646. domUtils.on(ea, 'dblclick', function (a, b) {
  12647. d(b)
  12648. }),
  12649. domUtils.on(ea, 'dragstart', function (a, b) {
  12650. domUtils.preventDefault(b)
  12651. })
  12652. var g
  12653. f.body.appendChild(ea)
  12654. }
  12655. function j(a, b, c, d) {
  12656. var e = f(c),
  12657. g = n(b, e)
  12658. if (d) {
  12659. var h = a.getElementsByTagName('caption')[0],
  12660. i = h ? h.offsetHeight : 0
  12661. return 'v1' == g && e.y - domUtils.getXY(a).y - i < 8
  12662. }
  12663. return 'h1' == g && e.x - domUtils.getXY(a).x < 8
  12664. }
  12665. function k(a, b) {
  12666. var c = Y(a)
  12667. if (c) {
  12668. var d = c.getSameEndPosCells(a, 'x')[0],
  12669. e = c.getSameStartPosXCells(a)[0],
  12670. g = f(b).x,
  12671. h = (d ? domUtils.getXY(d).x : domUtils.getXY(c.table).x) + 20,
  12672. i = e
  12673. ? domUtils.getXY(e).x + e.offsetWidth - 20
  12674. : N.body.offsetWidth + 5 ||
  12675. parseInt(domUtils.getComputedStyle(N.body, 'width'), 10)
  12676. return (h += Q), (i -= Q), g < h ? h : g > i ? i : g
  12677. }
  12678. }
  12679. function l(b, c) {
  12680. try {
  12681. var d = domUtils.getXY(b).y,
  12682. e = f(c).y
  12683. return e < d ? d : e
  12684. } catch (g) {
  12685. a(g)
  12686. }
  12687. }
  12688. function m(b, c, d, e, f) {
  12689. try {
  12690. ;(b.body.style.cursor =
  12691. 'h' == d ? 'col-resize' : 'v' == d ? 'row-resize' : 'text'),
  12692. browser.ie &&
  12693. (!d || ia || Z(b) ? I(b) : (H(b, b.document), J(d, f))),
  12694. (da = c)
  12695. } catch (g) {
  12696. a(g)
  12697. }
  12698. }
  12699. function n(a, b) {
  12700. var c = domUtils.getXY(a)
  12701. return c
  12702. ? c.x + a.offsetWidth - b.x < S
  12703. ? 'h'
  12704. : b.x - c.x < S
  12705. ? 'h1'
  12706. : c.y + a.offsetHeight - b.y < S
  12707. ? 'v'
  12708. : b.y - c.y < S
  12709. ? 'v1'
  12710. : ''
  12711. : ''
  12712. }
  12713. function o(a, b) {
  12714. if (!A())
  12715. if (((V = { x: b.clientX, y: b.clientY }), 2 == b.button)) {
  12716. var c = Z(N),
  12717. d = !1
  12718. if (c) {
  12719. var e = M(N, b)
  12720. utils.each(c.selectedTds, function (a) {
  12721. a === e && (d = !0)
  12722. }),
  12723. d
  12724. ? ((e = c.selectedTds[0]),
  12725. setTimeout(function () {
  12726. N.selection.getRange().setStart(e, 0).setCursor(!1, !0)
  12727. }, 0))
  12728. : (_(domUtils.getElementsByTagName(N.body, 'th td')),
  12729. c.clearSelected())
  12730. }
  12731. } else q(b)
  12732. }
  12733. function p(a) {
  12734. ;(U = 0), (a = a || N.window.event)
  12735. var b = d(a.target || a.srcElement)
  12736. if (b) {
  12737. var c
  12738. if ((c = n(b, f(a)))) {
  12739. if ((I(N), 'h1' == c))
  12740. if (
  12741. ((c = 'h'), j(domUtils.findParentByTagName(b, 'table'), b, a))
  12742. )
  12743. N.execCommand('adaptbywindow')
  12744. else if ((b = Y(b).getPreviewCell(b))) {
  12745. var e = N.selection.getRange()
  12746. e.selectNodeContents(b).setCursor(!0, !0)
  12747. }
  12748. if ('h' == c) {
  12749. var g = Y(b),
  12750. h = g.table,
  12751. i = C(b, h, !0)
  12752. ;(i = s(i, 'left')), (g.width = g.offsetWidth)
  12753. var k = [],
  12754. l = []
  12755. utils.each(i, function (a) {
  12756. k.push(a.offsetWidth)
  12757. }),
  12758. utils.each(i, function (a) {
  12759. a.removeAttribute('width')
  12760. }),
  12761. window.setTimeout(function () {
  12762. var a = !0
  12763. utils.each(i, function (b, c) {
  12764. var d = b.offsetWidth
  12765. return d > k[c] ? ((a = !1), !1) : void l.push(d)
  12766. })
  12767. var b = a ? l : k
  12768. utils.each(i, function (a, c) {
  12769. a.width = b[c] - G()
  12770. })
  12771. }, 0)
  12772. }
  12773. }
  12774. }
  12775. }
  12776. function q(a) {
  12777. if (
  12778. (_(domUtils.getElementsByTagName(N.body, 'td th')),
  12779. utils.each(N.document.getElementsByTagName('table'), function (a) {
  12780. a.ueTable = null
  12781. }),
  12782. (aa = M(N, a)))
  12783. ) {
  12784. var b = domUtils.findParentByTagName(aa, 'table', !0)
  12785. ;(ut = Y(b)),
  12786. ut && ut.clearSelected(),
  12787. da
  12788. ? r(a)
  12789. : ((N.document.body.style.webkitUserSelect = ''),
  12790. (ia = !0),
  12791. N.addListener('mouseover', x))
  12792. }
  12793. }
  12794. function r(a) {
  12795. browser.ie && (a = u(a)),
  12796. t(),
  12797. (R = !0),
  12798. (O = setTimeout(function () {
  12799. v(a)
  12800. }, W))
  12801. }
  12802. function s(a, b) {
  12803. for (var c = [], d = null, e = 0, f = a.length; e < f; e++)
  12804. (d = a[e][b]), d && c.push(d)
  12805. return c
  12806. }
  12807. function t() {
  12808. O && clearTimeout(O), (O = null)
  12809. }
  12810. function u(a) {
  12811. var b = [
  12812. 'pageX',
  12813. 'pageY',
  12814. 'clientX',
  12815. 'clientY',
  12816. 'srcElement',
  12817. 'target'
  12818. ],
  12819. c = {}
  12820. if (a)
  12821. for (var d, e, f = 0; (d = b[f]); f++) (e = a[d]), e && (c[d] = e)
  12822. return c
  12823. }
  12824. function v(a) {
  12825. if (((R = !1), (aa = a.target || a.srcElement))) {
  12826. var b = n(aa, f(a))
  12827. ;/\d/.test(b) &&
  12828. ((b = b.replace(/\d/, '')),
  12829. (aa = Y(aa).getPreviewCell(aa, 'v' == b))),
  12830. I(N),
  12831. H(N, N.document),
  12832. N.fireEvent('saveScene'),
  12833. J(b, aa),
  12834. (ia = !0),
  12835. (ca = b),
  12836. (ha = aa)
  12837. }
  12838. }
  12839. function w(a, b) {
  12840. if (!A()) {
  12841. if (
  12842. (t(),
  12843. (R = !1),
  12844. da &&
  12845. ((U = ++U % 3),
  12846. (V = { x: b.clientX, y: b.clientY }),
  12847. (P = setTimeout(function () {
  12848. U > 0 && U--
  12849. }, W)),
  12850. 2 === U))
  12851. )
  12852. return (U = 0), void p(b)
  12853. if (2 != b.button) {
  12854. var c = this,
  12855. d = c.selection.getRange(),
  12856. e = domUtils.findParentByTagName(d.startContainer, 'table', !0),
  12857. f = domUtils.findParentByTagName(d.endContainer, 'table', !0)
  12858. if (
  12859. ((e || f) &&
  12860. (e === f
  12861. ? ((e = domUtils.findParentByTagName(
  12862. d.startContainer,
  12863. ['td', 'th', 'caption'],
  12864. !0
  12865. )),
  12866. (f = domUtils.findParentByTagName(
  12867. d.endContainer,
  12868. ['td', 'th', 'caption'],
  12869. !0
  12870. )),
  12871. e !== f && c.selection.clearRange())
  12872. : c.selection.clearRange()),
  12873. (ia = !1),
  12874. (c.document.body.style.webkitUserSelect = ''),
  12875. ca &&
  12876. ha &&
  12877. (c.selection
  12878. .getNative()
  12879. [browser.ie9below ? 'empty' : 'removeAllRanges'](),
  12880. (U = 0),
  12881. (ga = c.document.getElementById('ue_tableDragLine'))))
  12882. ) {
  12883. var g = domUtils.getXY(ha),
  12884. h = domUtils.getXY(ga)
  12885. switch (ca) {
  12886. case 'h':
  12887. z(ha, h.x - g.x)
  12888. break
  12889. case 'v':
  12890. B(ha, h.y - g.y - ha.offsetHeight)
  12891. }
  12892. return (ca = ''), (ha = null), I(c), void c.fireEvent('saveScene')
  12893. }
  12894. if (aa) {
  12895. var i = Y(aa),
  12896. j = i ? i.selectedTds[0] : null
  12897. if (j)
  12898. (d = new dom.Range(c.document)),
  12899. domUtils.isEmptyBlock(j)
  12900. ? d.setStart(j, 0).setCursor(!1, !0)
  12901. : d.selectNodeContents(j).shrinkBoundary().setCursor(!1, !0)
  12902. else if (
  12903. ((d = c.selection.getRange().shrinkBoundary()), !d.collapsed)
  12904. ) {
  12905. var e = domUtils.findParentByTagName(
  12906. d.startContainer,
  12907. ['td', 'th'],
  12908. !0
  12909. ),
  12910. f = domUtils.findParentByTagName(
  12911. d.endContainer,
  12912. ['td', 'th'],
  12913. !0
  12914. )
  12915. ;((e && !f) || (!e && f) || (e && f && e !== f)) &&
  12916. d.setCursor(!1, !0)
  12917. }
  12918. ;(aa = null), c.removeListener('mouseover', x)
  12919. } else {
  12920. var k = domUtils.findParentByTagName(
  12921. b.target || b.srcElement,
  12922. 'td',
  12923. !0
  12924. )
  12925. if (
  12926. (k ||
  12927. (k = domUtils.findParentByTagName(
  12928. b.target || b.srcElement,
  12929. 'th',
  12930. !0
  12931. )),
  12932. k && ('TD' == k.tagName || 'TH' == k.tagName))
  12933. ) {
  12934. if (c.fireEvent('excludetable', k) === !0) return
  12935. ;(d = new dom.Range(c.document)),
  12936. d.setStart(k, 0).setCursor(!1, !0)
  12937. }
  12938. }
  12939. c._selectionChange(250, b)
  12940. }
  12941. }
  12942. }
  12943. function x(a, b) {
  12944. if (!A()) {
  12945. var c = this,
  12946. d = b.target || b.srcElement
  12947. if (
  12948. ((ba =
  12949. domUtils.findParentByTagName(d, 'td', !0) ||
  12950. domUtils.findParentByTagName(d, 'th', !0)),
  12951. aa &&
  12952. ba &&
  12953. (('TD' == aa.tagName && 'TD' == ba.tagName) ||
  12954. ('TH' == aa.tagName && 'TH' == ba.tagName)) &&
  12955. domUtils.findParentByTagName(aa, 'table') ==
  12956. domUtils.findParentByTagName(ba, 'table'))
  12957. ) {
  12958. var e = Y(ba)
  12959. if (aa != ba) {
  12960. ;(c.document.body.style.webkitUserSelect = 'none'),
  12961. c.selection
  12962. .getNative()
  12963. [browser.ie9below ? 'empty' : 'removeAllRanges']()
  12964. var f = e.getCellsRange(aa, ba)
  12965. e.setSelected(f)
  12966. } else
  12967. (c.document.body.style.webkitUserSelect = ''), e.clearSelected()
  12968. }
  12969. b.preventDefault ? b.preventDefault() : (b.returnValue = !1)
  12970. }
  12971. }
  12972. function y(a, b, c) {
  12973. var d = parseInt(domUtils.getComputedStyle(a, 'line-height'), 10),
  12974. e = c + b
  12975. ;(b = e < d ? d : e),
  12976. a.style.height && (a.style.height = ''),
  12977. 1 == a.rowSpan
  12978. ? a.setAttribute('height', b)
  12979. : a.removeAttribute && a.removeAttribute('height')
  12980. }
  12981. function z(a, b) {
  12982. var c = Y(a)
  12983. if (c) {
  12984. var d = c.table,
  12985. e = C(a, d)
  12986. if (
  12987. ((d.style.width = ''),
  12988. d.removeAttribute('width'),
  12989. (b = D(b, a, e)),
  12990. a.nextSibling)
  12991. ) {
  12992. utils.each(e, function (a) {
  12993. ;(a.left.width = +a.left.width + b),
  12994. a.right && (a.right.width = +a.right.width - b)
  12995. })
  12996. } else
  12997. utils.each(e, function (a) {
  12998. a.left.width -= -b
  12999. })
  13000. }
  13001. }
  13002. function A() {
  13003. return 'false' === N.body.contentEditable
  13004. }
  13005. function B(a, b) {
  13006. if (!(Math.abs(b) < 10)) {
  13007. var c = Y(a)
  13008. if (c)
  13009. for (
  13010. var d,
  13011. e = c.getSameEndPosCells(a, 'y'),
  13012. f = e[0] ? e[0].offsetHeight : 0,
  13013. g = 0;
  13014. (d = e[g++]);
  13015. )
  13016. y(d, b, f)
  13017. }
  13018. }
  13019. function C(a, b, c) {
  13020. if ((b || (b = domUtils.findParentByTagName(a, 'table')), !b))
  13021. return null
  13022. for (var d = (domUtils.getNodeIndex(a), a), e = b.rows, f = 0; d; )
  13023. 1 === d.nodeType && (f += d.colSpan || 1), (d = d.previousSibling)
  13024. d = null
  13025. var g = []
  13026. return (
  13027. utils.each(e, function (a) {
  13028. var b = a.cells,
  13029. d = 0
  13030. utils.each(b, function (a) {
  13031. return (
  13032. (d += a.colSpan || 1),
  13033. d === f
  13034. ? (g.push({ left: a, right: a.nextSibling || null }), !1)
  13035. : d > f
  13036. ? (c && g.push({ left: a }), !1)
  13037. : void 0
  13038. )
  13039. })
  13040. }),
  13041. g
  13042. )
  13043. }
  13044. function D(a, b, c) {
  13045. if (((a -= G()), a < 0)) return 0
  13046. a -= E(b)
  13047. var d = a < 0 ? 'left' : 'right'
  13048. return (
  13049. (a = Math.abs(a)),
  13050. utils.each(c, function (b) {
  13051. var c = b[d]
  13052. c && (a = Math.min(a, E(c) - Q))
  13053. }),
  13054. (a = a < 0 ? 0 : a),
  13055. 'left' === d ? -a : a
  13056. )
  13057. }
  13058. function E(a) {
  13059. var b = 0,
  13060. b = a.offsetWidth - G()
  13061. a.nextSibling || (b -= F(a)), (b = b < 0 ? 0 : b)
  13062. try {
  13063. a.width = b
  13064. } catch (c) {}
  13065. return b
  13066. }
  13067. function F(a) {
  13068. if (
  13069. ((tab = domUtils.findParentByTagName(a, 'table', !1)),
  13070. void 0 === tab.offsetVal)
  13071. ) {
  13072. var b = a.previousSibling
  13073. b
  13074. ? (tab.offsetVal =
  13075. a.offsetWidth - b.offsetWidth === X.borderWidth
  13076. ? X.borderWidth
  13077. : 0)
  13078. : (tab.offsetVal = 0)
  13079. }
  13080. return tab.offsetVal
  13081. }
  13082. function G() {
  13083. if (void 0 === X.tabcellSpace) {
  13084. var a = N.document.createElement('table'),
  13085. b = N.document.createElement('tbody'),
  13086. c = N.document.createElement('tr'),
  13087. d = N.document.createElement('td'),
  13088. e = null
  13089. ;(d.style.cssText = 'border: 0;'),
  13090. (d.width = 1),
  13091. c.appendChild(d),
  13092. c.appendChild((e = d.cloneNode(!1))),
  13093. b.appendChild(c),
  13094. a.appendChild(b),
  13095. (a.style.cssText = 'visibility: hidden;'),
  13096. N.body.appendChild(a),
  13097. (X.paddingSpace = d.offsetWidth - 1)
  13098. var f = a.offsetWidth
  13099. ;(d.style.cssText = ''),
  13100. (e.style.cssText = ''),
  13101. (X.borderWidth = (a.offsetWidth - f) / 3),
  13102. (X.tabcellSpace = X.paddingSpace + X.borderWidth),
  13103. N.body.removeChild(a)
  13104. }
  13105. return (
  13106. (G = function () {
  13107. return X.tabcellSpace
  13108. }),
  13109. X.tabcellSpace
  13110. )
  13111. }
  13112. function H(a, b) {
  13113. ia ||
  13114. ((ga = a.document.createElement('div')),
  13115. domUtils.setAttributes(ga, {
  13116. id: 'ue_tableDragLine',
  13117. unselectable: 'on',
  13118. contenteditable: !1,
  13119. onresizestart: 'return false',
  13120. ondragstart: 'return false',
  13121. onselectstart: 'return false',
  13122. style:
  13123. 'background-color:blue;position:absolute;padding:0;margin:0;background-image:none;border:0px none;opacity:0;filter:alpha(opacity=0)'
  13124. }),
  13125. a.body.appendChild(ga))
  13126. }
  13127. function I(a) {
  13128. if (!ia)
  13129. for (var b; (b = a.document.getElementById('ue_tableDragLine')); )
  13130. domUtils.remove(b)
  13131. }
  13132. function J(a, b) {
  13133. if (b) {
  13134. var c,
  13135. d = domUtils.findParentByTagName(b, 'table'),
  13136. e = d.getElementsByTagName('caption'),
  13137. f = d.offsetWidth,
  13138. g = d.offsetHeight - (e.length > 0 ? e[0].offsetHeight : 0),
  13139. h = domUtils.getXY(d),
  13140. i = domUtils.getXY(b)
  13141. switch (a) {
  13142. case 'h':
  13143. ;(c =
  13144. 'height:' +
  13145. g +
  13146. 'px;top:' +
  13147. (h.y + (e.length > 0 ? e[0].offsetHeight : 0)) +
  13148. 'px;left:' +
  13149. (i.x + b.offsetWidth)),
  13150. (ga.style.cssText =
  13151. c +
  13152. 'px;position: absolute;display:block;background-color:blue;width:1px;border:0; color:blue;opacity:.3;filter:alpha(opacity=30)')
  13153. break
  13154. case 'v':
  13155. ;(c =
  13156. 'width:' +
  13157. f +
  13158. 'px;left:' +
  13159. h.x +
  13160. 'px;top:' +
  13161. (i.y + b.offsetHeight)),
  13162. (ga.style.cssText =
  13163. c +
  13164. 'px;overflow:hidden;position: absolute;display:block;background-color:blue;height:1px;border:0;color:blue;opacity:.2;filter:alpha(opacity=20)')
  13165. }
  13166. }
  13167. }
  13168. function K(a, b) {
  13169. for (
  13170. var c, d, e = domUtils.getElementsByTagName(a.body, 'table'), f = 0;
  13171. (d = e[f++]);
  13172. ) {
  13173. var g = domUtils.getElementsByTagName(d, 'td')
  13174. g[0] &&
  13175. (b
  13176. ? ((c = g[0].style.borderColor.replace(/\s/g, '')),
  13177. /(#ffffff)|(rgb\(255,255,255\))/gi.test(c) &&
  13178. domUtils.addClass(d, 'noBorderTable'))
  13179. : domUtils.removeClasses(d, 'noBorderTable'))
  13180. }
  13181. }
  13182. function L(a, b, c) {
  13183. var d = a.body
  13184. return (
  13185. d.offsetWidth -
  13186. (b
  13187. ? 2 * parseInt(domUtils.getComputedStyle(d, 'margin-left'), 10)
  13188. : 0) -
  13189. 2 * c.tableBorder -
  13190. (a.options.offsetWidth || 0)
  13191. )
  13192. }
  13193. function M(a, b) {
  13194. var c = domUtils.findParentByTagName(
  13195. b.target || b.srcElement,
  13196. ['td', 'th'],
  13197. !0
  13198. ),
  13199. d = null
  13200. if (!c) return null
  13201. if (((d = n(c, f(b))), !c)) return null
  13202. if ('h1' === d && c.previousSibling) {
  13203. var e = domUtils.getXY(c),
  13204. g = c.offsetWidth
  13205. Math.abs(e.x + g - b.clientX) > g / 3 && (c = c.previousSibling)
  13206. } else if ('v1' === d && c.parentNode.previousSibling) {
  13207. var e = domUtils.getXY(c),
  13208. h = c.offsetHeight
  13209. Math.abs(e.y + h - b.clientY) > h / 3 &&
  13210. (c = c.parentNode.previousSibling.firstChild)
  13211. }
  13212. return c && a.fireEvent('excludetable', c) !== !0 ? c : null
  13213. }
  13214. var N = this,
  13215. O = null,
  13216. P = null,
  13217. Q = 5,
  13218. R = !1,
  13219. S = 5,
  13220. T = 10,
  13221. U = 0,
  13222. V = null,
  13223. W = 360,
  13224. X = UE.UETable,
  13225. Y = function (a) {
  13226. return X.getUETable(a)
  13227. },
  13228. Z = function (a) {
  13229. return X.getUETableBySelected(a)
  13230. },
  13231. $ = function (a, b) {
  13232. return X.getDefaultValue(a, b)
  13233. },
  13234. _ = function (a) {
  13235. return X.removeSelectedClass(a)
  13236. }
  13237. N.ready(function () {
  13238. var a = this,
  13239. b = a.selection.getText
  13240. a.selection.getText = function () {
  13241. var c = Z(a)
  13242. if (c) {
  13243. var d = ''
  13244. return (
  13245. utils.each(c.selectedTds, function (a) {
  13246. d += a[browser.ie ? 'innerText' : 'textContent']
  13247. }),
  13248. d
  13249. )
  13250. }
  13251. return b.call(a.selection)
  13252. }
  13253. })
  13254. var aa = null,
  13255. ba = null,
  13256. ca = '',
  13257. da = !1,
  13258. ea = null,
  13259. fa = !1,
  13260. ga = null,
  13261. ha = null,
  13262. ia = !1,
  13263. ja = !0
  13264. N.setOpt({
  13265. maxColNum: 20,
  13266. maxRowNum: 100,
  13267. defaultCols: 5,
  13268. defaultRows: 5,
  13269. tdvalign: 'top',
  13270. cursorpath:
  13271. N.options.UEDITOR_HOME_URL + 'themes/default/images/cursor_',
  13272. tableDragable: !1,
  13273. classList: [
  13274. 'ue-table-interlace-color-single',
  13275. 'ue-table-interlace-color-double'
  13276. ]
  13277. }),
  13278. (N.getUETable = Y)
  13279. var ka = {
  13280. deletetable: 1,
  13281. inserttable: 1,
  13282. cellvalign: 1,
  13283. insertcaption: 1,
  13284. deletecaption: 1,
  13285. inserttitle: 1,
  13286. deletetitle: 1,
  13287. mergeright: 1,
  13288. mergedown: 1,
  13289. mergecells: 1,
  13290. insertrow: 1,
  13291. insertrownext: 1,
  13292. deleterow: 1,
  13293. insertcol: 1,
  13294. insertcolnext: 1,
  13295. deletecol: 1,
  13296. splittocells: 1,
  13297. splittorows: 1,
  13298. splittocols: 1,
  13299. adaptbytext: 1,
  13300. adaptbywindow: 1,
  13301. adaptbycustomer: 1,
  13302. insertparagraph: 1,
  13303. insertparagraphbeforetable: 1,
  13304. averagedistributecol: 1,
  13305. averagedistributerow: 1
  13306. }
  13307. N.ready(function () {
  13308. utils.cssRule(
  13309. 'table',
  13310. '.selectTdClass{background-color:#edf5fa !important}table.noBorderTable td,table.noBorderTable th,table.noBorderTable caption{border:1px dashed #ddd !important}table{margin-bottom:10px;border-collapse:collapse;display:table;}td,th{padding: 5px 10px;border: 1px solid #DDD;}caption{border:1px dashed #DDD;border-bottom:0;padding:3px;text-align:center;}th{border-top:1px solid #BBB;background-color:#F7F7F7;}table tr.firstRow th{border-top-width:2px;}.ue-table-interlace-color-single{ background-color: #fcfcfc; } .ue-table-interlace-color-double{ background-color: #f7faff; }td p{margin:0;padding:0;}',
  13311. N.document
  13312. )
  13313. var a, c, f
  13314. N.addListener('keydown', function (b, d) {
  13315. var g = this,
  13316. h = d.keyCode || d.which
  13317. if (8 == h) {
  13318. var i = Z(g)
  13319. i &&
  13320. i.selectedTds.length &&
  13321. (i.isFullCol()
  13322. ? g.execCommand('deletecol')
  13323. : i.isFullRow()
  13324. ? g.execCommand('deleterow')
  13325. : g.fireEvent('delcells'),
  13326. domUtils.preventDefault(d))
  13327. var j = domUtils.findParentByTagName(
  13328. g.selection.getStart(),
  13329. 'caption',
  13330. !0
  13331. ),
  13332. k = g.selection.getRange()
  13333. if (k.collapsed && j && e(j)) {
  13334. g.fireEvent('saveScene')
  13335. var l = j.parentNode
  13336. domUtils.remove(j),
  13337. l && k.setStart(l.rows[0].cells[0], 0).setCursor(!1, !0),
  13338. g.fireEvent('saveScene')
  13339. }
  13340. }
  13341. if (46 == h && (i = Z(g))) {
  13342. g.fireEvent('saveScene')
  13343. for (var m, n = 0; (m = i.selectedTds[n++]); )
  13344. domUtils.fillNode(g.document, m)
  13345. g.fireEvent('saveScene'), domUtils.preventDefault(d)
  13346. }
  13347. if (13 == h) {
  13348. var o = g.selection.getRange(),
  13349. j = domUtils.findParentByTagName(o.startContainer, 'caption', !0)
  13350. if (j) {
  13351. var l = domUtils.findParentByTagName(j, 'table')
  13352. return (
  13353. o.collapsed
  13354. ? j && o.setStart(l.rows[0].cells[0], 0).setCursor(!1, !0)
  13355. : (o.deleteContents(), g.fireEvent('saveScene')),
  13356. void domUtils.preventDefault(d)
  13357. )
  13358. }
  13359. if (o.collapsed) {
  13360. var l = domUtils.findParentByTagName(o.startContainer, 'table')
  13361. if (l) {
  13362. var p = l.rows[0].cells[0],
  13363. q = domUtils.findParentByTagName(
  13364. g.selection.getStart(),
  13365. ['td', 'th'],
  13366. !0
  13367. ),
  13368. r = l.previousSibling
  13369. if (
  13370. p === q &&
  13371. (!r || (1 == r.nodeType && 'TABLE' == r.tagName)) &&
  13372. domUtils.isStartInblock(o)
  13373. ) {
  13374. var s = domUtils.findParent(
  13375. g.selection.getStart(),
  13376. function (a) {
  13377. return domUtils.isBlockElm(a)
  13378. },
  13379. !0
  13380. )
  13381. s &&
  13382. (/t(h|d)/i.test(s.tagName) || s === q.firstChild) &&
  13383. (g.execCommand('insertparagraphbeforetable'),
  13384. domUtils.preventDefault(d))
  13385. }
  13386. }
  13387. }
  13388. }
  13389. if ((d.ctrlKey || d.metaKey) && '67' == d.keyCode) {
  13390. a = null
  13391. var i = Z(g)
  13392. if (i) {
  13393. var t = i.selectedTds
  13394. ;(c = i.isFullCol()),
  13395. (f = i.isFullRow()),
  13396. (a = [[i.cloneCell(t[0], null, !0)]])
  13397. for (var m, n = 1; (m = t[n]); n++)
  13398. m.parentNode !== t[n - 1].parentNode
  13399. ? a.push([i.cloneCell(m, null, !0)])
  13400. : a[a.length - 1].push(i.cloneCell(m, null, !0))
  13401. }
  13402. }
  13403. }),
  13404. N.addListener('tablehasdeleted', function () {
  13405. m(this, !1, '', null), ea && domUtils.remove(ea)
  13406. }),
  13407. N.addListener('beforepaste', function (d, g) {
  13408. var h = this,
  13409. i = h.selection.getRange()
  13410. if (domUtils.findParentByTagName(i.startContainer, 'caption', !0)) {
  13411. var j = h.document.createElement('div')
  13412. return (
  13413. (j.innerHTML = g.html),
  13414. void (g.html =
  13415. j[browser.ie9below ? 'innerText' : 'textContent'])
  13416. )
  13417. }
  13418. var k = Z(h)
  13419. if (a) {
  13420. h.fireEvent('saveScene')
  13421. var l,
  13422. m,
  13423. i = h.selection.getRange(),
  13424. n = domUtils.findParentByTagName(
  13425. i.startContainer,
  13426. ['td', 'th'],
  13427. !0
  13428. )
  13429. if (n) {
  13430. var o = Y(n)
  13431. if (f) {
  13432. var p = o.getCellInfo(n).rowIndex
  13433. 'TH' == n.tagName && p++
  13434. for (var q, r = 0; (q = a[r++]); ) {
  13435. for (
  13436. var s, t = o.insertRow(p++, 'td'), u = 0;
  13437. (s = q[u]);
  13438. u++
  13439. ) {
  13440. var v = t.cells[u]
  13441. v || (v = t.insertCell(u)),
  13442. (v.innerHTML = s.innerHTML),
  13443. s.getAttribute('width') &&
  13444. v.setAttribute('width', s.getAttribute('width')),
  13445. s.getAttribute('vAlign') &&
  13446. v.setAttribute('vAlign', s.getAttribute('vAlign')),
  13447. s.getAttribute('align') &&
  13448. v.setAttribute('align', s.getAttribute('align')),
  13449. s.style.cssText && (v.style.cssText = s.style.cssText)
  13450. }
  13451. for (var s, u = 0; (s = t.cells[u]) && q[u]; u++)
  13452. (s.innerHTML = q[u].innerHTML),
  13453. q[u].getAttribute('width') &&
  13454. s.setAttribute('width', q[u].getAttribute('width')),
  13455. q[u].getAttribute('vAlign') &&
  13456. s.setAttribute('vAlign', q[u].getAttribute('vAlign')),
  13457. q[u].getAttribute('align') &&
  13458. s.setAttribute('align', q[u].getAttribute('align')),
  13459. q[u].style.cssText &&
  13460. (s.style.cssText = q[u].style.cssText)
  13461. }
  13462. } else {
  13463. if (c) {
  13464. y = o.getCellInfo(n)
  13465. for (var s, w = 0, u = 0, q = a[0]; (s = q[u++]); )
  13466. w += s.colSpan || 1
  13467. for (h.__hasEnterExecCommand = !0, r = 0; r < w; r++)
  13468. h.execCommand('insertcol')
  13469. ;(h.__hasEnterExecCommand = !1),
  13470. (n = o.table.rows[0].cells[y.cellIndex]),
  13471. 'TH' == n.tagName &&
  13472. (n = o.table.rows[1].cells[y.cellIndex])
  13473. }
  13474. for (var q, r = 0; (q = a[r++]); ) {
  13475. l = n
  13476. for (var s, u = 0; (s = q[u++]); )
  13477. if (n)
  13478. (n.innerHTML = s.innerHTML),
  13479. s.getAttribute('width') &&
  13480. n.setAttribute('width', s.getAttribute('width')),
  13481. s.getAttribute('vAlign') &&
  13482. n.setAttribute('vAlign', s.getAttribute('vAlign')),
  13483. s.getAttribute('align') &&
  13484. n.setAttribute('align', s.getAttribute('align')),
  13485. s.style.cssText &&
  13486. (n.style.cssText = s.style.cssText),
  13487. (m = n),
  13488. (n = n.nextSibling)
  13489. else {
  13490. var x = s.cloneNode(!0)
  13491. domUtils.removeAttributes(x, [
  13492. 'class',
  13493. 'rowSpan',
  13494. 'colSpan'
  13495. ]),
  13496. m.parentNode.appendChild(x)
  13497. }
  13498. if (((n = o.getNextCell(l, !0, !0)), !a[r])) break
  13499. if (!n) {
  13500. var y = o.getCellInfo(l)
  13501. o.table.insertRow(o.table.rows.length),
  13502. o.update(),
  13503. (n = o.getVSideCell(l, !0))
  13504. }
  13505. }
  13506. }
  13507. o.update()
  13508. } else {
  13509. k = h.document.createElement('table')
  13510. for (var q, r = 0; (q = a[r++]); ) {
  13511. for (
  13512. var s, t = k.insertRow(k.rows.length), u = 0;
  13513. (s = q[u++]);
  13514. )
  13515. (x = X.cloneCell(s, null, !0)),
  13516. domUtils.removeAttributes(x, ['class']),
  13517. t.appendChild(x)
  13518. 2 == u && x.rowSpan > 1 && (x.rowSpan = 1)
  13519. }
  13520. var z = $(h),
  13521. A =
  13522. h.body.offsetWidth -
  13523. (ja
  13524. ? 2 *
  13525. parseInt(
  13526. domUtils.getComputedStyle(h.body, 'margin-left'),
  13527. 10
  13528. )
  13529. : 0) -
  13530. 2 * z.tableBorder -
  13531. (h.options.offsetWidth || 0)
  13532. h.execCommand(
  13533. 'insertHTML',
  13534. '<table ' +
  13535. (c && f ? 'width="' + A + '"' : '') +
  13536. '>' +
  13537. k.innerHTML
  13538. .replace(/>\s*</g, '><')
  13539. .replace(/\bth\b/gi, 'td') +
  13540. '</table>'
  13541. )
  13542. }
  13543. return (
  13544. h.fireEvent('contentchange'),
  13545. h.fireEvent('saveScene'),
  13546. (g.html = ''),
  13547. !0
  13548. )
  13549. }
  13550. var B,
  13551. j = h.document.createElement('div')
  13552. ;(j.innerHTML = g.html),
  13553. (B = j.getElementsByTagName('table')),
  13554. domUtils.findParentByTagName(h.selection.getStart(), 'table')
  13555. ? (utils.each(B, function (a) {
  13556. domUtils.remove(a)
  13557. }),
  13558. domUtils.findParentByTagName(
  13559. h.selection.getStart(),
  13560. 'caption',
  13561. !0
  13562. ) &&
  13563. (j.innerHTML = j[browser.ie ? 'innerText' : 'textContent']))
  13564. : utils.each(B, function (a) {
  13565. b(a, !0),
  13566. domUtils.removeAttributes(a, ['style', 'border']),
  13567. utils.each(
  13568. domUtils.getElementsByTagName(a, 'td'),
  13569. function (a) {
  13570. e(a) && domUtils.fillNode(h.document, a), b(a, !0)
  13571. }
  13572. )
  13573. }),
  13574. (g.html = j.innerHTML)
  13575. }),
  13576. N.addListener('afterpaste', function () {
  13577. utils.each(
  13578. domUtils.getElementsByTagName(N.body, 'table'),
  13579. function (a) {
  13580. if (a.offsetWidth > N.body.offsetWidth) {
  13581. var b = $(N, a)
  13582. a.style.width =
  13583. N.body.offsetWidth -
  13584. (ja
  13585. ? 2 *
  13586. parseInt(
  13587. domUtils.getComputedStyle(N.body, 'margin-left'),
  13588. 10
  13589. )
  13590. : 0) -
  13591. 2 * b.tableBorder -
  13592. (N.options.offsetWidth || 0) +
  13593. 'px'
  13594. }
  13595. }
  13596. )
  13597. }),
  13598. N.addListener('blur', function () {
  13599. a = null
  13600. })
  13601. var i
  13602. N.addListener('keydown', function () {
  13603. clearTimeout(i),
  13604. (i = setTimeout(function () {
  13605. var a = N.selection.getRange(),
  13606. b = domUtils.findParentByTagName(
  13607. a.startContainer,
  13608. ['th', 'td'],
  13609. !0
  13610. )
  13611. if (b) {
  13612. var c = b.parentNode.parentNode.parentNode
  13613. c.offsetWidth > c.getAttribute('width') &&
  13614. (b.style.wordBreak = 'break-all')
  13615. }
  13616. }, 100))
  13617. }),
  13618. N.addListener('selectionchange', function () {
  13619. m(N, !1, '', null)
  13620. }),
  13621. N.addListener('contentchange', function () {
  13622. var a = this
  13623. if ((I(a), !Z(a))) {
  13624. var b = a.selection.getRange(),
  13625. c = b.startContainer
  13626. ;(c = domUtils.findParentByTagName(c, ['td', 'th'], !0)),
  13627. utils.each(
  13628. domUtils.getElementsByTagName(a.document, 'table'),
  13629. function (b) {
  13630. a.fireEvent('excludetable', b) !== !0 &&
  13631. ((b.ueTable = new X(b)),
  13632. (b.onmouseover = function () {
  13633. a.fireEvent('tablemouseover', b)
  13634. }),
  13635. (b.onmousemove = function () {
  13636. a.fireEvent('tablemousemove', b),
  13637. a.options.tableDragable && h(!0, this, a),
  13638. utils.defer(function () {
  13639. a.fireEvent('contentchange', 50)
  13640. }, !0)
  13641. }),
  13642. (b.onmouseout = function () {
  13643. a.fireEvent('tablemouseout', b),
  13644. m(a, !1, '', null),
  13645. I(a)
  13646. }),
  13647. (b.onclick = function (b) {
  13648. b = a.window.event || b
  13649. var c = d(b.target || b.srcElement)
  13650. if (c) {
  13651. var e,
  13652. f = Y(c),
  13653. g = f.table,
  13654. h = f.getCellInfo(c),
  13655. i = a.selection.getRange()
  13656. if (j(g, c, b, !0)) {
  13657. var k = f.getCell(
  13658. f.indexTable[f.rowsNum - 1][h.colIndex].rowIndex,
  13659. f.indexTable[f.rowsNum - 1][h.colIndex].cellIndex
  13660. )
  13661. return void (b.shiftKey && f.selectedTds.length
  13662. ? f.selectedTds[0] !== k
  13663. ? ((e = f.getCellsRange(f.selectedTds[0], k)),
  13664. f.setSelected(e))
  13665. : i && i.selectNodeContents(k).select()
  13666. : c !== k
  13667. ? ((e = f.getCellsRange(c, k)), f.setSelected(e))
  13668. : i && i.selectNodeContents(k).select())
  13669. }
  13670. if (j(g, c, b)) {
  13671. var l = f.getCell(
  13672. f.indexTable[h.rowIndex][f.colsNum - 1].rowIndex,
  13673. f.indexTable[h.rowIndex][f.colsNum - 1].cellIndex
  13674. )
  13675. b.shiftKey && f.selectedTds.length
  13676. ? f.selectedTds[0] !== l
  13677. ? ((e = f.getCellsRange(f.selectedTds[0], l)),
  13678. f.setSelected(e))
  13679. : i && i.selectNodeContents(l).select()
  13680. : c !== l
  13681. ? ((e = f.getCellsRange(c, l)), f.setSelected(e))
  13682. : i && i.selectNodeContents(l).select()
  13683. }
  13684. }
  13685. }))
  13686. }
  13687. ),
  13688. K(a, !0)
  13689. }
  13690. }),
  13691. domUtils.on(N.document, 'mousemove', g),
  13692. domUtils.on(N.document, 'mouseout', function (a) {
  13693. var b = a.target || a.srcElement
  13694. 'TABLE' == b.tagName && m(N, !1, '', null)
  13695. }),
  13696. N.addListener('interlacetable', function (a, b, c) {
  13697. if (b)
  13698. for (
  13699. var d = this,
  13700. e = b.rows,
  13701. f = e.length,
  13702. g = function (a, b, c) {
  13703. return a[b] ? a[b] : c ? a[b % a.length] : ''
  13704. },
  13705. h = 0;
  13706. h < f;
  13707. h++
  13708. )
  13709. e[h].className = g(c || d.options.classList, h, !0)
  13710. }),
  13711. N.addListener('uninterlacetable', function (a, b) {
  13712. if (b)
  13713. for (
  13714. var c = this,
  13715. d = b.rows,
  13716. e = c.options.classList,
  13717. f = d.length,
  13718. g = 0;
  13719. g < f;
  13720. g++
  13721. )
  13722. domUtils.removeClasses(d[g], e)
  13723. }),
  13724. N.addListener('mousedown', o),
  13725. N.addListener('mouseup', w),
  13726. domUtils.on(N.body, 'dragstart', function (a) {
  13727. w.call(N, 'dragstart', a)
  13728. }),
  13729. N.addOutputRule(function (a) {
  13730. utils.each(a.getNodesByTagName('div'), function (a) {
  13731. 'ue_tableDragLine' == a.getAttr('id') &&
  13732. a.parentNode.removeChild(a)
  13733. })
  13734. })
  13735. var k = 0
  13736. N.addListener('mousedown', function () {
  13737. k = 0
  13738. }),
  13739. N.addListener('tabkeydown', function () {
  13740. var a = this.selection.getRange(),
  13741. b = a.getCommonAncestor(!0, !0),
  13742. c = domUtils.findParentByTagName(b, 'table')
  13743. if (c) {
  13744. if (domUtils.findParentByTagName(b, 'caption', !0)) {
  13745. var d = domUtils.getElementsByTagName(c, 'th td')
  13746. d && d.length && a.setStart(d[0], 0).setCursor(!1, !0)
  13747. } else {
  13748. var d = domUtils.findParentByTagName(b, ['td', 'th'], !0),
  13749. f = Y(d)
  13750. k = d.rowSpan > 1 ? k : f.getCellInfo(d).rowIndex
  13751. var g = f.getTabNextCell(d, k)
  13752. g
  13753. ? e(g)
  13754. ? a.setStart(g, 0).setCursor(!1, !0)
  13755. : a.selectNodeContents(g).select()
  13756. : (N.fireEvent('saveScene'),
  13757. (N.__hasEnterExecCommand = !0),
  13758. this.execCommand('insertrownext'),
  13759. (N.__hasEnterExecCommand = !1),
  13760. (a = this.selection.getRange()),
  13761. a
  13762. .setStart(c.rows[c.rows.length - 1].cells[0], 0)
  13763. .setCursor(),
  13764. N.fireEvent('saveScene'))
  13765. }
  13766. return !0
  13767. }
  13768. }),
  13769. browser.ie &&
  13770. N.addListener('selectionchange', function () {
  13771. m(this, !1, '', null)
  13772. }),
  13773. N.addListener('keydown', function (a, b) {
  13774. var c = this,
  13775. d = b.keyCode || b.which
  13776. if (8 != d && 46 != d) {
  13777. var e = !(b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)
  13778. e && _(domUtils.getElementsByTagName(c.body, 'td'))
  13779. var f = Z(c)
  13780. f && e && f.clearSelected()
  13781. }
  13782. }),
  13783. N.addListener('beforegetcontent', function () {
  13784. K(this, !1),
  13785. browser.ie &&
  13786. utils.each(
  13787. this.document.getElementsByTagName('caption'),
  13788. function (a) {
  13789. domUtils.isEmptyNode(a) && (a.innerHTML = '&nbsp;')
  13790. }
  13791. )
  13792. }),
  13793. N.addListener('aftergetcontent', function () {
  13794. K(this, !0)
  13795. }),
  13796. N.addListener('getAllHtml', function () {
  13797. _(N.document.getElementsByTagName('td'))
  13798. }),
  13799. N.addListener('fullscreenchanged', function (a, b) {
  13800. if (!b) {
  13801. var c = this.body.offsetWidth / document.body.offsetWidth,
  13802. d = domUtils.getElementsByTagName(this.body, 'table')
  13803. utils.each(d, function (a) {
  13804. if (a.offsetWidth < N.body.offsetWidth) return !1
  13805. var b = domUtils.getElementsByTagName(a, 'td'),
  13806. d = []
  13807. utils.each(b, function (a) {
  13808. d.push(a.offsetWidth)
  13809. })
  13810. for (var e, f = 0; (e = b[f]); f++)
  13811. e.setAttribute('width', Math.floor(d[f] * c))
  13812. a.setAttribute('width', Math.floor(L(N, ja, $(N))))
  13813. })
  13814. }
  13815. })
  13816. var l = N.execCommand
  13817. N.execCommand = function (a, b) {
  13818. var c = this
  13819. a = a.toLowerCase()
  13820. var d,
  13821. f,
  13822. g = Z(c),
  13823. h = new dom.Range(c.document),
  13824. i = c.commands[a] || UE.commands[a]
  13825. if (i) {
  13826. if (!g || ka[a] || i.notNeedUndo || c.__hasEnterExecCommand)
  13827. f = l.apply(c, arguments)
  13828. else {
  13829. ;(c.__hasEnterExecCommand = !0),
  13830. c.fireEvent('beforeexeccommand', a),
  13831. (d = g.selectedTds)
  13832. for (var j, k, m, n = -2, o = -2, p = 0; (m = d[p]); p++)
  13833. e(m)
  13834. ? h.setStart(m, 0).setCursor(!1, !0)
  13835. : h.selectNode(m).select(!0),
  13836. (k = c.queryCommandState(a)),
  13837. (j = c.queryCommandValue(a)),
  13838. k != -1 &&
  13839. ((n === k && o === j) ||
  13840. ((c._ignoreContentChange = !0),
  13841. (f = l.apply(c, arguments)),
  13842. (c._ignoreContentChange = !1)),
  13843. (n = c.queryCommandState(a)),
  13844. (o = c.queryCommandValue(a)),
  13845. domUtils.isEmptyBlock(m) &&
  13846. domUtils.fillNode(c.document, m))
  13847. h.setStart(d[0], 0).shrinkBoundary(!0).setCursor(!1, !0),
  13848. c.fireEvent('contentchange'),
  13849. c.fireEvent('afterexeccommand', a),
  13850. (c.__hasEnterExecCommand = !1),
  13851. c._selectionChange()
  13852. }
  13853. return f
  13854. }
  13855. }
  13856. })
  13857. var la
  13858. }),
  13859. (UE.UETable.prototype.sortTable = function (a, b) {
  13860. var c = this.table,
  13861. d = c.rows,
  13862. e = [],
  13863. f = 'TH' === d[0].cells[0].tagName,
  13864. g = 0
  13865. if (this.selectedTds.length) {
  13866. for (
  13867. var h = this.cellsRange, i = h.endRowIndex + 1, j = h.beginRowIndex;
  13868. j < i;
  13869. j++
  13870. )
  13871. e[j] = d[j]
  13872. e.splice(0, h.beginRowIndex),
  13873. (g = h.endRowIndex + 1 === this.rowsNum ? 0 : h.endRowIndex + 1)
  13874. } else for (var j = 0, i = d.length; j < i; j++) e[j] = d[j]
  13875. var k = {
  13876. reversecurrent: function (a, b) {
  13877. return 1
  13878. },
  13879. orderbyasc: function (a, b) {
  13880. var c = a.innerText || a.textContent,
  13881. d = b.innerText || b.textContent
  13882. return c.localeCompare(d)
  13883. },
  13884. reversebyasc: function (a, b) {
  13885. var c = a.innerHTML,
  13886. d = b.innerHTML
  13887. return d.localeCompare(c)
  13888. },
  13889. orderbynum: function (a, b) {
  13890. var c = a[browser.ie ? 'innerText' : 'textContent'].match(/\d+/),
  13891. d = b[browser.ie ? 'innerText' : 'textContent'].match(/\d+/)
  13892. return c && (c = +c[0]), d && (d = +d[0]), (c || 0) - (d || 0)
  13893. },
  13894. reversebynum: function (a, b) {
  13895. var c = a[browser.ie ? 'innerText' : 'textContent'].match(/\d+/),
  13896. d = b[browser.ie ? 'innerText' : 'textContent'].match(/\d+/)
  13897. return c && (c = +c[0]), d && (d = +d[0]), (d || 0) - (c || 0)
  13898. }
  13899. }
  13900. c.setAttribute(
  13901. 'data-sort-type',
  13902. b && 'string' == typeof b && k[b] ? b : ''
  13903. ),
  13904. f && e.splice(0, 1),
  13905. (e = utils.sort(e, function (c, d) {
  13906. var e
  13907. return (e =
  13908. b && 'function' == typeof b
  13909. ? b.call(this, c.cells[a], d.cells[a])
  13910. : b && 'number' == typeof b
  13911. ? 1
  13912. : b && 'string' == typeof b && k[b]
  13913. ? k[b].call(this, c.cells[a], d.cells[a])
  13914. : k.orderbyasc.call(this, c.cells[a], d.cells[a]))
  13915. }))
  13916. for (
  13917. var l = c.ownerDocument.createDocumentFragment(), m = 0, i = e.length;
  13918. m < i;
  13919. m++
  13920. )
  13921. l.appendChild(e[m])
  13922. var n = c.getElementsByTagName('tbody')[0]
  13923. g
  13924. ? n.insertBefore(l, d[g - h.endRowIndex + h.beginRowIndex - 1])
  13925. : n.appendChild(l)
  13926. }),
  13927. (UE.plugins.tablesort = function () {
  13928. var a = this,
  13929. b = UE.UETable,
  13930. c = function (a) {
  13931. return b.getUETable(a)
  13932. },
  13933. d = function (a) {
  13934. return b.getTableItemsByRange(a)
  13935. }
  13936. a.ready(function () {
  13937. utils.cssRule(
  13938. 'tablesort',
  13939. 'table.sortEnabled tr.firstRow th,table.sortEnabled tr.firstRow td{padding-right:20px;background-repeat: no-repeat;background-position: center right; background-image:url(' +
  13940. a.options.themePath +
  13941. a.options.theme +
  13942. '/images/sortable.png);}',
  13943. a.document
  13944. ),
  13945. a.addListener('afterexeccommand', function (a, b) {
  13946. ;('mergeright' != b && 'mergedown' != b && 'mergecells' != b) ||
  13947. this.execCommand('disablesort')
  13948. })
  13949. }),
  13950. (UE.commands.sorttable = {
  13951. queryCommandState: function () {
  13952. var a = this,
  13953. b = d(a)
  13954. if (!b.cell) return -1
  13955. for (
  13956. var c, e = b.table, f = e.getElementsByTagName('td'), g = 0;
  13957. (c = f[g++]);
  13958. )
  13959. if (1 != c.rowSpan || 1 != c.colSpan) return -1
  13960. return 0
  13961. },
  13962. execCommand: function (a, b) {
  13963. var e = this,
  13964. f = e.selection.getRange(),
  13965. g = f.createBookmark(!0),
  13966. h = d(e),
  13967. i = h.cell,
  13968. j = c(h.table),
  13969. k = j.getCellInfo(i)
  13970. j.sortTable(k.cellIndex, b), f.moveToBookmark(g)
  13971. try {
  13972. f.select()
  13973. } catch (l) {}
  13974. }
  13975. }),
  13976. (UE.commands.enablesort = UE.commands.disablesort =
  13977. {
  13978. queryCommandState: function (a) {
  13979. var b = d(this).table
  13980. if (b && 'enablesort' == a)
  13981. for (
  13982. var c = domUtils.getElementsByTagName(b, 'th td'), e = 0;
  13983. e < c.length;
  13984. e++
  13985. )
  13986. if (
  13987. c[e].getAttribute('colspan') > 1 ||
  13988. c[e].getAttribute('rowspan') > 1
  13989. )
  13990. return -1
  13991. return b
  13992. ? ('enablesort' == a) ^
  13993. ('sortEnabled' != b.getAttribute('data-sort'))
  13994. ? -1
  13995. : 0
  13996. : -1
  13997. },
  13998. execCommand: function (a) {
  13999. var b = d(this).table
  14000. b.setAttribute(
  14001. 'data-sort',
  14002. 'enablesort' == a ? 'sortEnabled' : 'sortDisabled'
  14003. ),
  14004. 'enablesort' == a
  14005. ? domUtils.addClass(b, 'sortEnabled')
  14006. : domUtils.removeClasses(b, 'sortEnabled')
  14007. }
  14008. })
  14009. }),
  14010. (UE.plugins.contextmenu = function () {
  14011. var a = this
  14012. if (
  14013. (a.setOpt('enableContextMenu', !0),
  14014. a.getOpt('enableContextMenu') !== !1)
  14015. ) {
  14016. var b,
  14017. c = a.getLang('contextMenu'),
  14018. d = a.options.contextMenu || [
  14019. { label: c.selectall, cmdName: 'selectall' },
  14020. {
  14021. label: c.cleardoc,
  14022. cmdName: 'cleardoc',
  14023. exec: function () {
  14024. confirm(c.confirmclear) && this.execCommand('cleardoc')
  14025. }
  14026. },
  14027. '-',
  14028. { label: c.unlink, cmdName: 'unlink' },
  14029. '-',
  14030. {
  14031. group: c.paragraph,
  14032. icon: 'justifyjustify',
  14033. subMenu: [
  14034. { label: c.justifyleft, cmdName: 'justify', value: 'left' },
  14035. { label: c.justifyright, cmdName: 'justify', value: 'right' },
  14036. { label: c.justifycenter, cmdName: 'justify', value: 'center' },
  14037. {
  14038. label: c.justifyjustify,
  14039. cmdName: 'justify',
  14040. value: 'justify'
  14041. }
  14042. ]
  14043. },
  14044. '-',
  14045. {
  14046. group: c.table,
  14047. icon: 'table',
  14048. subMenu: [
  14049. { label: c.inserttable, cmdName: 'inserttable' },
  14050. { label: c.deletetable, cmdName: 'deletetable' },
  14051. '-',
  14052. { label: c.deleterow, cmdName: 'deleterow' },
  14053. { label: c.deletecol, cmdName: 'deletecol' },
  14054. { label: c.insertcol, cmdName: 'insertcol' },
  14055. { label: c.insertcolnext, cmdName: 'insertcolnext' },
  14056. { label: c.insertrow, cmdName: 'insertrow' },
  14057. { label: c.insertrownext, cmdName: 'insertrownext' },
  14058. '-',
  14059. { label: c.insertcaption, cmdName: 'insertcaption' },
  14060. { label: c.deletecaption, cmdName: 'deletecaption' },
  14061. { label: c.inserttitle, cmdName: 'inserttitle' },
  14062. { label: c.deletetitle, cmdName: 'deletetitle' },
  14063. { label: c.inserttitlecol, cmdName: 'inserttitlecol' },
  14064. { label: c.deletetitlecol, cmdName: 'deletetitlecol' },
  14065. '-',
  14066. { label: c.mergecells, cmdName: 'mergecells' },
  14067. { label: c.mergeright, cmdName: 'mergeright' },
  14068. { label: c.mergedown, cmdName: 'mergedown' },
  14069. '-',
  14070. { label: c.splittorows, cmdName: 'splittorows' },
  14071. { label: c.splittocols, cmdName: 'splittocols' },
  14072. { label: c.splittocells, cmdName: 'splittocells' },
  14073. '-',
  14074. { label: c.averageDiseRow, cmdName: 'averagedistributerow' },
  14075. { label: c.averageDisCol, cmdName: 'averagedistributecol' },
  14076. '-',
  14077. {
  14078. label: c.edittd,
  14079. cmdName: 'edittd',
  14080. exec: function () {
  14081. UE.ui.edittd && new UE.ui.edittd(this),
  14082. this.getDialog('edittd').open()
  14083. }
  14084. },
  14085. {
  14086. label: c.edittable,
  14087. cmdName: 'edittable',
  14088. exec: function () {
  14089. UE.ui.edittable && new UE.ui.edittable(this),
  14090. this.getDialog('edittable').open()
  14091. }
  14092. },
  14093. { label: c.setbordervisible, cmdName: 'setbordervisible' }
  14094. ]
  14095. },
  14096. {
  14097. group: c.tablesort,
  14098. icon: 'tablesort',
  14099. subMenu: [
  14100. { label: c.enablesort, cmdName: 'enablesort' },
  14101. { label: c.disablesort, cmdName: 'disablesort' },
  14102. '-',
  14103. {
  14104. label: c.reversecurrent,
  14105. cmdName: 'sorttable',
  14106. value: 'reversecurrent'
  14107. },
  14108. {
  14109. label: c.orderbyasc,
  14110. cmdName: 'sorttable',
  14111. value: 'orderbyasc'
  14112. },
  14113. {
  14114. label: c.reversebyasc,
  14115. cmdName: 'sorttable',
  14116. value: 'reversebyasc'
  14117. },
  14118. {
  14119. label: c.orderbynum,
  14120. cmdName: 'sorttable',
  14121. value: 'orderbynum'
  14122. },
  14123. {
  14124. label: c.reversebynum,
  14125. cmdName: 'sorttable',
  14126. value: 'reversebynum'
  14127. }
  14128. ]
  14129. },
  14130. {
  14131. group: c.borderbk,
  14132. icon: 'borderBack',
  14133. subMenu: [
  14134. {
  14135. label: c.setcolor,
  14136. cmdName: 'interlacetable',
  14137. exec: function () {
  14138. this.execCommand('interlacetable')
  14139. }
  14140. },
  14141. {
  14142. label: c.unsetcolor,
  14143. cmdName: 'uninterlacetable',
  14144. exec: function () {
  14145. this.execCommand('uninterlacetable')
  14146. }
  14147. },
  14148. {
  14149. label: c.setbackground,
  14150. cmdName: 'settablebackground',
  14151. exec: function () {
  14152. this.execCommand('settablebackground', {
  14153. repeat: !0,
  14154. colorList: ['#bbb', '#ccc']
  14155. })
  14156. }
  14157. },
  14158. {
  14159. label: c.unsetbackground,
  14160. cmdName: 'cleartablebackground',
  14161. exec: function () {
  14162. this.execCommand('cleartablebackground')
  14163. }
  14164. },
  14165. {
  14166. label: c.redandblue,
  14167. cmdName: 'settablebackground',
  14168. exec: function () {
  14169. this.execCommand('settablebackground', {
  14170. repeat: !0,
  14171. colorList: ['red', 'blue']
  14172. })
  14173. }
  14174. },
  14175. {
  14176. label: c.threecolorgradient,
  14177. cmdName: 'settablebackground',
  14178. exec: function () {
  14179. this.execCommand('settablebackground', {
  14180. repeat: !0,
  14181. colorList: ['#aaa', '#bbb', '#ccc']
  14182. })
  14183. }
  14184. }
  14185. ]
  14186. },
  14187. {
  14188. group: c.aligntd,
  14189. icon: 'aligntd',
  14190. subMenu: [
  14191. {
  14192. cmdName: 'cellalignment',
  14193. value: { align: 'left', vAlign: 'top' }
  14194. },
  14195. {
  14196. cmdName: 'cellalignment',
  14197. value: { align: 'center', vAlign: 'top' }
  14198. },
  14199. {
  14200. cmdName: 'cellalignment',
  14201. value: { align: 'right', vAlign: 'top' }
  14202. },
  14203. {
  14204. cmdName: 'cellalignment',
  14205. value: { align: 'left', vAlign: 'middle' }
  14206. },
  14207. {
  14208. cmdName: 'cellalignment',
  14209. value: { align: 'center', vAlign: 'middle' }
  14210. },
  14211. {
  14212. cmdName: 'cellalignment',
  14213. value: { align: 'right', vAlign: 'middle' }
  14214. },
  14215. {
  14216. cmdName: 'cellalignment',
  14217. value: { align: 'left', vAlign: 'bottom' }
  14218. },
  14219. {
  14220. cmdName: 'cellalignment',
  14221. value: { align: 'center', vAlign: 'bottom' }
  14222. },
  14223. {
  14224. cmdName: 'cellalignment',
  14225. value: { align: 'right', vAlign: 'bottom' }
  14226. }
  14227. ]
  14228. },
  14229. {
  14230. group: c.aligntable,
  14231. icon: 'aligntable',
  14232. subMenu: [
  14233. {
  14234. cmdName: 'tablealignment',
  14235. className: 'left',
  14236. label: c.tableleft,
  14237. value: 'left'
  14238. },
  14239. {
  14240. cmdName: 'tablealignment',
  14241. className: 'center',
  14242. label: c.tablecenter,
  14243. value: 'center'
  14244. },
  14245. {
  14246. cmdName: 'tablealignment',
  14247. className: 'right',
  14248. label: c.tableright,
  14249. value: 'right'
  14250. }
  14251. ]
  14252. },
  14253. '-',
  14254. {
  14255. label: c.insertparagraphbefore,
  14256. cmdName: 'insertparagraph',
  14257. value: !0
  14258. },
  14259. { label: c.insertparagraphafter, cmdName: 'insertparagraph' },
  14260. { label: c.copy, cmdName: 'copy' },
  14261. { label: c.paste, cmdName: 'paste' }
  14262. ]
  14263. if (d.length) {
  14264. var e = UE.ui.uiUtils
  14265. a.addListener('contextmenu', function (f, g) {
  14266. var h = e.getViewportOffsetByEvent(g)
  14267. a.fireEvent('beforeselectionchange'), b && b.destroy()
  14268. for (var i, j = 0, k = []; (i = d[j]); j++) {
  14269. var l
  14270. !(function (b) {
  14271. function d() {
  14272. switch (b.icon) {
  14273. case 'table':
  14274. return a.getLang('contextMenu.table')
  14275. case 'justifyjustify':
  14276. return a.getLang('contextMenu.paragraph')
  14277. case 'aligntd':
  14278. return a.getLang('contextMenu.aligntd')
  14279. case 'aligntable':
  14280. return a.getLang('contextMenu.aligntable')
  14281. case 'tablesort':
  14282. return c.tablesort
  14283. case 'borderBack':
  14284. return c.borderbk
  14285. default:
  14286. return ''
  14287. }
  14288. }
  14289. if ('-' == b) (l = k[k.length - 1]) && '-' !== l && k.push('-')
  14290. else if (b.hasOwnProperty('group')) {
  14291. for (var e, f = 0, g = []; (e = b.subMenu[f]); f++)
  14292. !(function (b) {
  14293. '-' == b
  14294. ? (l = g[g.length - 1]) && '-' !== l
  14295. ? g.push('-')
  14296. : g.splice(g.length - 1)
  14297. : (a.commands[b.cmdName] ||
  14298. UE.commands[b.cmdName] ||
  14299. b.query) &&
  14300. (b.query
  14301. ? b.query()
  14302. : a.queryCommandState(b.cmdName)) > -1 &&
  14303. g.push({
  14304. label:
  14305. b.label ||
  14306. a.getLang(
  14307. 'contextMenu.' + b.cmdName + (b.value || '')
  14308. ) ||
  14309. '',
  14310. className:
  14311. 'edui-for-' +
  14312. b.cmdName +
  14313. (b.className
  14314. ? ' edui-for-' + b.cmdName + '-' + b.className
  14315. : ''),
  14316. onclick: b.exec
  14317. ? function () {
  14318. b.exec.call(a)
  14319. }
  14320. : function () {
  14321. a.execCommand(b.cmdName, b.value)
  14322. }
  14323. })
  14324. })(e)
  14325. g.length &&
  14326. k.push({
  14327. label: d(),
  14328. className: 'edui-for-' + b.icon,
  14329. subMenu: { items: g, editor: a }
  14330. })
  14331. } else
  14332. (a.commands[b.cmdName] ||
  14333. UE.commands[b.cmdName] ||
  14334. b.query) &&
  14335. (b.query
  14336. ? b.query.call(a)
  14337. : a.queryCommandState(b.cmdName)) > -1 &&
  14338. k.push({
  14339. label: b.label || a.getLang('contextMenu.' + b.cmdName),
  14340. className:
  14341. 'edui-for-' +
  14342. (b.icon ? b.icon : b.cmdName + (b.value || '')),
  14343. onclick: b.exec
  14344. ? function () {
  14345. b.exec.call(a)
  14346. }
  14347. : function () {
  14348. a.execCommand(b.cmdName, b.value)
  14349. }
  14350. })
  14351. })(i)
  14352. }
  14353. if (
  14354. ('-' == k[k.length - 1] && k.pop(),
  14355. (b = new UE.ui.Menu({
  14356. items: k,
  14357. className: 'edui-contextmenu',
  14358. editor: a
  14359. })),
  14360. b.render(),
  14361. b.showAt(h),
  14362. a.fireEvent('aftershowcontextmenu', b),
  14363. domUtils.preventDefault(g),
  14364. browser.ie)
  14365. ) {
  14366. var m
  14367. try {
  14368. m = a.selection.getNative().createRange()
  14369. } catch (n) {
  14370. return
  14371. }
  14372. if (m.item) {
  14373. var o = new dom.Range(a.document)
  14374. o.selectNode(m.item(0)).select(!0, !0)
  14375. }
  14376. }
  14377. }),
  14378. a.addListener('aftershowcontextmenu', function (b, c) {
  14379. if (a.zeroclipboard) {
  14380. var d = c.items
  14381. for (var e in d)
  14382. 'edui-for-copy' == d[e].className &&
  14383. a.zeroclipboard.clip(d[e].getDom())
  14384. }
  14385. })
  14386. }
  14387. }
  14388. }),
  14389. (UE.plugins.shortcutmenu = function () {
  14390. var a,
  14391. b = this,
  14392. c = b.options.shortcutMenu || []
  14393. c.length &&
  14394. (b.addListener('contextmenu mouseup', function (b, d) {
  14395. var e = this,
  14396. f = {
  14397. type: b,
  14398. target: d.target || d.srcElement,
  14399. screenX: d.screenX,
  14400. screenY: d.screenY,
  14401. clientX: d.clientX,
  14402. clientY: d.clientY
  14403. }
  14404. if (
  14405. (setTimeout(function () {
  14406. var d = e.selection.getRange()
  14407. ;(d.collapsed !== !1 && 'contextmenu' != b) ||
  14408. (a ||
  14409. ((a = new baidu.editor.ui.ShortCutMenu({
  14410. editor: e,
  14411. items: c,
  14412. theme: e.options.theme,
  14413. className: 'edui-shortcutmenu'
  14414. })),
  14415. a.render(),
  14416. e.fireEvent('afterrendershortcutmenu', a)),
  14417. a.show(f, !!UE.plugins.contextmenu))
  14418. }),
  14419. 'contextmenu' == b &&
  14420. (domUtils.preventDefault(d), browser.ie9below))
  14421. ) {
  14422. var g
  14423. try {
  14424. g = e.selection.getNative().createRange()
  14425. } catch (d) {
  14426. return
  14427. }
  14428. if (g.item) {
  14429. var h = new dom.Range(e.document)
  14430. h.selectNode(g.item(0)).select(!0, !0)
  14431. }
  14432. }
  14433. }),
  14434. b.addListener('keydown', function (b) {
  14435. 'keydown' == b && a && !a.isHidden && a.hide()
  14436. }))
  14437. }),
  14438. (UE.plugins.basestyle = function () {
  14439. var a = {
  14440. bold: ['strong', 'b'],
  14441. italic: ['em', 'i'],
  14442. subscript: ['sub'],
  14443. superscript: ['sup']
  14444. },
  14445. b = function (a, b) {
  14446. return domUtils.filterNodeList(a.selection.getStartElementPath(), b)
  14447. },
  14448. c = this
  14449. c.addshortcutkey({
  14450. Bold: 'ctrl+66',
  14451. Italic: 'ctrl+73',
  14452. Underline: 'ctrl+85'
  14453. }),
  14454. c.addInputRule(function (a) {
  14455. utils.each(a.getNodesByTagName('b i'), function (a) {
  14456. switch (a.tagName) {
  14457. case 'b':
  14458. a.tagName = 'strong'
  14459. break
  14460. case 'i':
  14461. a.tagName = 'em'
  14462. }
  14463. })
  14464. })
  14465. for (var d in a)
  14466. !(function (a, d) {
  14467. c.commands[a] = {
  14468. execCommand: function (a) {
  14469. var e = c.selection.getRange(),
  14470. f = b(this, d)
  14471. if (e.collapsed) {
  14472. if (f) {
  14473. var g = c.document.createTextNode('')
  14474. e.insertNode(g).removeInlineStyle(d),
  14475. e.setStartBefore(g),
  14476. domUtils.remove(g)
  14477. } else {
  14478. var h = e.document.createElement(d[0])
  14479. ;('superscript' != a && 'subscript' != a) ||
  14480. ((g = c.document.createTextNode('')),
  14481. e
  14482. .insertNode(g)
  14483. .removeInlineStyle(['sub', 'sup'])
  14484. .setStartBefore(g)
  14485. .collapse(!0)),
  14486. e.insertNode(h).setStart(h, 0)
  14487. }
  14488. e.collapse(!0)
  14489. } else
  14490. ('superscript' != a && 'subscript' != a) ||
  14491. (f && f.tagName.toLowerCase() == a) ||
  14492. e.removeInlineStyle(['sub', 'sup']),
  14493. f ? e.removeInlineStyle(d) : e.applyInlineStyle(d[0])
  14494. e.select()
  14495. },
  14496. queryCommandState: function () {
  14497. return b(this, d) ? 1 : 0
  14498. }
  14499. }
  14500. })(d, a[d])
  14501. }),
  14502. (UE.plugins.elementpath = function () {
  14503. var a,
  14504. b,
  14505. c = this
  14506. c.setOpt('elementPathEnabled', !0),
  14507. c.options.elementPathEnabled &&
  14508. (c.commands.elementpath = {
  14509. execCommand: function (d, e) {
  14510. var f = b[e],
  14511. g = c.selection.getRange()
  14512. ;(a = 1 * e), g.selectNode(f).select()
  14513. },
  14514. queryCommandValue: function () {
  14515. var c = [].concat(this.selection.getStartElementPath()).reverse(),
  14516. d = []
  14517. b = c
  14518. for (var e, f = 0; (e = c[f]); f++)
  14519. if (3 != e.nodeType) {
  14520. var g = e.tagName.toLowerCase()
  14521. if (
  14522. ('img' == g &&
  14523. e.getAttribute('anchorname') &&
  14524. (g = 'anchor'),
  14525. (d[f] = g),
  14526. a == f)
  14527. ) {
  14528. a = -1
  14529. break
  14530. }
  14531. }
  14532. return d
  14533. }
  14534. })
  14535. }),
  14536. (UE.plugins.formatmatch = function () {
  14537. function a(f, g) {
  14538. function h(a) {
  14539. return (
  14540. m && a.selectNode(m),
  14541. a.applyInlineStyle(d[d.length - 1].tagName, null, d)
  14542. )
  14543. }
  14544. if (browser.webkit) var i = 'IMG' == g.target.tagName ? g.target : null
  14545. c.undoManger && c.undoManger.save()
  14546. var j = c.selection.getRange(),
  14547. k = i || j.getClosedNode()
  14548. if (b && k && 'IMG' == k.tagName)
  14549. (k.style.cssText +=
  14550. ';float:' +
  14551. (b.style.cssFloat || b.style.styleFloat || 'none') +
  14552. ';display:' +
  14553. (b.style.display || 'inline')),
  14554. (b = null)
  14555. else if (!b) {
  14556. var l = j.collapsed
  14557. if (l) {
  14558. var m = c.document.createTextNode('match')
  14559. j.insertNode(m).select()
  14560. }
  14561. c.__hasEnterExecCommand = !0
  14562. var n = c.options.removeFormatAttributes
  14563. ;(c.options.removeFormatAttributes = ''),
  14564. c.execCommand('removeformat'),
  14565. (c.options.removeFormatAttributes = n),
  14566. (c.__hasEnterExecCommand = !1),
  14567. (j = c.selection.getRange()),
  14568. d.length && h(j),
  14569. m && j.setStartBefore(m).collapse(!0),
  14570. j.select(),
  14571. m && domUtils.remove(m)
  14572. }
  14573. c.undoManger && c.undoManger.save(),
  14574. c.removeListener('mouseup', a),
  14575. (e = 0)
  14576. }
  14577. var b,
  14578. c = this,
  14579. d = [],
  14580. e = 0
  14581. c.addListener('reset', function () {
  14582. ;(d = []), (e = 0)
  14583. }),
  14584. (c.commands.formatmatch = {
  14585. execCommand: function (f) {
  14586. if (e) return (e = 0), (d = []), void c.removeListener('mouseup', a)
  14587. var g = c.selection.getRange()
  14588. if (((b = g.getClosedNode()), !b || 'IMG' != b.tagName)) {
  14589. g.collapse(!0).shrinkBoundary()
  14590. var h = g.startContainer
  14591. d = domUtils.findParents(h, !0, function (a) {
  14592. return !domUtils.isBlockElm(a) && 1 == a.nodeType
  14593. })
  14594. for (var i, j = 0; (i = d[j]); j++)
  14595. if ('A' == i.tagName) {
  14596. d.splice(j, 1)
  14597. break
  14598. }
  14599. }
  14600. c.addListener('mouseup', a), (e = 1)
  14601. },
  14602. queryCommandState: function () {
  14603. return e
  14604. },
  14605. notNeedUndo: 1
  14606. })
  14607. }),
  14608. UE.plugin.register('searchreplace', function () {
  14609. function a(a, b, c) {
  14610. var d = b.searchStr
  14611. b.dir == -1 &&
  14612. ((a = a.split('').reverse().join('')),
  14613. (d = d.split('').reverse().join('')),
  14614. (c = a.length - c))
  14615. for (
  14616. var e, f = new RegExp(d, 'g' + (b.casesensitive ? '' : 'i'));
  14617. (e = f.exec(a));
  14618. )
  14619. if (e.index >= c)
  14620. return b.dir == -1
  14621. ? a.length - e.index - b.searchStr.length
  14622. : e.index
  14623. return -1
  14624. }
  14625. function b(b, c, d) {
  14626. var e,
  14627. f,
  14628. h = d.all || 1 == d.dir ? 'getNextDomNode' : 'getPreDomNode'
  14629. domUtils.isBody(b) && (b = b.firstChild)
  14630. for (var i = 1; b; ) {
  14631. if (
  14632. ((e =
  14633. 3 == b.nodeType
  14634. ? b.nodeValue
  14635. : b[browser.ie ? 'innerText' : 'textContent']),
  14636. (f = a(e, d, c)),
  14637. (i = 0),
  14638. f != -1)
  14639. )
  14640. return { node: b, index: f }
  14641. for (b = domUtils[h](b); b && g[b.nodeName.toLowerCase()]; )
  14642. b = domUtils[h](b, !0)
  14643. b &&
  14644. (c =
  14645. d.dir == -1
  14646. ? (3 == b.nodeType
  14647. ? b.nodeValue
  14648. : b[browser.ie ? 'innerText' : 'textContent']
  14649. ).length
  14650. : 0)
  14651. }
  14652. }
  14653. function c(a, b, d) {
  14654. for (var e, f = 0, g = a.firstChild, h = 0; g; ) {
  14655. if (3 == g.nodeType) {
  14656. if (
  14657. ((h = g.nodeValue.replace(
  14658. /(^[\t\r\n]+)|([\t\r\n]+$)/,
  14659. ''
  14660. ).length),
  14661. (f += h),
  14662. f >= b)
  14663. )
  14664. return { node: g, index: h - (f - b) }
  14665. } else if (
  14666. !dtd.$empty[g.tagName] &&
  14667. ((h = g[browser.ie ? 'innerText' : 'textContent'].replace(
  14668. /(^[\t\r\n]+)|([\t\r\n]+$)/,
  14669. ''
  14670. ).length),
  14671. (f += h),
  14672. f >= b && (e = c(g, h - (f - b), d)))
  14673. )
  14674. return e
  14675. g = domUtils.getNextDomNode(g)
  14676. }
  14677. }
  14678. function d(a, d) {
  14679. var f,
  14680. g = a.selection.getRange(),
  14681. h = d.searchStr,
  14682. i = a.document.createElement('span')
  14683. if (
  14684. ((i.innerHTML = '$$ueditor_searchreplace_key$$'),
  14685. g.shrinkBoundary(!0),
  14686. !g.collapsed)
  14687. ) {
  14688. g.select()
  14689. var j = a.selection.getText()
  14690. if (
  14691. new RegExp(
  14692. '^' + d.searchStr + '$',
  14693. d.casesensitive ? '' : 'i'
  14694. ).test(j)
  14695. ) {
  14696. if (void 0 != d.replaceStr)
  14697. return e(g, d.replaceStr), g.select(), !0
  14698. g.collapse(d.dir == -1)
  14699. }
  14700. }
  14701. g.insertNode(i), g.enlargeToBlockElm(!0), (f = g.startContainer)
  14702. var k = f[browser.ie ? 'innerText' : 'textContent'].indexOf(
  14703. '$$ueditor_searchreplace_key$$'
  14704. )
  14705. g.setStartBefore(i), domUtils.remove(i)
  14706. var l = b(f, k, d)
  14707. if (l) {
  14708. var m = c(l.node, l.index, h),
  14709. n = c(l.node, l.index + h.length, h)
  14710. return (
  14711. g.setStart(m.node, m.index).setEnd(n.node, n.index),
  14712. void 0 !== d.replaceStr && e(g, d.replaceStr),
  14713. g.select(),
  14714. !0
  14715. )
  14716. }
  14717. g.setCursor()
  14718. }
  14719. function e(a, b) {
  14720. ;(b = f.document.createTextNode(b)), a.deleteContents().insertNode(b)
  14721. }
  14722. var f = this,
  14723. g = { table: 1, tbody: 1, tr: 1, ol: 1, ul: 1 }
  14724. return {
  14725. commands: {
  14726. searchreplace: {
  14727. execCommand: function (a, b) {
  14728. utils.extend(b, { all: !1, casesensitive: !1, dir: 1 }, !0)
  14729. var c = 0
  14730. if (b.all) {
  14731. var e = f.selection.getRange(),
  14732. g = f.body.firstChild
  14733. for (
  14734. g && 1 == g.nodeType
  14735. ? (e.setStart(g, 0), e.shrinkBoundary(!0))
  14736. : 3 == g.nodeType && e.setStartBefore(g),
  14737. e.collapse(!0).select(!0),
  14738. void 0 !== b.replaceStr && f.fireEvent('saveScene');
  14739. d(this, b);
  14740. )
  14741. c++
  14742. c && f.fireEvent('saveScene')
  14743. } else
  14744. void 0 !== b.replaceStr && f.fireEvent('saveScene'),
  14745. d(this, b) && c++,
  14746. c && f.fireEvent('saveScene')
  14747. return c
  14748. },
  14749. notNeedUndo: 1
  14750. }
  14751. }
  14752. }
  14753. }),
  14754. (UE.plugins.customstyle = function () {
  14755. var a = this
  14756. a.setOpt({
  14757. customstyle: [
  14758. {
  14759. tag: 'h1',
  14760. name: 'tc',
  14761. style:
  14762. 'font-size:32px;font-weight:bold;border-bottom:#ccc 2px solid;padding:0 4px 0 0;text-align:center;margin:0 0 20px 0;'
  14763. },
  14764. {
  14765. tag: 'h1',
  14766. name: 'tl',
  14767. style:
  14768. 'font-size:32px;font-weight:bold;border-bottom:#ccc 2px solid;padding:0 4px 0 0;text-align:left;margin:0 0 10px 0;'
  14769. },
  14770. {
  14771. tag: 'span',
  14772. name: 'im',
  14773. style:
  14774. 'font-size:16px;font-style:italic;font-weight:bold;line-height:18px;'
  14775. },
  14776. {
  14777. tag: 'span',
  14778. name: 'hi',
  14779. style:
  14780. 'font-size:16px;font-style:italic;font-weight:bold;color:rgb(51, 153, 204);line-height:18px;'
  14781. }
  14782. ]
  14783. }),
  14784. (a.commands.customstyle = {
  14785. execCommand: function (a, b) {
  14786. var c,
  14787. d,
  14788. e = this,
  14789. f = b.tag,
  14790. g = domUtils.findParent(
  14791. e.selection.getStart(),
  14792. function (a) {
  14793. return a.getAttribute('label')
  14794. },
  14795. !0
  14796. ),
  14797. h = {}
  14798. for (var i in b) void 0 !== b[i] && (h[i] = b[i])
  14799. if ((delete h.tag, g && g.getAttribute('label') == b.label)) {
  14800. if (
  14801. ((c = this.selection.getRange()),
  14802. (d = c.createBookmark()),
  14803. c.collapsed)
  14804. )
  14805. if (dtd.$block[g.tagName]) {
  14806. var j = e.document.createElement('p')
  14807. domUtils.moveChild(g, j),
  14808. g.parentNode.insertBefore(j, g),
  14809. domUtils.remove(g)
  14810. } else domUtils.remove(g, !0)
  14811. else {
  14812. var k = domUtils.getCommonAncestor(d.start, d.end),
  14813. l = domUtils.getElementsByTagName(k, f)
  14814. new RegExp(f, 'i').test(k.tagName) && l.push(k)
  14815. for (var m, n = 0; (m = l[n++]); )
  14816. if (m.getAttribute('label') == b.label) {
  14817. var o = domUtils.getPosition(m, d.start),
  14818. p = domUtils.getPosition(m, d.end)
  14819. if (
  14820. (o & domUtils.POSITION_FOLLOWING ||
  14821. o & domUtils.POSITION_CONTAINS) &&
  14822. (p & domUtils.POSITION_PRECEDING ||
  14823. p & domUtils.POSITION_CONTAINS) &&
  14824. dtd.$block[f]
  14825. ) {
  14826. var j = e.document.createElement('p')
  14827. domUtils.moveChild(m, j), m.parentNode.insertBefore(j, m)
  14828. }
  14829. domUtils.remove(m, !0)
  14830. }
  14831. ;(g = domUtils.findParent(
  14832. k,
  14833. function (a) {
  14834. return a.getAttribute('label') == b.label
  14835. },
  14836. !0
  14837. )),
  14838. g && domUtils.remove(g, !0)
  14839. }
  14840. c.moveToBookmark(d).select()
  14841. } else if (dtd.$block[f]) {
  14842. if (
  14843. (this.execCommand('paragraph', f, h, 'customstyle'),
  14844. (c = e.selection.getRange()),
  14845. !c.collapsed)
  14846. ) {
  14847. c.collapse(),
  14848. (g = domUtils.findParent(
  14849. e.selection.getStart(),
  14850. function (a) {
  14851. return a.getAttribute('label') == b.label
  14852. },
  14853. !0
  14854. ))
  14855. var q = e.document.createElement('p')
  14856. domUtils.insertAfter(g, q),
  14857. domUtils.fillNode(e.document, q),
  14858. c.setStart(q, 0).setCursor()
  14859. }
  14860. } else {
  14861. if (((c = e.selection.getRange()), c.collapsed))
  14862. return (
  14863. (g = e.document.createElement(f)),
  14864. domUtils.setAttributes(g, h),
  14865. void c.insertNode(g).setStart(g, 0).setCursor()
  14866. )
  14867. ;(d = c.createBookmark()),
  14868. c.applyInlineStyle(f, h).moveToBookmark(d).select()
  14869. }
  14870. },
  14871. queryCommandValue: function () {
  14872. var a = domUtils.filterNodeList(
  14873. this.selection.getStartElementPath(),
  14874. function (a) {
  14875. return a.getAttribute('label')
  14876. }
  14877. )
  14878. return a ? a.getAttribute('label') : ''
  14879. }
  14880. }),
  14881. a.addListener('keyup', function (b, c) {
  14882. var d = c.keyCode || c.which
  14883. if (32 == d || 13 == d) {
  14884. var e = a.selection.getRange()
  14885. if (e.collapsed) {
  14886. var f = domUtils.findParent(
  14887. a.selection.getStart(),
  14888. function (a) {
  14889. return a.getAttribute('label')
  14890. },
  14891. !0
  14892. )
  14893. if (f && dtd.$block[f.tagName] && domUtils.isEmptyNode(f)) {
  14894. var g = a.document.createElement('p')
  14895. domUtils.insertAfter(f, g),
  14896. domUtils.fillNode(a.document, g),
  14897. domUtils.remove(f),
  14898. e.setStart(g, 0).setCursor()
  14899. }
  14900. }
  14901. }
  14902. })
  14903. }),
  14904. (UE.plugins.catchremoteimage = function () {
  14905. var me = this,
  14906. ajax = UE.ajax
  14907. me.options.catchRemoteImageEnable !== !1 &&
  14908. (me.setOpt({ catchRemoteImageEnable: !1 }),
  14909. me.addListener('afterpaste', function () {
  14910. me.fireEvent('catchRemoteImage')
  14911. }),
  14912. me.addListener('catchRemoteImage', function () {
  14913. function catchremoteimage(a, b) {
  14914. var c =
  14915. utils.serializeParam(me.queryCommandValue('serverparam')) || '',
  14916. d = utils.formatUrl(
  14917. catcherActionUrl +
  14918. (catcherActionUrl.indexOf('?') == -1 ? '?' : '&') +
  14919. c
  14920. ),
  14921. e = utils.isCrossDomainUrl(d),
  14922. f = {
  14923. method: 'POST',
  14924. dataType: e ? 'jsonp' : '',
  14925. timeout: 6e4,
  14926. onsuccess: b.success,
  14927. onerror: b.error
  14928. }
  14929. ;(f[catcherFieldName] = a), ajax.request(d, f)
  14930. }
  14931. for (
  14932. var catcherLocalDomain = me.getOpt('catcherLocalDomain'),
  14933. catcherActionUrl = me.getActionUrl(
  14934. me.getOpt('catcherActionName')
  14935. ),
  14936. catcherUrlPrefix = me.getOpt('catcherUrlPrefix'),
  14937. catcherFieldName = me.getOpt('catcherFieldName'),
  14938. remoteImages = [],
  14939. imgs = domUtils.getElementsByTagName(me.document, 'img'),
  14940. test = function (a, b) {
  14941. if (a.indexOf(location.host) != -1 || /(^\.)|(^\/)/.test(a))
  14942. return !0
  14943. if (b)
  14944. for (var c, d = 0; (c = b[d++]); )
  14945. if (a.indexOf(c) !== -1) return !0
  14946. return !1
  14947. },
  14948. i = 0,
  14949. ci;
  14950. (ci = imgs[i++]);
  14951. )
  14952. if (!ci.getAttribute('word_img')) {
  14953. var src = ci.getAttribute('_src') || ci.src || ''
  14954. ;/^(https?|ftp):/i.test(src) &&
  14955. !test(src, catcherLocalDomain) &&
  14956. remoteImages.push(src)
  14957. }
  14958. remoteImages.length &&
  14959. catchremoteimage(remoteImages, {
  14960. success: function (r) {
  14961. try {
  14962. var info =
  14963. void 0 !== r.state ? r : eval('(' + r.responseText + ')')
  14964. } catch (e) {
  14965. return
  14966. }
  14967. var i,
  14968. j,
  14969. ci,
  14970. cj,
  14971. oldSrc,
  14972. newSrc,
  14973. list = info.list
  14974. for (i = 0; (ci = imgs[i++]); )
  14975. for (
  14976. oldSrc = ci.getAttribute('_src') || ci.src || '', j = 0;
  14977. (cj = list[j++]);
  14978. )
  14979. if (oldSrc == cj.source && 'SUCCESS' == cj.state) {
  14980. ;(newSrc = catcherUrlPrefix + cj.url),
  14981. domUtils.setAttributes(ci, {
  14982. src: newSrc,
  14983. _src: newSrc
  14984. })
  14985. break
  14986. }
  14987. me.fireEvent('catchremotesuccess')
  14988. },
  14989. error: function () {
  14990. me.fireEvent('catchremoteerror')
  14991. }
  14992. })
  14993. }))
  14994. }),
  14995. UE.plugin.register('snapscreen', function () {
  14996. function getLocation(a) {
  14997. var b,
  14998. c = document.createElement('a'),
  14999. d = utils.serializeParam(me.queryCommandValue('serverparam')) || ''
  15000. return (
  15001. (c.href = a),
  15002. browser.ie && (c.href = c.href),
  15003. (b = c.search),
  15004. d &&
  15005. ((b = b + (b.indexOf('?') == -1 ? '?' : '&') + d),
  15006. (b = b.replace(/[&]+/gi, '&'))),
  15007. {
  15008. port: c.port,
  15009. hostname: c.hostname,
  15010. path: c.pathname + b || +c.hash
  15011. }
  15012. )
  15013. }
  15014. var me = this,
  15015. snapplugin
  15016. return {
  15017. commands: {
  15018. snapscreen: {
  15019. execCommand: function (cmd) {
  15020. function onSuccess(rs) {
  15021. try {
  15022. if (((rs = eval('(' + rs + ')')), 'SUCCESS' == rs.state)) {
  15023. var opt = me.options
  15024. me.execCommand('insertimage', {
  15025. src: opt.snapscreenUrlPrefix + rs.url,
  15026. _src: opt.snapscreenUrlPrefix + rs.url,
  15027. alt: rs.title || '',
  15028. floatStyle: opt.snapscreenImgAlign
  15029. })
  15030. } else alert(rs.state)
  15031. } catch (e) {
  15032. alert(lang.callBackErrorMsg)
  15033. }
  15034. }
  15035. var url,
  15036. local,
  15037. res,
  15038. lang = me.getLang('snapScreen_plugin')
  15039. if (!snapplugin) {
  15040. var container = me.container,
  15041. doc = me.container.ownerDocument || me.container.document
  15042. snapplugin = doc.createElement('object')
  15043. try {
  15044. snapplugin.type = 'application/x-pluginbaidusnap'
  15045. } catch (e) {
  15046. return
  15047. }
  15048. ;(snapplugin.style.cssText =
  15049. 'position:absolute;left:-9999px;width:0;height:0;'),
  15050. snapplugin.setAttribute('width', '0'),
  15051. snapplugin.setAttribute('height', '0'),
  15052. container.appendChild(snapplugin)
  15053. }
  15054. ;(url = me.getActionUrl(me.getOpt('snapscreenActionName'))),
  15055. (local = getLocation(url)),
  15056. setTimeout(function () {
  15057. try {
  15058. res = snapplugin.saveSnapshot(
  15059. local.hostname,
  15060. local.path,
  15061. local.port
  15062. )
  15063. } catch (a) {
  15064. return void me.ui._dialogs.snapscreenDialog.open()
  15065. }
  15066. onSuccess(res)
  15067. }, 50)
  15068. },
  15069. queryCommandState: function () {
  15070. return navigator.userAgent.indexOf('Windows', 0) != -1 ? 0 : -1
  15071. }
  15072. }
  15073. }
  15074. }
  15075. }),
  15076. (UE.commands.insertparagraph = {
  15077. execCommand: function (a, b) {
  15078. for (
  15079. var c, d = this, e = d.selection.getRange(), f = e.startContainer;
  15080. f && !domUtils.isBody(f);
  15081. )
  15082. (c = f), (f = f.parentNode)
  15083. if (c) {
  15084. var g = d.document.createElement('p')
  15085. b
  15086. ? c.parentNode.insertBefore(g, c)
  15087. : c.parentNode.insertBefore(g, c.nextSibling),
  15088. domUtils.fillNode(d.document, g),
  15089. e.setStart(g, 0).setCursor(!1, !0)
  15090. }
  15091. }
  15092. }),
  15093. UE.plugin.register('webapp', function () {
  15094. function a(a, c) {
  15095. return c
  15096. ? '<iframe class="edui-faked-webapp" title="' +
  15097. a.title +
  15098. '" ' +
  15099. (a.align && !a.cssfloat ? 'align="' + a.align + '"' : '') +
  15100. (a.cssfloat ? 'style="float:' + a.cssfloat + '"' : '') +
  15101. 'width="' +
  15102. a.width +
  15103. '" height="' +
  15104. a.height +
  15105. '" scrolling="no" frameborder="0" src="' +
  15106. a.url +
  15107. '" logo_url = "' +
  15108. a.logo +
  15109. '"></iframe>'
  15110. : '<img title="' +
  15111. a.title +
  15112. '" width="' +
  15113. a.width +
  15114. '" height="' +
  15115. a.height +
  15116. '" src="' +
  15117. b.options.UEDITOR_HOME_URL +
  15118. 'themes/default/images/spacer.gif" _logo_url="' +
  15119. a.logo +
  15120. '" style="background:url(' +
  15121. a.logo +
  15122. ') no-repeat center center; border:1px solid gray;" class="edui-faked-webapp" _url="' +
  15123. a.url +
  15124. '" ' +
  15125. (a.align && !a.cssfloat ? 'align="' + a.align + '"' : '') +
  15126. (a.cssfloat ? 'style="float:' + a.cssfloat + '"' : '') +
  15127. '/>'
  15128. }
  15129. var b = this
  15130. return {
  15131. outputRule: function (b) {
  15132. utils.each(b.getNodesByTagName('img'), function (b) {
  15133. var c
  15134. if ('edui-faked-webapp' == b.getAttr('class')) {
  15135. c = a(
  15136. {
  15137. title: b.getAttr('title'),
  15138. width: b.getAttr('width'),
  15139. height: b.getAttr('height'),
  15140. align: b.getAttr('align'),
  15141. cssfloat: b.getStyle('float'),
  15142. url: b.getAttr('_url'),
  15143. logo: b.getAttr('_logo_url')
  15144. },
  15145. !0
  15146. )
  15147. var d = UE.uNode.createElement(c)
  15148. b.parentNode.replaceChild(d, b)
  15149. }
  15150. })
  15151. },
  15152. inputRule: function (b) {
  15153. utils.each(b.getNodesByTagName('iframe'), function (b) {
  15154. if ('edui-faked-webapp' == b.getAttr('class')) {
  15155. var c = UE.uNode.createElement(
  15156. a({
  15157. title: b.getAttr('title'),
  15158. width: b.getAttr('width'),
  15159. height: b.getAttr('height'),
  15160. align: b.getAttr('align'),
  15161. cssfloat: b.getStyle('float'),
  15162. url: b.getAttr('src'),
  15163. logo: b.getAttr('logo_url')
  15164. })
  15165. )
  15166. b.parentNode.replaceChild(c, b)
  15167. }
  15168. })
  15169. },
  15170. commands: {
  15171. webapp: {
  15172. execCommand: function (b, c) {
  15173. var d = this,
  15174. e = a(utils.extend(c, { align: 'none' }), !1)
  15175. d.execCommand('inserthtml', e)
  15176. },
  15177. queryCommandState: function () {
  15178. var a = this,
  15179. b = a.selection.getRange().getClosedNode(),
  15180. c = b && 'edui-faked-webapp' == b.className
  15181. return c ? 1 : 0
  15182. }
  15183. }
  15184. }
  15185. }
  15186. }),
  15187. (UE.plugins.template = function () {
  15188. ;(UE.commands.template = {
  15189. execCommand: function (a, b) {
  15190. b.html && this.execCommand('inserthtml', b.html)
  15191. }
  15192. }),
  15193. this.addListener('click', function (a, b) {
  15194. var c = b.target || b.srcElement,
  15195. d = this.selection.getRange(),
  15196. e = domUtils.findParent(
  15197. c,
  15198. function (a) {
  15199. if (a.className && domUtils.hasClass(a, 'ue_t')) return a
  15200. },
  15201. !0
  15202. )
  15203. e && d.selectNode(e).shrinkBoundary().select()
  15204. }),
  15205. this.addListener('keydown', function (a, b) {
  15206. var c = this.selection.getRange()
  15207. if (
  15208. !c.collapsed &&
  15209. !(b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)
  15210. ) {
  15211. var d = domUtils.findParent(
  15212. c.startContainer,
  15213. function (a) {
  15214. if (a.className && domUtils.hasClass(a, 'ue_t')) return a
  15215. },
  15216. !0
  15217. )
  15218. d && domUtils.removeClasses(d, ['ue_t'])
  15219. }
  15220. })
  15221. }),
  15222. UE.plugin.register('music', function () {
  15223. function a(a, c, d, e, f, g) {
  15224. return g
  15225. ? '<embed type="application/x-shockwave-flash" class="edui-faked-music" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' +
  15226. a +
  15227. '" width="' +
  15228. c +
  15229. '" height="' +
  15230. d +
  15231. '" ' +
  15232. (e && !f ? 'align="' + e + '"' : '') +
  15233. (f ? 'style="float:' + f + '"' : '') +
  15234. ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >'
  15235. : '<img ' +
  15236. (e && !f ? 'align="' + e + '"' : '') +
  15237. (f ? 'style="float:' + f + '"' : '') +
  15238. ' width="' +
  15239. c +
  15240. '" height="' +
  15241. d +
  15242. '" _url="' +
  15243. a +
  15244. '" class="edui-faked-music" src="' +
  15245. b.options.langPath +
  15246. b.options.lang +
  15247. '/images/music.png" />'
  15248. }
  15249. var b = this
  15250. return {
  15251. outputRule: function (b) {
  15252. utils.each(b.getNodesByTagName('img'), function (b) {
  15253. var c
  15254. if ('edui-faked-music' == b.getAttr('class')) {
  15255. var d = b.getStyle('float'),
  15256. e = b.getAttr('align')
  15257. c = a(
  15258. b.getAttr('_url'),
  15259. b.getAttr('width'),
  15260. b.getAttr('height'),
  15261. e,
  15262. d,
  15263. !0
  15264. )
  15265. var f = UE.uNode.createElement(c)
  15266. b.parentNode.replaceChild(f, b)
  15267. }
  15268. })
  15269. },
  15270. inputRule: function (b) {
  15271. utils.each(b.getNodesByTagName('embed'), function (b) {
  15272. if ('edui-faked-music' == b.getAttr('class')) {
  15273. var c = b.getStyle('float'),
  15274. d = b.getAttr('align')
  15275. html = a(
  15276. b.getAttr('src'),
  15277. b.getAttr('width'),
  15278. b.getAttr('height'),
  15279. d,
  15280. c,
  15281. !1
  15282. )
  15283. var e = UE.uNode.createElement(html)
  15284. b.parentNode.replaceChild(e, b)
  15285. }
  15286. })
  15287. },
  15288. commands: {
  15289. music: {
  15290. execCommand: function (b, c) {
  15291. var d = this,
  15292. e = a(c.url, c.width || 400, c.height || 95, 'none', !1)
  15293. d.execCommand('inserthtml', e)
  15294. },
  15295. queryCommandState: function () {
  15296. var a = this,
  15297. b = a.selection.getRange().getClosedNode(),
  15298. c = b && 'edui-faked-music' == b.className
  15299. return c ? 1 : 0
  15300. }
  15301. }
  15302. }
  15303. }
  15304. }),
  15305. UE.plugin.register('autoupload', function () {
  15306. function a(a, b) {
  15307. var c,
  15308. d,
  15309. e,
  15310. f,
  15311. g,
  15312. h,
  15313. i,
  15314. j,
  15315. k = b,
  15316. l = /image\/\w+/i.test(a.type) ? 'image' : 'file',
  15317. m = 'loading_' + (+new Date()).toString(36)
  15318. if (
  15319. ((c = k.getOpt(l + 'FieldName')),
  15320. (d = k.getOpt(l + 'UrlPrefix')),
  15321. (e = k.getOpt(l + 'MaxSize')),
  15322. (f = k.getOpt(l + 'AllowFiles')),
  15323. (g = k.getActionUrl(k.getOpt(l + 'ActionName'))),
  15324. (i = function (a) {
  15325. var b = k.document.getElementById(m)
  15326. b && domUtils.remove(b),
  15327. k.fireEvent('showmessage', {
  15328. id: m,
  15329. content: a,
  15330. type: 'error',
  15331. timeout: 4e3
  15332. })
  15333. }),
  15334. 'image' == l
  15335. ? ((h =
  15336. '<img class="loadingclass" id="' +
  15337. m +
  15338. '" src="' +
  15339. k.options.themePath +
  15340. k.options.theme +
  15341. '/images/spacer.gif" title="' +
  15342. (k.getLang('autoupload.loading') || '') +
  15343. '" >'),
  15344. (j = function (a) {
  15345. var b = d + a.url,
  15346. c = k.document.getElementById(m)
  15347. c &&
  15348. (c.setAttribute('src', b),
  15349. c.setAttribute('_src', b),
  15350. c.setAttribute('title', a.title || ''),
  15351. c.setAttribute('alt', a.original || ''),
  15352. c.removeAttribute('id'),
  15353. domUtils.removeClasses(c, 'loadingclass'))
  15354. }))
  15355. : ((h =
  15356. '<p><img class="loadingclass" id="' +
  15357. m +
  15358. '" src="' +
  15359. k.options.themePath +
  15360. k.options.theme +
  15361. '/images/spacer.gif" title="' +
  15362. (k.getLang('autoupload.loading') || '') +
  15363. '" ></p>'),
  15364. (j = function (a) {
  15365. var b = d + a.url,
  15366. c = k.document.getElementById(m),
  15367. e = k.selection.getRange(),
  15368. f = e.createBookmark()
  15369. e.selectNode(c).select(),
  15370. k.execCommand('insertfile', { url: b }),
  15371. e.moveToBookmark(f).select()
  15372. })),
  15373. k.execCommand('inserthtml', h),
  15374. !k.getOpt(l + 'ActionName'))
  15375. )
  15376. return void i(k.getLang('autoupload.errorLoadConfig'))
  15377. if (a.size > e) return void i(k.getLang('autoupload.exceedSizeError'))
  15378. var n = a.name ? a.name.substr(a.name.lastIndexOf('.')) : ''
  15379. if (
  15380. (n && 'image' != l) ||
  15381. (f && (f.join('') + '.').indexOf(n.toLowerCase() + '.') == -1)
  15382. )
  15383. return void i(k.getLang('autoupload.exceedTypeError'))
  15384. var o = new XMLHttpRequest(),
  15385. p = new FormData(),
  15386. q = utils.serializeParam(k.queryCommandValue('serverparam')) || '',
  15387. r = utils.formatUrl(g + (g.indexOf('?') == -1 ? '?' : '&') + q)
  15388. p.append(c, a, a.name || 'blob.' + a.type.substr('image/'.length)),
  15389. p.append('type', 'ajax'),
  15390. o.open('post', r, !0),
  15391. o.setRequestHeader('X-Requested-With', 'XMLHttpRequest'),
  15392. o.addEventListener('load', function (a) {
  15393. try {
  15394. var b = new Function('return ' + utils.trim(a.target.response))()
  15395. 'SUCCESS' == b.state && b.url ? j(b) : i(b.state)
  15396. } catch (c) {
  15397. i(k.getLang('autoupload.loadError'))
  15398. }
  15399. }),
  15400. o.send(p)
  15401. }
  15402. function b(a) {
  15403. return a.clipboardData &&
  15404. a.clipboardData.items &&
  15405. 1 == a.clipboardData.items.length &&
  15406. /^image\//.test(a.clipboardData.items[0].type)
  15407. ? a.clipboardData.items
  15408. : null
  15409. }
  15410. function c(a) {
  15411. return a.dataTransfer && a.dataTransfer.files
  15412. ? a.dataTransfer.files
  15413. : null
  15414. }
  15415. return {
  15416. outputRule: function (a) {
  15417. utils.each(a.getNodesByTagName('img'), function (a) {
  15418. ;/\b(loaderrorclass)|(bloaderrorclass)\b/.test(
  15419. a.getAttr('class')
  15420. ) && a.parentNode.removeChild(a)
  15421. }),
  15422. utils.each(a.getNodesByTagName('p'), function (a) {
  15423. ;/\bloadpara\b/.test(a.getAttr('class')) &&
  15424. a.parentNode.removeChild(a)
  15425. })
  15426. },
  15427. bindEvents: {
  15428. ready: function (d) {
  15429. var e = this
  15430. window.FormData &&
  15431. window.FileReader &&
  15432. (domUtils.on(e.body, 'paste drop', function (d) {
  15433. var f,
  15434. g = !1
  15435. if ((f = 'paste' == d.type ? b(d) : c(d))) {
  15436. for (var h, i = f.length; i--; )
  15437. (h = f[i]),
  15438. h.getAsFile && (h = h.getAsFile()),
  15439. h && h.size > 0 && (a(h, e), (g = !0))
  15440. g && d.preventDefault()
  15441. }
  15442. }),
  15443. domUtils.on(e.body, 'dragover', function (a) {
  15444. 'Files' == a.dataTransfer.types[0] && a.preventDefault()
  15445. }),
  15446. utils.cssRule(
  15447. 'loading',
  15448. ".loadingclass{display:inline-block;cursor:default;background: url('" +
  15449. this.options.themePath +
  15450. this.options.theme +
  15451. "/images/loading.gif') no-repeat center center transparent;border:1px solid #cccccc;margin-left:1px;height: 22px;width: 22px;}\n.loaderrorclass{display:inline-block;cursor:default;background: url('" +
  15452. this.options.themePath +
  15453. this.options.theme +
  15454. "/images/loaderror.png') no-repeat center center transparent;border:1px solid #cccccc;margin-right:1px;height: 22px;width: 22px;}",
  15455. this.document
  15456. ))
  15457. }
  15458. }
  15459. }
  15460. }),
  15461. UE.plugin.register('autosave', function () {
  15462. function a(a) {
  15463. var f
  15464. if (!(new Date() - c < d)) {
  15465. if (!a.hasContents()) return void (e && b.removePreferences(e))
  15466. ;(c = new Date()),
  15467. (a._saveFlag = null),
  15468. (f = b.body.innerHTML),
  15469. a.fireEvent('beforeautosave', { content: f }) !== !1 &&
  15470. (b.setPreferences(e, f),
  15471. a.fireEvent('afterautosave', { content: f }))
  15472. }
  15473. }
  15474. var b = this,
  15475. c = new Date(),
  15476. d = 20,
  15477. e = null
  15478. return {
  15479. defaultOptions: { saveInterval: 500, enableAutoSave: !0 },
  15480. bindEvents: {
  15481. ready: function () {
  15482. var a = '-drafts-data',
  15483. c = null
  15484. ;(c = b.key
  15485. ? b.key + a
  15486. : (b.container.parentNode.id || 'ue-common') + a),
  15487. (e =
  15488. (location.protocol + location.host + location.pathname).replace(
  15489. /[.:\/]/g,
  15490. '_'
  15491. ) + c)
  15492. },
  15493. contentchange: function () {
  15494. b.getOpt('enableAutoSave') &&
  15495. e &&
  15496. (b._saveFlag && window.clearTimeout(b._saveFlag),
  15497. b.options.saveInterval > 0
  15498. ? (b._saveFlag = window.setTimeout(function () {
  15499. a(b)
  15500. }, b.options.saveInterval))
  15501. : a(b))
  15502. }
  15503. },
  15504. commands: {
  15505. clearlocaldata: {
  15506. execCommand: function (a, c) {
  15507. e && b.getPreferences(e) && b.removePreferences(e)
  15508. },
  15509. notNeedUndo: !0,
  15510. ignoreContentChange: !0
  15511. },
  15512. getlocaldata: {
  15513. execCommand: function (a, c) {
  15514. return e ? b.getPreferences(e) || '' : ''
  15515. },
  15516. notNeedUndo: !0,
  15517. ignoreContentChange: !0
  15518. },
  15519. drafts: {
  15520. execCommand: function (a, c) {
  15521. e &&
  15522. ((b.body.innerHTML =
  15523. b.getPreferences(e) || '<p>' + domUtils.fillHtml + '</p>'),
  15524. b.focus(!0))
  15525. },
  15526. queryCommandState: function () {
  15527. return e ? (null === b.getPreferences(e) ? -1 : 0) : -1
  15528. },
  15529. notNeedUndo: !0,
  15530. ignoreContentChange: !0
  15531. }
  15532. }
  15533. }
  15534. }),
  15535. UE.plugin.register('charts', function () {
  15536. function a(a) {
  15537. var b = null,
  15538. c = 0
  15539. if (a.rows.length < 2) return !1
  15540. if (a.rows[0].cells.length < 2) return !1
  15541. ;(b = a.rows[0].cells), (c = b.length)
  15542. for (var d, e = 0; (d = b[e]); e++)
  15543. if ('th' !== d.tagName.toLowerCase()) return !1
  15544. for (var f, e = 1; (f = a.rows[e]); e++) {
  15545. if (f.cells.length != c) return !1
  15546. if ('th' !== f.cells[0].tagName.toLowerCase()) return !1
  15547. for (var d, g = 1; (d = f.cells[g]); g++) {
  15548. var h = utils.trim(d.innerText || d.textContent || '')
  15549. if (
  15550. ((h = h
  15551. .replace(new RegExp(UE.dom.domUtils.fillChar, 'g'), '')
  15552. .replace(/^\s+|\s+$/g, '')),
  15553. !/^\d*\.?\d+$/.test(h))
  15554. )
  15555. return !1
  15556. }
  15557. }
  15558. return !0
  15559. }
  15560. var b = this
  15561. return {
  15562. bindEvents: { chartserror: function () {} },
  15563. commands: {
  15564. charts: {
  15565. execCommand: function (c, d) {
  15566. var e = domUtils.findParentByTagName(
  15567. this.selection.getRange().startContainer,
  15568. 'table',
  15569. !0
  15570. ),
  15571. f = [],
  15572. g = {}
  15573. if (!e) return !1
  15574. if (!a(e)) return b.fireEvent('chartserror'), !1
  15575. ;(g.title = d.title || ''),
  15576. (g.subTitle = d.subTitle || ''),
  15577. (g.xTitle = d.xTitle || ''),
  15578. (g.yTitle = d.yTitle || ''),
  15579. (g.suffix = d.suffix || ''),
  15580. (g.tip = d.tip || ''),
  15581. (g.dataFormat = d.tableDataFormat || ''),
  15582. (g.chartType = d.chartType || 0)
  15583. for (var h in g) g.hasOwnProperty(h) && f.push(h + ':' + g[h])
  15584. e.setAttribute('data-chart', f.join(';')),
  15585. domUtils.addClass(e, 'edui-charts-table')
  15586. },
  15587. queryCommandState: function (b, c) {
  15588. var d = domUtils.findParentByTagName(
  15589. this.selection.getRange().startContainer,
  15590. 'table',
  15591. !0
  15592. )
  15593. return d && a(d) ? 0 : -1
  15594. }
  15595. }
  15596. },
  15597. inputRule: function (a) {
  15598. utils.each(a.getNodesByTagName('table'), function (a) {
  15599. void 0 !== a.getAttr('data-chart') && a.setAttr('style')
  15600. })
  15601. },
  15602. outputRule: function (a) {
  15603. utils.each(a.getNodesByTagName('table'), function (a) {
  15604. void 0 !== a.getAttr('data-chart') &&
  15605. a.setAttr('style', 'display: none;')
  15606. })
  15607. }
  15608. }
  15609. }),
  15610. UE.plugin.register('section', function () {
  15611. function a(a) {
  15612. ;(this.tag = ''),
  15613. (this.level = -1),
  15614. (this.dom = null),
  15615. (this.nextSection = null),
  15616. (this.previousSection = null),
  15617. (this.parentSection = null),
  15618. (this.startAddress = []),
  15619. (this.endAddress = []),
  15620. (this.children = [])
  15621. }
  15622. function b(b) {
  15623. var c = new a()
  15624. return utils.extend(c, b)
  15625. }
  15626. function c(a, b) {
  15627. for (var c = b, d = 0; d < a.length; d++) {
  15628. if (!c.childNodes) return null
  15629. c = c.childNodes[a[d]]
  15630. }
  15631. return c
  15632. }
  15633. var d = this
  15634. return {
  15635. bindMultiEvents: {
  15636. type: 'aftersetcontent afterscencerestore',
  15637. handler: function () {
  15638. d.fireEvent('updateSections')
  15639. }
  15640. },
  15641. bindEvents: {
  15642. ready: function () {
  15643. d.fireEvent('updateSections'),
  15644. domUtils.on(d.body, 'drop paste', function () {
  15645. d.fireEvent('updateSections')
  15646. })
  15647. },
  15648. afterexeccommand: function (a, b) {
  15649. 'paragraph' == b && d.fireEvent('updateSections')
  15650. },
  15651. keyup: function (a, b) {
  15652. var c = this,
  15653. d = c.selection.getRange()
  15654. if (1 != d.collapsed) c.fireEvent('updateSections')
  15655. else {
  15656. var e = b.keyCode || b.which
  15657. ;(13 != e && 8 != e && 46 != e) || c.fireEvent('updateSections')
  15658. }
  15659. }
  15660. },
  15661. commands: {
  15662. getsections: {
  15663. execCommand: function (a, c) {
  15664. function d(a) {
  15665. for (var b = 0; b < f.length; b++) if (f[b](a)) return b
  15666. return -1
  15667. }
  15668. function e(a, c) {
  15669. for (
  15670. var f, g, i, k = null, l = a.childNodes, m = 0, n = l.length;
  15671. m < n;
  15672. m++
  15673. )
  15674. if (((i = l[m]), (f = d(i)), f >= 0)) {
  15675. var o = h.selection
  15676. .getRange()
  15677. .selectNode(i)
  15678. .createAddress(!0).startAddress,
  15679. p = b({
  15680. tag: i.tagName,
  15681. title: i.innerText || i.textContent || '',
  15682. level: f,
  15683. dom: i,
  15684. startAddress: utils.clone(o, []),
  15685. endAddress: utils.clone(o, []),
  15686. children: []
  15687. })
  15688. for (
  15689. j.nextSection = p, p.previousSection = j, g = j;
  15690. f <= g.level;
  15691. )
  15692. g = g.parentSection
  15693. ;(p.parentSection = g), g.children.push(p), (k = j = p)
  15694. } else
  15695. 1 === i.nodeType && e(i, c),
  15696. k && k.endAddress[k.endAddress.length - 1]++
  15697. }
  15698. for (
  15699. var f = c || ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], g = 0;
  15700. g < f.length;
  15701. g++
  15702. )
  15703. 'string' == typeof f[g]
  15704. ? (f[g] = (function (a) {
  15705. return function (b) {
  15706. return b.tagName == a.toUpperCase()
  15707. }
  15708. })(f[g]))
  15709. : 'function' != typeof f[g] &&
  15710. (f[g] = function (a) {
  15711. return null
  15712. })
  15713. var h = this,
  15714. i = b({ level: -1, title: 'root' }),
  15715. j = i
  15716. return e(h.body, i), i
  15717. },
  15718. notNeedUndo: !0
  15719. },
  15720. movesection: {
  15721. execCommand: function (a, b, d, e) {
  15722. function f(a, b, c) {
  15723. for (
  15724. var d = !1, e = !1, f = 0;
  15725. f < a.length && !(f >= c.length);
  15726. f++
  15727. ) {
  15728. if (c[f] > a[f]) {
  15729. d = !0
  15730. break
  15731. }
  15732. if (c[f] < a[f]) break
  15733. }
  15734. for (var f = 0; f < b.length && !(f >= c.length); f++) {
  15735. if (c[f] < a[f]) {
  15736. e = !0
  15737. break
  15738. }
  15739. if (c[f] > a[f]) break
  15740. }
  15741. return d && e
  15742. }
  15743. var g,
  15744. h,
  15745. i = this
  15746. if (
  15747. b &&
  15748. d &&
  15749. d.level != -1 &&
  15750. ((g = e ? d.endAddress : d.startAddress),
  15751. (h = c(g, i.body)),
  15752. g && h && !f(b.startAddress, b.endAddress, g))
  15753. ) {
  15754. var j,
  15755. k,
  15756. l = c(b.startAddress, i.body),
  15757. m = c(b.endAddress, i.body)
  15758. if (e)
  15759. for (
  15760. j = m;
  15761. j &&
  15762. !(
  15763. domUtils.getPosition(l, j) & domUtils.POSITION_FOLLOWING
  15764. ) &&
  15765. ((k = j.previousSibling),
  15766. domUtils.insertAfter(h, j),
  15767. j != l);
  15768. )
  15769. j = k
  15770. else
  15771. for (
  15772. j = l;
  15773. j &&
  15774. !(
  15775. domUtils.getPosition(j, m) & domUtils.POSITION_FOLLOWING
  15776. ) &&
  15777. ((k = j.nextSibling),
  15778. h.parentNode.insertBefore(j, h),
  15779. j != m);
  15780. )
  15781. j = k
  15782. i.fireEvent('updateSections')
  15783. }
  15784. }
  15785. },
  15786. deletesection: {
  15787. execCommand: function (a, b, c) {
  15788. function d(a) {
  15789. for (var b = e.body, c = 0; c < a.length; c++) {
  15790. if (!b.childNodes) return null
  15791. b = b.childNodes[a[c]]
  15792. }
  15793. return b
  15794. }
  15795. var e = this
  15796. if (b) {
  15797. var f,
  15798. g = d(b.startAddress),
  15799. h = d(b.endAddress),
  15800. i = g
  15801. if (c) domUtils.remove(i)
  15802. else
  15803. for (
  15804. ;
  15805. i &&
  15806. domUtils.inDoc(h, e.document) &&
  15807. !(domUtils.getPosition(i, h) & domUtils.POSITION_FOLLOWING);
  15808. )
  15809. (f = i.nextSibling), domUtils.remove(i), (i = f)
  15810. e.fireEvent('updateSections')
  15811. }
  15812. }
  15813. },
  15814. selectsection: {
  15815. execCommand: function (a, b) {
  15816. if (!b && !b.dom) return !1
  15817. var c = this,
  15818. d = c.selection.getRange(),
  15819. e = {
  15820. startAddress: utils.clone(b.startAddress, []),
  15821. endAddress: utils.clone(b.endAddress, [])
  15822. }
  15823. return (
  15824. e.endAddress[e.endAddress.length - 1]++,
  15825. d.moveToAddress(e).select().scrollToView(),
  15826. !0
  15827. )
  15828. },
  15829. notNeedUndo: !0
  15830. },
  15831. scrolltosection: {
  15832. execCommand: function (a, b) {
  15833. if (!b && !b.dom) return !1
  15834. var c = this,
  15835. d = c.selection.getRange(),
  15836. e = { startAddress: b.startAddress, endAddress: b.endAddress }
  15837. return (
  15838. e.endAddress[e.endAddress.length - 1]++,
  15839. d.moveToAddress(e).scrollToView(),
  15840. !0
  15841. )
  15842. },
  15843. notNeedUndo: !0
  15844. }
  15845. }
  15846. }
  15847. }),
  15848. UE.plugin.register('simpleupload', function () {
  15849. function a() {
  15850. var a = b.offsetWidth || 20,
  15851. e = b.offsetHeight || 20,
  15852. f =
  15853. 'display:block;width:' +
  15854. a +
  15855. 'px;height:' +
  15856. e +
  15857. 'px;overflow:hidden;border:0;margin:0;padding:0;position:absolute;top:0;left:0;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;cursor:pointer;',
  15858. g = document.createElement('form'),
  15859. h = document.createElement('input')
  15860. ;(g.id = 'edui_form_' + d),
  15861. (g.enctype = 'multipart/form-data'),
  15862. (g.style = f),
  15863. (h.id = 'edui_input_' + d),
  15864. (h.type = 'file'),
  15865. (h.accept = 'image/*'),
  15866. (h.name = c.options.imageFieldName),
  15867. (h.style = f),
  15868. g.appendChild(h),
  15869. b.appendChild(g),
  15870. h.addEventListener('change', function (a) {
  15871. function b(a) {
  15872. if (d) {
  15873. var b = c.document.getElementById(d)
  15874. b && domUtils.remove(b),
  15875. c.fireEvent('showmessage', {
  15876. id: d,
  15877. content: a,
  15878. type: 'error',
  15879. timeout: 4e3
  15880. })
  15881. }
  15882. }
  15883. if (h.value) {
  15884. var d = 'loading_' + (+new Date()).toString(36),
  15885. e = c.getActionUrl(c.getOpt('imageActionName')),
  15886. f =
  15887. utils.serializeParam(c.queryCommandValue('serverparam')) ||
  15888. '',
  15889. i = utils.formatUrl(e + (e.indexOf('?') == -1 ? '?' : '&') + f),
  15890. j = c.getOpt('imageAllowFiles')
  15891. if (
  15892. (c.focus(),
  15893. c.execCommand(
  15894. 'inserthtml',
  15895. '<img class="loadingclass" id="' +
  15896. d +
  15897. '" src="' +
  15898. c.options.themePath +
  15899. c.options.theme +
  15900. '/images/spacer.gif" title="' +
  15901. (c.getLang('simpleupload.loading') || '') +
  15902. '" >'
  15903. ),
  15904. !c.getOpt('imageActionName'))
  15905. )
  15906. return void b(c.getLang('autoupload.errorLoadConfig'))
  15907. var k = h.value,
  15908. l = k ? k.substr(k.lastIndexOf('.')) : ''
  15909. if (
  15910. !l ||
  15911. (j && (j.join('') + '.').indexOf(l.toLowerCase() + '.') == -1)
  15912. )
  15913. return void b(c.getLang('simpleupload.exceedTypeError'))
  15914. var m = new XMLHttpRequest()
  15915. if (
  15916. (m.open('post', i, !0),
  15917. c.options.headers &&
  15918. '[object Object]' ===
  15919. Object.prototype.toString.apply(c.options.headers))
  15920. )
  15921. for (var n in c.options.headers)
  15922. m.setRequestHeader(n, c.options.headers[n])
  15923. ;(m.onload = function () {
  15924. if ((m.status >= 200 && m.status < 300) || 304 == m.status) {
  15925. var a = JSON.parse(m.responseText),
  15926. e = c.options.imageUrlPrefix + a.url
  15927. 'SUCCESS' == a.state && a.url
  15928. ? ((loader = c.document.getElementById(d)),
  15929. loader.setAttribute('src', e),
  15930. loader.setAttribute('_src', e),
  15931. loader.setAttribute('title', a.title || ''),
  15932. loader.setAttribute('alt', a.original || ''),
  15933. loader.removeAttribute('id'),
  15934. domUtils.removeClasses(loader, 'loadingclass'),
  15935. c.fireEvent('contentchange'))
  15936. : b(a.state)
  15937. } else b(c.getLang('simpleupload.loadError'))
  15938. }),
  15939. (m.onerror = function () {
  15940. b(c.getLang('simpleupload.loadError'))
  15941. }),
  15942. m.send(new FormData(g)),
  15943. g.reset()
  15944. }
  15945. })
  15946. }
  15947. var b,
  15948. c = this,
  15949. d = (+new Date()).toString(36)
  15950. return {
  15951. bindEvents: {
  15952. ready: function () {
  15953. utils.cssRule(
  15954. 'loading',
  15955. ".loadingclass{display:inline-block;cursor:default;background: url('" +
  15956. this.options.themePath +
  15957. this.options.theme +
  15958. "/images/loading.gif') no-repeat center center transparent;border:1px solid #cccccc;margin-right:1px;height: 22px;width: 22px;}\n.loaderrorclass{display:inline-block;cursor:default;background: url('" +
  15959. this.options.themePath +
  15960. this.options.theme +
  15961. "/images/loaderror.png') no-repeat center center transparent;border:1px solid #cccccc;margin-right:1px;height: 22px;width: 22px;}",
  15962. this.document
  15963. )
  15964. },
  15965. simpleuploadbtnready: function (d, e) {
  15966. ;(b = e), c.afterConfigReady(a)
  15967. }
  15968. },
  15969. outputRule: function (a) {
  15970. utils.each(a.getNodesByTagName('img'), function (a) {
  15971. ;/\b(loaderrorclass)|(bloaderrorclass)\b/.test(
  15972. a.getAttr('class')
  15973. ) && a.parentNode.removeChild(a)
  15974. })
  15975. }
  15976. }
  15977. }),
  15978. UE.plugin.register('serverparam', function () {
  15979. var a = {}
  15980. return {
  15981. commands: {
  15982. serverparam: {
  15983. execCommand: function (b, c, d) {
  15984. void 0 === c || null === c
  15985. ? (a = {})
  15986. : utils.isString(c)
  15987. ? void 0 === d || null === d
  15988. ? delete a[c]
  15989. : (a[c] = d)
  15990. : utils.isObject(c)
  15991. ? utils.extend(a, c, !0)
  15992. : utils.isFunction(c) && utils.extend(a, c(), !0)
  15993. },
  15994. queryCommandValue: function () {
  15995. return a || {}
  15996. }
  15997. }
  15998. }
  15999. }
  16000. }),
  16001. UE.plugin.register('insertfile', function () {
  16002. function a(a) {
  16003. var b = a.substr(a.lastIndexOf('.') + 1).toLowerCase(),
  16004. c = {
  16005. rar: 'icon_rar.gif',
  16006. zip: 'icon_rar.gif',
  16007. tar: 'icon_rar.gif',
  16008. gz: 'icon_rar.gif',
  16009. bz2: 'icon_rar.gif',
  16010. doc: 'icon_doc.gif',
  16011. docx: 'icon_doc.gif',
  16012. pdf: 'icon_pdf.gif',
  16013. mp3: 'icon_mp3.gif',
  16014. xls: 'icon_xls.gif',
  16015. chm: 'icon_chm.gif',
  16016. ppt: 'icon_ppt.gif',
  16017. pptx: 'icon_ppt.gif',
  16018. avi: 'icon_mv.gif',
  16019. rmvb: 'icon_mv.gif',
  16020. wmv: 'icon_mv.gif',
  16021. flv: 'icon_mv.gif',
  16022. swf: 'icon_mv.gif',
  16023. rm: 'icon_mv.gif',
  16024. exe: 'icon_exe.gif',
  16025. psd: 'icon_psd.gif',
  16026. txt: 'icon_txt.gif',
  16027. jpg: 'icon_jpg.gif',
  16028. png: 'icon_jpg.gif',
  16029. jpeg: 'icon_jpg.gif',
  16030. gif: 'icon_jpg.gif',
  16031. ico: 'icon_jpg.gif',
  16032. bmp: 'icon_jpg.gif'
  16033. }
  16034. return c[b] ? c[b] : c.txt
  16035. }
  16036. var b = this
  16037. return {
  16038. commands: {
  16039. insertfile: {
  16040. execCommand: function (c, d) {
  16041. d = utils.isArray(d) ? d : [d]
  16042. var e,
  16043. f,
  16044. g,
  16045. h,
  16046. i = '',
  16047. j = b.getOpt('UEDITOR_HOME_URL'),
  16048. k =
  16049. j +
  16050. ('/' == j.substr(j.length - 1) ? '' : '/') +
  16051. 'dialogs/attachment/fileTypeImages/'
  16052. for (e = 0; e < d.length; e++)
  16053. (f = d[e]),
  16054. (g = k + a(f.url)),
  16055. (h = f.title || f.url.substr(f.url.lastIndexOf('/') + 1)),
  16056. (i +=
  16057. '<p style="line-height: 16px;"><img style="vertical-align: middle; margin-right: 2px;" src="' +
  16058. g +
  16059. '" _src="' +
  16060. g +
  16061. '" /><a style="font-size:12px; color:#0066cc;" href="' +
  16062. f.url +
  16063. '" title="' +
  16064. h +
  16065. '">' +
  16066. h +
  16067. '</a></p>')
  16068. b.execCommand('insertHtml', i)
  16069. }
  16070. }
  16071. }
  16072. }
  16073. }),
  16074. (UE.plugins.xssFilter = function () {
  16075. function a(a) {
  16076. var b = a.tagName,
  16077. d = a.attrs
  16078. return c.hasOwnProperty(b)
  16079. ? void UE.utils.each(d, function (d, e) {
  16080. c[b].indexOf(e) === -1 && a.setAttr(e)
  16081. })
  16082. : (a.parentNode.removeChild(a), !1)
  16083. }
  16084. var b = UEDITOR_CONFIG,
  16085. c = b.whitList
  16086. c &&
  16087. b.xssFilterRules &&
  16088. (this.options.filterRules = (function () {
  16089. var b = {}
  16090. return (
  16091. UE.utils.each(c, function (c, d) {
  16092. b[d] = function (b) {
  16093. return a(b)
  16094. }
  16095. }),
  16096. b
  16097. )
  16098. })())
  16099. var d = []
  16100. UE.utils.each(c, function (a, b) {
  16101. d.push(b)
  16102. }),
  16103. c &&
  16104. b.inputXssFilter &&
  16105. this.addInputRule(function (b) {
  16106. b.traversal(function (b) {
  16107. return 'element' === b.type && void a(b)
  16108. })
  16109. }),
  16110. c &&
  16111. b.outputXssFilter &&
  16112. this.addOutputRule(function (b) {
  16113. b.traversal(function (b) {
  16114. return 'element' === b.type && void a(b)
  16115. })
  16116. })
  16117. })
  16118. var baidu = baidu || {}
  16119. ;(baidu.editor = baidu.editor || {}),
  16120. (UE.ui = baidu.editor.ui = {}),
  16121. (function () {
  16122. function a() {
  16123. var a = document.getElementById('edui_fixedlayer')
  16124. i.setViewportOffset(a, { left: 0, top: 0 })
  16125. }
  16126. function b(b) {
  16127. d.on(window, 'scroll', a),
  16128. d.on(window, 'resize', baidu.editor.utils.defer(a, 0, !0))
  16129. }
  16130. var c = baidu.editor.browser,
  16131. d = baidu.editor.dom.domUtils,
  16132. e = '$EDITORUI',
  16133. f = (window[e] = {}),
  16134. g = 'ID' + e,
  16135. h = 0,
  16136. i = (baidu.editor.ui.uiUtils = {
  16137. uid: function (a) {
  16138. return a ? a[g] || (a[g] = ++h) : ++h
  16139. },
  16140. hook: function (a, b) {
  16141. var c
  16142. return (
  16143. a && a._callbacks
  16144. ? (c = a)
  16145. : ((c = function () {
  16146. var b
  16147. a && (b = a.apply(this, arguments))
  16148. for (var d = c._callbacks, e = d.length; e--; ) {
  16149. var f = d[e].apply(this, arguments)
  16150. void 0 === b && (b = f)
  16151. }
  16152. return b
  16153. }),
  16154. (c._callbacks = [])),
  16155. c._callbacks.push(b),
  16156. c
  16157. )
  16158. },
  16159. createElementByHtml: function (a) {
  16160. var b = document.createElement('div')
  16161. return (
  16162. (b.innerHTML = a),
  16163. (b = b.firstChild),
  16164. b.parentNode.removeChild(b),
  16165. b
  16166. )
  16167. },
  16168. getViewportElement: function () {
  16169. return c.ie && c.quirks ? document.body : document.documentElement
  16170. },
  16171. getClientRect: function (a) {
  16172. var b
  16173. try {
  16174. b = a.getBoundingClientRect()
  16175. } catch (c) {
  16176. b = { left: 0, top: 0, height: 0, width: 0 }
  16177. }
  16178. for (
  16179. var e,
  16180. f = {
  16181. left: Math.round(b.left),
  16182. top: Math.round(b.top),
  16183. height: Math.round(b.bottom - b.top),
  16184. width: Math.round(b.right - b.left)
  16185. };
  16186. (e = a.ownerDocument) !== document &&
  16187. (a = d.getWindow(e).frameElement);
  16188. )
  16189. (b = a.getBoundingClientRect()),
  16190. (f.left += b.left),
  16191. (f.top += b.top)
  16192. return (
  16193. (f.bottom = f.top + f.height), (f.right = f.left + f.width), f
  16194. )
  16195. },
  16196. getViewportRect: function () {
  16197. var a = i.getViewportElement(),
  16198. b = 0 | (window.innerWidth || a.clientWidth),
  16199. c = 0 | (window.innerHeight || a.clientHeight)
  16200. return { left: 0, top: 0, height: c, width: b, bottom: c, right: b }
  16201. },
  16202. setViewportOffset: function (a, b) {
  16203. var c = i.getFixedLayer()
  16204. a.parentNode === c
  16205. ? ((a.style.left = b.left + 'px'), (a.style.top = b.top + 'px'))
  16206. : d.setViewportOffset(a, b)
  16207. },
  16208. getEventOffset: function (a) {
  16209. var b = a.target || a.srcElement,
  16210. c = i.getClientRect(b),
  16211. d = i.getViewportOffsetByEvent(a)
  16212. return { left: d.left - c.left, top: d.top - c.top }
  16213. },
  16214. getViewportOffsetByEvent: function (a) {
  16215. var b = a.target || a.srcElement,
  16216. c = d.getWindow(b).frameElement,
  16217. e = { left: a.clientX, top: a.clientY }
  16218. if (c && b.ownerDocument !== document) {
  16219. var f = i.getClientRect(c)
  16220. ;(e.left += f.left), (e.top += f.top)
  16221. }
  16222. return e
  16223. },
  16224. setGlobal: function (a, b) {
  16225. return (f[a] = b), e + '["' + a + '"]'
  16226. },
  16227. unsetGlobal: function (a) {
  16228. delete f[a]
  16229. },
  16230. copyAttributes: function (a, b) {
  16231. for (var e = b.attributes, f = e.length; f--; ) {
  16232. var g = e[f]
  16233. 'style' == g.nodeName ||
  16234. 'class' == g.nodeName ||
  16235. (c.ie && !g.specified) ||
  16236. a.setAttribute(g.nodeName, g.nodeValue)
  16237. }
  16238. b.className && d.addClass(a, b.className),
  16239. b.style.cssText && (a.style.cssText += ';' + b.style.cssText)
  16240. },
  16241. removeStyle: function (a, b) {
  16242. if (a.style.removeProperty) a.style.removeProperty(b)
  16243. else {
  16244. if (!a.style.removeAttribute) throw ''
  16245. a.style.removeAttribute(b)
  16246. }
  16247. },
  16248. contains: function (a, b) {
  16249. return (
  16250. a &&
  16251. b &&
  16252. a !== b &&
  16253. (a.contains ? a.contains(b) : 16 & a.compareDocumentPosition(b))
  16254. )
  16255. },
  16256. startDrag: function (a, b, c) {
  16257. function d(a) {
  16258. var c = a.clientX - g,
  16259. d = a.clientY - h
  16260. b.ondragmove(c, d, a),
  16261. a.stopPropagation ? a.stopPropagation() : (a.cancelBubble = !0)
  16262. }
  16263. function e(a) {
  16264. c.removeEventListener('mousemove', d, !0),
  16265. c.removeEventListener('mouseup', e, !0),
  16266. window.removeEventListener('mouseup', e, !0),
  16267. b.ondragstop()
  16268. }
  16269. function f() {
  16270. i.releaseCapture(),
  16271. i.detachEvent('onmousemove', d),
  16272. i.detachEvent('onmouseup', f),
  16273. i.detachEvent('onlosecaptrue', f),
  16274. b.ondragstop()
  16275. }
  16276. var c = c || document,
  16277. g = a.clientX,
  16278. h = a.clientY
  16279. if (c.addEventListener)
  16280. c.addEventListener('mousemove', d, !0),
  16281. c.addEventListener('mouseup', e, !0),
  16282. window.addEventListener('mouseup', e, !0),
  16283. a.preventDefault()
  16284. else {
  16285. var i = a.srcElement
  16286. i.setCapture(),
  16287. i.attachEvent('onmousemove', d),
  16288. i.attachEvent('onmouseup', f),
  16289. i.attachEvent('onlosecaptrue', f),
  16290. (a.returnValue = !1)
  16291. }
  16292. b.ondragstart()
  16293. },
  16294. getFixedLayer: function () {
  16295. var d = document.getElementById('edui_fixedlayer')
  16296. return (
  16297. null == d &&
  16298. ((d = document.createElement('div')),
  16299. (d.id = 'edui_fixedlayer'),
  16300. document.body.appendChild(d),
  16301. c.ie && c.version <= 8
  16302. ? ((d.style.position = 'absolute'), b(), setTimeout(a))
  16303. : (d.style.position = 'fixed'),
  16304. (d.style.left = '0'),
  16305. (d.style.top = '0'),
  16306. (d.style.width = '0'),
  16307. (d.style.height = '0')),
  16308. d
  16309. )
  16310. },
  16311. makeUnselectable: function (a) {
  16312. if (c.opera || (c.ie && c.version < 9)) {
  16313. if (((a.unselectable = 'on'), a.hasChildNodes()))
  16314. for (var b = 0; b < a.childNodes.length; b++)
  16315. 1 == a.childNodes[b].nodeType &&
  16316. i.makeUnselectable(a.childNodes[b])
  16317. } else
  16318. void 0 !== a.style.MozUserSelect
  16319. ? (a.style.MozUserSelect = 'none')
  16320. : void 0 !== a.style.WebkitUserSelect
  16321. ? (a.style.WebkitUserSelect = 'none')
  16322. : void 0 !== a.style.KhtmlUserSelect &&
  16323. (a.style.KhtmlUserSelect = 'none')
  16324. }
  16325. })
  16326. })(),
  16327. (function () {
  16328. var a = baidu.editor.utils,
  16329. b = baidu.editor.ui.uiUtils,
  16330. c = baidu.editor.EventBase,
  16331. d = (baidu.editor.ui.UIBase = function () {})
  16332. ;(d.prototype = {
  16333. className: '',
  16334. uiName: '',
  16335. initOptions: function (a) {
  16336. var c = this
  16337. for (var d in a) c[d] = a[d]
  16338. this.id = this.id || 'edui' + b.uid()
  16339. },
  16340. initUIBase: function () {
  16341. this._globalKey = a.unhtml(b.setGlobal(this.id, this))
  16342. },
  16343. render: function (a) {
  16344. for (
  16345. var c,
  16346. d = this.renderHtml(),
  16347. e = b.createElementByHtml(d),
  16348. f = domUtils.getElementsByTagName(e, '*'),
  16349. g = 'edui-' + (this.theme || this.editor.options.theme),
  16350. h = document.getElementById('edui_fixedlayer'),
  16351. i = 0;
  16352. (c = f[i++]);
  16353. )
  16354. domUtils.addClass(c, g)
  16355. domUtils.addClass(e, g),
  16356. h && ((h.className = ''), domUtils.addClass(h, g))
  16357. var j = this.getDom()
  16358. null != j
  16359. ? (j.parentNode.replaceChild(e, j), b.copyAttributes(e, j))
  16360. : ('string' == typeof a && (a = document.getElementById(a)),
  16361. (a = a || b.getFixedLayer()),
  16362. domUtils.addClass(a, g),
  16363. a.appendChild(e)),
  16364. this.postRender()
  16365. },
  16366. getDom: function (a) {
  16367. return a
  16368. ? document.getElementById(this.id + '_' + a)
  16369. : document.getElementById(this.id)
  16370. },
  16371. postRender: function () {
  16372. this.fireEvent('postrender')
  16373. },
  16374. getHtmlTpl: function () {
  16375. return ''
  16376. },
  16377. formatHtml: function (a) {
  16378. var b = 'edui-' + this.uiName
  16379. return a
  16380. .replace(/##/g, this.id)
  16381. .replace(/%%-/g, this.uiName ? b + '-' : '')
  16382. .replace(/%%/g, (this.uiName ? b : '') + ' ' + this.className)
  16383. .replace(/\$\$/g, this._globalKey)
  16384. },
  16385. renderHtml: function () {
  16386. return this.formatHtml(this.getHtmlTpl())
  16387. },
  16388. dispose: function () {
  16389. var a = this.getDom()
  16390. a && baidu.editor.dom.domUtils.remove(a), b.unsetGlobal(this.id)
  16391. }
  16392. }),
  16393. a.inherits(d, c)
  16394. })(),
  16395. (function () {
  16396. var a = baidu.editor.utils,
  16397. b = baidu.editor.ui.UIBase,
  16398. c = (baidu.editor.ui.Separator = function (a) {
  16399. this.initOptions(a), this.initSeparator()
  16400. })
  16401. ;(c.prototype = {
  16402. uiName: 'separator',
  16403. initSeparator: function () {
  16404. this.initUIBase()
  16405. },
  16406. getHtmlTpl: function () {
  16407. return '<div id="##" class="edui-box %%"></div>'
  16408. }
  16409. }),
  16410. a.inherits(c, b)
  16411. })(),
  16412. (function () {
  16413. var a = baidu.editor.utils,
  16414. b = baidu.editor.dom.domUtils,
  16415. c = baidu.editor.ui.UIBase,
  16416. d = baidu.editor.ui.uiUtils,
  16417. e = (baidu.editor.ui.Mask = function (a) {
  16418. this.initOptions(a), this.initUIBase()
  16419. })
  16420. ;(e.prototype = {
  16421. getHtmlTpl: function () {
  16422. return '<div id="##" class="edui-mask %%" onclick="return $$._onClick(event, this);" onmousedown="return $$._onMouseDown(event, this);"></div>'
  16423. },
  16424. postRender: function () {
  16425. var a = this
  16426. b.on(window, 'resize', function () {
  16427. setTimeout(function () {
  16428. a.isHidden() || a._fill()
  16429. })
  16430. })
  16431. },
  16432. show: function (a) {
  16433. this._fill(),
  16434. (this.getDom().style.display = ''),
  16435. (this.getDom().style.zIndex = a)
  16436. },
  16437. hide: function () {
  16438. ;(this.getDom().style.display = 'none'),
  16439. (this.getDom().style.zIndex = '')
  16440. },
  16441. isHidden: function () {
  16442. return 'none' == this.getDom().style.display
  16443. },
  16444. _onMouseDown: function () {
  16445. return !1
  16446. },
  16447. _onClick: function (a, b) {
  16448. this.fireEvent('click', a, b)
  16449. },
  16450. _fill: function () {
  16451. var a = this.getDom(),
  16452. b = d.getViewportRect()
  16453. ;(a.style.width = b.width + 'px'), (a.style.height = b.height + 'px')
  16454. }
  16455. }),
  16456. a.inherits(e, c)
  16457. })(),
  16458. (function () {
  16459. function a(a, b) {
  16460. for (var c = 0; c < g.length; c++) {
  16461. var d = g[c]
  16462. if (!d.isHidden() && d.queryAutoHide(b) !== !1) {
  16463. if (
  16464. a &&
  16465. /scroll/gi.test(a.type) &&
  16466. 'edui-wordpastepop' == d.className
  16467. )
  16468. return
  16469. d.hide()
  16470. }
  16471. }
  16472. g.length && d.editor.fireEvent('afterhidepop')
  16473. }
  16474. var b = baidu.editor.utils,
  16475. c = baidu.editor.ui.uiUtils,
  16476. d = baidu.editor.dom.domUtils,
  16477. e = baidu.editor.ui.UIBase,
  16478. f = (baidu.editor.ui.Popup = function (a) {
  16479. this.initOptions(a), this.initPopup()
  16480. }),
  16481. g = []
  16482. f.postHide = a
  16483. var h = [
  16484. 'edui-anchor-topleft',
  16485. 'edui-anchor-topright',
  16486. 'edui-anchor-bottomleft',
  16487. 'edui-anchor-bottomright'
  16488. ]
  16489. ;(f.prototype = {
  16490. SHADOW_RADIUS: 5,
  16491. content: null,
  16492. _hidden: !1,
  16493. autoRender: !0,
  16494. canSideLeft: !0,
  16495. canSideUp: !0,
  16496. initPopup: function () {
  16497. this.initUIBase(), g.push(this)
  16498. },
  16499. getHtmlTpl: function () {
  16500. return (
  16501. '<div id="##" class="edui-popup %%" onmousedown="return false;"> <div id="##_body" class="edui-popup-body"> <iframe style="position:absolute;z-index:-1;left:0;top:0;background-color: transparent;" frameborder="0" width="100%" height="100%" src="about:blank"></iframe> <div class="edui-shadow"></div> <div id="##_content" class="edui-popup-content">' +
  16502. this.getContentHtmlTpl() +
  16503. ' </div> </div></div>'
  16504. )
  16505. },
  16506. getContentHtmlTpl: function () {
  16507. return this.content
  16508. ? 'string' == typeof this.content
  16509. ? this.content
  16510. : this.content.renderHtml()
  16511. : ''
  16512. },
  16513. _UIBase_postRender: e.prototype.postRender,
  16514. postRender: function () {
  16515. if (
  16516. (this.content instanceof e && this.content.postRender(),
  16517. this.captureWheel && !this.captured)
  16518. ) {
  16519. this.captured = !0
  16520. var a =
  16521. (document.documentElement.clientHeight ||
  16522. document.body.clientHeight) - 80,
  16523. b = this.getDom().offsetHeight,
  16524. f = c.getClientRect(this.combox.getDom()).top,
  16525. g = this.getDom('content'),
  16526. h = this.getDom('body').getElementsByTagName('iframe'),
  16527. i = this
  16528. for (h.length && (h = h[0]); f + b > a; ) b -= 30
  16529. ;(g.style.height = b + 'px'),
  16530. h && (h.style.height = b + 'px'),
  16531. window.XMLHttpRequest
  16532. ? d.on(
  16533. g,
  16534. 'onmousewheel' in document.body
  16535. ? 'mousewheel'
  16536. : 'DOMMouseScroll',
  16537. function (a) {
  16538. a.preventDefault
  16539. ? a.preventDefault()
  16540. : (a.returnValue = !1),
  16541. a.wheelDelta
  16542. ? (g.scrollTop -= (a.wheelDelta / 120) * 60)
  16543. : (g.scrollTop -= (a.detail / -3) * 60)
  16544. }
  16545. )
  16546. : d.on(this.getDom(), 'mousewheel', function (a) {
  16547. ;(a.returnValue = !1),
  16548. (i.getDom('content').scrollTop -=
  16549. (a.wheelDelta / 120) * 60)
  16550. })
  16551. }
  16552. this.fireEvent('postRenderAfter'),
  16553. this.hide(!0),
  16554. this._UIBase_postRender()
  16555. },
  16556. _doAutoRender: function () {
  16557. !this.getDom() && this.autoRender && this.render()
  16558. },
  16559. mesureSize: function () {
  16560. var a = this.getDom('content')
  16561. return c.getClientRect(a)
  16562. },
  16563. fitSize: function () {
  16564. if (this.captureWheel && this.sized) return this.__size
  16565. this.sized = !0
  16566. var a = this.getDom('body')
  16567. ;(a.style.width = ''), (a.style.height = '')
  16568. var b = this.mesureSize()
  16569. if (this.captureWheel) {
  16570. a.style.width = -(-20 - b.width) + 'px'
  16571. var c = parseInt(this.getDom('content').style.height, 10)
  16572. !window.isNaN(c) && (b.height = c)
  16573. } else a.style.width = b.width + 'px'
  16574. return (
  16575. (a.style.height = b.height + 'px'),
  16576. (this.__size = b),
  16577. this.captureWheel &&
  16578. (this.getDom('content').style.overflow = 'auto'),
  16579. b
  16580. )
  16581. },
  16582. showAnchor: function (a, b) {
  16583. this.showAnchorRect(c.getClientRect(a), b)
  16584. },
  16585. showAnchorRect: function (a, b, e) {
  16586. this._doAutoRender()
  16587. var f = c.getViewportRect()
  16588. ;(this.getDom().style.visibility = 'hidden'), this._show()
  16589. var g,
  16590. i,
  16591. j,
  16592. k,
  16593. l = this.fitSize()
  16594. b
  16595. ? ((g =
  16596. this.canSideLeft &&
  16597. a.right + l.width > f.right &&
  16598. a.left > l.width),
  16599. (i =
  16600. this.canSideUp &&
  16601. a.top + l.height > f.bottom &&
  16602. a.bottom > l.height),
  16603. (j = g ? a.left - l.width : a.right),
  16604. (k = i ? a.bottom - l.height : a.top))
  16605. : ((g =
  16606. this.canSideLeft &&
  16607. a.right + l.width > f.right &&
  16608. a.left > l.width),
  16609. (i =
  16610. this.canSideUp &&
  16611. a.top + l.height > f.bottom &&
  16612. a.bottom > l.height),
  16613. (j = g ? a.right - l.width : a.left),
  16614. (k = i ? a.top - l.height : a.bottom))
  16615. var m = this.getDom()
  16616. c.setViewportOffset(m, { left: j, top: k }),
  16617. d.removeClasses(m, h),
  16618. (m.className += ' ' + h[2 * (i ? 1 : 0) + (g ? 1 : 0)]),
  16619. this.editor &&
  16620. ((m.style.zIndex = 1 * this.editor.container.style.zIndex + 10),
  16621. (baidu.editor.ui.uiUtils.getFixedLayer().style.zIndex =
  16622. m.style.zIndex - 1)),
  16623. (this.getDom().style.visibility = 'visible')
  16624. },
  16625. showAt: function (a) {
  16626. var b = a.left,
  16627. c = a.top,
  16628. d = { left: b, top: c, right: b, bottom: c, height: 0, width: 0 }
  16629. this.showAnchorRect(d, !1, !0)
  16630. },
  16631. _show: function () {
  16632. if (this._hidden) {
  16633. var a = this.getDom()
  16634. ;(a.style.display = ''), (this._hidden = !1), this.fireEvent('show')
  16635. }
  16636. },
  16637. isHidden: function () {
  16638. return this._hidden
  16639. },
  16640. show: function () {
  16641. this._doAutoRender(), this._show()
  16642. },
  16643. hide: function (a) {
  16644. !this._hidden &&
  16645. this.getDom() &&
  16646. ((this.getDom().style.display = 'none'),
  16647. (this._hidden = !0),
  16648. a || this.fireEvent('hide'))
  16649. },
  16650. queryAutoHide: function (a) {
  16651. return !a || !c.contains(this.getDom(), a)
  16652. }
  16653. }),
  16654. b.inherits(f, e),
  16655. d.on(document, 'mousedown', function (b) {
  16656. var c = b.target || b.srcElement
  16657. a(b, c)
  16658. }),
  16659. d.on(window, 'scroll', function (b, c) {
  16660. a(b, c)
  16661. })
  16662. })(),
  16663. (function () {
  16664. function a(a, b) {
  16665. for (
  16666. var c =
  16667. '<div id="##" class="edui-colorpicker %%"><div class="edui-colorpicker-topbar edui-clearfix"><div unselectable="on" id="##_preview" class="edui-colorpicker-preview"></div><div unselectable="on" class="edui-colorpicker-nocolor" onclick="$$._onPickNoColor(event, this);">' +
  16668. a +
  16669. '</div></div><table class="edui-box" style="border-collapse: collapse;" onmouseover="$$._onTableOver(event, this);" onmouseout="$$._onTableOut(event, this);" onclick="return $$._onTableClick(event, this);" cellspacing="0" cellpadding="0"><tr style="border-bottom: 1px solid #ddd;font-size: 13px;line-height: 25px;color:#39C;padding-top: 2px"><td colspan="10">' +
  16670. b.getLang('themeColor') +
  16671. '</td> </tr><tr class="edui-colorpicker-tablefirstrow" >',
  16672. d = 0;
  16673. d < e.length;
  16674. d++
  16675. )
  16676. d &&
  16677. d % 10 === 0 &&
  16678. (c +=
  16679. '</tr>' +
  16680. (60 == d
  16681. ? '<tr style="border-bottom: 1px solid #ddd;font-size: 13px;line-height: 25px;color:#39C;"><td colspan="10">' +
  16682. b.getLang('standardColor') +
  16683. '</td></tr>'
  16684. : '') +
  16685. '<tr' +
  16686. (60 == d ? ' class="edui-colorpicker-tablefirstrow"' : '') +
  16687. '>'),
  16688. (c +=
  16689. d < 70
  16690. ? '<td style="padding: 0 2px;"><a hidefocus title="' +
  16691. e[d] +
  16692. '" onclick="return false;" href="javascript:" unselectable="on" class="edui-box edui-colorpicker-colorcell" data-color="#' +
  16693. e[d] +
  16694. '" style="background-color:#' +
  16695. e[d] +
  16696. ';border:solid #ccc;' +
  16697. (d < 10 || d >= 60
  16698. ? 'border-width:1px;'
  16699. : d >= 10 && d < 20
  16700. ? 'border-width:1px 1px 0 1px;'
  16701. : 'border-width:0 1px 0 1px;') +
  16702. '"></a></td>'
  16703. : '')
  16704. return (c += '</tr></table></div>')
  16705. }
  16706. var b = baidu.editor.utils,
  16707. c = baidu.editor.ui.UIBase,
  16708. d = (baidu.editor.ui.ColorPicker = function (a) {
  16709. this.initOptions(a),
  16710. (this.noColorText =
  16711. this.noColorText || this.editor.getLang('clearColor')),
  16712. this.initUIBase()
  16713. })
  16714. ;(d.prototype = {
  16715. getHtmlTpl: function () {
  16716. return a(this.noColorText, this.editor)
  16717. },
  16718. _onTableClick: function (a) {
  16719. var b = a.target || a.srcElement,
  16720. c = b.getAttribute('data-color')
  16721. c && this.fireEvent('pickcolor', c)
  16722. },
  16723. _onTableOver: function (a) {
  16724. var b = a.target || a.srcElement,
  16725. c = b.getAttribute('data-color')
  16726. c && (this.getDom('preview').style.backgroundColor = c)
  16727. },
  16728. _onTableOut: function () {
  16729. this.getDom('preview').style.backgroundColor = ''
  16730. },
  16731. _onPickNoColor: function () {
  16732. this.fireEvent('picknocolor')
  16733. }
  16734. }),
  16735. b.inherits(d, c)
  16736. var e =
  16737. 'ffffff,000000,eeece1,1f497d,4f81bd,c0504d,9bbb59,8064a2,4bacc6,f79646,f2f2f2,7f7f7f,ddd9c3,c6d9f0,dbe5f1,f2dcdb,ebf1dd,e5e0ec,dbeef3,fdeada,d8d8d8,595959,c4bd97,8db3e2,b8cce4,e5b9b7,d7e3bc,ccc1d9,b7dde8,fbd5b5,bfbfbf,3f3f3f,938953,548dd4,95b3d7,d99694,c3d69b,b2a2c7,92cddc,fac08f,a5a5a5,262626,494429,17365d,366092,953734,76923c,5f497a,31859b,e36c09,7f7f7f,0c0c0c,1d1b10,0f243e,244061,632423,4f6128,3f3151,205867,974806,c00000,ff0000,ffc000,ffff00,92d050,00b050,00b0f0,0070c0,002060,7030a0,'.split(
  16738. ','
  16739. )
  16740. })(),
  16741. (function () {
  16742. var a = baidu.editor.utils,
  16743. b = baidu.editor.ui.uiUtils,
  16744. c = baidu.editor.ui.UIBase,
  16745. d = (baidu.editor.ui.TablePicker = function (a) {
  16746. this.initOptions(a), this.initTablePicker()
  16747. })
  16748. ;(d.prototype = {
  16749. defaultNumRows: 10,
  16750. defaultNumCols: 10,
  16751. maxNumRows: 20,
  16752. maxNumCols: 20,
  16753. numRows: 10,
  16754. numCols: 10,
  16755. lengthOfCellSide: 22,
  16756. initTablePicker: function () {
  16757. this.initUIBase()
  16758. },
  16759. getHtmlTpl: function () {
  16760. return '<div id="##" class="edui-tablepicker %%"><div class="edui-tablepicker-body"><div class="edui-infoarea"><span id="##_label" class="edui-label"></span></div><div class="edui-pickarea" onmousemove="$$._onMouseMove(event, this);" onmouseover="$$._onMouseOver(event, this);" onmouseout="$$._onMouseOut(event, this);" onclick="$$._onClick(event, this);"><div id="##_overlay" class="edui-overlay"></div></div></div></div>'
  16761. },
  16762. _UIBase_render: c.prototype.render,
  16763. render: function (a) {
  16764. this._UIBase_render(a),
  16765. (this.getDom('label').innerHTML =
  16766. '0' +
  16767. this.editor.getLang('t_row') +
  16768. ' x 0' +
  16769. this.editor.getLang('t_col'))
  16770. },
  16771. _track: function (a, b) {
  16772. var c = this.getDom('overlay').style,
  16773. d = this.lengthOfCellSide
  16774. ;(c.width = a * d + 'px'), (c.height = b * d + 'px')
  16775. var e = this.getDom('label')
  16776. ;(e.innerHTML =
  16777. a +
  16778. this.editor.getLang('t_col') +
  16779. ' x ' +
  16780. b +
  16781. this.editor.getLang('t_row')),
  16782. (this.numCols = a),
  16783. (this.numRows = b)
  16784. },
  16785. _onMouseOver: function (a, c) {
  16786. var d = a.relatedTarget || a.fromElement
  16787. b.contains(c, d) ||
  16788. c === d ||
  16789. ((this.getDom('label').innerHTML =
  16790. '0' +
  16791. this.editor.getLang('t_col') +
  16792. ' x 0' +
  16793. this.editor.getLang('t_row')),
  16794. (this.getDom('overlay').style.visibility = ''))
  16795. },
  16796. _onMouseOut: function (a, c) {
  16797. var d = a.relatedTarget || a.toElement
  16798. b.contains(c, d) ||
  16799. c === d ||
  16800. ((this.getDom('label').innerHTML =
  16801. '0' +
  16802. this.editor.getLang('t_col') +
  16803. ' x 0' +
  16804. this.editor.getLang('t_row')),
  16805. (this.getDom('overlay').style.visibility = 'hidden'))
  16806. },
  16807. _onMouseMove: function (a, c) {
  16808. var d = (this.getDom('overlay').style, b.getEventOffset(a)),
  16809. e = this.lengthOfCellSide,
  16810. f = Math.ceil(d.left / e),
  16811. g = Math.ceil(d.top / e)
  16812. this._track(f, g)
  16813. },
  16814. _onClick: function () {
  16815. this.fireEvent('picktable', this.numCols, this.numRows)
  16816. }
  16817. }),
  16818. a.inherits(d, c)
  16819. })(),
  16820. (function () {
  16821. var a = baidu.editor.browser,
  16822. b = baidu.editor.dom.domUtils,
  16823. c = baidu.editor.ui.uiUtils,
  16824. d =
  16825. 'onmousedown="$$.Stateful_onMouseDown(event, this);" onmouseup="$$.Stateful_onMouseUp(event, this);"' +
  16826. (a.ie
  16827. ? ' onmouseenter="$$.Stateful_onMouseEnter(event, this);" onmouseleave="$$.Stateful_onMouseLeave(event, this);"'
  16828. : ' onmouseover="$$.Stateful_onMouseOver(event, this);" onmouseout="$$.Stateful_onMouseOut(event, this);"')
  16829. baidu.editor.ui.Stateful = {
  16830. alwalysHoverable: !1,
  16831. target: null,
  16832. Stateful_init: function () {
  16833. ;(this._Stateful_dGetHtmlTpl = this.getHtmlTpl),
  16834. (this.getHtmlTpl = this.Stateful_getHtmlTpl)
  16835. },
  16836. Stateful_getHtmlTpl: function () {
  16837. var a = this._Stateful_dGetHtmlTpl()
  16838. return a.replace(/stateful/g, function () {
  16839. return d
  16840. })
  16841. },
  16842. Stateful_onMouseEnter: function (a, b) {
  16843. ;(this.target = b),
  16844. (this.isDisabled() && !this.alwalysHoverable) ||
  16845. (this.addState('hover'), this.fireEvent('over'))
  16846. },
  16847. Stateful_onMouseLeave: function (a, b) {
  16848. ;(this.isDisabled() && !this.alwalysHoverable) ||
  16849. (this.removeState('hover'),
  16850. this.removeState('active'),
  16851. this.fireEvent('out'))
  16852. },
  16853. Stateful_onMouseOver: function (a, b) {
  16854. var d = a.relatedTarget
  16855. c.contains(b, d) || b === d || this.Stateful_onMouseEnter(a, b)
  16856. },
  16857. Stateful_onMouseOut: function (a, b) {
  16858. var d = a.relatedTarget
  16859. c.contains(b, d) || b === d || this.Stateful_onMouseLeave(a, b)
  16860. },
  16861. Stateful_onMouseDown: function (a, b) {
  16862. this.isDisabled() || this.addState('active')
  16863. },
  16864. Stateful_onMouseUp: function (a, b) {
  16865. this.isDisabled() || this.removeState('active')
  16866. },
  16867. Stateful_postRender: function () {
  16868. this.disabled &&
  16869. !this.hasState('disabled') &&
  16870. this.addState('disabled')
  16871. },
  16872. hasState: function (a) {
  16873. return b.hasClass(this.getStateDom(), 'edui-state-' + a)
  16874. },
  16875. addState: function (a) {
  16876. this.hasState(a) ||
  16877. (this.getStateDom().className += ' edui-state-' + a)
  16878. },
  16879. removeState: function (a) {
  16880. this.hasState(a) &&
  16881. b.removeClasses(this.getStateDom(), ['edui-state-' + a])
  16882. },
  16883. getStateDom: function () {
  16884. return this.getDom('state')
  16885. },
  16886. isChecked: function () {
  16887. return this.hasState('checked')
  16888. },
  16889. setChecked: function (a) {
  16890. !this.isDisabled() && a
  16891. ? this.addState('checked')
  16892. : this.removeState('checked')
  16893. },
  16894. isDisabled: function () {
  16895. return this.hasState('disabled')
  16896. },
  16897. setDisabled: function (a) {
  16898. a
  16899. ? (this.removeState('hover'),
  16900. this.removeState('checked'),
  16901. this.removeState('active'),
  16902. this.addState('disabled'))
  16903. : this.removeState('disabled')
  16904. }
  16905. }
  16906. })(),
  16907. (function () {
  16908. var a = baidu.editor.utils,
  16909. b = baidu.editor.ui.UIBase,
  16910. c = baidu.editor.ui.Stateful,
  16911. d = (baidu.editor.ui.Button = function (a) {
  16912. if (a.name) {
  16913. var b = a.name,
  16914. c = a.cssRules
  16915. a.className || (a.className = 'edui-for-' + b),
  16916. (a.cssRules =
  16917. '.edui-default .edui-for-' + b + ' .edui-icon {' + c + '}')
  16918. }
  16919. this.initOptions(a), this.initButton()
  16920. })
  16921. ;(d.prototype = {
  16922. uiName: 'button',
  16923. label: '',
  16924. title: '',
  16925. showIcon: !0,
  16926. showText: !0,
  16927. cssRules: '',
  16928. initButton: function () {
  16929. this.initUIBase(),
  16930. this.Stateful_init(),
  16931. this.cssRules &&
  16932. a.cssRule('edui-customize-' + this.name + '-style', this.cssRules)
  16933. },
  16934. getHtmlTpl: function () {
  16935. return (
  16936. '<div id="##" class="edui-box %%"><div id="##_state" stateful><div class="%%-wrap"><div id="##_body" unselectable="on" ' +
  16937. (this.title ? 'title="' + this.title + '"' : '') +
  16938. ' class="%%-body" onmousedown="return $$._onMouseDown(event, this);" onclick="return $$._onClick(event, this);">' +
  16939. (this.showIcon ? '<div class="edui-box edui-icon"></div>' : '') +
  16940. (this.showText
  16941. ? '<div class="edui-box edui-label">' + this.label + '</div>'
  16942. : '') +
  16943. '</div></div></div></div>'
  16944. )
  16945. },
  16946. postRender: function () {
  16947. this.Stateful_postRender(), this.setDisabled(this.disabled)
  16948. },
  16949. _onMouseDown: function (a) {
  16950. var b = a.target || a.srcElement,
  16951. c = b && b.tagName && b.tagName.toLowerCase()
  16952. if ('input' == c || 'object' == c || 'object' == c) return !1
  16953. },
  16954. _onClick: function () {
  16955. this.isDisabled() || this.fireEvent('click')
  16956. },
  16957. setTitle: function (a) {
  16958. var b = this.getDom('label')
  16959. b.innerHTML = a
  16960. }
  16961. }),
  16962. a.inherits(d, b),
  16963. a.extend(d.prototype, c)
  16964. })(),
  16965. (function () {
  16966. var a = baidu.editor.utils,
  16967. b = baidu.editor.ui.uiUtils,
  16968. c = (baidu.editor.dom.domUtils, baidu.editor.ui.UIBase),
  16969. d = baidu.editor.ui.Stateful,
  16970. e = (baidu.editor.ui.SplitButton = function (a) {
  16971. this.initOptions(a), this.initSplitButton()
  16972. })
  16973. ;(e.prototype = {
  16974. popup: null,
  16975. uiName: 'splitbutton',
  16976. title: '',
  16977. initSplitButton: function () {
  16978. this.initUIBase(), this.Stateful_init()
  16979. if (null != this.popup) {
  16980. var a = this.popup
  16981. ;(this.popup = null), this.setPopup(a)
  16982. }
  16983. },
  16984. _UIBase_postRender: c.prototype.postRender,
  16985. postRender: function () {
  16986. this.Stateful_postRender(), this._UIBase_postRender()
  16987. },
  16988. setPopup: function (c) {
  16989. this.popup !== c &&
  16990. (null != this.popup && this.popup.dispose(),
  16991. c.addListener('show', a.bind(this._onPopupShow, this)),
  16992. c.addListener('hide', a.bind(this._onPopupHide, this)),
  16993. c.addListener(
  16994. 'postrender',
  16995. a.bind(function () {
  16996. c
  16997. .getDom('body')
  16998. .appendChild(
  16999. b.createElementByHtml(
  17000. '<div id="' +
  17001. this.popup.id +
  17002. '_bordereraser" class="edui-bordereraser edui-background" style="width:' +
  17003. (b.getClientRect(this.getDom()).width + 20) +
  17004. 'px"></div>'
  17005. )
  17006. ),
  17007. (c.getDom().className += ' ' + this.className)
  17008. }, this)
  17009. ),
  17010. (this.popup = c))
  17011. },
  17012. _onPopupShow: function () {
  17013. this.addState('opened')
  17014. },
  17015. _onPopupHide: function () {
  17016. this.removeState('opened')
  17017. },
  17018. getHtmlTpl: function () {
  17019. return (
  17020. '<div id="##" class="edui-box %%"><div ' +
  17021. (this.title ? 'title="' + this.title + '"' : '') +
  17022. ' id="##_state" stateful><div class="%%-body"><div id="##_button_body" class="edui-box edui-button-body" onclick="$$._onButtonClick(event, this);"><div class="edui-box edui-icon"></div></div><div class="edui-box edui-splitborder"></div><div class="edui-box edui-arrow" onclick="$$._onArrowClick();"></div></div></div></div>'
  17023. )
  17024. },
  17025. showPopup: function () {
  17026. var a = b.getClientRect(this.getDom())
  17027. ;(a.top -= this.popup.SHADOW_RADIUS),
  17028. (a.height += this.popup.SHADOW_RADIUS),
  17029. this.popup.showAnchorRect(a)
  17030. },
  17031. _onArrowClick: function (a, b) {
  17032. this.isDisabled() || this.showPopup()
  17033. },
  17034. _onButtonClick: function () {
  17035. this.isDisabled() || this.fireEvent('buttonclick')
  17036. }
  17037. }),
  17038. a.inherits(e, c),
  17039. a.extend(e.prototype, d, !0)
  17040. })(),
  17041. (function () {
  17042. var a = baidu.editor.utils,
  17043. b = baidu.editor.ui.uiUtils,
  17044. c = baidu.editor.ui.ColorPicker,
  17045. d = baidu.editor.ui.Popup,
  17046. e = baidu.editor.ui.SplitButton,
  17047. f = (baidu.editor.ui.ColorButton = function (a) {
  17048. this.initOptions(a), this.initColorButton()
  17049. })
  17050. ;(f.prototype = {
  17051. initColorButton: function () {
  17052. var a = this
  17053. ;(this.popup = new d({
  17054. content: new c({
  17055. noColorText: a.editor.getLang('clearColor'),
  17056. editor: a.editor,
  17057. onpickcolor: function (b, c) {
  17058. a._onPickColor(c)
  17059. },
  17060. onpicknocolor: function (b, c) {
  17061. a._onPickNoColor(c)
  17062. }
  17063. }),
  17064. editor: a.editor
  17065. })),
  17066. this.initSplitButton()
  17067. },
  17068. _SplitButton_postRender: e.prototype.postRender,
  17069. postRender: function () {
  17070. this._SplitButton_postRender(),
  17071. this.getDom('button_body').appendChild(
  17072. b.createElementByHtml(
  17073. '<div id="' +
  17074. this.id +
  17075. '_colorlump" class="edui-colorlump"></div>'
  17076. )
  17077. ),
  17078. (this.getDom().className += ' edui-colorbutton')
  17079. },
  17080. setColor: function (a) {
  17081. ;(this.getDom('colorlump').style.backgroundColor = a),
  17082. (this.color = a)
  17083. },
  17084. _onPickColor: function (a) {
  17085. this.fireEvent('pickcolor', a) !== !1 &&
  17086. (this.setColor(a), this.popup.hide())
  17087. },
  17088. _onPickNoColor: function (a) {
  17089. this.fireEvent('picknocolor') !== !1 && this.popup.hide()
  17090. }
  17091. }),
  17092. a.inherits(f, e)
  17093. })(),
  17094. (function () {
  17095. var a = baidu.editor.utils,
  17096. b = baidu.editor.ui.Popup,
  17097. c = baidu.editor.ui.TablePicker,
  17098. d = baidu.editor.ui.SplitButton,
  17099. e = (baidu.editor.ui.TableButton = function (a) {
  17100. this.initOptions(a), this.initTableButton()
  17101. })
  17102. ;(e.prototype = {
  17103. initTableButton: function () {
  17104. var a = this
  17105. ;(this.popup = new b({
  17106. content: new c({
  17107. editor: a.editor,
  17108. onpicktable: function (b, c, d) {
  17109. a._onPickTable(c, d)
  17110. }
  17111. }),
  17112. editor: a.editor
  17113. })),
  17114. this.initSplitButton()
  17115. },
  17116. _onPickTable: function (a, b) {
  17117. this.fireEvent('picktable', a, b) !== !1 && this.popup.hide()
  17118. }
  17119. }),
  17120. a.inherits(e, d)
  17121. })(),
  17122. (function () {
  17123. var a = baidu.editor.utils,
  17124. b = baidu.editor.ui.UIBase,
  17125. c = (baidu.editor.ui.AutoTypeSetPicker = function (a) {
  17126. this.initOptions(a), this.initAutoTypeSetPicker()
  17127. })
  17128. ;(c.prototype = {
  17129. initAutoTypeSetPicker: function () {
  17130. this.initUIBase()
  17131. },
  17132. getHtmlTpl: function () {
  17133. var a = this.editor,
  17134. b = a.options.autotypeset,
  17135. c = a.getLang('autoTypeSet'),
  17136. d = 'textAlignValue' + a.uid,
  17137. e = 'imageBlockLineValue' + a.uid,
  17138. f = 'symbolConverValue' + a.uid
  17139. return (
  17140. '<div id="##" class="edui-autotypesetpicker %%"><div class="edui-autotypesetpicker-body"><table ><tr><td nowrap><input type="checkbox" name="mergeEmptyline" ' +
  17141. (b.mergeEmptyline ? 'checked' : '') +
  17142. '>' +
  17143. c.mergeLine +
  17144. '</td><td colspan="2"><input type="checkbox" name="removeEmptyline" ' +
  17145. (b.removeEmptyline ? 'checked' : '') +
  17146. '>' +
  17147. c.delLine +
  17148. '</td></tr><tr><td nowrap><input type="checkbox" name="removeClass" ' +
  17149. (b.removeClass ? 'checked' : '') +
  17150. '>' +
  17151. c.removeFormat +
  17152. '</td><td colspan="2"><input type="checkbox" name="indent" ' +
  17153. (b.indent ? 'checked' : '') +
  17154. '>' +
  17155. c.indent +
  17156. '</td></tr><tr><td nowrap><input type="checkbox" name="textAlign" ' +
  17157. (b.textAlign ? 'checked' : '') +
  17158. '>' +
  17159. c.alignment +
  17160. '</td><td colspan="2" id="' +
  17161. d +
  17162. '"><input type="radio" name="' +
  17163. d +
  17164. '" value="left" ' +
  17165. (b.textAlign && 'left' == b.textAlign ? 'checked' : '') +
  17166. '>' +
  17167. a.getLang('justifyleft') +
  17168. '<input type="radio" name="' +
  17169. d +
  17170. '" value="center" ' +
  17171. (b.textAlign && 'center' == b.textAlign ? 'checked' : '') +
  17172. '>' +
  17173. a.getLang('justifycenter') +
  17174. '<input type="radio" name="' +
  17175. d +
  17176. '" value="right" ' +
  17177. (b.textAlign && 'right' == b.textAlign ? 'checked' : '') +
  17178. '>' +
  17179. a.getLang('justifyright') +
  17180. '</td></tr><tr><td nowrap><input type="checkbox" name="imageBlockLine" ' +
  17181. (b.imageBlockLine ? 'checked' : '') +
  17182. '>' +
  17183. c.imageFloat +
  17184. '</td><td nowrap id="' +
  17185. e +
  17186. '"><input type="radio" name="' +
  17187. e +
  17188. '" value="none" ' +
  17189. (b.imageBlockLine && 'none' == b.imageBlockLine ? 'checked' : '') +
  17190. '>' +
  17191. a.getLang('default') +
  17192. '<input type="radio" name="' +
  17193. e +
  17194. '" value="left" ' +
  17195. (b.imageBlockLine && 'left' == b.imageBlockLine ? 'checked' : '') +
  17196. '>' +
  17197. a.getLang('justifyleft') +
  17198. '<input type="radio" name="' +
  17199. e +
  17200. '" value="center" ' +
  17201. (b.imageBlockLine && 'center' == b.imageBlockLine
  17202. ? 'checked'
  17203. : '') +
  17204. '>' +
  17205. a.getLang('justifycenter') +
  17206. '<input type="radio" name="' +
  17207. e +
  17208. '" value="right" ' +
  17209. (b.imageBlockLine && 'right' == b.imageBlockLine ? 'checked' : '') +
  17210. '>' +
  17211. a.getLang('justifyright') +
  17212. '</td></tr><tr><td nowrap><input type="checkbox" name="clearFontSize" ' +
  17213. (b.clearFontSize ? 'checked' : '') +
  17214. '>' +
  17215. c.removeFontsize +
  17216. '</td><td colspan="2"><input type="checkbox" name="clearFontFamily" ' +
  17217. (b.clearFontFamily ? 'checked' : '') +
  17218. '>' +
  17219. c.removeFontFamily +
  17220. '</td></tr><tr><td nowrap colspan="3"><input type="checkbox" name="removeEmptyNode" ' +
  17221. (b.removeEmptyNode ? 'checked' : '') +
  17222. '>' +
  17223. c.removeHtml +
  17224. '</td></tr><tr><td nowrap colspan="3"><input type="checkbox" name="pasteFilter" ' +
  17225. (b.pasteFilter ? 'checked' : '') +
  17226. '>' +
  17227. c.pasteFilter +
  17228. '</td></tr><tr><td nowrap><input type="checkbox" name="symbolConver" ' +
  17229. (b.bdc2sb || b.tobdc ? 'checked' : '') +
  17230. '>' +
  17231. c.symbol +
  17232. '</td><td id="' +
  17233. f +
  17234. '"><input type="radio" name="bdc" value="bdc2sb" ' +
  17235. (b.bdc2sb ? 'checked' : '') +
  17236. '>' +
  17237. c.bdc2sb +
  17238. '<input type="radio" name="bdc" value="tobdc" ' +
  17239. (b.tobdc ? 'checked' : '') +
  17240. '>' +
  17241. c.tobdc +
  17242. '</td><td nowrap align="right"><button >' +
  17243. c.run +
  17244. '</button></td></tr></table></div></div>'
  17245. )
  17246. },
  17247. _UIBase_render: b.prototype.render
  17248. }),
  17249. a.inherits(c, b)
  17250. })(),
  17251. (function () {
  17252. function a(a) {
  17253. for (
  17254. var c,
  17255. d = {},
  17256. e = a.getDom(),
  17257. f = a.editor.uid,
  17258. g = null,
  17259. h = null,
  17260. i = domUtils.getElementsByTagName(e, 'input'),
  17261. j = i.length - 1;
  17262. (c = i[j--]);
  17263. )
  17264. if (((g = c.getAttribute('type')), 'checkbox' == g))
  17265. if (
  17266. ((h = c.getAttribute('name')), d[h] && delete d[h], c.checked)
  17267. ) {
  17268. var k = document.getElementById(h + 'Value' + f)
  17269. if (k) {
  17270. if (/input/gi.test(k.tagName)) d[h] = k.value
  17271. else
  17272. for (
  17273. var l,
  17274. m = k.getElementsByTagName('input'),
  17275. n = m.length - 1;
  17276. (l = m[n--]);
  17277. )
  17278. if (l.checked) {
  17279. d[h] = l.value
  17280. break
  17281. }
  17282. } else d[h] = !0
  17283. } else d[h] = !1
  17284. else d[c.getAttribute('value')] = c.checked
  17285. for (
  17286. var o, p = domUtils.getElementsByTagName(e, 'select'), j = 0;
  17287. (o = p[j++]);
  17288. ) {
  17289. var q = o.getAttribute('name')
  17290. d[q] = d[q] ? o.value : ''
  17291. }
  17292. b.extend(a.editor.options.autotypeset, d),
  17293. a.editor.setPreferences('autotypeset', d)
  17294. }
  17295. var b = baidu.editor.utils,
  17296. c = baidu.editor.ui.Popup,
  17297. d = baidu.editor.ui.AutoTypeSetPicker,
  17298. e = baidu.editor.ui.SplitButton,
  17299. f = (baidu.editor.ui.AutoTypeSetButton = function (a) {
  17300. this.initOptions(a), this.initAutoTypeSetButton()
  17301. })
  17302. ;(f.prototype = {
  17303. initAutoTypeSetButton: function () {
  17304. var b = this
  17305. this.popup = new c({
  17306. content: new d({ editor: b.editor }),
  17307. editor: b.editor,
  17308. hide: function () {
  17309. !this._hidden &&
  17310. this.getDom() &&
  17311. (a(this),
  17312. (this.getDom().style.display = 'none'),
  17313. (this._hidden = !0),
  17314. this.fireEvent('hide'))
  17315. }
  17316. })
  17317. var e = 0
  17318. this.popup.addListener('postRenderAfter', function () {
  17319. var c = this
  17320. if (!e) {
  17321. var d = this.getDom(),
  17322. f = d.getElementsByTagName('button')[0]
  17323. ;(f.onclick = function () {
  17324. a(c), b.editor.execCommand('autotypeset'), c.hide()
  17325. }),
  17326. domUtils.on(d, 'click', function (d) {
  17327. var e = d.target || d.srcElement,
  17328. f = b.editor.uid
  17329. if (e && 'INPUT' == e.tagName) {
  17330. if (
  17331. 'imageBlockLine' == e.name ||
  17332. 'textAlign' == e.name ||
  17333. 'symbolConver' == e.name
  17334. )
  17335. for (
  17336. var g = e.checked,
  17337. h = document.getElementById(e.name + 'Value' + f),
  17338. i = h.getElementsByTagName('input'),
  17339. j = {
  17340. imageBlockLine: 'none',
  17341. textAlign: 'left',
  17342. symbolConver: 'tobdc'
  17343. },
  17344. k = 0;
  17345. k < i.length;
  17346. k++
  17347. )
  17348. g
  17349. ? i[k].value == j[e.name] &&
  17350. (i[k].checked = 'checked')
  17351. : (i[k].checked = !1)
  17352. if (
  17353. e.name == 'imageBlockLineValue' + f ||
  17354. e.name == 'textAlignValue' + f ||
  17355. 'bdc' == e.name
  17356. ) {
  17357. var l =
  17358. e.parentNode.previousSibling.getElementsByTagName(
  17359. 'input'
  17360. )
  17361. l && (l[0].checked = !0)
  17362. }
  17363. a(c)
  17364. }
  17365. }),
  17366. (e = 1)
  17367. }
  17368. }),
  17369. this.initSplitButton()
  17370. }
  17371. }),
  17372. b.inherits(f, e)
  17373. })(),
  17374. (function () {
  17375. var a = baidu.editor.utils,
  17376. b = baidu.editor.ui.Popup,
  17377. c = baidu.editor.ui.Stateful,
  17378. d = baidu.editor.ui.UIBase,
  17379. e = (baidu.editor.ui.CellAlignPicker = function (a) {
  17380. this.initOptions(a), this.initSelected(), this.initCellAlignPicker()
  17381. })
  17382. ;(e.prototype = {
  17383. initSelected: function () {
  17384. var a = {
  17385. valign: { top: 0, middle: 1, bottom: 2 },
  17386. align: { left: 0, center: 1, right: 2 },
  17387. count: 3
  17388. }
  17389. this.selected &&
  17390. (this.selectedIndex =
  17391. a.valign[this.selected.valign] * a.count +
  17392. a.align[this.selected.align])
  17393. },
  17394. initCellAlignPicker: function () {
  17395. this.initUIBase(), this.Stateful_init()
  17396. },
  17397. getHtmlTpl: function () {
  17398. for (
  17399. var a = ['left', 'center', 'right'],
  17400. b = 9,
  17401. c = null,
  17402. d = -1,
  17403. e = [],
  17404. f = 0;
  17405. f < b;
  17406. f++
  17407. )
  17408. (c =
  17409. this.selectedIndex === f
  17410. ? ' class="edui-cellalign-selected" '
  17411. : ''),
  17412. (d = f % 3),
  17413. 0 === d && e.push('<tr>'),
  17414. e.push(
  17415. '<td index="' +
  17416. f +
  17417. '" ' +
  17418. c +
  17419. ' stateful><div class="edui-icon edui-' +
  17420. a[d] +
  17421. '"></div></td>'
  17422. ),
  17423. 2 === d && e.push('</tr>')
  17424. return (
  17425. '<div id="##" class="edui-cellalignpicker %%"><div class="edui-cellalignpicker-body"><table onclick="$$._onClick(event);">' +
  17426. e.join('') +
  17427. '</table></div></div>'
  17428. )
  17429. },
  17430. getStateDom: function () {
  17431. return this.target
  17432. },
  17433. _onClick: function (a) {
  17434. var c = a.target || a.srcElement
  17435. ;/icon/.test(c.className) &&
  17436. (this.items[c.parentNode.getAttribute('index')].onclick(),
  17437. b.postHide(a))
  17438. },
  17439. _UIBase_render: d.prototype.render
  17440. }),
  17441. a.inherits(e, d),
  17442. a.extend(e.prototype, c, !0)
  17443. })(),
  17444. (function () {
  17445. var a = baidu.editor.utils,
  17446. b = baidu.editor.ui.Stateful,
  17447. c = baidu.editor.ui.uiUtils,
  17448. d = baidu.editor.ui.UIBase,
  17449. e = (baidu.editor.ui.PastePicker = function (a) {
  17450. this.initOptions(a), this.initPastePicker()
  17451. })
  17452. ;(e.prototype = {
  17453. initPastePicker: function () {
  17454. this.initUIBase(), this.Stateful_init()
  17455. },
  17456. getHtmlTpl: function () {
  17457. return (
  17458. '<div class="edui-pasteicon" onclick="$$._onClick(this)"></div><div class="edui-pastecontainer"><div class="edui-title">' +
  17459. this.editor.getLang('pasteOpt') +
  17460. '</div><div class="edui-button"><div title="' +
  17461. this.editor.getLang('pasteSourceFormat') +
  17462. '" onclick="$$.format(false)" stateful><div class="edui-richtxticon"></div></div><div title="' +
  17463. this.editor.getLang('tagFormat') +
  17464. '" onclick="$$.format(2)" stateful><div class="edui-tagicon"></div></div><div title="' +
  17465. this.editor.getLang('pasteTextFormat') +
  17466. '" onclick="$$.format(true)" stateful><div class="edui-plaintxticon"></div></div></div></div></div>'
  17467. )
  17468. },
  17469. getStateDom: function () {
  17470. return this.target
  17471. },
  17472. format: function (a) {
  17473. ;(this.editor.ui._isTransfer = !0),
  17474. this.editor.fireEvent('pasteTransfer', a)
  17475. },
  17476. _onClick: function (a) {
  17477. var b = domUtils.getNextDomNode(a),
  17478. d = c.getViewportRect().height,
  17479. e = c.getClientRect(b)
  17480. e.top + e.height > d
  17481. ? (b.style.top = -e.height - a.offsetHeight + 'px')
  17482. : (b.style.top = ''),
  17483. /hidden/gi.test(domUtils.getComputedStyle(b, 'visibility'))
  17484. ? ((b.style.visibility = 'visible'),
  17485. domUtils.addClass(a, 'edui-state-opened'))
  17486. : ((b.style.visibility = 'hidden'),
  17487. domUtils.removeClasses(a, 'edui-state-opened'))
  17488. },
  17489. _UIBase_render: d.prototype.render
  17490. }),
  17491. a.inherits(e, d),
  17492. a.extend(e.prototype, b, !0)
  17493. })(),
  17494. (function () {
  17495. var a = baidu.editor.utils,
  17496. b = baidu.editor.ui.uiUtils,
  17497. c = baidu.editor.ui.UIBase,
  17498. d = (baidu.editor.ui.Toolbar = function (a) {
  17499. this.initOptions(a), this.initToolbar()
  17500. })
  17501. ;(d.prototype = {
  17502. items: null,
  17503. initToolbar: function () {
  17504. ;(this.items = this.items || []), this.initUIBase()
  17505. },
  17506. add: function (a, b) {
  17507. void 0 === b ? this.items.push(a) : this.items.splice(b, 0, a)
  17508. },
  17509. getHtmlTpl: function () {
  17510. for (var a = [], b = 0; b < this.items.length; b++)
  17511. a[b] = this.items[b].renderHtml()
  17512. return (
  17513. '<div id="##" class="edui-toolbar %%" onselectstart="return false;" onmousedown="return $$._onMouseDown(event, this);">' +
  17514. a.join('') +
  17515. '</div>'
  17516. )
  17517. },
  17518. postRender: function () {
  17519. for (var a = this.getDom(), c = 0; c < this.items.length; c++)
  17520. this.items[c].postRender()
  17521. b.makeUnselectable(a)
  17522. },
  17523. _onMouseDown: function (a) {
  17524. var b = a.target || a.srcElement,
  17525. c = b && b.tagName && b.tagName.toLowerCase()
  17526. if ('input' == c || 'object' == c || 'object' == c) return !1
  17527. }
  17528. }),
  17529. a.inherits(d, c)
  17530. })(),
  17531. (function () {
  17532. var a = baidu.editor.utils,
  17533. b = baidu.editor.dom.domUtils,
  17534. c = baidu.editor.ui.uiUtils,
  17535. d = baidu.editor.ui.UIBase,
  17536. e = baidu.editor.ui.Popup,
  17537. f = baidu.editor.ui.Stateful,
  17538. g = baidu.editor.ui.CellAlignPicker,
  17539. h = (baidu.editor.ui.Menu = function (a) {
  17540. this.initOptions(a), this.initMenu()
  17541. }),
  17542. i = {
  17543. renderHtml: function () {
  17544. return '<div class="edui-menuitem edui-menuseparator"><div class="edui-menuseparator-inner"></div></div>'
  17545. },
  17546. postRender: function () {},
  17547. queryAutoHide: function () {
  17548. return !0
  17549. }
  17550. }
  17551. ;(h.prototype = {
  17552. items: null,
  17553. uiName: 'menu',
  17554. initMenu: function () {
  17555. ;(this.items = this.items || []), this.initPopup(), this.initItems()
  17556. },
  17557. initItems: function () {
  17558. for (var a = 0; a < this.items.length; a++) {
  17559. var b = this.items[a]
  17560. '-' == b
  17561. ? (this.items[a] = this.getSeparator())
  17562. : b instanceof j ||
  17563. ((b.editor = this.editor),
  17564. (b.theme = this.editor.options.theme),
  17565. (this.items[a] = this.createItem(b)))
  17566. }
  17567. },
  17568. getSeparator: function () {
  17569. return i
  17570. },
  17571. createItem: function (a) {
  17572. return (a.menu = this), new j(a)
  17573. },
  17574. _Popup_getContentHtmlTpl: e.prototype.getContentHtmlTpl,
  17575. getContentHtmlTpl: function () {
  17576. if (0 == this.items.length) return this._Popup_getContentHtmlTpl()
  17577. for (var a = [], b = 0; b < this.items.length; b++) {
  17578. var c = this.items[b]
  17579. a[b] = c.renderHtml()
  17580. }
  17581. return '<div class="%%-body">' + a.join('') + '</div>'
  17582. },
  17583. _Popup_postRender: e.prototype.postRender,
  17584. postRender: function () {
  17585. for (var a = this, d = 0; d < this.items.length; d++) {
  17586. var e = this.items[d]
  17587. ;(e.ownerMenu = this), e.postRender()
  17588. }
  17589. b.on(this.getDom(), 'mouseover', function (b) {
  17590. b = b || event
  17591. var d = b.relatedTarget || b.fromElement,
  17592. e = a.getDom()
  17593. c.contains(e, d) || e === d || a.fireEvent('over')
  17594. }),
  17595. this._Popup_postRender()
  17596. },
  17597. queryAutoHide: function (a) {
  17598. if (a) {
  17599. if (c.contains(this.getDom(), a)) return !1
  17600. for (var b = 0; b < this.items.length; b++) {
  17601. var d = this.items[b]
  17602. if (d.queryAutoHide(a) === !1) return !1
  17603. }
  17604. }
  17605. },
  17606. clearItems: function () {
  17607. for (var a = 0; a < this.items.length; a++) {
  17608. var b = this.items[a]
  17609. clearTimeout(b._showingTimer),
  17610. clearTimeout(b._closingTimer),
  17611. b.subMenu && b.subMenu.destroy()
  17612. }
  17613. this.items = []
  17614. },
  17615. destroy: function () {
  17616. this.getDom() && b.remove(this.getDom()), this.clearItems()
  17617. },
  17618. dispose: function () {
  17619. this.destroy()
  17620. }
  17621. }),
  17622. a.inherits(h, e)
  17623. var j = (baidu.editor.ui.MenuItem = function (a) {
  17624. if (
  17625. (this.initOptions(a),
  17626. this.initUIBase(),
  17627. this.Stateful_init(),
  17628. this.subMenu && !(this.subMenu instanceof h))
  17629. )
  17630. if (a.className && a.className.indexOf('aligntd') != -1) {
  17631. var c = this
  17632. ;(this.subMenu.selected =
  17633. this.editor.queryCommandValue('cellalignment')),
  17634. (this.subMenu = new e({
  17635. content: new g(this.subMenu),
  17636. parentMenu: c,
  17637. editor: c.editor,
  17638. destroy: function () {
  17639. this.getDom() && b.remove(this.getDom())
  17640. }
  17641. })),
  17642. this.subMenu.addListener('postRenderAfter', function () {
  17643. b.on(this.getDom(), 'mouseover', function () {
  17644. c.addState('opened')
  17645. })
  17646. })
  17647. } else this.subMenu = new h(this.subMenu)
  17648. })
  17649. ;(j.prototype = {
  17650. label: '',
  17651. subMenu: null,
  17652. ownerMenu: null,
  17653. uiName: 'menuitem',
  17654. alwalysHoverable: !0,
  17655. getHtmlTpl: function () {
  17656. return (
  17657. '<div id="##" class="%%" stateful onclick="$$._onClick(event, this);"><div class="%%-body">' +
  17658. this.renderLabelHtml() +
  17659. '</div></div>'
  17660. )
  17661. },
  17662. postRender: function () {
  17663. var a = this
  17664. this.addListener('over', function () {
  17665. a.ownerMenu.fireEvent('submenuover', a),
  17666. a.subMenu && a.delayShowSubMenu()
  17667. }),
  17668. this.subMenu &&
  17669. ((this.getDom().className += ' edui-hassubmenu'),
  17670. this.subMenu.render(),
  17671. this.addListener('out', function () {
  17672. a.delayHideSubMenu()
  17673. }),
  17674. this.subMenu.addListener('over', function () {
  17675. clearTimeout(a._closingTimer),
  17676. (a._closingTimer = null),
  17677. a.addState('opened')
  17678. }),
  17679. this.ownerMenu.addListener('hide', function () {
  17680. a.hideSubMenu()
  17681. }),
  17682. this.ownerMenu.addListener('submenuover', function (b, c) {
  17683. c !== a && a.delayHideSubMenu()
  17684. }),
  17685. (this.subMenu._bakQueryAutoHide = this.subMenu.queryAutoHide),
  17686. (this.subMenu.queryAutoHide = function (b) {
  17687. return (
  17688. (!b || !c.contains(a.getDom(), b)) &&
  17689. this._bakQueryAutoHide(b)
  17690. )
  17691. })),
  17692. (this.getDom().style.tabIndex = '-1'),
  17693. c.makeUnselectable(this.getDom()),
  17694. this.Stateful_postRender()
  17695. },
  17696. delayShowSubMenu: function () {
  17697. var a = this
  17698. a.isDisabled() ||
  17699. (a.addState('opened'),
  17700. clearTimeout(a._showingTimer),
  17701. clearTimeout(a._closingTimer),
  17702. (a._closingTimer = null),
  17703. (a._showingTimer = setTimeout(function () {
  17704. a.showSubMenu()
  17705. }, 250)))
  17706. },
  17707. delayHideSubMenu: function () {
  17708. var a = this
  17709. a.isDisabled() ||
  17710. (a.removeState('opened'),
  17711. clearTimeout(a._showingTimer),
  17712. a._closingTimer ||
  17713. (a._closingTimer = setTimeout(function () {
  17714. a.hasState('opened') || a.hideSubMenu(),
  17715. (a._closingTimer = null)
  17716. }, 400)))
  17717. },
  17718. renderLabelHtml: function () {
  17719. return (
  17720. '<div class="edui-arrow"></div><div class="edui-box edui-icon"></div><div class="edui-box edui-label %%-label">' +
  17721. (this.label || '') +
  17722. '</div>'
  17723. )
  17724. },
  17725. getStateDom: function () {
  17726. return this.getDom()
  17727. },
  17728. queryAutoHide: function (a) {
  17729. if (this.subMenu && this.hasState('opened'))
  17730. return this.subMenu.queryAutoHide(a)
  17731. },
  17732. _onClick: function (a, b) {
  17733. this.hasState('disabled') ||
  17734. (this.fireEvent('click', a, b) !== !1 &&
  17735. (this.subMenu ? this.showSubMenu() : e.postHide(a)))
  17736. },
  17737. showSubMenu: function () {
  17738. var a = c.getClientRect(this.getDom())
  17739. ;(a.right -= 5),
  17740. (a.left += 2),
  17741. (a.width -= 7),
  17742. (a.top -= 4),
  17743. (a.bottom += 4),
  17744. (a.height += 8),
  17745. this.subMenu.showAnchorRect(a, !0, !0)
  17746. },
  17747. hideSubMenu: function () {
  17748. this.subMenu.hide()
  17749. }
  17750. }),
  17751. a.inherits(j, d),
  17752. a.extend(j.prototype, f, !0)
  17753. })(),
  17754. (function () {
  17755. var a = baidu.editor.utils,
  17756. b = baidu.editor.ui.uiUtils,
  17757. c = baidu.editor.ui.Menu,
  17758. d = baidu.editor.ui.SplitButton,
  17759. e = (baidu.editor.ui.Combox = function (a) {
  17760. this.initOptions(a), this.initCombox()
  17761. })
  17762. ;(e.prototype = {
  17763. uiName: 'combox',
  17764. onbuttonclick: function () {
  17765. this.showPopup()
  17766. },
  17767. initCombox: function () {
  17768. var a = this
  17769. this.items = this.items || []
  17770. for (var b = 0; b < this.items.length; b++) {
  17771. var d = this.items[b]
  17772. ;(d.uiName = 'listitem'),
  17773. (d.index = b),
  17774. (d.onclick = function () {
  17775. a.selectByIndex(this.index)
  17776. })
  17777. }
  17778. ;(this.popup = new c({
  17779. items: this.items,
  17780. uiName: 'list',
  17781. editor: this.editor,
  17782. captureWheel: !0,
  17783. combox: this
  17784. })),
  17785. this.initSplitButton()
  17786. },
  17787. _SplitButton_postRender: d.prototype.postRender,
  17788. postRender: function () {
  17789. this._SplitButton_postRender(),
  17790. this.setLabel(this.label || ''),
  17791. this.setValue(this.initValue || '')
  17792. },
  17793. showPopup: function () {
  17794. var a = b.getClientRect(this.getDom())
  17795. ;(a.top += 1),
  17796. (a.bottom -= 1),
  17797. (a.height -= 2),
  17798. this.popup.showAnchorRect(a)
  17799. },
  17800. getValue: function () {
  17801. return this.value
  17802. },
  17803. setValue: function (a) {
  17804. var b = this.indexByValue(a)
  17805. b != -1
  17806. ? ((this.selectedIndex = b),
  17807. this.setLabel(this.items[b].label),
  17808. (this.value = this.items[b].value))
  17809. : ((this.selectedIndex = -1),
  17810. this.setLabel(this.getLabelForUnknowValue(a)),
  17811. (this.value = a))
  17812. },
  17813. setLabel: function (a) {
  17814. ;(this.getDom('button_body').innerHTML = a), (this.label = a)
  17815. },
  17816. getLabelForUnknowValue: function (a) {
  17817. return a
  17818. },
  17819. indexByValue: function (a) {
  17820. for (var b = 0; b < this.items.length; b++)
  17821. if (a == this.items[b].value) return b
  17822. return -1
  17823. },
  17824. getItem: function (a) {
  17825. return this.items[a]
  17826. },
  17827. selectByIndex: function (a) {
  17828. a < this.items.length &&
  17829. this.fireEvent('select', a) !== !1 &&
  17830. ((this.selectedIndex = a),
  17831. (this.value = this.items[a].value),
  17832. this.setLabel(this.items[a].label))
  17833. }
  17834. }),
  17835. a.inherits(e, d)
  17836. })(),
  17837. (function () {
  17838. var a,
  17839. b,
  17840. c,
  17841. d = baidu.editor.utils,
  17842. e = baidu.editor.dom.domUtils,
  17843. f = baidu.editor.ui.uiUtils,
  17844. g = baidu.editor.ui.Mask,
  17845. h = baidu.editor.ui.UIBase,
  17846. i = baidu.editor.ui.Button,
  17847. j = (baidu.editor.ui.Dialog = function (a) {
  17848. if (a.name) {
  17849. var b = a.name,
  17850. c = a.cssRules
  17851. a.className || (a.className = 'edui-for-' + b),
  17852. c &&
  17853. (a.cssRules =
  17854. '.edui-default .edui-for-' +
  17855. b +
  17856. ' .edui-dialog-content {' +
  17857. c +
  17858. '}')
  17859. }
  17860. this.initOptions(
  17861. d.extend(
  17862. {
  17863. autoReset: !0,
  17864. draggable: !0,
  17865. onok: function () {},
  17866. oncancel: function () {},
  17867. onclose: function (a, b) {
  17868. return b ? this.onok() : this.oncancel()
  17869. },
  17870. holdScroll: !1
  17871. },
  17872. a
  17873. )
  17874. ),
  17875. this.initDialog()
  17876. })
  17877. ;(j.prototype = {
  17878. draggable: !1,
  17879. uiName: 'dialog',
  17880. initDialog: function () {
  17881. var e = this,
  17882. f = this.editor.options.theme
  17883. if (
  17884. (this.cssRules &&
  17885. d.cssRule(
  17886. 'edui-customize-' + this.name + '-style',
  17887. this.cssRules
  17888. ),
  17889. this.initUIBase(),
  17890. (this.modalMask =
  17891. a ||
  17892. (a = new g({
  17893. className: 'edui-dialog-modalmask',
  17894. theme: f,
  17895. onclick: function () {
  17896. c && c.close(!1)
  17897. }
  17898. }))),
  17899. (this.dragMask =
  17900. b ||
  17901. (b = new g({ className: 'edui-dialog-dragmask', theme: f }))),
  17902. (this.closeButton = new i({
  17903. className: 'edui-dialog-closebutton',
  17904. title: e.closeDialog,
  17905. theme: f,
  17906. onclick: function () {
  17907. e.close(!1)
  17908. }
  17909. })),
  17910. this.fullscreen && this.initResizeEvent(),
  17911. this.buttons)
  17912. )
  17913. for (var h = 0; h < this.buttons.length; h++)
  17914. this.buttons[h] instanceof i ||
  17915. (this.buttons[h] = new i(
  17916. d.extend(this.buttons[h], { editor: this.editor }, !0)
  17917. ))
  17918. },
  17919. initResizeEvent: function () {
  17920. var a = this
  17921. e.on(window, 'resize', function () {
  17922. a._hidden ||
  17923. void 0 === a._hidden ||
  17924. (a.__resizeTimer && window.clearTimeout(a.__resizeTimer),
  17925. (a.__resizeTimer = window.setTimeout(function () {
  17926. a.__resizeTimer = null
  17927. var b = a.getDom(),
  17928. c = a.getDom('content'),
  17929. d = UE.ui.uiUtils.getClientRect(b),
  17930. e = UE.ui.uiUtils.getClientRect(c),
  17931. g = f.getViewportRect()
  17932. ;(c.style.width = g.width - d.width + e.width + 'px'),
  17933. (c.style.height = g.height - d.height + e.height + 'px'),
  17934. (b.style.width = g.width + 'px'),
  17935. (b.style.height = g.height + 'px'),
  17936. a.fireEvent('resize')
  17937. }, 100)))
  17938. })
  17939. },
  17940. fitSize: function () {
  17941. var a = this.getDom('body'),
  17942. b = this.mesureSize()
  17943. return (
  17944. (a.style.width = b.width + 'px'),
  17945. (a.style.height = b.height + 'px'),
  17946. b
  17947. )
  17948. },
  17949. safeSetOffset: function (a) {
  17950. var b = this,
  17951. c = b.getDom(),
  17952. d = f.getViewportRect(),
  17953. e = f.getClientRect(c),
  17954. g = a.left
  17955. g + e.width > d.right && (g = d.right - e.width)
  17956. var h = a.top
  17957. h + e.height > d.bottom && (h = d.bottom - e.height),
  17958. (c.style.left = Math.max(g, 0) + 'px'),
  17959. (c.style.top = Math.max(h, 0) + 'px')
  17960. },
  17961. showAtCenter: function () {
  17962. var a = f.getViewportRect()
  17963. if (this.fullscreen) {
  17964. var b = this.getDom(),
  17965. c = this.getDom('content')
  17966. b.style.display = 'block'
  17967. var d = UE.ui.uiUtils.getClientRect(b),
  17968. g = UE.ui.uiUtils.getClientRect(c)
  17969. ;(b.style.left = '-100000px'),
  17970. (c.style.width = a.width - d.width + g.width + 'px'),
  17971. (c.style.height = a.height - d.height + g.height + 'px'),
  17972. (b.style.width = a.width + 'px'),
  17973. (b.style.height = a.height + 'px'),
  17974. (b.style.left = 0),
  17975. (this._originalContext = {
  17976. html: {
  17977. overflowX: document.documentElement.style.overflowX,
  17978. overflowY: document.documentElement.style.overflowY
  17979. },
  17980. body: {
  17981. overflowX: document.body.style.overflowX,
  17982. overflowY: document.body.style.overflowY
  17983. }
  17984. }),
  17985. (document.documentElement.style.overflowX = 'hidden'),
  17986. (document.documentElement.style.overflowY = 'hidden'),
  17987. (document.body.style.overflowX = 'hidden'),
  17988. (document.body.style.overflowY = 'hidden')
  17989. } else {
  17990. this.getDom().style.display = ''
  17991. var h = this.fitSize(),
  17992. i = 0 | this.getDom('titlebar').offsetHeight,
  17993. j = a.width / 2 - h.width / 2,
  17994. k = a.height / 2 - (h.height - i) / 2 - i,
  17995. l = this.getDom()
  17996. this.safeSetOffset({
  17997. left: Math.max(0 | j, 0),
  17998. top: Math.max(0 | k, 0)
  17999. }),
  18000. e.hasClass(l, 'edui-state-centered') ||
  18001. (l.className += ' edui-state-centered')
  18002. }
  18003. this._show()
  18004. },
  18005. getContentHtml: function () {
  18006. var a = ''
  18007. return (
  18008. 'string' == typeof this.content
  18009. ? (a = this.content)
  18010. : this.iframeUrl &&
  18011. (a =
  18012. '<span id="' +
  18013. this.id +
  18014. '_contmask" class="dialogcontmask"></span><iframe id="' +
  18015. this.id +
  18016. '_iframe" class="%%-iframe" height="100%" width="100%" frameborder="0" src="' +
  18017. this.iframeUrl +
  18018. '"></iframe>'),
  18019. a
  18020. )
  18021. },
  18022. getHtmlTpl: function () {
  18023. var a = ''
  18024. if (this.buttons) {
  18025. for (var b = [], c = 0; c < this.buttons.length; c++)
  18026. b[c] = this.buttons[c].renderHtml()
  18027. a =
  18028. '<div class="%%-foot"><div id="##_buttons" class="%%-buttons">' +
  18029. b.join('') +
  18030. '</div></div>'
  18031. }
  18032. return (
  18033. '<div id="##" class="%%"><div ' +
  18034. (this.fullscreen
  18035. ? 'class="%%-wrap edui-dialog-fullscreen-flag"'
  18036. : 'class="%%"') +
  18037. '><div id="##_body" class="%%-body"><div class="%%-shadow"></div><div id="##_titlebar" class="%%-titlebar"><div class="%%-draghandle" onmousedown="$$._onTitlebarMouseDown(event, this);"><span class="%%-caption">' +
  18038. (this.title || '') +
  18039. '</span></div>' +
  18040. this.closeButton.renderHtml() +
  18041. '</div><div id="##_content" class="%%-content">' +
  18042. (this.autoReset ? '' : this.getContentHtml()) +
  18043. '</div>' +
  18044. a +
  18045. '</div></div></div>'
  18046. )
  18047. },
  18048. postRender: function () {
  18049. this.modalMask.getDom() ||
  18050. (this.modalMask.render(), this.modalMask.hide()),
  18051. this.dragMask.getDom() ||
  18052. (this.dragMask.render(), this.dragMask.hide())
  18053. var a = this
  18054. if (
  18055. (this.addListener('show', function () {
  18056. a.modalMask.show(this.getDom().style.zIndex - 2)
  18057. }),
  18058. this.addListener('hide', function () {
  18059. a.modalMask.hide()
  18060. }),
  18061. this.buttons)
  18062. )
  18063. for (var b = 0; b < this.buttons.length; b++)
  18064. this.buttons[b].postRender()
  18065. e.on(window, 'resize', function () {
  18066. setTimeout(function () {
  18067. a.isHidden() || a.safeSetOffset(f.getClientRect(a.getDom()))
  18068. })
  18069. }),
  18070. this._hide()
  18071. },
  18072. mesureSize: function () {
  18073. var a = this.getDom('body'),
  18074. b = f.getClientRect(this.getDom('content')).width,
  18075. c = a.style
  18076. return (c.width = b), f.getClientRect(a)
  18077. },
  18078. _onTitlebarMouseDown: function (a, b) {
  18079. if (this.draggable) {
  18080. var c,
  18081. d = (f.getViewportRect(), this)
  18082. f.startDrag(a, {
  18083. ondragstart: function () {
  18084. ;(c = f.getClientRect(d.getDom())),
  18085. (d.getDom('contmask').style.visibility = 'visible'),
  18086. d.dragMask.show(d.getDom().style.zIndex - 1)
  18087. },
  18088. ondragmove: function (a, b) {
  18089. var e = c.left + a,
  18090. f = c.top + b
  18091. d.safeSetOffset({ left: e, top: f })
  18092. },
  18093. ondragstop: function () {
  18094. ;(d.getDom('contmask').style.visibility = 'hidden'),
  18095. e.removeClasses(d.getDom(), ['edui-state-centered']),
  18096. d.dragMask.hide()
  18097. }
  18098. })
  18099. }
  18100. },
  18101. reset: function () {
  18102. ;(this.getDom('content').innerHTML = this.getContentHtml()),
  18103. this.fireEvent('dialogafterreset')
  18104. },
  18105. _show: function () {
  18106. this._hidden &&
  18107. ((this.getDom().style.display = ''),
  18108. this.editor.container.style.zIndex &&
  18109. (this.getDom().style.zIndex =
  18110. 1 * this.editor.container.style.zIndex + 10),
  18111. (this._hidden = !1),
  18112. this.fireEvent('show'),
  18113. (baidu.editor.ui.uiUtils.getFixedLayer().style.zIndex =
  18114. this.getDom().style.zIndex - 4))
  18115. },
  18116. isHidden: function () {
  18117. return this._hidden
  18118. },
  18119. _hide: function () {
  18120. if (!this._hidden) {
  18121. var a = this.getDom()
  18122. ;(a.style.display = 'none'),
  18123. (a.style.zIndex = ''),
  18124. (a.style.width = ''),
  18125. (a.style.height = ''),
  18126. (this._hidden = !0),
  18127. this.fireEvent('hide')
  18128. }
  18129. },
  18130. open: function () {
  18131. if (this.autoReset)
  18132. try {
  18133. this.reset()
  18134. } catch (a) {
  18135. this.render(), this.open()
  18136. }
  18137. if ((this.showAtCenter(), this.iframeUrl))
  18138. try {
  18139. this.getDom('iframe').focus()
  18140. } catch (b) {}
  18141. c = this
  18142. },
  18143. _onCloseButtonClick: function (a, b) {
  18144. this.close(!1)
  18145. },
  18146. close: function (a) {
  18147. if (this.fireEvent('close', a) !== !1) {
  18148. this.fullscreen &&
  18149. ((document.documentElement.style.overflowX =
  18150. this._originalContext.html.overflowX),
  18151. (document.documentElement.style.overflowY =
  18152. this._originalContext.html.overflowY),
  18153. (document.body.style.overflowX =
  18154. this._originalContext.body.overflowX),
  18155. (document.body.style.overflowY =
  18156. this._originalContext.body.overflowY),
  18157. delete this._originalContext),
  18158. this._hide()
  18159. var b = this.getDom('content'),
  18160. c = this.getDom('iframe')
  18161. if (b && c) {
  18162. var d = c.contentDocument || c.contentWindow.document
  18163. d && (d.body.innerHTML = ''), e.remove(b)
  18164. }
  18165. }
  18166. }
  18167. }),
  18168. d.inherits(j, h)
  18169. })(),
  18170. (function () {
  18171. var a = baidu.editor.utils,
  18172. b = baidu.editor.ui.Menu,
  18173. c = baidu.editor.ui.SplitButton,
  18174. d = (baidu.editor.ui.MenuButton = function (a) {
  18175. this.initOptions(a), this.initMenuButton()
  18176. })
  18177. ;(d.prototype = {
  18178. initMenuButton: function () {
  18179. var a = this
  18180. ;(this.uiName = 'menubutton'),
  18181. (this.popup = new b({
  18182. items: a.items,
  18183. className: a.className,
  18184. editor: a.editor
  18185. })),
  18186. this.popup.addListener('show', function () {
  18187. for (var b = this, c = 0; c < b.items.length; c++)
  18188. b.items[c].removeState('checked'),
  18189. b.items[c].value == a._value &&
  18190. (b.items[c].addState('checked'), (this.value = a._value))
  18191. }),
  18192. this.initSplitButton()
  18193. },
  18194. setValue: function (a) {
  18195. this._value = a
  18196. }
  18197. }),
  18198. a.inherits(d, c)
  18199. })(),
  18200. (function () {
  18201. var a = baidu.editor.utils,
  18202. b = baidu.editor.ui.Popup,
  18203. c = baidu.editor.ui.SplitButton,
  18204. d = (baidu.editor.ui.MultiMenuPop = function (a) {
  18205. this.initOptions(a), this.initMultiMenu()
  18206. })
  18207. ;(d.prototype = {
  18208. initMultiMenu: function () {
  18209. var a = this
  18210. ;(this.popup = new b({
  18211. content: '',
  18212. editor: a.editor,
  18213. iframe_rendered: !1,
  18214. onshow: function () {
  18215. this.iframe_rendered ||
  18216. ((this.iframe_rendered = !0),
  18217. (this.getDom('content').innerHTML =
  18218. '<iframe id="' +
  18219. a.id +
  18220. '_iframe" src="' +
  18221. a.iframeUrl +
  18222. '" frameborder="0"></iframe>'),
  18223. a.editor.container.style.zIndex &&
  18224. (this.getDom().style.zIndex =
  18225. 1 * a.editor.container.style.zIndex + 1))
  18226. }
  18227. })),
  18228. (this.onbuttonclick = function () {
  18229. this.showPopup()
  18230. }),
  18231. this.initSplitButton()
  18232. }
  18233. }),
  18234. a.inherits(d, c)
  18235. })(),
  18236. (function () {
  18237. function a(a) {
  18238. var b = a.target || a.srcElement,
  18239. c = g.findParent(
  18240. b,
  18241. function (a) {
  18242. return (
  18243. g.hasClass(a, 'edui-shortcutmenu') ||
  18244. g.hasClass(a, 'edui-popup')
  18245. )
  18246. },
  18247. !0
  18248. )
  18249. if (!c) for (var d, e = 0; (d = h[e++]); ) d.hide()
  18250. }
  18251. var b,
  18252. c = baidu.editor.ui,
  18253. d = c.UIBase,
  18254. e = c.uiUtils,
  18255. f = baidu.editor.utils,
  18256. g = baidu.editor.dom.domUtils,
  18257. h = [],
  18258. i = !1,
  18259. j = (c.ShortCutMenu = function (a) {
  18260. this.initOptions(a), this.initShortCutMenu()
  18261. })
  18262. ;(j.postHide = a),
  18263. (j.prototype = {
  18264. isHidden: !0,
  18265. SPACE: 5,
  18266. initShortCutMenu: function () {
  18267. ;(this.items = this.items || []),
  18268. this.initUIBase(),
  18269. this.initItems(),
  18270. this.initEvent(),
  18271. h.push(this)
  18272. },
  18273. initEvent: function () {
  18274. var a = this,
  18275. c = a.editor.document
  18276. g.on(c, 'mousemove', function (c) {
  18277. if (a.isHidden === !1) {
  18278. if (a.getSubMenuMark() || 'contextmenu' == a.eventType) return
  18279. var d = !0,
  18280. e = a.getDom(),
  18281. f = e.offsetWidth,
  18282. g = e.offsetHeight,
  18283. h = f / 2 + a.SPACE,
  18284. i = g / 2,
  18285. j = Math.abs(c.screenX - a.left),
  18286. k = Math.abs(c.screenY - a.top)
  18287. clearTimeout(b),
  18288. (b = setTimeout(function () {
  18289. k > 0 && k < i
  18290. ? a.setOpacity(e, '1')
  18291. : k > i && k < i + 70
  18292. ? (a.setOpacity(e, '0.5'), (d = !1))
  18293. : k > i + 70 && k < i + 140 && a.hide(),
  18294. d && j > 0 && j < h
  18295. ? a.setOpacity(e, '1')
  18296. : j > h && j < h + 70
  18297. ? a.setOpacity(e, '0.5')
  18298. : j > h + 70 && j < h + 140 && a.hide()
  18299. }))
  18300. }
  18301. }),
  18302. browser.chrome &&
  18303. g.on(c, 'mouseout', function (b) {
  18304. var c = b.relatedTarget || b.toElement
  18305. ;(null != c && 'HTML' != c.tagName) || a.hide()
  18306. }),
  18307. a.editor.addListener('afterhidepop', function () {
  18308. a.isHidden || (i = !0)
  18309. })
  18310. },
  18311. initItems: function () {
  18312. if (f.isArray(this.items))
  18313. for (var a = 0, b = this.items.length; a < b; a++) {
  18314. var d = this.items[a].toLowerCase()
  18315. c[d] &&
  18316. ((this.items[a] = new c[d](this.editor)),
  18317. (this.items[a].className += ' edui-shortcutsubmenu '))
  18318. }
  18319. },
  18320. setOpacity: function (a, b) {
  18321. browser.ie && browser.version < 9
  18322. ? (a.style.filter =
  18323. 'alpha(opacity = ' + 100 * parseFloat(b) + ');')
  18324. : (a.style.opacity = b)
  18325. },
  18326. getSubMenuMark: function () {
  18327. i = !1
  18328. for (
  18329. var a,
  18330. b = e.getFixedLayer(),
  18331. c = g.getElementsByTagName(b, 'div', function (a) {
  18332. return g.hasClass(a, 'edui-shortcutsubmenu edui-popup')
  18333. }),
  18334. d = 0;
  18335. (a = c[d++]);
  18336. )
  18337. 'none' != a.style.display && (i = !0)
  18338. return i
  18339. },
  18340. show: function (a, b) {
  18341. function c(a) {
  18342. a.left < 0 && (a.left = 0),
  18343. a.top < 0 && (a.top = 0),
  18344. (i.style.cssText =
  18345. 'position:absolute;left:' +
  18346. a.left +
  18347. 'px;top:' +
  18348. a.top +
  18349. 'px;')
  18350. }
  18351. function d(a) {
  18352. a.tagName || (a = a.getDom()),
  18353. (h.left = parseInt(a.style.left)),
  18354. (h.top = parseInt(a.style.top)),
  18355. (h.top -= i.offsetHeight + 15),
  18356. c(h)
  18357. }
  18358. var f = this,
  18359. h = {},
  18360. i = this.getDom(),
  18361. j = e.getFixedLayer()
  18362. if (
  18363. ((f.eventType = a.type),
  18364. (i.style.cssText = 'display:block;left:-9999px'),
  18365. 'contextmenu' == a.type && b)
  18366. ) {
  18367. var k = g.getElementsByTagName(j, 'div', 'edui-contextmenu')[0]
  18368. k
  18369. ? d(k)
  18370. : f.editor.addListener('aftershowcontextmenu', function (a, b) {
  18371. d(b)
  18372. })
  18373. } else
  18374. (h = e.getViewportOffsetByEvent(a)),
  18375. (h.top -= i.offsetHeight + f.SPACE),
  18376. (h.left += f.SPACE + 20),
  18377. c(h),
  18378. f.setOpacity(i, 0.2)
  18379. ;(f.isHidden = !1),
  18380. (f.left = a.screenX + i.offsetWidth / 2 - f.SPACE),
  18381. (f.top = a.screenY - i.offsetHeight / 2 - f.SPACE),
  18382. f.editor &&
  18383. ((i.style.zIndex = 1 * f.editor.container.style.zIndex + 10),
  18384. (j.style.zIndex = i.style.zIndex - 1))
  18385. },
  18386. hide: function () {
  18387. this.getDom() && (this.getDom().style.display = 'none'),
  18388. (this.isHidden = !0)
  18389. },
  18390. postRender: function () {
  18391. if (f.isArray(this.items))
  18392. for (var a, b = 0; (a = this.items[b++]); ) a.postRender()
  18393. },
  18394. getHtmlTpl: function () {
  18395. var a
  18396. if (f.isArray(this.items)) {
  18397. a = []
  18398. for (var b = 0; b < this.items.length; b++)
  18399. a[b] = this.items[b].renderHtml()
  18400. a = a.join('')
  18401. } else a = this.items
  18402. return (
  18403. '<div id="##" class="%% edui-toolbar" data-src="shortcutmenu" onmousedown="return false;" onselectstart="return false;" >' +
  18404. a +
  18405. '</div>'
  18406. )
  18407. }
  18408. }),
  18409. f.inherits(j, d),
  18410. g.on(document, 'mousedown', function (b) {
  18411. a(b)
  18412. }),
  18413. g.on(window, 'scroll', function (b) {
  18414. a(b)
  18415. })
  18416. })(),
  18417. (function () {
  18418. var a = baidu.editor.utils,
  18419. b = baidu.editor.ui.UIBase,
  18420. c = (baidu.editor.ui.Breakline = function (a) {
  18421. this.initOptions(a), this.initSeparator()
  18422. })
  18423. ;(c.prototype = {
  18424. uiName: 'Breakline',
  18425. initSeparator: function () {
  18426. this.initUIBase()
  18427. },
  18428. getHtmlTpl: function () {
  18429. return '<br/>'
  18430. }
  18431. }),
  18432. a.inherits(c, b)
  18433. })(),
  18434. (function () {
  18435. var a = baidu.editor.utils,
  18436. b = baidu.editor.dom.domUtils,
  18437. c = baidu.editor.ui.UIBase,
  18438. d = (baidu.editor.ui.Message = function (a) {
  18439. this.initOptions(a), this.initMessage()
  18440. })
  18441. ;(d.prototype = {
  18442. initMessage: function () {
  18443. this.initUIBase()
  18444. },
  18445. getHtmlTpl: function () {
  18446. return '<div id="##" class="edui-message %%"> <div id="##_closer" class="edui-message-closer">×</div> <div id="##_body" class="edui-message-body edui-message-type-info"> <iframe style="position:absolute;z-index:-1;left:0;top:0;background-color: transparent;" frameborder="0" width="100%" height="100%" src="about:blank"></iframe> <div class="edui-shadow"></div> <div id="##_content" class="edui-message-content"> </div> </div></div>'
  18447. },
  18448. reset: function (a) {
  18449. var b = this
  18450. a.keepshow ||
  18451. (clearTimeout(this.timer),
  18452. (b.timer = setTimeout(function () {
  18453. b.hide()
  18454. }, a.timeout || 4e3))),
  18455. void 0 !== a.content && b.setContent(a.content),
  18456. void 0 !== a.type && b.setType(a.type),
  18457. b.show()
  18458. },
  18459. postRender: function () {
  18460. var a = this,
  18461. c = this.getDom('closer')
  18462. c &&
  18463. b.on(c, 'click', function () {
  18464. a.hide()
  18465. })
  18466. },
  18467. setContent: function (a) {
  18468. this.getDom('content').innerHTML = a
  18469. },
  18470. setType: function (a) {
  18471. a = a || 'info'
  18472. var b = this.getDom('body')
  18473. b.className = b.className.replace(
  18474. /edui-message-type-[\w-]+/,
  18475. 'edui-message-type-' + a
  18476. )
  18477. },
  18478. getContent: function () {
  18479. return this.getDom('content').innerHTML
  18480. },
  18481. getType: function () {
  18482. var a = this.getDom('body').match(/edui-message-type-([\w-]+)/)
  18483. return a ? a[1] : ''
  18484. },
  18485. show: function () {
  18486. this.getDom().style.display = 'block'
  18487. },
  18488. hide: function () {
  18489. var a = this.getDom()
  18490. a &&
  18491. ((a.style.display = 'none'),
  18492. a.parentNode && a.parentNode.removeChild(a))
  18493. }
  18494. }),
  18495. a.inherits(d, c)
  18496. })(),
  18497. (function () {
  18498. var a = baidu.editor.utils,
  18499. b = baidu.editor.ui,
  18500. c = b.Dialog
  18501. ;(b.buttons = {}),
  18502. (b.Dialog = function (a) {
  18503. var b = new c(a)
  18504. return (
  18505. b.addListener('hide', function () {
  18506. if (b.editor) {
  18507. var a = b.editor
  18508. try {
  18509. if (browser.gecko) {
  18510. var c = a.window.scrollY,
  18511. d = a.window.scrollX
  18512. a.body.focus(), a.window.scrollTo(d, c)
  18513. } else a.focus()
  18514. } catch (e) {}
  18515. }
  18516. }),
  18517. b
  18518. )
  18519. })
  18520. for (
  18521. var d,
  18522. e = {
  18523. anchor: '~/dialogs/anchor/anchor.html',
  18524. insertimage: '~/dialogs/image/image.html',
  18525. link: '~/dialogs/link/link.html',
  18526. spechars: '~/dialogs/spechars/spechars.html',
  18527. searchreplace: '~/dialogs/searchreplace/searchreplace.html',
  18528. map: '~/dialogs/map/map.html',
  18529. gmap: '~/dialogs/gmap/gmap.html',
  18530. insertvideo: '~/dialogs/video/video.html',
  18531. help: '~/dialogs/help/help.html',
  18532. preview: '~/dialogs/preview/preview.html',
  18533. emotion: '~/dialogs/emotion/emotion.html',
  18534. wordimage: '~/dialogs/wordimage/wordimage.html',
  18535. attachment: '~/dialogs/attachment/attachment.html',
  18536. insertframe: '~/dialogs/insertframe/insertframe.html',
  18537. edittip: '~/dialogs/table/edittip.html',
  18538. edittable: '~/dialogs/table/edittable.html',
  18539. edittd: '~/dialogs/table/edittd.html',
  18540. webapp: '~/dialogs/webapp/webapp.html',
  18541. snapscreen: '~/dialogs/snapscreen/snapscreen.html',
  18542. scrawl: '~/dialogs/scrawl/scrawl.html',
  18543. music: '~/dialogs/music/music.html',
  18544. template: '~/dialogs/template/template.html',
  18545. background: '~/dialogs/background/background.html',
  18546. charts: '~/dialogs/charts/charts.html'
  18547. },
  18548. f = [
  18549. 'undo',
  18550. 'redo',
  18551. 'formatmatch',
  18552. 'bold',
  18553. 'italic',
  18554. 'underline',
  18555. 'fontborder',
  18556. 'touppercase',
  18557. 'tolowercase',
  18558. 'strikethrough',
  18559. 'subscript',
  18560. 'superscript',
  18561. 'source',
  18562. 'indent',
  18563. 'outdent',
  18564. 'blockquote',
  18565. 'pasteplain',
  18566. 'pagebreak',
  18567. 'selectall',
  18568. 'print',
  18569. 'horizontal',
  18570. 'removeformat',
  18571. 'time',
  18572. 'date',
  18573. 'unlink',
  18574. 'insertparagraphbeforetable',
  18575. 'insertrow',
  18576. 'insertcol',
  18577. 'mergeright',
  18578. 'mergedown',
  18579. 'deleterow',
  18580. 'deletecol',
  18581. 'splittorows',
  18582. 'splittocols',
  18583. 'splittocells',
  18584. 'mergecells',
  18585. 'deletetable',
  18586. 'drafts'
  18587. ],
  18588. g = 0;
  18589. (d = f[g++]);
  18590. )
  18591. (d = d.toLowerCase()),
  18592. (b[d] = (function (a) {
  18593. return function (c) {
  18594. var d = new b.Button({
  18595. className: 'edui-for-' + a,
  18596. title:
  18597. c.options.labelMap[a] || c.getLang('labelMap.' + a) || '',
  18598. onclick: function () {
  18599. c.execCommand(a)
  18600. },
  18601. theme: c.options.theme,
  18602. showText: !1
  18603. })
  18604. return (
  18605. (b.buttons[a] = d),
  18606. c.addListener('selectionchange', function (b, e, f) {
  18607. var g = c.queryCommandState(a)
  18608. g == -1
  18609. ? (d.setDisabled(!0), d.setChecked(!1))
  18610. : f || (d.setDisabled(!1), d.setChecked(g))
  18611. }),
  18612. d
  18613. )
  18614. }
  18615. })(d))
  18616. b.cleardoc = function (a) {
  18617. var c = new b.Button({
  18618. className: 'edui-for-cleardoc',
  18619. title:
  18620. a.options.labelMap.cleardoc || a.getLang('labelMap.cleardoc') || '',
  18621. theme: a.options.theme,
  18622. onclick: function () {
  18623. confirm(a.getLang('confirmClear')) && a.execCommand('cleardoc')
  18624. }
  18625. })
  18626. return (
  18627. (b.buttons.cleardoc = c),
  18628. a.addListener('selectionchange', function () {
  18629. c.setDisabled(a.queryCommandState('cleardoc') == -1)
  18630. }),
  18631. c
  18632. )
  18633. }
  18634. var h = {
  18635. justify: ['left', 'right', 'center', 'justify'],
  18636. imagefloat: ['none', 'left', 'center', 'right'],
  18637. directionality: ['ltr', 'rtl']
  18638. }
  18639. for (var i in h)
  18640. !(function (a, c) {
  18641. for (var d, e = 0; (d = c[e++]); )
  18642. !(function (c) {
  18643. b[a.replace('float', '') + c] = function (d) {
  18644. var e = new b.Button({
  18645. className: 'edui-for-' + a.replace('float', '') + c,
  18646. title:
  18647. d.options.labelMap[a.replace('float', '') + c] ||
  18648. d.getLang('labelMap.' + a.replace('float', '') + c) ||
  18649. '',
  18650. theme: d.options.theme,
  18651. onclick: function () {
  18652. d.execCommand(a, c)
  18653. }
  18654. })
  18655. return (
  18656. (b.buttons[a] = e),
  18657. d.addListener('selectionchange', function (b, f, g) {
  18658. e.setDisabled(d.queryCommandState(a) == -1),
  18659. e.setChecked(d.queryCommandValue(a) == c && !g)
  18660. }),
  18661. e
  18662. )
  18663. }
  18664. })(d)
  18665. })(i, h[i])
  18666. for (var d, g = 0; (d = ['backcolor', 'forecolor'][g++]); )
  18667. b[d] = (function (a) {
  18668. return function (c) {
  18669. var d = new b.ColorButton({
  18670. className: 'edui-for-' + a,
  18671. color: 'default',
  18672. title: c.options.labelMap[a] || c.getLang('labelMap.' + a) || '',
  18673. editor: c,
  18674. onpickcolor: function (b, d) {
  18675. c.execCommand(a, d)
  18676. },
  18677. onpicknocolor: function () {
  18678. c.execCommand(a, 'default'),
  18679. this.setColor('transparent'),
  18680. (this.color = 'default')
  18681. },
  18682. onbuttonclick: function () {
  18683. c.execCommand(a, this.color)
  18684. }
  18685. })
  18686. return (
  18687. (b.buttons[a] = d),
  18688. c.addListener('selectionchange', function () {
  18689. d.setDisabled(c.queryCommandState(a) == -1)
  18690. }),
  18691. d
  18692. )
  18693. }
  18694. })(d)
  18695. var j = {
  18696. noOk: ['searchreplace', 'help', 'spechars', 'webapp', 'preview'],
  18697. ok: [
  18698. 'attachment',
  18699. 'anchor',
  18700. 'link',
  18701. 'insertimage',
  18702. 'map',
  18703. 'gmap',
  18704. 'insertframe',
  18705. 'wordimage',
  18706. 'insertvideo',
  18707. 'insertframe',
  18708. 'edittip',
  18709. 'edittable',
  18710. 'edittd',
  18711. 'scrawl',
  18712. 'template',
  18713. 'music',
  18714. 'background',
  18715. 'charts'
  18716. ]
  18717. }
  18718. for (var i in j)
  18719. !(function (c, d) {
  18720. for (var f, g = 0; (f = d[g++]); )
  18721. (browser.opera && 'searchreplace' === f) ||
  18722. !(function (d) {
  18723. b[d] = function (f, g, h) {
  18724. ;(g = g || (f.options.iframeUrlMap || {})[d] || e[d]),
  18725. (h =
  18726. f.options.labelMap[d] || f.getLang('labelMap.' + d) || '')
  18727. var i
  18728. g &&
  18729. ((i = new b.Dialog(
  18730. a.extend(
  18731. {
  18732. iframeUrl: f.ui.mapUrl(g),
  18733. editor: f,
  18734. className: 'edui-for-' + d,
  18735. title: h,
  18736. holdScroll: 'insertimage' === d,
  18737. fullscreen: /charts|preview/.test(d),
  18738. closeDialog: f.getLang('closeDialog')
  18739. },
  18740. 'ok' == c
  18741. ? {
  18742. buttons: [
  18743. {
  18744. className: 'edui-okbutton',
  18745. label: f.getLang('ok'),
  18746. editor: f,
  18747. onclick: function () {
  18748. i.close(!0)
  18749. }
  18750. },
  18751. {
  18752. className: 'edui-cancelbutton',
  18753. label: f.getLang('cancel'),
  18754. editor: f,
  18755. onclick: function () {
  18756. i.close(!1)
  18757. }
  18758. }
  18759. ]
  18760. }
  18761. : {}
  18762. )
  18763. )),
  18764. (f.ui._dialogs[d + 'Dialog'] = i))
  18765. var j = new b.Button({
  18766. className: 'edui-for-' + d,
  18767. title: h,
  18768. onclick: function () {
  18769. if (i)
  18770. switch (d) {
  18771. case 'wordimage':
  18772. var a = f.execCommand('wordimage')
  18773. a && a.length && (i.render(), i.open())
  18774. break
  18775. case 'scrawl':
  18776. f.queryCommandState('scrawl') != -1 &&
  18777. (i.render(), i.open())
  18778. break
  18779. default:
  18780. i.render(), i.open()
  18781. }
  18782. },
  18783. theme: f.options.theme,
  18784. disabled:
  18785. ('scrawl' == d && f.queryCommandState('scrawl') == -1) ||
  18786. 'charts' == d
  18787. })
  18788. return (
  18789. (b.buttons[d] = j),
  18790. f.addListener('selectionchange', function () {
  18791. var a = { edittable: 1 }
  18792. if (!(d in a)) {
  18793. var b = f.queryCommandState(d)
  18794. j.getDom() && (j.setDisabled(b == -1), j.setChecked(b))
  18795. }
  18796. }),
  18797. j
  18798. )
  18799. }
  18800. })(f.toLowerCase())
  18801. })(i, j[i])
  18802. ;(b.snapscreen = function (a, c, d) {
  18803. d =
  18804. a.options.labelMap.snapscreen ||
  18805. a.getLang('labelMap.snapscreen') ||
  18806. ''
  18807. var f = new b.Button({
  18808. className: 'edui-for-snapscreen',
  18809. title: d,
  18810. onclick: function () {
  18811. a.execCommand('snapscreen')
  18812. },
  18813. theme: a.options.theme
  18814. })
  18815. if (
  18816. ((b.buttons.snapscreen = f),
  18817. (c = c || (a.options.iframeUrlMap || {}).snapscreen || e.snapscreen))
  18818. ) {
  18819. var g = new b.Dialog({
  18820. iframeUrl: a.ui.mapUrl(c),
  18821. editor: a,
  18822. className: 'edui-for-snapscreen',
  18823. title: d,
  18824. buttons: [
  18825. {
  18826. className: 'edui-okbutton',
  18827. label: a.getLang('ok'),
  18828. editor: a,
  18829. onclick: function () {
  18830. g.close(!0)
  18831. }
  18832. },
  18833. {
  18834. className: 'edui-cancelbutton',
  18835. label: a.getLang('cancel'),
  18836. editor: a,
  18837. onclick: function () {
  18838. g.close(!1)
  18839. }
  18840. }
  18841. ]
  18842. })
  18843. g.render(), (a.ui._dialogs.snapscreenDialog = g)
  18844. }
  18845. return (
  18846. a.addListener('selectionchange', function () {
  18847. f.setDisabled(a.queryCommandState('snapscreen') == -1)
  18848. }),
  18849. f
  18850. )
  18851. }),
  18852. (b.insertcode = function (c, d, e) {
  18853. ;(d = c.options.insertcode || []),
  18854. (e =
  18855. c.options.labelMap.insertcode ||
  18856. c.getLang('labelMap.insertcode') ||
  18857. '')
  18858. var f = []
  18859. a.each(d, function (a, b) {
  18860. f.push({
  18861. label: a,
  18862. value: b,
  18863. theme: c.options.theme,
  18864. renderLabelHtml: function () {
  18865. return (
  18866. '<div class="edui-label %%-label" >' +
  18867. (this.label || '') +
  18868. '</div>'
  18869. )
  18870. }
  18871. })
  18872. })
  18873. var g = new b.Combox({
  18874. editor: c,
  18875. items: f,
  18876. onselect: function (a, b) {
  18877. c.execCommand('insertcode', this.items[b].value)
  18878. },
  18879. onbuttonclick: function () {
  18880. this.showPopup()
  18881. },
  18882. title: e,
  18883. initValue: e,
  18884. className: 'edui-for-insertcode',
  18885. indexByValue: function (a) {
  18886. if (a)
  18887. for (var b, c = 0; (b = this.items[c]); c++)
  18888. if (b.value.indexOf(a) != -1) return c
  18889. return -1
  18890. }
  18891. })
  18892. return (
  18893. (b.buttons.insertcode = g),
  18894. c.addListener('selectionchange', function (a, b, d) {
  18895. if (!d) {
  18896. var f = c.queryCommandState('insertcode')
  18897. if (f == -1) g.setDisabled(!0)
  18898. else {
  18899. g.setDisabled(!1)
  18900. var h = c.queryCommandValue('insertcode')
  18901. if (!h) return void g.setValue(e)
  18902. h && (h = h.replace(/['"]/g, '').split(',')[0]), g.setValue(h)
  18903. }
  18904. }
  18905. }),
  18906. g
  18907. )
  18908. }),
  18909. (b.fontfamily = function (c, d, e) {
  18910. if (
  18911. ((d = c.options.fontfamily || []),
  18912. (e =
  18913. c.options.labelMap.fontfamily ||
  18914. c.getLang('labelMap.fontfamily') ||
  18915. ''),
  18916. d.length)
  18917. ) {
  18918. for (var f, g = 0, h = []; (f = d[g]); g++) {
  18919. var i = c.getLang('fontfamily')[f.name] || ''
  18920. !(function (b, d) {
  18921. h.push({
  18922. label: b,
  18923. value: d,
  18924. theme: c.options.theme,
  18925. renderLabelHtml: function () {
  18926. return (
  18927. '<div class="edui-label %%-label" style="font-family:' +
  18928. a.unhtml(this.value) +
  18929. '">' +
  18930. (this.label || '') +
  18931. '</div>'
  18932. )
  18933. }
  18934. })
  18935. })(f.label || i, f.val)
  18936. }
  18937. var j = new b.Combox({
  18938. editor: c,
  18939. items: h,
  18940. onselect: function (a, b) {
  18941. c.execCommand('FontFamily', this.items[b].value)
  18942. },
  18943. onbuttonclick: function () {
  18944. this.showPopup()
  18945. },
  18946. title: e,
  18947. initValue: e,
  18948. className: 'edui-for-fontfamily',
  18949. indexByValue: function (a) {
  18950. if (a)
  18951. for (var b, c = 0; (b = this.items[c]); c++)
  18952. if (b.value.indexOf(a) != -1) return c
  18953. return -1
  18954. }
  18955. })
  18956. return (
  18957. (b.buttons.fontfamily = j),
  18958. c.addListener('selectionchange', function (a, b, d) {
  18959. if (!d) {
  18960. var e = c.queryCommandState('FontFamily')
  18961. if (e == -1) j.setDisabled(!0)
  18962. else {
  18963. j.setDisabled(!1)
  18964. var f = c.queryCommandValue('FontFamily')
  18965. f && (f = f.replace(/['"]/g, '').split(',')[0]),
  18966. j.setValue(f)
  18967. }
  18968. }
  18969. }),
  18970. j
  18971. )
  18972. }
  18973. }),
  18974. (b.fontsize = function (a, c, d) {
  18975. if (
  18976. ((d =
  18977. a.options.labelMap.fontsize ||
  18978. a.getLang('labelMap.fontsize') ||
  18979. ''),
  18980. (c = c || a.options.fontsize || []),
  18981. c.length)
  18982. ) {
  18983. for (var e = [], f = 0; f < c.length; f++) {
  18984. var g = c[f] + 'px'
  18985. e.push({
  18986. label: g,
  18987. value: g,
  18988. theme: a.options.theme,
  18989. renderLabelHtml: function () {
  18990. return (
  18991. '<div class="edui-label %%-label" style="line-height:1;font-size:' +
  18992. this.value +
  18993. '">' +
  18994. (this.label || '') +
  18995. '</div>'
  18996. )
  18997. }
  18998. })
  18999. }
  19000. var h = new b.Combox({
  19001. editor: a,
  19002. items: e,
  19003. title: d,
  19004. initValue: d,
  19005. onselect: function (b, c) {
  19006. a.execCommand('FontSize', this.items[c].value)
  19007. },
  19008. onbuttonclick: function () {
  19009. this.showPopup()
  19010. },
  19011. className: 'edui-for-fontsize'
  19012. })
  19013. return (
  19014. (b.buttons.fontsize = h),
  19015. a.addListener('selectionchange', function (b, c, d) {
  19016. if (!d) {
  19017. var e = a.queryCommandState('FontSize')
  19018. e == -1
  19019. ? h.setDisabled(!0)
  19020. : (h.setDisabled(!1),
  19021. h.setValue(a.queryCommandValue('FontSize')))
  19022. }
  19023. }),
  19024. h
  19025. )
  19026. }
  19027. }),
  19028. (b.paragraph = function (c, d, e) {
  19029. if (
  19030. ((e =
  19031. c.options.labelMap.paragraph ||
  19032. c.getLang('labelMap.paragraph') ||
  19033. ''),
  19034. (d = c.options.paragraph || []),
  19035. !a.isEmptyObject(d))
  19036. ) {
  19037. var f = []
  19038. for (var g in d)
  19039. f.push({
  19040. value: g,
  19041. label: d[g] || c.getLang('paragraph')[g],
  19042. theme: c.options.theme,
  19043. renderLabelHtml: function () {
  19044. return (
  19045. '<div class="edui-label %%-label"><span class="edui-for-' +
  19046. this.value +
  19047. '">' +
  19048. (this.label || '') +
  19049. '</span></div>'
  19050. )
  19051. }
  19052. })
  19053. var h = new b.Combox({
  19054. editor: c,
  19055. items: f,
  19056. title: e,
  19057. initValue: e,
  19058. className: 'edui-for-paragraph',
  19059. onselect: function (a, b) {
  19060. c.execCommand('Paragraph', this.items[b].value)
  19061. },
  19062. onbuttonclick: function () {
  19063. this.showPopup()
  19064. }
  19065. })
  19066. return (
  19067. (b.buttons.paragraph = h),
  19068. c.addListener('selectionchange', function (a, b, d) {
  19069. if (!d) {
  19070. var e = c.queryCommandState('Paragraph')
  19071. if (e == -1) h.setDisabled(!0)
  19072. else {
  19073. h.setDisabled(!1)
  19074. var f = c.queryCommandValue('Paragraph'),
  19075. g = h.indexByValue(f)
  19076. g != -1 ? h.setValue(f) : h.setValue(h.initValue)
  19077. }
  19078. }
  19079. }),
  19080. h
  19081. )
  19082. }
  19083. }),
  19084. (b.customstyle = function (a) {
  19085. var c = a.options.customstyle || [],
  19086. d =
  19087. a.options.labelMap.customstyle ||
  19088. a.getLang('labelMap.customstyle') ||
  19089. ''
  19090. if (c.length) {
  19091. for (
  19092. var e, f = a.getLang('customstyle'), g = 0, h = [];
  19093. (e = c[g++]);
  19094. )
  19095. !(function (b) {
  19096. var c = {}
  19097. ;(c.label = b.label ? b.label : f[b.name]),
  19098. (c.style = b.style),
  19099. (c.className = b.className),
  19100. (c.tag = b.tag),
  19101. h.push({
  19102. label: c.label,
  19103. value: c,
  19104. theme: a.options.theme,
  19105. renderLabelHtml: function () {
  19106. return (
  19107. '<div class="edui-label %%-label"><' +
  19108. c.tag +
  19109. ' ' +
  19110. (c.className ? ' class="' + c.className + '"' : '') +
  19111. (c.style ? ' style="' + c.style + '"' : '') +
  19112. '>' +
  19113. c.label +
  19114. '</' +
  19115. c.tag +
  19116. '></div>'
  19117. )
  19118. }
  19119. })
  19120. })(e)
  19121. var i = new b.Combox({
  19122. editor: a,
  19123. items: h,
  19124. title: d,
  19125. initValue: d,
  19126. className: 'edui-for-customstyle',
  19127. onselect: function (b, c) {
  19128. a.execCommand('customstyle', this.items[c].value)
  19129. },
  19130. onbuttonclick: function () {
  19131. this.showPopup()
  19132. },
  19133. indexByValue: function (a) {
  19134. for (var b, c = 0; (b = this.items[c++]); )
  19135. if (b.label == a) return c - 1
  19136. return -1
  19137. }
  19138. })
  19139. return (
  19140. (b.buttons.customstyle = i),
  19141. a.addListener('selectionchange', function (b, c, d) {
  19142. if (!d) {
  19143. var e = a.queryCommandState('customstyle')
  19144. if (e == -1) i.setDisabled(!0)
  19145. else {
  19146. i.setDisabled(!1)
  19147. var f = a.queryCommandValue('customstyle'),
  19148. g = i.indexByValue(f)
  19149. g != -1 ? i.setValue(f) : i.setValue(i.initValue)
  19150. }
  19151. }
  19152. }),
  19153. i
  19154. )
  19155. }
  19156. }),
  19157. (b.inserttable = function (a, c, d) {
  19158. d =
  19159. a.options.labelMap.inserttable ||
  19160. a.getLang('labelMap.inserttable') ||
  19161. ''
  19162. var e = new b.TableButton({
  19163. editor: a,
  19164. title: d,
  19165. className: 'edui-for-inserttable',
  19166. onpicktable: function (b, c, d) {
  19167. a.execCommand('InsertTable', {
  19168. numRows: d,
  19169. numCols: c,
  19170. border: 1
  19171. })
  19172. },
  19173. onbuttonclick: function () {
  19174. this.showPopup()
  19175. }
  19176. })
  19177. return (
  19178. (b.buttons.inserttable = e),
  19179. a.addListener('selectionchange', function () {
  19180. e.setDisabled(a.queryCommandState('inserttable') == -1)
  19181. }),
  19182. e
  19183. )
  19184. }),
  19185. (b.lineheight = function (a) {
  19186. var c = a.options.lineheight || []
  19187. if (c.length) {
  19188. for (var d, e = 0, f = []; (d = c[e++]); )
  19189. f.push({
  19190. label: d,
  19191. value: d,
  19192. theme: a.options.theme,
  19193. onclick: function () {
  19194. a.execCommand('lineheight', this.value)
  19195. }
  19196. })
  19197. var g = new b.MenuButton({
  19198. editor: a,
  19199. className: 'edui-for-lineheight',
  19200. title:
  19201. a.options.labelMap.lineheight ||
  19202. a.getLang('labelMap.lineheight') ||
  19203. '',
  19204. items: f,
  19205. onbuttonclick: function () {
  19206. var b = a.queryCommandValue('LineHeight') || this.value
  19207. a.execCommand('LineHeight', b)
  19208. }
  19209. })
  19210. return (
  19211. (b.buttons.lineheight = g),
  19212. a.addListener('selectionchange', function () {
  19213. var b = a.queryCommandState('LineHeight')
  19214. if (b == -1) g.setDisabled(!0)
  19215. else {
  19216. g.setDisabled(!1)
  19217. var c = a.queryCommandValue('LineHeight')
  19218. c && g.setValue((c + '').replace(/cm/, '')), g.setChecked(b)
  19219. }
  19220. }),
  19221. g
  19222. )
  19223. }
  19224. })
  19225. for (var k, l = ['top', 'bottom'], m = 0; (k = l[m++]); )
  19226. !(function (a) {
  19227. b['rowspacing' + a] = function (c) {
  19228. var d = c.options['rowspacing' + a] || []
  19229. if (!d.length) return null
  19230. for (var e, f = 0, g = []; (e = d[f++]); )
  19231. g.push({
  19232. label: e,
  19233. value: e,
  19234. theme: c.options.theme,
  19235. onclick: function () {
  19236. c.execCommand('rowspacing', this.value, a)
  19237. }
  19238. })
  19239. var h = new b.MenuButton({
  19240. editor: c,
  19241. className: 'edui-for-rowspacing' + a,
  19242. title:
  19243. c.options.labelMap['rowspacing' + a] ||
  19244. c.getLang('labelMap.rowspacing' + a) ||
  19245. '',
  19246. items: g,
  19247. onbuttonclick: function () {
  19248. var b = c.queryCommandValue('rowspacing', a) || this.value
  19249. c.execCommand('rowspacing', b, a)
  19250. }
  19251. })
  19252. return (
  19253. (b.buttons[a] = h),
  19254. c.addListener('selectionchange', function () {
  19255. var b = c.queryCommandState('rowspacing', a)
  19256. if (b == -1) h.setDisabled(!0)
  19257. else {
  19258. h.setDisabled(!1)
  19259. var d = c.queryCommandValue('rowspacing', a)
  19260. d && h.setValue((d + '').replace(/%/, '')), h.setChecked(b)
  19261. }
  19262. }),
  19263. h
  19264. )
  19265. }
  19266. })(k)
  19267. for (
  19268. var n, o = ['insertorderedlist', 'insertunorderedlist'], p = 0;
  19269. (n = o[p++]);
  19270. )
  19271. !(function (a) {
  19272. b[a] = function (c) {
  19273. var d = c.options[a],
  19274. e = function () {
  19275. c.execCommand(a, this.value)
  19276. },
  19277. f = []
  19278. for (var g in d)
  19279. f.push({
  19280. label: d[g] || c.getLang()[a][g] || '',
  19281. value: g,
  19282. theme: c.options.theme,
  19283. onclick: e
  19284. })
  19285. var h = new b.MenuButton({
  19286. editor: c,
  19287. className: 'edui-for-' + a,
  19288. title: c.getLang('labelMap.' + a) || '',
  19289. items: f,
  19290. onbuttonclick: function () {
  19291. var b = c.queryCommandValue(a) || this.value
  19292. c.execCommand(a, b)
  19293. }
  19294. })
  19295. return (
  19296. (b.buttons[a] = h),
  19297. c.addListener('selectionchange', function () {
  19298. var b = c.queryCommandState(a)
  19299. if (b == -1) h.setDisabled(!0)
  19300. else {
  19301. h.setDisabled(!1)
  19302. var d = c.queryCommandValue(a)
  19303. h.setValue(d), h.setChecked(b)
  19304. }
  19305. }),
  19306. h
  19307. )
  19308. }
  19309. })(n)
  19310. ;(b.fullscreen = function (a, c) {
  19311. c =
  19312. a.options.labelMap.fullscreen ||
  19313. a.getLang('labelMap.fullscreen') ||
  19314. ''
  19315. var d = new b.Button({
  19316. className: 'edui-for-fullscreen',
  19317. title: c,
  19318. theme: a.options.theme,
  19319. onclick: function () {
  19320. a.ui && a.ui.setFullScreen(!a.ui.isFullScreen()),
  19321. this.setChecked(a.ui.isFullScreen())
  19322. }
  19323. })
  19324. return (
  19325. (b.buttons.fullscreen = d),
  19326. a.addListener('selectionchange', function () {
  19327. var b = a.queryCommandState('fullscreen')
  19328. d.setDisabled(b == -1), d.setChecked(a.ui.isFullScreen())
  19329. }),
  19330. d
  19331. )
  19332. }),
  19333. (b.emotion = function (a, c) {
  19334. var d = 'emotion',
  19335. f = new b.MultiMenuPop({
  19336. title: a.options.labelMap[d] || a.getLang('labelMap.' + d) || '',
  19337. editor: a,
  19338. className: 'edui-for-' + d,
  19339. iframeUrl: a.ui.mapUrl(
  19340. c || (a.options.iframeUrlMap || {})[d] || e[d]
  19341. )
  19342. })
  19343. return (
  19344. (b.buttons[d] = f),
  19345. a.addListener('selectionchange', function () {
  19346. f.setDisabled(a.queryCommandState(d) == -1)
  19347. }),
  19348. f
  19349. )
  19350. }),
  19351. (b.autotypeset = function (a) {
  19352. var c = new b.AutoTypeSetButton({
  19353. editor: a,
  19354. title:
  19355. a.options.labelMap.autotypeset ||
  19356. a.getLang('labelMap.autotypeset') ||
  19357. '',
  19358. className: 'edui-for-autotypeset',
  19359. onbuttonclick: function () {
  19360. a.execCommand('autotypeset')
  19361. }
  19362. })
  19363. return (
  19364. (b.buttons.autotypeset = c),
  19365. a.addListener('selectionchange', function () {
  19366. c.setDisabled(a.queryCommandState('autotypeset') == -1)
  19367. }),
  19368. c
  19369. )
  19370. }),
  19371. (b.simpleupload = function (a) {
  19372. var c = 'simpleupload',
  19373. d = new b.Button({
  19374. className: 'edui-for-' + c,
  19375. title: a.options.labelMap[c] || a.getLang('labelMap.' + c) || '',
  19376. onclick: function () {},
  19377. theme: a.options.theme,
  19378. showText: !1
  19379. })
  19380. return (
  19381. (b.buttons[c] = d),
  19382. a.addListener('ready', function () {
  19383. var b = d.getDom('body'),
  19384. c = b.children[0]
  19385. a.fireEvent('simpleuploadbtnready', c)
  19386. }),
  19387. a.addListener('selectionchange', function (b, e, f) {
  19388. var g = a.queryCommandState(c)
  19389. g == -1
  19390. ? (d.setDisabled(!0), d.setChecked(!1))
  19391. : f || (d.setDisabled(!1), d.setChecked(g))
  19392. }),
  19393. d
  19394. )
  19395. })
  19396. })(),
  19397. (function () {
  19398. function a(a) {
  19399. this.initOptions(a), this.initEditorUI()
  19400. }
  19401. var b = baidu.editor.utils,
  19402. c = baidu.editor.ui.uiUtils,
  19403. d = baidu.editor.ui.UIBase,
  19404. e = baidu.editor.dom.domUtils,
  19405. f = []
  19406. ;(a.prototype = {
  19407. uiName: 'editor',
  19408. initEditorUI: function () {
  19409. function a(a, b) {
  19410. a.setOpt({
  19411. wordCount: !0,
  19412. maximumWords: 1e4,
  19413. wordCountMsg: a.options.wordCountMsg || a.getLang('wordCountMsg'),
  19414. wordOverFlowMsg:
  19415. a.options.wordOverFlowMsg || a.getLang('wordOverFlowMsg')
  19416. })
  19417. var c = a.options,
  19418. d = c.maximumWords,
  19419. e = c.wordCountMsg,
  19420. f = c.wordOverFlowMsg,
  19421. g = b.getDom('wordcount')
  19422. if (c.wordCount) {
  19423. var h = a.getContentLength(!0)
  19424. h > d
  19425. ? ((g.innerHTML = f), a.fireEvent('wordcountoverflow'))
  19426. : (g.innerHTML = e
  19427. .replace('{#leave}', d - h)
  19428. .replace('{#count}', h))
  19429. }
  19430. }
  19431. ;(this.editor.ui = this),
  19432. (this._dialogs = {}),
  19433. this.initUIBase(),
  19434. this._initToolbars()
  19435. var b = this.editor,
  19436. c = this
  19437. b.addListener('ready', function () {
  19438. function d() {
  19439. a(b, c), e.un(b.document, 'click', arguments.callee)
  19440. }
  19441. ;(b.getDialog = function (a) {
  19442. return b.ui._dialogs[a + 'Dialog']
  19443. }),
  19444. e.on(b.window, 'scroll', function (a) {
  19445. baidu.editor.ui.Popup.postHide(a)
  19446. }),
  19447. (b.ui._actualFrameWidth = b.options.initialFrameWidth),
  19448. UE.browser.ie &&
  19449. 6 === UE.browser.version &&
  19450. b.container.ownerDocument.execCommand(
  19451. 'BackgroundImageCache',
  19452. !1,
  19453. !0
  19454. ),
  19455. b.options.elementPathEnabled &&
  19456. (b.ui.getDom('elementpath').innerHTML =
  19457. '<div class="edui-editor-breadcrumb">' +
  19458. b.getLang('elementPathTip') +
  19459. ':</div>'),
  19460. b.options.wordCount &&
  19461. (e.on(b.document, 'click', d),
  19462. (b.ui.getDom('wordcount').innerHTML =
  19463. b.getLang('wordCountTip'))),
  19464. b.ui._scale(),
  19465. b.options.scaleEnabled
  19466. ? (b.autoHeightEnabled && b.disableAutoHeight(),
  19467. c.enableScale())
  19468. : c.disableScale(),
  19469. b.options.elementPathEnabled ||
  19470. b.options.wordCount ||
  19471. b.options.scaleEnabled ||
  19472. ((b.ui.getDom('elementpath').style.display = 'none'),
  19473. (b.ui.getDom('wordcount').style.display = 'none'),
  19474. (b.ui.getDom('scale').style.display = 'none')),
  19475. b.selection.isFocus() && b.fireEvent('selectionchange', !1, !0)
  19476. }),
  19477. b.addListener('mousedown', function (a, b) {
  19478. var c = b.target || b.srcElement
  19479. baidu.editor.ui.Popup.postHide(b, c),
  19480. baidu.editor.ui.ShortCutMenu.postHide(b)
  19481. }),
  19482. b.addListener('delcells', function () {
  19483. UE.ui.edittip && new UE.ui.edittip(b),
  19484. b.getDialog('edittip').open()
  19485. })
  19486. var d,
  19487. f,
  19488. g = !1
  19489. b.addListener('afterpaste', function () {
  19490. b.queryCommandState('pasteplain') ||
  19491. (baidu.editor.ui.PastePicker &&
  19492. ((d = new baidu.editor.ui.Popup({
  19493. content: new baidu.editor.ui.PastePicker({ editor: b }),
  19494. editor: b,
  19495. className: 'edui-wordpastepop'
  19496. })),
  19497. d.render()),
  19498. (g = !0))
  19499. }),
  19500. b.addListener('afterinserthtml', function () {
  19501. clearTimeout(f),
  19502. (f = setTimeout(function () {
  19503. if (d && (g || b.ui._isTransfer)) {
  19504. if (d.isHidden()) {
  19505. var a = e.createElement(b.document, 'span', {
  19506. style: 'line-height:0px;',
  19507. innerHTML: '\ufeff'
  19508. }),
  19509. c = b.selection.getRange()
  19510. c.insertNode(a)
  19511. var f = getDomNode(a, 'firstChild', 'previousSibling')
  19512. f && d.showAnchor(3 == f.nodeType ? f.parentNode : f),
  19513. e.remove(a)
  19514. } else d.show()
  19515. delete b.ui._isTransfer, (g = !1)
  19516. }
  19517. }, 200))
  19518. }),
  19519. b.addListener('contextmenu', function (a, b) {
  19520. baidu.editor.ui.Popup.postHide(b)
  19521. }),
  19522. b.addListener('keydown', function (a, b) {
  19523. d && d.dispose(b)
  19524. var c = b.keyCode || b.which
  19525. b.altKey && 90 == c && UE.ui.buttons.fullscreen.onclick()
  19526. }),
  19527. b.addListener('wordcount', function (b) {
  19528. a(this, c)
  19529. }),
  19530. b.addListener('selectionchange', function () {
  19531. b.options.elementPathEnabled &&
  19532. c[
  19533. (b.queryCommandState('elementpath') == -1 ? 'dis' : 'en') +
  19534. 'ableElementPath'
  19535. ](),
  19536. b.options.scaleEnabled &&
  19537. c[
  19538. (b.queryCommandState('scale') == -1 ? 'dis' : 'en') +
  19539. 'ableScale'
  19540. ]()
  19541. })
  19542. var h = new baidu.editor.ui.Popup({
  19543. editor: b,
  19544. content: '',
  19545. className: 'edui-bubble',
  19546. _onEditButtonClick: function () {
  19547. this.hide(), b.ui._dialogs.linkDialog.open()
  19548. },
  19549. _onImgEditButtonClick: function (a) {
  19550. this.hide(), b.ui._dialogs[a] && b.ui._dialogs[a].open()
  19551. },
  19552. _onImgSetFloat: function (a) {
  19553. this.hide(), b.execCommand('imagefloat', a)
  19554. },
  19555. _setIframeAlign: function (a) {
  19556. var b = h.anchorEl,
  19557. c = b.cloneNode(!0)
  19558. switch (a) {
  19559. case -2:
  19560. c.setAttribute('align', '')
  19561. break
  19562. case -1:
  19563. c.setAttribute('align', 'left')
  19564. break
  19565. case 1:
  19566. c.setAttribute('align', 'right')
  19567. }
  19568. b.parentNode.insertBefore(c, b),
  19569. e.remove(b),
  19570. (h.anchorEl = c),
  19571. h.showAnchor(h.anchorEl)
  19572. },
  19573. _updateIframe: function () {
  19574. var a = (b._iframe = h.anchorEl)
  19575. e.hasClass(a, 'ueditor_baidumap')
  19576. ? (b.selection.getRange().selectNode(a).select(),
  19577. b.ui._dialogs.mapDialog.open(),
  19578. h.hide())
  19579. : (b.ui._dialogs.insertframeDialog.open(), h.hide())
  19580. },
  19581. _onRemoveButtonClick: function (a) {
  19582. b.execCommand(a), this.hide()
  19583. },
  19584. queryAutoHide: function (a) {
  19585. return a &&
  19586. a.ownerDocument == b.document &&
  19587. ('img' == a.tagName.toLowerCase() ||
  19588. e.findParentByTagName(a, 'a', !0))
  19589. ? a !== h.anchorEl
  19590. : baidu.editor.ui.Popup.prototype.queryAutoHide.call(this, a)
  19591. }
  19592. })
  19593. h.render(),
  19594. b.options.imagePopup &&
  19595. (b.addListener('mouseover', function (a, c) {
  19596. c = c || window.event
  19597. var d = c.target || c.srcElement
  19598. if (
  19599. b.ui._dialogs.insertframeDialog &&
  19600. /iframe/gi.test(d.tagName)
  19601. ) {
  19602. var e = h.formatHtml(
  19603. '<nobr>' +
  19604. b.getLang('property') +
  19605. ': <span onclick=$$._setIframeAlign(-2) class="edui-clickable">' +
  19606. b.getLang('default') +
  19607. '</span>&nbsp;&nbsp;<span onclick=$$._setIframeAlign(-1) class="edui-clickable">' +
  19608. b.getLang('justifyleft') +
  19609. '</span>&nbsp;&nbsp;<span onclick=$$._setIframeAlign(1) class="edui-clickable">' +
  19610. b.getLang('justifyright') +
  19611. '</span>&nbsp;&nbsp; <span onclick="$$._updateIframe( this);" class="edui-clickable">' +
  19612. b.getLang('modify') +
  19613. '</span></nobr>'
  19614. )
  19615. e
  19616. ? ((h.getDom('content').innerHTML = e),
  19617. (h.anchorEl = d),
  19618. h.showAnchor(h.anchorEl))
  19619. : h.hide()
  19620. }
  19621. }),
  19622. b.addListener('selectionchange', function (a, c) {
  19623. if (c) {
  19624. var d = '',
  19625. f = '',
  19626. g = b.selection.getRange().getClosedNode(),
  19627. i = b.ui._dialogs
  19628. if (g && 'IMG' == g.tagName) {
  19629. var j = 'insertimageDialog'
  19630. if (
  19631. ((g.className.indexOf('edui-faked-video') == -1 &&
  19632. g.className.indexOf('edui-upload-video') == -1) ||
  19633. (j = 'insertvideoDialog'),
  19634. g.className.indexOf('edui-faked-webapp') != -1 &&
  19635. (j = 'webappDialog'),
  19636. g.src.indexOf('http://api.map.baidu.com') != -1 &&
  19637. (j = 'mapDialog'),
  19638. g.className.indexOf('edui-faked-music') != -1 &&
  19639. (j = 'musicDialog'),
  19640. g.src.indexOf(
  19641. 'http://maps.google.com/maps/api/staticmap'
  19642. ) != -1 && (j = 'gmapDialog'),
  19643. g.getAttribute('anchorname') &&
  19644. ((j = 'anchorDialog'),
  19645. (d = h.formatHtml(
  19646. '<nobr>' +
  19647. b.getLang('property') +
  19648. ': <span onclick=$$._onImgEditButtonClick("anchorDialog") class="edui-clickable">' +
  19649. b.getLang('modify') +
  19650. '</span>&nbsp;&nbsp;<span onclick=$$._onRemoveButtonClick(\'anchor\') class="edui-clickable">' +
  19651. b.getLang('delete') +
  19652. '</span></nobr>'
  19653. ))),
  19654. g.getAttribute('word_img') &&
  19655. ((b.word_img = [g.getAttribute('word_img')]),
  19656. (j = 'wordimageDialog')),
  19657. (e.hasClass(g, 'loadingclass') ||
  19658. e.hasClass(g, 'loaderrorclass')) &&
  19659. (j = ''),
  19660. !i[j])
  19661. )
  19662. return
  19663. ;(f =
  19664. '<nobr>' +
  19665. b.getLang('property') +
  19666. ': <span onclick=$$._onImgSetFloat("none") class="edui-clickable">' +
  19667. b.getLang('default') +
  19668. '</span>&nbsp;&nbsp;<span onclick=$$._onImgSetFloat("left") class="edui-clickable">' +
  19669. b.getLang('justifyleft') +
  19670. '</span>&nbsp;&nbsp;<span onclick=$$._onImgSetFloat("right") class="edui-clickable">' +
  19671. b.getLang('justifyright') +
  19672. '</span>&nbsp;&nbsp;<span onclick=$$._onImgSetFloat("center") class="edui-clickable">' +
  19673. b.getLang('justifycenter') +
  19674. '</span>&nbsp;&nbsp;<span onclick="$$._onImgEditButtonClick(\'' +
  19675. j +
  19676. '\');" class="edui-clickable">' +
  19677. b.getLang('modify') +
  19678. '</span></nobr>'),
  19679. !d && (d = h.formatHtml(f))
  19680. }
  19681. if (b.ui._dialogs.linkDialog) {
  19682. var k,
  19683. l = b.queryCommandValue('link')
  19684. if (
  19685. l &&
  19686. (k = l.getAttribute('_href') || l.getAttribute('href', 2))
  19687. ) {
  19688. var m = k
  19689. k.length > 30 && (m = k.substring(0, 20) + '...'),
  19690. d && (d += '<div style="height:5px;"></div>'),
  19691. (d += h.formatHtml(
  19692. '<nobr>' +
  19693. b.getLang('anthorMsg') +
  19694. ': <a target="_blank" href="' +
  19695. k +
  19696. '" title="' +
  19697. k +
  19698. '" >' +
  19699. m +
  19700. '</a> <span class="edui-clickable" onclick="$$._onEditButtonClick();">' +
  19701. b.getLang('modify') +
  19702. '</span> <span class="edui-clickable" onclick="$$._onRemoveButtonClick(\'unlink\');"> ' +
  19703. b.getLang('clear') +
  19704. '</span></nobr>'
  19705. )),
  19706. h.showAnchor(l)
  19707. }
  19708. }
  19709. d
  19710. ? ((h.getDom('content').innerHTML = d),
  19711. (h.anchorEl = g || l),
  19712. h.showAnchor(h.anchorEl))
  19713. : h.hide()
  19714. }
  19715. }))
  19716. },
  19717. _initToolbars: function () {
  19718. for (
  19719. var a = this.editor, b = this.toolbars || [], c = [], d = 0;
  19720. d < b.length;
  19721. d++
  19722. ) {
  19723. for (
  19724. var e = b[d],
  19725. f = new baidu.editor.ui.Toolbar({ theme: a.options.theme }),
  19726. g = 0;
  19727. g < e.length;
  19728. g++
  19729. ) {
  19730. var h = e[g],
  19731. i = null
  19732. if ('string' == typeof h) {
  19733. if (
  19734. ((h = h.toLowerCase()),
  19735. '|' == h && (h = 'Separator'),
  19736. '||' == h && (h = 'Breakline'),
  19737. baidu.editor.ui[h] && (i = new baidu.editor.ui[h](a)),
  19738. 'fullscreen' == h)
  19739. ) {
  19740. c && c[0]
  19741. ? c[0].items.splice(0, 0, i)
  19742. : i && f.items.splice(0, 0, i)
  19743. continue
  19744. }
  19745. } else i = h
  19746. i && i.id && f.add(i)
  19747. }
  19748. c[d] = f
  19749. }
  19750. for (var j in UE._customizeUI) {
  19751. var k,
  19752. l,
  19753. m = UE._customizeUI[j]
  19754. ;(m.id && m.id != a.key) ||
  19755. ((k = m.execFn.call(a, a, j)),
  19756. k &&
  19757. ((l = m.index),
  19758. void 0 === l && (l = f.items.length),
  19759. f.add(k, l)))
  19760. }
  19761. this.toolbars = c
  19762. },
  19763. getHtmlTpl: function () {
  19764. return (
  19765. '<div id="##" class="%%"><div id="##_toolbarbox" class="%%-toolbarbox">' +
  19766. (this.toolbars.length
  19767. ? '<div id="##_toolbarboxouter" class="%%-toolbarboxouter"><div class="%%-toolbarboxinner">' +
  19768. this.renderToolbarBoxHtml() +
  19769. '</div></div>'
  19770. : '') +
  19771. '<div id="##_toolbarmsg" class="%%-toolbarmsg" style="display:none;"><div id = "##_upload_dialog" class="%%-toolbarmsg-upload" onclick="$$.showWordImageDialog();">' +
  19772. this.editor.getLang('clickToUpload') +
  19773. '</div><div class="%%-toolbarmsg-close" onclick="$$.hideToolbarMsg();">x</div><div id="##_toolbarmsg_label" class="%%-toolbarmsg-label"></div><div style="height:0;overflow:hidden;clear:both;"></div></div><div id="##_message_holder" class="%%-messageholder"></div></div><div id="##_iframeholder" class="%%-iframeholder"></div><div id="##_bottombar" class="%%-bottomContainer"><table><tr><td id="##_elementpath" class="%%-bottombar"></td><td id="##_wordcount" class="%%-wordcount"></td><td id="##_scale" class="%%-scale"><div class="%%-icon"></div></td></tr></table></div><div id="##_scalelayer"></div></div>'
  19774. )
  19775. },
  19776. showWordImageDialog: function () {
  19777. this._dialogs.wordimageDialog.open()
  19778. },
  19779. renderToolbarBoxHtml: function () {
  19780. for (var a = [], b = 0; b < this.toolbars.length; b++)
  19781. a.push(this.toolbars[b].renderHtml())
  19782. return a.join('')
  19783. },
  19784. setFullScreen: function (a) {
  19785. var b = this.editor,
  19786. c = b.container.parentNode.parentNode
  19787. if (this._fullscreen != a) {
  19788. if (
  19789. ((this._fullscreen = a),
  19790. this.editor.fireEvent('beforefullscreenchange', a),
  19791. baidu.editor.browser.gecko)
  19792. )
  19793. var d = b.selection.getRange().createBookmark()
  19794. if (a) {
  19795. for (; 'BODY' != c.tagName; ) {
  19796. var e = baidu.editor.dom.domUtils.getComputedStyle(
  19797. c,
  19798. 'position'
  19799. )
  19800. f.push(e), (c.style.position = 'static'), (c = c.parentNode)
  19801. }
  19802. ;(this._bakHtmlOverflow =
  19803. document.documentElement.style.overflow),
  19804. (this._bakBodyOverflow = document.body.style.overflow),
  19805. (this._bakAutoHeight = this.editor.autoHeightEnabled),
  19806. (this._bakScrollTop = Math.max(
  19807. document.documentElement.scrollTop,
  19808. document.body.scrollTop
  19809. )),
  19810. (this._bakEditorContaninerWidth =
  19811. b.iframe.parentNode.offsetWidth),
  19812. this._bakAutoHeight &&
  19813. ((b.autoHeightEnabled = !1), this.editor.disableAutoHeight()),
  19814. (document.documentElement.style.overflow = 'hidden'),
  19815. window.scrollTo(0, window.scrollY),
  19816. (this._bakCssText = this.getDom().style.cssText),
  19817. (this._bakCssText1 = this.getDom('iframeholder').style.cssText),
  19818. (b.iframe.parentNode.style.width = ''),
  19819. this._updateFullScreen()
  19820. } else {
  19821. for (; 'BODY' != c.tagName; )
  19822. (c.style.position = f.shift()), (c = c.parentNode)
  19823. ;(this.getDom().style.cssText = this._bakCssText),
  19824. (this.getDom('iframeholder').style.cssText = this._bakCssText1),
  19825. this._bakAutoHeight &&
  19826. ((b.autoHeightEnabled = !0), this.editor.enableAutoHeight()),
  19827. (document.documentElement.style.overflow =
  19828. this._bakHtmlOverflow),
  19829. (document.body.style.overflow = this._bakBodyOverflow),
  19830. (b.iframe.parentNode.style.width =
  19831. this._bakEditorContaninerWidth + 'px'),
  19832. window.scrollTo(0, this._bakScrollTop)
  19833. }
  19834. if (browser.gecko && 'true' === b.body.contentEditable) {
  19835. var g = document.createElement('input')
  19836. document.body.appendChild(g),
  19837. (b.body.contentEditable = !1),
  19838. setTimeout(function () {
  19839. g.focus(),
  19840. setTimeout(function () {
  19841. ;(b.body.contentEditable = !0),
  19842. b.fireEvent('fullscreenchanged', a),
  19843. b.selection.getRange().moveToBookmark(d).select(!0),
  19844. baidu.editor.dom.domUtils.remove(g),
  19845. a && window.scroll(0, 0)
  19846. }, 0)
  19847. }, 0)
  19848. }
  19849. 'true' === b.body.contentEditable &&
  19850. (this.editor.fireEvent('fullscreenchanged', a),
  19851. this.triggerLayout())
  19852. }
  19853. },
  19854. _updateFullScreen: function () {
  19855. if (this._fullscreen) {
  19856. var a = c.getViewportRect()
  19857. if (
  19858. ((this.getDom().style.cssText =
  19859. 'border:0;position:absolute;left:0;top:' +
  19860. (this.editor.options.topOffset || 0) +
  19861. 'px;width:' +
  19862. a.width +
  19863. 'px;height:' +
  19864. a.height +
  19865. 'px;z-index:' +
  19866. (1 * this.getDom().style.zIndex + 100)),
  19867. c.setViewportOffset(this.getDom(), {
  19868. left: 0,
  19869. top: this.editor.options.topOffset || 0
  19870. }),
  19871. this.editor.setHeight(
  19872. a.height -
  19873. this.getDom('toolbarbox').offsetHeight -
  19874. this.getDom('bottombar').offsetHeight -
  19875. (this.editor.options.topOffset || 0),
  19876. !0
  19877. ),
  19878. browser.gecko)
  19879. )
  19880. try {
  19881. window.onresize()
  19882. } catch (b) {}
  19883. }
  19884. },
  19885. _updateElementPath: function () {
  19886. var a,
  19887. b = this.getDom('elementpath')
  19888. if (
  19889. this.elementPathEnabled &&
  19890. (a = this.editor.queryCommandValue('elementpath'))
  19891. ) {
  19892. for (var c, d = [], e = 0; (c = a[e]); e++)
  19893. d[e] = this.formatHtml(
  19894. '<span unselectable="on" onclick="$$.editor.execCommand(&quot;elementpath&quot;, &quot;' +
  19895. e +
  19896. '&quot;);">' +
  19897. c +
  19898. '</span>'
  19899. )
  19900. b.innerHTML =
  19901. '<div class="edui-editor-breadcrumb" onmousedown="return false;">' +
  19902. this.editor.getLang('elementPathTip') +
  19903. ': ' +
  19904. d.join(' &gt; ') +
  19905. '</div>'
  19906. } else b.style.display = 'none'
  19907. },
  19908. disableElementPath: function () {
  19909. var a = this.getDom('elementpath')
  19910. ;(a.innerHTML = ''),
  19911. (a.style.display = 'none'),
  19912. (this.elementPathEnabled = !1)
  19913. },
  19914. enableElementPath: function () {
  19915. var a = this.getDom('elementpath')
  19916. ;(a.style.display = ''),
  19917. (this.elementPathEnabled = !0),
  19918. this._updateElementPath()
  19919. },
  19920. _scale: function () {
  19921. function a() {
  19922. ;(o = e.getXY(h)),
  19923. p ||
  19924. (p =
  19925. g.options.minFrameHeight + j.offsetHeight + k.offsetHeight),
  19926. (m.style.cssText =
  19927. 'position:absolute;left:0;display:;top:0;background-color:#41ABFF;opacity:0.4;filter: Alpha(opacity=40);width:' +
  19928. h.offsetWidth +
  19929. 'px;height:' +
  19930. h.offsetHeight +
  19931. 'px;z-index:' +
  19932. (g.options.zIndex + 1)),
  19933. e.on(f, 'mousemove', b),
  19934. e.on(i, 'mouseup', c),
  19935. e.on(f, 'mouseup', c)
  19936. }
  19937. function b(a) {
  19938. d()
  19939. var b = a || window.event
  19940. ;(r = b.pageX || f.documentElement.scrollLeft + b.clientX),
  19941. (s = b.pageY || f.documentElement.scrollTop + b.clientY),
  19942. (t = r - o.x),
  19943. (u = s - o.y),
  19944. t >= q && ((n = !0), (m.style.width = t + 'px')),
  19945. u >= p && ((n = !0), (m.style.height = u + 'px'))
  19946. }
  19947. function c() {
  19948. n &&
  19949. ((n = !1),
  19950. (g.ui._actualFrameWidth = m.offsetWidth - 2),
  19951. (h.style.width = g.ui._actualFrameWidth + 'px'),
  19952. g.setHeight(
  19953. m.offsetHeight - k.offsetHeight - j.offsetHeight - 2,
  19954. !0
  19955. )),
  19956. m && (m.style.display = 'none'),
  19957. d(),
  19958. e.un(f, 'mousemove', b),
  19959. e.un(i, 'mouseup', c),
  19960. e.un(f, 'mouseup', c)
  19961. }
  19962. function d() {
  19963. browser.ie
  19964. ? f.selection.clear()
  19965. : window.getSelection().removeAllRanges()
  19966. }
  19967. var f = document,
  19968. g = this.editor,
  19969. h = g.container,
  19970. i = g.document,
  19971. j = this.getDom('toolbarbox'),
  19972. k = this.getDom('bottombar'),
  19973. l = this.getDom('scale'),
  19974. m = this.getDom('scalelayer'),
  19975. n = !1,
  19976. o = null,
  19977. p = 0,
  19978. q = g.options.minFrameWidth,
  19979. r = 0,
  19980. s = 0,
  19981. t = 0,
  19982. u = 0,
  19983. v = this
  19984. this.editor.addListener('fullscreenchanged', function (a, b) {
  19985. if (b) v.disableScale()
  19986. else if (v.editor.options.scaleEnabled) {
  19987. v.enableScale()
  19988. var c = v.editor.document.createElement('span')
  19989. v.editor.body.appendChild(c),
  19990. (v.editor.body.style.height =
  19991. Math.max(e.getXY(c).y, v.editor.iframe.offsetHeight - 20) +
  19992. 'px'),
  19993. e.remove(c)
  19994. }
  19995. }),
  19996. (this.enableScale = function () {
  19997. 1 != g.queryCommandState('source') &&
  19998. ((l.style.display = ''),
  19999. (this.scaleEnabled = !0),
  20000. e.on(l, 'mousedown', a))
  20001. }),
  20002. (this.disableScale = function () {
  20003. ;(l.style.display = 'none'),
  20004. (this.scaleEnabled = !1),
  20005. e.un(l, 'mousedown', a)
  20006. })
  20007. },
  20008. isFullScreen: function () {
  20009. return this._fullscreen
  20010. },
  20011. postRender: function () {
  20012. d.prototype.postRender.call(this)
  20013. for (var a = 0; a < this.toolbars.length; a++)
  20014. this.toolbars[a].postRender()
  20015. var b,
  20016. c = this,
  20017. e = baidu.editor.dom.domUtils,
  20018. f = function () {
  20019. clearTimeout(b),
  20020. (b = setTimeout(function () {
  20021. c._updateFullScreen()
  20022. }))
  20023. }
  20024. e.on(window, 'resize', f),
  20025. c.addListener('destroy', function () {
  20026. e.un(window, 'resize', f), clearTimeout(b)
  20027. })
  20028. },
  20029. showToolbarMsg: function (a, b) {
  20030. if (
  20031. ((this.getDom('toolbarmsg_label').innerHTML = a),
  20032. (this.getDom('toolbarmsg').style.display = ''),
  20033. !b)
  20034. ) {
  20035. var c = this.getDom('upload_dialog')
  20036. c.style.display = 'none'
  20037. }
  20038. },
  20039. hideToolbarMsg: function () {
  20040. this.getDom('toolbarmsg').style.display = 'none'
  20041. },
  20042. mapUrl: function (a) {
  20043. return a
  20044. ? a.replace('~/', this.editor.options.UEDITOR_HOME_URL || '')
  20045. : ''
  20046. },
  20047. triggerLayout: function () {
  20048. var a = this.getDom()
  20049. '1' == a.style.zoom ? (a.style.zoom = '100%') : (a.style.zoom = '1')
  20050. }
  20051. }),
  20052. b.inherits(a, baidu.editor.ui.UIBase)
  20053. var g = {}
  20054. ;(UE.ui.Editor = function (c) {
  20055. var d = new UE.Editor(c)
  20056. ;(d.options.editor = d),
  20057. b.loadFile(document, {
  20058. href: d.options.themePath + d.options.theme + '/css/ueditor.css',
  20059. tag: 'link',
  20060. type: 'text/css',
  20061. rel: 'stylesheet'
  20062. })
  20063. var f = d.render
  20064. return (
  20065. (d.render = function (c) {
  20066. c.constructor === String && ((d.key = c), (g[c] = d)),
  20067. b.domReady(function () {
  20068. function b() {
  20069. if (
  20070. (d.setOpt({
  20071. labelMap: d.options.labelMap || d.getLang('labelMap')
  20072. }),
  20073. new a(d.options),
  20074. c &&
  20075. (c.constructor === String &&
  20076. (c = document.getElementById(c)),
  20077. c &&
  20078. c.getAttribute('name') &&
  20079. (d.options.textarea = c.getAttribute('name')),
  20080. c && /script|textarea/gi.test(c.tagName)))
  20081. ) {
  20082. var b = document.createElement('div')
  20083. c.parentNode.insertBefore(b, c)
  20084. var g = c.value || c.innerHTML
  20085. ;(d.options.initialContent = /^[\t\r\n ]*$/.test(g)
  20086. ? d.options.initialContent
  20087. : g
  20088. .replace(/>[\n\r\t]+([ ]{4})+/g, '>')
  20089. .replace(/[\n\r\t]+([ ]{4})+</g, '<')
  20090. .replace(/>[\n\r\t]+</g, '><')),
  20091. c.className && (b.className = c.className),
  20092. c.style.cssText && (b.style.cssText = c.style.cssText),
  20093. /textarea/i.test(c.tagName)
  20094. ? ((d.textarea = c),
  20095. (d.textarea.style.display = 'none'))
  20096. : c.parentNode.removeChild(c),
  20097. c.id && ((b.id = c.id), e.removeAttributes(c, 'id')),
  20098. (c = b),
  20099. (c.innerHTML = '')
  20100. }
  20101. e.addClass(c, 'edui-' + d.options.theme), d.ui.render(c)
  20102. var h = d.options
  20103. d.container = d.ui.getDom()
  20104. for (
  20105. var i, j = e.findParents(c, !0), k = [], l = 0;
  20106. (i = j[l]);
  20107. l++
  20108. )
  20109. (k[l] = i.style.display), (i.style.display = 'block')
  20110. if (h.initialFrameWidth) h.minFrameWidth = h.initialFrameWidth
  20111. else {
  20112. h.minFrameWidth = h.initialFrameWidth = c.offsetWidth
  20113. var m = c.style.width
  20114. ;/%$/.test(m) && (h.initialFrameWidth = m)
  20115. }
  20116. h.initialFrameHeight
  20117. ? (h.minFrameHeight = h.initialFrameHeight)
  20118. : (h.initialFrameHeight = h.minFrameHeight = c.offsetHeight)
  20119. for (var i, l = 0; (i = j[l]); l++) i.style.display = k[l]
  20120. c.style.height && (c.style.height = ''),
  20121. (d.container.style.width =
  20122. h.initialFrameWidth +
  20123. (/%$/.test(h.initialFrameWidth) ? '' : 'px')),
  20124. (d.container.style.zIndex = h.zIndex),
  20125. f.call(d, d.ui.getDom('iframeholder')),
  20126. d.fireEvent('afteruiready')
  20127. }
  20128. d.langIsReady ? b() : d.addListener('langReady', b)
  20129. })
  20130. }),
  20131. d
  20132. )
  20133. }),
  20134. (UE.getEditor = function (a, b) {
  20135. var c = g[a]
  20136. return c || ((c = g[a] = new UE.ui.Editor(b)), c.render(a)), c
  20137. }),
  20138. (UE.delEditor = function (a) {
  20139. var b
  20140. ;(b = g[a]) && (b.key && b.destroy(), delete g[a])
  20141. }),
  20142. (UE.registerUI = function (a, c, d, e) {
  20143. b.each(a.split(/\s+/), function (a) {
  20144. UE._customizeUI[a] = { id: e, execFn: c, index: d }
  20145. })
  20146. })
  20147. })(),
  20148. UE.registerUI('message', function (a) {
  20149. function b() {
  20150. var a = g.ui.getDom('toolbarbox')
  20151. a && (c.style.top = a.offsetHeight + 3 + 'px'),
  20152. (c.style.zIndex =
  20153. Math.max(g.options.zIndex, g.iframe.style.zIndex) + 1)
  20154. }
  20155. var c,
  20156. d = baidu.editor.ui,
  20157. e = d.Message,
  20158. f = [],
  20159. g = a
  20160. g.addListener('ready', function () {
  20161. ;(c = document.getElementById(g.ui.id + '_message_holder')), b()
  20162. }),
  20163. g.addListener('showmessage', function (a, d) {
  20164. d = utils.isString(d) ? { content: d } : d
  20165. var h = new e({
  20166. timeout: d.timeout,
  20167. type: d.type,
  20168. content: d.content,
  20169. keepshow: d.keepshow,
  20170. editor: g
  20171. }),
  20172. i = d.id || 'msg_' + (+new Date()).toString(36)
  20173. return h.render(c), (f[i] = h), h.reset(d), b(), i
  20174. }),
  20175. g.addListener('updatemessage', function (a, b, d) {
  20176. d = utils.isString(d) ? { content: d } : d
  20177. var e = f[b]
  20178. e.render(c), e && e.reset(d)
  20179. }),
  20180. g.addListener('hidemessage', function (a, b) {
  20181. var c = f[b]
  20182. c && c.hide()
  20183. })
  20184. }),
  20185. UE.registerUI('autosave', function (a) {
  20186. var b = null,
  20187. c = null
  20188. a.on('afterautosave', function () {
  20189. clearTimeout(b),
  20190. (b = setTimeout(function () {
  20191. c && a.trigger('hidemessage', c),
  20192. (c = a.trigger('showmessage', {
  20193. content: a.getLang('autosave.success'),
  20194. timeout: 2e3
  20195. }))
  20196. }, 2e3))
  20197. })
  20198. })
  20199. })()