tiny_mce_src.js 261 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059
  1. /* file:jscripts/tiny_mce/classes/tinymce.js */
  2. var tinymce = {
  3. majorVersion : '3',
  4. minorVersion : '2.0.2',
  5. releaseDate : '2008-10-02',
  6. _init : function() {
  7. var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v;
  8. // Browser checks
  9. t.isOpera = w.opera && opera.buildNumber;
  10. t.isWebKit = /WebKit/.test(ua);
  11. t.isOldWebKit = t.isWebKit && !w.getSelection().getRangeAt;
  12. t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName);
  13. t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
  14. t.isGecko = !t.isWebKit && /Gecko/.test(ua);
  15. t.isMac = ua.indexOf('Mac') != -1;
  16. t.isAir = /adobeair/i.test(ua);
  17. // TinyMCE .NET webcontrol might be setting the values for TinyMCE
  18. if (w.tinyMCEPreInit) {
  19. t.suffix = tinyMCEPreInit.suffix;
  20. t.baseURL = tinyMCEPreInit.base;
  21. t.query = tinyMCEPreInit.query;
  22. return;
  23. }
  24. // Get suffix and base
  25. t.suffix = '';
  26. // If base element found, add that infront of baseURL
  27. nl = d.getElementsByTagName('base');
  28. for (i=0; i<nl.length; i++) {
  29. if (v = nl[i].href) {
  30. // Host only value like http://site.com or http://site.com:8008
  31. if (/^https?:\/\/[^\/]+$/.test(v))
  32. v += '/';
  33. base = v ? v.match(/.*\//)[0] : ''; // Get only directory
  34. }
  35. }
  36. function getBase(n) {
  37. if (n.src && /tiny_mce(|_dev|_src|_gzip|_jquery|_prototype).js/.test(n.src)) {
  38. if (/_(src|dev)\.js/g.test(n.src))
  39. t.suffix = '_src';
  40. if ((p = n.src.indexOf('?')) != -1)
  41. t.query = n.src.substring(p + 1);
  42. t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
  43. // If path to script is relative and a base href was found add that one infront
  44. if (base && t.baseURL.indexOf('://') == -1)
  45. t.baseURL = base + t.baseURL;
  46. return t.baseURL;
  47. }
  48. return null;
  49. };
  50. // Check document
  51. nl = d.getElementsByTagName('script');
  52. for (i=0; i<nl.length; i++) {
  53. if (getBase(nl[i]))
  54. return;
  55. }
  56. // Check head
  57. n = d.getElementsByTagName('head')[0];
  58. if (n) {
  59. nl = n.getElementsByTagName('script');
  60. for (i=0; i<nl.length; i++) {
  61. if (getBase(nl[i]))
  62. return;
  63. }
  64. }
  65. return;
  66. },
  67. is : function(o, t) {
  68. var n = typeof(o);
  69. if (!t)
  70. return n != 'undefined';
  71. if (t == 'array' && (o instanceof Array))
  72. return true;
  73. return n == t;
  74. },
  75. // #if !jquery
  76. each : function(o, cb, s) {
  77. var n, l;
  78. if (!o)
  79. return 0;
  80. s = s || o;
  81. if (typeof(o.length) != 'undefined') {
  82. // Indexed arrays, needed for Safari
  83. for (n=0, l = o.length; n<l; n++) {
  84. if (cb.call(s, o[n], n, o) === false)
  85. return 0;
  86. }
  87. } else {
  88. // Hashtables
  89. for (n in o) {
  90. if (o.hasOwnProperty(n)) {
  91. if (cb.call(s, o[n], n, o) === false)
  92. return 0;
  93. }
  94. }
  95. }
  96. return 1;
  97. },
  98. map : function(a, f) {
  99. var o = [];
  100. tinymce.each(a, function(v) {
  101. o.push(f(v));
  102. });
  103. return o;
  104. },
  105. grep : function(a, f) {
  106. var o = [];
  107. tinymce.each(a, function(v) {
  108. if (!f || f(v))
  109. o.push(v);
  110. });
  111. return o;
  112. },
  113. inArray : function(a, v) {
  114. var i, l;
  115. if (a) {
  116. for (i = 0, l = a.length; i < l; i++) {
  117. if (a[i] === v)
  118. return i;
  119. }
  120. }
  121. return -1;
  122. },
  123. extend : function(o, e) {
  124. var i, a = arguments;
  125. for (i=1; i<a.length; i++) {
  126. e = a[i];
  127. tinymce.each(e, function(v, n) {
  128. if (typeof(v) !== 'undefined')
  129. o[n] = v;
  130. });
  131. }
  132. return o;
  133. },
  134. trim : function(s) {
  135. return (s ? '' + s : '').replace(/^\s*|\s*$/g, '');
  136. },
  137. // #endif
  138. create : function(s, p) {
  139. var t = this, sp, ns, cn, scn, c, de = 0;
  140. // Parse : <prefix> <class>:<super class>
  141. s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s);
  142. cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name
  143. // Create namespace for new class
  144. ns = t.createNS(s[3].replace(/\.\w+$/, ''));
  145. // Class already exists
  146. if (ns[cn])
  147. return;
  148. // Make pure static class
  149. if (s[2] == 'static') {
  150. ns[cn] = p;
  151. if (this.onCreate)
  152. this.onCreate(s[2], s[3], ns[cn]);
  153. return;
  154. }
  155. // Create default constructor
  156. if (!p[cn]) {
  157. p[cn] = function() {};
  158. de = 1;
  159. }
  160. // Add constructor and methods
  161. ns[cn] = p[cn];
  162. t.extend(ns[cn].prototype, p);
  163. // Extend
  164. if (s[5]) {
  165. sp = t.resolve(s[5]).prototype;
  166. scn = s[5].match(/\.(\w+)$/i)[1]; // Class name
  167. // Extend constructor
  168. c = ns[cn];
  169. if (de) {
  170. // Add passthrough constructor
  171. ns[cn] = function() {
  172. return sp[scn].apply(this, arguments);
  173. };
  174. } else {
  175. // Add inherit constructor
  176. ns[cn] = function() {
  177. this.parent = sp[scn];
  178. return c.apply(this, arguments);
  179. };
  180. }
  181. ns[cn].prototype[cn] = ns[cn];
  182. // Add super methods
  183. t.each(sp, function(f, n) {
  184. ns[cn].prototype[n] = sp[n];
  185. });
  186. // Add overridden methods
  187. t.each(p, function(f, n) {
  188. // Extend methods if needed
  189. if (sp[n]) {
  190. ns[cn].prototype[n] = function() {
  191. this.parent = sp[n];
  192. return f.apply(this, arguments);
  193. };
  194. } else {
  195. if (n != cn)
  196. ns[cn].prototype[n] = f;
  197. }
  198. });
  199. }
  200. // Add static methods
  201. t.each(p['static'], function(f, n) {
  202. ns[cn][n] = f;
  203. });
  204. if (this.onCreate)
  205. this.onCreate(s[2], s[3], ns[cn].prototype);
  206. },
  207. walk : function(o, f, n, s) {
  208. s = s || this;
  209. if (o) {
  210. if (n)
  211. o = o[n];
  212. tinymce.each(o, function(o, i) {
  213. if (f.call(s, o, i, n) === false)
  214. return false;
  215. tinymce.walk(o, f, n, s);
  216. });
  217. }
  218. },
  219. createNS : function(n, o) {
  220. var i, v;
  221. o = o || window;
  222. n = n.split('.');
  223. for (i=0; i<n.length; i++) {
  224. v = n[i];
  225. if (!o[v])
  226. o[v] = {};
  227. o = o[v];
  228. }
  229. return o;
  230. },
  231. resolve : function(n, o) {
  232. var i, l;
  233. o = o || window;
  234. n = n.split('.');
  235. for (i=0, l = n.length; i<l; i++) {
  236. o = o[n[i]];
  237. if (!o)
  238. break;
  239. }
  240. return o;
  241. },
  242. addUnload : function(f, s) {
  243. var t = this, w = window;
  244. f = {func : f, scope : s || this};
  245. if (!t.unloads) {
  246. function unload() {
  247. var li = t.unloads, o, n;
  248. if (li) {
  249. // Call unload handlers
  250. for (n in li) {
  251. o = li[n];
  252. if (o && o.func)
  253. o.func.call(o.scope, 1); // Send in one arg to distinct unload and user destroy
  254. }
  255. // Detach unload function
  256. if (w.detachEvent) {
  257. w.detachEvent('onbeforeunload', fakeUnload);
  258. w.detachEvent('onunload', unload);
  259. } else if (w.removeEventListener)
  260. w.removeEventListener('unload', unload, false);
  261. // Destroy references
  262. t.unloads = o = li = w = unload = null;
  263. // Run garbarge collector on IE
  264. if (window.CollectGarbage)
  265. window.CollectGarbage();
  266. }
  267. };
  268. function fakeUnload() {
  269. var d = document;
  270. // Is there things still loading, then do some magic
  271. if (d.readyState == 'interactive') {
  272. function stop() {
  273. // Prevent memory leak
  274. d.detachEvent('onstop', stop);
  275. // Call unload handler
  276. unload();
  277. d = null;
  278. };
  279. // Fire unload when the currently loading page is stopped
  280. d.attachEvent('onstop', stop);
  281. // Remove onstop listener after a while to prevent the unload function
  282. // to execute if the user presses cancel in an onbeforeunload
  283. // confirm dialog and then presses the browser stop button
  284. window.setTimeout(function() {
  285. d.detachEvent('onstop', stop);
  286. }, 0);
  287. }
  288. };
  289. // Attach unload handler
  290. if (w.attachEvent) {
  291. w.attachEvent('onunload', unload);
  292. w.attachEvent('onbeforeunload', fakeUnload);
  293. } else if (w.addEventListener)
  294. w.addEventListener('unload', unload, false);
  295. // Setup initial unload handler array
  296. t.unloads = [f];
  297. } else
  298. t.unloads.push(f);
  299. return f;
  300. },
  301. removeUnload : function(f) {
  302. var u = this.unloads, r = null;
  303. tinymce.each(u, function(o, i) {
  304. if (o && o.func == f) {
  305. u.splice(i, 1);
  306. r = f;
  307. return false;
  308. }
  309. });
  310. return r;
  311. },
  312. explode : function(s, d) {
  313. return s ? tinymce.map(s.split(d || ','), tinymce.trim) : s;
  314. },
  315. _addVer : function(u) {
  316. var v;
  317. if (!this.query)
  318. return u;
  319. v = (u.indexOf('?') == -1 ? '?' : '&') + this.query;
  320. if (u.indexOf('#') == -1)
  321. return u + v;
  322. return u.replace('#', v + '#');
  323. }
  324. };
  325. // Required for GZip AJAX loading
  326. window.tinymce = tinymce;
  327. // Initialize the API
  328. tinymce._init();
  329. /* file:jscripts/tiny_mce/classes/adapter/jquery/adapter.js */
  330. /* file:jscripts/tiny_mce/classes/adapter/prototype/adapter.js */
  331. /* file:jscripts/tiny_mce/classes/util/Dispatcher.js */
  332. tinymce.create('tinymce.util.Dispatcher', {
  333. scope : null,
  334. listeners : null,
  335. Dispatcher : function(s) {
  336. this.scope = s || this;
  337. this.listeners = [];
  338. },
  339. add : function(cb, s) {
  340. this.listeners.push({cb : cb, scope : s || this.scope});
  341. return cb;
  342. },
  343. addToTop : function(cb, s) {
  344. this.listeners.unshift({cb : cb, scope : s || this.scope});
  345. return cb;
  346. },
  347. remove : function(cb) {
  348. var l = this.listeners, o = null;
  349. tinymce.each(l, function(c, i) {
  350. if (cb == c.cb) {
  351. o = cb;
  352. l.splice(i, 1);
  353. return false;
  354. }
  355. });
  356. return o;
  357. },
  358. dispatch : function() {
  359. var s, a = arguments, i, li = this.listeners, c;
  360. // Needs to be a real loop since the listener count might change while looping
  361. // And this is also more efficient
  362. for (i = 0; i<li.length; i++) {
  363. c = li[i];
  364. s = c.cb.apply(c.scope, a);
  365. if (s === false)
  366. break;
  367. }
  368. return s;
  369. }
  370. });
  371. /* file:jscripts/tiny_mce/classes/util/URI.js */
  372. (function() {
  373. var each = tinymce.each;
  374. tinymce.create('tinymce.util.URI', {
  375. URI : function(u, s) {
  376. var t = this, o, a, b;
  377. // Default settings
  378. s = t.settings = s || {};
  379. // Strange app protocol or local anchor
  380. if (/^(mailto|news|javascript|about):/i.test(u) || /^\s*#/.test(u)) {
  381. t.source = u;
  382. return;
  383. }
  384. // Absolute path with no host, fake host and protocol
  385. if (u.indexOf('/') === 0 && u.indexOf('//') !== 0)
  386. u = (s.base_uri ? s.base_uri.protocol || 'http' : 'http') + '://mce_host' + u;
  387. // Relative path
  388. if (u.indexOf(':/') === -1 && u.indexOf('//') !== 0)
  389. u = (s.base_uri.protocol || 'http') + '://mce_host' + t.toAbsPath(s.base_uri.path, u);
  390. // Parse URL (Credits goes to Steave, http://blog.stevenlevithan.com/archives/parseuri)
  391. u = u.replace(/@@/g, '(mce_at)'); // Zope 3 workaround, they use @@something
  392. u = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(u);
  393. each(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], function(v, i) {
  394. var s = u[i];
  395. // Zope 3 workaround, they use @@something
  396. if (s)
  397. s = s.replace(/\(mce_at\)/g, '@@');
  398. t[v] = s;
  399. });
  400. if (b = s.base_uri) {
  401. if (!t.protocol)
  402. t.protocol = b.protocol;
  403. if (!t.userInfo)
  404. t.userInfo = b.userInfo;
  405. if (!t.port && t.host == 'mce_host')
  406. t.port = b.port;
  407. if (!t.host || t.host == 'mce_host')
  408. t.host = b.host;
  409. t.source = '';
  410. }
  411. //t.path = t.path || '/';
  412. },
  413. setPath : function(p) {
  414. var t = this;
  415. p = /^(.*?)\/?(\w+)?$/.exec(p);
  416. // Update path parts
  417. t.path = p[0];
  418. t.directory = p[1];
  419. t.file = p[2];
  420. // Rebuild source
  421. t.source = '';
  422. t.getURI();
  423. },
  424. toRelative : function(u) {
  425. var t = this, o;
  426. if (u === "./")
  427. return u;
  428. u = new tinymce.util.URI(u, {base_uri : t});
  429. // Not on same domain/port or protocol
  430. if ((u.host != 'mce_host' && t.host != u.host && u.host) || t.port != u.port || t.protocol != u.protocol)
  431. return u.getURI();
  432. o = t.toRelPath(t.path, u.path);
  433. // Add query
  434. if (u.query)
  435. o += '?' + u.query;
  436. // Add anchor
  437. if (u.anchor)
  438. o += '#' + u.anchor;
  439. return o;
  440. },
  441. toAbsolute : function(u, nh) {
  442. var u = new tinymce.util.URI(u, {base_uri : this});
  443. return u.getURI(this.host == u.host ? nh : 0);
  444. },
  445. toRelPath : function(base, path) {
  446. var items, bp = 0, out = '', i, l;
  447. // Split the paths
  448. base = base.substring(0, base.lastIndexOf('/'));
  449. base = base.split('/');
  450. items = path.split('/');
  451. if (base.length >= items.length) {
  452. for (i = 0, l = base.length; i < l; i++) {
  453. if (i >= items.length || base[i] != items[i]) {
  454. bp = i + 1;
  455. break;
  456. }
  457. }
  458. }
  459. if (base.length < items.length) {
  460. for (i = 0, l = items.length; i < l; i++) {
  461. if (i >= base.length || base[i] != items[i]) {
  462. bp = i + 1;
  463. break;
  464. }
  465. }
  466. }
  467. if (bp == 1)
  468. return path;
  469. for (i = 0, l = base.length - (bp - 1); i < l; i++)
  470. out += "../";
  471. for (i = bp - 1, l = items.length; i < l; i++) {
  472. if (i != bp - 1)
  473. out += "/" + items[i];
  474. else
  475. out += items[i];
  476. }
  477. return out;
  478. },
  479. toAbsPath : function(base, path) {
  480. var i, nb = 0, o = [];
  481. // Split paths
  482. base = base.split('/');
  483. path = path.split('/');
  484. // Remove empty chunks
  485. each(base, function(k) {
  486. if (k)
  487. o.push(k);
  488. });
  489. base = o;
  490. // Merge relURLParts chunks
  491. for (i = path.length - 1, o = []; i >= 0; i--) {
  492. // Ignore empty or .
  493. if (path[i].length == 0 || path[i] == ".")
  494. continue;
  495. // Is parent
  496. if (path[i] == '..') {
  497. nb++;
  498. continue;
  499. }
  500. // Move up
  501. if (nb > 0) {
  502. nb--;
  503. continue;
  504. }
  505. o.push(path[i]);
  506. }
  507. i = base.length - nb;
  508. // If /a/b/c or /
  509. if (i <= 0)
  510. return '/' + o.reverse().join('/');
  511. return '/' + base.slice(0, i).join('/') + '/' + o.reverse().join('/');
  512. },
  513. getURI : function(nh) {
  514. var s, t = this;
  515. // Rebuild source
  516. if (!t.source || nh) {
  517. s = '';
  518. if (!nh) {
  519. if (t.protocol)
  520. s += t.protocol + '://';
  521. if (t.userInfo)
  522. s += t.userInfo + '@';
  523. if (t.host)
  524. s += t.host;
  525. if (t.port)
  526. s += ':' + t.port;
  527. }
  528. if (t.path)
  529. s += t.path;
  530. if (t.query)
  531. s += '?' + t.query;
  532. if (t.anchor)
  533. s += '#' + t.anchor;
  534. t.source = s;
  535. }
  536. return t.source;
  537. }
  538. });
  539. })();
  540. /* file:jscripts/tiny_mce/classes/util/Cookie.js */
  541. (function() {
  542. var each = tinymce.each;
  543. tinymce.create('static tinymce.util.Cookie', {
  544. getHash : function(n) {
  545. var v = this.get(n), h;
  546. if (v) {
  547. each(v.split('&'), function(v) {
  548. v = v.split('=');
  549. h = h || {};
  550. h[unescape(v[0])] = unescape(v[1]);
  551. });
  552. }
  553. return h;
  554. },
  555. setHash : function(n, v, e, p, d, s) {
  556. var o = '';
  557. each(v, function(v, k) {
  558. o += (!o ? '' : '&') + escape(k) + '=' + escape(v);
  559. });
  560. this.set(n, o, e, p, d, s);
  561. },
  562. get : function(n) {
  563. var c = document.cookie, e, p = n + "=", b;
  564. // Strict mode
  565. if (!c)
  566. return;
  567. b = c.indexOf("; " + p);
  568. if (b == -1) {
  569. b = c.indexOf(p);
  570. if (b != 0)
  571. return null;
  572. } else
  573. b += 2;
  574. e = c.indexOf(";", b);
  575. if (e == -1)
  576. e = c.length;
  577. return unescape(c.substring(b + p.length, e));
  578. },
  579. set : function(n, v, e, p, d, s) {
  580. document.cookie = n + "=" + escape(v) +
  581. ((e) ? "; expires=" + e.toGMTString() : "") +
  582. ((p) ? "; path=" + escape(p) : "") +
  583. ((d) ? "; domain=" + d : "") +
  584. ((s) ? "; secure" : "");
  585. },
  586. remove : function(n, p) {
  587. var d = new Date();
  588. d.setTime(d.getTime() - 1000);
  589. this.set(n, '', d, p, d);
  590. }
  591. });
  592. })();
  593. /* file:jscripts/tiny_mce/classes/util/JSON.js */
  594. tinymce.create('static tinymce.util.JSON', {
  595. serialize : function(o) {
  596. var i, v, s = tinymce.util.JSON.serialize, t;
  597. if (o == null)
  598. return 'null';
  599. t = typeof o;
  600. if (t == 'string') {
  601. v = '\bb\tt\nn\ff\rr\""\'\'\\\\';
  602. return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function(a, b) {
  603. i = v.indexOf(b);
  604. if (i + 1)
  605. return '\\' + v.charAt(i + 1);
  606. a = b.charCodeAt().toString(16);
  607. return '\\u' + '0000'.substring(a.length) + a;
  608. }) + '"';
  609. }
  610. if (t == 'object') {
  611. if (o instanceof Array) {
  612. for (i=0, v = '['; i<o.length; i++)
  613. v += (i > 0 ? ',' : '') + s(o[i]);
  614. return v + ']';
  615. }
  616. v = '{';
  617. for (i in o)
  618. v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : '';
  619. return v + '}';
  620. }
  621. return '' + o;
  622. },
  623. parse : function(s) {
  624. try {
  625. return eval('(' + s + ')');
  626. } catch (ex) {
  627. // Ignore
  628. }
  629. }
  630. });
  631. /* file:jscripts/tiny_mce/classes/util/XHR.js */
  632. tinymce.create('static tinymce.util.XHR', {
  633. send : function(o) {
  634. var x, t, w = window, c = 0;
  635. // Default settings
  636. o.scope = o.scope || this;
  637. o.success_scope = o.success_scope || o.scope;
  638. o.error_scope = o.error_scope || o.scope;
  639. o.async = o.async === false ? false : true;
  640. o.data = o.data || '';
  641. function get(s) {
  642. x = 0;
  643. try {
  644. x = new ActiveXObject(s);
  645. } catch (ex) {
  646. }
  647. return x;
  648. };
  649. x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP');
  650. if (x) {
  651. if (x.overrideMimeType)
  652. x.overrideMimeType(o.content_type);
  653. x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async);
  654. if (o.content_type)
  655. x.setRequestHeader('Content-Type', o.content_type);
  656. x.send(o.data);
  657. function ready() {
  658. if (!o.async || x.readyState == 4 || c++ > 10000) {
  659. if (o.success && c < 10000 && x.status == 200)
  660. o.success.call(o.success_scope, '' + x.responseText, x, o);
  661. else if (o.error)
  662. o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o);
  663. x = null;
  664. } else
  665. w.setTimeout(ready, 10);
  666. };
  667. // Syncronous request
  668. if (!o.async)
  669. return ready();
  670. // Wait for response, onReadyStateChange can not be used since it leaks memory in IE
  671. t = w.setTimeout(ready, 10);
  672. }
  673. }
  674. });
  675. /* file:jscripts/tiny_mce/classes/util/JSONRequest.js */
  676. (function() {
  677. var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR;
  678. tinymce.create('tinymce.util.JSONRequest', {
  679. JSONRequest : function(s) {
  680. this.settings = extend({
  681. }, s);
  682. this.count = 0;
  683. },
  684. send : function(o) {
  685. var ecb = o.error, scb = o.success;
  686. o = extend(this.settings, o);
  687. o.success = function(c, x) {
  688. c = JSON.parse(c);
  689. if (typeof(c) == 'undefined') {
  690. c = {
  691. error : 'JSON Parse error.'
  692. };
  693. }
  694. if (c.error)
  695. ecb.call(o.error_scope || o.scope, c.error, x);
  696. else
  697. scb.call(o.success_scope || o.scope, c.result);
  698. };
  699. o.error = function(ty, x) {
  700. ecb.call(o.error_scope || o.scope, ty, x);
  701. };
  702. o.data = JSON.serialize({
  703. id : o.id || 'c' + (this.count++),
  704. method : o.method,
  705. params : o.params
  706. });
  707. // JSON content type for Ruby on rails. Bug: #1883287
  708. o.content_type = 'application/json';
  709. XHR.send(o);
  710. },
  711. 'static' : {
  712. sendRPC : function(o) {
  713. return new tinymce.util.JSONRequest().send(o);
  714. }
  715. }
  716. });
  717. }());
  718. /* file:jscripts/tiny_mce/classes/dom/DOMUtils.js */
  719. (function() {
  720. // Shorten names
  721. var each = tinymce.each, is = tinymce.is;
  722. var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE;
  723. tinymce.create('tinymce.dom.DOMUtils', {
  724. doc : null,
  725. root : null,
  726. files : null,
  727. listeners : {},
  728. pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/,
  729. cache : {},
  730. idPattern : /^#[\w]+$/,
  731. elmPattern : /^[\w_*]+$/,
  732. elmClassPattern : /^([\w_]*)\.([\w_]+)$/,
  733. props : {
  734. "for" : "htmlFor",
  735. "class" : "className",
  736. className : "className",
  737. checked : "checked",
  738. disabled : "disabled",
  739. maxlength : "maxLength",
  740. readonly : "readOnly",
  741. selected : "selected",
  742. value : "value"
  743. },
  744. DOMUtils : function(d, s) {
  745. var t = this;
  746. t.doc = d;
  747. t.win = window;
  748. t.files = {};
  749. t.cssFlicker = false;
  750. t.counter = 0;
  751. t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat";
  752. t.stdMode = d.documentMode === 8;
  753. this.settings = s = tinymce.extend({
  754. keep_values : false,
  755. hex_colors : 1,
  756. process_html : 1
  757. }, s);
  758. // Fix IE6SP2 flicker and check it failed for pre SP2
  759. if (tinymce.isIE6) {
  760. try {
  761. d.execCommand('BackgroundImageCache', false, true);
  762. } catch (e) {
  763. t.cssFlicker = true;
  764. }
  765. }
  766. tinymce.addUnload(t.destroy, t);
  767. },
  768. getRoot : function() {
  769. var t = this, s = t.settings;
  770. return (s && t.get(s.root_element)) || t.doc.body;
  771. },
  772. getViewPort : function(w) {
  773. var d, b;
  774. w = !w ? this.win : w;
  775. d = w.document;
  776. b = this.boxModel ? d.documentElement : d.body;
  777. // Returns viewport size excluding scrollbars
  778. return {
  779. x : w.pageXOffset || b.scrollLeft,
  780. y : w.pageYOffset || b.scrollTop,
  781. w : w.innerWidth || b.clientWidth,
  782. h : w.innerHeight || b.clientHeight
  783. };
  784. },
  785. getRect : function(e) {
  786. var p, t = this, sr;
  787. e = t.get(e);
  788. p = t.getPos(e);
  789. sr = t.getSize(e);
  790. return {
  791. x : p.x,
  792. y : p.y,
  793. w : sr.w,
  794. h : sr.h
  795. };
  796. },
  797. getSize : function(e) {
  798. var t = this, w, h;
  799. e = t.get(e);
  800. w = t.getStyle(e, 'width');
  801. h = t.getStyle(e, 'height');
  802. // Non pixel value, then force offset/clientWidth
  803. if (w.indexOf('px') === -1)
  804. w = 0;
  805. // Non pixel value, then force offset/clientWidth
  806. if (h.indexOf('px') === -1)
  807. h = 0;
  808. return {
  809. w : parseInt(w) || e.offsetWidth || e.clientWidth,
  810. h : parseInt(h) || e.offsetHeight || e.clientHeight
  811. };
  812. },
  813. getParent : function(n, f, r) {
  814. var na, se = this.settings;
  815. n = this.get(n);
  816. if (se.strict_root)
  817. r = r || this.getRoot();
  818. // Wrap node name as func
  819. if (is(f, 'string')) {
  820. na = f.toUpperCase();
  821. f = function(n) {
  822. var s = false;
  823. // Any element
  824. if (n.nodeType == 1 && na === '*') {
  825. s = true;
  826. return false;
  827. }
  828. each(na.split(','), function(v) {
  829. if (n.nodeType == 1 && ((se.strict && n.nodeName.toUpperCase() == v) || n.nodeName.toUpperCase() == v)) {
  830. s = true;
  831. return false; // Break loop
  832. }
  833. });
  834. return s;
  835. };
  836. }
  837. while (n) {
  838. if (n == r)
  839. return null;
  840. if (f(n))
  841. return n;
  842. n = n.parentNode;
  843. }
  844. return null;
  845. },
  846. get : function(e) {
  847. var n;
  848. if (e && this.doc && typeof(e) == 'string') {
  849. n = e;
  850. e = this.doc.getElementById(e);
  851. // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick
  852. if (e && e.id !== n)
  853. return this.doc.getElementsByName(n)[1];
  854. }
  855. return e;
  856. },
  857. // #if !jquery
  858. select : function(pa, s) {
  859. var t = this, cs, c, pl, o = [], x, i, l, n, xp;
  860. s = t.get(s) || t.doc;
  861. // Look for native support and use that if it's found
  862. if (s.querySelectorAll) {
  863. // Element scope then use temp id
  864. // We need to do this to be compatible with other implementations
  865. // See bug report: http://bugs.webkit.org/show_bug.cgi?id=17461
  866. if (s != t.doc) {
  867. i = s.id;
  868. s.id = '_mc_tmp';
  869. pa = '#_mc_tmp ' + pa;
  870. }
  871. // Select elements
  872. l = tinymce.grep(s.querySelectorAll(pa));
  873. // Restore old id
  874. s.id = i;
  875. return l;
  876. }
  877. if (!t.selectorRe)
  878. t.selectorRe = /^([\w\\*]+)?(?:#([\w\\]+))?(?:\.([\w\\\.]+))?(?:\[\@([\w\\]+)([\^\$\*!]?=)([\w\\]+)\])?(?:\:([\w\\]+))?/i;;
  879. // Air doesn't support eval due to security sandboxing and querySelectorAll isn't supported yet
  880. if (tinymce.isAir) {
  881. each(tinymce.explode(pa), function(v) {
  882. if (!(xp = t.cache[v])) {
  883. xp = '';
  884. each(v.split(' '), function(v) {
  885. v = t.selectorRe.exec(v);
  886. xp += v[1] ? '//' + v[1] : '//*';
  887. // Id
  888. if (v[2])
  889. xp += "[@id='" + v[2] + "']";
  890. // Class
  891. if (v[3]) {
  892. each(v[3].split('.'), function(n) {
  893. xp += "[@class = '" + n + "' or contains(concat(' ', @class, ' '), ' " + n + " ')]";
  894. });
  895. }
  896. });
  897. t.cache[v] = xp;
  898. }
  899. xp = t.doc.evaluate(xp, s, null, 4, null);
  900. while (n = xp.iterateNext())
  901. o.push(n);
  902. });
  903. return o;
  904. }
  905. if (t.settings.strict) {
  906. function get(s, n) {
  907. return s.getElementsByTagName(n.toLowerCase());
  908. };
  909. } else {
  910. function get(s, n) {
  911. return s.getElementsByTagName(n);
  912. };
  913. }
  914. // Simple element pattern. For example: "p" or "*"
  915. if (t.elmPattern.test(pa)) {
  916. x = get(s, pa);
  917. for (i = 0, l = x.length; i<l; i++)
  918. o.push(x[i]);
  919. return o;
  920. }
  921. // Simple class pattern. For example: "p.class" or ".class"
  922. if (t.elmClassPattern.test(pa)) {
  923. pl = t.elmClassPattern.exec(pa);
  924. x = get(s, pl[1] || '*');
  925. c = ' ' + pl[2] + ' ';
  926. for (i = 0, l = x.length; i<l; i++) {
  927. n = x[i];
  928. if (n.className && (' ' + n.className + ' ').indexOf(c) !== -1)
  929. o.push(n);
  930. }
  931. return o;
  932. }
  933. function collect(n) {
  934. if (!n.mce_save) {
  935. n.mce_save = 1;
  936. o.push(n);
  937. }
  938. };
  939. function collectIE(n) {
  940. if (!n.getAttribute('mce_save')) {
  941. n.setAttribute('mce_save', '1');
  942. o.push(n);
  943. }
  944. };
  945. function find(n, f, r) {
  946. var i, l, nl = get(r, n);
  947. for (i = 0, l = nl.length; i < l; i++)
  948. f(nl[i]);
  949. };
  950. each(pa.split(','), function(v, i) {
  951. v = tinymce.trim(v);
  952. // Simple element pattern, most common in TinyMCE
  953. if (t.elmPattern.test(v)) {
  954. each(get(s, v), function(n) {
  955. collect(n);
  956. });
  957. return;
  958. }
  959. // Simple element pattern with class, fairly common in TinyMCE
  960. if (t.elmClassPattern.test(v)) {
  961. x = t.elmClassPattern.exec(v);
  962. each(get(s, x[1]), function(n) {
  963. if (t.hasClass(n, x[2]))
  964. collect(n);
  965. });
  966. return;
  967. }
  968. if (!(cs = t.cache[pa])) {
  969. cs = 'x=(function(cf, s) {';
  970. pl = v.split(' ');
  971. each(pl, function(v) {
  972. var p = t.selectorRe.exec(v);
  973. // Find elements
  974. p[1] = p[1] || '*';
  975. cs += 'find("' + p[1] + '", function(n) {';
  976. // Check id
  977. if (p[2])
  978. cs += 'if (n.id !== "' + p[2] + '") return;';
  979. // Check classes
  980. if (p[3]) {
  981. cs += 'var c = " " + n.className + " ";';
  982. cs += 'if (';
  983. c = '';
  984. each(p[3].split('.'), function(v) {
  985. if (v)
  986. c += (c ? '||' : '') + 'c.indexOf(" ' + v + ' ") === -1';
  987. });
  988. cs += c + ') return;';
  989. }
  990. });
  991. cs += 'cf(n);';
  992. for (i = pl.length - 1; i >= 0; i--)
  993. cs += '}, ' + (i ? 'n' : 's') + ');';
  994. cs += '})';
  995. // Compile CSS pattern function
  996. t.cache[pa] = cs = eval(cs);
  997. }
  998. // Run selector function
  999. cs(isIE ? collectIE : collect, s);
  1000. });
  1001. // Cleanup
  1002. each(o, function(n) {
  1003. if (isIE)
  1004. n.removeAttribute('mce_save');
  1005. else
  1006. delete n.mce_save;
  1007. });
  1008. return o;
  1009. },
  1010. // #endif
  1011. add : function(p, n, a, h, c) {
  1012. var t = this;
  1013. return this.run(p, function(p) {
  1014. var e, k;
  1015. e = is(n, 'string') ? t.doc.createElement(n) : n;
  1016. t.setAttribs(e, a);
  1017. if (h) {
  1018. if (h.nodeType)
  1019. e.appendChild(h);
  1020. else
  1021. t.setHTML(e, h);
  1022. }
  1023. return !c ? p.appendChild(e) : e;
  1024. });
  1025. },
  1026. create : function(n, a, h) {
  1027. return this.add(this.doc.createElement(n), n, a, h, 1);
  1028. },
  1029. createHTML : function(n, a, h) {
  1030. var o = '', t = this, k;
  1031. o += '<' + n;
  1032. for (k in a) {
  1033. if (a.hasOwnProperty(k))
  1034. o += ' ' + k + '="' + t.encode(a[k]) + '"';
  1035. }
  1036. if (tinymce.is(h))
  1037. return o + '>' + h + '</' + n + '>';
  1038. return o + ' />';
  1039. },
  1040. remove : function(n, k) {
  1041. return this.run(n, function(n) {
  1042. var p, g;
  1043. p = n.parentNode;
  1044. if (!p)
  1045. return null;
  1046. if (k) {
  1047. each (n.childNodes, function(c) {
  1048. p.insertBefore(c.cloneNode(true), n);
  1049. });
  1050. }
  1051. // Fix IE psuedo leak
  1052. /* if (isIE) {
  1053. p = n.cloneNode(true);
  1054. n.outerHTML = '';
  1055. return p;
  1056. }*/
  1057. return p.removeChild(n);
  1058. });
  1059. },
  1060. // #if !jquery
  1061. setStyle : function(n, na, v) {
  1062. var t = this;
  1063. return t.run(n, function(e) {
  1064. var s, i;
  1065. s = e.style;
  1066. // Camelcase it, if needed
  1067. na = na.replace(/-(\D)/g, function(a, b){
  1068. return b.toUpperCase();
  1069. });
  1070. // Default px suffix on these
  1071. if (t.pixelStyles.test(na) && (tinymce.is(v, 'number') || /^[\-0-9\.]+$/.test(v)))
  1072. v += 'px';
  1073. switch (na) {
  1074. case 'opacity':
  1075. // IE specific opacity
  1076. if (isIE) {
  1077. s.filter = v === '' ? '' : "alpha(opacity=" + (v * 100) + ")";
  1078. if (!n.currentStyle || !n.currentStyle.hasLayout)
  1079. s.display = 'inline-block';
  1080. }
  1081. // Fix for older browsers
  1082. s[na] = s['-moz-opacity'] = s['-khtml-opacity'] = v || '';
  1083. break;
  1084. case 'float':
  1085. isIE ? s.styleFloat = v : s.cssFloat = v;
  1086. break;
  1087. default:
  1088. s[na] = v || '';
  1089. }
  1090. // Force update of the style data
  1091. if (t.settings.update_styles)
  1092. t.setAttrib(e, 'mce_style');
  1093. });
  1094. },
  1095. getStyle : function(n, na, c) {
  1096. n = this.get(n);
  1097. if (!n)
  1098. return false;
  1099. // Gecko
  1100. if (this.doc.defaultView && c) {
  1101. // Remove camelcase
  1102. na = na.replace(/[A-Z]/g, function(a){
  1103. return '-' + a;
  1104. });
  1105. try {
  1106. return this.doc.defaultView.getComputedStyle(n, null).getPropertyValue(na);
  1107. } catch (ex) {
  1108. // Old safari might fail
  1109. return null;
  1110. }
  1111. }
  1112. // Camelcase it, if needed
  1113. na = na.replace(/-(\D)/g, function(a, b){
  1114. return b.toUpperCase();
  1115. });
  1116. if (na == 'float')
  1117. na = isIE ? 'styleFloat' : 'cssFloat';
  1118. // IE & Opera
  1119. if (n.currentStyle && c)
  1120. return n.currentStyle[na];
  1121. return n.style[na];
  1122. },
  1123. setStyles : function(e, o) {
  1124. var t = this, s = t.settings, ol;
  1125. ol = s.update_styles;
  1126. s.update_styles = 0;
  1127. each(o, function(v, n) {
  1128. t.setStyle(e, n, v);
  1129. });
  1130. // Update style info
  1131. s.update_styles = ol;
  1132. if (s.update_styles)
  1133. t.setAttrib(e, s.cssText);
  1134. },
  1135. setAttrib : function(e, n, v) {
  1136. var t = this;
  1137. // Whats the point
  1138. if (!e || !n)
  1139. return;
  1140. // Strict XML mode
  1141. if (t.settings.strict)
  1142. n = n.toLowerCase();
  1143. return this.run(e, function(e) {
  1144. var s = t.settings;
  1145. switch (n) {
  1146. case "style":
  1147. if (!is(v, 'string')) {
  1148. each(v, function(v, n) {
  1149. t.setStyle(e, n, v);
  1150. });
  1151. return;
  1152. }
  1153. // No mce_style for elements with these since they might get resized by the user
  1154. if (s.keep_values) {
  1155. if (v && !t._isRes(v))
  1156. e.setAttribute('mce_style', v, 2);
  1157. else
  1158. e.removeAttribute('mce_style', 2);
  1159. }
  1160. e.style.cssText = v;
  1161. break;
  1162. case "class":
  1163. e.className = v || ''; // Fix IE null bug
  1164. break;
  1165. case "src":
  1166. case "href":
  1167. if (s.keep_values) {
  1168. if (s.url_converter)
  1169. v = s.url_converter.call(s.url_converter_scope || t, v, n, e);
  1170. t.setAttrib(e, 'mce_' + n, v, 2);
  1171. }
  1172. break;
  1173. case "shape":
  1174. e.setAttribute('mce_style', v);
  1175. break;
  1176. }
  1177. if (is(v) && v !== null && v.length !== 0)
  1178. e.setAttribute(n, '' + v, 2);
  1179. else
  1180. e.removeAttribute(n, 2);
  1181. });
  1182. },
  1183. setAttribs : function(e, o) {
  1184. var t = this;
  1185. return this.run(e, function(e) {
  1186. each(o, function(v, n) {
  1187. t.setAttrib(e, n, v);
  1188. });
  1189. });
  1190. },
  1191. // #endif
  1192. getAttrib : function(e, n, dv) {
  1193. var v, t = this;
  1194. e = t.get(e);
  1195. if (!e || e.nodeType !== 1)
  1196. return false;
  1197. if (!is(dv))
  1198. dv = '';
  1199. // Try the mce variant for these
  1200. if (/^(src|href|style|coords|shape)$/.test(n)) {
  1201. v = e.getAttribute("mce_" + n);
  1202. if (v)
  1203. return v;
  1204. }
  1205. if (isIE && t.props[n]) {
  1206. v = e[t.props[n]];
  1207. v = v && v.nodeValue ? v.nodeValue : v;
  1208. }
  1209. if (!v)
  1210. v = e.getAttribute(n, 2);
  1211. if (n === 'style') {
  1212. v = v || e.style.cssText;
  1213. if (v) {
  1214. v = t.serializeStyle(t.parseStyle(v));
  1215. if (t.settings.keep_values && !t._isRes(v))
  1216. e.setAttribute('mce_style', v);
  1217. }
  1218. }
  1219. // Remove Apple and WebKit stuff
  1220. if (isWebKit && n === "class" && v)
  1221. v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, '');
  1222. // Handle IE issues
  1223. if (isIE) {
  1224. switch (n) {
  1225. case 'rowspan':
  1226. case 'colspan':
  1227. // IE returns 1 as default value
  1228. if (v === 1)
  1229. v = '';
  1230. break;
  1231. case 'size':
  1232. // IE returns +0 as default value for size
  1233. if (v === '+0' || v === 20)
  1234. v = '';
  1235. break;
  1236. case 'width':
  1237. case 'height':
  1238. case 'vspace':
  1239. if (v === 0)
  1240. v = '';
  1241. break;
  1242. case 'hspace':
  1243. // IE returns -1 as default value
  1244. if (v === -1)
  1245. v = '';
  1246. break;
  1247. case 'maxlength':
  1248. case 'tabindex':
  1249. // IE returns default value
  1250. if (v === 32768 || v === 2147483647)
  1251. v = '';
  1252. break;
  1253. case 'compact':
  1254. case 'noshade':
  1255. if (v === 65535)
  1256. return n;
  1257. return dv;
  1258. case 'shape':
  1259. v = v.toLowerCase();
  1260. break;
  1261. default:
  1262. // IE has odd anonymous function for event attributes
  1263. if (n.indexOf('on') === 0 && v)
  1264. v = ('' + v).replace(/^function\s+anonymous\(\)\s+\{\s+(.*)\s+\}$/, '$1');
  1265. }
  1266. }
  1267. return (v !== undefined && v !== null && v !== '') ? '' + v : dv;
  1268. },
  1269. getPos : function(n) {
  1270. var t = this, x = 0, y = 0, e, d = t.doc, r;
  1271. n = t.get(n);
  1272. // Use getBoundingClientRect on IE, Opera has it but it's not perfect
  1273. if (n && isIE) {
  1274. n = n.getBoundingClientRect();
  1275. e = t.boxModel ? d.documentElement : d.body;
  1276. x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border
  1277. x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x;
  1278. n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset
  1279. return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x};
  1280. }
  1281. r = n;
  1282. while (r) {
  1283. x += r.offsetLeft || 0;
  1284. y += r.offsetTop || 0;
  1285. r = r.offsetParent;
  1286. }
  1287. r = n;
  1288. while (r) {
  1289. // Opera 9.25 bug fix, fixed in 9.50
  1290. if (!/^table-row|inline.*/i.test(t.getStyle(r, "display", 1))) {
  1291. x -= r.scrollLeft || 0;
  1292. y -= r.scrollTop || 0;
  1293. }
  1294. r = r.parentNode;
  1295. if (r == d.body)
  1296. break;
  1297. }
  1298. return {x : x, y : y};
  1299. },
  1300. parseStyle : function(st) {
  1301. var t = this, s = t.settings, o = {};
  1302. if (!st)
  1303. return o;
  1304. function compress(p, s, ot) {
  1305. var t, r, b, l;
  1306. // Get values and check it it needs compressing
  1307. t = o[p + '-top' + s];
  1308. if (!t)
  1309. return;
  1310. r = o[p + '-right' + s];
  1311. if (t != r)
  1312. return;
  1313. b = o[p + '-bottom' + s];
  1314. if (r != b)
  1315. return;
  1316. l = o[p + '-left' + s];
  1317. if (b != l)
  1318. return;
  1319. // Compress
  1320. o[ot] = l;
  1321. delete o[p + '-top' + s];
  1322. delete o[p + '-right' + s];
  1323. delete o[p + '-bottom' + s];
  1324. delete o[p + '-left' + s];
  1325. };
  1326. function compress2(ta, a, b, c) {
  1327. var t;
  1328. t = o[a];
  1329. if (!t)
  1330. return;
  1331. t = o[b];
  1332. if (!t)
  1333. return;
  1334. t = o[c];
  1335. if (!t)
  1336. return;
  1337. // Compress
  1338. o[ta] = o[a] + ' ' + o[b] + ' ' + o[c];
  1339. delete o[a];
  1340. delete o[b];
  1341. delete o[c];
  1342. };
  1343. st = st.replace(/&(#?[a-z0-9]+);/g, '&$1_MCE_SEMI_'); // Protect entities
  1344. each(st.split(';'), function(v) {
  1345. var sv, ur = [];
  1346. if (v) {
  1347. v = v.replace(/_MCE_SEMI_/g, ';'); // Restore entities
  1348. v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';});
  1349. v = v.split(':');
  1350. sv = tinymce.trim(v[1]);
  1351. sv = sv.replace(/url\(([^\)]+)\)/g, function(a, b) {return ur[parseInt(b) - 1];});
  1352. sv = sv.replace(/rgb\([^\)]+\)/g, function(v) {
  1353. return t.toHex(v);
  1354. });
  1355. if (s.url_converter) {
  1356. sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) {
  1357. return 'url(' + s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null) + ')';
  1358. });
  1359. }
  1360. o[tinymce.trim(v[0]).toLowerCase()] = sv;
  1361. }
  1362. });
  1363. compress("border", "", "border");
  1364. compress("border", "-width", "border-width");
  1365. compress("border", "-color", "border-color");
  1366. compress("border", "-style", "border-style");
  1367. compress("padding", "", "padding");
  1368. compress("margin", "", "margin");
  1369. compress2('border', 'border-width', 'border-style', 'border-color');
  1370. if (isIE) {
  1371. // Remove pointless border
  1372. if (o.border == 'medium none')
  1373. o.border = '';
  1374. }
  1375. return o;
  1376. },
  1377. serializeStyle : function(o) {
  1378. var s = '';
  1379. each(o, function(v, k) {
  1380. if (k && v) {
  1381. if (tinymce.isGecko && k.indexOf('-moz-') === 0)
  1382. return;
  1383. switch (k) {
  1384. case 'color':
  1385. case 'background-color':
  1386. v = v.toLowerCase();
  1387. break;
  1388. }
  1389. s += (s ? ' ' : '') + k + ': ' + v + ';';
  1390. }
  1391. });
  1392. return s;
  1393. },
  1394. loadCSS : function(u) {
  1395. var t = this, d = t.doc;
  1396. if (!u)
  1397. u = '';
  1398. each(u.split(','), function(u) {
  1399. if (t.files[u])
  1400. return;
  1401. t.files[u] = true;
  1402. t.add(t.select('head')[0], 'link', {rel : 'stylesheet', href : tinymce._addVer(u)});
  1403. });
  1404. },
  1405. // #if !jquery
  1406. addClass : function(e, c) {
  1407. return this.run(e, function(e) {
  1408. var o;
  1409. if (!c)
  1410. return 0;
  1411. if (this.hasClass(e, c))
  1412. return e.className;
  1413. o = this.removeClass(e, c);
  1414. return e.className = (o != '' ? (o + ' ') : '') + c;
  1415. });
  1416. },
  1417. removeClass : function(e, c) {
  1418. var t = this, re;
  1419. return t.run(e, function(e) {
  1420. var v;
  1421. if (t.hasClass(e, c)) {
  1422. if (!re)
  1423. re = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
  1424. v = e.className.replace(re, ' ');
  1425. return e.className = tinymce.trim(v != ' ' ? v : '');
  1426. }
  1427. return e.className;
  1428. });
  1429. },
  1430. hasClass : function(n, c) {
  1431. n = this.get(n);
  1432. if (!n || !c)
  1433. return false;
  1434. return (' ' + n.className + ' ').indexOf(' ' + c + ' ') !== -1;
  1435. },
  1436. show : function(e) {
  1437. return this.setStyle(e, 'display', 'block');
  1438. },
  1439. hide : function(e) {
  1440. return this.setStyle(e, 'display', 'none');
  1441. },
  1442. isHidden : function(e) {
  1443. e = this.get(e);
  1444. return e.style.display == 'none' || this.getStyle(e, 'display') == 'none';
  1445. },
  1446. // #endif
  1447. uniqueId : function(p) {
  1448. return (!p ? 'mce_' : p) + (this.counter++);
  1449. },
  1450. setHTML : function(e, h) {
  1451. var t = this;
  1452. return this.run(e, function(e) {
  1453. var x, i, nl, n, p, x;
  1454. h = t.processHTML(h);
  1455. if (isIE) {
  1456. function set() {
  1457. try {
  1458. // IE will remove comments from the beginning
  1459. // unless you padd the contents with something
  1460. e.innerHTML = '<br />' + h;
  1461. e.removeChild(e.firstChild);
  1462. } catch (ex) {
  1463. // IE sometimes produces an unknown runtime error on innerHTML if it's an block element within a block element for example a div inside a p
  1464. // This seems to fix this problem
  1465. // Remove all child nodes
  1466. while (e.firstChild)
  1467. e.firstChild.removeNode();
  1468. // Create new div with HTML contents and a BR infront to keep comments
  1469. x = t.create('div');
  1470. x.innerHTML = '<br />' + h;
  1471. // Add all children from div to target
  1472. each (x.childNodes, function(n, i) {
  1473. // Skip br element
  1474. if (i)
  1475. e.appendChild(n);
  1476. });
  1477. }
  1478. };
  1479. // IE has a serious bug when it comes to paragraphs it can produce an invalid
  1480. // DOM tree if contents like this <p><ul><li>Item 1</li></ul></p> is inserted
  1481. // It seems to be that IE doesn't like a root block element placed inside another root block element
  1482. if (t.settings.fix_ie_paragraphs)
  1483. h = h.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi, '<p$1 mce_keep="true">&nbsp;</p>');
  1484. set();
  1485. if (t.settings.fix_ie_paragraphs) {
  1486. // Check for odd paragraphs this is a sign of a broken DOM
  1487. nl = e.getElementsByTagName("p");
  1488. for (i = nl.length - 1, x = 0; i >= 0; i--) {
  1489. n = nl[i];
  1490. if (!n.hasChildNodes()) {
  1491. if (!n.mce_keep) {
  1492. x = 1; // Is broken
  1493. break;
  1494. }
  1495. n.removeAttribute('mce_keep');
  1496. }
  1497. }
  1498. }
  1499. // Time to fix the madness IE left us
  1500. if (x) {
  1501. // So if we replace the p elements with divs and mark them and then replace them back to paragraphs
  1502. // after we use innerHTML we can fix the DOM tree
  1503. h = h.replace(/<p([^>]+)>|<p>/g, '<div$1 mce_tmp="1">');
  1504. h = h.replace(/<\/p>/g, '</div>');
  1505. // Set the new HTML with DIVs
  1506. set();
  1507. // Replace all DIV elements with he mce_tmp attibute back to paragraphs
  1508. // This is needed since IE has a annoying bug see above for details
  1509. // This is a slow process but it has to be done. :(
  1510. if (t.settings.fix_ie_paragraphs) {
  1511. nl = e.getElementsByTagName("DIV");
  1512. for (i = nl.length - 1; i >= 0; i--) {
  1513. n = nl[i];
  1514. // Is it a temp div
  1515. if (n.mce_tmp) {
  1516. // Create new paragraph
  1517. p = t.doc.createElement('p');
  1518. // Copy all attributes
  1519. n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) {
  1520. var v;
  1521. if (b !== 'mce_tmp') {
  1522. v = n.getAttribute(b);
  1523. if (!v && b === 'class')
  1524. v = n.className;
  1525. p.setAttribute(b, v);
  1526. }
  1527. });
  1528. // Append all children to new paragraph
  1529. for (x = 0; x<n.childNodes.length; x++)
  1530. p.appendChild(n.childNodes[x].cloneNode(true));
  1531. // Replace div with new paragraph
  1532. n.swapNode(p);
  1533. }
  1534. }
  1535. }
  1536. }
  1537. } else
  1538. e.innerHTML = h;
  1539. return h;
  1540. });
  1541. },
  1542. processHTML : function(h) {
  1543. var t = this, s = t.settings;
  1544. if (!s.process_html)
  1545. return h;
  1546. // Convert strong and em to b and i in FF since it can't handle them
  1547. if (tinymce.isGecko) {
  1548. h = h.replace(/<(\/?)strong>|<strong( [^>]+)>/gi, '<$1b$2>');
  1549. h = h.replace(/<(\/?)em>|<em( [^>]+)>/gi, '<$1i$2>');
  1550. } else if (isIE)
  1551. h = h.replace(/&apos;/g, '&#39;'); // IE can't handle apos
  1552. // Fix some issues
  1553. h = h.replace(/<a( )([^>]+)\/>|<a\/>/gi, '<a$1$2></a>'); // Force open
  1554. // Store away src and href in mce_src and mce_href since browsers mess them up
  1555. if (s.keep_values) {
  1556. h = h.replace(/<!\[CDATA\[([\s\S]+)\]\]>/g, '<!--[CDATA[$1]]-->');
  1557. // Wrap scripts and styles in comments for serialization purposes
  1558. if (/<script|style/.test(h)) {
  1559. function trim(s) {
  1560. // Remove prefix and suffix code for element
  1561. s = s.replace(/^[\r\n]*|[\r\n]*$/g, '');
  1562. s = s.replace(/^\s*(\/\/\s*<!--|\/\/\s*<\[CDATA\[|<!--|<\[CDATA\[)[\r\n]*/g, '');
  1563. s = s.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->)\s*$/g, '');
  1564. return s;
  1565. };
  1566. // Preserve script elements
  1567. h = h.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/g, function(v, a, b) {
  1568. // Remove prefix and suffix code for script element
  1569. b = trim(b);
  1570. // Force type attribute
  1571. if (!a)
  1572. a = ' type="text/javascript"';
  1573. // Wrap contents in a comment
  1574. if (b)
  1575. b = '<!--\n' + b + '\n// -->';
  1576. // Output fake element
  1577. return '<mce:script' + a + '>' + b + '</mce:script>';
  1578. });
  1579. // Preserve style elements
  1580. h = h.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/g, function(v, a, b) {
  1581. b = trim(b);
  1582. return '<mce:style' + a + '><!--\n' + b + '\n--></mce:style><style' + a + ' mce_bogus="1">' + b + '</style>';
  1583. });
  1584. }
  1585. // Process all tags with src, href or style
  1586. h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) {
  1587. function handle(m, b, c) {
  1588. var u = c;
  1589. // Tag already got a mce_ version
  1590. if (a.indexOf('mce_' + b) != -1)
  1591. return m;
  1592. if (b == 'style') {
  1593. // Why did I need this one?
  1594. //if (isIE)
  1595. // u = t.serializeStyle(t.parseStyle(u));
  1596. // No mce_style for elements with these since they might get resized by the user
  1597. if (t._isRes(c))
  1598. return m;
  1599. if (s.hex_colors) {
  1600. u = u.replace(/rgb\([^\)]+\)/g, function(v) {
  1601. return t.toHex(v);
  1602. });
  1603. }
  1604. if (s.url_converter) {
  1605. u = u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g, function(x, c) {
  1606. return 'url(' + t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)) + ')';
  1607. });
  1608. }
  1609. } else if (b != 'coords' && b != 'shape') {
  1610. if (s.url_converter)
  1611. u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n));
  1612. }
  1613. return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"';
  1614. };
  1615. a = a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi, handle); // W3C
  1616. a = a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi, handle); // W3C
  1617. return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE
  1618. });
  1619. }
  1620. return h;
  1621. },
  1622. getOuterHTML : function(e) {
  1623. var d;
  1624. e = this.get(e);
  1625. if (!e)
  1626. return null;
  1627. if (isIE)
  1628. return e.outerHTML;
  1629. d = (e.ownerDocument || this.doc).createElement("body");
  1630. d.appendChild(e.cloneNode(true));
  1631. return d.innerHTML;
  1632. },
  1633. setOuterHTML : function(e, h, d) {
  1634. var t = this;
  1635. return this.run(e, function(e) {
  1636. var n, tp;
  1637. e = t.get(e);
  1638. d = d || e.ownerDocument || t.doc;
  1639. if (isIE && e.nodeType == 1)
  1640. e.outerHTML = h;
  1641. else {
  1642. tp = d.createElement("body");
  1643. tp.innerHTML = h;
  1644. n = tp.lastChild;
  1645. while (n) {
  1646. t.insertAfter(n.cloneNode(true), e);
  1647. n = n.previousSibling;
  1648. }
  1649. t.remove(e);
  1650. }
  1651. });
  1652. },
  1653. decode : function(s) {
  1654. var e;
  1655. // Look for entities to decode
  1656. if (/&[^;]+;/.test(s)) {
  1657. // Decode the entities using a div element not super efficient but less code
  1658. e = this.doc.createElement("div");
  1659. e.innerHTML = s;
  1660. return !e.firstChild ? s : e.firstChild.nodeValue;
  1661. }
  1662. return s;
  1663. },
  1664. encode : function(s) {
  1665. return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) {
  1666. switch (c) {
  1667. case '&':
  1668. return '&amp;';
  1669. case '"':
  1670. return '&quot;';
  1671. case '<':
  1672. return '&lt;';
  1673. case '>':
  1674. return '&gt;';
  1675. }
  1676. return c;
  1677. }) : s;
  1678. },
  1679. // #if !jquery
  1680. insertAfter : function(n, r) {
  1681. var t = this;
  1682. r = t.get(r);
  1683. return this.run(n, function(n) {
  1684. var p, ns;
  1685. p = r.parentNode;
  1686. ns = r.nextSibling;
  1687. if (ns)
  1688. p.insertBefore(n, ns);
  1689. else
  1690. p.appendChild(n);
  1691. return n;
  1692. });
  1693. },
  1694. // #endif
  1695. isBlock : function(n) {
  1696. if (n.nodeType && n.nodeType !== 1)
  1697. return false;
  1698. n = n.nodeName || n;
  1699. return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);
  1700. },
  1701. // #if !jquery
  1702. replace : function(n, o, k) {
  1703. if (is(o, 'array'))
  1704. n = n.cloneNode(true);
  1705. return this.run(o, function(o) {
  1706. if (k) {
  1707. each(o.childNodes, function(c) {
  1708. n.appendChild(c.cloneNode(true));
  1709. });
  1710. }
  1711. // Fix IE psuedo leak for elements since replacing elements if fairly common
  1712. // Will break parentNode for some unknown reason
  1713. /* if (isIE && o.nodeType === 1) {
  1714. o.parentNode.insertBefore(n, o);
  1715. o.outerHTML = '';
  1716. return n;
  1717. }*/
  1718. return o.parentNode.replaceChild(n, o);
  1719. });
  1720. },
  1721. // #endif
  1722. toHex : function(s) {
  1723. var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);
  1724. function hex(s) {
  1725. s = parseInt(s).toString(16);
  1726. return s.length > 1 ? s : '0' + s; // 0 -> 00
  1727. };
  1728. if (c) {
  1729. s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]);
  1730. return s;
  1731. }
  1732. return s;
  1733. },
  1734. getClasses : function() {
  1735. var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov;
  1736. if (t.classes)
  1737. return t.classes;
  1738. function addClasses(s) {
  1739. // IE style imports
  1740. each(s.imports, function(r) {
  1741. addClasses(r);
  1742. });
  1743. each(s.cssRules || s.rules, function(r) {
  1744. // Real type or fake it on IE
  1745. switch (r.type || 1) {
  1746. // Rule
  1747. case 1:
  1748. if (r.selectorText) {
  1749. each(r.selectorText.split(','), function(v) {
  1750. v = v.replace(/^\s*|\s*$|^\s\./g, "");
  1751. // Is internal or it doesn't contain a class
  1752. if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v))
  1753. return;
  1754. // Remove everything but class name
  1755. ov = v;
  1756. v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1');
  1757. // Filter classes
  1758. if (f && !(v = f(v, ov)))
  1759. return;
  1760. if (!lo[v]) {
  1761. cl.push({'class' : v});
  1762. lo[v] = 1;
  1763. }
  1764. });
  1765. }
  1766. break;
  1767. // Import
  1768. case 3:
  1769. addClasses(r.styleSheet);
  1770. break;
  1771. }
  1772. });
  1773. };
  1774. try {
  1775. each(t.doc.styleSheets, addClasses);
  1776. } catch (ex) {
  1777. // Ignore
  1778. }
  1779. if (cl.length > 0)
  1780. t.classes = cl;
  1781. return cl;
  1782. },
  1783. run : function(e, f, s) {
  1784. var t = this, o;
  1785. if (t.doc && typeof(e) === 'string')
  1786. e = t.get(e);
  1787. if (!e)
  1788. return false;
  1789. s = s || this;
  1790. if (!e.nodeType && (e.length || e.length === 0)) {
  1791. o = [];
  1792. each(e, function(e, i) {
  1793. if (e) {
  1794. if (typeof(e) == 'string')
  1795. e = t.doc.getElementById(e);
  1796. o.push(f.call(s, e, i));
  1797. }
  1798. });
  1799. return o;
  1800. }
  1801. return f.call(s, e);
  1802. },
  1803. getAttribs : function(n) {
  1804. var o;
  1805. n = this.get(n);
  1806. if (!n)
  1807. return [];
  1808. if (isIE) {
  1809. o = [];
  1810. // Object will throw exception in IE
  1811. if (n.nodeName == 'OBJECT')
  1812. return n.attributes;
  1813. // It's crazy that this is faster in IE but it's because it returns all attributes all the time
  1814. n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
  1815. o.push({specified : 1, nodeName : b});
  1816. });
  1817. return o;
  1818. }
  1819. return n.attributes;
  1820. },
  1821. destroy : function(s) {
  1822. var t = this;
  1823. t.win = t.doc = t.root = null;
  1824. // Manual destroy then remove unload handler
  1825. if (!s)
  1826. tinymce.removeUnload(t.destroy);
  1827. },
  1828. _isRes : function(c) {
  1829. // Is live resizble element
  1830. return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c);
  1831. }
  1832. /*
  1833. walk : function(n, f, s) {
  1834. var d = this.doc, w;
  1835. if (d.createTreeWalker) {
  1836. w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
  1837. while ((n = w.nextNode()) != null)
  1838. f.call(s || this, n);
  1839. } else
  1840. tinymce.walk(n, f, 'childNodes', s);
  1841. }
  1842. */
  1843. /*
  1844. toRGB : function(s) {
  1845. var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s);
  1846. if (c) {
  1847. // #FFF -> #FFFFFF
  1848. if (!is(c[3]))
  1849. c[3] = c[2] = c[1];
  1850. return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")";
  1851. }
  1852. return s;
  1853. }
  1854. */
  1855. });
  1856. // Setup page DOM
  1857. tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0});
  1858. })();
  1859. /* file:jscripts/tiny_mce/classes/dom/Event.js */
  1860. (function() {
  1861. // Shorten names
  1862. var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event;
  1863. tinymce.create('static tinymce.dom.Event', {
  1864. inits : [],
  1865. events : [],
  1866. // #if !jquery
  1867. add : function(o, n, f, s) {
  1868. var cb, t = this, el = t.events, r;
  1869. // Handle array
  1870. if (o && o instanceof Array) {
  1871. r = [];
  1872. each(o, function(o) {
  1873. o = DOM.get(o);
  1874. r.push(t.add(o, n, f, s));
  1875. });
  1876. return r;
  1877. }
  1878. o = DOM.get(o);
  1879. if (!o)
  1880. return;
  1881. // Setup event callback
  1882. cb = function(e) {
  1883. e = e || window.event;
  1884. // Patch in target in IE it's W3C valid
  1885. if (e && !e.target && isIE)
  1886. e.target = e.srcElement;
  1887. if (!s)
  1888. return f(e);
  1889. return f.call(s, e);
  1890. };
  1891. if (n == 'unload') {
  1892. tinymce.unloads.unshift({func : cb});
  1893. return cb;
  1894. }
  1895. if (n == 'init') {
  1896. if (t.domLoaded)
  1897. cb();
  1898. else
  1899. t.inits.push(cb);
  1900. return cb;
  1901. }
  1902. // Store away listener reference
  1903. el.push({
  1904. obj : o,
  1905. name : n,
  1906. func : f,
  1907. cfunc : cb,
  1908. scope : s
  1909. });
  1910. t._add(o, n, cb);
  1911. return f;
  1912. },
  1913. remove : function(o, n, f) {
  1914. var t = this, a = t.events, s = false, r;
  1915. // Handle array
  1916. if (o && o instanceof Array) {
  1917. r = [];
  1918. each(o, function(o) {
  1919. o = DOM.get(o);
  1920. r.push(t.remove(o, n, f));
  1921. });
  1922. return r;
  1923. }
  1924. o = DOM.get(o);
  1925. each(a, function(e, i) {
  1926. if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) {
  1927. a.splice(i, 1);
  1928. t._remove(o, n, e.cfunc);
  1929. s = true;
  1930. return false;
  1931. }
  1932. });
  1933. return s;
  1934. },
  1935. clear : function(o) {
  1936. var t = this, a = t.events, i, e;
  1937. if (o) {
  1938. o = DOM.get(o);
  1939. for (i = a.length - 1; i >= 0; i--) {
  1940. e = a[i];
  1941. if (e.obj === o) {
  1942. t._remove(e.obj, e.name, e.cfunc);
  1943. e.obj = e.cfunc = null;
  1944. a.splice(i, 1);
  1945. }
  1946. }
  1947. }
  1948. },
  1949. // #endif
  1950. cancel : function(e) {
  1951. if (!e)
  1952. return false;
  1953. this.stop(e);
  1954. return this.prevent(e);
  1955. },
  1956. stop : function(e) {
  1957. if (e.stopPropagation)
  1958. e.stopPropagation();
  1959. else
  1960. e.cancelBubble = true;
  1961. return false;
  1962. },
  1963. prevent : function(e) {
  1964. if (e.preventDefault)
  1965. e.preventDefault();
  1966. else
  1967. e.returnValue = false;
  1968. return false;
  1969. },
  1970. _unload : function() {
  1971. var t = Event;
  1972. each(t.events, function(e, i) {
  1973. t._remove(e.obj, e.name, e.cfunc);
  1974. e.obj = e.cfunc = null;
  1975. });
  1976. t.events = [];
  1977. t = null;
  1978. },
  1979. _add : function(o, n, f) {
  1980. if (o.attachEvent)
  1981. o.attachEvent('on' + n, f);
  1982. else if (o.addEventListener)
  1983. o.addEventListener(n, f, false);
  1984. else
  1985. o['on' + n] = f;
  1986. },
  1987. _remove : function(o, n, f) {
  1988. if (o) {
  1989. try {
  1990. if (o.detachEvent)
  1991. o.detachEvent('on' + n, f);
  1992. else if (o.removeEventListener)
  1993. o.removeEventListener(n, f, false);
  1994. else
  1995. o['on' + n] = null;
  1996. } catch (ex) {
  1997. // Might fail with permission denined on IE so we just ignore that
  1998. }
  1999. }
  2000. },
  2001. _pageInit : function() {
  2002. var e = Event;
  2003. e._remove(window, 'DOMContentLoaded', e._pageInit);
  2004. e.domLoaded = true;
  2005. each(e.inits, function(c) {
  2006. c();
  2007. });
  2008. e.inits = [];
  2009. },
  2010. _wait : function() {
  2011. var t;
  2012. // No need since the document is already loaded
  2013. if (window.tinyMCE_GZ && tinyMCE_GZ.loaded) {
  2014. Event.domLoaded = 1;
  2015. return;
  2016. }
  2017. if (isIE && document.location.protocol != 'https:') {
  2018. // Fake DOMContentLoaded on IE
  2019. document.write('<script id=__ie_onload defer src=\'javascript:""\';><\/script>');
  2020. DOM.get("__ie_onload").onreadystatechange = function() {
  2021. if (this.readyState == "complete") {
  2022. Event._pageInit();
  2023. DOM.get("__ie_onload").onreadystatechange = null; // Prevent leak
  2024. }
  2025. };
  2026. } else {
  2027. Event._add(window, 'DOMContentLoaded', Event._pageInit, Event);
  2028. if (isIE || isWebKit) {
  2029. t = setInterval(function() {
  2030. if (/loaded|complete/.test(document.readyState)) {
  2031. clearInterval(t);
  2032. Event._pageInit();
  2033. }
  2034. }, 10);
  2035. }
  2036. }
  2037. }
  2038. });
  2039. // Shorten name
  2040. Event = tinymce.dom.Event;
  2041. // Dispatch DOM content loaded event for IE and Safari
  2042. Event._wait();
  2043. tinymce.addUnload(Event._unload);
  2044. })();
  2045. /* file:jscripts/tiny_mce/classes/dom/Element.js */
  2046. (function() {
  2047. var each = tinymce.each;
  2048. tinymce.create('tinymce.dom.Element', {
  2049. Element : function(id, s) {
  2050. var t = this, dom, el;
  2051. s = s || {};
  2052. t.id = id;
  2053. t.dom = dom = s.dom || tinymce.DOM;
  2054. t.settings = s;
  2055. // Only IE leaks DOM references, this is a lot faster
  2056. if (!tinymce.isIE)
  2057. el = t.dom.get(t.id);
  2058. each([
  2059. 'getPos',
  2060. 'getRect',
  2061. 'getParent',
  2062. 'add',
  2063. 'setStyle',
  2064. 'getStyle',
  2065. 'setStyles',
  2066. 'setAttrib',
  2067. 'setAttribs',
  2068. 'getAttrib',
  2069. 'addClass',
  2070. 'removeClass',
  2071. 'hasClass',
  2072. 'getOuterHTML',
  2073. 'setOuterHTML',
  2074. 'remove',
  2075. 'show',
  2076. 'hide',
  2077. 'isHidden',
  2078. 'setHTML',
  2079. 'get'
  2080. ], function(k) {
  2081. t[k] = function() {
  2082. var a = arguments, o;
  2083. // Opera fails
  2084. if (tinymce.isOpera) {
  2085. a = [id];
  2086. each(arguments, function(v) {
  2087. a.push(v);
  2088. });
  2089. } else
  2090. Array.prototype.unshift.call(a, el || id);
  2091. o = dom[k].apply(dom, a);
  2092. t.update(k);
  2093. return o;
  2094. };
  2095. });
  2096. },
  2097. on : function(n, f, s) {
  2098. return tinymce.dom.Event.add(this.id, n, f, s);
  2099. },
  2100. getXY : function() {
  2101. return {
  2102. x : parseInt(this.getStyle('left')),
  2103. y : parseInt(this.getStyle('top'))
  2104. };
  2105. },
  2106. getSize : function() {
  2107. var n = this.dom.get(this.id);
  2108. return {
  2109. w : parseInt(this.getStyle('width') || n.clientWidth),
  2110. h : parseInt(this.getStyle('height') || n.clientHeight)
  2111. };
  2112. },
  2113. moveTo : function(x, y) {
  2114. this.setStyles({left : x, top : y});
  2115. },
  2116. moveBy : function(x, y) {
  2117. var p = this.getXY();
  2118. this.moveTo(p.x + x, p.y + y);
  2119. },
  2120. resizeTo : function(w, h) {
  2121. this.setStyles({width : w, height : h});
  2122. },
  2123. resizeBy : function(w, h) {
  2124. var s = this.getSize();
  2125. this.resizeTo(s.w + w, s.h + h);
  2126. },
  2127. update : function(k) {
  2128. var t = this, b, dom = t.dom;
  2129. if (tinymce.isIE6 && t.settings.blocker) {
  2130. k = k || '';
  2131. // Ignore getters
  2132. if (k.indexOf('get') === 0 || k.indexOf('has') === 0 || k.indexOf('is') === 0)
  2133. return;
  2134. // Remove blocker on remove
  2135. if (k == 'remove') {
  2136. dom.remove(t.blocker);
  2137. return;
  2138. }
  2139. if (!t.blocker) {
  2140. t.blocker = dom.uniqueId();
  2141. b = dom.add(t.settings.container || dom.getRoot(), 'iframe', {id : t.blocker, style : 'position:absolute;', frameBorder : 0, src : 'javascript:""'});
  2142. dom.setStyle(b, 'opacity', 0);
  2143. } else
  2144. b = dom.get(t.blocker);
  2145. dom.setStyle(b, 'left', t.getStyle('left', 1));
  2146. dom.setStyle(b, 'top', t.getStyle('top', 1));
  2147. dom.setStyle(b, 'width', t.getStyle('width', 1));
  2148. dom.setStyle(b, 'height', t.getStyle('height', 1));
  2149. dom.setStyle(b, 'display', t.getStyle('display', 1));
  2150. dom.setStyle(b, 'zIndex', parseInt(t.getStyle('zIndex', 1) || 0) - 1);
  2151. }
  2152. }
  2153. });
  2154. })();
  2155. /* file:jscripts/tiny_mce/classes/dom/Selection.js */
  2156. (function() {
  2157. function trimNl(s) {
  2158. return s.replace(/[\n\r]+/g, '');
  2159. };
  2160. // Shorten names
  2161. var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each;
  2162. tinymce.create('tinymce.dom.Selection', {
  2163. Selection : function(dom, win, serializer) {
  2164. var t = this;
  2165. t.dom = dom;
  2166. t.win = win;
  2167. t.serializer = serializer;
  2168. // Add events
  2169. each([
  2170. 'onBeforeSetContent',
  2171. 'onBeforeGetContent',
  2172. 'onSetContent',
  2173. 'onGetContent'
  2174. ], function(e) {
  2175. t[e] = new tinymce.util.Dispatcher(t);
  2176. });
  2177. // Prevent leaks
  2178. tinymce.addUnload(t.destroy, t);
  2179. },
  2180. getContent : function(s) {
  2181. var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n;
  2182. s = s || {};
  2183. wb = wa = '';
  2184. s.get = true;
  2185. s.format = s.format || 'html';
  2186. t.onBeforeGetContent.dispatch(t, s);
  2187. if (s.format == 'text')
  2188. return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : ''));
  2189. if (r.cloneContents) {
  2190. n = r.cloneContents();
  2191. if (n)
  2192. e.appendChild(n);
  2193. } else if (is(r.item) || is(r.htmlText))
  2194. e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
  2195. else
  2196. e.innerHTML = r.toString();
  2197. // Keep whitespace before and after
  2198. if (/^\s/.test(e.innerHTML))
  2199. wb = ' ';
  2200. if (/\s+$/.test(e.innerHTML))
  2201. wa = ' ';
  2202. s.getInner = true;
  2203. s.content = t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa;
  2204. t.onGetContent.dispatch(t, s);
  2205. return s.content;
  2206. },
  2207. setContent : function(h, s) {
  2208. var t = this, r = t.getRng(), c, d = t.win.document;
  2209. s = s || {format : 'html'};
  2210. s.set = true;
  2211. h = s.content = t.dom.processHTML(h);
  2212. // Dispatch before set content event
  2213. t.onBeforeSetContent.dispatch(t, s);
  2214. h = s.content;
  2215. if (r.insertNode) {
  2216. // Make caret marker since insertNode places the caret in the beginning of text after insert
  2217. h += '<span id="__caret">_</span>';
  2218. // Delete and insert new node
  2219. r.deleteContents();
  2220. r.insertNode(t.getRng().createContextualFragment(h));
  2221. // Move to caret marker
  2222. c = t.dom.get('__caret');
  2223. // Make sure we wrap it compleatly, Opera fails with a simple select call
  2224. r = d.createRange();
  2225. r.setStartBefore(c);
  2226. r.setEndAfter(c);
  2227. t.setRng(r);
  2228. // Delete the marker, and hopefully the caret gets placed in the right location
  2229. d.execCommand('Delete', false, null);
  2230. // In case it's still there
  2231. t.dom.remove('__caret');
  2232. } else {
  2233. if (r.item) {
  2234. // Delete content and get caret text selection
  2235. d.execCommand('Delete', false, null);
  2236. r = t.getRng();
  2237. }
  2238. r.pasteHTML(h);
  2239. }
  2240. // Dispatch set content event
  2241. t.onSetContent.dispatch(t, s);
  2242. },
  2243. getStart : function() {
  2244. var t = this, r = t.getRng(), e;
  2245. if (isIE) {
  2246. if (r.item)
  2247. return r.item(0);
  2248. r = r.duplicate();
  2249. r.collapse(1);
  2250. e = r.parentElement();
  2251. if (e && e.nodeName == 'BODY')
  2252. return e.firstChild;
  2253. return e;
  2254. } else {
  2255. e = r.startContainer;
  2256. if (e.nodeName == 'BODY')
  2257. return e.firstChild;
  2258. return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
  2259. }
  2260. },
  2261. getEnd : function() {
  2262. var t = this, r = t.getRng(), e;
  2263. if (isIE) {
  2264. if (r.item)
  2265. return r.item(0);
  2266. r = r.duplicate();
  2267. r.collapse(0);
  2268. e = r.parentElement();
  2269. if (e && e.nodeName == 'BODY')
  2270. return e.lastChild;
  2271. return e;
  2272. } else {
  2273. e = r.endContainer;
  2274. if (e.nodeName == 'BODY')
  2275. return e.lastChild;
  2276. return t.dom.getParent(e, function(n) {return n.nodeType == 1;});
  2277. }
  2278. },
  2279. getBookmark : function(si) {
  2280. var t = this, r = t.getRng(), tr, sx, sy, vp = t.dom.getViewPort(t.win), e, sp, bp, le, c = -0xFFFFFF, s, ro = t.dom.getRoot(), wb = 0, wa = 0, nv;
  2281. sx = vp.x;
  2282. sy = vp.y;
  2283. // Simple bookmark fast but not as persistent
  2284. if (si == 'simple')
  2285. return {rng : r, scrollX : sx, scrollY : sy};
  2286. // Handle IE
  2287. if (isIE) {
  2288. // Control selection
  2289. if (r.item) {
  2290. e = r.item(0);
  2291. each(t.dom.select(e.nodeName), function(n, i) {
  2292. if (e == n) {
  2293. sp = i;
  2294. return false;
  2295. }
  2296. });
  2297. return {
  2298. tag : e.nodeName,
  2299. index : sp,
  2300. scrollX : sx,
  2301. scrollY : sy
  2302. };
  2303. }
  2304. // Text selection
  2305. tr = t.dom.doc.body.createTextRange();
  2306. tr.moveToElementText(ro);
  2307. tr.collapse(true);
  2308. bp = Math.abs(tr.move('character', c));
  2309. tr = r.duplicate();
  2310. tr.collapse(true);
  2311. sp = Math.abs(tr.move('character', c));
  2312. tr = r.duplicate();
  2313. tr.collapse(false);
  2314. le = Math.abs(tr.move('character', c)) - sp;
  2315. return {
  2316. start : sp - bp,
  2317. length : le,
  2318. scrollX : sx,
  2319. scrollY : sy
  2320. };
  2321. }
  2322. // Handle W3C
  2323. e = t.getNode();
  2324. s = t.getSel();
  2325. if (!s)
  2326. return null;
  2327. // Image selection
  2328. if (e && e.nodeName == 'IMG') {
  2329. return {
  2330. scrollX : sx,
  2331. scrollY : sy
  2332. };
  2333. }
  2334. // Text selection
  2335. function getPos(r, sn, en) {
  2336. var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
  2337. while ((n = w.nextNode()) != null) {
  2338. if (n == sn)
  2339. d.start = p;
  2340. if (n == en) {
  2341. d.end = p;
  2342. return d;
  2343. }
  2344. p += trimNl(n.nodeValue || '').length;
  2345. }
  2346. return null;
  2347. };
  2348. // Caret or selection
  2349. if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
  2350. e = getPos(ro, s.anchorNode, s.focusNode);
  2351. if (!e)
  2352. return {scrollX : sx, scrollY : sy};
  2353. // Count whitespace before
  2354. trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
  2355. return {
  2356. start : Math.max(e.start + s.anchorOffset - wb, 0),
  2357. end : Math.max(e.end + s.focusOffset - wb, 0),
  2358. scrollX : sx,
  2359. scrollY : sy,
  2360. beg : s.anchorOffset - wb == 0
  2361. };
  2362. } else {
  2363. e = getPos(ro, r.startContainer, r.endContainer);
  2364. // Count whitespace before start and end container
  2365. //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;});
  2366. //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;});
  2367. if (!e)
  2368. return {scrollX : sx, scrollY : sy};
  2369. return {
  2370. start : Math.max(e.start + r.startOffset - wb, 0),
  2371. end : Math.max(e.end + r.endOffset - wa, 0),
  2372. scrollX : sx,
  2373. scrollY : sy,
  2374. beg : r.startOffset - wb == 0
  2375. };
  2376. }
  2377. },
  2378. moveToBookmark : function(b) {
  2379. var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv;
  2380. function getPos(r, sp, ep) {
  2381. var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb;
  2382. while ((n = w.nextNode()) != null) {
  2383. wa = wb = 0;
  2384. nv = n.nodeValue || '';
  2385. //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;});
  2386. //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;});
  2387. nvl = trimNl(nv).length;
  2388. p += nvl;
  2389. if (p >= sp && !d.startNode) {
  2390. o = sp - (p - nvl);
  2391. // Fix for odd quirk in FF
  2392. if (b.beg && o >= nvl)
  2393. continue;
  2394. d.startNode = n;
  2395. d.startOffset = o + wb;
  2396. }
  2397. if (p >= ep) {
  2398. d.endNode = n;
  2399. d.endOffset = ep - (p - nvl) + wb;
  2400. return d;
  2401. }
  2402. }
  2403. return null;
  2404. };
  2405. if (!b)
  2406. return false;
  2407. t.win.scrollTo(b.scrollX, b.scrollY);
  2408. // Handle explorer
  2409. if (isIE) {
  2410. // Handle simple
  2411. if (r = b.rng) {
  2412. try {
  2413. r.select();
  2414. } catch (ex) {
  2415. // Ignore
  2416. }
  2417. return true;
  2418. }
  2419. t.win.focus();
  2420. // Handle control bookmark
  2421. if (b.tag) {
  2422. r = ro.createControlRange();
  2423. each(t.dom.select(b.tag), function(n, i) {
  2424. if (i == b.index)
  2425. r.addElement(n);
  2426. });
  2427. } else {
  2428. // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
  2429. try {
  2430. // Incorrect bookmark
  2431. if (b.start < 0)
  2432. return true;
  2433. r = s.createRange();
  2434. r.moveToElementText(ro);
  2435. r.collapse(true);
  2436. r.moveStart('character', b.start);
  2437. r.moveEnd('character', b.length);
  2438. } catch (ex2) {
  2439. return true;
  2440. }
  2441. }
  2442. try {
  2443. r.select();
  2444. } catch (ex) {
  2445. // Needed for some odd IE bug #1843306
  2446. }
  2447. return true;
  2448. }
  2449. // Handle W3C
  2450. if (!s)
  2451. return false;
  2452. // Handle simple
  2453. if (b.rng) {
  2454. s.removeAllRanges();
  2455. s.addRange(b.rng);
  2456. } else {
  2457. if (is(b.start) && is(b.end)) {
  2458. try {
  2459. sd = getPos(ro, b.start, b.end);
  2460. if (sd) {
  2461. r = t.dom.doc.createRange();
  2462. r.setStart(sd.startNode, sd.startOffset);
  2463. r.setEnd(sd.endNode, sd.endOffset);
  2464. s.removeAllRanges();
  2465. s.addRange(r);
  2466. }
  2467. if (!tinymce.isOpera)
  2468. t.win.focus();
  2469. } catch (ex) {
  2470. // Ignore
  2471. }
  2472. }
  2473. }
  2474. },
  2475. select : function(n, c) {
  2476. var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document;
  2477. function first(n) {
  2478. return n ? d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() : null;
  2479. };
  2480. function last(n) {
  2481. var c, o, w;
  2482. if (!n)
  2483. return null;
  2484. w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
  2485. while (c = w.nextNode())
  2486. o = c;
  2487. return o;
  2488. };
  2489. if (isIE) {
  2490. try {
  2491. b = d.body;
  2492. if (/^(IMG|TABLE)$/.test(n.nodeName)) {
  2493. r = b.createControlRange();
  2494. r.addElement(n);
  2495. } else {
  2496. r = b.createTextRange();
  2497. r.moveToElementText(n);
  2498. }
  2499. r.select();
  2500. } catch (ex) {
  2501. // Throws illigal agrument in IE some times
  2502. }
  2503. } else {
  2504. if (c) {
  2505. fn = first(n);
  2506. ln = last(n);
  2507. if (fn && ln) {
  2508. //console.debug(fn, ln);
  2509. r = d.createRange();
  2510. r.setStart(fn, 0);
  2511. r.setEnd(ln, ln.nodeValue.length);
  2512. } else
  2513. r.selectNode(n);
  2514. } else
  2515. r.selectNode(n);
  2516. t.setRng(r);
  2517. }
  2518. return n;
  2519. },
  2520. isCollapsed : function() {
  2521. var t = this, r = t.getRng(), s = t.getSel();
  2522. if (!r || r.item)
  2523. return false;
  2524. return !s || r.boundingWidth == 0 || r.collapsed;
  2525. },
  2526. collapse : function(b) {
  2527. var t = this, r = t.getRng(), n;
  2528. // Control range on IE
  2529. if (r.item) {
  2530. n = r.item(0);
  2531. r = this.win.document.body.createTextRange();
  2532. r.moveToElementText(n);
  2533. }
  2534. r.collapse(!!b);
  2535. t.setRng(r);
  2536. },
  2537. getSel : function() {
  2538. var t = this, w = this.win;
  2539. return w.getSelection ? w.getSelection() : w.document.selection;
  2540. },
  2541. getRng : function() {
  2542. var t = this, s = t.getSel(), r;
  2543. try {
  2544. if (s)
  2545. r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange());
  2546. } catch (ex) {
  2547. // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
  2548. }
  2549. // No range found then create an empty one
  2550. // This can occur when the editor is placed in a hidden container element on Gecko
  2551. // Or on IE when there was an exception
  2552. if (!r)
  2553. r = isIE ? t.win.document.body.createTextRange() : t.win.document.createRange();
  2554. return r;
  2555. },
  2556. setRng : function(r) {
  2557. var s;
  2558. if (!isIE) {
  2559. s = this.getSel();
  2560. if (s) {
  2561. s.removeAllRanges();
  2562. s.addRange(r);
  2563. }
  2564. } else {
  2565. try {
  2566. r.select();
  2567. } catch (ex) {
  2568. // Needed for some odd IE bug #1843306
  2569. }
  2570. }
  2571. },
  2572. setNode : function(n) {
  2573. var t = this;
  2574. t.setContent(t.dom.getOuterHTML(n));
  2575. return n;
  2576. },
  2577. getNode : function() {
  2578. var t = this, r = t.getRng(), s = t.getSel(), e;
  2579. if (!isIE) {
  2580. // Range maybe lost after the editor is made visible again
  2581. if (!r)
  2582. return t.dom.getRoot();
  2583. e = r.commonAncestorContainer;
  2584. // Handle selection a image or other control like element such as anchors
  2585. if (!r.collapsed) {
  2586. // If the anchor node is a element instead of a text node then return this element
  2587. if (tinymce.isWebKit && s.anchorNode && s.anchorNode.nodeType == 1)
  2588. return s.anchorNode.childNodes[s.anchorOffset];
  2589. if (r.startContainer == r.endContainer) {
  2590. if (r.startOffset - r.endOffset < 2) {
  2591. if (r.startContainer.hasChildNodes())
  2592. e = r.startContainer.childNodes[r.startOffset];
  2593. }
  2594. }
  2595. }
  2596. return t.dom.getParent(e, function(n) {
  2597. return n.nodeType == 1;
  2598. });
  2599. }
  2600. return r.item ? r.item(0) : r.parentElement();
  2601. },
  2602. destroy : function(s) {
  2603. var t = this;
  2604. t.win = null;
  2605. // Manual destroy then remove unload handler
  2606. if (!s)
  2607. tinymce.removeUnload(t.destroy);
  2608. }
  2609. });
  2610. })();
  2611. /* file:jscripts/tiny_mce/classes/dom/XMLWriter.js */
  2612. (function() {
  2613. tinymce.create('tinymce.dom.XMLWriter', {
  2614. node : null,
  2615. XMLWriter : function(s) {
  2616. // Get XML document
  2617. function getXML() {
  2618. var i = document.implementation;
  2619. if (!i || !i.createDocument) {
  2620. // Try IE objects
  2621. try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {}
  2622. try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {}
  2623. } else
  2624. return i.createDocument('', '', null);
  2625. };
  2626. this.doc = getXML();
  2627. // Since Opera and WebKit doesn't escape > into &gt; we need to do it our self to normalize the output for all browsers
  2628. this.valid = tinymce.isOpera || tinymce.isWebKit;
  2629. this.reset();
  2630. },
  2631. reset : function() {
  2632. var t = this, d = t.doc;
  2633. if (d.firstChild)
  2634. d.removeChild(d.firstChild);
  2635. t.node = d.appendChild(d.createElement("html"));
  2636. },
  2637. writeStartElement : function(n) {
  2638. var t = this;
  2639. t.node = t.node.appendChild(t.doc.createElement(n));
  2640. },
  2641. writeAttribute : function(n, v) {
  2642. if (this.valid)
  2643. v = v.replace(/>/g, '%MCGT%');
  2644. this.node.setAttribute(n, v);
  2645. },
  2646. writeEndElement : function() {
  2647. this.node = this.node.parentNode;
  2648. },
  2649. writeFullEndElement : function() {
  2650. var t = this, n = t.node;
  2651. n.appendChild(t.doc.createTextNode(""));
  2652. t.node = n.parentNode;
  2653. },
  2654. writeText : function(v) {
  2655. if (this.valid)
  2656. v = v.replace(/>/g, '%MCGT%');
  2657. this.node.appendChild(this.doc.createTextNode(v));
  2658. },
  2659. writeCDATA : function(v) {
  2660. this.node.appendChild(this.doc.createCDATA(v));
  2661. },
  2662. writeComment : function(v) {
  2663. // Fix for bug #2035694
  2664. if (tinymce.isIE)
  2665. v = v.replace(/^\-|\-$/g, ' ');
  2666. this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' ')));
  2667. },
  2668. getContent : function() {
  2669. var h;
  2670. h = this.doc.xml || new XMLSerializer().serializeToString(this.doc);
  2671. h = h.replace(/<\?[^?]+\?>|<html>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g, '');
  2672. h = h.replace(/ ?\/>/g, ' />');
  2673. if (this.valid)
  2674. h = h.replace(/\%MCGT%/g, '&gt;');
  2675. return h;
  2676. }
  2677. });
  2678. })();
  2679. /* file:jscripts/tiny_mce/classes/dom/StringWriter.js */
  2680. (function() {
  2681. tinymce.create('tinymce.dom.StringWriter', {
  2682. str : null,
  2683. tags : null,
  2684. count : 0,
  2685. settings : null,
  2686. indent : null,
  2687. StringWriter : function(s) {
  2688. this.settings = tinymce.extend({
  2689. indent_char : ' ',
  2690. indentation : 1
  2691. }, s);
  2692. this.reset();
  2693. },
  2694. reset : function() {
  2695. this.indent = '';
  2696. this.str = "";
  2697. this.tags = [];
  2698. this.count = 0;
  2699. },
  2700. writeStartElement : function(n) {
  2701. this._writeAttributesEnd();
  2702. this.writeRaw('<' + n);
  2703. this.tags.push(n);
  2704. this.inAttr = true;
  2705. this.count++;
  2706. this.elementCount = this.count;
  2707. },
  2708. writeAttribute : function(n, v) {
  2709. var t = this;
  2710. t.writeRaw(" " + t.encode(n) + '="' + t.encode(v) + '"');
  2711. },
  2712. writeEndElement : function() {
  2713. var n;
  2714. if (this.tags.length > 0) {
  2715. n = this.tags.pop();
  2716. if (this._writeAttributesEnd(1))
  2717. this.writeRaw('</' + n + '>');
  2718. if (this.settings.indentation > 0)
  2719. this.writeRaw('\n');
  2720. }
  2721. },
  2722. writeFullEndElement : function() {
  2723. if (this.tags.length > 0) {
  2724. this._writeAttributesEnd();
  2725. this.writeRaw('</' + this.tags.pop() + '>');
  2726. if (this.settings.indentation > 0)
  2727. this.writeRaw('\n');
  2728. }
  2729. },
  2730. writeText : function(v) {
  2731. this._writeAttributesEnd();
  2732. this.writeRaw(this.encode(v));
  2733. this.count++;
  2734. },
  2735. writeCDATA : function(v) {
  2736. this._writeAttributesEnd();
  2737. this.writeRaw('<![CDATA[' + v + ']]>');
  2738. this.count++;
  2739. },
  2740. writeComment : function(v) {
  2741. this._writeAttributesEnd();
  2742. this.writeRaw('<!-- ' + v + '-->');
  2743. this.count++;
  2744. },
  2745. writeRaw : function(v) {
  2746. this.str += v;
  2747. },
  2748. encode : function(s) {
  2749. return s.replace(/[<>&"]/g, function(v) {
  2750. switch (v) {
  2751. case '<':
  2752. return '&lt;';
  2753. case '>':
  2754. return '&gt;';
  2755. case '&':
  2756. return '&amp;';
  2757. case '"':
  2758. return '&quot;';
  2759. }
  2760. return v;
  2761. });
  2762. },
  2763. getContent : function() {
  2764. return this.str;
  2765. },
  2766. _writeAttributesEnd : function(s) {
  2767. if (!this.inAttr)
  2768. return;
  2769. this.inAttr = false;
  2770. if (s && this.elementCount == this.count) {
  2771. this.writeRaw(' />');
  2772. return false;
  2773. }
  2774. this.writeRaw('>');
  2775. return true;
  2776. }
  2777. });
  2778. })();
  2779. /* file:jscripts/tiny_mce/classes/dom/Serializer.js */
  2780. (function() {
  2781. // Shorten names
  2782. var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko;
  2783. // Returns only attribites that have values not all attributes in IE
  2784. function getIEAtts(n) {
  2785. var o = [];
  2786. // Object will throw exception in IE
  2787. if (n.nodeName == 'OBJECT')
  2788. return n.attributes;
  2789. n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi, function(a, b) {
  2790. o.push({specified : 1, nodeName : b});
  2791. });
  2792. return o;
  2793. };
  2794. function wildcardToRE(s) {
  2795. return s.replace(/([?+*])/g, '.$1');
  2796. };
  2797. tinymce.create('tinymce.dom.Serializer', {
  2798. Serializer : function(s) {
  2799. var t = this;
  2800. t.key = 0;
  2801. t.onPreProcess = new Dispatcher(t);
  2802. t.onPostProcess = new Dispatcher(t);
  2803. if (tinymce.relaxedDomain && tinymce.isGecko) {
  2804. // Gecko has a bug where we can't create a new XML document if domain relaxing is used
  2805. t.writer = new tinymce.dom.StringWriter();
  2806. } else {
  2807. try {
  2808. t.writer = new tinymce.dom.XMLWriter();
  2809. } catch (ex) {
  2810. // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter
  2811. t.writer = new tinymce.dom.StringWriter();
  2812. }
  2813. }
  2814. // Default settings
  2815. t.settings = s = extend({
  2816. dom : tinymce.DOM,
  2817. valid_nodes : 0,
  2818. node_filter : 0,
  2819. attr_filter : 0,
  2820. invalid_attrs : /^(mce_|_moz_)/,
  2821. closed : /(br|hr|input|meta|img|link|param)/,
  2822. entity_encoding : 'named',
  2823. entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro',
  2824. valid_elements : '*[*]',
  2825. extended_valid_elements : 0,
  2826. valid_child_elements : 0,
  2827. invalid_elements : 0,
  2828. fix_table_elements : 0,
  2829. fix_list_elements : true,
  2830. fix_content_duplication : true,
  2831. convert_fonts_to_spans : false,
  2832. font_size_classes : 0,
  2833. font_size_style_values : 0,
  2834. apply_source_formatting : 0,
  2835. indent_mode : 'simple',
  2836. indent_char : '\t',
  2837. indent_levels : 1,
  2838. remove_linebreaks : 1,
  2839. remove_redundant_brs : 1,
  2840. element_format : 'xhtml'
  2841. }, s);
  2842. t.dom = s.dom;
  2843. if (s.remove_redundant_brs) {
  2844. t.onPostProcess.add(function(se, o) {
  2845. // Remove BR elements at end of list elements since they get rendered in IE
  2846. o.content = o.content.replace(/<br \/>(\s*<\/li>)/g, '$1');
  2847. });
  2848. }
  2849. // Remove XHTML element endings i.e. produce crap :) XHTML is better
  2850. if (s.element_format == 'html') {
  2851. t.onPostProcess.add(function(se, o) {
  2852. o.content = o.content.replace(/<([^>]+) \/>/g, '<$1>');
  2853. });
  2854. }
  2855. if (s.fix_list_elements) {
  2856. t.onPreProcess.add(function(se, o) {
  2857. var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np;
  2858. function prevNode(e, n) {
  2859. var a = n.split(','), i;
  2860. while ((e = e.previousSibling) != null) {
  2861. for (i=0; i<a.length; i++) {
  2862. if (e.nodeName == a[i])
  2863. return e;
  2864. }
  2865. }
  2866. return null;
  2867. };
  2868. for (x=0; x<a.length; x++) {
  2869. nl = t.dom.select(a[x], o.node);
  2870. for (i=0; i<nl.length; i++) {
  2871. n = nl[i];
  2872. p = n.parentNode;
  2873. if (r.test(p.nodeName)) {
  2874. np = prevNode(n, 'LI');
  2875. if (!np) {
  2876. np = t.dom.create('li');
  2877. np.innerHTML = '&nbsp;';
  2878. np.appendChild(n);
  2879. p.insertBefore(np, p.firstChild);
  2880. } else
  2881. np.appendChild(n);
  2882. }
  2883. }
  2884. }
  2885. });
  2886. }
  2887. if (s.fix_table_elements) {
  2888. t.onPreProcess.add(function(se, o) {
  2889. each(t.dom.select('table', o.node), function(e) {
  2890. var pa = t.dom.getParent(e, 'H1,H2,H3,H4,H5,H6,P'), pa2, n, tm, pl = [], i, ns;
  2891. if (pa) {
  2892. pa2 = pa.cloneNode(false);
  2893. pl.push(e);
  2894. for (n = e; n = n.parentNode;) {
  2895. pl.push(n);
  2896. if (n == pa)
  2897. break;
  2898. }
  2899. tm = pa2;
  2900. for (i = pl.length - 1; i >= 0; i--) {
  2901. if (i == pl.length - 1) {
  2902. while (ns = pl[i - 1].nextSibling)
  2903. tm.appendChild(ns.parentNode.removeChild(ns));
  2904. } else {
  2905. n = pl[i].cloneNode(false);
  2906. if (i != 0) {
  2907. while (ns = pl[i - 1].nextSibling)
  2908. n.appendChild(ns.parentNode.removeChild(ns));
  2909. }
  2910. tm = tm.appendChild(n);
  2911. }
  2912. }
  2913. e = t.dom.insertAfter(e.parentNode.removeChild(e), pa);
  2914. t.dom.insertAfter(e, pa);
  2915. t.dom.insertAfter(pa2, e);
  2916. }
  2917. });
  2918. });
  2919. }
  2920. },
  2921. setEntities : function(s) {
  2922. var t = this, a, i, l = {}, re = '', v;
  2923. // No need to setup more than once
  2924. if (t.entityLookup)
  2925. return;
  2926. // Build regex and lookup array
  2927. a = s.split(',');
  2928. for (i = 0; i < a.length; i += 2) {
  2929. v = a[i];
  2930. // Don't add default &amp; &quot; etc.
  2931. if (v == 34 || v == 38 || v == 60 || v == 62)
  2932. continue;
  2933. l[String.fromCharCode(a[i])] = a[i + 1];
  2934. v = parseInt(a[i]).toString(16);
  2935. re += '\\u' + '0000'.substring(v.length) + v;
  2936. }
  2937. if (!re) {
  2938. t.settings.entity_encoding = 'raw';
  2939. return;
  2940. }
  2941. t.entitiesRE = new RegExp('[' + re + ']', 'g');
  2942. t.entityLookup = l;
  2943. },
  2944. setValidChildRules : function(s) {
  2945. this.childRules = null;
  2946. this.addValidChildRules(s);
  2947. },
  2948. addValidChildRules : function(s) {
  2949. var t = this, inst, intr, bloc;
  2950. if (!s)
  2951. return;
  2952. inst = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';
  2953. intr = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';
  2954. bloc = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
  2955. each(s.split(','), function(s) {
  2956. var p = s.split(/\[|\]/), re;
  2957. s = '';
  2958. each(p[1].split('|'), function(v) {
  2959. if (s)
  2960. s += '|';
  2961. switch (v) {
  2962. case '%itrans':
  2963. v = intr;
  2964. break;
  2965. case '%itrans_na':
  2966. v = intr.substring(2);
  2967. break;
  2968. case '%istrict':
  2969. v = inst;
  2970. break;
  2971. case '%istrict_na':
  2972. v = inst.substring(2);
  2973. break;
  2974. case '%btrans':
  2975. v = bloc;
  2976. break;
  2977. case '%bstrict':
  2978. v = bloc;
  2979. break;
  2980. }
  2981. s += v;
  2982. });
  2983. re = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
  2984. each(p[0].split('/'), function(s) {
  2985. t.childRules = t.childRules || {};
  2986. t.childRules[s] = re;
  2987. });
  2988. });
  2989. // Build regex
  2990. s = '';
  2991. each(t.childRules, function(v, k) {
  2992. if (s)
  2993. s += '|';
  2994. s += k;
  2995. });
  2996. t.parentElementsRE = new RegExp('^(' + s.toLowerCase() + ')$', 'i');
  2997. /*console.debug(t.parentElementsRE.toString());
  2998. each(t.childRules, function(v) {
  2999. console.debug(v.toString());
  3000. });*/
  3001. },
  3002. setRules : function(s) {
  3003. var t = this;
  3004. t._setup();
  3005. t.rules = {};
  3006. t.wildRules = [];
  3007. t.validElements = {};
  3008. return t.addRules(s);
  3009. },
  3010. addRules : function(s) {
  3011. var t = this, dr;
  3012. if (!s)
  3013. return;
  3014. t._setup();
  3015. each(s.split(','), function(s) {
  3016. var p = s.split(/\[|\]/), tn = p[0].split('/'), ra, at, wat, va = [];
  3017. // Extend with default rules
  3018. if (dr)
  3019. at = tinymce.extend([], dr.attribs);
  3020. // Parse attributes
  3021. if (p.length > 1) {
  3022. each(p[1].split('|'), function(s) {
  3023. var ar = {}, i;
  3024. at = at || [];
  3025. // Parse attribute rule
  3026. s = s.replace(/::/g, '~');
  3027. s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s);
  3028. s[2] = s[2].replace(/~/g, ':');
  3029. // Add required attributes
  3030. if (s[1] == '!') {
  3031. ra = ra || [];
  3032. ra.push(s[2]);
  3033. }
  3034. // Remove inherited attributes
  3035. if (s[1] == '-') {
  3036. for (i = 0; i <at.length; i++) {
  3037. if (at[i].name == s[2]) {
  3038. at.splice(i, 1);
  3039. return;
  3040. }
  3041. }
  3042. }
  3043. switch (s[3]) {
  3044. // Add default attrib values
  3045. case '=':
  3046. ar.defaultVal = s[4] || '';
  3047. break;
  3048. // Add forced attrib values
  3049. case ':':
  3050. ar.forcedVal = s[4];
  3051. break;
  3052. // Add validation values
  3053. case '<':
  3054. ar.validVals = s[4].split('?');
  3055. break;
  3056. }
  3057. if (/[*.?]/.test(s[2])) {
  3058. wat = wat || [];
  3059. ar.nameRE = new RegExp('^' + wildcardToRE(s[2]) + '$');
  3060. wat.push(ar);
  3061. } else {
  3062. ar.name = s[2];
  3063. at.push(ar);
  3064. }
  3065. va.push(s[2]);
  3066. });
  3067. }
  3068. // Handle element names
  3069. each(tn, function(s, i) {
  3070. var pr = s.charAt(0), x = 1, ru = {};
  3071. // Extend with default rule data
  3072. if (dr) {
  3073. if (dr.noEmpty)
  3074. ru.noEmpty = dr.noEmpty;
  3075. if (dr.fullEnd)
  3076. ru.fullEnd = dr.fullEnd;
  3077. if (dr.padd)
  3078. ru.padd = dr.padd;
  3079. }
  3080. // Handle prefixes
  3081. switch (pr) {
  3082. case '-':
  3083. ru.noEmpty = true;
  3084. break;
  3085. case '+':
  3086. ru.fullEnd = true;
  3087. break;
  3088. case '#':
  3089. ru.padd = true;
  3090. break;
  3091. default:
  3092. x = 0;
  3093. }
  3094. tn[i] = s = s.substring(x);
  3095. t.validElements[s] = 1;
  3096. // Add element name or element regex
  3097. if (/[*.?]/.test(tn[0])) {
  3098. ru.nameRE = new RegExp('^' + wildcardToRE(tn[0]) + '$');
  3099. t.wildRules = t.wildRules || {};
  3100. t.wildRules.push(ru);
  3101. } else {
  3102. ru.name = tn[0];
  3103. // Store away default rule
  3104. if (tn[0] == '@')
  3105. dr = ru;
  3106. t.rules[s] = ru;
  3107. }
  3108. ru.attribs = at;
  3109. if (ra)
  3110. ru.requiredAttribs = ra;
  3111. if (wat) {
  3112. // Build valid attributes regexp
  3113. s = '';
  3114. each(va, function(v) {
  3115. if (s)
  3116. s += '|';
  3117. s += '(' + wildcardToRE(v) + ')';
  3118. });
  3119. ru.validAttribsRE = new RegExp('^' + s.toLowerCase() + '$');
  3120. ru.wildAttribs = wat;
  3121. }
  3122. });
  3123. });
  3124. // Build valid elements regexp
  3125. s = '';
  3126. each(t.validElements, function(v, k) {
  3127. if (s)
  3128. s += '|';
  3129. if (k != '@')
  3130. s += k;
  3131. });
  3132. t.validElementsRE = new RegExp('^(' + wildcardToRE(s.toLowerCase()) + ')$');
  3133. //console.debug(t.validElementsRE.toString());
  3134. //console.dir(t.rules);
  3135. //console.dir(t.wildRules);
  3136. },
  3137. findRule : function(n) {
  3138. var t = this, rl = t.rules, i, r;
  3139. t._setup();
  3140. // Exact match
  3141. r = rl[n];
  3142. if (r)
  3143. return r;
  3144. // Try wildcards
  3145. rl = t.wildRules;
  3146. for (i = 0; i < rl.length; i++) {
  3147. if (rl[i].nameRE.test(n))
  3148. return rl[i];
  3149. }
  3150. return null;
  3151. },
  3152. findAttribRule : function(ru, n) {
  3153. var i, wa = ru.wildAttribs;
  3154. for (i = 0; i < wa.length; i++) {
  3155. if (wa[i].nameRE.test(n))
  3156. return wa[i];
  3157. }
  3158. return null;
  3159. },
  3160. serialize : function(n, o) {
  3161. var h, t = this;
  3162. t._setup();
  3163. o = o || {};
  3164. o.format = o.format || 'html';
  3165. t.processObj = o;
  3166. n = n.cloneNode(true);
  3167. t.key = '' + (parseInt(t.key) + 1);
  3168. // Pre process
  3169. if (!o.no_events) {
  3170. o.node = n;
  3171. t.onPreProcess.dispatch(t, o);
  3172. }
  3173. // Serialize HTML DOM into a string
  3174. t.writer.reset();
  3175. t._serializeNode(n, o.getInner);
  3176. // Post process
  3177. o.content = t.writer.getContent();
  3178. if (!o.no_events)
  3179. t.onPostProcess.dispatch(t, o);
  3180. t._postProcess(o);
  3181. o.node = null;
  3182. return tinymce.trim(o.content);
  3183. },
  3184. // Internal functions
  3185. _postProcess : function(o) {
  3186. var t = this, s = t.settings, h = o.content, sc = [], p;
  3187. if (o.format == 'html') {
  3188. // Protect some elements
  3189. p = t._protect({
  3190. content : h,
  3191. patterns : [
  3192. {pattern : /(<script[^>]*>)(.*?)(<\/script>)/g},
  3193. {pattern : /(<style[^>]*>)(.*?)(<\/style>)/g},
  3194. {pattern : /(<pre[^>]*>)(.*?)(<\/pre>)/g, encode : 1},
  3195. {pattern : /(<!--\[CDATA\[)(.*?)(\]\]-->)/g}
  3196. ]
  3197. });
  3198. h = p.content;
  3199. // Entity encode
  3200. if (s.entity_encoding !== 'raw')
  3201. h = t._encode(h);
  3202. // Use BR instead of &nbsp; padded P elements inside editor and use <p>&nbsp;</p> outside editor
  3203. /* if (o.set)
  3204. h = h.replace(/<p>\s+(&nbsp;|&#160;|\u00a0|<br \/>)\s+<\/p>/g, '<p><br /></p>');
  3205. else
  3206. h = h.replace(/<p>\s+(&nbsp;|&#160;|\u00a0|<br \/>)\s+<\/p>/g, '<p>$1</p>');*/
  3207. // Since Gecko and Safari keeps whitespace in the DOM we need to
  3208. // remove it inorder to match other browsers. But I think Gecko and Safari is right.
  3209. // This process is only done when getting contents out from the editor.
  3210. if (!o.set) {
  3211. // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char
  3212. h = h.replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? '<p$1>&#160;</p>' : '<p$1>&nbsp;</p>');
  3213. if (s.remove_linebreaks) {
  3214. h = h.replace(/\r?\n|\r/g, ' ');
  3215. h = h.replace(/(<[^>]+>)\s+/g, '$1 ');
  3216. h = h.replace(/\s+(<\/[^>]+>)/g, ' $1');
  3217. h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g, '<$1 $2>'); // Trim block start
  3218. h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g, '<$1>'); // Trim block start
  3219. h = h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g, '</$1>'); // Trim block end
  3220. }
  3221. // Simple indentation
  3222. if (s.apply_source_formatting && s.indent_mode == 'simple') {
  3223. // Add line breaks before and after block elements
  3224. h = h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g, '\n<$1$2$3>\n');
  3225. h = h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g, '\n<$1$2>');
  3226. h = h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g, '</$1>\n');
  3227. h = h.replace(/\n\n/g, '\n');
  3228. }
  3229. }
  3230. h = t._unprotect(h, p);
  3231. // Restore CDATA sections
  3232. h = h.replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g, '<![CDATA[$1]]>');
  3233. // Restore the \u00a0 character if raw mode is enabled
  3234. if (s.entity_encoding == 'raw')
  3235. h = h.replace(/<p>&nbsp;<\/p>|<p([^>]+)>&nbsp;<\/p>/g, '<p$1>\u00a0</p>');
  3236. }
  3237. o.content = h;
  3238. },
  3239. _serializeNode : function(n, inn) {
  3240. var t = this, s = t.settings, w = t.writer, hc, el, cn, i, l, a, at, no, v, nn, ru, ar, iv;
  3241. if (!s.node_filter || s.node_filter(n)) {
  3242. switch (n.nodeType) {
  3243. case 1: // Element
  3244. if (n.hasAttribute ? n.hasAttribute('mce_bogus') : n.getAttribute('mce_bogus'))
  3245. return;
  3246. iv = false;
  3247. hc = n.hasChildNodes();
  3248. nn = n.getAttribute('mce_name') || n.nodeName.toLowerCase();
  3249. // Add correct prefix on IE
  3250. if (isIE) {
  3251. if (n.scopeName !== 'HTML' && n.scopeName !== 'html')
  3252. nn = n.scopeName + ':' + nn;
  3253. }
  3254. // Remove mce prefix on IE needed for the abbr element
  3255. if (nn.indexOf('mce:') === 0)
  3256. nn = nn.substring(4);
  3257. // Check if valid
  3258. if (!t.validElementsRE.test(nn) || (t.invalidElementsRE && t.invalidElementsRE.test(nn)) || inn) {
  3259. iv = true;
  3260. break;
  3261. }
  3262. if (isIE) {
  3263. // Fix IE content duplication (DOM can have multiple copies of the same node)
  3264. if (s.fix_content_duplication) {
  3265. if (n.mce_serialized == t.key)
  3266. return;
  3267. n.mce_serialized = t.key;
  3268. }
  3269. // IE sometimes adds a / infront of the node name
  3270. if (nn.charAt(0) == '/')
  3271. nn = nn.substring(1);
  3272. } else if (isGecko) {
  3273. // Ignore br elements
  3274. if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz')
  3275. return;
  3276. }
  3277. // Check if valid child
  3278. if (t.childRules) {
  3279. if (t.parentElementsRE.test(t.elementName)) {
  3280. if (!t.childRules[t.elementName].test(nn)) {
  3281. iv = true;
  3282. break;
  3283. }
  3284. }
  3285. t.elementName = nn;
  3286. }
  3287. ru = t.findRule(nn);
  3288. nn = ru.name || nn;
  3289. // Skip empty nodes or empty node name in IE
  3290. if ((!hc && ru.noEmpty) || (isIE && !nn)) {
  3291. iv = true;
  3292. break;
  3293. }
  3294. // Check required
  3295. if (ru.requiredAttribs) {
  3296. a = ru.requiredAttribs;
  3297. for (i = a.length - 1; i >= 0; i--) {
  3298. if (this.dom.getAttrib(n, a[i]) !== '')
  3299. break;
  3300. }
  3301. // None of the required was there
  3302. if (i == -1) {
  3303. iv = true;
  3304. break;
  3305. }
  3306. }
  3307. w.writeStartElement(nn);
  3308. // Add ordered attributes
  3309. if (ru.attribs) {
  3310. for (i=0, at = ru.attribs, l = at.length; i<l; i++) {
  3311. a = at[i];
  3312. v = t._getAttrib(n, a);
  3313. if (v !== null)
  3314. w.writeAttribute(a.name, v);
  3315. }
  3316. }
  3317. // Add wild attributes
  3318. if (ru.validAttribsRE) {
  3319. at = isIE ? getIEAtts(n) : n.attributes;
  3320. for (i=at.length-1; i>-1; i--) {
  3321. no = at[i];
  3322. if (no.specified) {
  3323. a = no.nodeName.toLowerCase();
  3324. if (s.invalid_attrs.test(a) || !ru.validAttribsRE.test(a))
  3325. continue;
  3326. ar = t.findAttribRule(ru, a);
  3327. v = t._getAttrib(n, ar, a);
  3328. if (v !== null)
  3329. w.writeAttribute(a, v);
  3330. }
  3331. }
  3332. }
  3333. // Padd empty nodes with a &nbsp;
  3334. if (ru.padd) {
  3335. // If it has only one bogus child, padd it anyway workaround for <td><br /></td> bug
  3336. if (hc && (cn = n.firstChild) && cn.nodeType === 1 && n.childNodes.length === 1) {
  3337. if (cn.hasAttribute ? cn.hasAttribute('mce_bogus') : cn.getAttribute('mce_bogus'))
  3338. w.writeText('\u00a0');
  3339. } else if (!hc)
  3340. w.writeText('\u00a0'); // No children then padd it
  3341. }
  3342. break;
  3343. case 3: // Text
  3344. // Check if valid child
  3345. if (t.childRules && t.parentElementsRE.test(t.elementName)) {
  3346. if (!t.childRules[t.elementName].test(n.nodeName))
  3347. return;
  3348. }
  3349. return w.writeText(n.nodeValue);
  3350. case 4: // CDATA
  3351. return w.writeCDATA(n.nodeValue);
  3352. case 8: // Comment
  3353. return w.writeComment(n.nodeValue);
  3354. }
  3355. } else if (n.nodeType == 1)
  3356. hc = n.hasChildNodes();
  3357. if (hc) {
  3358. cn = n.firstChild;
  3359. while (cn) {
  3360. t._serializeNode(cn);
  3361. t.elementName = nn;
  3362. cn = cn.nextSibling;
  3363. }
  3364. }
  3365. // Write element end
  3366. if (!iv) {
  3367. if (hc || !s.closed.test(nn))
  3368. w.writeFullEndElement();
  3369. else
  3370. w.writeEndElement();
  3371. }
  3372. },
  3373. _protect : function(o) {
  3374. var t = this;
  3375. o.items = o.items || [];
  3376. function enc(s) {
  3377. return s.replace(/[\r\n\\]/g, function(c) {
  3378. if (c === '\n')
  3379. return '\\n';
  3380. else if (c === '\\')
  3381. return '\\\\';
  3382. return '\\r';
  3383. });
  3384. };
  3385. function dec(s) {
  3386. return s.replace(/\\[\\rn]/g, function(c) {
  3387. if (c === '\\n')
  3388. return '\n';
  3389. else if (c === '\\\\')
  3390. return '\\';
  3391. return '\r';
  3392. });
  3393. };
  3394. each(o.patterns, function(p) {
  3395. o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) {
  3396. b = dec(b);
  3397. if (p.encode)
  3398. b = t._encode(b);
  3399. o.items.push(b);
  3400. return a + '<!--mce:' + (o.items.length - 1) + '-->' + c;
  3401. }));
  3402. });
  3403. return o;
  3404. },
  3405. _unprotect : function(h, o) {
  3406. h = h.replace(/\<!--mce:([0-9]+)--\>/g, function(a, b) {
  3407. return o.items[parseInt(b)];
  3408. });
  3409. o.items = [];
  3410. return h;
  3411. },
  3412. _encode : function(h) {
  3413. var t = this, s = t.settings, l;
  3414. // Entity encode
  3415. if (s.entity_encoding !== 'raw') {
  3416. if (s.entity_encoding.indexOf('named') != -1) {
  3417. t.setEntities(s.entities);
  3418. l = t.entityLookup;
  3419. h = h.replace(t.entitiesRE, function(a) {
  3420. var v;
  3421. if (v = l[a])
  3422. a = '&' + v + ';';
  3423. return a;
  3424. });
  3425. }
  3426. if (s.entity_encoding.indexOf('numeric') != -1) {
  3427. h = h.replace(/[\u007E-\uFFFF]/g, function(a) {
  3428. return '&#' + a.charCodeAt(0) + ';';
  3429. });
  3430. }
  3431. }
  3432. return h;
  3433. },
  3434. _setup : function() {
  3435. var t = this, s = this.settings;
  3436. if (t.done)
  3437. return;
  3438. t.done = 1;
  3439. t.setRules(s.valid_elements);
  3440. t.addRules(s.extended_valid_elements);
  3441. t.addValidChildRules(s.valid_child_elements);
  3442. if (s.invalid_elements)
  3443. t.invalidElementsRE = new RegExp('^(' + wildcardToRE(s.invalid_elements.replace(/,/g, '|').toLowerCase()) + ')$');
  3444. if (s.attrib_value_filter)
  3445. t.attribValueFilter = s.attribValueFilter;
  3446. },
  3447. _getAttrib : function(n, a, na) {
  3448. var i, v;
  3449. na = na || a.name;
  3450. if (a.forcedVal && (v = a.forcedVal)) {
  3451. if (v === '{$uid}')
  3452. return this.dom.uniqueId();
  3453. return v;
  3454. }
  3455. v = this.dom.getAttrib(n, na);
  3456. switch (na) {
  3457. case 'rowspan':
  3458. case 'colspan':
  3459. // Whats the point? Remove usless attribute value
  3460. if (v == '1')
  3461. v = '';
  3462. break;
  3463. }
  3464. if (this.attribValueFilter)
  3465. v = this.attribValueFilter(na, v, n);
  3466. if (a.validVals) {
  3467. for (i = a.validVals.length - 1; i >= 0; i--) {
  3468. if (v == a.validVals[i])
  3469. break;
  3470. }
  3471. if (i == -1)
  3472. return null;
  3473. }
  3474. if (v === '' && typeof(a.defaultVal) != 'undefined') {
  3475. v = a.defaultVal;
  3476. if (v === '{$uid}')
  3477. return this.dom.uniqueId();
  3478. return v;
  3479. } else {
  3480. // Remove internal mceItemXX classes when content is extracted from editor
  3481. if (na == 'class' && this.processObj.get)
  3482. v = v.replace(/\s?mceItem\w+\s?/g, '');
  3483. }
  3484. if (v === '')
  3485. return null;
  3486. return v;
  3487. }
  3488. });
  3489. })();
  3490. /* file:jscripts/tiny_mce/classes/dom/ScriptLoader.js */
  3491. (function() {
  3492. var each = tinymce.each;
  3493. tinymce.create('tinymce.dom.ScriptLoader', {
  3494. ScriptLoader : function(s) {
  3495. this.settings = s || {};
  3496. this.queue = [];
  3497. this.lookup = {};
  3498. },
  3499. isDone : function(u) {
  3500. return this.lookup[u] ? this.lookup[u].state == 2 : 0;
  3501. },
  3502. markDone : function(u) {
  3503. this.lookup[u] = {state : 2, url : u};
  3504. },
  3505. add : function(u, cb, s, pr) {
  3506. var t = this, lo = t.lookup, o;
  3507. if (o = lo[u]) {
  3508. // Is loaded fire callback
  3509. if (cb && o.state == 2)
  3510. cb.call(s || this);
  3511. return o;
  3512. }
  3513. o = {state : 0, url : u, func : cb, scope : s || this};
  3514. if (pr)
  3515. t.queue.unshift(o);
  3516. else
  3517. t.queue.push(o);
  3518. lo[u] = o;
  3519. return o;
  3520. },
  3521. load : function(u, cb, s) {
  3522. var t = this, o;
  3523. if (o = t.lookup[u]) {
  3524. // Is loaded fire callback
  3525. if (cb && o.state == 2)
  3526. cb.call(s || t);
  3527. return o;
  3528. }
  3529. function loadScript(u) {
  3530. if (tinymce.dom.Event.domLoaded || t.settings.strict_mode) {
  3531. tinymce.util.XHR.send({
  3532. url : tinymce._addVer(u),
  3533. error : t.settings.error,
  3534. async : false,
  3535. success : function(co) {
  3536. t.eval(co);
  3537. }
  3538. });
  3539. } else
  3540. document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
  3541. };
  3542. if (!tinymce.is(u, 'string')) {
  3543. each(u, function(u) {
  3544. loadScript(u);
  3545. });
  3546. if (cb)
  3547. cb.call(s || t);
  3548. } else {
  3549. loadScript(u);
  3550. if (cb)
  3551. cb.call(s || t);
  3552. }
  3553. },
  3554. loadQueue : function(cb, s) {
  3555. var t = this;
  3556. if (!t.queueLoading) {
  3557. t.queueLoading = 1;
  3558. t.queueCallbacks = [];
  3559. t.loadScripts(t.queue, function() {
  3560. t.queueLoading = 0;
  3561. if (cb)
  3562. cb.call(s || t);
  3563. each(t.queueCallbacks, function(o) {
  3564. o.func.call(o.scope);
  3565. });
  3566. });
  3567. } else if (cb)
  3568. t.queueCallbacks.push({func : cb, scope : s || t});
  3569. },
  3570. eval : function(co) {
  3571. var w = window;
  3572. // Evaluate script
  3573. if (!w.execScript) {
  3574. try {
  3575. eval.call(w, co);
  3576. } catch (ex) {
  3577. eval(co, w); // Firefox 3.0a8
  3578. }
  3579. } else
  3580. w.execScript(co); // IE
  3581. },
  3582. loadScripts : function(sc, cb, s) {
  3583. var t = this, lo = t.lookup;
  3584. function done(o) {
  3585. o.state = 2; // Has been loaded
  3586. // Run callback
  3587. if (o.func)
  3588. o.func.call(o.scope || t);
  3589. };
  3590. function allDone() {
  3591. var l;
  3592. // Check if all files are loaded
  3593. l = sc.length;
  3594. each(sc, function(o) {
  3595. o = lo[o.url];
  3596. if (o.state === 2) {// It has finished loading
  3597. done(o);
  3598. l--;
  3599. } else
  3600. load(o);
  3601. });
  3602. // They are all loaded
  3603. if (l === 0 && cb) {
  3604. cb.call(s || t);
  3605. cb = 0;
  3606. }
  3607. };
  3608. function load(o) {
  3609. if (o.state > 0)
  3610. return;
  3611. o.state = 1; // Is loading
  3612. tinymce.util.XHR.send({
  3613. url : o.url,
  3614. error : t.settings.error,
  3615. success : function(co) {
  3616. t.eval(co);
  3617. done(o);
  3618. allDone();
  3619. }
  3620. });
  3621. };
  3622. each(sc, function(o) {
  3623. var u = o.url;
  3624. // Add to queue if needed
  3625. if (!lo[u]) {
  3626. lo[u] = o;
  3627. t.queue.push(o);
  3628. } else
  3629. o = lo[u];
  3630. // Is already loading or has been loaded
  3631. if (o.state > 0)
  3632. return;
  3633. if (!tinymce.dom.Event.domLoaded && !t.settings.strict_mode) {
  3634. var ix, ol = '';
  3635. // Add onload events
  3636. if (cb || o.func) {
  3637. o.state = 1; // Is loading
  3638. ix = tinymce.dom.ScriptLoader._addOnLoad(function() {
  3639. done(o);
  3640. allDone();
  3641. });
  3642. if (tinymce.isIE)
  3643. ol = ' onreadystatechange="';
  3644. else
  3645. ol = ' onload="';
  3646. ol += 'tinymce.dom.ScriptLoader._onLoad(this,\'' + u + '\',' + ix + ');"';
  3647. }
  3648. document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"' + ol + '></script>');
  3649. if (!o.func)
  3650. done(o);
  3651. } else
  3652. load(o);
  3653. });
  3654. allDone();
  3655. },
  3656. // Static methods
  3657. 'static' : {
  3658. _addOnLoad : function(f) {
  3659. var t = this;
  3660. t._funcs = t._funcs || [];
  3661. t._funcs.push(f);
  3662. return t._funcs.length - 1;
  3663. },
  3664. _onLoad : function(e, u, ix) {
  3665. if (!tinymce.isIE || e.readyState == 'complete')
  3666. this._funcs[ix].call(this);
  3667. }
  3668. }
  3669. });
  3670. // Global script loader
  3671. tinymce.ScriptLoader = new tinymce.dom.ScriptLoader();
  3672. })();
  3673. /* file:jscripts/tiny_mce/classes/ui/Control.js */
  3674. (function() {
  3675. // Shorten class names
  3676. var DOM = tinymce.DOM, is = tinymce.is;
  3677. tinymce.create('tinymce.ui.Control', {
  3678. Control : function(id, s) {
  3679. this.id = id;
  3680. this.settings = s = s || {};
  3681. this.rendered = false;
  3682. this.onRender = new tinymce.util.Dispatcher(this);
  3683. this.classPrefix = '';
  3684. this.scope = s.scope || this;
  3685. this.disabled = 0;
  3686. this.active = 0;
  3687. },
  3688. setDisabled : function(s) {
  3689. var e;
  3690. if (s != this.disabled) {
  3691. e = DOM.get(this.id);
  3692. // Add accessibility title for unavailable actions
  3693. if (e && this.settings.unavailable_prefix) {
  3694. if (s) {
  3695. this.prevTitle = e.title;
  3696. e.title = this.settings.unavailable_prefix + ": " + e.title;
  3697. } else
  3698. e.title = this.prevTitle;
  3699. }
  3700. this.setState('Disabled', s);
  3701. this.setState('Enabled', !s);
  3702. this.disabled = s;
  3703. }
  3704. },
  3705. isDisabled : function() {
  3706. return this.disabled;
  3707. },
  3708. setActive : function(s) {
  3709. if (s != this.active) {
  3710. this.setState('Active', s);
  3711. this.active = s;
  3712. }
  3713. },
  3714. isActive : function() {
  3715. return this.active;
  3716. },
  3717. setState : function(c, s) {
  3718. var n = DOM.get(this.id);
  3719. c = this.classPrefix + c;
  3720. if (s)
  3721. DOM.addClass(n, c);
  3722. else
  3723. DOM.removeClass(n, c);
  3724. },
  3725. isRendered : function() {
  3726. return this.rendered;
  3727. },
  3728. renderHTML : function() {
  3729. },
  3730. renderTo : function(n) {
  3731. DOM.setHTML(n, this.renderHTML());
  3732. },
  3733. postRender : function() {
  3734. var t = this, b;
  3735. // Set pending states
  3736. if (is(t.disabled)) {
  3737. b = t.disabled;
  3738. t.disabled = -1;
  3739. t.setDisabled(b);
  3740. }
  3741. if (is(t.active)) {
  3742. b = t.active;
  3743. t.active = -1;
  3744. t.setActive(b);
  3745. }
  3746. },
  3747. remove : function() {
  3748. DOM.remove(this.id);
  3749. this.destroy();
  3750. },
  3751. destroy : function() {
  3752. tinymce.dom.Event.clear(this.id);
  3753. }
  3754. });
  3755. })();
  3756. /* file:jscripts/tiny_mce/classes/ui/Container.js */
  3757. tinymce.create('tinymce.ui.Container:tinymce.ui.Control', {
  3758. Container : function(id, s) {
  3759. this.parent(id, s);
  3760. this.controls = [];
  3761. this.lookup = {};
  3762. },
  3763. add : function(c) {
  3764. this.lookup[c.id] = c;
  3765. this.controls.push(c);
  3766. return c;
  3767. },
  3768. get : function(n) {
  3769. return this.lookup[n];
  3770. }
  3771. });
  3772. /* file:jscripts/tiny_mce/classes/ui/Separator.js */
  3773. tinymce.create('tinymce.ui.Separator:tinymce.ui.Control', {
  3774. Separator : function(id, s) {
  3775. this.parent(id, s);
  3776. this.classPrefix = 'mceSeparator';
  3777. },
  3778. renderHTML : function() {
  3779. return tinymce.DOM.createHTML('span', {'class' : this.classPrefix});
  3780. }
  3781. });
  3782. /* file:jscripts/tiny_mce/classes/ui/MenuItem.js */
  3783. (function() {
  3784. var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
  3785. tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
  3786. MenuItem : function(id, s) {
  3787. this.parent(id, s);
  3788. this.classPrefix = 'mceMenuItem';
  3789. },
  3790. setSelected : function(s) {
  3791. this.setState('Selected', s);
  3792. this.selected = s;
  3793. },
  3794. isSelected : function() {
  3795. return this.selected;
  3796. },
  3797. postRender : function() {
  3798. var t = this;
  3799. t.parent();
  3800. // Set pending state
  3801. if (is(t.selected))
  3802. t.setSelected(t.selected);
  3803. }
  3804. });
  3805. })();
  3806. /* file:jscripts/tiny_mce/classes/ui/Menu.js */
  3807. (function() {
  3808. var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
  3809. tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', {
  3810. Menu : function(id, s) {
  3811. var t = this;
  3812. t.parent(id, s);
  3813. t.items = {};
  3814. t.collapsed = false;
  3815. t.menuCount = 0;
  3816. t.onAddItem = new tinymce.util.Dispatcher(this);
  3817. },
  3818. expand : function(d) {
  3819. var t = this;
  3820. if (d) {
  3821. walk(t, function(o) {
  3822. if (o.expand)
  3823. o.expand();
  3824. }, 'items', t);
  3825. }
  3826. t.collapsed = false;
  3827. },
  3828. collapse : function(d) {
  3829. var t = this;
  3830. if (d) {
  3831. walk(t, function(o) {
  3832. if (o.collapse)
  3833. o.collapse();
  3834. }, 'items', t);
  3835. }
  3836. t.collapsed = true;
  3837. },
  3838. isCollapsed : function() {
  3839. return this.collapsed;
  3840. },
  3841. add : function(o) {
  3842. if (!o.settings)
  3843. o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o);
  3844. this.onAddItem.dispatch(this, o);
  3845. return this.items[o.id] = o;
  3846. },
  3847. addSeparator : function() {
  3848. return this.add({separator : true});
  3849. },
  3850. addMenu : function(o) {
  3851. if (!o.collapse)
  3852. o = this.createMenu(o);
  3853. this.menuCount++;
  3854. return this.add(o);
  3855. },
  3856. hasMenus : function() {
  3857. return this.menuCount !== 0;
  3858. },
  3859. remove : function(o) {
  3860. delete this.items[o.id];
  3861. },
  3862. removeAll : function() {
  3863. var t = this;
  3864. walk(t, function(o) {
  3865. if (o.removeAll)
  3866. o.removeAll();
  3867. else
  3868. o.remove();
  3869. o.destroy();
  3870. }, 'items', t);
  3871. t.items = {};
  3872. },
  3873. createMenu : function(o) {
  3874. var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o);
  3875. m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem);
  3876. return m;
  3877. }
  3878. });
  3879. })();
  3880. /* file:jscripts/tiny_mce/classes/ui/DropMenu.js */
  3881. (function() {
  3882. var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event, Element = tinymce.dom.Element;
  3883. tinymce.create('tinymce.ui.DropMenu:tinymce.ui.Menu', {
  3884. DropMenu : function(id, s) {
  3885. s = s || {};
  3886. s.container = s.container || DOM.doc.body;
  3887. s.offset_x = s.offset_x || 0;
  3888. s.offset_y = s.offset_y || 0;
  3889. s.vp_offset_x = s.vp_offset_x || 0;
  3890. s.vp_offset_y = s.vp_offset_y || 0;
  3891. if (is(s.icons) && !s.icons)
  3892. s['class'] += ' mceNoIcons';
  3893. this.parent(id, s);
  3894. this.onShowMenu = new tinymce.util.Dispatcher(this);
  3895. this.onHideMenu = new tinymce.util.Dispatcher(this);
  3896. this.classPrefix = 'mceMenu';
  3897. },
  3898. createMenu : function(s) {
  3899. var t = this, cs = t.settings, m;
  3900. s.container = s.container || cs.container;
  3901. s.parent = t;
  3902. s.constrain = s.constrain || cs.constrain;
  3903. s['class'] = s['class'] || cs['class'];
  3904. s.vp_offset_x = s.vp_offset_x || cs.vp_offset_x;
  3905. s.vp_offset_y = s.vp_offset_y || cs.vp_offset_y;
  3906. m = new tinymce.ui.DropMenu(s.id || DOM.uniqueId(), s);
  3907. m.onAddItem.add(t.onAddItem.dispatch, t.onAddItem);
  3908. return m;
  3909. },
  3910. update : function() {
  3911. var t = this, s = t.settings, tb = DOM.get('menu_' + t.id + '_tbl'), co = DOM.get('menu_' + t.id + '_co'), tw, th;
  3912. tw = s.max_width ? Math.min(tb.clientWidth, s.max_width) : tb.clientWidth;
  3913. th = s.max_height ? Math.min(tb.clientHeight, s.max_height) : tb.clientHeight;
  3914. if (!DOM.boxModel)
  3915. t.element.setStyles({width : tw + 2, height : th + 2});
  3916. else
  3917. t.element.setStyles({width : tw, height : th});
  3918. if (s.max_width)
  3919. DOM.setStyle(co, 'width', tw);
  3920. if (s.max_height) {
  3921. DOM.setStyle(co, 'height', th);
  3922. if (tb.clientHeight < s.max_height)
  3923. DOM.setStyle(co, 'overflow', 'hidden');
  3924. }
  3925. },
  3926. showMenu : function(x, y, px) {
  3927. var t = this, s = t.settings, co, vp = DOM.getViewPort(), w, h, mx, my, ot = 2, dm, tb, cp = t.classPrefix;
  3928. t.collapse(1);
  3929. if (t.isMenuVisible)
  3930. return;
  3931. if (!t.rendered) {
  3932. co = DOM.add(t.settings.container, t.renderNode());
  3933. each(t.items, function(o) {
  3934. o.postRender();
  3935. });
  3936. t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
  3937. } else
  3938. co = DOM.get('menu_' + t.id);
  3939. // Move layer out of sight unless it's Opera since it scrolls to top of page due to an bug
  3940. if (!tinymce.isOpera)
  3941. DOM.setStyles(co, {left : -0xFFFF , top : -0xFFFF});
  3942. DOM.show(co);
  3943. t.update();
  3944. x += s.offset_x || 0;
  3945. y += s.offset_y || 0;
  3946. vp.w -= 4;
  3947. vp.h -= 4;
  3948. // Move inside viewport if not submenu
  3949. if (s.constrain) {
  3950. w = co.clientWidth - ot;
  3951. h = co.clientHeight - ot;
  3952. mx = vp.x + vp.w;
  3953. my = vp.y + vp.h;
  3954. if ((x + s.vp_offset_x + w) > mx)
  3955. x = px ? px - w : Math.max(0, (mx - s.vp_offset_x) - w);
  3956. if ((y + s.vp_offset_y + h) > my)
  3957. y = Math.max(0, (my - s.vp_offset_y) - h);
  3958. }
  3959. DOM.setStyles(co, {left : x , top : y});
  3960. t.element.update();
  3961. t.isMenuVisible = 1;
  3962. t.mouseClickFunc = Event.add(co, 'click', function(e) {
  3963. var m;
  3964. e = e.target;
  3965. if (e && (e = DOM.getParent(e, 'TR')) && !DOM.hasClass(e, cp + 'ItemSub')) {
  3966. m = t.items[e.id];
  3967. if (m.isDisabled())
  3968. return;
  3969. dm = t;
  3970. while (dm) {
  3971. if (dm.hideMenu)
  3972. dm.hideMenu();
  3973. dm = dm.settings.parent;
  3974. }
  3975. if (m.settings.onclick)
  3976. m.settings.onclick(e);
  3977. return Event.cancel(e); // Cancel to fix onbeforeunload problem
  3978. }
  3979. });
  3980. if (t.hasMenus()) {
  3981. t.mouseOverFunc = Event.add(co, 'mouseover', function(e) {
  3982. var m, r, mi;
  3983. e = e.target;
  3984. if (e && (e = DOM.getParent(e, 'TR'))) {
  3985. m = t.items[e.id];
  3986. if (t.lastMenu)
  3987. t.lastMenu.collapse(1);
  3988. if (m.isDisabled())
  3989. return;
  3990. if (e && DOM.hasClass(e, cp + 'ItemSub')) {
  3991. //p = DOM.getPos(s.container);
  3992. r = DOM.getRect(e);
  3993. m.showMenu((r.x + r.w - ot), r.y - ot, r.x);
  3994. t.lastMenu = m;
  3995. DOM.addClass(DOM.get(m.id).firstChild, cp + 'ItemActive');
  3996. }
  3997. }
  3998. });
  3999. }
  4000. t.onShowMenu.dispatch(t);
  4001. if (s.keyboard_focus) {
  4002. Event.add(co, 'keydown', t._keyHandler, t);
  4003. DOM.select('a', 'menu_' + t.id)[0].focus(); // Select first link
  4004. t._focusIdx = 0;
  4005. }
  4006. },
  4007. hideMenu : function(c) {
  4008. var t = this, co = DOM.get('menu_' + t.id), e;
  4009. if (!t.isMenuVisible)
  4010. return;
  4011. Event.remove(co, 'mouseover', t.mouseOverFunc);
  4012. Event.remove(co, 'click', t.mouseClickFunc);
  4013. Event.remove(co, 'keydown', t._keyHandler);
  4014. DOM.hide(co);
  4015. t.isMenuVisible = 0;
  4016. if (!c)
  4017. t.collapse(1);
  4018. if (t.element)
  4019. t.element.hide();
  4020. if (e = DOM.get(t.id))
  4021. DOM.removeClass(e.firstChild, t.classPrefix + 'ItemActive');
  4022. t.onHideMenu.dispatch(t);
  4023. },
  4024. add : function(o) {
  4025. var t = this, co;
  4026. o = t.parent(o);
  4027. if (t.isRendered && (co = DOM.get('menu_' + t.id)))
  4028. t._add(DOM.select('tbody', co)[0], o);
  4029. return o;
  4030. },
  4031. collapse : function(d) {
  4032. this.parent(d);
  4033. this.hideMenu(1);
  4034. },
  4035. remove : function(o) {
  4036. DOM.remove(o.id);
  4037. this.destroy();
  4038. return this.parent(o);
  4039. },
  4040. destroy : function() {
  4041. var t = this, co = DOM.get('menu_' + t.id);
  4042. Event.remove(co, 'mouseover', t.mouseOverFunc);
  4043. Event.remove(co, 'click', t.mouseClickFunc);
  4044. if (t.element)
  4045. t.element.remove();
  4046. DOM.remove(co);
  4047. },
  4048. renderNode : function() {
  4049. var t = this, s = t.settings, n, tb, co, w;
  4050. w = DOM.create('div', {id : 'menu_' + t.id, 'class' : s['class'], 'style' : 'position:absolute;left:0;top:0;z-index:200000'});
  4051. co = DOM.add(w, 'div', {id : 'menu_' + t.id + '_co', 'class' : t.classPrefix + (s['class'] ? ' ' + s['class'] : '')});
  4052. t.element = new Element('menu_' + t.id, {blocker : 1, container : s.container});
  4053. if (s.menu_line)
  4054. DOM.add(co, 'span', {'class' : t.classPrefix + 'Line'});
  4055. // n = DOM.add(co, 'div', {id : 'menu_' + t.id + '_co', 'class' : 'mceMenuContainer'});
  4056. n = DOM.add(co, 'table', {id : 'menu_' + t.id + '_tbl', border : 0, cellPadding : 0, cellSpacing : 0});
  4057. tb = DOM.add(n, 'tbody');
  4058. each(t.items, function(o) {
  4059. t._add(tb, o);
  4060. });
  4061. t.rendered = true;
  4062. return w;
  4063. },
  4064. // Internal functions
  4065. _keyHandler : function(e) {
  4066. var t = this, kc = e.keyCode;
  4067. function focus(d) {
  4068. var i = t._focusIdx + d, e = DOM.select('a', 'menu_' + t.id)[i];
  4069. if (e) {
  4070. t._focusIdx = i;
  4071. e.focus();
  4072. }
  4073. };
  4074. switch (kc) {
  4075. case 38:
  4076. focus(-1); // Select first link
  4077. return;
  4078. case 40:
  4079. focus(1);
  4080. return;
  4081. case 13:
  4082. return;
  4083. case 27:
  4084. return this.hideMenu();
  4085. }
  4086. },
  4087. _add : function(tb, o) {
  4088. var n, s = o.settings, a, ro, it, cp = this.classPrefix;
  4089. if (s.separator) {
  4090. ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'ItemSeparator'});
  4091. DOM.add(ro, 'td', {'class' : cp + 'ItemSeparator'});
  4092. if (n = ro.previousSibling)
  4093. DOM.addClass(n, 'mceLast');
  4094. return;
  4095. }
  4096. n = ro = DOM.add(tb, 'tr', {id : o.id, 'class' : cp + 'Item ' + cp + 'ItemEnabled'});
  4097. n = it = DOM.add(n, 'td');
  4098. n = a = DOM.add(n, 'a', {href : 'javascript:;', onclick : "return false;", onmousedown : 'return false;'});
  4099. DOM.addClass(it, s['class']);
  4100. // n = DOM.add(n, 'span', {'class' : 'item'});
  4101. DOM.add(n, 'span', {'class' : 'mceIcon' + (s.icon ? ' mce_' + s.icon : '')});
  4102. n = DOM.add(n, s.element || 'span', {'class' : 'mceText', title : o.settings.title}, o.settings.title);
  4103. if (o.settings.style)
  4104. DOM.setAttrib(n, 'style', o.settings.style);
  4105. if (tb.childNodes.length == 1)
  4106. DOM.addClass(ro, 'mceFirst');
  4107. if ((n = ro.previousSibling) && DOM.hasClass(n, cp + 'ItemSeparator'))
  4108. DOM.addClass(ro, 'mceFirst');
  4109. if (o.collapse)
  4110. DOM.addClass(ro, cp + 'ItemSub');
  4111. if (n = ro.previousSibling)
  4112. DOM.removeClass(n, 'mceLast');
  4113. DOM.addClass(ro, 'mceLast');
  4114. }
  4115. });
  4116. })();
  4117. /* file:jscripts/tiny_mce/classes/ui/Button.js */
  4118. (function() {
  4119. var DOM = tinymce.DOM;
  4120. tinymce.create('tinymce.ui.Button:tinymce.ui.Control', {
  4121. Button : function(id, s) {
  4122. this.parent(id, s);
  4123. this.classPrefix = 'mceButton';
  4124. },
  4125. renderHTML : function() {
  4126. var cp = this.classPrefix, s = this.settings, h, l;
  4127. l = DOM.encode(s.label || '');
  4128. h = '<a id="' + this.id + '" href="javascript:;" class="' + cp + ' ' + cp + 'Enabled ' + s['class'] + (l ? ' ' + cp + 'Labeled' : '') +'" onmousedown="return false;" onclick="return false;" title="' + DOM.encode(s.title) + '">';
  4129. if (s.image)
  4130. h += '<img class="mceIcon" src="' + s.image + '" />' + l + '</a>';
  4131. else
  4132. h += '<span class="mceIcon ' + s['class'] + '"></span>' + (l ? '<span class="' + cp + 'Label">' + l + '</span>' : '') + '</a>';
  4133. return h;
  4134. },
  4135. postRender : function() {
  4136. var t = this, s = t.settings;
  4137. tinymce.dom.Event.add(t.id, 'click', function(e) {
  4138. if (!t.isDisabled())
  4139. return s.onclick.call(s.scope, e);
  4140. });
  4141. }
  4142. });
  4143. })();
  4144. /* file:jscripts/tiny_mce/classes/ui/ListBox.js */
  4145. (function() {
  4146. var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
  4147. tinymce.create('tinymce.ui.ListBox:tinymce.ui.Control', {
  4148. ListBox : function(id, s) {
  4149. var t = this;
  4150. t.parent(id, s);
  4151. t.items = [];
  4152. t.onChange = new Dispatcher(t);
  4153. t.onPostRender = new Dispatcher(t);
  4154. t.onAdd = new Dispatcher(t);
  4155. t.onRenderMenu = new tinymce.util.Dispatcher(this);
  4156. t.classPrefix = 'mceListBox';
  4157. },
  4158. select : function(va) {
  4159. var t = this, fv, f;
  4160. if (va == undefined)
  4161. return t.selectByIndex(-1);
  4162. // Is string or number make function selector
  4163. if (va && va.call)
  4164. f = va;
  4165. else {
  4166. f = function(v) {
  4167. return v == va;
  4168. };
  4169. }
  4170. // Do we need to do something?
  4171. if (va != t.selectedValue) {
  4172. // Find item
  4173. each(t.items, function(o, i) {
  4174. if (f(o.value)) {
  4175. fv = 1;
  4176. t.selectByIndex(i);
  4177. return false;
  4178. }
  4179. });
  4180. if (!fv)
  4181. t.selectByIndex(-1);
  4182. }
  4183. },
  4184. selectByIndex : function(idx) {
  4185. var t = this, e, o;
  4186. if (idx != t.selectedIndex) {
  4187. e = DOM.get(t.id + '_text');
  4188. o = t.items[idx];
  4189. if (o) {
  4190. t.selectedValue = o.value;
  4191. t.selectedIndex = idx;
  4192. DOM.setHTML(e, DOM.encode(o.title));
  4193. DOM.removeClass(e, 'mceTitle');
  4194. } else {
  4195. DOM.setHTML(e, DOM.encode(t.settings.title));
  4196. DOM.addClass(e, 'mceTitle');
  4197. t.selectedValue = t.selectedIndex = null;
  4198. }
  4199. e = 0;
  4200. } else
  4201. t.selectedValue = t.selectedIndex = null;
  4202. },
  4203. add : function(n, v, o) {
  4204. var t = this;
  4205. o = o || {};
  4206. o = tinymce.extend(o, {
  4207. title : n,
  4208. value : v
  4209. });
  4210. t.items.push(o);
  4211. t.onAdd.dispatch(t, o);
  4212. },
  4213. getLength : function() {
  4214. return this.items.length;
  4215. },
  4216. renderHTML : function() {
  4217. var h = '', t = this, s = t.settings, cp = t.classPrefix;
  4218. h = '<table id="' + t.id + '" cellpadding="0" cellspacing="0" class="' + cp + ' ' + cp + 'Enabled' + (s['class'] ? (' ' + s['class']) : '') + '"><tbody><tr>';
  4219. h += '<td>' + DOM.createHTML('a', {id : t.id + '_text', href : 'javascript:;', 'class' : 'mceText', onclick : "return false;", onmousedown : 'return false;'}, DOM.encode(t.settings.title)) + '</td>';
  4220. h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', tabindex : -1, href : 'javascript:;', 'class' : 'mceOpen', onclick : "return false;", onmousedown : 'return false;'}, '<span></span>') + '</td>';
  4221. h += '</tr></tbody></table>';
  4222. return h;
  4223. },
  4224. showMenu : function() {
  4225. var t = this, p1, p2, e = DOM.get(this.id), m;
  4226. if (t.isDisabled() || t.items.length == 0)
  4227. return;
  4228. if (t.menu && t.menu.isMenuVisible)
  4229. return t.hideMenu();
  4230. if (!t.isMenuRendered) {
  4231. t.renderMenu();
  4232. t.isMenuRendered = true;
  4233. }
  4234. p1 = DOM.getPos(this.settings.menu_container);
  4235. p2 = DOM.getPos(e);
  4236. m = t.menu;
  4237. m.settings.offset_x = p2.x;
  4238. m.settings.offset_y = p2.y;
  4239. m.settings.keyboard_focus = !tinymce.isOpera; // Opera is buggy when it comes to auto focus
  4240. // Select in menu
  4241. if (t.oldID)
  4242. m.items[t.oldID].setSelected(0);
  4243. each(t.items, function(o) {
  4244. if (o.value === t.selectedValue) {
  4245. m.items[o.id].setSelected(1);
  4246. t.oldID = o.id;
  4247. }
  4248. });
  4249. m.showMenu(0, e.clientHeight);
  4250. Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
  4251. DOM.addClass(t.id, t.classPrefix + 'Selected');
  4252. //DOM.get(t.id + '_text').focus();
  4253. },
  4254. hideMenu : function(e) {
  4255. var t = this;
  4256. // Prevent double toogles by canceling the mouse click event to the button
  4257. if (e && e.type == "mousedown" && (e.target.id == t.id + '_text' || e.target.id == t.id + '_open'))
  4258. return;
  4259. if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
  4260. DOM.removeClass(t.id, t.classPrefix + 'Selected');
  4261. Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
  4262. if (t.menu)
  4263. t.menu.hideMenu();
  4264. }
  4265. },
  4266. renderMenu : function() {
  4267. var t = this, m;
  4268. m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
  4269. menu_line : 1,
  4270. 'class' : t.classPrefix + 'Menu mceNoIcons',
  4271. max_width : 150,
  4272. max_height : 150
  4273. });
  4274. m.onHideMenu.add(t.hideMenu, t);
  4275. m.add({
  4276. title : t.settings.title,
  4277. 'class' : 'mceMenuItemTitle',
  4278. onclick : function() {
  4279. if (t.settings.onselect('') !== false)
  4280. t.select(''); // Must be runned after
  4281. }
  4282. });
  4283. each(t.items, function(o) {
  4284. o.id = DOM.uniqueId();
  4285. o.onclick = function() {
  4286. if (t.settings.onselect(o.value) !== false)
  4287. t.select(o.value); // Must be runned after
  4288. };
  4289. m.add(o);
  4290. });
  4291. t.onRenderMenu.dispatch(t, m);
  4292. t.menu = m;
  4293. },
  4294. postRender : function() {
  4295. var t = this, cp = t.classPrefix;
  4296. Event.add(t.id, 'click', t.showMenu, t);
  4297. Event.add(t.id + '_text', 'focus', function(e) {
  4298. if (!t._focused) {
  4299. t.keyDownHandler = Event.add(t.id + '_text', 'keydown', function(e) {
  4300. var idx = -1, v, kc = e.keyCode;
  4301. // Find current index
  4302. each(t.items, function(v, i) {
  4303. if (t.selectedValue == v.value)
  4304. idx = i;
  4305. });
  4306. // Move up/down
  4307. if (kc == 38)
  4308. v = t.items[idx - 1];
  4309. else if (kc == 40)
  4310. v = t.items[idx + 1];
  4311. else if (kc == 13) {
  4312. // Fake select on enter
  4313. v = t.selectedValue;
  4314. t.selectedValue = null; // Needs to be null to fake change
  4315. t.settings.onselect(v);
  4316. return Event.cancel(e);
  4317. }
  4318. if (v) {
  4319. t.hideMenu();
  4320. t.select(v.value);
  4321. }
  4322. });
  4323. }
  4324. t._focused = 1;
  4325. });
  4326. Event.add(t.id + '_text', 'blur', function() {Event.remove(t.id + '_text', 'keydown', t.keyDownHandler); t._focused = 0;});
  4327. // Old IE doesn't have hover on all elements
  4328. if (tinymce.isIE6 || !DOM.boxModel) {
  4329. Event.add(t.id, 'mouseover', function() {
  4330. if (!DOM.hasClass(t.id, cp + 'Disabled'))
  4331. DOM.addClass(t.id, cp + 'Hover');
  4332. });
  4333. Event.add(t.id, 'mouseout', function() {
  4334. if (!DOM.hasClass(t.id, cp + 'Disabled'))
  4335. DOM.removeClass(t.id, cp + 'Hover');
  4336. });
  4337. }
  4338. t.onPostRender.dispatch(t, DOM.get(t.id));
  4339. },
  4340. destroy : function() {
  4341. this.parent();
  4342. Event.clear(this.id + '_text');
  4343. }
  4344. });
  4345. })();
  4346. /* file:jscripts/tiny_mce/classes/ui/NativeListBox.js */
  4347. (function() {
  4348. var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher;
  4349. tinymce.create('tinymce.ui.NativeListBox:tinymce.ui.ListBox', {
  4350. NativeListBox : function(id, s) {
  4351. this.parent(id, s);
  4352. this.classPrefix = 'mceNativeListBox';
  4353. },
  4354. setDisabled : function(s) {
  4355. DOM.get(this.id).disabled = s;
  4356. },
  4357. isDisabled : function() {
  4358. return DOM.get(this.id).disabled;
  4359. },
  4360. select : function(va) {
  4361. var t = this, fv, f;
  4362. if (va == undefined)
  4363. return t.selectByIndex(-1);
  4364. // Is string or number make function selector
  4365. if (va && va.call)
  4366. f = va;
  4367. else {
  4368. f = function(v) {
  4369. return v == va;
  4370. };
  4371. }
  4372. // Do we need to do something?
  4373. if (va != t.selectedValue) {
  4374. // Find item
  4375. each(t.items, function(o, i) {
  4376. if (f(o.value)) {
  4377. fv = 1;
  4378. t.selectByIndex(i);
  4379. return false;
  4380. }
  4381. });
  4382. if (!fv)
  4383. t.selectByIndex(-1);
  4384. }
  4385. },
  4386. selectByIndex : function(idx) {
  4387. DOM.get(this.id).selectedIndex = idx + 1;
  4388. this.selectedValue = this.items[idx] ? this.items[idx].value : null;
  4389. },
  4390. add : function(n, v, a) {
  4391. var o, t = this;
  4392. a = a || {};
  4393. a.value = v;
  4394. if (t.isRendered())
  4395. DOM.add(DOM.get(this.id), 'option', a, n);
  4396. o = {
  4397. title : n,
  4398. value : v,
  4399. attribs : a
  4400. };
  4401. t.items.push(o);
  4402. t.onAdd.dispatch(t, o);
  4403. },
  4404. getLength : function() {
  4405. return DOM.get(this.id).options.length - 1;
  4406. },
  4407. renderHTML : function() {
  4408. var h, t = this;
  4409. h = DOM.createHTML('option', {value : ''}, '-- ' + t.settings.title + ' --');
  4410. each(t.items, function(it) {
  4411. h += DOM.createHTML('option', {value : it.value}, it.title);
  4412. });
  4413. h = DOM.createHTML('select', {id : t.id, 'class' : 'mceNativeListBox'}, h);
  4414. return h;
  4415. },
  4416. postRender : function() {
  4417. var t = this, ch;
  4418. t.rendered = true;
  4419. function onChange(e) {
  4420. var v = t.items[e.target.selectedIndex - 1];
  4421. if (v = v.value) {
  4422. t.onChange.dispatch(t, v);
  4423. if (t.settings.onselect)
  4424. t.settings.onselect(v);
  4425. }
  4426. };
  4427. Event.add(t.id, 'change', onChange);
  4428. // Accessibility keyhandler
  4429. Event.add(t.id, 'keydown', function(e) {
  4430. var bf;
  4431. Event.remove(t.id, 'change', ch);
  4432. bf = Event.add(t.id, 'blur', function() {
  4433. Event.add(t.id, 'change', onChange);
  4434. Event.remove(t.id, 'blur', bf);
  4435. });
  4436. if (e.keyCode == 13 || e.keyCode == 32) {
  4437. onChange(e);
  4438. return Event.cancel(e);
  4439. }
  4440. });
  4441. t.onPostRender.dispatch(t, DOM.get(t.id));
  4442. }
  4443. });
  4444. })();
  4445. /* file:jscripts/tiny_mce/classes/ui/MenuButton.js */
  4446. (function() {
  4447. var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
  4448. tinymce.create('tinymce.ui.MenuButton:tinymce.ui.Button', {
  4449. MenuButton : function(id, s) {
  4450. this.parent(id, s);
  4451. this.onRenderMenu = new tinymce.util.Dispatcher(this);
  4452. s.menu_container = s.menu_container || DOM.doc.body;
  4453. },
  4454. showMenu : function() {
  4455. var t = this, p1, p2, e = DOM.get(t.id), m;
  4456. if (t.isDisabled())
  4457. return;
  4458. if (!t.isMenuRendered) {
  4459. t.renderMenu();
  4460. t.isMenuRendered = true;
  4461. }
  4462. if (t.isMenuVisible)
  4463. return t.hideMenu();
  4464. p1 = DOM.getPos(t.settings.menu_container);
  4465. p2 = DOM.getPos(e);
  4466. m = t.menu;
  4467. m.settings.offset_x = p2.x;
  4468. m.settings.offset_y = p2.y;
  4469. m.settings.vp_offset_x = p2.x;
  4470. m.settings.vp_offset_y = p2.y;
  4471. m.settings.keyboard_focus = t._focused;
  4472. m.showMenu(0, e.clientHeight);
  4473. Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
  4474. t.setState('Selected', 1);
  4475. t.isMenuVisible = 1;
  4476. },
  4477. renderMenu : function() {
  4478. var t = this, m;
  4479. m = t.settings.control_manager.createDropMenu(t.id + '_menu', {
  4480. menu_line : 1,
  4481. 'class' : this.classPrefix + 'Menu',
  4482. icons : t.settings.icons
  4483. });
  4484. m.onHideMenu.add(t.hideMenu, t);
  4485. t.onRenderMenu.dispatch(t, m);
  4486. t.menu = m;
  4487. },
  4488. hideMenu : function(e) {
  4489. var t = this;
  4490. // Prevent double toogles by canceling the mouse click event to the button
  4491. if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id || e.id === t.id + '_open';}))
  4492. return;
  4493. if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceMenu');})) {
  4494. t.setState('Selected', 0);
  4495. Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
  4496. if (t.menu)
  4497. t.menu.hideMenu();
  4498. }
  4499. t.isMenuVisible = 0;
  4500. },
  4501. postRender : function() {
  4502. var t = this, s = t.settings;
  4503. Event.add(t.id, 'click', function() {
  4504. if (!t.isDisabled()) {
  4505. if (s.onclick)
  4506. s.onclick(t.value);
  4507. t.showMenu();
  4508. }
  4509. });
  4510. }
  4511. });
  4512. })();
  4513. /* file:jscripts/tiny_mce/classes/ui/SplitButton.js */
  4514. (function() {
  4515. var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each;
  4516. tinymce.create('tinymce.ui.SplitButton:tinymce.ui.MenuButton', {
  4517. SplitButton : function(id, s) {
  4518. this.parent(id, s);
  4519. this.classPrefix = 'mceSplitButton';
  4520. },
  4521. renderHTML : function() {
  4522. var h, t = this, s = t.settings, h1;
  4523. h = '<tbody><tr>';
  4524. if (s.image)
  4525. h1 = DOM.createHTML('img ', {src : s.image, 'class' : 'mceAction ' + s['class']});
  4526. else
  4527. h1 = DOM.createHTML('span', {'class' : 'mceAction ' + s['class']}, '');
  4528. h += '<td>' + DOM.createHTML('a', {id : t.id + '_action', href : 'javascript:;', 'class' : 'mceAction ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
  4529. h1 = DOM.createHTML('span', {'class' : 'mceOpen ' + s['class']});
  4530. h += '<td>' + DOM.createHTML('a', {id : t.id + '_open', href : 'javascript:;', 'class' : 'mceOpen ' + s['class'], onclick : "return false;", onmousedown : 'return false;', title : s.title}, h1) + '</td>';
  4531. h += '</tr></tbody>';
  4532. return DOM.createHTML('table', {id : t.id, 'class' : 'mceSplitButton mceSplitButtonEnabled ' + s['class'], cellpadding : '0', cellspacing : '0', onmousedown : 'return false;', title : s.title}, h);
  4533. },
  4534. postRender : function() {
  4535. var t = this, s = t.settings;
  4536. if (s.onclick) {
  4537. Event.add(t.id + '_action', 'click', function() {
  4538. if (!t.isDisabled())
  4539. s.onclick(t.value);
  4540. });
  4541. }
  4542. Event.add(t.id + '_open', 'click', t.showMenu, t);
  4543. Event.add(t.id + '_open', 'focus', function() {t._focused = 1;});
  4544. Event.add(t.id + '_open', 'blur', function() {t._focused = 0;});
  4545. // Old IE doesn't have hover on all elements
  4546. if (tinymce.isIE6 || !DOM.boxModel) {
  4547. Event.add(t.id, 'mouseover', function() {
  4548. if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
  4549. DOM.addClass(t.id, 'mceSplitButtonHover');
  4550. });
  4551. Event.add(t.id, 'mouseout', function() {
  4552. if (!DOM.hasClass(t.id, 'mceSplitButtonDisabled'))
  4553. DOM.removeClass(t.id, 'mceSplitButtonHover');
  4554. });
  4555. }
  4556. },
  4557. destroy : function() {
  4558. this.parent();
  4559. Event.clear(this.id + '_action');
  4560. Event.clear(this.id + '_open');
  4561. }
  4562. });
  4563. })();
  4564. /* file:jscripts/tiny_mce/classes/ui/ColorSplitButton.js */
  4565. (function() {
  4566. var DOM = tinymce.DOM, Event = tinymce.dom.Event, is = tinymce.is, each = tinymce.each;
  4567. tinymce.create('tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton', {
  4568. ColorSplitButton : function(id, s) {
  4569. var t = this;
  4570. t.parent(id, s);
  4571. t.settings = s = tinymce.extend({
  4572. colors : '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF',
  4573. grid_width : 8,
  4574. default_color : '#888888'
  4575. }, t.settings);
  4576. t.onShowMenu = new tinymce.util.Dispatcher(t);
  4577. t.onHideMenu = new tinymce.util.Dispatcher(t);
  4578. t.value = s.default_color;
  4579. },
  4580. showMenu : function() {
  4581. var t = this, r, p, e, p2;
  4582. if (t.isDisabled())
  4583. return;
  4584. if (!t.isMenuRendered) {
  4585. t.renderMenu();
  4586. t.isMenuRendered = true;
  4587. }
  4588. if (t.isMenuVisible)
  4589. return t.hideMenu();
  4590. e = DOM.get(t.id);
  4591. DOM.show(t.id + '_menu');
  4592. DOM.addClass(e, 'mceSplitButtonSelected');
  4593. p2 = DOM.getPos(e);
  4594. DOM.setStyles(t.id + '_menu', {
  4595. left : p2.x,
  4596. top : p2.y + e.clientHeight,
  4597. zIndex : 200000
  4598. });
  4599. e = 0;
  4600. Event.add(DOM.doc, 'mousedown', t.hideMenu, t);
  4601. if (t._focused) {
  4602. t._keyHandler = Event.add(t.id + '_menu', 'keydown', function(e) {
  4603. if (e.keyCode == 27)
  4604. t.hideMenu();
  4605. });
  4606. DOM.select('a', t.id + '_menu')[0].focus(); // Select first link
  4607. }
  4608. t.onShowMenu.dispatch(t);
  4609. t.isMenuVisible = 1;
  4610. },
  4611. hideMenu : function(e) {
  4612. var t = this;
  4613. // Prevent double toogles by canceling the mouse click event to the button
  4614. if (e && e.type == "mousedown" && DOM.getParent(e.target, function(e) {return e.id === t.id + '_open';}))
  4615. return;
  4616. if (!e || !DOM.getParent(e.target, function(n) {return DOM.hasClass(n, 'mceSplitButtonMenu');})) {
  4617. DOM.removeClass(t.id, 'mceSplitButtonSelected');
  4618. Event.remove(DOM.doc, 'mousedown', t.hideMenu, t);
  4619. Event.remove(t.id + '_menu', 'keydown', t._keyHandler);
  4620. DOM.hide(t.id + '_menu');
  4621. }
  4622. t.onHideMenu.dispatch(t);
  4623. t.isMenuVisible = 0;
  4624. },
  4625. renderMenu : function() {
  4626. var t = this, m, i = 0, s = t.settings, n, tb, tr, w;
  4627. w = DOM.add(s.menu_container, 'div', {id : t.id + '_menu', 'class' : s['menu_class'] + ' ' + s['class'], style : 'position:absolute;left:0;top:-1000px;'});
  4628. m = DOM.add(w, 'div', {'class' : s['class'] + ' mceSplitButtonMenu'});
  4629. DOM.add(m, 'span', {'class' : 'mceMenuLine'});
  4630. n = DOM.add(m, 'table', {'class' : 'mceColorSplitMenu'});
  4631. tb = DOM.add(n, 'tbody');
  4632. // Generate color grid
  4633. i = 0;
  4634. each(is(s.colors, 'array') ? s.colors : s.colors.split(','), function(c) {
  4635. c = c.replace(/^#/, '');
  4636. if (!i--) {
  4637. tr = DOM.add(tb, 'tr');
  4638. i = s.grid_width - 1;
  4639. }
  4640. n = DOM.add(tr, 'td');
  4641. n = DOM.add(n, 'a', {
  4642. href : 'javascript:;',
  4643. style : {
  4644. backgroundColor : '#' + c
  4645. },
  4646. mce_color : '#' + c
  4647. });
  4648. });
  4649. if (s.more_colors_func) {
  4650. n = DOM.add(tb, 'tr');
  4651. n = DOM.add(n, 'td', {colspan : s.grid_width, 'class' : 'mceMoreColors'});
  4652. n = DOM.add(n, 'a', {id : t.id + '_more', href : 'javascript:;', onclick : 'return false;', 'class' : 'mceMoreColors'}, s.more_colors_title);
  4653. Event.add(n, 'click', function(e) {
  4654. s.more_colors_func.call(s.more_colors_scope || this);
  4655. return Event.cancel(e); // Cancel to fix onbeforeunload problem
  4656. });
  4657. }
  4658. DOM.addClass(m, 'mceColorSplitMenu');
  4659. Event.add(t.id + '_menu', 'click', function(e) {
  4660. var c;
  4661. e = e.target;
  4662. if (e.nodeName == 'A' && (c = e.getAttribute('mce_color')))
  4663. t.setColor(c);
  4664. return Event.cancel(e); // Prevent IE auto save warning
  4665. });
  4666. return w;
  4667. },
  4668. setColor : function(c) {
  4669. var t = this;
  4670. DOM.setStyle(t.id + '_preview', 'backgroundColor', c);
  4671. t.value = c;
  4672. t.hideMenu();
  4673. t.settings.onselect(c);
  4674. },
  4675. postRender : function() {
  4676. var t = this, id = t.id;
  4677. t.parent();
  4678. DOM.add(id + '_action', 'div', {id : id + '_preview', 'class' : 'mceColorPreview'});
  4679. },
  4680. destroy : function() {
  4681. this.parent();
  4682. Event.clear(this.id + '_menu');
  4683. Event.clear(this.id + '_more');
  4684. DOM.remove(this.id + '_menu');
  4685. }
  4686. });
  4687. })();
  4688. /* file:jscripts/tiny_mce/classes/ui/Toolbar.js */
  4689. tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
  4690. renderHTML : function() {
  4691. var t = this, h = '', c, co, dom = tinymce.DOM, s = t.settings, i, pr, nx, cl;
  4692. cl = t.controls;
  4693. for (i=0; i<cl.length; i++) {
  4694. // Get current control, prev control, next control and if the control is a list box or not
  4695. co = cl[i];
  4696. pr = cl[i - 1];
  4697. nx = cl[i + 1];
  4698. // Add toolbar start
  4699. if (i === 0) {
  4700. c = 'mceToolbarStart';
  4701. if (co.Button)
  4702. c += ' mceToolbarStartButton';
  4703. else if (co.SplitButton)
  4704. c += ' mceToolbarStartSplitButton';
  4705. else if (co.ListBox)
  4706. c += ' mceToolbarStartListBox';
  4707. h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
  4708. }
  4709. // Add toolbar end before list box and after the previous button
  4710. // This is to fix the o2k7 editor skins
  4711. if (pr && co.ListBox) {
  4712. if (pr.Button || pr.SplitButton)
  4713. h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->'));
  4714. }
  4715. // Render control HTML
  4716. // IE 8 quick fix, needed to propertly generate a hit area for anchors
  4717. if (dom.stdMode)
  4718. h += '<td style="position: relative">' + co.renderHTML() + '</td>';
  4719. else
  4720. h += '<td>' + co.renderHTML() + '</td>';
  4721. // Add toolbar start after list box and before the next button
  4722. // This is to fix the o2k7 editor skins
  4723. if (nx && co.ListBox) {
  4724. if (nx.Button || nx.SplitButton)
  4725. h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->'));
  4726. }
  4727. }
  4728. c = 'mceToolbarEnd';
  4729. if (co.Button)
  4730. c += ' mceToolbarEndButton';
  4731. else if (co.SplitButton)
  4732. c += ' mceToolbarEndSplitButton';
  4733. else if (co.ListBox)
  4734. c += ' mceToolbarEndListBox';
  4735. h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
  4736. return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || ''}, '<tbody><tr>' + h + '</tr></tbody>');
  4737. }
  4738. });
  4739. /* file:jscripts/tiny_mce/classes/AddOnManager.js */
  4740. (function() {
  4741. var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each;
  4742. tinymce.create('tinymce.AddOnManager', {
  4743. items : [],
  4744. urls : {},
  4745. lookup : {},
  4746. onAdd : new Dispatcher(this),
  4747. get : function(n) {
  4748. return this.lookup[n];
  4749. },
  4750. requireLangPack : function(n) {
  4751. var u, s = tinymce.EditorManager.settings;
  4752. if (s && s.language) {
  4753. u = this.urls[n] + '/langs/' + s.language + '.js';
  4754. if (!tinymce.dom.Event.domLoaded && !s.strict_mode)
  4755. tinymce.ScriptLoader.load(u);
  4756. else
  4757. tinymce.ScriptLoader.add(u);
  4758. }
  4759. },
  4760. add : function(id, o) {
  4761. this.items.push(o);
  4762. this.lookup[id] = o;
  4763. this.onAdd.dispatch(this, id, o);
  4764. return o;
  4765. },
  4766. load : function(n, u, cb, s) {
  4767. var t = this;
  4768. if (t.urls[n])
  4769. return;
  4770. if (u.indexOf('/') != 0 && u.indexOf('://') == -1)
  4771. u = tinymce.baseURL + '/' + u;
  4772. t.urls[n] = u.substring(0, u.lastIndexOf('/'));
  4773. tinymce.ScriptLoader.add(u, cb, s);
  4774. }
  4775. });
  4776. // Create plugin and theme managers
  4777. tinymce.PluginManager = new tinymce.AddOnManager();
  4778. tinymce.ThemeManager = new tinymce.AddOnManager();
  4779. }());
  4780. /* file:jscripts/tiny_mce/classes/EditorManager.js */
  4781. (function() {
  4782. // Shorten names
  4783. var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode;
  4784. tinymce.create('static tinymce.EditorManager', {
  4785. editors : {},
  4786. i18n : {},
  4787. activeEditor : null,
  4788. preInit : function() {
  4789. var t = this, lo = window.location;
  4790. // Setup some URLs where the editor API is located and where the document is
  4791. tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
  4792. if (!/[\/\\]$/.test(tinymce.documentBaseURL))
  4793. tinymce.documentBaseURL += '/';
  4794. tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL);
  4795. tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL);
  4796. // User already specified a document.domain value
  4797. if (document.domain && lo.hostname != document.domain)
  4798. tinymce.relaxedDomain = document.domain;
  4799. // Setup document domain if tinymce is loaded from other domain
  4800. if (!tinymce.relaxedDomain && tinymce.EditorManager.baseURI.host != lo.hostname && lo.hostname)
  4801. document.domain = tinymce.relaxedDomain = lo.hostname.replace(/.*\.(.+\..+)$/, '$1');
  4802. // Add before unload listener
  4803. // This was required since IE was leaking memory if you added and removed beforeunload listeners
  4804. // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event
  4805. t.onBeforeUnload = new tinymce.util.Dispatcher(t);
  4806. // Must be on window or IE will leak if the editor is placed in frame or iframe
  4807. Event.add(window, 'beforeunload', function(e) {
  4808. t.onBeforeUnload.dispatch(t, e);
  4809. });
  4810. },
  4811. init : function(s) {
  4812. var t = this, pl, sl = tinymce.ScriptLoader, c, e, el = [], ed;
  4813. function execCallback(se, n, s) {
  4814. var f = se[n];
  4815. if (!f)
  4816. return;
  4817. if (tinymce.is(f, 'string')) {
  4818. s = f.replace(/\.\w+$/, '');
  4819. s = s ? tinymce.resolve(s) : 0;
  4820. f = tinymce.resolve(f);
  4821. }
  4822. return f.apply(s || this, Array.prototype.slice.call(arguments, 2));
  4823. };
  4824. s = extend({
  4825. theme : "simple",
  4826. language : "en",
  4827. strict_loading_mode : document.contentType == 'application/xhtml+xml'
  4828. }, s);
  4829. t.settings = s;
  4830. // If page not loaded and strict mode isn't enabled then load them
  4831. if (!Event.domLoaded && !s.strict_loading_mode) {
  4832. // Load language
  4833. if (s.language)
  4834. sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
  4835. // Load theme
  4836. if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
  4837. ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
  4838. // Load plugins
  4839. if (s.plugins) {
  4840. pl = explode(s.plugins);
  4841. // Load compat2x first
  4842. if (tinymce.inArray(pl, 'compat2x') != -1)
  4843. PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
  4844. // Load rest if plugins
  4845. each(pl, function(v) {
  4846. if (v && v.charAt(0) != '-' && !PluginManager.urls[v]) {
  4847. // Skip safari plugin for other browsers
  4848. if (!tinymce.isWebKit && v == 'safari')
  4849. return;
  4850. PluginManager.load(v, 'plugins/' + v + '/editor_plugin' + tinymce.suffix + '.js');
  4851. }
  4852. });
  4853. }
  4854. sl.loadQueue();
  4855. }
  4856. // Legacy call
  4857. Event.add(document, 'init', function() {
  4858. var l, co;
  4859. execCallback(s, 'onpageload');
  4860. // Verify that it's a valid browser
  4861. if (s.browsers) {
  4862. l = false;
  4863. each(explode(s.browsers), function(v) {
  4864. switch (v) {
  4865. case 'ie':
  4866. case 'msie':
  4867. if (tinymce.isIE)
  4868. l = true;
  4869. break;
  4870. case 'gecko':
  4871. if (tinymce.isGecko)
  4872. l = true;
  4873. break;
  4874. case 'safari':
  4875. case 'webkit':
  4876. if (tinymce.isWebKit)
  4877. l = true;
  4878. break;
  4879. case 'opera':
  4880. if (tinymce.isOpera)
  4881. l = true;
  4882. break;
  4883. }
  4884. });
  4885. // Not a valid one
  4886. if (!l)
  4887. return;
  4888. }
  4889. switch (s.mode) {
  4890. case "exact":
  4891. l = s.elements || '';
  4892. if(l.length > 0) {
  4893. each(explode(l), function(v) {
  4894. if (DOM.get(v)) {
  4895. ed = new tinymce.Editor(v, s);
  4896. el.push(ed);
  4897. ed.render(1);
  4898. } else {
  4899. c = 0;
  4900. each(document.forms, function(f) {
  4901. each(f.elements, function(e) {
  4902. if (e.name === v) {
  4903. v = 'mce_editor_' + c;
  4904. DOM.setAttrib(e, 'id', v);
  4905. ed = new tinymce.Editor(v, s);
  4906. el.push(ed);
  4907. ed.render(1);
  4908. }
  4909. });
  4910. });
  4911. }
  4912. });
  4913. }
  4914. break;
  4915. case "textareas":
  4916. case "specific_textareas":
  4917. function hasClass(n, c) {
  4918. return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c);
  4919. };
  4920. each(DOM.select('textarea'), function(v) {
  4921. if (s.editor_deselector && hasClass(v, s.editor_deselector))
  4922. return;
  4923. if (!s.editor_selector || hasClass(v, s.editor_selector)) {
  4924. // Can we use the name
  4925. e = DOM.get(v.name);
  4926. if (!v.id && !e)
  4927. v.id = v.name;
  4928. // Generate unique name if missing or already exists
  4929. if (!v.id || t.get(v.id))
  4930. v.id = DOM.uniqueId();
  4931. ed = new tinymce.Editor(v.id, s);
  4932. el.push(ed);
  4933. ed.render(1);
  4934. }
  4935. });
  4936. break;
  4937. }
  4938. // Call onInit when all editors are initialized
  4939. if (s.oninit) {
  4940. l = co = 0;
  4941. each (el, function(ed) {
  4942. co++;
  4943. if (!ed.initialized) {
  4944. // Wait for it
  4945. ed.onInit.add(function() {
  4946. l++;
  4947. // All done
  4948. if (l == co)
  4949. execCallback(s, 'oninit');
  4950. });
  4951. } else
  4952. l++;
  4953. // All done
  4954. if (l == co)
  4955. execCallback(s, 'oninit');
  4956. });
  4957. }
  4958. });
  4959. },
  4960. get : function(id) {
  4961. return this.editors[id];
  4962. },
  4963. getInstanceById : function(id) {
  4964. return this.get(id);
  4965. },
  4966. add : function(e) {
  4967. this.editors[e.id] = e;
  4968. this._setActive(e);
  4969. return e;
  4970. },
  4971. remove : function(e) {
  4972. var t = this;
  4973. // Not in the collection
  4974. if (!t.editors[e.id])
  4975. return null;
  4976. delete t.editors[e.id];
  4977. // Select another editor since the active one was removed
  4978. if (t.activeEditor == e) {
  4979. each(t.editors, function(e) {
  4980. t._setActive(e);
  4981. return false; // Break
  4982. });
  4983. }
  4984. e.destroy();
  4985. return e;
  4986. },
  4987. execCommand : function(c, u, v) {
  4988. var t = this, ed = t.get(v), w;
  4989. // Manager commands
  4990. switch (c) {
  4991. case "mceFocus":
  4992. ed.focus();
  4993. return true;
  4994. case "mceAddEditor":
  4995. case "mceAddControl":
  4996. if (!t.get(v))
  4997. new tinymce.Editor(v, t.settings).render();
  4998. return true;
  4999. case "mceAddFrameControl":
  5000. w = v.window;
  5001. // Add tinyMCE global instance and tinymce namespace to specified window
  5002. w.tinyMCE = tinyMCE;
  5003. w.tinymce = tinymce;
  5004. tinymce.DOM.doc = w.document;
  5005. tinymce.DOM.win = w;
  5006. ed = new tinymce.Editor(v.element_id, v);
  5007. ed.render();
  5008. // Fix IE memory leaks
  5009. if (tinymce.isIE) {
  5010. function clr() {
  5011. ed.destroy();
  5012. w.detachEvent('onunload', clr);
  5013. w = w.tinyMCE = w.tinymce = null; // IE leak
  5014. };
  5015. w.attachEvent('onunload', clr);
  5016. }
  5017. v.page_window = null;
  5018. return true;
  5019. case "mceRemoveEditor":
  5020. case "mceRemoveControl":
  5021. if (ed)
  5022. ed.remove();
  5023. return true;
  5024. case 'mceToggleEditor':
  5025. if (!ed) {
  5026. t.execCommand('mceAddControl', 0, v);
  5027. return true;
  5028. }
  5029. if (ed.isHidden())
  5030. ed.show();
  5031. else
  5032. ed.hide();
  5033. return true;
  5034. }
  5035. // Run command on active editor
  5036. if (t.activeEditor)
  5037. return t.activeEditor.execCommand(c, u, v);
  5038. return false;
  5039. },
  5040. execInstanceCommand : function(id, c, u, v) {
  5041. var ed = this.get(id);
  5042. if (ed)
  5043. return ed.execCommand(c, u, v);
  5044. return false;
  5045. },
  5046. triggerSave : function() {
  5047. each(this.editors, function(e) {
  5048. e.save();
  5049. });
  5050. },
  5051. addI18n : function(p, o) {
  5052. var lo, i18n = this.i18n;
  5053. if (!tinymce.is(p, 'string')) {
  5054. each(p, function(o, lc) {
  5055. each(o, function(o, g) {
  5056. each(o, function(o, k) {
  5057. if (g === 'common')
  5058. i18n[lc + '.' + k] = o;
  5059. else
  5060. i18n[lc + '.' + g + '.' + k] = o;
  5061. });
  5062. });
  5063. });
  5064. } else {
  5065. each(o, function(o, k) {
  5066. i18n[p + '.' + k] = o;
  5067. });
  5068. }
  5069. },
  5070. // Private methods
  5071. _setActive : function(e) {
  5072. this.selectedInstance = this.activeEditor = e;
  5073. }
  5074. });
  5075. tinymce.EditorManager.preInit();
  5076. })();
  5077. // Short for editor manager window.tinyMCE is needed when TinyMCE gets loaded though a XHR call
  5078. var tinyMCE = window.tinyMCE = tinymce.EditorManager;
  5079. /* file:jscripts/tiny_mce/classes/Editor.js */
  5080. (function() {
  5081. var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher;
  5082. var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit;
  5083. var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager;
  5084. var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode;
  5085. tinymce.create('tinymce.Editor', {
  5086. Editor : function(id, s) {
  5087. var t = this;
  5088. t.id = t.editorId = id;
  5089. t.execCommands = {};
  5090. t.queryStateCommands = {};
  5091. t.queryValueCommands = {};
  5092. t.plugins = {};
  5093. // Add events to the editor
  5094. each([
  5095. 'onPreInit',
  5096. 'onBeforeRenderUI',
  5097. 'onPostRender',
  5098. 'onInit',
  5099. 'onRemove',
  5100. 'onActivate',
  5101. 'onDeactivate',
  5102. 'onClick',
  5103. 'onEvent',
  5104. 'onMouseUp',
  5105. 'onMouseDown',
  5106. 'onDblClick',
  5107. 'onKeyDown',
  5108. 'onKeyUp',
  5109. 'onKeyPress',
  5110. 'onContextMenu',
  5111. 'onSubmit',
  5112. 'onReset',
  5113. 'onPaste',
  5114. 'onPreProcess',
  5115. 'onPostProcess',
  5116. 'onBeforeSetContent',
  5117. 'onBeforeGetContent',
  5118. 'onSetContent',
  5119. 'onGetContent',
  5120. 'onLoadContent',
  5121. 'onSaveContent',
  5122. 'onNodeChange',
  5123. 'onChange',
  5124. 'onBeforeExecCommand',
  5125. 'onExecCommand',
  5126. 'onUndo',
  5127. 'onRedo',
  5128. 'onVisualAid',
  5129. 'onSetProgressState'
  5130. ], function(e) {
  5131. t[e] = new Dispatcher(t);
  5132. });
  5133. // Default editor config
  5134. t.settings = s = extend({
  5135. id : id,
  5136. language : 'en',
  5137. docs_language : 'en',
  5138. theme : 'simple',
  5139. skin : 'default',
  5140. delta_width : 0,
  5141. delta_height : 0,
  5142. popup_css : '',
  5143. plugins : '',
  5144. document_base_url : tinymce.documentBaseURL,
  5145. add_form_submit_trigger : 1,
  5146. submit_patch : 1,
  5147. add_unload_trigger : 1,
  5148. convert_urls : 1,
  5149. relative_urls : 1,
  5150. remove_script_host : 1,
  5151. table_inline_editing : 0,
  5152. object_resizing : 1,
  5153. cleanup : 1,
  5154. accessibility_focus : 1,
  5155. custom_shortcuts : 1,
  5156. custom_undo_redo_keyboard_shortcuts : 1,
  5157. custom_undo_redo_restore_selection : 1,
  5158. custom_undo_redo : 1,
  5159. doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
  5160. visual_table_class : 'mceItemTable',
  5161. visual : 1,
  5162. inline_styles : true,
  5163. convert_fonts_to_spans : true,
  5164. font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large',
  5165. apply_source_formatting : 1,
  5166. directionality : 'ltr',
  5167. forced_root_block : 'p',
  5168. valid_elements : '@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p[align],-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border=0|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big',
  5169. hidden_input : 1,
  5170. padd_empty_editor : 1,
  5171. render_ui : 1,
  5172. init_theme : 1,
  5173. force_p_newlines : 1,
  5174. indentation : '30px',
  5175. keep_styles : 1
  5176. }, s);
  5177. // Setup URIs
  5178. t.documentBaseURI = new tinymce.util.URI(s.document_base_url || tinymce.documentBaseURL, {
  5179. base_uri : tinyMCE.baseURI
  5180. });
  5181. t.baseURI = EditorManager.baseURI;
  5182. // Call setup
  5183. t.execCallback('setup', t);
  5184. },
  5185. render : function(nst) {
  5186. var t = this, s = t.settings, id = t.id, sl = tinymce.ScriptLoader;
  5187. // Page is not loaded yet, wait for it
  5188. if (!Event.domLoaded) {
  5189. Event.add(document, 'init', function() {
  5190. t.render();
  5191. });
  5192. return;
  5193. }
  5194. // Force strict loading mode if render us called by user and not internally
  5195. if (!nst) {
  5196. s.strict_loading_mode = 1;
  5197. tinyMCE.settings = s;
  5198. }
  5199. // Element not found, then skip initialization
  5200. if (!t.getElement())
  5201. return;
  5202. if (s.strict_loading_mode) {
  5203. sl.settings.strict_mode = s.strict_loading_mode;
  5204. tinymce.DOM.settings.strict = 1;
  5205. }
  5206. // Add hidden input for non input elements inside form elements
  5207. if (!/TEXTAREA|INPUT/i.test(t.getElement().nodeName) && s.hidden_input && DOM.getParent(id, 'form'))
  5208. DOM.insertAfter(DOM.create('input', {type : 'hidden', name : id}), id);
  5209. t.windowManager = new tinymce.WindowManager(t);
  5210. if (s.encoding == 'xml') {
  5211. t.onGetContent.add(function(ed, o) {
  5212. if (o.save)
  5213. o.content = DOM.encode(o.content);
  5214. });
  5215. }
  5216. if (s.add_form_submit_trigger) {
  5217. t.onSubmit.addToTop(function() {
  5218. if (t.initialized) {
  5219. t.save();
  5220. t.isNotDirty = 1;
  5221. }
  5222. });
  5223. }
  5224. if (s.add_unload_trigger && !s.ask) {
  5225. t._beforeUnload = tinyMCE.onBeforeUnload.add(function() {
  5226. if (t.initialized && !t.destroyed && !t.isHidden())
  5227. t.save({format : 'raw', no_events : true});
  5228. });
  5229. }
  5230. tinymce.addUnload(t.destroy, t);
  5231. if (s.submit_patch) {
  5232. t.onBeforeRenderUI.add(function() {
  5233. var n = t.getElement().form;
  5234. if (!n)
  5235. return;
  5236. // Already patched
  5237. if (n._mceOldSubmit)
  5238. return;
  5239. // Check page uses id="submit" or name="submit" for it's submit button
  5240. if (!n.submit.nodeType && !n.submit.length) {
  5241. t.formElement = n;
  5242. n._mceOldSubmit = n.submit;
  5243. n.submit = function() {
  5244. // Save all instances
  5245. EditorManager.triggerSave();
  5246. t.isNotDirty = 1;
  5247. return this._mceOldSubmit(this);
  5248. };
  5249. }
  5250. n = null;
  5251. });
  5252. }
  5253. // Load scripts
  5254. function loadScripts() {
  5255. if (s.language)
  5256. sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
  5257. if (s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
  5258. ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
  5259. each(explode(s.plugins), function(p) {
  5260. if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) {
  5261. // Skip safari plugin for other browsers
  5262. if (!isWebKit && p == 'safari')
  5263. return;
  5264. PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js');
  5265. }
  5266. });
  5267. // Init when que is loaded
  5268. sl.loadQueue(function() {
  5269. if (s.ask) {
  5270. function ask() {
  5271. // Yield for awhile to avoid focus bug on FF 3 when cancel is pressed
  5272. window.setTimeout(function() {
  5273. Event.remove(t.id, 'focus', ask);
  5274. t.windowManager.confirm(t.getLang('edit_confirm'), function(s) {
  5275. if (s)
  5276. t.init();
  5277. });
  5278. }, 0);
  5279. };
  5280. Event.add(t.id, 'focus', ask);
  5281. return;
  5282. }
  5283. if (!t.removed)
  5284. t.init();
  5285. });
  5286. };
  5287. // Load compat2x first
  5288. if (s.plugins.indexOf('compat2x') != -1) {
  5289. PluginManager.load('compat2x', 'plugins/compat2x/editor_plugin' + tinymce.suffix + '.js');
  5290. sl.loadQueue(loadScripts);
  5291. } else
  5292. loadScripts();
  5293. },
  5294. init : function() {
  5295. var n, t = this, s = t.settings, w, h, e = t.getElement(), o, ti, u, bi, bc, re;
  5296. EditorManager.add(t);
  5297. // Create theme
  5298. s.theme = s.theme.replace(/-/, '');
  5299. o = ThemeManager.get(s.theme);
  5300. t.theme = new o();
  5301. if (t.theme.init && s.init_theme)
  5302. t.theme.init(t, ThemeManager.urls[s.theme] || tinymce.documentBaseURL.replace(/\/$/, ''));
  5303. // Create all plugins
  5304. each(explode(s.plugins.replace(/\-/g, '')), function(p) {
  5305. var c = PluginManager.get(p), u = PluginManager.urls[p] || tinymce.documentBaseURL.replace(/\/$/, ''), po;
  5306. if (c) {
  5307. po = new c(t, u);
  5308. t.plugins[p] = po;
  5309. if (po.init)
  5310. po.init(t, u);
  5311. }
  5312. });
  5313. // Setup popup CSS path(s)
  5314. if (s.popup_css !== false) {
  5315. if (s.popup_css)
  5316. s.popup_css = t.documentBaseURI.toAbsolute(s.popup_css);
  5317. else
  5318. s.popup_css = t.baseURI.toAbsolute("themes/" + s.theme + "/skins/" + s.skin + "/dialog.css");
  5319. }
  5320. if (s.popup_css_add)
  5321. s.popup_css += ',' + t.documentBaseURI.toAbsolute(s.popup_css_add);
  5322. // Setup control factory
  5323. t.controlManager = new tinymce.ControlManager(t);
  5324. t.undoManager = new tinymce.UndoManager(t);
  5325. // Pass through
  5326. t.undoManager.onAdd.add(function(um, l) {
  5327. if (!l.initial)
  5328. return t.onChange.dispatch(t, l, um);
  5329. });
  5330. t.undoManager.onUndo.add(function(um, l) {
  5331. return t.onUndo.dispatch(t, l, um);
  5332. });
  5333. t.undoManager.onRedo.add(function(um, l) {
  5334. return t.onRedo.dispatch(t, l, um);
  5335. });
  5336. if (s.custom_undo_redo) {
  5337. t.onExecCommand.add(function(ed, cmd, ui, val, a) {
  5338. if (cmd != 'Undo' && cmd != 'Redo' && cmd != 'mceRepaint' && (!a || !a.skip_undo))
  5339. t.undoManager.add();
  5340. });
  5341. }
  5342. t.onExecCommand.add(function(ed, c) {
  5343. // Don't refresh the select lists until caret move
  5344. if (!/^(FontName|FontSize)$/.test(c))
  5345. t.nodeChanged();
  5346. });
  5347. // Remove ghost selections on images and tables in Gecko
  5348. if (isGecko) {
  5349. function repaint(a, o) {
  5350. if (!o || !o.initial)
  5351. t.execCommand('mceRepaint');
  5352. };
  5353. t.onUndo.add(repaint);
  5354. t.onRedo.add(repaint);
  5355. t.onSetContent.add(repaint);
  5356. }
  5357. // Enables users to override the control factory
  5358. t.onBeforeRenderUI.dispatch(t, t.controlManager);
  5359. // Measure box
  5360. if (s.render_ui) {
  5361. w = s.width || e.style.width || e.offsetWidth;
  5362. h = s.height || e.style.height || e.offsetHeight;
  5363. t.orgDisplay = e.style.display;
  5364. re = /^[0-9\.]+(|px)$/i;
  5365. if (re.test('' + w))
  5366. w = Math.max(parseInt(w) + (o.deltaWidth || 0), 100);
  5367. if (re.test('' + h))
  5368. h = Math.max(parseInt(h) + (o.deltaHeight || 0), 100);
  5369. // Render UI
  5370. o = t.theme.renderUI({
  5371. targetNode : e,
  5372. width : w,
  5373. height : h,
  5374. deltaWidth : s.delta_width,
  5375. deltaHeight : s.delta_height
  5376. });
  5377. t.editorContainer = o.editorContainer;
  5378. }
  5379. // Resize editor
  5380. DOM.setStyles(o.sizeContainer || o.editorContainer, {
  5381. width : w,
  5382. height : h
  5383. });
  5384. h = (o.iframeHeight || h) + ((h + '').indexOf('%') == -1 ? (o.deltaHeight || 0) : '');
  5385. if (h < 100)
  5386. h = 100;
  5387. t.iframeHTML = s.doctype + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + t.documentBaseURI.getURI() + '" />';
  5388. t.iframeHTML += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
  5389. if (tinymce.relaxedDomain)
  5390. t.iframeHTML += '<script type="text/javascript">document.domain = "' + tinymce.relaxedDomain + '";</script>';
  5391. bi = s.body_id || 'tinymce';
  5392. if (bi.indexOf('=') != -1) {
  5393. bi = t.getParam('body_id', '', 'hash');
  5394. bi = bi[t.id] || bi;
  5395. }
  5396. bc = s.body_class || '';
  5397. if (bc.indexOf('=') != -1) {
  5398. bc = t.getParam('body_class', '', 'hash');
  5399. bc = bc[t.id] || '';
  5400. }
  5401. t.iframeHTML += '</head><body id="' + bi + '" class="mceContentBody ' + bc + '"></body></html>';
  5402. // Domain relaxing enabled, then set document domain
  5403. if (tinymce.relaxedDomain) {
  5404. // We need to write the contents here in IE since multiple writes messes up refresh button and back button
  5405. if (isIE || (tinymce.isOpera && parseFloat(opera.version()) >= 9.5))
  5406. u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.tinyMCE.get("' + t.id + '");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';
  5407. else if (tinymce.isOpera)
  5408. u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";document.close();ed.setupIframe();})()';
  5409. }
  5410. // Create iframe
  5411. n = DOM.add(o.iframeContainer, 'iframe', {
  5412. id : t.id + "_ifr",
  5413. src : u || 'javascript:""', // Workaround for HTTPS warning in IE6/7
  5414. frameBorder : '0',
  5415. style : {
  5416. width : '100%',
  5417. height : h
  5418. }
  5419. });
  5420. t.contentAreaContainer = o.iframeContainer;
  5421. DOM.get(o.editorContainer).style.display = t.orgDisplay;
  5422. DOM.get(t.id).style.display = 'none';
  5423. // Safari 2.x requires us to wait for the load event and load a real HTML doc
  5424. if (tinymce.isOldWebKit) {
  5425. Event.add(n, 'load', t.setupIframe, t);
  5426. n.src = tinymce.baseURL + '/plugins/safari/blank.htm';
  5427. } else {
  5428. if (!isIE || !tinymce.relaxedDomain)
  5429. t.setupIframe();
  5430. e = n = o = null; // Cleanup
  5431. }
  5432. },
  5433. setupIframe : function() {
  5434. var t = this, s = t.settings, e = DOM.get(t.id), d = t.getDoc(), h, b;
  5435. // Setup iframe body
  5436. if (!isIE || !tinymce.relaxedDomain) {
  5437. d.open();
  5438. d.write(t.iframeHTML);
  5439. d.close();
  5440. }
  5441. // Design mode needs to be added here Ctrl+A will fail otherwise
  5442. if (!isIE) {
  5443. try {
  5444. if (!s.readonly)
  5445. d.designMode = 'On';
  5446. } catch (ex) {
  5447. // Will fail on Gecko if the editor is placed in an hidden container element
  5448. // The design mode will be set ones the editor is focused
  5449. }
  5450. }
  5451. // IE needs to use contentEditable or it will display non secure items for HTTPS
  5452. if (isIE) {
  5453. // It will not steal focus if we hide it while setting contentEditable
  5454. b = t.getBody();
  5455. DOM.hide(b);
  5456. if (!s.readonly)
  5457. b.contentEditable = true;
  5458. DOM.show(b);
  5459. }
  5460. // Setup objects
  5461. t.dom = new tinymce.DOM.DOMUtils(t.getDoc(), {
  5462. keep_values : true,
  5463. url_converter : t.convertURL,
  5464. url_converter_scope : t,
  5465. hex_colors : s.force_hex_style_colors,
  5466. class_filter : s.class_filter,
  5467. update_styles : 1,
  5468. fix_ie_paragraphs : 1
  5469. });
  5470. t.serializer = new tinymce.dom.Serializer({
  5471. entity_encoding : s.entity_encoding,
  5472. entities : s.entities,
  5473. valid_elements : s.verify_html === false ? '*[*]' : s.valid_elements,
  5474. extended_valid_elements : s.extended_valid_elements,
  5475. valid_child_elements : s.valid_child_elements,
  5476. invalid_elements : s.invalid_elements,
  5477. fix_table_elements : s.fix_table_elements,
  5478. fix_list_elements : s.fix_list_elements,
  5479. fix_content_duplication : s.fix_content_duplication,
  5480. convert_fonts_to_spans : s.convert_fonts_to_spans,
  5481. font_size_classes : s.font_size_classes,
  5482. font_size_style_values : s.font_size_style_values,
  5483. apply_source_formatting : s.apply_source_formatting,
  5484. remove_linebreaks : s.remove_linebreaks,
  5485. element_format : s.element_format,
  5486. dom : t.dom
  5487. });
  5488. t.selection = new tinymce.dom.Selection(t.dom, t.getWin(), t.serializer);
  5489. t.forceBlocks = new tinymce.ForceBlocks(t, {
  5490. forced_root_block : s.forced_root_block
  5491. });
  5492. t.editorCommands = new tinymce.EditorCommands(t);
  5493. // Pass through
  5494. t.serializer.onPreProcess.add(function(se, o) {
  5495. return t.onPreProcess.dispatch(t, o, se);
  5496. });
  5497. t.serializer.onPostProcess.add(function(se, o) {
  5498. return t.onPostProcess.dispatch(t, o, se);
  5499. });
  5500. t.onPreInit.dispatch(t);
  5501. if (!s.gecko_spellcheck)
  5502. t.getBody().spellcheck = 0;
  5503. if (!s.readonly)
  5504. t._addEvents();
  5505. t.controlManager.onPostRender.dispatch(t, t.controlManager);
  5506. t.onPostRender.dispatch(t);
  5507. if (s.directionality)
  5508. t.getBody().dir = s.directionality;
  5509. if (s.nowrap)
  5510. t.getBody().style.whiteSpace = "nowrap";
  5511. if (s.auto_resize)
  5512. t.onNodeChange.add(t.resizeToContent, t);
  5513. if (s.custom_elements) {
  5514. function handleCustom(ed, o) {
  5515. each(explode(s.custom_elements), function(v) {
  5516. var n;
  5517. if (v.indexOf('~') === 0) {
  5518. v = v.substring(1);
  5519. n = 'span';
  5520. } else
  5521. n = 'div';
  5522. o.content = o.content.replace(new RegExp('<(' + v + ')([^>]*)>', 'g'), '<' + n + ' mce_name="$1"$2>');
  5523. o.content = o.content.replace(new RegExp('</(' + v + ')>', 'g'), '</' + n + '>');
  5524. });
  5525. };
  5526. t.onBeforeSetContent.add(handleCustom);
  5527. t.onPostProcess.add(function(ed, o) {
  5528. if (o.set)
  5529. handleCustom(ed, o)
  5530. });
  5531. }
  5532. if (s.handle_node_change_callback) {
  5533. t.onNodeChange.add(function(ed, cm, n) {
  5534. t.execCallback('handle_node_change_callback', t.id, n, -1, -1, true, t.selection.isCollapsed());
  5535. });
  5536. }
  5537. if (s.save_callback) {
  5538. t.onSaveContent.add(function(ed, o) {
  5539. var h = t.execCallback('save_callback', t.id, o.content, t.getBody());
  5540. if (h)
  5541. o.content = h;
  5542. });
  5543. }
  5544. if (s.onchange_callback) {
  5545. t.onChange.add(function(ed, l) {
  5546. t.execCallback('onchange_callback', t, l);
  5547. });
  5548. }
  5549. if (s.convert_newlines_to_brs) {
  5550. t.onBeforeSetContent.add(function(ed, o) {
  5551. if (o.initial)
  5552. o.content = o.content.replace(/\r?\n/g, '<br />');
  5553. });
  5554. }
  5555. if (s.fix_nesting && isIE) {
  5556. t.onBeforeSetContent.add(function(ed, o) {
  5557. o.content = t._fixNesting(o.content);
  5558. });
  5559. }
  5560. if (s.preformatted) {
  5561. t.onPostProcess.add(function(ed, o) {
  5562. o.content = o.content.replace(/^\s*<pre.*?>/, '');
  5563. o.content = o.content.replace(/<\/pre>\s*$/, '');
  5564. if (o.set)
  5565. o.content = '<pre class="mceItemHidden">' + o.content + '</pre>';
  5566. });
  5567. }
  5568. if (s.verify_css_classes) {
  5569. t.serializer.attribValueFilter = function(n, v) {
  5570. var s, cl;
  5571. if (n == 'class') {
  5572. // Build regexp for classes
  5573. if (!t.classesRE) {
  5574. cl = t.dom.getClasses();
  5575. if (cl.length > 0) {
  5576. s = '';
  5577. each (cl, function(o) {
  5578. s += (s ? '|' : '') + o['class'];
  5579. });
  5580. t.classesRE = new RegExp('(' + s + ')', 'gi');
  5581. }
  5582. }
  5583. return !t.classesRE || /(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v) || t.classesRE.test(v) ? v : '';
  5584. }
  5585. return v;
  5586. };
  5587. }
  5588. if (s.convert_fonts_to_spans)
  5589. t._convertFonts();
  5590. if (s.inline_styles)
  5591. t._convertInlineElements();
  5592. if (s.cleanup_callback) {
  5593. t.onBeforeSetContent.add(function(ed, o) {
  5594. o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
  5595. });
  5596. t.onPreProcess.add(function(ed, o) {
  5597. if (o.set)
  5598. t.execCallback('cleanup_callback', 'insert_to_editor_dom', o.node, o);
  5599. if (o.get)
  5600. t.execCallback('cleanup_callback', 'get_from_editor_dom', o.node, o);
  5601. });
  5602. t.onPostProcess.add(function(ed, o) {
  5603. if (o.set)
  5604. o.content = t.execCallback('cleanup_callback', 'insert_to_editor', o.content, o);
  5605. if (o.get)
  5606. o.content = t.execCallback('cleanup_callback', 'get_from_editor', o.content, o);
  5607. });
  5608. }
  5609. if (s.save_callback) {
  5610. t.onGetContent.add(function(ed, o) {
  5611. if (o.save)
  5612. o.content = t.execCallback('save_callback', t.id, o.content, t.getBody());
  5613. });
  5614. }
  5615. if (s.handle_event_callback) {
  5616. t.onEvent.add(function(ed, e, o) {
  5617. if (t.execCallback('handle_event_callback', e, ed, o) === false)
  5618. Event.cancel(e);
  5619. });
  5620. }
  5621. t.onSetContent.add(function() {
  5622. // Safari needs some time, it will crash the browser when a link is created otherwise
  5623. // I think this crash issue is resolved in the latest 3.0.4
  5624. //window.setTimeout(function() {
  5625. t.addVisual(t.getBody());
  5626. //}, 1);
  5627. });
  5628. // Remove empty contents
  5629. if (s.padd_empty_editor) {
  5630. t.onPostProcess.add(function(ed, o) {
  5631. o.content = o.content.replace(/^(<p>(&nbsp;|&#160;|\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/, '');
  5632. });
  5633. }
  5634. if (isGecko && !s.readonly) {
  5635. try {
  5636. // Design mode must be set here once again to fix a bug where
  5637. // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
  5638. d.designMode = 'Off';
  5639. d.designMode = 'On';
  5640. } catch (ex) {
  5641. // Will fail on Gecko if the editor is placed in an hidden container element
  5642. // The design mode will be set ones the editor is focused
  5643. }
  5644. }
  5645. // A small timeout was needed since firefox will remove. Bug: #1838304
  5646. setTimeout(function () {
  5647. if (t.removed)
  5648. return;
  5649. t.load({initial : true, format : (s.cleanup_on_startup ? 'html' : 'raw')});
  5650. t.startContent = t.getContent({format : 'raw'});
  5651. t.undoManager.add({initial : true});
  5652. t.initialized = true;
  5653. t.onInit.dispatch(t);
  5654. t.execCallback('setupcontent_callback', t.id, t.getBody(), t.getDoc());
  5655. t.execCallback('init_instance_callback', t);
  5656. t.focus(true);
  5657. t.nodeChanged({initial : 1});
  5658. // Load specified content CSS last
  5659. if (s.content_css) {
  5660. tinymce.each(explode(s.content_css), function(u) {
  5661. t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));
  5662. });
  5663. }
  5664. // Handle auto focus
  5665. if (s.auto_focus) {
  5666. setTimeout(function () {
  5667. var ed = EditorManager.get(s.auto_focus);
  5668. ed.selection.select(ed.getBody(), 1);
  5669. ed.selection.collapse(1);
  5670. ed.getWin().focus();
  5671. }, 100);
  5672. }
  5673. }, 1);
  5674. e = null;
  5675. },
  5676. focus : function(sf) {
  5677. var oed, t = this, ce = t.settings.content_editable;
  5678. if (!sf) {
  5679. // Is not content editable or the selection is outside the area in IE
  5680. // the IE statement is needed to avoid bluring if element selections inside layers since
  5681. // the layer is like it's own document in IE
  5682. if (!ce && (!isIE || t.selection.getNode().ownerDocument != t.getDoc()))
  5683. t.getWin().focus();
  5684. }
  5685. if (EditorManager.activeEditor != t) {
  5686. if ((oed = EditorManager.activeEditor) != null)
  5687. oed.onDeactivate.dispatch(oed, t);
  5688. t.onActivate.dispatch(t, oed);
  5689. }
  5690. EditorManager._setActive(t);
  5691. },
  5692. execCallback : function(n) {
  5693. var t = this, f = t.settings[n], s;
  5694. if (!f)
  5695. return;
  5696. // Look through lookup
  5697. if (t.callbackLookup && (s = t.callbackLookup[n])) {
  5698. f = s.func;
  5699. s = s.scope;
  5700. }
  5701. if (is(f, 'string')) {
  5702. s = f.replace(/\.\w+$/, '');
  5703. s = s ? tinymce.resolve(s) : 0;
  5704. f = tinymce.resolve(f);
  5705. t.callbackLookup = t.callbackLookup || {};
  5706. t.callbackLookup[n] = {func : f, scope : s};
  5707. }
  5708. return f.apply(s || t, Array.prototype.slice.call(arguments, 1));
  5709. },
  5710. translate : function(s) {
  5711. var c = this.settings.language || 'en', i18n = EditorManager.i18n;
  5712. if (!s)
  5713. return '';
  5714. return i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
  5715. return i18n[c + '.' + b] || '{#' + b + '}';
  5716. });
  5717. },
  5718. getLang : function(n, dv) {
  5719. return EditorManager.i18n[(this.settings.language || 'en') + '.' + n] || (is(dv) ? dv : '{#' + n + '}');
  5720. },
  5721. getParam : function(n, dv, ty) {
  5722. var tr = tinymce.trim, v = is(this.settings[n]) ? this.settings[n] : dv, o;
  5723. if (ty === 'hash') {
  5724. o = {};
  5725. if (is(v, 'string')) {
  5726. each(v.indexOf('=') > 0 ? v.split(/[;,](?![^=;,]*(?:[;,]|$))/) : v.split(','), function(v) {
  5727. v = v.split('=');
  5728. if (v.length > 1)
  5729. o[tr(v[0])] = tr(v[1]);
  5730. else
  5731. o[tr(v[0])] = tr(v);
  5732. });
  5733. } else
  5734. o = v;
  5735. return o;
  5736. }
  5737. return v;
  5738. },
  5739. nodeChanged : function(o) {
  5740. var t = this, s = t.selection, n = s.getNode() || t.getBody();
  5741. // Fix for bug #1896577 it seems that this can not be fired while the editor is loading
  5742. if (t.initialized) {
  5743. t.onNodeChange.dispatch(
  5744. t,
  5745. o ? o.controlManager || t.controlManager : t.controlManager,
  5746. isIE && n.ownerDocument != t.getDoc() ? t.getBody() : n, // Fix for IE initial state
  5747. s.isCollapsed(),
  5748. o
  5749. );
  5750. }
  5751. },
  5752. addButton : function(n, s) {
  5753. var t = this;
  5754. t.buttons = t.buttons || {};
  5755. t.buttons[n] = s;
  5756. },
  5757. addCommand : function(n, f, s) {
  5758. this.execCommands[n] = {func : f, scope : s || this};
  5759. },
  5760. addQueryStateHandler : function(n, f, s) {
  5761. this.queryStateCommands[n] = {func : f, scope : s || this};
  5762. },
  5763. addQueryValueHandler : function(n, f, s) {
  5764. this.queryValueCommands[n] = {func : f, scope : s || this};
  5765. },
  5766. addShortcut : function(pa, desc, cmd_func, sc) {
  5767. var t = this, c;
  5768. if (!t.settings.custom_shortcuts)
  5769. return false;
  5770. t.shortcuts = t.shortcuts || {};
  5771. if (is(cmd_func, 'string')) {
  5772. c = cmd_func;
  5773. cmd_func = function() {
  5774. t.execCommand(c, false, null);
  5775. };
  5776. }
  5777. if (is(cmd_func, 'object')) {
  5778. c = cmd_func;
  5779. cmd_func = function() {
  5780. t.execCommand(c[0], c[1], c[2]);
  5781. };
  5782. }
  5783. each(explode(pa), function(pa) {
  5784. var o = {
  5785. func : cmd_func,
  5786. scope : sc || this,
  5787. desc : desc,
  5788. alt : false,
  5789. ctrl : false,
  5790. shift : false
  5791. };
  5792. each(explode(pa, '+'), function(v) {
  5793. switch (v) {
  5794. case 'alt':
  5795. case 'ctrl':
  5796. case 'shift':
  5797. o[v] = true;
  5798. break;
  5799. default:
  5800. o.charCode = v.charCodeAt(0);
  5801. o.keyCode = v.toUpperCase().charCodeAt(0);
  5802. }
  5803. });
  5804. t.shortcuts[(o.ctrl ? 'ctrl' : '') + ',' + (o.alt ? 'alt' : '') + ',' + (o.shift ? 'shift' : '') + ',' + o.keyCode] = o;
  5805. });
  5806. return true;
  5807. },
  5808. execCommand : function(cmd, ui, val, a) {
  5809. var t = this, s = 0, o, st;
  5810. if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd) && (!a || !a.skip_focus))
  5811. t.focus();
  5812. o = {};
  5813. t.onBeforeExecCommand.dispatch(t, cmd, ui, val, o);
  5814. if (o.terminate)
  5815. return false;
  5816. // Command callback
  5817. if (t.execCallback('execcommand_callback', t.id, t.selection.getNode(), cmd, ui, val)) {
  5818. t.onExecCommand.dispatch(t, cmd, ui, val, a);
  5819. return true;
  5820. }
  5821. // Registred commands
  5822. if (o = t.execCommands[cmd]) {
  5823. st = o.func.call(o.scope, ui, val);
  5824. // Fall through on true
  5825. if (st !== true) {
  5826. t.onExecCommand.dispatch(t, cmd, ui, val, a);
  5827. return st;
  5828. }
  5829. }
  5830. // Plugin commands
  5831. each(t.plugins, function(p) {
  5832. if (p.execCommand && p.execCommand(cmd, ui, val)) {
  5833. t.onExecCommand.dispatch(t, cmd, ui, val, a);
  5834. s = 1;
  5835. return false;
  5836. }
  5837. });
  5838. if (s)
  5839. return true;
  5840. // Theme commands
  5841. if (t.theme.execCommand && t.theme.execCommand(cmd, ui, val)) {
  5842. t.onExecCommand.dispatch(t, cmd, ui, val, a);
  5843. return true;
  5844. }
  5845. // Editor commands
  5846. if (t.editorCommands.execCommand(cmd, ui, val)) {
  5847. t.onExecCommand.dispatch(t, cmd, ui, val, a);
  5848. return true;
  5849. }
  5850. // Browser commands
  5851. t.getDoc().execCommand(cmd, ui, val);
  5852. t.onExecCommand.dispatch(t, cmd, ui, val, a);
  5853. },
  5854. queryCommandState : function(c) {
  5855. var t = this, o, s;
  5856. // Is hidden then return undefined
  5857. if (t._isHidden())
  5858. return;
  5859. // Registred commands
  5860. if (o = t.queryStateCommands[c]) {
  5861. s = o.func.call(o.scope);
  5862. // Fall though on true
  5863. if (s !== true)
  5864. return s;
  5865. }
  5866. // Registred commands
  5867. o = t.editorCommands.queryCommandState(c);
  5868. if (o !== -1)
  5869. return o;
  5870. // Browser commands
  5871. try {
  5872. return this.getDoc().queryCommandState(c);
  5873. } catch (ex) {
  5874. // Fails sometimes see bug: 1896577
  5875. }
  5876. },
  5877. queryCommandValue : function(c) {
  5878. var t = this, o, s;
  5879. // Is hidden then return undefined
  5880. if (t._isHidden())
  5881. return;
  5882. // Registred commands
  5883. if (o = t.queryValueCommands[c]) {
  5884. s = o.func.call(o.scope);
  5885. // Fall though on true
  5886. if (s !== true)
  5887. return s;
  5888. }
  5889. // Registred commands
  5890. o = t.editorCommands.queryCommandValue(c);
  5891. if (is(o))
  5892. return o;
  5893. // Browser commands
  5894. try {
  5895. return this.getDoc().queryCommandValue(c);
  5896. } catch (ex) {
  5897. // Fails sometimes see bug: 1896577
  5898. }
  5899. },
  5900. show : function() {
  5901. var t = this;
  5902. DOM.show(t.getContainer());
  5903. DOM.hide(t.id);
  5904. t.load();
  5905. },
  5906. hide : function() {
  5907. var t = this, d = t.getDoc();
  5908. // Fixed bug where IE has a blinking cursor left from the editor
  5909. if (isIE && d)
  5910. d.execCommand('SelectAll');
  5911. // We must save before we hide so Safari doesn't crash
  5912. t.save();
  5913. DOM.hide(t.getContainer());
  5914. DOM.setStyle(t.id, 'display', t.orgDisplay);
  5915. },
  5916. isHidden : function() {
  5917. return !DOM.isHidden(this.id);
  5918. },
  5919. setProgressState : function(b, ti, o) {
  5920. this.onSetProgressState.dispatch(this, b, ti, o);
  5921. return b;
  5922. },
  5923. resizeToContent : function() {
  5924. var t = this;
  5925. DOM.setStyle(t.id + "_ifr", 'height', t.getBody().scrollHeight);
  5926. },
  5927. load : function(o) {
  5928. var t = this, e = t.getElement(), h;
  5929. o = o || {};
  5930. o.load = true;
  5931. h = t.setContent(is(e.value) ? e.value : e.innerHTML, o);
  5932. o.element = e;
  5933. if (!o.no_events)
  5934. t.onLoadContent.dispatch(t, o);
  5935. o.element = e = null;
  5936. return h;
  5937. },
  5938. save : function(o) {
  5939. var t = this, e = t.getElement(), h, f;
  5940. if (!t.initialized)
  5941. return;
  5942. o = o || {};
  5943. o.save = true;
  5944. // Add undo level will trigger onchange event
  5945. if (!o.no_events) {
  5946. t.undoManager.typing = 0;
  5947. t.undoManager.add();
  5948. }
  5949. o.element = e;
  5950. h = o.content = t.getContent(o);
  5951. if (!o.no_events)
  5952. t.onSaveContent.dispatch(t, o);
  5953. h = o.content;
  5954. if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
  5955. e.innerHTML = h;
  5956. // Update hidden form element
  5957. if (f = DOM.getParent(t.id, 'form')) {
  5958. each(f.elements, function(e) {
  5959. if (e.name == t.id) {
  5960. e.value = h;
  5961. return false;
  5962. }
  5963. });
  5964. }
  5965. } else
  5966. e.value = h;
  5967. o.element = e = null;
  5968. return h;
  5969. },
  5970. setContent : function(h, o) {
  5971. var t = this;
  5972. o = o || {};
  5973. o.format = o.format || 'html';
  5974. o.set = true;
  5975. o.content = h;
  5976. if (!o.no_events)
  5977. t.onBeforeSetContent.dispatch(t, o);
  5978. // Padd empty content in Gecko and Safari. Commands will otherwise fail on the content
  5979. // It will also be impossible to place the caret in the editor unless there is a BR element present
  5980. if (!tinymce.isIE && (h.length === 0 || /^\s+$/.test(h))) {
  5981. o.content = t.dom.setHTML(t.getBody(), '<br mce_bogus="1" />');
  5982. o.format = 'raw';
  5983. }
  5984. o.content = t.dom.setHTML(t.getBody(), tinymce.trim(o.content));
  5985. if (o.format != 'raw' && t.settings.cleanup) {
  5986. o.getInner = true;
  5987. o.content = t.dom.setHTML(t.getBody(), t.serializer.serialize(t.getBody(), o));
  5988. }
  5989. if (!o.no_events)
  5990. t.onSetContent.dispatch(t, o);
  5991. return o.content;
  5992. },
  5993. getContent : function(o) {
  5994. var t = this, h;
  5995. o = o || {};
  5996. o.format = o.format || 'html';
  5997. o.get = true;
  5998. if (!o.no_events)
  5999. t.onBeforeGetContent.dispatch(t, o);
  6000. if (o.format != 'raw' && t.settings.cleanup) {
  6001. o.getInner = true;
  6002. h = t.serializer.serialize(t.getBody(), o);
  6003. } else
  6004. h = t.getBody().innerHTML;
  6005. h = h.replace(/^\s*|\s*$/g, '');
  6006. o.content = h;
  6007. if (!o.no_events)
  6008. t.onGetContent.dispatch(t, o);
  6009. return o.content;
  6010. },
  6011. isDirty : function() {
  6012. var t = this;
  6013. return tinymce.trim(t.startContent) != tinymce.trim(t.getContent({format : 'raw', no_events : 1})) && !t.isNotDirty;
  6014. },
  6015. getContainer : function() {
  6016. var t = this;
  6017. if (!t.container)
  6018. t.container = DOM.get(t.editorContainer || t.id + '_parent');
  6019. return t.container;
  6020. },
  6021. getContentAreaContainer : function() {
  6022. return this.contentAreaContainer;
  6023. },
  6024. getElement : function() {
  6025. return DOM.get(this.settings.content_element || this.id);
  6026. },
  6027. getWin : function() {
  6028. var t = this, e;
  6029. if (!t.contentWindow) {
  6030. e = DOM.get(t.id + "_ifr");
  6031. if (e)
  6032. t.contentWindow = e.contentWindow;
  6033. }
  6034. return t.contentWindow;
  6035. },
  6036. getDoc : function() {
  6037. var t = this, w;
  6038. if (!t.contentDocument) {
  6039. w = t.getWin();
  6040. if (w)
  6041. t.contentDocument = w.document;
  6042. }
  6043. return t.contentDocument;
  6044. },
  6045. getBody : function() {
  6046. return this.bodyElement || this.getDoc().body;
  6047. },
  6048. convertURL : function(u, n, e) {
  6049. var t = this, s = t.settings;
  6050. // Use callback instead
  6051. if (s.urlconverter_callback)
  6052. return t.execCallback('urlconverter_callback', u, e, true, n);
  6053. // Don't convert link href since thats the CSS files that gets loaded into the editor also skip local file URLs
  6054. if (!s.convert_urls || (e && e.nodeName == 'LINK') || u.indexOf('file:') === 0)
  6055. return u;
  6056. // Convert to relative
  6057. if (s.relative_urls)
  6058. return t.documentBaseURI.toRelative(u);
  6059. // Convert to absolute
  6060. u = t.documentBaseURI.toAbsolute(u, s.remove_script_host);
  6061. return u;
  6062. },
  6063. addVisual : function(e) {
  6064. var t = this, s = t.settings;
  6065. e = e || t.getBody();
  6066. if (!is(t.hasVisual))
  6067. t.hasVisual = s.visual;
  6068. each(t.dom.select('table,a', e), function(e) {
  6069. var v;
  6070. switch (e.nodeName) {
  6071. case 'TABLE':
  6072. v = t.dom.getAttrib(e, 'border');
  6073. if (!v || v == '0') {
  6074. if (t.hasVisual)
  6075. t.dom.addClass(e, s.visual_table_class);
  6076. else
  6077. t.dom.removeClass(e, s.visual_table_class);
  6078. }
  6079. return;
  6080. case 'A':
  6081. v = t.dom.getAttrib(e, 'name');
  6082. if (v) {
  6083. if (t.hasVisual)
  6084. t.dom.addClass(e, 'mceItemAnchor');
  6085. else
  6086. t.dom.removeClass(e, 'mceItemAnchor');
  6087. }
  6088. return;
  6089. }
  6090. });
  6091. t.onVisualAid.dispatch(t, e, t.hasVisual);
  6092. },
  6093. remove : function() {
  6094. var t = this, e = t.getContainer();
  6095. t.removed = 1; // Cancels post remove event execution
  6096. t.hide();
  6097. t.execCallback('remove_instance_callback', t);
  6098. t.onRemove.dispatch(t);
  6099. // Clear all execCommand listeners this is required to avoid errors if the editor was removed inside another command
  6100. t.onExecCommand.listeners = [];
  6101. EditorManager.remove(t);
  6102. DOM.remove(e);
  6103. },
  6104. destroy : function(s) {
  6105. var t = this;
  6106. // One time is enough
  6107. if (t.destroyed)
  6108. return;
  6109. if (!s) {
  6110. tinymce.removeUnload(t.destroy);
  6111. tinyMCE.onBeforeUnload.remove(t._beforeUnload);
  6112. // Manual destroy
  6113. if (t.theme.destroy)
  6114. t.theme.destroy();
  6115. // Destroy controls, selection and dom
  6116. t.controlManager.destroy();
  6117. t.selection.destroy();
  6118. t.dom.destroy();
  6119. // Remove all events
  6120. // Don't clear the window or document if content editable
  6121. // is enabled since other instances might still be present
  6122. if (!t.settings.content_editable) {
  6123. Event.clear(t.getWin());
  6124. Event.clear(t.getDoc());
  6125. }
  6126. Event.clear(t.getBody());
  6127. Event.clear(t.formElement);
  6128. }
  6129. if (t.formElement) {
  6130. t.formElement.submit = t.formElement._mceOldSubmit;
  6131. t.formElement._mceOldSubmit = null;
  6132. }
  6133. t.contentAreaContainer = t.formElement = t.container = t.settings.content_element = t.bodyElement = t.contentDocument = t.contentWindow = null;
  6134. if (t.selection)
  6135. t.selection = t.selection.win = t.selection.dom = t.selection.dom.doc = null;
  6136. t.destroyed = 1;
  6137. },
  6138. // Internal functions
  6139. _addEvents : function() {
  6140. // 'focus', 'blur', 'dblclick', 'beforedeactivate', submit, reset
  6141. var t = this, i, s = t.settings, lo = {
  6142. mouseup : 'onMouseUp',
  6143. mousedown : 'onMouseDown',
  6144. click : 'onClick',
  6145. keyup : 'onKeyUp',
  6146. keydown : 'onKeyDown',
  6147. keypress : 'onKeyPress',
  6148. submit : 'onSubmit',
  6149. reset : 'onReset',
  6150. contextmenu : 'onContextMenu',
  6151. dblclick : 'onDblClick',
  6152. paste : 'onPaste' // Doesn't work in all browsers yet
  6153. };
  6154. function eventHandler(e, o) {
  6155. var ty = e.type;
  6156. // Don't fire events when it's removed
  6157. if (t.removed)
  6158. return;
  6159. // Generic event handler
  6160. if (t.onEvent.dispatch(t, e, o) !== false) {
  6161. // Specific event handler
  6162. t[lo[e.fakeType || e.type]].dispatch(t, e, o);
  6163. }
  6164. };
  6165. // Add DOM events
  6166. each(lo, function(v, k) {
  6167. switch (k) {
  6168. case 'contextmenu':
  6169. if (tinymce.isOpera) {
  6170. // Fake contextmenu on Opera
  6171. Event.add(t.getBody(), 'mousedown', function(e) {
  6172. if (e.ctrlKey) {
  6173. e.fakeType = 'contextmenu';
  6174. eventHandler(e);
  6175. }
  6176. });
  6177. } else
  6178. Event.add(t.getBody(), k, eventHandler);
  6179. break;
  6180. case 'paste':
  6181. Event.add(t.getBody(), k, function(e) {
  6182. var tx, h, el, r;
  6183. // Get plain text data
  6184. if (e.clipboardData)
  6185. tx = e.clipboardData.getData('text/plain');
  6186. else if (tinymce.isIE)
  6187. tx = t.getWin().clipboardData.getData('Text');
  6188. // Get HTML data
  6189. /*if (tinymce.isIE) {
  6190. el = DOM.add(DOM.doc.body, 'div', {style : 'visibility:hidden;overflow:hidden;position:absolute;width:1px;height:1px'});
  6191. r = DOM.doc.body.createTextRange();
  6192. r.moveToElementText(el);
  6193. r.execCommand('Paste');
  6194. h = el.innerHTML;
  6195. DOM.remove(el);
  6196. }*/
  6197. eventHandler(e, {text : tx, html : h});
  6198. });
  6199. break;
  6200. case 'submit':
  6201. case 'reset':
  6202. Event.add(t.getElement().form || DOM.getParent(t.id, 'form'), k, eventHandler);
  6203. break;
  6204. default:
  6205. Event.add(s.content_editable ? t.getBody() : t.getDoc(), k, eventHandler);
  6206. }
  6207. });
  6208. Event.add(s.content_editable ? t.getBody() : (isGecko ? t.getDoc() : t.getWin()), 'focus', function(e) {
  6209. t.focus(true);
  6210. });
  6211. // Fixes bug where a specified document_base_uri could result in broken images
  6212. // This will also fix drag drop of images in Gecko
  6213. if (tinymce.isGecko) {
  6214. // Convert all images to absolute URLs
  6215. /* t.onSetContent.add(function(ed, o) {
  6216. each(ed.dom.select('img'), function(e) {
  6217. var v;
  6218. if (v = e.getAttribute('mce_src'))
  6219. e.src = t.documentBaseURI.toAbsolute(v);
  6220. })
  6221. });*/
  6222. Event.add(t.getDoc(), 'DOMNodeInserted', function(e) {
  6223. var v;
  6224. e = e.target;
  6225. if (e.nodeType === 1 && e.nodeName === 'IMG' && (v = e.getAttribute('mce_src')))
  6226. e.src = t.documentBaseURI.toAbsolute(v);
  6227. });
  6228. }
  6229. // Set various midas options in Gecko
  6230. if (isGecko) {
  6231. function setOpts() {
  6232. var t = this, d = t.getDoc(), s = t.settings;
  6233. if (isGecko && !s.readonly) {
  6234. if (t._isHidden()) {
  6235. try {
  6236. if (!s.content_editable)
  6237. d.designMode = 'On';
  6238. } catch (ex) {
  6239. // Fails if it's hidden
  6240. }
  6241. }
  6242. try {
  6243. // Try new Gecko method
  6244. d.execCommand("styleWithCSS", 0, false);
  6245. } catch (ex) {
  6246. // Use old method
  6247. if (!t._isHidden())
  6248. try {d.execCommand("useCSS", 0, true);} catch (ex) {}
  6249. }
  6250. if (!s.table_inline_editing)
  6251. try {d.execCommand('enableInlineTableEditing', false, false);} catch (ex) {}
  6252. if (!s.object_resizing)
  6253. try {d.execCommand('enableObjectResizing', false, false);} catch (ex) {}
  6254. }
  6255. };
  6256. t.onBeforeExecCommand.add(setOpts);
  6257. t.onMouseDown.add(setOpts);
  6258. }
  6259. // Add node change handlers
  6260. t.onMouseUp.add(t.nodeChanged);
  6261. t.onClick.add(t.nodeChanged);
  6262. t.onKeyUp.add(function(ed, e) {
  6263. var c = e.keyCode;
  6264. if ((c >= 33 && c <= 36) || (c >= 37 && c <= 40) || c == 13 || c == 45 || c == 46 || c == 8 || (tinymce.isMac && (c == 91 || c == 93)) || e.ctrlKey)
  6265. t.nodeChanged();
  6266. });
  6267. // Add reset handler
  6268. t.onReset.add(function() {
  6269. t.setContent(t.startContent, {format : 'raw'});
  6270. });
  6271. if (t.getParam('tab_focus')) {
  6272. function tabCancel(ed, e) {
  6273. if (e.keyCode === 9)
  6274. return Event.cancel(e);
  6275. };
  6276. function tabHandler(ed, e) {
  6277. var x, i, f, el, v;
  6278. function find(d) {
  6279. f = DOM.getParent(ed.id, 'form');
  6280. el = f.elements;
  6281. if (f) {
  6282. each(el, function(e, i) {
  6283. if (e.id == ed.id) {
  6284. x = i;
  6285. return false;
  6286. }
  6287. });
  6288. if (d > 0) {
  6289. for (i = x + 1; i < el.length; i++) {
  6290. if (el[i].type != 'hidden')
  6291. return el[i];
  6292. }
  6293. } else {
  6294. for (i = x - 1; i >= 0; i--) {
  6295. if (el[i].type != 'hidden')
  6296. return el[i];
  6297. }
  6298. }
  6299. }
  6300. return null;
  6301. };
  6302. if (e.keyCode === 9) {
  6303. v = explode(ed.getParam('tab_focus'));
  6304. if (v.length == 1) {
  6305. v[1] = v[0];
  6306. v[0] = ':prev';
  6307. }
  6308. // Find element to focus
  6309. if (e.shiftKey) {
  6310. if (v[0] == ':prev')
  6311. el = find(-1);
  6312. else
  6313. el = DOM.get(v[0]);
  6314. } else {
  6315. if (v[1] == ':next')
  6316. el = find(1);
  6317. else
  6318. el = DOM.get(v[1]);
  6319. }
  6320. if (el) {
  6321. if (ed = EditorManager.get(el.id || el.name))
  6322. ed.focus();
  6323. else
  6324. window.setTimeout(function() {window.focus();el.focus();}, 10);
  6325. return Event.cancel(e);
  6326. }
  6327. }
  6328. };
  6329. t.onKeyUp.add(tabCancel);
  6330. if (isGecko) {
  6331. t.onKeyPress.add(tabHandler);
  6332. t.onKeyDown.add(tabCancel);
  6333. } else
  6334. t.onKeyDown.add(tabHandler);
  6335. }
  6336. // Add shortcuts
  6337. if (s.custom_shortcuts) {
  6338. if (s.custom_undo_redo_keyboard_shortcuts) {
  6339. t.addShortcut('ctrl+z', t.getLang('undo_desc'), 'Undo');
  6340. t.addShortcut('ctrl+y', t.getLang('redo_desc'), 'Redo');
  6341. }
  6342. // Add default shortcuts for gecko
  6343. if (isGecko) {
  6344. t.addShortcut('ctrl+b', t.getLang('bold_desc'), 'Bold');
  6345. t.addShortcut('ctrl+i', t.getLang('italic_desc'), 'Italic');
  6346. t.addShortcut('ctrl+u', t.getLang('underline_desc'), 'Underline');
  6347. }
  6348. // BlockFormat shortcuts keys
  6349. for (i=1; i<=6; i++)
  6350. t.addShortcut('ctrl+' + i, '', ['FormatBlock', false, '<h' + i + '>']);
  6351. t.addShortcut('ctrl+7', '', ['FormatBlock', false, '<p>']);
  6352. t.addShortcut('ctrl+8', '', ['FormatBlock', false, '<div>']);
  6353. t.addShortcut('ctrl+9', '', ['FormatBlock', false, '<address>']);
  6354. function find(e) {
  6355. var v = null;
  6356. if (!e.altKey && !e.ctrlKey && !e.metaKey)
  6357. return v;
  6358. each(t.shortcuts, function(o) {
  6359. if (o.ctrl != e.ctrlKey && (!tinymce.isMac || o.ctrl == e.metaKey))
  6360. return;
  6361. if (o.alt != e.altKey)
  6362. return;
  6363. if (o.shift != e.shiftKey)
  6364. return;
  6365. if (e.keyCode == o.keyCode || (e.charCode && e.charCode == o.charCode)) {
  6366. v = o;
  6367. return false;
  6368. }
  6369. });
  6370. return v;
  6371. };
  6372. t.onKeyUp.add(function(ed, e) {
  6373. var o = find(e);
  6374. if (o)
  6375. return Event.cancel(e);
  6376. });
  6377. t.onKeyPress.add(function(ed, e) {
  6378. var o = find(e);
  6379. if (o)
  6380. return Event.cancel(e);
  6381. });
  6382. t.onKeyDown.add(function(ed, e) {
  6383. var o = find(e);
  6384. if (o) {
  6385. o.func.call(o.scope);
  6386. return Event.cancel(e);
  6387. }
  6388. });
  6389. }
  6390. if (tinymce.isIE) {
  6391. // Fix so resize will only update the width and height attributes not the styles of an image
  6392. // It will also block mceItemNoResize items
  6393. Event.add(t.getDoc(), 'controlselect', function(e) {
  6394. var re = t.resizeInfo, cb;
  6395. e = e.target;
  6396. // Don't do this action for non image elements
  6397. if (e.nodeName !== 'IMG')
  6398. return;
  6399. if (re)
  6400. Event.remove(re.node, re.ev, re.cb);
  6401. if (!t.dom.hasClass(e, 'mceItemNoResize')) {
  6402. ev = 'resizeend';
  6403. cb = Event.add(e, ev, function(e) {
  6404. var v;
  6405. e = e.target;
  6406. if (v = t.dom.getStyle(e, 'width')) {
  6407. t.dom.setAttrib(e, 'width', v.replace(/[^0-9%]+/g, ''));
  6408. t.dom.setStyle(e, 'width', '');
  6409. }
  6410. if (v = t.dom.getStyle(e, 'height')) {
  6411. t.dom.setAttrib(e, 'height', v.replace(/[^0-9%]+/g, ''));
  6412. t.dom.setStyle(e, 'height', '');
  6413. }
  6414. });
  6415. } else {
  6416. ev = 'resizestart';
  6417. cb = Event.add(e, 'resizestart', Event.cancel, Event);
  6418. }
  6419. re = t.resizeInfo = {
  6420. node : e,
  6421. ev : ev,
  6422. cb : cb
  6423. };
  6424. });
  6425. t.onKeyDown.add(function(ed, e) {
  6426. switch (e.keyCode) {
  6427. case 8:
  6428. // Fix IE control + backspace browser bug
  6429. if (t.selection.getRng().item) {
  6430. t.selection.getRng().item(0).removeNode();
  6431. return Event.cancel(e);
  6432. }
  6433. }
  6434. });
  6435. }
  6436. if (tinymce.isOpera) {
  6437. t.onClick.add(function(ed, e) {
  6438. Event.prevent(e);
  6439. });
  6440. }
  6441. // Add custom undo/redo handlers
  6442. if (s.custom_undo_redo) {
  6443. function addUndo() {
  6444. t.undoManager.typing = 0;
  6445. t.undoManager.add();
  6446. };
  6447. // Add undo level on editor blur
  6448. if (tinymce.isIE) {
  6449. Event.add(t.getWin(), 'blur', function(e) {
  6450. var n;
  6451. // Check added for fullscreen bug
  6452. if (t.selection) {
  6453. n = t.selection.getNode();
  6454. // Add undo level is selection was lost to another document
  6455. if (!t.removed && n.ownerDocument && n.ownerDocument != t.getDoc())
  6456. addUndo();
  6457. }
  6458. });
  6459. } else {
  6460. Event.add(t.getDoc(), 'blur', function() {
  6461. if (t.selection && !t.removed)
  6462. addUndo();
  6463. });
  6464. }
  6465. t.onMouseDown.add(addUndo);
  6466. t.onKeyUp.add(function(ed, e) {
  6467. if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45 || e.ctrlKey) {
  6468. t.undoManager.typing = 0;
  6469. t.undoManager.add();
  6470. }
  6471. });
  6472. t.onKeyDown.add(function(ed, e) {
  6473. // Is caracter positon keys
  6474. if ((e.keyCode >= 33 && e.keyCode <= 36) || (e.keyCode >= 37 && e.keyCode <= 40) || e.keyCode == 13 || e.keyCode == 45) {
  6475. if (t.undoManager.typing) {
  6476. t.undoManager.add();
  6477. t.undoManager.typing = 0;
  6478. }
  6479. return;
  6480. }
  6481. if (!t.undoManager.typing) {
  6482. t.undoManager.add();
  6483. t.undoManager.typing = 1;
  6484. }
  6485. });
  6486. }
  6487. },
  6488. _convertInlineElements : function() {
  6489. var t = this, s = t.settings, dom = t.dom, v, e, na, st, sp;
  6490. function convert(ed, o) {
  6491. if (!s.inline_styles)
  6492. return;
  6493. if (o.get) {
  6494. each(t.dom.select('table,u,strike', o.node), function(n) {
  6495. switch (n.nodeName) {
  6496. case 'TABLE':
  6497. if (v = dom.getAttrib(n, 'height')) {
  6498. dom.setStyle(n, 'height', v);
  6499. dom.setAttrib(n, 'height', '');
  6500. }
  6501. break;
  6502. case 'U':
  6503. case 'STRIKE':
  6504. //sp = dom.create('span', {style : dom.getAttrib(n, 'style')});
  6505. n.style.textDecoration = n.nodeName == 'U' ? 'underline' : 'line-through';
  6506. dom.setAttrib(n, 'mce_style', '');
  6507. dom.setAttrib(n, 'mce_name', 'span');
  6508. break;
  6509. }
  6510. });
  6511. } else if (o.set) {
  6512. each(t.dom.select('table,span', o.node).reverse(), function(n) {
  6513. if (n.nodeName == 'TABLE') {
  6514. if (v = dom.getStyle(n, 'height'))
  6515. dom.setAttrib(n, 'height', v.replace(/[^0-9%]+/g, ''));
  6516. } else {
  6517. // Convert spans to elements
  6518. if (n.style.textDecoration == 'underline')
  6519. na = 'u';
  6520. else if (n.style.textDecoration == 'line-through')
  6521. na = 'strike';
  6522. else
  6523. na = '';
  6524. if (na) {
  6525. n.style.textDecoration = '';
  6526. dom.setAttrib(n, 'mce_style', '');
  6527. e = dom.create(na, {
  6528. style : dom.getAttrib(n, 'style')
  6529. });
  6530. dom.replace(e, n, 1);
  6531. }
  6532. }
  6533. });
  6534. }
  6535. };
  6536. t.onPreProcess.add(convert);
  6537. if (!s.cleanup_on_startup) {
  6538. t.onSetContent.add(function(ed, o) {
  6539. if (o.initial)
  6540. convert(t, {node : t.getBody(), set : 1});
  6541. });
  6542. }
  6543. },
  6544. _convertFonts : function() {
  6545. var t = this, s = t.settings, dom = t.dom, fz, fzn, sl, cl;
  6546. // No need
  6547. if (!s.inline_styles)
  6548. return;
  6549. // Font pt values and font size names
  6550. fz = [8, 10, 12, 14, 18, 24, 36];
  6551. fzn = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large'];
  6552. if (sl = s.font_size_style_values)
  6553. sl = explode(sl);
  6554. if (cl = s.font_size_classes)
  6555. cl = explode(cl);
  6556. /*
  6557. function convertToFonts(no) {
  6558. var n, f, nl, x, i, v, st;
  6559. // Convert spans to fonts on non WebKit browsers
  6560. if (tinymce.isWebKit || !s.inline_styles)
  6561. return;
  6562. nl = t.dom.select('span', no);
  6563. for (x = nl.length - 1; x >= 0; x--) {
  6564. n = nl[x];
  6565. f = dom.create('font', {
  6566. color : dom.toHex(dom.getStyle(n, 'color')),
  6567. face : dom.getStyle(n, 'fontFamily'),
  6568. style : dom.getAttrib(n, 'style'),
  6569. 'class' : dom.getAttrib(n, 'class')
  6570. });
  6571. // Clear color and font family
  6572. st = f.style;
  6573. if (st.color || st.fontFamily) {
  6574. st.color = st.fontFamily = '';
  6575. dom.setAttrib(f, 'mce_style', ''); // Remove cached style data
  6576. }
  6577. if (sl) {
  6578. i = inArray(sl, dom.getStyle(n, 'fontSize'));
  6579. if (i != -1) {
  6580. dom.setAttrib(f, 'size', '' + (i + 1 || 1));
  6581. //f.style.fontSize = '';
  6582. }
  6583. } else if (cl) {
  6584. i = inArray(cl, dom.getAttrib(n, 'class'));
  6585. v = dom.getStyle(n, 'fontSize');
  6586. if (i == -1 && v.indexOf('pt') > 0)
  6587. i = inArray(fz, parseInt(v));
  6588. if (i == -1)
  6589. i = inArray(fzn, v);
  6590. if (i != -1) {
  6591. dom.setAttrib(f, 'size', '' + (i + 1 || 1));
  6592. f.style.fontSize = '';
  6593. }
  6594. }
  6595. if (f.color || f.face || f.size) {
  6596. f.style.fontFamily = '';
  6597. dom.setAttrib(f, 'mce_style', '');
  6598. dom.replace(f, n, 1);
  6599. }
  6600. f = n = null;
  6601. }
  6602. };
  6603. // Run on setup
  6604. t.onSetContent.add(function(ed, o) {
  6605. convertToFonts(ed.getBody());
  6606. });
  6607. */
  6608. // Run on cleanup
  6609. t.onPreProcess.add(function(ed, o) {
  6610. var n, sp, nl, x;
  6611. // Keep unit tests happy
  6612. if (!s.inline_styles)
  6613. return;
  6614. if (o.get) {
  6615. nl = t.dom.select('font', o.node);
  6616. for (x = nl.length - 1; x >= 0; x--) {
  6617. n = nl[x];
  6618. sp = dom.create('span', {
  6619. style : dom.getAttrib(n, 'style'),
  6620. 'class' : dom.getAttrib(n, 'class')
  6621. });
  6622. dom.setStyles(sp, {
  6623. fontFamily : dom.getAttrib(n, 'face'),
  6624. color : dom.getAttrib(n, 'color'),
  6625. backgroundColor : n.style.backgroundColor
  6626. });
  6627. if (n.size) {
  6628. if (sl)
  6629. dom.setStyle(sp, 'fontSize', sl[parseInt(n.size) - 1]);
  6630. else
  6631. dom.setAttrib(sp, 'class', cl[parseInt(n.size) - 1]);
  6632. }
  6633. dom.setAttrib(sp, 'mce_style', '');
  6634. dom.replace(sp, n, 1);
  6635. }
  6636. }
  6637. });
  6638. },
  6639. _isHidden : function() {
  6640. var s;
  6641. if (!isGecko)
  6642. return 0;
  6643. // Weird, wheres that cursor selection?
  6644. s = this.selection.getSel();
  6645. return (!s || !s.rangeCount || s.rangeCount == 0);
  6646. },
  6647. // Fix for bug #1867292
  6648. _fixNesting : function(s) {
  6649. var d = [], i;
  6650. s = s.replace(/<(\/)?([^\s>]+)[^>]*?>/g, function(a, b, c) {
  6651. var e;
  6652. // Handle end element
  6653. if (b === '/') {
  6654. if (!d.length)
  6655. return '';
  6656. if (c !== d[d.length - 1].tag) {
  6657. for (i=d.length - 1; i>=0; i--) {
  6658. if (d[i].tag === c) {
  6659. d[i].close = 1;
  6660. break;
  6661. }
  6662. }
  6663. return '';
  6664. } else {
  6665. d.pop();
  6666. if (d.length && d[d.length - 1].close) {
  6667. a = a + '</' + d[d.length - 1].tag + '>';
  6668. d.pop();
  6669. }
  6670. }
  6671. } else {
  6672. // Ignore these
  6673. if (/^(br|hr|input|meta|img|link|param)$/i.test(c))
  6674. return a;
  6675. // Ignore closed ones
  6676. if (/\/>$/.test(a))
  6677. return a;
  6678. d.push({tag : c}); // Push start element
  6679. }
  6680. return a;
  6681. });
  6682. // End all open tags
  6683. for (i=d.length - 1; i>=0; i--)
  6684. s += '</' + d[i].tag + '>';
  6685. return s;
  6686. }
  6687. });
  6688. })();
  6689. /* file:jscripts/tiny_mce/classes/EditorCommands.js */
  6690. (function() {
  6691. var each = tinymce.each, isIE = tinymce.isIE, isGecko = tinymce.isGecko, isOpera = tinymce.isOpera, isWebKit = tinymce.isWebKit;
  6692. function isBlock(n) {
  6693. return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n.nodeName);
  6694. };
  6695. tinymce.create('tinymce.EditorCommands', {
  6696. EditorCommands : function(ed) {
  6697. this.editor = ed;
  6698. },
  6699. execCommand : function(cmd, ui, val) {
  6700. var t = this, ed = t.editor, f;
  6701. switch (cmd) {
  6702. case 'Cut':
  6703. case 'Copy':
  6704. case 'Paste':
  6705. try {
  6706. ed.getDoc().execCommand(cmd, ui, val);
  6707. } catch (ex) {
  6708. if (isGecko) {
  6709. ed.windowManager.confirm(ed.getLang('clipboard_msg'), function(s) {
  6710. if (s)
  6711. window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
  6712. });
  6713. } else
  6714. ed.windowManager.alert(ed.getLang('clipboard_no_support'));
  6715. }
  6716. return true;
  6717. // Ignore these
  6718. case 'mceResetDesignMode':
  6719. case 'mceBeginUndoLevel':
  6720. return true;
  6721. // Ignore these
  6722. case 'unlink':
  6723. t.UnLink();
  6724. return true;
  6725. // Bundle these together
  6726. case 'JustifyLeft':
  6727. case 'JustifyCenter':
  6728. case 'JustifyRight':
  6729. case 'JustifyFull':
  6730. t.mceJustify(cmd, cmd.substring(7).toLowerCase());
  6731. return true;
  6732. case 'mceEndUndoLevel':
  6733. case 'mceAddUndoLevel':
  6734. ed.undoManager.add();
  6735. return true;
  6736. default:
  6737. f = this[cmd];
  6738. if (f) {
  6739. f.call(this, ui, val);
  6740. return true;
  6741. }
  6742. }
  6743. return false;
  6744. },
  6745. Indent : function() {
  6746. var ed = this.editor, d = ed.dom, s = ed.selection, e, iv, iu;
  6747. // Setup indent level
  6748. iv = ed.settings.indentation;
  6749. iu = /[a-z%]+$/i.exec(iv);
  6750. iv = parseInt(iv);
  6751. if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
  6752. each(this._getSelectedBlocks(), function(e) {
  6753. d.setStyle(e, 'paddingLeft', (parseInt(e.style.paddingLeft || 0) + iv) + iu);
  6754. });
  6755. return;
  6756. }
  6757. ed.getDoc().execCommand('Indent', false, null);
  6758. if (isIE) {
  6759. d.getParent(s.getNode(), function(n) {
  6760. if (n.nodeName == 'BLOCKQUOTE') {
  6761. n.dir = n.style.cssText = '';
  6762. }
  6763. });
  6764. }
  6765. },
  6766. Outdent : function() {
  6767. var ed = this.editor, d = ed.dom, s = ed.selection, e, v, iv, iu;
  6768. // Setup indent level
  6769. iv = ed.settings.indentation;
  6770. iu = /[a-z%]+$/i.exec(iv);
  6771. iv = parseInt(iv);
  6772. if (ed.settings.inline_styles && (!this.queryStateInsertUnorderedList() && !this.queryStateInsertOrderedList())) {
  6773. each(this._getSelectedBlocks(), function(e) {
  6774. v = Math.max(0, parseInt(e.style.paddingLeft || 0) - iv);
  6775. d.setStyle(e, 'paddingLeft', v ? v + iu : '');
  6776. });
  6777. return;
  6778. }
  6779. ed.getDoc().execCommand('Outdent', false, null);
  6780. },
  6781. mceSetAttribute : function(u, v) {
  6782. var ed = this.editor, d = ed.dom, e;
  6783. if (e = d.getParent(ed.selection.getNode(), d.isBlock))
  6784. d.setAttrib(e, v.name, v.value);
  6785. },
  6786. mceSetContent : function(u, v) {
  6787. this.editor.setContent(v);
  6788. },
  6789. mceToggleVisualAid : function() {
  6790. var ed = this.editor;
  6791. ed.hasVisual = !ed.hasVisual;
  6792. ed.addVisual();
  6793. },
  6794. mceReplaceContent : function(u, v) {
  6795. var s = this.editor.selection;
  6796. s.setContent(v.replace(/\{\$selection\}/g, s.getContent({format : 'text'})));
  6797. },
  6798. mceInsertLink : function(u, v) {
  6799. var ed = this.editor, s = ed.selection, e = ed.dom.getParent(s.getNode(), 'A');
  6800. if (tinymce.is(v, 'string'))
  6801. v = {href : v};
  6802. function set(e) {
  6803. each(v, function(v, k) {
  6804. ed.dom.setAttrib(e, k, v);
  6805. });
  6806. };
  6807. if (!e) {
  6808. ed.execCommand('CreateLink', false, 'javascript:mctmp(0);');
  6809. each(ed.dom.select('a'), function(e) {
  6810. if (e.href == 'javascript:mctmp(0);')
  6811. set(e);
  6812. });
  6813. } else {
  6814. if (v.href)
  6815. set(e);
  6816. else
  6817. ed.dom.remove(e, 1);
  6818. }
  6819. },
  6820. UnLink : function() {
  6821. var ed = this.editor, s = ed.selection;
  6822. if (s.isCollapsed())
  6823. s.select(s.getNode());
  6824. ed.getDoc().execCommand('unlink', false, null);
  6825. s.collapse(0);
  6826. },
  6827. FontName : function(u, v) {
  6828. var t = this, ed = t.editor, s = ed.selection, e;
  6829. if (!v) {
  6830. if (s.isCollapsed())
  6831. s.select(s.getNode());
  6832. t.RemoveFormat();
  6833. } else {
  6834. if (ed.settings.convert_fonts_to_spans)
  6835. t._applyInlineStyle('span', {style : {fontFamily : v}});
  6836. else
  6837. ed.getDoc().execCommand('FontName', false, v);
  6838. }
  6839. },
  6840. FontSize : function(u, v) {
  6841. var ed = this.editor, s = ed.settings, fc, fs;
  6842. // Use style options instead
  6843. if (s.convert_fonts_to_spans && v >= 1 && v <= 7) {
  6844. fs = tinymce.explode(s.font_size_style_values);
  6845. fc = tinymce.explode(s.font_size_classes);
  6846. if (fc)
  6847. v = fc[v - 1] || v;
  6848. else
  6849. v = fs[v - 1] || v;
  6850. }
  6851. if (v >= 1 && v <= 7)
  6852. ed.getDoc().execCommand('FontSize', false, v);
  6853. else
  6854. this._applyInlineStyle('span', {style : {fontSize : v}});
  6855. },
  6856. queryCommandValue : function(c) {
  6857. var f = this['queryValue' + c];
  6858. if (f)
  6859. return f.call(this, c);
  6860. return false;
  6861. },
  6862. queryCommandState : function(cmd) {
  6863. var f;
  6864. switch (cmd) {
  6865. // Bundle these together
  6866. case 'JustifyLeft':
  6867. case 'JustifyCenter':
  6868. case 'JustifyRight':
  6869. case 'JustifyFull':
  6870. return this.queryStateJustify(cmd, cmd.substring(7).toLowerCase());
  6871. default:
  6872. if (f = this['queryState' + cmd])
  6873. return f.call(this, cmd);
  6874. }
  6875. return -1;
  6876. },
  6877. _queryState : function(c) {
  6878. try {
  6879. return this.editor.getDoc().queryCommandState(c);
  6880. } catch (ex) {
  6881. // Ignore exception
  6882. }
  6883. },
  6884. _queryVal : function(c) {
  6885. try {
  6886. return this.editor.getDoc().queryCommandValue(c);
  6887. } catch (ex) {
  6888. // Ignore exception
  6889. }
  6890. },
  6891. queryValueFontSize : function() {
  6892. var ed = this.editor, v = 0, p;
  6893. if (p = ed.dom.getParent(ed.selection.getNode(), 'SPAN'))
  6894. v = p.style.fontSize;
  6895. if (!v && (isOpera || isWebKit)) {
  6896. if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
  6897. v = p.size;
  6898. return v;
  6899. }
  6900. return v || this._queryVal('FontSize');
  6901. },
  6902. queryValueFontName : function() {
  6903. var ed = this.editor, v = 0, p;
  6904. if (p = ed.dom.getParent(ed.selection.getNode(), 'FONT'))
  6905. v = p.face;
  6906. if (p = ed.dom.getParent(ed.selection.getNode(), 'SPAN'))
  6907. v = p.style.fontFamily.replace(/, /g, ',').replace(/[\'\"]/g, '').toLowerCase();
  6908. if (!v)
  6909. v = this._queryVal('FontName');
  6910. return v;
  6911. },
  6912. mceJustify : function(c, v) {
  6913. var ed = this.editor, se = ed.selection, n = se.getNode(), nn = n.nodeName, bl, nb, dom = ed.dom, rm;
  6914. if (ed.settings.inline_styles && this.queryStateJustify(c, v))
  6915. rm = 1;
  6916. bl = dom.getParent(n, ed.dom.isBlock);
  6917. if (nn == 'IMG') {
  6918. if (v == 'full')
  6919. return;
  6920. if (rm) {
  6921. if (v == 'center')
  6922. dom.setStyle(bl || n.parentNode, 'textAlign', '');
  6923. dom.setStyle(n, 'float', '');
  6924. this.mceRepaint();
  6925. return;
  6926. }
  6927. if (v == 'center') {
  6928. // Do not change table elements
  6929. if (bl && /^(TD|TH)$/.test(bl.nodeName))
  6930. bl = 0;
  6931. if (!bl || bl.childNodes.length > 1) {
  6932. nb = dom.create('p');
  6933. nb.appendChild(n.cloneNode(false));
  6934. if (bl)
  6935. dom.insertAfter(nb, bl);
  6936. else
  6937. dom.insertAfter(nb, n);
  6938. dom.remove(n);
  6939. n = nb.firstChild;
  6940. bl = nb;
  6941. }
  6942. dom.setStyle(bl, 'textAlign', v);
  6943. dom.setStyle(n, 'float', '');
  6944. } else {
  6945. dom.setStyle(n, 'float', v);
  6946. dom.setStyle(bl || n.parentNode, 'textAlign', '');
  6947. }
  6948. this.mceRepaint();
  6949. return;
  6950. }
  6951. // Handle the alignment outselfs, less quirks in all browsers
  6952. if (ed.settings.inline_styles && ed.settings.forced_root_block) {
  6953. if (rm)
  6954. v = '';
  6955. each(this._getSelectedBlocks(dom.getParent(se.getStart(), dom.isBlock), dom.getParent(se.getEnd(), dom.isBlock)), function(e) {
  6956. dom.setAttrib(e, 'align', '');
  6957. dom.setStyle(e, 'textAlign', v == 'full' ? 'justify' : v);
  6958. });
  6959. return;
  6960. } else if (!rm)
  6961. ed.getDoc().execCommand(c, false, null);
  6962. if (ed.settings.inline_styles) {
  6963. if (rm) {
  6964. dom.getParent(ed.selection.getNode(), function(n) {
  6965. if (n.style && n.style.textAlign)
  6966. dom.setStyle(n, 'textAlign', '');
  6967. });
  6968. return;
  6969. }
  6970. each(dom.select('*'), function(n) {
  6971. var v = n.align;
  6972. if (v) {
  6973. if (v == 'full')
  6974. v = 'justify';
  6975. dom.setStyle(n, 'textAlign', v);
  6976. dom.setAttrib(n, 'align', '');
  6977. }
  6978. });
  6979. }
  6980. },
  6981. mceSetCSSClass : function(u, v) {
  6982. this.mceSetStyleInfo(0, {command : 'setattrib', name : 'class', value : v});
  6983. },
  6984. getSelectedElement : function() {
  6985. var t = this, ed = t.editor, dom = ed.dom, se = ed.selection, r = se.getRng(), r1, r2, sc, ec, so, eo, e, sp, ep, re;
  6986. if (se.isCollapsed() || r.item)
  6987. return se.getNode();
  6988. // Setup regexp
  6989. re = ed.settings.merge_styles_invalid_parents;
  6990. if (tinymce.is(re, 'string'))
  6991. re = new RegExp(re, 'i');
  6992. if (isIE) {
  6993. r1 = r.duplicate();
  6994. r1.collapse(true);
  6995. sc = r1.parentElement();
  6996. r2 = r.duplicate();
  6997. r2.collapse(false);
  6998. ec = r2.parentElement();
  6999. if (sc != ec) {
  7000. r1.move('character', 1);
  7001. sc = r1.parentElement();
  7002. }
  7003. if (sc == ec) {
  7004. r1 = r.duplicate();
  7005. r1.moveToElementText(sc);
  7006. if (r1.compareEndPoints('StartToStart', r) == 0 && r1.compareEndPoints('EndToEnd', r) == 0)
  7007. return re && re.test(sc.nodeName) ? null : sc;
  7008. }
  7009. } else {
  7010. function getParent(n) {
  7011. return dom.getParent(n, function(n) {return n.nodeType == 1;});
  7012. };
  7013. sc = r.startContainer;
  7014. ec = r.endContainer;
  7015. so = r.startOffset;
  7016. eo = r.endOffset;
  7017. if (!r.collapsed) {
  7018. if (sc == ec) {
  7019. if (so - eo < 2) {
  7020. if (sc.hasChildNodes()) {
  7021. sp = sc.childNodes[so];
  7022. return re && re.test(sp.nodeName) ? null : sp;
  7023. }
  7024. }
  7025. }
  7026. }
  7027. if (sc.nodeType != 3 || ec.nodeType != 3)
  7028. return null;
  7029. if (so == 0) {
  7030. sp = getParent(sc);
  7031. if (sp && sp.firstChild != sc)
  7032. sp = null;
  7033. }
  7034. if (so == sc.nodeValue.length) {
  7035. e = sc.nextSibling;
  7036. if (e && e.nodeType == 1)
  7037. sp = sc.nextSibling;
  7038. }
  7039. if (eo == 0) {
  7040. e = ec.previousSibling;
  7041. if (e && e.nodeType == 1)
  7042. ep = e;
  7043. }
  7044. if (eo == ec.nodeValue.length) {
  7045. ep = getParent(ec);
  7046. if (ep && ep.lastChild != ec)
  7047. ep = null;
  7048. }
  7049. // Same element
  7050. if (sp == ep)
  7051. return re && sp && re.test(sp.nodeName) ? null : sp;
  7052. }
  7053. return null;
  7054. },
  7055. InsertHorizontalRule : function() {
  7056. // Fix for Gecko <hr size="1" /> issue and IE bug rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
  7057. if (isGecko || isIE)
  7058. this.editor.selection.setContent('<hr />');
  7059. else
  7060. this.editor.getDoc().execCommand('InsertHorizontalRule', false, '');
  7061. },
  7062. RemoveFormat : function() {
  7063. var t = this, ed = t.editor, s = ed.selection, b;
  7064. // Safari breaks tables
  7065. if (isWebKit)
  7066. s.setContent(s.getContent({format : 'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g, ''), {format : 'raw'});
  7067. else
  7068. ed.getDoc().execCommand('RemoveFormat', false, null);
  7069. t.mceSetStyleInfo(0, {command : 'removeformat'});
  7070. ed.addVisual();
  7071. },
  7072. mceSetStyleInfo : function(u, v) {
  7073. var t = this, ed = t.editor, d = ed.getDoc(), dom = ed.dom, e, b, s = ed.selection, nn = v.wrapper || 'span', b = s.getBookmark(), re;
  7074. function set(n, e) {
  7075. if (n.nodeType == 1) {
  7076. switch (v.command) {
  7077. case 'setattrib':
  7078. return dom.setAttrib(n, v.name, v.value);
  7079. case 'setstyle':
  7080. return dom.setStyle(n, v.name, v.value);
  7081. case 'removeformat':
  7082. return dom.setAttrib(n, 'class', '');
  7083. }
  7084. }
  7085. };
  7086. // Setup regexp
  7087. re = ed.settings.merge_styles_invalid_parents;
  7088. if (tinymce.is(re, 'string'))
  7089. re = new RegExp(re, 'i');
  7090. // Set style info on selected element
  7091. if ((e = t.getSelectedElement()) && !ed.settings.force_span_wrappers)
  7092. set(e, 1);
  7093. else {
  7094. // Generate wrappers and set styles on them
  7095. d.execCommand('FontName', false, '__');
  7096. each(isWebKit ? dom.select('span') : dom.select('font'), function(n) {
  7097. var sp, e;
  7098. if (dom.getAttrib(n, 'face') == '__' || n.style.fontFamily === '__') {
  7099. sp = dom.create(nn, {mce_new : '1'});
  7100. set(sp);
  7101. each (n.childNodes, function(n) {
  7102. sp.appendChild(n.cloneNode(true));
  7103. });
  7104. dom.replace(sp, n);
  7105. }
  7106. });
  7107. }
  7108. // Remove wrappers inside new ones
  7109. each(dom.select(nn).reverse(), function(n) {
  7110. var p = n.parentNode;
  7111. // Check if it's an old span in a new wrapper
  7112. if (!dom.getAttrib(n, 'mce_new')) {
  7113. // Find new wrapper
  7114. p = dom.getParent(n, function(n) {
  7115. return n.nodeType == 1 && dom.getAttrib(n, 'mce_new');
  7116. });
  7117. if (p)
  7118. dom.remove(n, 1);
  7119. }
  7120. });
  7121. // Merge wrappers with parent wrappers
  7122. each(dom.select(nn).reverse(), function(n) {
  7123. var p = n.parentNode;
  7124. if (!p || !dom.getAttrib(n, 'mce_new'))
  7125. return;
  7126. if (ed.settings.force_span_wrappers && p.nodeName != 'SPAN')
  7127. return;
  7128. // Has parent of the same type and only child
  7129. if (p.nodeName == nn.toUpperCase() && p.childNodes.length == 1)
  7130. return dom.remove(p, 1);
  7131. // Has parent that is more suitable to have the class and only child
  7132. if (n.nodeType == 1 && (!re || !re.test(p.nodeName)) && p.childNodes.length == 1) {
  7133. set(p); // Set style info on parent instead
  7134. dom.setAttrib(n, 'class', '');
  7135. }
  7136. });
  7137. // Remove empty wrappers
  7138. each(dom.select(nn).reverse(), function(n) {
  7139. if (dom.getAttrib(n, 'mce_new') || (dom.getAttribs(n).length <= 1 && n.className === '')) {
  7140. if (!dom.getAttrib(n, 'class') && !dom.getAttrib(n, 'style'))
  7141. return dom.remove(n, 1);
  7142. dom.setAttrib(n, 'mce_new', ''); // Remove mce_new marker
  7143. }
  7144. });
  7145. s.moveToBookmark(b);
  7146. },
  7147. queryStateJustify : function(c, v) {
  7148. var ed = this.editor, n = ed.selection.getNode(), dom = ed.dom;
  7149. if (n && n.nodeName == 'IMG') {
  7150. if (dom.getStyle(n, 'float') == v)
  7151. return 1;
  7152. return n.parentNode.style.textAlign == v;
  7153. }
  7154. n = dom.getParent(ed.selection.getStart(), function(n) {
  7155. return n.nodeType == 1 && n.style.textAlign;
  7156. });
  7157. if (v == 'full')
  7158. v = 'justify';
  7159. if (ed.settings.inline_styles)
  7160. return (n && n.style.textAlign == v);
  7161. return this._queryState(c);
  7162. },
  7163. ForeColor : function(ui, v) {
  7164. var ed = this.editor;
  7165. if (ed.settings.convert_fonts_to_spans) {
  7166. this._applyInlineStyle('span', {style : {color : v}});
  7167. return;
  7168. } else
  7169. ed.getDoc().execCommand('ForeColor', false, v);
  7170. },
  7171. HiliteColor : function(ui, val) {
  7172. var t = this, ed = t.editor, d = ed.getDoc();
  7173. if (ed.settings.convert_fonts_to_spans) {
  7174. this._applyInlineStyle('span', {style : {backgroundColor : val}});
  7175. return;
  7176. }
  7177. function set(s) {
  7178. if (!isGecko)
  7179. return;
  7180. try {
  7181. // Try new Gecko method
  7182. d.execCommand("styleWithCSS", 0, s);
  7183. } catch (ex) {
  7184. // Use old
  7185. d.execCommand("useCSS", 0, !s);
  7186. }
  7187. };
  7188. if (isGecko || isOpera) {
  7189. set(true);
  7190. d.execCommand('hilitecolor', false, val);
  7191. set(false);
  7192. } else
  7193. d.execCommand('BackColor', false, val);
  7194. },
  7195. Undo : function() {
  7196. var ed = this.editor;
  7197. if (ed.settings.custom_undo_redo) {
  7198. ed.undoManager.undo();
  7199. ed.nodeChanged();
  7200. } else
  7201. ed.getDoc().execCommand('Undo', false, null);
  7202. },
  7203. Redo : function() {
  7204. var ed = this.editor;
  7205. if (ed.settings.custom_undo_redo) {
  7206. ed.undoManager.redo();
  7207. ed.nodeChanged();
  7208. } else
  7209. ed.getDoc().execCommand('Redo', false, null);
  7210. },
  7211. FormatBlock : function(ui, val) {
  7212. var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, bl, nb, b;
  7213. function isBlock(n) {
  7214. return /^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);
  7215. };
  7216. bl = dom.getParent(s.getNode(), function(n) {
  7217. return isBlock(n);
  7218. });
  7219. // IE has an issue where it removes the parent div if you change format on the paragrah in <div><p>Content</p></div>
  7220. // FF and Opera doesn't change parent DIV elements if you switch format
  7221. if (bl) {
  7222. if ((isIE && isBlock(bl.parentNode)) || bl.nodeName == 'DIV') {
  7223. // Rename block element
  7224. nb = ed.dom.create(val);
  7225. each(dom.getAttribs(bl), function(v) {
  7226. dom.setAttrib(nb, v.nodeName, dom.getAttrib(bl, v.nodeName));
  7227. });
  7228. b = s.getBookmark();
  7229. dom.replace(nb, bl, 1);
  7230. s.moveToBookmark(b);
  7231. ed.nodeChanged();
  7232. return;
  7233. }
  7234. }
  7235. val = ed.settings.forced_root_block ? (val || '<p>') : val;
  7236. if (val.indexOf('<') == -1)
  7237. val = '<' + val + '>';
  7238. if (tinymce.isGecko)
  7239. val = val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi, '$1');
  7240. ed.getDoc().execCommand('FormatBlock', false, val);
  7241. },
  7242. mceCleanup : function() {
  7243. var ed = this.editor, s = ed.selection, b = s.getBookmark();
  7244. ed.setContent(ed.getContent());
  7245. s.moveToBookmark(b);
  7246. },
  7247. mceRemoveNode : function(ui, val) {
  7248. var ed = this.editor, s = ed.selection, b, n = val || s.getNode();
  7249. // Make sure that the body node isn't removed
  7250. if (n == ed.getBody())
  7251. return;
  7252. b = s.getBookmark();
  7253. ed.dom.remove(n, 1);
  7254. s.moveToBookmark(b);
  7255. ed.nodeChanged();
  7256. },
  7257. mceSelectNodeDepth : function(ui, val) {
  7258. var ed = this.editor, s = ed.selection, c = 0;
  7259. ed.dom.getParent(s.getNode(), function(n) {
  7260. if (n.nodeType == 1 && c++ == val) {
  7261. s.select(n);
  7262. ed.nodeChanged();
  7263. return false;
  7264. }
  7265. }, ed.getBody());
  7266. },
  7267. mceSelectNode : function(u, v) {
  7268. this.editor.selection.select(v);
  7269. },
  7270. mceInsertContent : function(ui, val) {
  7271. this.editor.selection.setContent(val);
  7272. },
  7273. mceInsertRawHTML : function(ui, val) {
  7274. var ed = this.editor;
  7275. ed.selection.setContent('tiny_mce_marker');
  7276. ed.setContent(ed.getContent().replace(/tiny_mce_marker/g, val));
  7277. },
  7278. mceRepaint : function() {
  7279. var s, b, e = this.editor;
  7280. if (tinymce.isGecko) {
  7281. try {
  7282. s = e.selection;
  7283. b = s.getBookmark(true);
  7284. if (s.getSel())
  7285. s.getSel().selectAllChildren(e.getBody());
  7286. s.collapse(true);
  7287. s.moveToBookmark(b);
  7288. } catch (ex) {
  7289. // Ignore
  7290. }
  7291. }
  7292. },
  7293. queryStateUnderline : function() {
  7294. var ed = this.editor, n = ed.selection.getNode();
  7295. if (n && n.nodeName == 'A')
  7296. return false;
  7297. return this._queryState('Underline');
  7298. },
  7299. queryStateOutdent : function() {
  7300. var ed = this.editor, n;
  7301. if (ed.settings.inline_styles) {
  7302. if ((n = ed.dom.getParent(ed.selection.getStart(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
  7303. return true;
  7304. if ((n = ed.dom.getParent(ed.selection.getEnd(), ed.dom.isBlock)) && parseInt(n.style.paddingLeft) > 0)
  7305. return true;
  7306. }
  7307. return this.queryStateInsertUnorderedList() || this.queryStateInsertOrderedList() || (!ed.settings.inline_styles && !!ed.dom.getParent(ed.selection.getNode(), 'BLOCKQUOTE'));
  7308. },
  7309. queryStateInsertUnorderedList : function() {
  7310. return this.editor.dom.getParent(this.editor.selection.getNode(), 'UL');
  7311. },
  7312. queryStateInsertOrderedList : function() {
  7313. return this.editor.dom.getParent(this.editor.selection.getNode(), 'OL');
  7314. },
  7315. queryStatemceBlockQuote : function() {
  7316. return !!this.editor.dom.getParent(this.editor.selection.getStart(), function(n) {return n.nodeName === 'BLOCKQUOTE';});
  7317. },
  7318. mceBlockQuote : function() {
  7319. var t = this, ed = t.editor, s = ed.selection, dom = ed.dom, sb, eb, n, bm, bq, r, bq2, i, nl;
  7320. function getBQ(e) {
  7321. return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
  7322. };
  7323. // Get start/end block
  7324. sb = dom.getParent(s.getStart(), isBlock);
  7325. eb = dom.getParent(s.getEnd(), isBlock);
  7326. // Remove blockquote(s)
  7327. if (bq = getBQ(sb)) {
  7328. if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
  7329. bm = s.getBookmark();
  7330. // Move all elements after the end block into new bq
  7331. if (getBQ(eb)) {
  7332. bq2 = bq.cloneNode(false);
  7333. while (n = eb.nextSibling)
  7334. bq2.appendChild(n.parentNode.removeChild(n));
  7335. }
  7336. // Add new bq after
  7337. if (bq2)
  7338. dom.insertAfter(bq2, bq);
  7339. // Move all selected blocks after the current bq
  7340. nl = t._getSelectedBlocks(sb, eb);
  7341. for (i = nl.length - 1; i >= 0; i--) {
  7342. dom.insertAfter(nl[i], bq);
  7343. }
  7344. // Empty bq, then remove it
  7345. if (/^\s*$/.test(bq.innerHTML))
  7346. dom.remove(bq, 1); // Keep children so boomark restoration works correctly
  7347. // Empty bq, then remote it
  7348. if (bq2 && /^\s*$/.test(bq2.innerHTML))
  7349. dom.remove(bq2, 1); // Keep children so boomark restoration works correctly
  7350. if (!bm) {
  7351. // Move caret inside empty block element
  7352. if (!isIE) {
  7353. r = ed.getDoc().createRange();
  7354. r.setStart(sb, 0);
  7355. r.setEnd(sb, 0);
  7356. s.setRng(r);
  7357. } else {
  7358. s.select(sb);
  7359. s.collapse(0);
  7360. // IE misses the empty block some times element so we must move back the caret
  7361. if (dom.getParent(s.getStart(), isBlock) != sb) {
  7362. r = s.getRng();
  7363. r.move('character', -1);
  7364. r.select();
  7365. }
  7366. }
  7367. } else
  7368. t.editor.selection.moveToBookmark(bm);
  7369. return;
  7370. }
  7371. // Since IE can start with a totally empty document we need to add the first bq and paragraph
  7372. if (isIE && !sb && !eb) {
  7373. t.editor.getDoc().execCommand('Indent');
  7374. n = getBQ(s.getNode());
  7375. n.style.margin = n.dir = ''; // IE adds margin and dir to bq
  7376. return;
  7377. }
  7378. if (!sb || !eb)
  7379. return;
  7380. // If empty paragraph node then do not use bookmark
  7381. if (sb != eb || sb.childNodes.length > 1 || (sb.childNodes.length == 1 && sb.firstChild.nodeName != 'BR'))
  7382. bm = s.getBookmark();
  7383. // Move selected block elements into a bq
  7384. each(t._getSelectedBlocks(getBQ(s.getStart()), getBQ(s.getEnd())), function(e) {
  7385. // Found existing BQ add to this one
  7386. if (e.nodeName == 'BLOCKQUOTE' && !bq) {
  7387. bq = e;
  7388. return;
  7389. }
  7390. // No BQ found, create one
  7391. if (!bq) {
  7392. bq = dom.create('blockquote');
  7393. e.parentNode.insertBefore(bq, e);
  7394. }
  7395. // Add children from existing BQ
  7396. if (e.nodeName == 'BLOCKQUOTE' && bq) {
  7397. n = e.firstChild;
  7398. while (n) {
  7399. bq.appendChild(n.cloneNode(true));
  7400. n = n.nextSibling;
  7401. }
  7402. dom.remove(e);
  7403. return;
  7404. }
  7405. // Add non BQ element to BQ
  7406. bq.appendChild(dom.remove(e));
  7407. });
  7408. if (!bm) {
  7409. // Move caret inside empty block element
  7410. if (!isIE) {
  7411. r = ed.getDoc().createRange();
  7412. r.setStart(sb, 0);
  7413. r.setEnd(sb, 0);
  7414. s.setRng(r);
  7415. } else {
  7416. s.select(sb);
  7417. s.collapse(1);
  7418. }
  7419. } else
  7420. s.moveToBookmark(bm);
  7421. },
  7422. _applyInlineStyle : function(na, at, op) {
  7423. var t = this, ed = t.editor, dom = ed.dom, bm, lo = {}, kh;
  7424. na = na.toUpperCase();
  7425. if (op && op.check_classes && at['class'])
  7426. op.check_classes.push(at['class']);
  7427. function replaceFonts() {
  7428. var bm;
  7429. each(dom.select(tinymce.isWebKit ? 'span' : 'font'), function(n) {
  7430. if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline') {
  7431. if (!bm)
  7432. bm = ed.selection.getBookmark();
  7433. at._mce_new = '1';
  7434. dom.replace(dom.create(na, at), n, 1);
  7435. }
  7436. });
  7437. // Remove redundant elements
  7438. each(dom.select(na), function(n) {
  7439. if (n.getAttribute('_mce_new')) {
  7440. function removeStyle(n) {
  7441. if (n.nodeType == 1) {
  7442. each(at.style, function(v, k) {
  7443. dom.setStyle(n, k, '');
  7444. });
  7445. // Remove spans with the same class or marked classes
  7446. if (at['class'] && n.className && op) {
  7447. each(op.check_classes, function(c) {
  7448. if (dom.hasClass(n, c))
  7449. dom.removeClass(n, c);
  7450. });
  7451. }
  7452. }
  7453. };
  7454. // Remove specified style information from child elements
  7455. each(dom.select(na, n), removeStyle);
  7456. // Remove the specified style information on parent if current node is only child (IE)
  7457. if (n.parentNode && n.parentNode.nodeType == 1 && n.parentNode.childNodes.length == 1)
  7458. removeStyle(n.parentNode);
  7459. // Remove the child elements style info if a parent already has it
  7460. dom.getParent(n.parentNode, function(pn) {
  7461. if (pn.nodeType == 1) {
  7462. if (at.style) {
  7463. each(at.style, function(v, k) {
  7464. var sv;
  7465. if (!lo[k] && (sv = dom.getStyle(pn, k))) {
  7466. if (sv === v)
  7467. dom.setStyle(n, k, '');
  7468. lo[k] = 1;
  7469. }
  7470. });
  7471. }
  7472. // Remove spans with the same class or marked classes
  7473. if (at['class'] && pn.className && op) {
  7474. each(op.check_classes, function(c) {
  7475. if (dom.hasClass(pn, c))
  7476. dom.removeClass(n, c);
  7477. });
  7478. }
  7479. }
  7480. return false;
  7481. });
  7482. n.removeAttribute('_mce_new');
  7483. }
  7484. });
  7485. // Remove empty span elements
  7486. each(dom.select(na).reverse(), function(n) {
  7487. var c = 0;
  7488. // Check if there is any attributes
  7489. each(dom.getAttribs(n), function(an) {
  7490. if (an.nodeName.substring(0, 1) != '_' && dom.getAttrib(n, an.nodeName) != '') {
  7491. //console.log(dom.getOuterHTML(n), dom.getAttrib(n, an.nodeName));
  7492. c++;
  7493. }
  7494. });
  7495. // No attributes then remove the element and keep the children
  7496. if (c == 0)
  7497. dom.remove(n, 1);
  7498. });
  7499. ed.selection.moveToBookmark(bm);
  7500. return !!bm;
  7501. };
  7502. // Create inline elements
  7503. ed.focus();
  7504. ed.getDoc().execCommand('FontName', false, 'mceinline');
  7505. replaceFonts();
  7506. if (kh = t._applyInlineStyle.keyhandler) {
  7507. ed.onKeyUp.remove(kh);
  7508. ed.onKeyPress.remove(kh);
  7509. ed.onKeyDown.remove(kh);
  7510. ed.onSetContent.remove(t._applyInlineStyle.chandler);
  7511. }
  7512. if (ed.selection.isCollapsed()) {
  7513. // Start collecting styles
  7514. t._pendingStyles = tinymce.extend(t._pendingStyles || {}, at.style);
  7515. t._applyInlineStyle.chandler = ed.onSetContent.add(function() {
  7516. delete t._pendingStyles;
  7517. });
  7518. t._applyInlineStyle.keyhandler = kh = function(e) {
  7519. // Use pending styles
  7520. if (t._pendingStyles) {
  7521. at.style = t._pendingStyles;
  7522. delete t._pendingStyles;
  7523. }
  7524. if (replaceFonts()) {
  7525. ed.onKeyDown.remove(t._applyInlineStyle.keyhandler);
  7526. ed.onKeyPress.remove(t._applyInlineStyle.keyhandler);
  7527. }
  7528. if (e.type == 'keyup')
  7529. ed.onKeyUp.remove(t._applyInlineStyle.keyhandler);
  7530. };
  7531. ed.onKeyDown.add(kh);
  7532. ed.onKeyPress.add(kh);
  7533. ed.onKeyUp.add(kh);
  7534. } else
  7535. t._pendingStyles = 0;
  7536. },
  7537. /*
  7538. _mceBlockQuote : function() {
  7539. var t = this, s = t.editor.selection, b = s.getBookmark(), bq, dom = t.editor.dom;
  7540. function findBQ(e) {
  7541. return dom.getParent(e, function(n) {return n.nodeName === 'BLOCKQUOTE';});
  7542. };
  7543. // Remove blockquote(s)
  7544. if (findBQ(s.getStart())) {
  7545. each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
  7546. // Found BQ lets remove it
  7547. if (e.nodeName == 'BLOCKQUOTE')
  7548. dom.remove(e, 1);
  7549. });
  7550. t.editor.selection.moveToBookmark(b);
  7551. return;
  7552. }
  7553. each(t._getSelectedBlocks(findBQ(s.getStart()), findBQ(s.getEnd())), function(e) {
  7554. var n;
  7555. // Found existing BQ add to this one
  7556. if (e.nodeName == 'BLOCKQUOTE' && !bq) {
  7557. bq = e;
  7558. return;
  7559. }
  7560. // No BQ found, create one
  7561. if (!bq) {
  7562. bq = dom.create('blockquote');
  7563. e.parentNode.insertBefore(bq, e);
  7564. }
  7565. // Add children from existing BQ
  7566. if (e.nodeName == 'BLOCKQUOTE' && bq) {
  7567. n = e.firstChild;
  7568. while (n) {
  7569. bq.appendChild(n.cloneNode(true));
  7570. n = n.nextSibling;
  7571. }
  7572. dom.remove(e);
  7573. return;
  7574. }
  7575. // Add non BQ element to BQ
  7576. bq.appendChild(dom.remove(e));
  7577. });
  7578. t.editor.selection.moveToBookmark(b);
  7579. },
  7580. */
  7581. _getSelectedBlocks : function(st, en) {
  7582. var ed = this.editor, dom = ed.dom, s = ed.selection, sb, eb, n, bl = [];
  7583. sb = dom.getParent(st || s.getStart(), isBlock);
  7584. eb = dom.getParent(en || s.getEnd(), isBlock);
  7585. if (sb)
  7586. bl.push(sb);
  7587. if (sb && eb && sb != eb) {
  7588. n = sb;
  7589. while ((n = n.nextSibling) && n != eb) {
  7590. if (isBlock(n))
  7591. bl.push(n);
  7592. }
  7593. }
  7594. if (eb && sb != eb)
  7595. bl.push(eb);
  7596. return bl;
  7597. }
  7598. });
  7599. })();
  7600. /* file:jscripts/tiny_mce/classes/UndoManager.js */
  7601. tinymce.create('tinymce.UndoManager', {
  7602. index : 0,
  7603. data : null,
  7604. typing : 0,
  7605. UndoManager : function(ed) {
  7606. var t = this, Dispatcher = tinymce.util.Dispatcher;
  7607. t.editor = ed;
  7608. t.data = [];
  7609. t.onAdd = new Dispatcher(this);
  7610. t.onUndo = new Dispatcher(this);
  7611. t.onRedo = new Dispatcher(this);
  7612. },
  7613. add : function(l) {
  7614. var t = this, i, ed = t.editor, b, s = ed.settings, la;
  7615. l = l || {};
  7616. l.content = l.content || ed.getContent({format : 'raw', no_events : 1});
  7617. // Add undo level if needed
  7618. l.content = l.content.replace(/^\s*|\s*$/g, '');
  7619. la = t.data[t.index > 0 && (t.index == 0 || t.index == t.data.length) ? t.index - 1 : t.index];
  7620. if (!l.initial && la && l.content == la.content)
  7621. return null;
  7622. // Time to compress
  7623. if (s.custom_undo_redo_levels) {
  7624. if (t.data.length > s.custom_undo_redo_levels) {
  7625. for (i = 0; i < t.data.length - 1; i++)
  7626. t.data[i] = t.data[i + 1];
  7627. t.data.length--;
  7628. t.index = t.data.length;
  7629. }
  7630. }
  7631. if (s.custom_undo_redo_restore_selection && !l.initial)
  7632. l.bookmark = b = l.bookmark || ed.selection.getBookmark();
  7633. if (t.index < t.data.length)
  7634. t.index++;
  7635. // Only initial marked undo levels should be allowed as first item
  7636. // This to workaround a bug with Firefox and the blur event
  7637. if (t.data.length === 0 && !l.initial)
  7638. return null;
  7639. // Add level
  7640. t.data.length = t.index + 1;
  7641. t.data[t.index++] = l;
  7642. if (l.initial)
  7643. t.index = 0;
  7644. // Set initial bookmark use first real undo level
  7645. if (t.data.length == 2 && t.data[0].initial)
  7646. t.data[0].bookmark = b;
  7647. t.onAdd.dispatch(t, l);
  7648. ed.isNotDirty = 0;
  7649. //console.dir(t.data);
  7650. return l;
  7651. },
  7652. undo : function() {
  7653. var t = this, ed = t.editor, l = l, i;
  7654. if (t.typing) {
  7655. t.add();
  7656. t.typing = 0;
  7657. }
  7658. if (t.index > 0) {
  7659. // If undo on last index then take snapshot
  7660. if (t.index == t.data.length && t.index > 1) {
  7661. i = t.index;
  7662. t.typing = 0;
  7663. if (!t.add())
  7664. t.index = i;
  7665. --t.index;
  7666. }
  7667. l = t.data[--t.index];
  7668. ed.setContent(l.content, {format : 'raw'});
  7669. ed.selection.moveToBookmark(l.bookmark);
  7670. t.onUndo.dispatch(t, l);
  7671. }
  7672. return l;
  7673. },
  7674. redo : function() {
  7675. var t = this, ed = t.editor, l = null;
  7676. if (t.index < t.data.length - 1) {
  7677. l = t.data[++t.index];
  7678. ed.setContent(l.content, {format : 'raw'});
  7679. ed.selection.moveToBookmark(l.bookmark);
  7680. t.onRedo.dispatch(t, l);
  7681. }
  7682. return l;
  7683. },
  7684. clear : function() {
  7685. var t = this;
  7686. t.data = [];
  7687. t.index = 0;
  7688. t.typing = 0;
  7689. t.add({initial : true});
  7690. },
  7691. hasUndo : function() {
  7692. return this.index != 0 || this.typing;
  7693. },
  7694. hasRedo : function() {
  7695. return this.index < this.data.length - 1;
  7696. }
  7697. });
  7698. /* file:jscripts/tiny_mce/classes/ForceBlocks.js */
  7699. (function() {
  7700. // Shorten names
  7701. var Event, isIE, isGecko, isOpera, each, extend;
  7702. Event = tinymce.dom.Event;
  7703. isIE = tinymce.isIE;
  7704. isGecko = tinymce.isGecko;
  7705. isOpera = tinymce.isOpera;
  7706. each = tinymce.each;
  7707. extend = tinymce.extend;
  7708. tinymce.create('tinymce.ForceBlocks', {
  7709. ForceBlocks : function(ed) {
  7710. var t = this, s = ed.settings, elm;
  7711. t.editor = ed;
  7712. t.dom = ed.dom;
  7713. elm = (s.forced_root_block || 'p').toLowerCase();
  7714. s.element = elm.toUpperCase();
  7715. ed.onPreInit.add(t.setup, t);
  7716. t.reOpera = new RegExp('(\\u00a0|&#160;|&nbsp;)<\/' + elm + '>', 'gi');
  7717. t.rePadd = new RegExp('<p( )([^>]+)><\\\/p>|<p( )([^>]+)\\\/>|<p( )([^>]+)>\\s+<\\\/p>|<p><\\\/p>|<p\\\/>|<p>\\s+<\\\/p>'.replace(/p/g, elm), 'gi');
  7718. t.reNbsp2BR1 = new RegExp('<p( )([^>]+)>[\\s\\u00a0]+<\\\/p>|<p>[\\s\\u00a0]+<\\\/p>'.replace(/p/g, elm), 'gi');
  7719. t.reNbsp2BR2 = new RegExp('<p( )([^>]+)>(&nbsp;|&#160;)<\\\/p>|<p>(&nbsp;|&#160;)<\\\/p>'.replace(/p/g, elm), 'gi');
  7720. t.reBR2Nbsp = new RegExp('<p( )([^>]+)>\\s*<br \\\/>\\s*<\\\/p>|<p>\\s*<br \\\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
  7721. t.reTrailBr = new RegExp('\\s*<br \\/>\\s*<\\\/p>'.replace(/p/g, elm), 'gi');
  7722. function padd(ed, o) {
  7723. if (isOpera)
  7724. o.content = o.content.replace(t.reOpera, '</' + elm + '>');
  7725. o.content = o.content.replace(t.rePadd, '<' + elm + '$1$2$3$4$5$6>\u00a0</' + elm + '>');
  7726. if (!isIE && !isOpera && o.set) {
  7727. // Use &nbsp; instead of BR in padded paragraphs
  7728. o.content = o.content.replace(t.reNbsp2BR1, '<' + elm + '$1$2><br /></' + elm + '>');
  7729. o.content = o.content.replace(t.reNbsp2BR2, '<' + elm + '$1$2><br /></' + elm + '>');
  7730. } else {
  7731. o.content = o.content.replace(t.reBR2Nbsp, '<' + elm + '$1$2>\u00a0</' + elm + '>');
  7732. o.content = o.content.replace(t.reTrailBr, '</' + elm + '>');
  7733. }
  7734. };
  7735. ed.onBeforeSetContent.add(padd);
  7736. ed.onPostProcess.add(padd);
  7737. if (s.forced_root_block) {
  7738. ed.onInit.add(t.forceRoots, t);
  7739. ed.onSetContent.add(t.forceRoots, t);
  7740. ed.onBeforeGetContent.add(t.forceRoots, t);
  7741. }
  7742. },
  7743. setup : function() {
  7744. var t = this, ed = t.editor, s = ed.settings;
  7745. // Force root blocks when typing and when getting output
  7746. if (s.forced_root_block) {
  7747. ed.onKeyUp.add(t.forceRoots, t);
  7748. ed.onPreProcess.add(t.forceRoots, t);
  7749. }
  7750. if (s.force_br_newlines) {
  7751. // Force IE to produce BRs on enter
  7752. if (isIE) {
  7753. ed.onKeyPress.add(function(ed, e) {
  7754. var n, s = ed.selection;
  7755. if (e.keyCode == 13 && s.getNode().nodeName != 'LI') {
  7756. s.setContent('<br id="__" /> ', {format : 'raw'});
  7757. n = ed.dom.get('__');
  7758. n.removeAttribute('id');
  7759. s.select(n);
  7760. s.collapse();
  7761. return Event.cancel(e);
  7762. }
  7763. });
  7764. }
  7765. return;
  7766. }
  7767. if (!isIE && s.force_p_newlines) {
  7768. /* ed.onPreProcess.add(function(ed, o) {
  7769. each(ed.dom.select('br', o.node), function(n) {
  7770. var p = n.parentNode;
  7771. // Replace <p><br /></p> with <p>&nbsp;</p>
  7772. if (p && p.nodeName == 'p' && (p.childNodes.length == 1 || p.lastChild == n)) {
  7773. p.replaceChild(ed.getDoc().createTextNode('\u00a0'), n);
  7774. }
  7775. });
  7776. });*/
  7777. ed.onKeyPress.add(function(ed, e) {
  7778. if (e.keyCode == 13 && !e.shiftKey) {
  7779. if (!t.insertPara(e))
  7780. Event.cancel(e);
  7781. }
  7782. });
  7783. if (isGecko) {
  7784. ed.onKeyDown.add(function(ed, e) {
  7785. if ((e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey)
  7786. t.backspaceDelete(e, e.keyCode == 8);
  7787. });
  7788. }
  7789. }
  7790. function ren(rn, na) {
  7791. var ne = ed.dom.create(na);
  7792. each(rn.attributes, function(a) {
  7793. if (a.specified && a.nodeValue)
  7794. ne.setAttribute(a.nodeName.toLowerCase(), a.nodeValue);
  7795. });
  7796. each(rn.childNodes, function(n) {
  7797. ne.appendChild(n.cloneNode(true));
  7798. });
  7799. rn.parentNode.replaceChild(ne, rn);
  7800. return ne;
  7801. };
  7802. // Replaces IE:s auto generated paragraphs with the specified element name
  7803. if (isIE && s.element != 'P') {
  7804. ed.onKeyPress.add(function(ed, e) {
  7805. t.lastElm = ed.selection.getNode().nodeName;
  7806. });
  7807. ed.onKeyUp.add(function(ed, e) {
  7808. var bl, sel = ed.selection, n = sel.getNode(), b = ed.getBody();
  7809. if (b.childNodes.length === 1 && n.nodeName == 'P') {
  7810. n = ren(n, s.element);
  7811. sel.select(n);
  7812. sel.collapse();
  7813. ed.nodeChanged();
  7814. } else if (e.keyCode == 13 && !e.shiftKey && t.lastElm != 'P') {
  7815. bl = ed.dom.getParent(n, 'P');
  7816. if (bl) {
  7817. ren(bl, s.element);
  7818. ed.nodeChanged();
  7819. }
  7820. }
  7821. });
  7822. }
  7823. },
  7824. find : function(n, t, s) {
  7825. var ed = this.editor, w = ed.getDoc().createTreeWalker(n, 4, null, false), c = -1;
  7826. while (n = w.nextNode()) {
  7827. c++;
  7828. // Index by node
  7829. if (t == 0 && n == s)
  7830. return c;
  7831. // Node by index
  7832. if (t == 1 && c == s)
  7833. return n;
  7834. }
  7835. return -1;
  7836. },
  7837. forceRoots : function(ed, e) {
  7838. var t = this, ed = t.editor, b = ed.getBody(), d = ed.getDoc(), se = ed.selection, s = se.getSel(), r = se.getRng(), si = -2, ei, so, eo, tr, c = -0xFFFFFF;
  7839. var nx, bl, bp, sp, le, nl = b.childNodes, i, n;
  7840. // Fix for bug #1863847
  7841. //if (e && e.keyCode == 13)
  7842. // return true;
  7843. // Wrap non blocks into blocks
  7844. for (i = nl.length - 1; i >= 0; i--) {
  7845. nx = nl[i];
  7846. // Is text or non block element
  7847. if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) {
  7848. if (!bl) {
  7849. // Create new block but ignore whitespace
  7850. if (nx.nodeType != 3 || /[^\s]/g.test(nx.nodeValue)) {
  7851. // Store selection
  7852. if (si == -2 && r) {
  7853. if (!isIE) {
  7854. // If selection is element then mark it
  7855. if (r.startContainer.nodeType == 1 && (n = r.startContainer.childNodes[r.startOffset]) && n.nodeType == 1) {
  7856. n.setAttribute("id", "__mce");
  7857. } else {
  7858. // If element is inside body, might not be the case in contentEdiable mode
  7859. if (ed.dom.getParent(r.startContainer, function(e) {return e === b;})) {
  7860. so = r.startOffset;
  7861. eo = r.endOffset;
  7862. si = t.find(b, 0, r.startContainer);
  7863. ei = t.find(b, 0, r.endContainer);
  7864. }
  7865. }
  7866. } else {
  7867. tr = d.body.createTextRange();
  7868. tr.moveToElementText(b);
  7869. tr.collapse(1);
  7870. bp = tr.move('character', c) * -1;
  7871. tr = r.duplicate();
  7872. tr.collapse(1);
  7873. sp = tr.move('character', c) * -1;
  7874. tr = r.duplicate();
  7875. tr.collapse(0);
  7876. le = (tr.move('character', c) * -1) - sp;
  7877. si = sp - bp;
  7878. ei = le;
  7879. }
  7880. }
  7881. bl = ed.dom.create(ed.settings.forced_root_block);
  7882. bl.appendChild(nx.cloneNode(1));
  7883. nx.parentNode.replaceChild(bl, nx);
  7884. }
  7885. } else {
  7886. if (bl.hasChildNodes())
  7887. bl.insertBefore(nx, bl.firstChild);
  7888. else
  7889. bl.appendChild(nx);
  7890. }
  7891. } else
  7892. bl = null; // Time to create new block
  7893. }
  7894. // Restore selection
  7895. if (si != -2) {
  7896. if (!isIE) {
  7897. bl = b.getElementsByTagName(ed.settings.element)[0];
  7898. r = d.createRange();
  7899. // Select last location or generated block
  7900. if (si != -1)
  7901. r.setStart(t.find(b, 1, si), so);
  7902. else
  7903. r.setStart(bl, 0);
  7904. // Select last location or generated block
  7905. if (ei != -1)
  7906. r.setEnd(t.find(b, 1, ei), eo);
  7907. else
  7908. r.setEnd(bl, 0);
  7909. if (s) {
  7910. s.removeAllRanges();
  7911. s.addRange(r);
  7912. }
  7913. } else {
  7914. try {
  7915. r = s.createRange();
  7916. r.moveToElementText(b);
  7917. r.collapse(1);
  7918. r.moveStart('character', si);
  7919. r.moveEnd('character', ei);
  7920. r.select();
  7921. } catch (ex) {
  7922. // Ignore
  7923. }
  7924. }
  7925. } else if (!isIE && (n = ed.dom.get('__mce'))) {
  7926. // Move caret before selected element
  7927. n.removeAttribute('id');
  7928. r = d.createRange();
  7929. r.setStartBefore(n);
  7930. r.setEndBefore(n);
  7931. se.setRng(r);
  7932. }
  7933. },
  7934. getParentBlock : function(n) {
  7935. var d = this.dom;
  7936. return d.getParent(n, d.isBlock);
  7937. },
  7938. insertPara : function(e) {
  7939. var t = this, ed = t.editor, dom = ed.dom, d = ed.getDoc(), se = ed.settings, s = ed.selection.getSel(), r = s.getRangeAt(0), b = d.body;
  7940. var rb, ra, dir, sn, so, en, eo, sb, eb, bn, bef, aft, sc, ec, n, vp = dom.getViewPort(ed.getWin()), y, ch, car;
  7941. function isEmpty(n) {
  7942. n = n.innerHTML;
  7943. n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars
  7944. n = n.replace(/<[^>]+>/g, ''); // Remove all tags
  7945. return n.replace(/[ \t\r\n]+/g, '') == '';
  7946. };
  7947. // If root blocks are forced then use Operas default behavior since it's really good
  7948. // Removed due to bug: #1853816
  7949. // if (se.forced_root_block && isOpera)
  7950. // return true;
  7951. // Setup before range
  7952. rb = d.createRange();
  7953. // If is before the first block element and in body, then move it into first block element
  7954. rb.setStart(s.anchorNode, s.anchorOffset);
  7955. rb.collapse(true);
  7956. // Setup after range
  7957. ra = d.createRange();
  7958. // If is before the first block element and in body, then move it into first block element
  7959. ra.setStart(s.focusNode, s.focusOffset);
  7960. ra.collapse(true);
  7961. // Setup start/end points
  7962. dir = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
  7963. sn = dir ? s.anchorNode : s.focusNode;
  7964. so = dir ? s.anchorOffset : s.focusOffset;
  7965. en = dir ? s.focusNode : s.anchorNode;
  7966. eo = dir ? s.focusOffset : s.anchorOffset;
  7967. // If selection is in empty table cell
  7968. if (sn === en && /^(TD|TH)$/.test(sn.nodeName)) {
  7969. dom.remove(sn.firstChild); // Remove BR
  7970. // Create two new block elements
  7971. ed.dom.add(sn, se.element, null, '<br />');
  7972. aft = ed.dom.add(sn, se.element, null, '<br />');
  7973. // Move caret into the last one
  7974. r = d.createRange();
  7975. r.selectNodeContents(aft);
  7976. r.collapse(1);
  7977. ed.selection.setRng(r);
  7978. return false;
  7979. }
  7980. // If the caret is in an invalid location in FF we need to move it into the first block
  7981. if (sn == b && en == b && b.firstChild && ed.dom.isBlock(b.firstChild)) {
  7982. sn = en = sn.firstChild;
  7983. so = eo = 0;
  7984. rb = d.createRange();
  7985. rb.setStart(sn, 0);
  7986. ra = d.createRange();
  7987. ra.setStart(en, 0);
  7988. }
  7989. // Never use body as start or end node
  7990. sn = sn.nodeName == "HTML" ? d.body : sn; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
  7991. sn = sn.nodeName == "BODY" ? sn.firstChild : sn;
  7992. en = en.nodeName == "HTML" ? d.body : en; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
  7993. en = en.nodeName == "BODY" ? en.firstChild : en;
  7994. // Get start and end blocks
  7995. sb = t.getParentBlock(sn);
  7996. eb = t.getParentBlock(en);
  7997. bn = sb ? sb.nodeName : se.element; // Get block name to create
  7998. // Return inside list use default browser behavior
  7999. if (t.dom.getParent(sb, function(n) { return /OL|UL|PRE/.test(n.nodeName); }))
  8000. return true;
  8001. // If caption or absolute layers then always generate new blocks within
  8002. if (sb && (sb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(sb.style.position))) {
  8003. bn = se.element;
  8004. sb = null;
  8005. }
  8006. // If caption or absolute layers then always generate new blocks within
  8007. if (eb && (eb.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(eb.style.position))) {
  8008. bn = se.element;
  8009. eb = null;
  8010. }
  8011. // Use P instead
  8012. if (/(TD|TABLE|TH|CAPTION)/.test(bn) || (sb && bn == "DIV" && /left|right/gi.test(sb.style.cssFloat))) {
  8013. bn = se.element;
  8014. sb = eb = null;
  8015. }
  8016. // Setup new before and after blocks
  8017. bef = (sb && sb.nodeName == bn) ? sb.cloneNode(0) : ed.dom.create(bn);
  8018. aft = (eb && eb.nodeName == bn) ? eb.cloneNode(0) : ed.dom.create(bn);
  8019. // Remove id from after clone
  8020. aft.removeAttribute('id');
  8021. // Is header and cursor is at the end, then force paragraph under
  8022. if (/^(H[1-6])$/.test(bn) && sn.nodeValue && so == sn.nodeValue.length)
  8023. aft = ed.dom.create(se.element);
  8024. // Find start chop node
  8025. n = sc = sn;
  8026. do {
  8027. if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
  8028. break;
  8029. sc = n;
  8030. } while ((n = n.previousSibling ? n.previousSibling : n.parentNode));
  8031. // Find end chop node
  8032. n = ec = en;
  8033. do {
  8034. if (n == b || n.nodeType == 9 || t.dom.isBlock(n) || /(TD|TABLE|TH|CAPTION)/.test(n.nodeName))
  8035. break;
  8036. ec = n;
  8037. } while ((n = n.nextSibling ? n.nextSibling : n.parentNode));
  8038. // Place first chop part into before block element
  8039. if (sc.nodeName == bn)
  8040. rb.setStart(sc, 0);
  8041. else
  8042. rb.setStartBefore(sc);
  8043. rb.setEnd(sn, so);
  8044. bef.appendChild(rb.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
  8045. // Place secnd chop part within new block element
  8046. try {
  8047. ra.setEndAfter(ec);
  8048. } catch(ex) {
  8049. //console.debug(s.focusNode, s.focusOffset);
  8050. }
  8051. ra.setStart(en, eo);
  8052. aft.appendChild(ra.cloneContents() || d.createTextNode('')); // Empty text node needed for Safari
  8053. // Create range around everything
  8054. r = d.createRange();
  8055. if (!sc.previousSibling && sc.parentNode.nodeName == bn) {
  8056. r.setStartBefore(sc.parentNode);
  8057. } else {
  8058. if (rb.startContainer.nodeName == bn && rb.startOffset == 0)
  8059. r.setStartBefore(rb.startContainer);
  8060. else
  8061. r.setStart(rb.startContainer, rb.startOffset);
  8062. }
  8063. if (!ec.nextSibling && ec.parentNode.nodeName == bn)
  8064. r.setEndAfter(ec.parentNode);
  8065. else
  8066. r.setEnd(ra.endContainer, ra.endOffset);
  8067. // Delete and replace it with new block elements
  8068. r.deleteContents();
  8069. if (isOpera)
  8070. ed.getWin().scrollTo(0, vp.y);
  8071. // Never wrap blocks in blocks
  8072. if (bef.firstChild && bef.firstChild.nodeName == bn)
  8073. bef.innerHTML = bef.firstChild.innerHTML;
  8074. if (aft.firstChild && aft.firstChild.nodeName == bn)
  8075. aft.innerHTML = aft.firstChild.innerHTML;
  8076. // Padd empty blocks
  8077. if (isEmpty(bef))
  8078. bef.innerHTML = '<br />';
  8079. function appendStyles(e, en) {
  8080. var nl = [], nn, n, i;
  8081. e.innerHTML = '';
  8082. // Make clones of style elements
  8083. if (se.keep_styles) {
  8084. n = en;
  8085. do {
  8086. // We only want style specific elements
  8087. if (/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(n.nodeName)) {
  8088. nn = n.cloneNode(false);
  8089. dom.setAttrib(nn, 'id', ''); // Remove ID since it needs to be unique
  8090. nl.push(nn);
  8091. }
  8092. } while (n = n.parentNode);
  8093. }
  8094. // Append style elements to aft
  8095. if (nl.length > 0) {
  8096. for (i = nl.length - 1, nn = e; i >= 0; i--)
  8097. nn = nn.appendChild(nl[i]);
  8098. // Padd most inner style element
  8099. nl[0].innerHTML = isOpera ? '&nbsp;' : '<br />'; // Extra space for Opera so that the caret can move there
  8100. return nl[0]; // Move caret to most inner element
  8101. } else
  8102. e.innerHTML = isOpera ? '&nbsp;' : '<br />'; // Extra space for Opera so that the caret can move there
  8103. };
  8104. // Fill empty afterblook with current style
  8105. if (isEmpty(aft))
  8106. car = appendStyles(aft, en);
  8107. // Opera needs this one backwards for older versions
  8108. if (isOpera && parseFloat(opera.version()) < 9.5) {
  8109. r.insertNode(bef);
  8110. r.insertNode(aft);
  8111. } else {
  8112. r.insertNode(aft);
  8113. r.insertNode(bef);
  8114. }
  8115. // Normalize
  8116. aft.normalize();
  8117. bef.normalize();
  8118. function first(n) {
  8119. return d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false).nextNode() || n;
  8120. };
  8121. // Move cursor and scroll into view
  8122. r = d.createRange();
  8123. r.selectNodeContents(isGecko ? first(car || aft) : car || aft);
  8124. r.collapse(1);
  8125. s.removeAllRanges();
  8126. s.addRange(r);
  8127. // scrollIntoView seems to scroll the parent window in most browsers now including FF 3.0b4 so it's time to stop using it and do it our selfs
  8128. y = ed.dom.getPos(aft).y;
  8129. ch = aft.clientHeight;
  8130. // Is element within viewport
  8131. if (y < vp.y || y + ch > vp.y + vp.h) {
  8132. ed.getWin().scrollTo(0, y < vp.y ? y : y - vp.h + 25); // Needs to be hardcoded to roughly one line of text if a huge text block is broken into two blocks
  8133. //console.debug('SCROLL!', 'vp.y: ' + vp.y, 'y' + y, 'vp.h' + vp.h, 'clientHeight' + aft.clientHeight, 'yyy: ' + (y < vp.y ? y : y - vp.h + aft.clientHeight));
  8134. }
  8135. return false;
  8136. },
  8137. backspaceDelete : function(e, bs) {
  8138. var t = this, ed = t.editor, b = ed.getBody(), n, se = ed.selection, r = se.getRng(), sc = r.startContainer, n, w, tn;
  8139. // The caret sometimes gets stuck in Gecko if you delete empty paragraphs
  8140. // This workaround removes the element by hand and moves the caret to the previous element
  8141. if (sc && ed.dom.isBlock(sc) && !/^(TD|TH)$/.test(sc.nodeName) && bs) {
  8142. if (sc.childNodes.length == 0 || (sc.childNodes.length == 1 && sc.firstChild.nodeName == 'BR')) {
  8143. // Find previous block element
  8144. n = sc;
  8145. while ((n = n.previousSibling) && !ed.dom.isBlock(n)) ;
  8146. if (n) {
  8147. if (sc != b.firstChild) {
  8148. // Find last text node
  8149. w = ed.dom.doc.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
  8150. while (tn = w.nextNode())
  8151. n = tn;
  8152. // Place caret at the end of last text node
  8153. r = ed.getDoc().createRange();
  8154. r.setStart(n, n.nodeValue ? n.nodeValue.length : 0);
  8155. r.setEnd(n, n.nodeValue ? n.nodeValue.length : 0);
  8156. se.setRng(r);
  8157. // Remove the target container
  8158. ed.dom.remove(sc);
  8159. }
  8160. return Event.cancel(e);
  8161. }
  8162. }
  8163. }
  8164. // Gecko generates BR elements here and there, we don't like those so lets remove them
  8165. function handler(e) {
  8166. var pr;
  8167. e = e.target;
  8168. // A new BR was created in a block element, remove it
  8169. if (e && e.parentNode && e.nodeName == 'BR' && (n = t.getParentBlock(e))) {
  8170. pr = e.previousSibling;
  8171. Event.remove(b, 'DOMNodeInserted', handler);
  8172. // Is there whitespace at the end of the node before then we might need the pesky BR
  8173. // to place the caret at a correct location see bug: #2013943
  8174. if (pr && pr.nodeType == 3 && /\s+$/.test(pr.nodeValue))
  8175. return;
  8176. // Only remove BR elements that got inserted in the middle of the text
  8177. if (e.previousSibling || e.nextSibling)
  8178. ed.dom.remove(e);
  8179. }
  8180. };
  8181. // Listen for new nodes
  8182. Event._add(b, 'DOMNodeInserted', handler);
  8183. // Remove listener
  8184. window.setTimeout(function() {
  8185. Event._remove(b, 'DOMNodeInserted', handler);
  8186. }, 1);
  8187. }
  8188. });
  8189. })();
  8190. /* file:jscripts/tiny_mce/classes/ControlManager.js */
  8191. (function() {
  8192. // Shorten names
  8193. var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, extend = tinymce.extend;
  8194. tinymce.create('tinymce.ControlManager', {
  8195. ControlManager : function(ed, s) {
  8196. var t = this, i;
  8197. s = s || {};
  8198. t.editor = ed;
  8199. t.controls = {};
  8200. t.onAdd = new tinymce.util.Dispatcher(t);
  8201. t.onPostRender = new tinymce.util.Dispatcher(t);
  8202. t.prefix = s.prefix || ed.id + '_';
  8203. t._cls = {};
  8204. t.onPostRender.add(function() {
  8205. each(t.controls, function(c) {
  8206. c.postRender();
  8207. });
  8208. });
  8209. },
  8210. get : function(id) {
  8211. return this.controls[this.prefix + id] || this.controls[id];
  8212. },
  8213. setActive : function(id, s) {
  8214. var c = null;
  8215. if (c = this.get(id))
  8216. c.setActive(s);
  8217. return c;
  8218. },
  8219. setDisabled : function(id, s) {
  8220. var c = null;
  8221. if (c = this.get(id))
  8222. c.setDisabled(s);
  8223. return c;
  8224. },
  8225. add : function(c) {
  8226. var t = this;
  8227. if (c) {
  8228. t.controls[c.id] = c;
  8229. t.onAdd.dispatch(c, t);
  8230. }
  8231. return c;
  8232. },
  8233. createControl : function(n) {
  8234. var c, t = this, ed = t.editor;
  8235. each(ed.plugins, function(p) {
  8236. if (p.createControl) {
  8237. c = p.createControl(n, t);
  8238. if (c)
  8239. return false;
  8240. }
  8241. });
  8242. switch (n) {
  8243. case "|":
  8244. case "separator":
  8245. return t.createSeparator();
  8246. }
  8247. if (!c && ed.buttons && (c = ed.buttons[n]))
  8248. return t.createButton(n, c);
  8249. return t.add(c);
  8250. },
  8251. createDropMenu : function(id, s, cc) {
  8252. var t = this, ed = t.editor, c, bm, v, cls;
  8253. s = extend({
  8254. 'class' : 'mceDropDown',
  8255. constrain : ed.settings.constrain_menus
  8256. }, s);
  8257. s['class'] = s['class'] + ' ' + ed.getParam('skin') + 'Skin';
  8258. if (v = ed.getParam('skin_variant'))
  8259. s['class'] += ' ' + ed.getParam('skin') + 'Skin' + v.substring(0, 1).toUpperCase() + v.substring(1);
  8260. id = t.prefix + id;
  8261. cls = cc || t._cls.dropmenu || tinymce.ui.DropMenu;
  8262. c = t.controls[id] = new cls(id, s);
  8263. c.onAddItem.add(function(c, o) {
  8264. var s = o.settings;
  8265. s.title = ed.getLang(s.title, s.title);
  8266. if (!s.onclick) {
  8267. s.onclick = function(v) {
  8268. ed.execCommand(s.cmd, s.ui || false, s.value);
  8269. };
  8270. }
  8271. });
  8272. ed.onRemove.add(function() {
  8273. c.destroy();
  8274. });
  8275. // Fix for bug #1897785, #1898007
  8276. if (tinymce.isIE) {
  8277. c.onShowMenu.add(function() {
  8278. bm = ed.selection.getBookmark(1);
  8279. });
  8280. c.onHideMenu.add(function() {
  8281. if (bm)
  8282. ed.selection.moveToBookmark(bm);
  8283. });
  8284. }
  8285. return t.add(c);
  8286. },
  8287. createListBox : function(id, s, cc) {
  8288. var t = this, ed = t.editor, cmd, c, cls;
  8289. if (t.get(id))
  8290. return null;
  8291. s.title = ed.translate(s.title);
  8292. s.scope = s.scope || ed;
  8293. if (!s.onselect) {
  8294. s.onselect = function(v) {
  8295. ed.execCommand(s.cmd, s.ui || false, v || s.value);
  8296. };
  8297. }
  8298. s = extend({
  8299. title : s.title,
  8300. 'class' : 'mce_' + id,
  8301. scope : s.scope,
  8302. control_manager : t
  8303. }, s);
  8304. id = t.prefix + id;
  8305. if (ed.settings.use_native_selects)
  8306. c = new tinymce.ui.NativeListBox(id, s);
  8307. else {
  8308. cls = cc || t._cls.listbox || tinymce.ui.ListBox;
  8309. c = new cls(id, s);
  8310. }
  8311. t.controls[id] = c;
  8312. // Fix focus problem in Safari
  8313. if (tinymce.isWebKit) {
  8314. c.onPostRender.add(function(c, n) {
  8315. // Store bookmark on mousedown
  8316. Event.add(n, 'mousedown', function() {
  8317. ed.bookmark = ed.selection.getBookmark('simple');
  8318. });
  8319. // Restore on focus, since it might be lost
  8320. Event.add(n, 'focus', function() {
  8321. ed.selection.moveToBookmark(ed.bookmark);
  8322. ed.bookmark = null;
  8323. });
  8324. });
  8325. }
  8326. if (c.hideMenu)
  8327. ed.onMouseDown.add(c.hideMenu, c);
  8328. return t.add(c);
  8329. },
  8330. createButton : function(id, s, cc) {
  8331. var t = this, ed = t.editor, o, c, cls;
  8332. if (t.get(id))
  8333. return null;
  8334. s.title = ed.translate(s.title);
  8335. s.label = ed.translate(s.label);
  8336. s.scope = s.scope || ed;
  8337. if (!s.onclick && !s.menu_button) {
  8338. s.onclick = function() {
  8339. ed.execCommand(s.cmd, s.ui || false, s.value);
  8340. };
  8341. }
  8342. s = extend({
  8343. title : s.title,
  8344. 'class' : 'mce_' + id,
  8345. unavailable_prefix : ed.getLang('unavailable', ''),
  8346. scope : s.scope,
  8347. control_manager : t
  8348. }, s);
  8349. id = t.prefix + id;
  8350. if (s.menu_button) {
  8351. cls = cc || t._cls.menubutton || tinymce.ui.MenuButton;
  8352. c = new cls(id, s);
  8353. ed.onMouseDown.add(c.hideMenu, c);
  8354. } else {
  8355. cls = t._cls.button || tinymce.ui.Button;
  8356. c = new cls(id, s);
  8357. }
  8358. return t.add(c);
  8359. },
  8360. createMenuButton : function(id, s, cc) {
  8361. s = s || {};
  8362. s.menu_button = 1;
  8363. return this.createButton(id, s, cc);
  8364. },
  8365. createSplitButton : function(id, s, cc) {
  8366. var t = this, ed = t.editor, cmd, c, cls;
  8367. if (t.get(id))
  8368. return null;
  8369. s.title = ed.translate(s.title);
  8370. s.scope = s.scope || ed;
  8371. if (!s.onclick) {
  8372. s.onclick = function(v) {
  8373. ed.execCommand(s.cmd, s.ui || false, v || s.value);
  8374. };
  8375. }
  8376. if (!s.onselect) {
  8377. s.onselect = function(v) {
  8378. ed.execCommand(s.cmd, s.ui || false, v || s.value);
  8379. };
  8380. }
  8381. s = extend({
  8382. title : s.title,
  8383. 'class' : 'mce_' + id,
  8384. scope : s.scope,
  8385. control_manager : t
  8386. }, s);
  8387. id = t.prefix + id;
  8388. cls = cc || t._cls.splitbutton || tinymce.ui.SplitButton;
  8389. c = t.add(new cls(id, s));
  8390. ed.onMouseDown.add(c.hideMenu, c);
  8391. return c;
  8392. },
  8393. createColorSplitButton : function(id, s, cc) {
  8394. var t = this, ed = t.editor, cmd, c, cls, bm;
  8395. if (t.get(id))
  8396. return null;
  8397. s.title = ed.translate(s.title);
  8398. s.scope = s.scope || ed;
  8399. if (!s.onclick) {
  8400. s.onclick = function(v) {
  8401. ed.execCommand(s.cmd, s.ui || false, v || s.value);
  8402. };
  8403. }
  8404. if (!s.onselect) {
  8405. s.onselect = function(v) {
  8406. ed.execCommand(s.cmd, s.ui || false, v || s.value);
  8407. };
  8408. }
  8409. s = extend({
  8410. title : s.title,
  8411. 'class' : 'mce_' + id,
  8412. 'menu_class' : ed.getParam('skin') + 'Skin',
  8413. scope : s.scope,
  8414. more_colors_title : ed.getLang('more_colors')
  8415. }, s);
  8416. id = t.prefix + id;
  8417. cls = cc || t._cls.colorsplitbutton || tinymce.ui.ColorSplitButton;
  8418. c = new cls(id, s);
  8419. ed.onMouseDown.add(c.hideMenu, c);
  8420. // Remove the menu element when the editor is removed
  8421. ed.onRemove.add(function() {
  8422. c.destroy();
  8423. });
  8424. // Fix for bug #1897785, #1898007
  8425. if (tinymce.isIE) {
  8426. c.onShowMenu.add(function() {
  8427. bm = ed.selection.getBookmark(1);
  8428. });
  8429. c.onHideMenu.add(function() {
  8430. if (bm) {
  8431. ed.selection.moveToBookmark(bm);
  8432. bm = 0;
  8433. }
  8434. });
  8435. }
  8436. return t.add(c);
  8437. },
  8438. createToolbar : function(id, s, cc) {
  8439. var c, t = this, cls;
  8440. id = t.prefix + id;
  8441. cls = cc || t._cls.toolbar || tinymce.ui.Toolbar;
  8442. c = new cls(id, s);
  8443. if (t.get(id))
  8444. return null;
  8445. return t.add(c);
  8446. },
  8447. createSeparator : function(cc) {
  8448. var cls = cc || this._cls.separator || tinymce.ui.Separator;
  8449. return new cls();
  8450. },
  8451. setControlType : function(n, c) {
  8452. return this._cls[n.toLowerCase()] = c;
  8453. },
  8454. destroy : function() {
  8455. each(this.controls, function(c) {
  8456. c.destroy();
  8457. });
  8458. this.controls = null;
  8459. }
  8460. });
  8461. })();
  8462. /* file:jscripts/tiny_mce/classes/WindowManager.js */
  8463. (function() {
  8464. var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each, isIE = tinymce.isIE, isOpera = tinymce.isOpera;
  8465. tinymce.create('tinymce.WindowManager', {
  8466. WindowManager : function(ed) {
  8467. var t = this;
  8468. t.editor = ed;
  8469. t.onOpen = new Dispatcher(t);
  8470. t.onClose = new Dispatcher(t);
  8471. t.params = {};
  8472. t.features = {};
  8473. },
  8474. open : function(s, p) {
  8475. var t = this, f = '', x, y, mo = t.editor.settings.dialog_type == 'modal', w, sw, sh, vp = tinymce.DOM.getViewPort(), u;
  8476. // Default some options
  8477. s = s || {};
  8478. p = p || {};
  8479. sw = isOpera ? vp.w : screen.width; // Opera uses windows inside the Opera window
  8480. sh = isOpera ? vp.h : screen.height;
  8481. s.name = s.name || 'mc_' + new Date().getTime();
  8482. s.width = parseInt(s.width || 320);
  8483. s.height = parseInt(s.height || 240);
  8484. s.resizable = true;
  8485. s.left = s.left || parseInt(sw / 2.0) - (s.width / 2.0);
  8486. s.top = s.top || parseInt(sh / 2.0) - (s.height / 2.0);
  8487. p.inline = false;
  8488. p.mce_width = s.width;
  8489. p.mce_height = s.height;
  8490. p.mce_auto_focus = s.auto_focus;
  8491. if (mo) {
  8492. if (isIE) {
  8493. s.center = true;
  8494. s.help = false;
  8495. s.dialogWidth = s.width + 'px';
  8496. s.dialogHeight = s.height + 'px';
  8497. s.scroll = s.scrollbars || false;
  8498. }
  8499. }
  8500. // Build features string
  8501. each(s, function(v, k) {
  8502. if (tinymce.is(v, 'boolean'))
  8503. v = v ? 'yes' : 'no';
  8504. if (!/^(name|url)$/.test(k)) {
  8505. if (isIE && mo)
  8506. f += (f ? ';' : '') + k + ':' + v;
  8507. else
  8508. f += (f ? ',' : '') + k + '=' + v;
  8509. }
  8510. });
  8511. t.features = s;
  8512. t.params = p;
  8513. t.onOpen.dispatch(t, s, p);
  8514. u = s.url || s.file;
  8515. if (tinymce.relaxedDomain)
  8516. u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
  8517. u = tinymce._addVer(u);
  8518. try {
  8519. if (isIE && mo) {
  8520. w = 1;
  8521. window.showModalDialog(u, window, f);
  8522. } else
  8523. w = window.open(u, s.name, f);
  8524. } catch (ex) {
  8525. // Ignore
  8526. }
  8527. if (!w)
  8528. alert(t.editor.getLang('popup_blocked'));
  8529. },
  8530. close : function(w) {
  8531. w.close();
  8532. this.onClose.dispatch(this);
  8533. },
  8534. createInstance : function(cl, a, b, c, d, e) {
  8535. var f = tinymce.resolve(cl);
  8536. return new f(a, b, c, d, e);
  8537. },
  8538. confirm : function(t, cb, s, w) {
  8539. w = w || window;
  8540. cb.call(s || this, w.confirm(this._decode(this.editor.getLang(t, t))));
  8541. },
  8542. alert : function(tx, cb, s, w) {
  8543. var t = this;
  8544. w = w || window;
  8545. w.alert(t._decode(t.editor.getLang(tx, tx)));
  8546. if (cb)
  8547. cb.call(s || t);
  8548. },
  8549. // Internal functions
  8550. _decode : function(s) {
  8551. return tinymce.DOM.decode(s).replace(/\\n/g, '\n');
  8552. }
  8553. });
  8554. }());