kindeditor-all-min.js 265 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011
  1. /* KindEditor 4.1.11 (2016-03-31), Copyright (C) kindsoft.net, Licence: http://kindeditor.net/license.php */
  2. !
  3. function(window, undefined) {
  4. function _isArray(a) {
  5. return a ? "[object Array]" === Object.prototype.toString.call(a) : !1
  6. }
  7. function _isFunction(a) {
  8. return a ? "[object Function]" === Object.prototype.toString.call(a) : !1
  9. }
  10. function _inArray(a, b) {
  11. for (var c = 0,
  12. d = b.length; d > c; c++) if (a === b[c]) return c;
  13. return - 1
  14. }
  15. function _each(a, b) {
  16. if (_isArray(a)) for (var c = 0,
  17. d = a.length; d > c && b.call(a[c], c, a[c]) !== !1; c++);
  18. else for (var e in a) if (a.hasOwnProperty(e) && b.call(a[e], e, a[e]) === !1) break
  19. }
  20. function _trim(a) {
  21. return a.replace(/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g, "")
  22. }
  23. function _inString(a, b, c) {
  24. return c = c === undefined ? ",": c,
  25. (c + b + c).indexOf(c + a + c) >= 0
  26. }
  27. function _addUnit(a, b) {
  28. return b = b || "px",
  29. a && /^-?\d+(?:\.\d+)?$/.test(a) ? a + b: a
  30. }
  31. function _removeUnit(a) {
  32. var b;
  33. return a && (b = /(\d+)/.exec(a)) ? parseInt(b[1], 10) : 0
  34. }
  35. function _escape(a) {
  36. return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
  37. }
  38. function _unescape(a) {
  39. return a.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&")
  40. }
  41. function _toCamel(a) {
  42. var b = a.split("-");
  43. return a = "",
  44. _each(b,
  45. function(b, c) {
  46. a += b > 0 ? c.charAt(0).toUpperCase() + c.substr(1) : c
  47. }),
  48. a
  49. }
  50. function _toHex(a) {
  51. function b(a) {
  52. var b = parseInt(a, 10).toString(16).toUpperCase();
  53. return b.length > 1 ? b: "0" + b
  54. }
  55. return a.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/gi,
  56. function(a, c, d, e) {
  57. return "#" + b(c) + b(d) + b(e)
  58. })
  59. }
  60. function _toMap(a, b) {
  61. b = b === undefined ? ",": b;
  62. var c, d = {},
  63. e = _isArray(a) ? a: a.split(b);
  64. return _each(e,
  65. function(a, b) {
  66. if (c = /^(\d+)\.\.(\d+)$/.exec(b)) for (var e = parseInt(c[1], 10); e <= parseInt(c[2], 10); e++) d[e.toString()] = !0;
  67. else d[b] = !0
  68. }),
  69. d
  70. }
  71. function _toArray(a, b) {
  72. return Array.prototype.slice.call(a, b || 0)
  73. }
  74. function _undef(a, b) {
  75. return a === undefined ? b: a
  76. }
  77. function _invalidUrl(a) {
  78. return ! a || /[<>"]/.test(a)
  79. }
  80. function _addParam(a, b) {
  81. return a.indexOf("?") >= 0 ? a + "&" + b: a + "?" + b
  82. }
  83. function _extend(a, b, c) {
  84. c || (c = b, b = null);
  85. var d;
  86. if (b) {
  87. var e = function() {};
  88. e.prototype = b.prototype,
  89. d = new e,
  90. _each(c,
  91. function(a, b) {
  92. d[a] = b
  93. })
  94. } else d = c;
  95. d.constructor = a,
  96. a.prototype = d,
  97. a.parent = b ? b.prototype: null
  98. }
  99. function _json(text) {
  100. var match; (match = /\{[\s\S]*\}|\[[\s\S]*\]/.exec(text)) && (text = match[0]);
  101. var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
  102. if (cx.lastIndex = 0, cx.test(text) && (text = text.replace(cx,
  103. function(a) {
  104. return "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice( - 4)
  105. })), /^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) return eval("(" + text + ")");
  106. throw "JSON parse error"
  107. }
  108. function _getBasePath() {
  109. for (var a, b = document.getElementsByTagName("script"), c = 0, d = b.length; d > c; c++) if (a = b[c].src || "", /kindeditor[\w\-\.]*\.js/.test(a)) return a.substring(0, a.lastIndexOf("/") + 1);
  110. return ""
  111. }
  112. function _bindEvent(a, b, c) {
  113. a.addEventListener ? a.addEventListener(b, c, _useCapture) : a.attachEvent && a.attachEvent("on" + b, c)
  114. }
  115. function _unbindEvent(a, b, c) {
  116. a.removeEventListener ? a.removeEventListener(b, c, _useCapture) : a.detachEvent && a.detachEvent("on" + b, c)
  117. }
  118. function KEvent(a, b) {
  119. this.init(a, b)
  120. }
  121. function _getId(a) {
  122. return a[_eventExpendo] || null
  123. }
  124. function _setId(a) {
  125. return a[_eventExpendo] = ++_eventId,
  126. _eventId
  127. }
  128. function _removeId(a) {
  129. try {
  130. delete a[_eventExpendo]
  131. } catch(b) {
  132. a.removeAttribute && a.removeAttribute(_eventExpendo)
  133. }
  134. }
  135. function _bind(a, b, c) {
  136. if (b.indexOf(",") >= 0) return void _each(b.split(","),
  137. function() {
  138. _bind(a, this, c)
  139. });
  140. var d = _getId(a);
  141. d || (d = _setId(a)),
  142. _eventData[d] === undefined && (_eventData[d] = {});
  143. var e = _eventData[d][b];
  144. e && e.length > 0 ? _unbindEvent(a, b, e[0]) : (_eventData[d][b] = [], _eventData[d].el = a),
  145. e = _eventData[d][b],
  146. 0 === e.length && (e[0] = function(b) {
  147. var c = b ? new KEvent(a, b) : undefined;
  148. _each(e,
  149. function(b, d) {
  150. b > 0 && d && d.call(a, c)
  151. })
  152. }),
  153. _inArray(c, e) < 0 && e.push(c),
  154. _bindEvent(a, b, e[0])
  155. }
  156. function _unbind(a, b, c) {
  157. if (b && b.indexOf(",") >= 0) return void _each(b.split(","),
  158. function() {
  159. _unbind(a, this, c)
  160. });
  161. var d = _getId(a);
  162. if (d) {
  163. if (b === undefined) return void(d in _eventData && (_each(_eventData[d],
  164. function(b, c) {
  165. "el" != b && c.length > 0 && _unbindEvent(a, b, c[0])
  166. }), delete _eventData[d], _removeId(a)));
  167. if (_eventData[d]) {
  168. var e = _eventData[d][b];
  169. if (e && e.length > 0) {
  170. c === undefined ? (_unbindEvent(a, b, e[0]), delete _eventData[d][b]) : (_each(e,
  171. function(a, b) {
  172. a > 0 && b === c && e.splice(a, 1)
  173. }), 1 == e.length && (_unbindEvent(a, b, e[0]), delete _eventData[d][b]));
  174. var f = 0;
  175. _each(_eventData[d],
  176. function() {
  177. f++
  178. }),
  179. 2 > f && (delete _eventData[d], _removeId(a))
  180. }
  181. }
  182. }
  183. }
  184. function _fire(a, b) {
  185. if (b.indexOf(",") >= 0) return void _each(b.split(","),
  186. function() {
  187. _fire(a, this)
  188. });
  189. var c = _getId(a);
  190. if (c) {
  191. var d = _eventData[c][b];
  192. _eventData[c] && d && d.length > 0 && d[0]()
  193. }
  194. }
  195. function _ctrl(a, b, c) {
  196. b = /^\d{2,}$/.test(b) ? b: b.toUpperCase().charCodeAt(0),
  197. _bind(a, "keydown",
  198. function(d) { ! d.ctrlKey || d.which != b || d.shiftKey || d.altKey || (c.call(a), d.stop())
  199. })
  200. }
  201. function _ready(a) {
  202. function b() {
  203. e || (e = !0, a(KindEditor), _readyFinished = !0)
  204. }
  205. function c() {
  206. if (!e) {
  207. try {
  208. document.documentElement.doScroll("left")
  209. } catch(a) {
  210. return void setTimeout(c, 100)
  211. }
  212. b()
  213. }
  214. }
  215. function d() {
  216. "complete" === document.readyState && b()
  217. }
  218. if (_readyFinished) return void a(KindEditor);
  219. var e = !1;
  220. if (document.addEventListener) _bind(document, "DOMContentLoaded", b);
  221. else if (document.attachEvent) {
  222. _bind(document, "readystatechange", d);
  223. var f = !1;
  224. try {
  225. f = null == window.frameElement
  226. } catch(g) {}
  227. document.documentElement.doScroll && f && c()
  228. }
  229. _bind(window, "load", b)
  230. }
  231. function _getCssList(a) {
  232. for (var b, c = {},
  233. d = /\s*([\w\-]+)\s*:([^;]*)(;|$)/g; b = d.exec(a);) {
  234. var e = _trim(b[1].toLowerCase()),
  235. f = _trim(_toHex(b[2]));
  236. c[e] = f
  237. }
  238. return c
  239. }
  240. function _getAttrList(a) {
  241. for (var b, c = {},
  242. d = /\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g; b = d.exec(a);) {
  243. var e = (b[1] || b[2] || b[4] || b[6]).toLowerCase(),
  244. f = (b[2] ? b[3] : b[4] ? b[5] : b[7]) || "";
  245. c[e] = f
  246. }
  247. return c
  248. }
  249. function _addClassToTag(a, b) {
  250. return a = /\s+class\s*=/.test(a) ? a.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/,
  251. function(a, c, d, e) {
  252. return (" " + d + " ").indexOf(" " + b + " ") < 0 ? "" === d ? c + b + e: c + d + " " + b + e: a
  253. }) : a.substr(0, a.length - 1) + ' class="' + b + '">'
  254. }
  255. function _formatCss(a) {
  256. var b = "";
  257. return _each(_getCssList(a),
  258. function(a, c) {
  259. b += a + ":" + c + ";"
  260. }),
  261. b
  262. }
  263. function _formatUrl(a, b, c, d) {
  264. function e(a) {
  265. for (var b = a.split("/"), c = [], d = 0, e = b.length; e > d; d++) {
  266. var f = b[d];
  267. ".." == f ? c.length > 0 && c.pop() : "" !== f && "." != f && c.push(f)
  268. }
  269. return "/" + c.join("/")
  270. }
  271. function f(b, c) {
  272. if (a.substr(0, b.length) === b) {
  273. for (var e = [], g = 0; c > g; g++) e.push("..");
  274. var i = ".";
  275. return e.length > 0 && (i += "/" + e.join("/")),
  276. "/" == d && (i += "/"),
  277. i + a.substr(b.length)
  278. }
  279. return (h = /^(.*)\//.exec(b)) ? f(h[1], ++c) : void 0
  280. }
  281. if (b = _undef(b, "").toLowerCase(), "data:" != a.substr(0, 5) && (a = a.replace(/([^:])\/\//g, "$1/")), _inArray(b, ["absolute", "relative", "domain"]) < 0) return a;
  282. if (c = c || location.protocol + "//" + location.host, d === undefined) {
  283. var g = location.pathname.match(/^(\/.*)\//);
  284. d = g ? g[1] : ""
  285. }
  286. var h;
  287. if (h = /^(\w+:\/\/[^\/]*)/.exec(a)) {
  288. if (h[1] !== c) return a
  289. } else if (/^\w+:/.test(a)) return a;
  290. return /^\//.test(a) ? a = c + e(a.substr(1)) : /^\w+:\/\//.test(a) || (a = c + e(d + "/" + a)),
  291. "relative" === b ? a = f(c + d, 0).substr(2) : "absolute" === b && a.substr(0, c.length) === c && (a = a.substr(c.length)),
  292. a
  293. }
  294. function
  295. // _formatHtml(a,b,c,d,e){null==a&&(a=""),c=c||"",d=_undef(d,!1),e=_undef(e,"
  296. // ");var
  297. // f="xx-small,x-small,small,medium,large,x-large,xx-large".split(",");a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/gi,function(a,b,c,d){return
  298. // b+c.replace(/<(?:br|br\s[^>]*)>/gi,"\n")+d}),a=a.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/gi,"</p>"),a=a.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/gi,"$1<br
  299. // />$2"),a=a.replace(/\u200B/g,""),a=a.replace(/\u00A9/g,"&copy;"),a=a.replace(/\u00AE/g,"&reg;"),a=a.replace(/\u2003/g,"&emsp;"),a=a.replace(/\u3000/g,"&emsp;"),a=a.replace(/<[^>]+/g,function(a){return
  300. // a.replace(/\s+/g,"
  301. // ")});var
  302. // g={};b&&(_each(b,function(a,b){for(var
  303. // c=a.split(","),d=0,e=c.length;e>d;d++)g[c[d]]=_toMap(b)}),g.script||(a=a.replace(/(<(?:script|script\s[^>]*)>)([\s\S]*?)(<\/script>)/gi,"")),g.style||(a=a.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/gi,"")));var
  304. // h=/(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g,i=[];return
  305. // a=a.replace(h,function(a,h,j,k,l,m,n){var
  306. // o=a,p=h||"",q=j||"",r=k.toLowerCase(),s=l||"",t=m?"
  307. // "+m:"",u=n||"";if(b&&!g[r])return"";if(""===t&&_SINGLE_TAG_MAP[r]&&(t="
  308. // /"),_INLINE_TAG_MAP[r]&&(p&&(p="
  309. // "),u&&(u="
  310. // ")),_PRE_TAG_MAP[r]&&(q?u="\n":p="\n"),d&&"br"==r&&(u="\n"),_BLOCK_TAG_MAP[r]&&!_PRE_TAG_MAP[r])if(d){q&&i.length>0&&i[i.length-1]===r?i.pop():i.push(r),p="\n",u="\n";for(var
  311. // v=0,w=q?i.length:i.length-1;w>v;v++)p+=e,q||(u+=e);t?i.pop():q||(u+=e)}else
  312. // p=u="";if(""!==s){var
  313. // x=_getAttrList(o);if("font"===r){var
  314. // y={},z="";_each(x,function(a,b){"color"===a&&(y.color=b,delete
  315. // x[a]),"size"===a&&(y["font-size"]=f[parseInt(b,10)-1]||"",delete
  316. // x[a]),"face"===a&&(y["font-family"]=b,delete
  317. // x[a]),"style"===a&&(z=b)}),z&&!/;$/.test(z)&&(z+=";"),_each(y,function(a,b){""!==b&&(/\s/.test(b)&&(b="'"+b+"'"),z+=a+":"+b+";")}),x.style=z}_each(x,function(a,d){if(_FILL_ATTR_MAP[a]&&(x[a]=a),_inArray(a,["src","href"])>=0&&(x[a]=_formatUrl(d,c)),(b&&"style"!==a&&!g[r]["*"]&&!g[r][a]||"body"===r&&"contenteditable"===a||/^kindeditor_\d+$/.test(a))&&delete
  318. // x[a],"style"===a&&""!==d){var
  319. // e=_getCssList(d);_each(e,function(a){!b||g[r].style||g[r]["."+a]||delete
  320. // e[a]});var
  321. // f="";_each(e,function(a,b){f+=a+":"+b+";"}),x.style=f}}),s="",_each(x,function(a,b){("style"!==a||""!==b)&&(b=b.replace(/"/g,"&quot;"),s+="
  322. // "+a+'="'+b+'"')})}return"font"===r&&(r="span"),p+"<"+q+r+s+t+">"+u}),a=a.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/gi,function(a,b,c,d){return
  323. // b+c.replace(/\n/g,'<span
  324. // id="__kindeditor_pre_newline__">\n')+d}),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/<span
  325. // id="__kindeditor_pre_newline__">\n/g,"\n"),_trim(a)}function
  326. // _clearMsWord(a,b){return
  327. // a=a.replace(/<meta[\s\S]*?>/gi,"").replace(/<![\s\S]*?>/gi,"").replace(/<style[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<w:[^>]+>[\s\S]*?<\/w:[^>]+>/gi,"").replace(/<o:[^>]+>[\s\S]*?<\/o:[^>]+>/gi,"").replace(/<xml>[\s\S]*?<\/xml>/gi,"").replace(/<(?:table|td)[^>]*>/gi,function(a){return
  328. // a.replace(/border-bottom:([#\w\s]+)/gi,"border:$1")}),_formatHtml(a,b)}function
  329. // _mediaType(a){return/\.(rm|rmvb)(\?|$)/i.test(a)?"audio/x-pn-realaudio-plugin":/\.(swf|flv)(\?|$)/i.test(a)?"application/x-shockwave-flash":"video/x-ms-asf-plugin"}function
  330. // _mediaClass(a){return/realaudio/i.test(a)?"ke-rm":/flash/i.test(a)?"ke-flash":"ke-media"}function
  331. // _mediaAttrs(a){return
  332. // _getAttrList(unescape(a))}function
  333. // _mediaEmbed(a){var
  334. // b="<embed
  335. // ";return
  336. // _each(a,function(a,c){b+=a+'="'+c+'"
  337. // '}),b+="/>"}function
  338. // _mediaImg(a,b){var
  339. // c=b.width,d=b.height,e=b.type||_mediaType(b.src),f=_mediaEmbed(b),g="";/\D/.test(c)?g+="width:"+c+";":c>0&&(g+="width:"+c+"px;"),/\D/.test(d)?g+="height:"+d+";":d>0&&(g+="height:"+d+"px;");var
  340. // h='<img
  341. // class="'+_mediaClass(e)+'"
  342. // src="'+a+'"
  343. // ';return""!==g&&(h+='style="'+g+'"
  344. // '),h+='data-ke-tag="'+escape(f)+'"
  345. // alt=""
  346. // />'}function
  347. // _tmpl(a,b){var
  348. // c=new
  349. // Function("obj","var
  350. // p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g,"
  351. // ").split("<%").join("
  352. // ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split("
  353. // ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return
  354. // p.join('');");return
  355. // b?c(b):c}function
  356. // _contains(a,b){if(9==a.nodeType&&9!=b.nodeType)return!0;for(;b=b.parentNode;)if(b==a)return!0;return!1}function
  357. // _getAttr(a,b){b=b.toLowerCase();var
  358. // c=null;if(_GET_SET_ATTRIBUTE||"script"==a.nodeName.toLowerCase())try{c=a.getAttribute(b,2)}catch(d){c=a.getAttribute(b,1)}else{var
  359. // e=a.ownerDocument.createElement("div");e.appendChild(a.cloneNode(!1));var
  360. // f=_getAttrList(_unescape(e.innerHTML));b
  361. // in
  362. // f&&(c=f[b])}return"style"===b&&null!==c&&(c=_formatCss(c)),c}function
  363. // _queryAll(a,b){function
  364. // c(a){return"string"!=typeof
  365. // a?a:a.replace(/([^\w\-])/g,"\\$1")}function
  366. // d(a){return
  367. // a.replace(/\\/g,"")}function
  368. // e(a,b){return"*"===a||a.toLowerCase()===c(b.toLowerCase())}function
  369. // f(a,b,c){var
  370. // f=[],g=c.ownerDocument||c,h=g.getElementById(d(a));return
  371. // h&&e(b,h.nodeName)&&_contains(c,h)&&f.push(h),f}function
  372. // g(a,b,c){var
  373. // f,g,h,i,j=c.ownerDocument||c,k=[];if(c.getElementsByClassName)for(f=c.getElementsByClassName(d(a)),g=0,h=f.length;h>g;g++)i=f[g],e(b,i.nodeName)&&k.push(i);else
  374. // if(j.querySelectorAll)for(f=j.querySelectorAll(("#document"!==c.nodeName?c.nodeName+"
  375. // ":"")+b+"."+a),g=0,h=f.length;h>g;g++)i=f[g],_contains(c,i)&&k.push(i);else
  376. // for(f=c.getElementsByTagName(b),a="
  377. // "+a+"
  378. // ",g=0,h=f.length;h>g;g++)if(i=f[g],1==i.nodeType){var
  379. // l=i.className;l&&("
  380. // "+l+"
  381. // ").indexOf(a)>-1&&k.push(i)}return
  382. // k}function
  383. // h(a,b,c){for(var
  384. // f,g=[],h=c.ownerDocument||c,i=h.getElementsByName(d(a)),j=0,k=i.length;k>j;j++)f=i[j],e(b,f.nodeName)&&_contains(c,f)&&null!==f.getAttribute("name")&&g.push(f);return
  385. // g}function
  386. // i(a,b,d,e){for(var
  387. // f,g=[],h=e.getElementsByTagName(d),i=0,j=h.length;j>i;i++)f=h[i],1==f.nodeType&&(null===b?null!==_getAttr(f,a)&&g.push(f):b===c(_getAttr(f,a))&&g.push(f));return
  388. // g}function
  389. // j(a,b){var
  390. // c,d=[];c=/^((?:\\.|[^.#\s\[<>])+)/.exec(a);var
  391. // e=c?c[1]:"*";if(c=/#((?:[\w\-]|\\.)+)$/.exec(a))d=f(c[1],e,b);else
  392. // if(c=/\.((?:[\w\-]|\\.)+)$/.exec(a))d=g(c[1],e,b);else
  393. // if(c=/\[((?:[\w\-]|\\.)+)\]/.exec(a))d=i(c[1].toLowerCase(),null,e,b);else
  394. // if(c=/\[((?:[\w\-]|\\.)+)\s*=\s*['"]?((?:\\.|[^'"]+)+)['"]?\]/.exec(a)){var
  395. // j=c[1].toLowerCase(),k=c[2];d="id"===j?f(k,e,b):"class"===j?g(k,e,b):"name"===j?h(k,e,b):i(j,k,e,b)}else
  396. // for(var
  397. // l,m=b.getElementsByTagName(e),n=0,o=m.length;o>n;n++)l=m[n],1==l.nodeType&&d.push(l);return
  398. // d}var
  399. // k=a.split(",");if(k.length>1){var
  400. // l=[];return
  401. // _each(k,function(){_each(_queryAll(this,b),function(){_inArray(this,l)<0&&l.push(this)})}),l}b=b||document;for(var
  402. // m,n=[],o=/((?:\\.|[^\s>])+|[\s>])/g;m=o.exec(a);)"
  403. // "!==m[1]&&n.push(m[1]);var
  404. // p=[];if(1==n.length)return
  405. // j(n[0],b);var
  406. // q,r,s,t,u,v,w,x,y,z,A=!1;for(v=0,lenth=n.length;v<lenth;v++)if(q=n[v],">"!==q){if(v>0){for(r=[],w=0,y=p.length;y>w;w++)for(t=p[w],s=j(q,t),x=0,z=s.length;z>x;x++)u=s[x],A?t===u.parentNode&&r.push(u):r.push(u);p=r}else
  407. // p=j(q,b);if(0===p.length)return[]}else
  408. // A=!0;return
  409. // p}function
  410. // _query(a,b){var
  411. // c=_queryAll(a,b);return
  412. // c.length>0?c[0]:null}function
  413. // _get(a){return
  414. // K(a)[0]}function
  415. // _getDoc(a){return
  416. // a?a.ownerDocument||a.document||a:document}function
  417. // _getWin(a){if(!a)return
  418. // window;var
  419. // b=_getDoc(a);return
  420. // b.parentWindow||b.defaultView}function
  421. // _setHtml(a,b){if(1==a.nodeType){var
  422. // c=_getDoc(a);try{a.innerHTML='<img
  423. // id="__kindeditor_temp_tag__"
  424. // width="0"
  425. // height="0"
  426. // style="display:none;"
  427. // />'+b;var
  428. // d=c.getElementById("__kindeditor_temp_tag__");d.parentNode.removeChild(d)}catch(e){K(a).empty(),K("@"+b,c).each(function(){a.appendChild(this)})}}}function
  429. // _hasClass(a,b){return
  430. // _inString(b,a.className,"
  431. // ")}function
  432. // _setAttr(a,b,c){_IE&&8>_V&&"class"==b.toLowerCase()&&(b="className"),a.setAttribute(b,""+c)}function
  433. // _removeAttr(a,b){_IE&&8>_V&&"class"==b.toLowerCase()&&(b="className"),_setAttr(a,b,""),a.removeAttribute(b)}function
  434. // _getNodeName(a){return
  435. // a&&a.nodeName?a.nodeName.toLowerCase():""}function
  436. // _computedCss(a,b){var
  437. // c=_getWin(a),d=_toCamel(b),e="";if(c.getComputedStyle){var
  438. // f=c.getComputedStyle(a,null);e=f[d]||f.getPropertyValue(b)||a.style[d]}else
  439. // a.currentStyle&&(e=a.currentStyle[d]||a.style[d]);return
  440. // e}function
  441. // _hasVal(a){return!!_VALUE_TAG_MAP[_getNodeName(a)]}function
  442. // _docElement(a){return
  443. // a=a||document,_QUIRKS?a.body:a.documentElement}function
  444. // _docHeight(a){var
  445. // b=_docElement(a);return
  446. // Math.max(b.scrollHeight,b.clientHeight)}function
  447. // _docWidth(a){var
  448. // b=_docElement(a);return
  449. // Math.max(b.scrollWidth,b.clientWidth)}function
  450. // _getScrollPos(a){a=a||document;var
  451. // b,c;return
  452. // _IE||_NEWIE||_OPERA?(b=_docElement(a).scrollLeft,c=_docElement(a).scrollTop):(b=_getWin(a).scrollX,c=_getWin(a).scrollY),{x:b,y:c}}function
  453. // KNode(a){this.init(a)}function
  454. // _updateCollapsed(a){return
  455. // a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset,a}function
  456. // _copyAndDelete(a,b,c){function
  457. // d(d,e,f){var
  458. // g,i=d.nodeValue.length;if(b){var
  459. // j=d.cloneNode(!0);g=e>0?j.splitText(e):j,i>f&&g.splitText(f-e)}if(c){var
  460. // k=d;if(e>0&&(k=d.splitText(e),a.setStart(d,e)),i>f){var
  461. // l=k.splitText(f-e);a.setEnd(l,0)}h.push(k)}return
  462. // g}function
  463. // e(){c&&a.up().collapse(!0);for(var
  464. // b=0,d=h.length;d>b;b++){var
  465. // e=h[b];e.parentNode&&e.parentNode.removeChild(e)}}function
  466. // f(e,n){for(var
  467. // o,p=e.firstChild;p;){var
  468. // q=new
  469. // KRange(g).selectNode(p);if(j=q.compareBoundaryPoints(_START_TO_END,a),j>=0&&0>=k&&(k=q.compareBoundaryPoints(_START_TO_START,a)),k>=0&&0>=l&&(l=q.compareBoundaryPoints(_END_TO_END,a)),l>=0&&0>=m&&(m=q.compareBoundaryPoints(_END_TO_START,a)),m>=0)return!1;if(o=p.nextSibling,j>0)if(1==p.nodeType)if(k>=0&&0>=l)b&&n.appendChild(p.cloneNode(!0)),c&&h.push(p);else{var
  470. // r;if(b&&(r=p.cloneNode(!1),n.appendChild(r)),f(p,r)===!1)return!1}else
  471. // if(3==p.nodeType){var
  472. // s;if(s=p==i.startContainer?d(p,i.startOffset,p.nodeValue.length):p==i.endContainer?d(p,0,i.endOffset):d(p,0,p.nodeValue.length),b)try{n.appendChild(s)}catch(t){}}p=o}}var
  473. // g=a.doc,h=[],i=a.cloneRange().down(),j=-1,k=-1,l=-1,m=-1,n=a.commonAncestor(),o=g.createDocumentFragment();if(3==n.nodeType){var
  474. // p=d(n,a.startOffset,a.endOffset);return
  475. // b&&o.appendChild(p),e(),b?o:a}f(n,o),c&&a.up().collapse(!0);for(var
  476. // q=0,r=h.length;r>q;q++){var
  477. // s=h[q];s.parentNode&&s.parentNode.removeChild(s)}return
  478. // b?o:a}function
  479. // _moveToElementText(a,b){for(var
  480. // c=b;c;){var
  481. // d=K(c);if("marquee"==d.name||"select"==d.name)return;c=c.parentNode}try{a.moveToElementText(b)}catch(e){}}function
  482. // _getStartEnd(a,b){var
  483. // c=a.parentElement().ownerDocument,d=a.duplicate();d.collapse(b);var
  484. // e=d.parentElement(),f=e.childNodes;if(0===f.length)return{node:e.parentNode,offset:K(e).index()};var
  485. // g=c,h=0,i=-1,j=a.duplicate();_moveToElementText(j,e);for(var
  486. // k=0,l=f.length;l>k;k++){var
  487. // m=f[k];if(i=j.compareEndPoints("StartToStart",d),0===i)return{node:m.parentNode,offset:k};if(1==m.nodeType){var
  488. // n,o=a.duplicate(),p=K(m),q=m;p.isControl()&&(n=c.createElement("span"),p.after(n),q=n,h+=p.text().replace(/\r\n|\n|\r/g,"").length),_moveToElementText(o,q),j.setEndPoint("StartToEnd",o),i>0?h+=o.text.replace(/\r\n|\n|\r/g,"").length:h=0,n&&K(n).remove()}else
  489. // 3==m.nodeType&&(j.moveStart("character",m.nodeValue.length),h+=m.nodeValue.length);0>i&&(g=m)}if(0>i&&1==g.nodeType)return{node:e,offset:K(e.lastChild).index()+1};if(i>0)for(;g.nextSibling&&1==g.nodeType;)g=g.nextSibling;if(j=a.duplicate(),_moveToElementText(j,e),j.setEndPoint("StartToEnd",d),h-=j.text.replace(/\r\n|\n|\r/g,"").length,i>0&&3==g.nodeType)for(var
  490. // r=g.previousSibling;r&&3==r.nodeType;)h-=r.nodeValue.length,r=r.previousSibling;return{node:g,offset:h}}function
  491. // _getEndRange(a,b){var
  492. // c=a.ownerDocument||a,d=c.body.createTextRange();if(c==a)return
  493. // d.collapse(!0),d;if(1==a.nodeType&&a.childNodes.length>0){var
  494. // e,f,g=a.childNodes;if(0===b?(f=g[0],e=!0):(f=g[b-1],e=!1),!f)return
  495. // d;if("head"===K(f).name)return
  496. // 1===b&&(e=!0),2===b&&(e=!1),d.collapse(e),d;if(1==f.nodeType){var
  497. // h,i=K(f);return
  498. // i.isControl()&&(h=c.createElement("span"),e?i.before(h):i.after(h),f=h),_moveToElementText(d,f),d.collapse(e),h&&K(h).remove(),d}a=f,b=e?0:f.nodeValue.length}var
  499. // j=c.createElement("span");return
  500. // K(a).before(j),_moveToElementText(d,j),d.moveStart("character",b),K(j).remove(),d}function
  501. // _toRange(a){function
  502. // b(a){"tr"==K(a.node).name&&(a.node=a.node.cells[a.offset],a.offset=0)}var
  503. // c,d;if(_IERANGE){if(a.item)return
  504. // c=_getDoc(a.item(0)),d=new
  505. // KRange(c),d.selectNode(a.item(0)),d;c=a.parentElement().ownerDocument;var
  506. // e=_getStartEnd(a,!0),f=_getStartEnd(a,!1);return
  507. // b(e),b(f),d=new
  508. // KRange(c),d.setStart(e.node,e.offset),d.setEnd(f.node,f.offset),d}var
  509. // g=a.startContainer;return
  510. // c=g.ownerDocument||g,d=new
  511. // KRange(c),d.setStart(g,a.startOffset),d.setEnd(a.endContainer,a.endOffset),d}function
  512. // KRange(a){this.init(a)}function
  513. // _range(a){return
  514. // a.nodeName?new
  515. // KRange(a):a.constructor===KRange?a:_toRange(a)}function
  516. // _nativeCommand(a,b,c){try{a.execCommand(b,!1,c)}catch(d){}}function
  517. // _nativeCommandValue(a,b){var
  518. // c="";try{c=a.queryCommandValue(b)}catch(d){}return"string"!=typeof
  519. // c&&(c=""),c}function
  520. // _getSel(a){var
  521. // b=_getWin(a);return
  522. // _IERANGE?a.selection:b.getSelection()}function
  523. // _getRng(a){var
  524. // b,c=_getSel(a);try{b=c.rangeCount>0?c.getRangeAt(0):c.createRange()}catch(d){}return!_IERANGE||b&&(b.item||b.parentElement().ownerDocument===a)?b:null}function
  525. // _singleKeyMap(a){var
  526. // b,c,d={};return
  527. // _each(a,function(a,e){b=a.split(",");for(var
  528. // f=0,g=b.length;g>f;f++)c=b[f],d[c]=e}),d}function
  529. // _hasAttrOrCss(a,b){return
  530. // _hasAttrOrCssByKey(a,b,"*")||_hasAttrOrCssByKey(a,b)}function
  531. // _hasAttrOrCssByKey(a,b,c){if(c=c||a.name,1!==a.type)return!1;var
  532. // d=_singleKeyMap(b);if(!d[c])return!1;for(var
  533. // e=d[c].split(","),f=0,g=e.length;g>f;f++){var
  534. // h=e[f];if("*"===h)return!0;var
  535. // i=/^(\.?)([^=]+)(?:=([^=]*))?$/.exec(h),j=i[1]?"css":"attr";h=i[2];var
  536. // k=i[3]||"";if(""===k&&""!==a[j](h))return!0;if(""!==k&&a[j](h)===k)return!0}return!1}function
  537. // _removeAttrOrCss(a,b){1==a.type&&(_removeAttrOrCssByKey(a,b,"*"),_removeAttrOrCssByKey(a,b))}function
  538. // _removeAttrOrCssByKey(a,b,c){if(c=c||a.name,1===a.type){var
  539. // d=_singleKeyMap(b);if(d[c]){for(var
  540. // e=d[c].split(","),f=!1,g=0,h=e.length;h>g;g++){var
  541. // i=e[g];if("*"===i){f=!0;break}var
  542. // j=/^(\.?)([^=]+)(?:=([^=]*))?$/.exec(i);i=j[2],j[1]?(i=_toCamel(i),a[0].style[i]&&(a[0].style[i]="")):a.removeAttr(i)}f&&a.remove(!0)}}}function
  543. // _getInnerNode(a){for(var
  544. // b=a;b.first();)b=b.first();return
  545. // b}function
  546. // _isEmptyNode(a){return
  547. // 1!=a.type||a.isSingle()?!1:""===a.html().replace(/<[^>]+>/g,"")}function
  548. // _mergeWrapper(a,b){a=a.clone(!0);for(var
  549. // c=_getInnerNode(a),d=a,e=!1;b;){for(;d;)d.name===b.name&&(_mergeAttrs(d,b.attr(),b.css()),e=!0),d=d.first();e||c.append(b.clone(!1)),e=!1,b=b.first()}return
  550. // a}function
  551. // _wrapNode(a,b){if(b=b.clone(!0),3==a.type)return
  552. // _getInnerNode(b).append(a.clone(!1)),a.replaceWith(b),b;for(var
  553. // c,d=a;(c=a.first())&&1==c.children().length;)a=c;c=a.first();for(var
  554. // e=a.doc.createDocumentFragment();c;)e.appendChild(c[0]),c=c.next();return
  555. // b=_mergeWrapper(d,b),e.firstChild&&_getInnerNode(b).append(e),d.replaceWith(b),b}function
  556. // _mergeAttrs(a,b,c){_each(b,function(b,c){"style"!==b&&a.attr(b,c)}),_each(c,function(b,c){a.css(b,c)})}function
  557. // _inPreElement(a){for(;a&&"body"!=a.name;){if(_PRE_TAG_MAP[a.name]||"div"==a.name&&a.hasClass("ke-script"))return!0;a=a.parent()}return!1}function
  558. // KCmd(a){this.init(a)}function
  559. // _cmd(a){if(a.nodeName){var
  560. // b=_getDoc(a);a=_range(b).selectNodeContents(b.body).collapse(!1)}return
  561. // new
  562. // KCmd(a)}function
  563. // _drag(a){var
  564. // b=a.moveEl,c=a.moveFn,d=a.clickEl||b,e=a.beforeDrag,f=a.iframeFix===undefined?!0:a.iframeFix,g=[document];f&&K("iframe").each(function(){var
  565. // a=_formatUrl(this.src||"","absolute");if(!/^https?:\/\//.test(a)){var
  566. // b;try{b=_iframeDoc(this)}catch(c){}if(b){var
  567. // d=K(this).pos();K(b).data("pos-x",d.x),K(b).data("pos-y",d.y),g.push(b)}}}),d.mousedown(function(a){function
  568. // f(a){a.preventDefault();var
  569. // b=K(_getDoc(a.target)),e=_round((b.data("pos-x")||0)+a.pageX-o),f=_round((b.data("pos-y")||0)+a.pageY-p);c.call(d,k,l,m,n,e,f)}function
  570. // h(a){a.preventDefault()}function
  571. // i(a){a.preventDefault(),K(g).unbind("mousemove",f).unbind("mouseup",i).unbind("selectstart",h),j.releaseCapture&&j.releaseCapture()}if(0===a.button||1===a.button){a.stopPropagation();var
  572. // j=d.get(),k=_removeUnit(b.css("left")),l=_removeUnit(b.css("top")),m=b.width(),n=b.height(),o=a.pageX,p=a.pageY;e&&e(),K(g).mousemove(f).mouseup(i).bind("selectstart",h),j.setCapture&&j.setCapture()}})}function
  573. // KWidget(a){this.init(a)}function
  574. // _widget(a){return
  575. // new
  576. // KWidget(a)}function
  577. // _iframeDoc(a){return
  578. // a=_get(a),a.contentDocument||a.contentWindow.document}function
  579. // _getInitHtml(a,b,c,d){var
  580. // e=[""===_direction?"<html>":'<html
  581. // dir="'+_direction+'">','<head><meta
  582. // charset="utf-8"
  583. // /><title></title>',"<style>","html
  584. // {margin:0;padding:0;}","body
  585. // {margin:0;padding:5px;}",'body,
  586. // td
  587. // {font:12px/1.5
  588. // "sans
  589. // serif",tahoma,verdana,helvetica;}',"body,
  590. // p,
  591. // div
  592. // {word-wrap:
  593. // break-word;}","p
  594. // {margin:5px
  595. // 0;}","table
  596. // {border-collapse:collapse;}","img
  597. // {border:0;}","noscript
  598. // {display:none;}","table.ke-zeroborder
  599. // td
  600. // {border:1px
  601. // dotted
  602. // #AAA;}","img.ke-flash
  603. // {","
  604. // border:1px
  605. // solid
  606. // #AAA;","
  607. // background-image:url("+a+"common/flash.gif);","
  608. // background-position:center
  609. // center;","
  610. // background-repeat:no-repeat;","
  611. // width:100px;","
  612. // height:100px;","}","img.ke-rm
  613. // {","
  614. // border:1px
  615. // solid
  616. // #AAA;","
  617. // background-image:url("+a+"common/rm.gif);","
  618. // background-position:center
  619. // center;","
  620. // background-repeat:no-repeat;","
  621. // width:100px;","
  622. // height:100px;","}","img.ke-media
  623. // {","
  624. // border:1px
  625. // solid
  626. // #AAA;","
  627. // background-image:url("+a+"common/media.gif);","
  628. // background-position:center
  629. // center;","
  630. // background-repeat:no-repeat;","
  631. // width:100px;","
  632. // height:100px;","}","img.ke-anchor
  633. // {","
  634. // border:1px
  635. // dashed
  636. // #666;","
  637. // width:16px;","
  638. // height:16px;","}",".ke-script,
  639. // .ke-noscript,
  640. // .ke-display-none
  641. // {","
  642. // display:none;","
  643. // font-size:0;","
  644. // width:0;","
  645. // height:0;","}",".ke-pagebreak
  646. // {","
  647. // border:1px
  648. // dotted
  649. // #AAA;","
  650. // font-size:0;","
  651. // height:2px;","}","</style>"];return
  652. // _isArray(c)||(c=[c]),_each(c,function(a,b){b&&e.push('<link
  653. // href="'+b+'"
  654. // rel="stylesheet"
  655. // />')}),d&&e.push("<style>"+d+"</style>"),e.push("</head><body
  656. // "+(b?'class="'+b+'"':"")+"></body></html>"),e.join("\n")}function
  657. // _elementVal(a,b){if(a.hasVal()){if(b===undefined){var
  658. // c=a.val();return
  659. // c=c.replace(/(<(?:p|p\s[^>]*)>)
  660. // *(<\/p>)/gi,"")}return
  661. // a.val(b)}return
  662. // a.html(b)}function
  663. // KEdit(a){this.init(a)}function
  664. // _edit(a){return
  665. // new
  666. // KEdit(a)}function
  667. // _selectToolbar(a,b){var
  668. // c=this,d=c.get(a);if(d){if(d.hasClass("ke-disabled"))return;b(d)}}function
  669. // KToolbar(a){this.init(a)}function
  670. // _toolbar(a){return
  671. // new
  672. // KToolbar(a)}function
  673. // KMenu(a){this.init(a)}function
  674. // _menu(a){return
  675. // new
  676. // KMenu(a)}function
  677. // KColorPicker(a){this.init(a)}function
  678. // _colorpicker(a){return
  679. // new
  680. // KColorPicker(a)}function
  681. // KUploadButton(a){this.init(a)}function
  682. // _uploadbutton(a){return
  683. // new
  684. // KUploadButton(a)}function
  685. // _createButton(a){a=a||{};var
  686. // b=a.name||"",c=K('<span
  687. // class="ke-button-common
  688. // ke-button-outer"
  689. // title="'+b+'"></span>'),d=K('<input
  690. // class="ke-button-common
  691. // ke-button"
  692. // type="button"
  693. // value="'+b+'"
  694. // />');return
  695. // a.click&&d.click(a.click),c.append(d),c}function
  696. // KDialog(a){this.init(a)}function
  697. // _dialog(a){return
  698. // new
  699. // KDialog(a)}function
  700. // _tabs(a){var
  701. // b=_widget(a),c=b.remove,d=a.afterSelect,e=b.div,f=[];e.addClass("ke-tabs").bind("contextmenu,mousedown,mousemove",function(a){a.preventDefault()});var
  702. // g=K('<ul
  703. // class="ke-tabs-ul
  704. // ke-clearfix"></ul>');return
  705. // e.append(g),b.add=function(a){var
  706. // b=K('<li
  707. // class="ke-tabs-li">'+a.title+"</li>");b.data("tab",a),f.push(b),g.append(b)},b.selectedIndex=0,b.select=function(a){b.selectedIndex=a,_each(f,function(c,d){d.unbind(),c===a?(d.addClass("ke-tabs-li-selected"),K(d.data("tab").panel).show("")):(d.removeClass("ke-tabs-li-selected").removeClass("ke-tabs-li-on").mouseover(function(){K(this).addClass("ke-tabs-li-on")}).mouseout(function(){K(this).removeClass("ke-tabs-li-on")}).click(function(){b.select(c)}),K(d.data("tab").panel).hide())}),d&&d.call(b,a)},b.remove=function(){_each(f,function(){this.remove()}),g.remove(),c.call(b)},b}function
  708. // _loadScript(a,b){var
  709. // c=document.getElementsByTagName("head")[0]||(_QUIRKS?document.body:document.documentElement),d=document.createElement("script");c.appendChild(d),d.src=a,d.charset="utf-8",d.onload=d.onreadystatechange=function(){this.readyState&&"loaded"!==this.readyState||(b&&b(),d.onload=d.onreadystatechange=null,c.removeChild(d))}}function
  710. // _chopQuery(a){var
  711. // b=a.indexOf("?");return
  712. // b>0?a.substr(0,b):a}function
  713. // _loadStyle(a){for(var
  714. // b=document.getElementsByTagName("head")[0]||(_QUIRKS?document.body:document.documentElement),c=document.createElement("link"),d=_chopQuery(_formatUrl(a,"absolute")),e=K('link[rel="stylesheet"]',b),f=0,g=e.length;g>f;f++)if(_chopQuery(_formatUrl(e[f].href,"absolute"))===d)return;b.appendChild(c),c.href=a,c.rel="stylesheet"}function
  715. // _ajax(a,b,c,d,e){c=c||"GET",e=e||"json";var
  716. // f=window.XMLHttpRequest?new
  717. // window.XMLHttpRequest:new
  718. // ActiveXObject("Microsoft.XMLHTTP");if(f.open(c,a,!0),f.onreadystatechange=function(){if(4==f.readyState&&200==f.status&&b){var
  719. // a=_trim(f.responseText);"json"==e&&(a=_json(a)),b(a)}},"POST"==c){var
  720. // g=[];_each(d,function(a,b){g.push(encodeURIComponent(a)+"="+encodeURIComponent(b))});try{f.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(h){}f.send(g.join("&"))}else
  721. // f.send(null)}function
  722. // _plugin(a,b){return
  723. // a===undefined?_plugins:b?void(_plugins[a]=b):_plugins[a]}function
  724. // _parseLangKey(a){var
  725. // b,c="core";return(b=/^(\w+)\.(\w+)$/.exec(a))&&(c=b[1],a=b[2]),{ns:c,key:a}}function
  726. // _lang(a,b){if(b=b===undefined?K.options.langType:b,"string"==typeof
  727. // a){if(!_language[b])return"no
  728. // language";var
  729. // c=a.length-1;if("."===a.substr(c))return
  730. // _language[b][a.substr(0,c)];var
  731. // d=_parseLangKey(a);return
  732. // _language[b][d.ns][d.key]}_each(a,function(a,c){var
  733. // d=_parseLangKey(a);_language[b]||(_language[b]={}),_language[b][d.ns]||(_language[b][d.ns]={}),_language[b][d.ns][d.key]=c})}function
  734. // _getImageFromRange(a,b){if(!a.collapsed){a=a.cloneRange().up();var
  735. // c=a.startContainer,d=a.startOffset;if(_WEBKIT||a.isControl()){var
  736. // e=K(c.childNodes[d]);if(e&&"img"==e.name)return
  737. // b(e)?e:void
  738. // 0}}}function
  739. // _bindContextmenuEvent(){var
  740. // a=this,b=a.edit.doc;K(b).contextmenu(function(b){if(a.menu&&a.hideMenu(),!a.useContextmenu)return
  741. // void
  742. // b.preventDefault();if(0!==a._contextmenus.length){var
  743. // c=0,d=[];for(_each(a._contextmenus,function(){return"-"==this.title?void
  744. // d.push(this):void(this.cond&&this.cond()&&(d.push(this),this.width&&this.width>c&&(c=this.width)))});d.length>0&&"-"==d[0].title;)d.shift();for(;d.length>0&&"-"==d[d.length-1].title;)d.pop();var
  745. // e=null;if(_each(d,function(a){"-"==this.title&&"-"==e.title&&delete
  746. // d[a],e=this}),d.length>0){b.preventDefault();var
  747. // f=K(a.edit.iframe).pos(),g=_menu({x:f.x+b.clientX,y:f.y+b.clientY,width:c,css:{visibility:"hidden"},shadowMode:a.shadowMode});_each(d,function(){this.title&&g.addItem(this)});var
  748. // h=_docElement(g.doc),i=g.div.height();b.clientY+i>=h.clientHeight-100&&g.pos(g.x,_removeUnit(g.y)-i),g.div.css("visibility","visible"),a.menu=g}}})}function
  749. // _bindNewlineEvent(){function
  750. // a(a){for(var
  751. // b=K(a.commonAncestor());b&&(1!=b.type||b.isStyle());)b=b.parent();return
  752. // b.name}var
  753. // b=this,c=b.edit.doc,d=b.newlineTag;if(!(_IE&&"br"!==d||_GECKO&&3>_V&&"p"!==d||_OPERA&&9>_V)){var
  754. // e=_toMap("h1,h2,h3,h4,h5,h6,pre,li"),f=_toMap("p,h1,h2,h3,h4,h5,h6,pre,li,blockquote");K(c).keydown(function(g){if(!(13!=g.which||g.shiftKey||g.ctrlKey||g.altKey)){b.cmd.selection();var
  755. // h=a(b.cmd.range);if("marquee"!=h&&"select"!=h)return"br"!==d||e[h]?void(f[h]||_nativeCommand(c,"formatblock","<p>")):(g.preventDefault(),void
  756. // b.insertHtml("<br
  757. // />"+(_IE&&9>_V?"":"​")))}}),K(c).keyup(function(e){if(!(13!=e.which||e.shiftKey||e.ctrlKey||e.altKey)&&"br"!=d){if(_GECKO){var
  758. // g=b.cmd.commonAncestor("p"),h=b.cmd.commonAncestor("a");return
  759. // void(h&&""==h.text()&&(h.remove(!0),b.cmd.range.selectNodeContents(g[0]).collapse(!0),b.cmd.select()))}b.cmd.selection();var
  760. // i=a(b.cmd.range);if("marquee"!=i&&"select"!=i){f[i]||_nativeCommand(c,"formatblock","<p>");var
  761. // j=b.cmd.commonAncestor("div");if(j){for(var
  762. // k=K("<p></p>"),l=j[0].firstChild;l;){var
  763. // m=l.nextSibling;k.append(l),l=m}j.before(k),j.remove(),b.cmd.range.selectNodeContents(k[0]),b.cmd.select()}}}})}}function
  764. // _bindTabEvent(){var
  765. // a=this,b=a.edit.doc;K(b).keydown(function(c){if(9==c.which){if(c.preventDefault(),a.afterTab)return
  766. // void
  767. // a.afterTab.call(a,c);var
  768. // d=a.cmd,e=d.range;e.shrink(),e.collapsed&&1==e.startContainer.nodeType&&(e.insertNode(K("@&nbsp;",b)[0]),d.select()),a.insertHtml("&nbsp;&nbsp;&nbsp;&nbsp;")}})}function
  769. // _bindFocusEvent(){var
  770. // a=this;K(a.edit.textarea[0],a.edit.win).focus(function(b){a.afterFocus&&a.afterFocus.call(a,b)}).blur(function(b){a.afterBlur&&a.afterBlur.call(a,b)})}function
  771. // _removeBookmarkTag(a){return
  772. // _trim(a.replace(/<span
  773. // [^>]*id="?__kindeditor_bookmark_\w+_\d+__"?[^>]*><\/span>/gi,""))}function
  774. // _removeTempTag(a){return
  775. // a.replace(/<div[^>]+class="?__kindeditor_paste__"?[^>]*>[\s\S]*?<\/div>/gi,"")}function
  776. // _addBookmarkToStack(a,b){if(0===a.length)return
  777. // void
  778. // a.push(b);var
  779. // c=a[a.length-1];_removeBookmarkTag(b.html)!==_removeBookmarkTag(c.html)&&a.push(b)}function
  780. // _undoToRedo(a,b){var
  781. // c,d,e=this,f=e.edit,g=f.doc.body;if(0===a.length)return
  782. // e;f.designMode?(c=e.cmd.range,d=c.createBookmark(!0),d.html=g.innerHTML):d={html:g.innerHTML},_addBookmarkToStack(b,d);
  783. var h = a.pop();
  784. return _removeBookmarkTag(d.html) === _removeBookmarkTag(h.html) && a.length > 0 && (h = a.pop()),
  785. f.designMode ? (f.html(h.html), h.start && (c.moveToBookmark(h), e.select())) : K(g).html(_removeBookmarkTag(h.html)),
  786. e
  787. }
  788. function KEditor(a) {
  789. function b(a, b) {
  790. KEditor.prototype[a] === undefined && (c[a] = b),
  791. c.options[a] = b
  792. }
  793. var c = this;
  794. c.options = {},
  795. _each(a,
  796. function(c) {
  797. b(c, a[c])
  798. }),
  799. _each(K.options,
  800. function(a, d) {
  801. c[a] === undefined && b(a, d)
  802. });
  803. var d = K(c.srcElement || "<textarea/>");
  804. c.width || (c.width = d[0].style.width || d.width()),
  805. c.height || (c.height = d[0].style.height || d.height()),
  806. b("width", _undef(c.width, c.minWidth)),
  807. b("height", _undef(c.height, c.minHeight)),
  808. b("width", _addUnit(c.width)),
  809. b("height", _addUnit(c.height)),
  810. _MOBILE && (!_IOS || 534 > _V) && (c.designMode = !1),
  811. c.srcElement = d,
  812. c.initContent = "",
  813. c.plugin = {},
  814. c.isCreated = !1,
  815. c._handlers = {},
  816. c._contextmenus = [],
  817. c._undoStack = [],
  818. c._redoStack = [],
  819. c._firstAddBookmark = !0,
  820. c.menu = c.contextmenu = null,
  821. c.dialogs = []
  822. }
  823. function _editor(a) {
  824. return new KEditor(a)
  825. }
  826. function _create(a, b) {
  827. function c(a) {
  828. return _each(_plugins,
  829. function(b, c) {
  830. _isFunction(c) && (c.call(a, KindEditor), a._pluginStatus || (a._pluginStatus = {}), a._pluginStatus[b] = "inited")
  831. }),
  832. a.create()
  833. }
  834. if (b = b || {},
  835. b.basePath = _undef(b.basePath, K.basePath), b.themesPath = _undef(b.themesPath, b.basePath + "themes/"), b.langPath = _undef(b.langPath, b.basePath + "lang/"), b.pluginsPath = _undef(b.pluginsPath, b.basePath + "plugins/"), _undef(b.loadStyleMode, K.options.loadStyleMode)) {
  836. var d = _undef(b.themeType, K.options.themeType);
  837. _loadStyle(b.themesPath + "default/default.css"),
  838. _loadStyle(b.themesPath + d + "/" + d + ".css")
  839. }
  840. var e = K(a);
  841. if (e && 0 !== e.length) {
  842. if (e.length > 1) return e.each(function() {
  843. _create(this, b)
  844. }),
  845. _instances[0];
  846. b.srcElement = e[0];
  847. var f = new KEditor(b);
  848. return _instances.push(f),
  849. _language[f.langType] ? c(f) : (_loadScript(f.langPath + f.langType + ".js?ver=" + encodeURIComponent(K.DEBUG ? _TIME: _VERSION),
  850. function() {
  851. c(f)
  852. }), f)
  853. }
  854. }
  855. function _eachEditor(a, b) {
  856. K(a).each(function(a, c) {
  857. K.each(_instances,
  858. function(a, d) {
  859. return d && d.srcElement[0] == c ? (b.call(d, a), !1) : void 0
  860. })
  861. })
  862. }
  863. if (!window.KindEditor) {
  864. window.console || (window.console = {}),
  865. console.log || (console.log = function() {});
  866. var _VERSION = "4.1.11 (2016-03-31)",
  867. _ua = navigator.userAgent.toLowerCase(),
  868. _IE = _ua.indexOf("msie") > -1 && -1 == _ua.indexOf("opera"),
  869. _NEWIE = -1 == _ua.indexOf("msie") && _ua.indexOf("trident") > -1,
  870. _GECKO = _ua.indexOf("gecko") > -1 && -1 == _ua.indexOf("khtml"),
  871. _WEBKIT = _ua.indexOf("applewebkit") > -1,
  872. _OPERA = _ua.indexOf("opera") > -1,
  873. _MOBILE = _ua.indexOf("mobile") > -1,
  874. _IOS = /ipad|iphone|ipod/.test(_ua),
  875. _QUIRKS = "CSS1Compat" != document.compatMode,
  876. _IERANGE = !window.getSelection,
  877. _matches = /(?:msie|firefox|webkit|opera)[\/:\s](\d+)/.exec(_ua),
  878. _V = _matches ? _matches[1] : "0",
  879. _TIME = (new Date).getTime(),
  880. _round = Math.round,
  881. K = {
  882. DEBUG: !1,
  883. VERSION: _VERSION,
  884. IE: _IE,
  885. GECKO: _GECKO,
  886. WEBKIT: _WEBKIT,
  887. OPERA: _OPERA,
  888. V: _V,
  889. TIME: _TIME,
  890. each: _each,
  891. isArray: _isArray,
  892. isFunction: _isFunction,
  893. inArray: _inArray,
  894. inString: _inString,
  895. trim: _trim,
  896. addUnit: _addUnit,
  897. removeUnit: _removeUnit,
  898. escape: _escape,
  899. unescape: _unescape,
  900. toCamel: _toCamel,
  901. toHex: _toHex,
  902. toMap: _toMap,
  903. toArray: _toArray,
  904. undef: _undef,
  905. invalidUrl: _invalidUrl,
  906. addParam: _addParam,
  907. extend: _extend,
  908. json: _json
  909. },
  910. _INLINE_TAG_MAP = _toMap("a,abbr,acronym,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,img,input,ins,kbd,label,map,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"),
  911. _BLOCK_TAG_MAP = _toMap("address,applet,blockquote,body,center,dd,dir,div,dl,dt,fieldset,form,frameset,h1,h2,h3,h4,h5,h6,head,hr,html,iframe,ins,isindex,li,map,menu,meta,noframes,noscript,object,ol,p,pre,script,style,table,tbody,td,tfoot,th,thead,title,tr,ul"),
  912. _SINGLE_TAG_MAP = _toMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"),
  913. _STYLE_TAG_MAP = _toMap("b,basefont,big,del,em,font,i,s,small,span,strike,strong,sub,sup,u"),
  914. _CONTROL_TAG_MAP = _toMap("img,table,input,textarea,button"),
  915. _PRE_TAG_MAP = _toMap("pre,style,script"),
  916. _NOSPLIT_TAG_MAP = _toMap("html,head,body,td,tr,table,ol,ul,li"),
  917. _AUTOCLOSE_TAG_MAP = _toMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"),
  918. _FILL_ATTR_MAP = _toMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),
  919. _VALUE_TAG_MAP = _toMap("input,button,textarea,select");
  920. K.basePath = _getBasePath(),
  921. K.options = {
  922. designMode: !0,
  923. fullscreenMode: !1,
  924. filterMode: !0,
  925. wellFormatMode: !0,
  926. shadowMode: !0,
  927. loadStyleMode: !0,
  928. basePath: K.basePath,
  929. themesPath: K.basePath + "themes/",
  930. langPath: K.basePath + "lang/",
  931. pluginsPath: K.basePath + "plugins/",
  932. themeType: "default",
  933. langType: "zh-CN",
  934. urlType: "",
  935. newlineTag: "p",
  936. resizeType: 2,
  937. syncType: "form",
  938. pasteType: 2,
  939. dialogAlignType: "page",
  940. useContextmenu: !0,
  941. fullscreenShortcut: !1,
  942. bodyClass: "ke-content",
  943. indentChar: " ",
  944. cssPath: "",
  945. cssData: "",
  946. minWidth: 650,
  947. minHeight: 100,
  948. minChangeSize: 50,
  949. zIndex: 811213,
  950. items: ["source", "|", "undo", "redo", "|", "preview", "print", "template", "code", "cut", "copy", "paste", "plainpaste", "wordpaste", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml", "quickformat", "selectall", "|", "fullscreen", "/", "formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "lineheight", "removeformat", "|", "image", "multiimage", "flash", "media", "insertfile", "table", "hr", "emoticons", "baidumap", "pagebreak", "anchor", "link", "unlink", "|", "about"],
  951. noDisableItems: ["source", "fullscreen"],
  952. colorTable: [["#E53333", "#E56600", "#FF9900", "#64451D", "#DFC5A4", "#FFE500"], ["#009900", "#006600", "#99BB00", "#B8D100", "#60D978", "#00D5FF"], ["#337FE5", "#003399", "#4C33E5", "#9933E5", "#CC33E5", "#EE33EE"], ["#FFFFFF", "#CCCCCC", "#999999", "#666666", "#333333", "#000000"]],
  953. fontSizeTable: ["9px", "10px", "12px", "14px", "16px", "18px", "24px", "32px"],
  954. htmlTags: {
  955. font: ["id", "class", "color", "size", "face", ".background-color"],
  956. span: ["id", "class", ".color", ".background-color", ".font-size", ".font-family", ".background", ".font-weight", ".font-style", ".text-decoration", ".vertical-align", ".line-height"],
  957. div: ["id", "class", "align", ".border", ".margin", ".padding", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".font-weight", ".background", ".font-style", ".text-decoration", ".vertical-align", ".margin-left"],
  958. table: ["id", "class", "border", "cellspacing", "cellpadding", "width", "height", "align", "bordercolor", ".padding", ".margin", ".border", "bgcolor", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".font-weight", ".font-style", ".text-decoration", ".background", ".width", ".height", ".border-collapse"],
  959. "td,th": ["id", "class", "align", "valign", "width", "height", "colspan", "rowspan", "bgcolor", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".font-weight", ".font-style", ".text-decoration", ".vertical-align", ".background", ".border"],
  960. a: ["id", "class", "href", "target", "name"],
  961. embed: ["id", "class", "src", "width", "height", "type", "loop", "autostart", "quality", ".width", ".height", "align", "allowscriptaccess", "wmode"],
  962. img: ["id", "class", "src", "width", "height", "border", "alt", "title", "align", ".width", ".height", ".border"],
  963. "p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6": ["id", "class", "align", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".background", ".font-weight", ".font-style", ".text-decoration", ".vertical-align", ".text-indent", ".margin-left"],
  964. pre: ["id", "class"],
  965. hr: ["id", "class", ".page-break-after"],
  966. "br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del": ["id", "class"],
  967. iframe: ["id", "class", "src", "frameborder", "width", "height", ".width", ".height"]
  968. },
  969. layout: '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>'
  970. };
  971. var _useCapture = !1,
  972. _INPUT_KEY_MAP = _toMap("8,9,13,32,46,48..57,59,61,65..90,106,109..111,188,190..192,219..222"),
  973. _CURSORMOVE_KEY_MAP = _toMap("33..40"),
  974. _CHANGE_KEY_MAP = {};
  975. _each(_INPUT_KEY_MAP,
  976. function(a, b) {
  977. _CHANGE_KEY_MAP[a] = b
  978. }),
  979. _each(_CURSORMOVE_KEY_MAP,
  980. function(a, b) {
  981. _CHANGE_KEY_MAP[a] = b
  982. });
  983. var _EVENT_PROPS = "altKey,attrChange,attrName,bubbles,button,cancelable,charCode,clientX,clientY,ctrlKey,currentTarget,data,detail,eventPhase,fromElement,handler,keyCode,metaKey,newValue,offsetX,offsetY,originalTarget,pageX,pageY,prevValue,relatedNode,relatedTarget,screenX,screenY,shiftKey,srcElement,target,toElement,view,wheelDelta,which".split(",");
  984. _extend(KEvent, {
  985. init: function(a, b) {
  986. var c = this,
  987. d = a.ownerDocument || a.document || a;
  988. if (c.event = b, _each(_EVENT_PROPS,
  989. function(a, d) {
  990. c[d] = b[d]
  991. }), c.target || (c.target = c.srcElement || d), 3 === c.target.nodeType && (c.target = c.target.parentNode), !c.relatedTarget && c.fromElement && (c.relatedTarget = c.fromElement === c.target ? c.toElement: c.fromElement), null == c.pageX && null != c.clientX) {
  992. var e = d.documentElement,
  993. f = d.body;
  994. c.pageX = c.clientX + (e && e.scrollLeft || f && f.scrollLeft || 0) - (e && e.clientLeft || f && f.clientLeft || 0),
  995. c.pageY = c.clientY + (e && e.scrollTop || f && f.scrollTop || 0) - (e && e.clientTop || f && f.clientTop || 0)
  996. }
  997. switch (!c.which && (c.charCode || 0 === c.charCode ? c.charCode: c.keyCode) && (c.which = c.charCode || c.keyCode), !c.metaKey && c.ctrlKey && (c.metaKey = c.ctrlKey), c.which || c.button === undefined || (c.which = 1 & c.button ? 1 : 2 & c.button ? 3 : 4 & c.button ? 2 : 0), c.which) {
  998. case 186:
  999. c.which = 59;
  1000. break;
  1001. case 187:
  1002. case 107:
  1003. case 43:
  1004. c.which = 61;
  1005. break;
  1006. case 189:
  1007. case 45:
  1008. c.which = 109;
  1009. break;
  1010. case 42:
  1011. c.which = 106;
  1012. break;
  1013. case 47:
  1014. c.which = 111;
  1015. break;
  1016. case 78:
  1017. c.which = 110
  1018. }
  1019. c.which >= 96 && c.which <= 105 && (c.which -= 48)
  1020. },
  1021. preventDefault: function() {
  1022. var a = this.event;
  1023. a.preventDefault ? a.preventDefault() : a.returnValue = !1
  1024. },
  1025. stopPropagation: function() {
  1026. var a = this.event;
  1027. a.stopPropagation ? a.stopPropagation() : a.cancelBubble = !0
  1028. },
  1029. stop: function() {
  1030. this.preventDefault(),
  1031. this.stopPropagation()
  1032. }
  1033. });
  1034. var _eventExpendo = "kindeditor_" + _TIME,
  1035. _eventId = 0,
  1036. _eventData = {},
  1037. _readyFinished = !1;
  1038. window.attachEvent && window.attachEvent("onunload",
  1039. function() {
  1040. _each(_eventData,
  1041. function(a, b) {
  1042. b.el && _unbind(b.el)
  1043. })
  1044. }),
  1045. K.ctrl = _ctrl,
  1046. K.ready = _ready,
  1047. K.formatUrl = _formatUrl,
  1048. K.formatHtml = _formatHtml,
  1049. K.getCssList = _getCssList,
  1050. K.getAttrList = _getAttrList,
  1051. K.mediaType = _mediaType,
  1052. K.mediaAttrs = _mediaAttrs,
  1053. K.mediaEmbed = _mediaEmbed,
  1054. K.mediaImg = _mediaImg,
  1055. K.clearMsWord = _clearMsWord,
  1056. K.tmpl = _tmpl;
  1057. var _getSetAttrDiv = document.createElement("div");
  1058. _getSetAttrDiv.setAttribute("className", "t");
  1059. var _GET_SET_ATTRIBUTE = "t" !== _getSetAttrDiv.className;
  1060. K.query = _query,
  1061. K.queryAll = _queryAll,
  1062. _extend(KNode, {
  1063. init: function(a) {
  1064. var b = this;
  1065. a = _isArray(a) ? a: [a];
  1066. for (var c = 0,
  1067. d = 0,
  1068. e = a.length; e > d; d++) a[d] && (b[d] = a[d].constructor === KNode ? a[d][0] : a[d], c++);
  1069. b.length = c,
  1070. b.doc = _getDoc(b[0]),
  1071. b.name = _getNodeName(b[0]),
  1072. b.type = b.length > 0 ? b[0].nodeType: null,
  1073. b.win = _getWin(b[0])
  1074. },
  1075. each: function(a) {
  1076. for (var b = this,
  1077. c = 0; c < b.length; c++) if (a.call(b[c], c, b[c]) === !1) return b;
  1078. return b
  1079. },
  1080. bind: function(a, b) {
  1081. return this.each(function() {
  1082. _bind(this, a, b)
  1083. }),
  1084. this
  1085. },
  1086. unbind: function(a, b) {
  1087. return this.each(function() {
  1088. _unbind(this, a, b)
  1089. }),
  1090. this
  1091. },
  1092. fire: function(a) {
  1093. return this.length < 1 ? this: (_fire(this[0], a), this)
  1094. },
  1095. hasAttr: function(a) {
  1096. return this.length < 1 ? !1 : !!_getAttr(this[0], a)
  1097. },
  1098. attr: function(a, b) {
  1099. var c = this;
  1100. return a === undefined ? _getAttrList(c.outer()) : "object" == typeof a ? (_each(a,
  1101. function(a, b) {
  1102. c.attr(a, b)
  1103. }), c) : b === undefined ? (b = c.length < 1 ? null: _getAttr(c[0], a), null === b ? "": b) : (c.each(function() {
  1104. _setAttr(this, a, b)
  1105. }), c)
  1106. },
  1107. removeAttr: function(a) {
  1108. return this.each(function() {
  1109. _removeAttr(this, a)
  1110. }),
  1111. this
  1112. },
  1113. get: function(a) {
  1114. return this.length < 1 ? null: this[a || 0]
  1115. },
  1116. eq: function(a) {
  1117. return this.length < 1 ? null: this[a] ? new KNode(this[a]) : null
  1118. },
  1119. hasClass: function(a) {
  1120. return this.length < 1 ? !1 : _hasClass(this[0], a)
  1121. },
  1122. addClass: function(a) {
  1123. return this.each(function() {
  1124. _hasClass(this, a) || (this.className = _trim(this.className + " " + a))
  1125. }),
  1126. this
  1127. },
  1128. removeClass: function(a) {
  1129. return this.each(function() {
  1130. _hasClass(this, a) && (this.className = _trim(this.className.replace(new RegExp("(^|\\s)" + a + "(\\s|$)"), " ")))
  1131. }),
  1132. this
  1133. },
  1134. html: function(a) {
  1135. var b = this;
  1136. return a === undefined ? b.length < 1 || 1 != b.type ? "": _formatHtml(b[0].innerHTML) : (b.each(function() {
  1137. _setHtml(this, a)
  1138. }), b)
  1139. },
  1140. text: function() {
  1141. var a = this;
  1142. return a.length < 1 ? "": _IE ? a[0].innerText: a[0].textContent
  1143. },
  1144. hasVal: function() {
  1145. return this.length < 1 ? !1 : _hasVal(this[0])
  1146. },
  1147. val: function(a) {
  1148. var b = this;
  1149. return a === undefined ? b.length < 1 ? "": b.hasVal() ? b[0].value: b.attr("value") : (b.each(function() {
  1150. _hasVal(this) ? this.value = a: _setAttr(this, "value", a)
  1151. }), b)
  1152. },
  1153. css: function(a, b) {
  1154. var c = this;
  1155. return a === undefined ? _getCssList(c.attr("style")) : "object" == typeof a ? (_each(a,
  1156. function(a, b) {
  1157. c.css(a, b)
  1158. }), c) : b === undefined ? c.length < 1 ? "": c[0].style[_toCamel(a)] || _computedCss(c[0], a) || "": (c.each(function() {
  1159. this.style[_toCamel(a)] = b
  1160. }), c)
  1161. },
  1162. width: function(a) {
  1163. var b = this;
  1164. return a === undefined ? b.length < 1 ? 0 : b[0].offsetWidth: b.css("width", _addUnit(a))
  1165. },
  1166. height: function(a) {
  1167. var b = this;
  1168. return a === undefined ? b.length < 1 ? 0 : b[0].offsetHeight: b.css("height", _addUnit(a))
  1169. },
  1170. opacity: function(a) {
  1171. return this.each(function() {
  1172. this.style.opacity === undefined ? this.style.filter = 1 == a ? "": "alpha(opacity=" + 100 * a + ")": this.style.opacity = 1 == a ? "": a
  1173. }),
  1174. this
  1175. },
  1176. data: function(a, b) {
  1177. var c = this;
  1178. return a = "kindeditor_data_" + a,
  1179. b === undefined ? c.length < 1 ? null: c[0][a] : (this.each(function() {
  1180. this[a] = b
  1181. }), c)
  1182. },
  1183. pos: function() {
  1184. var a = this,
  1185. b = a[0],
  1186. c = 0,
  1187. d = 0;
  1188. if (b) if (b.getBoundingClientRect) {
  1189. var e = b.getBoundingClientRect(),
  1190. f = _getScrollPos(a.doc);
  1191. c = e.left + f.x,
  1192. d = e.top + f.y
  1193. } else for (; b;) c += b.offsetLeft,
  1194. d += b.offsetTop,
  1195. b = b.offsetParent;
  1196. return {
  1197. x: _round(c),
  1198. y: _round(d)
  1199. }
  1200. },
  1201. clone: function(a) {
  1202. return new KNode(this.length < 1 ? [] : this[0].cloneNode(a))
  1203. },
  1204. append: function(a) {
  1205. return this.each(function() {
  1206. this.appendChild && this.appendChild(_get(a))
  1207. }),
  1208. this
  1209. },
  1210. appendTo: function(a) {
  1211. return this.each(function() {
  1212. _get(a).appendChild(this)
  1213. }),
  1214. this
  1215. },
  1216. before: function(a) {
  1217. return this.each(function() {
  1218. this.parentNode.insertBefore(_get(a), this)
  1219. }),
  1220. this
  1221. },
  1222. after: function(a) {
  1223. return this.each(function() {
  1224. this.nextSibling ? this.parentNode.insertBefore(_get(a), this.nextSibling) : this.parentNode.appendChild(_get(a))
  1225. }),
  1226. this
  1227. },
  1228. replaceWith: function(a) {
  1229. var b = [];
  1230. return this.each(function(c, d) {
  1231. _unbind(d);
  1232. var e = _get(a);
  1233. d.parentNode.replaceChild(e, d),
  1234. b.push(e)
  1235. }),
  1236. K(b)
  1237. },
  1238. empty: function() {
  1239. var a = this;
  1240. return a.each(function(a, b) {
  1241. for (var c = b.firstChild; c;) {
  1242. if (!b.parentNode) return;
  1243. var d = c.nextSibling;
  1244. c.parentNode.removeChild(c),
  1245. c = d
  1246. }
  1247. }),
  1248. a
  1249. },
  1250. remove: function(a) {
  1251. var b = this;
  1252. return b.each(function(c, d) {
  1253. if (d.parentNode) {
  1254. if (_unbind(d), a) for (var e = d.firstChild; e;) {
  1255. var f = e.nextSibling;
  1256. d.parentNode.insertBefore(e, d),
  1257. e = f
  1258. }
  1259. d.parentNode.removeChild(d),
  1260. delete b[c]
  1261. }
  1262. }),
  1263. b.length = 0,
  1264. b
  1265. },
  1266. show: function(a) {
  1267. var b = this;
  1268. return a === undefined && (a = b._originDisplay || ""),
  1269. "none" != b.css("display") ? b: b.css("display", a)
  1270. },
  1271. hide: function() {
  1272. var a = this;
  1273. return a.length < 1 ? a: (a._originDisplay = a[0].style.display, a.css("display", "none"))
  1274. },
  1275. outer: function() {
  1276. var a = this;
  1277. if (a.length < 1) return "";
  1278. var b, c = a.doc.createElement("div");
  1279. return c.appendChild(a[0].cloneNode(!0)),
  1280. b = _formatHtml(c.innerHTML),
  1281. c = null,
  1282. b
  1283. },
  1284. isSingle: function() {
  1285. return !! _SINGLE_TAG_MAP[this.name]
  1286. },
  1287. isInline: function() {
  1288. return !! _INLINE_TAG_MAP[this.name]
  1289. },
  1290. isBlock: function() {
  1291. return !! _BLOCK_TAG_MAP[this.name]
  1292. },
  1293. isStyle: function() {
  1294. return !! _STYLE_TAG_MAP[this.name]
  1295. },
  1296. isControl: function() {
  1297. return !! _CONTROL_TAG_MAP[this.name]
  1298. },
  1299. contains: function(a) {
  1300. return this.length < 1 ? !1 : _contains(this[0], _get(a))
  1301. },
  1302. parent: function() {
  1303. if (this.length < 1) return null;
  1304. var a = this[0].parentNode;
  1305. return a ? new KNode(a) : null
  1306. },
  1307. children: function() {
  1308. if (this.length < 1) return new KNode([]);
  1309. for (var a = [], b = this[0].firstChild; b;)(3 != b.nodeType || "" !== _trim(b.nodeValue)) && a.push(b),
  1310. b = b.nextSibling;
  1311. return new KNode(a)
  1312. },
  1313. first: function() {
  1314. var a = this.children();
  1315. return a.length > 0 ? a.eq(0) : null
  1316. },
  1317. last: function() {
  1318. var a = this.children();
  1319. return a.length > 0 ? a.eq(a.length - 1) : null
  1320. },
  1321. index: function() {
  1322. if (this.length < 1) return - 1;
  1323. for (var a = -1,
  1324. b = this[0]; b;) a++,
  1325. b = b.previousSibling;
  1326. return a
  1327. },
  1328. prev: function() {
  1329. if (this.length < 1) return null;
  1330. var a = this[0].previousSibling;
  1331. return a ? new KNode(a) : null
  1332. },
  1333. next: function() {
  1334. if (this.length < 1) return null;
  1335. var a = this[0].nextSibling;
  1336. return a ? new KNode(a) : null
  1337. },
  1338. scan: function(a, b) {
  1339. function c(d) {
  1340. for (var e = b ? d.firstChild: d.lastChild; e;) {
  1341. var f = b ? e.nextSibling: e.previousSibling;
  1342. if (a(e) === !1) return ! 1;
  1343. if (c(e) === !1) return ! 1;
  1344. e = f
  1345. }
  1346. }
  1347. if (! (this.length < 1)) return b = b === undefined ? !0 : b,
  1348. c(this[0]),
  1349. this
  1350. }
  1351. }),
  1352. _each("blur,focus,focusin,focusout,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error,contextmenu".split(","),
  1353. function(a, b) {
  1354. KNode.prototype[b] = function(a) {
  1355. return a ? this.bind(b, a) : this.fire(b)
  1356. }
  1357. });
  1358. var _K = K;
  1359. K = function(a, b) {
  1360. function c(a) {
  1361. return a[0] || (a = []),
  1362. new KNode(a)
  1363. }
  1364. if (a !== undefined && null !== a) {
  1365. if ("string" == typeof a) {
  1366. b && (b = _get(b));
  1367. var d = a.length;
  1368. if ("@" === a.charAt(0) && (a = a.substr(1)), a.length !== d || /<.+>/.test(a)) {
  1369. var e = b ? b.ownerDocument || b: document,
  1370. f = e.createElement("div"),
  1371. g = [];
  1372. f.innerHTML = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + a;
  1373. for (var h = 0,
  1374. i = f.childNodes.length; i > h; h++) {
  1375. var j = f.childNodes[h];
  1376. "__kindeditor_temp_tag__" != j.id && g.push(j)
  1377. }
  1378. return c(g)
  1379. }
  1380. return c(_queryAll(a, b))
  1381. }
  1382. return a && a.constructor === KNode ? a: (a.toArray && (a = a.toArray()), c(_isArray(a) ? a: _toArray(arguments)))
  1383. }
  1384. },
  1385. _each(_K,
  1386. function(a, b) {
  1387. K[a] = b
  1388. }),
  1389. K.NodeClass = KNode,
  1390. window.KindEditor = K;
  1391. var _START_TO_START = 0,
  1392. _START_TO_END = 1,
  1393. _END_TO_END = 2,
  1394. _END_TO_START = 3,
  1395. _BOOKMARK_ID = 0;
  1396. _extend(KRange, {
  1397. init: function(a) {
  1398. var b = this;
  1399. b.startContainer = a,
  1400. b.startOffset = 0,
  1401. b.endContainer = a,
  1402. b.endOffset = 0,
  1403. b.collapsed = !0,
  1404. b.doc = a
  1405. },
  1406. commonAncestor: function() {
  1407. function a(a) {
  1408. for (var b = []; a;) b.push(a),
  1409. a = a.parentNode;
  1410. return b
  1411. }
  1412. for (var b, c, d = a(this.startContainer), e = a(this.endContainer), f = 0, g = d.length, h = e.length; ++f && (b = d[g - f], c = e[h - f], b && c && b === c););
  1413. return d[g - f + 1]
  1414. },
  1415. setStart: function(a, b) {
  1416. var c = this,
  1417. d = c.doc;
  1418. return c.startContainer = a,
  1419. c.startOffset = b,
  1420. c.endContainer === d && (c.endContainer = a, c.endOffset = b),
  1421. _updateCollapsed(this)
  1422. },
  1423. setEnd: function(a, b) {
  1424. var c = this,
  1425. d = c.doc;
  1426. return c.endContainer = a,
  1427. c.endOffset = b,
  1428. c.startContainer === d && (c.startContainer = a, c.startOffset = b),
  1429. _updateCollapsed(this)
  1430. },
  1431. setStartBefore: function(a) {
  1432. return this.setStart(a.parentNode || this.doc, K(a).index())
  1433. },
  1434. setStartAfter: function(a) {
  1435. return this.setStart(a.parentNode || this.doc, K(a).index() + 1)
  1436. },
  1437. setEndBefore: function(a) {
  1438. return this.setEnd(a.parentNode || this.doc, K(a).index())
  1439. },
  1440. setEndAfter: function(a) {
  1441. return this.setEnd(a.parentNode || this.doc, K(a).index() + 1)
  1442. },
  1443. selectNode: function(a) {
  1444. return this.setStartBefore(a).setEndAfter(a)
  1445. },
  1446. selectNodeContents: function(a) {
  1447. var b = K(a);
  1448. if (3 == b.type || b.isSingle()) return this.selectNode(a);
  1449. var c = b.children();
  1450. return c.length > 0 ? this.setStartBefore(c[0]).setEndAfter(c[c.length - 1]) : this.setStart(a, 0).setEnd(a, 0)
  1451. },
  1452. collapse: function(a) {
  1453. return a ? this.setEnd(this.startContainer, this.startOffset) : this.setStart(this.endContainer, this.endOffset)
  1454. },
  1455. compareBoundaryPoints: function(a, b) {
  1456. var c = this.get(),
  1457. d = b.get();
  1458. if (!_IERANGE) return c.compareBoundaryPoints(a, d);
  1459. var e = {};
  1460. e[_START_TO_START] = "StartToStart",
  1461. e[_START_TO_END] = "EndToStart",
  1462. e[_END_TO_END] = "EndToEnd",
  1463. e[_END_TO_START] = "StartToEnd";
  1464. var f = c.compareEndPoints(e[a], d);
  1465. if (0 !== f) return f;
  1466. var g, h, i, j, k;
  1467. if ((a === _START_TO_START || a === _END_TO_START) && (g = this.startContainer, j = this.startOffset), (a === _START_TO_END || a === _END_TO_END) && (g = this.endContainer, j = this.endOffset), (a === _START_TO_START || a === _START_TO_END) && (h = b.startContainer, k = b.startOffset), (a === _END_TO_END || a === _END_TO_START) && (h = b.endContainer, k = b.endOffset), g === h) {
  1468. var l = j - k;
  1469. return l > 0 ? 1 : 0 > l ? -1 : 0
  1470. }
  1471. for (i = h; i && i.parentNode !== g;) i = i.parentNode;
  1472. if (i) return K(i).index() >= j ? -1 : 1;
  1473. for (i = g; i && i.parentNode !== h;) i = i.parentNode;
  1474. return i ? K(i).index() >= k ? 1 : -1 : (i = K(h).next(), i && i.contains(g) ? 1 : (i = K(g).next(), i && i.contains(h) ? -1 : void 0))
  1475. },
  1476. cloneRange: function() {
  1477. return new KRange(this.doc).setStart(this.startContainer, this.startOffset).setEnd(this.endContainer, this.endOffset)
  1478. },
  1479. toString: function() {
  1480. var a = this.get(),
  1481. b = _IERANGE ? a.text: a.toString();
  1482. return b.replace(/\r\n|\n|\r/g, "")
  1483. },
  1484. cloneContents: function() {
  1485. return _copyAndDelete(this, !0, !1)
  1486. },
  1487. deleteContents: function() {
  1488. return _copyAndDelete(this, !1, !0)
  1489. },
  1490. extractContents: function() {
  1491. return _copyAndDelete(this, !0, !0)
  1492. },
  1493. insertNode: function(a) {
  1494. var b, c, d, e = this,
  1495. f = e.startContainer,
  1496. g = e.startOffset,
  1497. h = e.endContainer,
  1498. i = e.endOffset,
  1499. j = 1;
  1500. return "#document-fragment" === a.nodeName.toLowerCase() && (b = a.firstChild, c = a.lastChild, j = a.childNodes.length),
  1501. 1 == f.nodeType ? (d = f.childNodes[g], d ? (f.insertBefore(a, d), f === h && (i += j)) : f.appendChild(a)) : 3 == f.nodeType && (0 === g ? (f.parentNode.insertBefore(a, f), f.parentNode === h && (i += j)) : g >= f.nodeValue.length ? f.nextSibling ? f.parentNode.insertBefore(a, f.nextSibling) : f.parentNode.appendChild(a) : (d = g > 0 ? f.splitText(g) : f, f.parentNode.insertBefore(a, d), f === h && (h = d, i -= g))),
  1502. b ? e.setStartBefore(b).setEndAfter(c) : e.selectNode(a),
  1503. e.compareBoundaryPoints(_END_TO_END, e.cloneRange().setEnd(h, i)) >= 1 ? e: e.setEnd(h, i)
  1504. },
  1505. surroundContents: function(a) {
  1506. return a.appendChild(this.extractContents()),
  1507. this.insertNode(a).selectNode(a)
  1508. },
  1509. isControl: function() {
  1510. var a = this,
  1511. b = a.startContainer,
  1512. c = a.startOffset,
  1513. d = a.endContainer,
  1514. e = a.endOffset;
  1515. return 1 == b.nodeType && b === d && c + 1 === e && K(b.childNodes[c]).isControl()
  1516. },
  1517. get: function(a) {
  1518. var b, c = this,
  1519. d = c.doc;
  1520. if (!_IERANGE) {
  1521. b = d.createRange();
  1522. try {
  1523. b.setStart(c.startContainer, c.startOffset),
  1524. b.setEnd(c.endContainer, c.endOffset)
  1525. } catch(e) {}
  1526. return b
  1527. }
  1528. if (a && c.isControl()) return b = d.body.createControlRange(),
  1529. b.addElement(c.startContainer.childNodes[c.startOffset]),
  1530. b;
  1531. var f = c.cloneRange().down();
  1532. return b = d.body.createTextRange(),
  1533. b.setEndPoint("StartToStart", _getEndRange(f.startContainer, f.startOffset)),
  1534. b.setEndPoint("EndToStart", _getEndRange(f.endContainer, f.endOffset)),
  1535. b
  1536. },
  1537. html: function() {
  1538. return K(this.cloneContents()).outer()
  1539. },
  1540. down: function() {
  1541. function a(a, c, d) {
  1542. if (1 == a.nodeType) {
  1543. var e = K(a).children();
  1544. if (0 !== e.length) {
  1545. var f, g, h, i;
  1546. c > 0 && (f = e.eq(c - 1)),
  1547. c < e.length && (g = e.eq(c)),
  1548. f && 3 == f.type && (h = f[0], i = h.nodeValue.length),
  1549. g && 3 == g.type && (h = g[0], i = 0),
  1550. h && (d ? b.setStart(h, i) : b.setEnd(h, i))
  1551. }
  1552. }
  1553. }
  1554. var b = this;
  1555. return a(b.startContainer, b.startOffset, !0),
  1556. a(b.endContainer, b.endOffset, !1),
  1557. b
  1558. },
  1559. up: function() {
  1560. function a(a, c, d) {
  1561. 3 == a.nodeType && (0 === c ? d ? b.setStartBefore(a) : b.setEndBefore(a) : c == a.nodeValue.length && (d ? b.setStartAfter(a) : b.setEndAfter(a)))
  1562. }
  1563. var b = this;
  1564. return a(b.startContainer, b.startOffset, !0),
  1565. a(b.endContainer, b.endOffset, !1),
  1566. b
  1567. },
  1568. enlarge: function(a) {
  1569. function b(b, d, e) {
  1570. var f, g = K(b);
  1571. if (! (3 == g.type || _NOSPLIT_TAG_MAP[g.name] || !a && g.isBlock())) if (0 === d) {
  1572. for (; ! g.prev() && (f = g.parent(), f && !_NOSPLIT_TAG_MAP[f.name] && (a || !f.isBlock()));) g = f;
  1573. e ? c.setStartBefore(g[0]) : c.setEndBefore(g[0])
  1574. } else if (d == g.children().length) {
  1575. for (; ! g.next() && (f = g.parent(), f && !_NOSPLIT_TAG_MAP[f.name] && (a || !f.isBlock()));) g = f;
  1576. e ? c.setStartAfter(g[0]) : c.setEndAfter(g[0])
  1577. }
  1578. }
  1579. var c = this;
  1580. return c.up(),
  1581. b(c.startContainer, c.startOffset, !0),
  1582. b(c.endContainer, c.endOffset, !1),
  1583. c
  1584. },
  1585. shrink: function() {
  1586. for (var a, b = this,
  1587. c = b.collapsed; 1 == b.startContainer.nodeType && (a = b.startContainer.childNodes[b.startOffset]) && 1 == a.nodeType && !K(a).isSingle();) b.setStart(a, 0);
  1588. if (c) return b.collapse(c);
  1589. for (; 1 == b.endContainer.nodeType && b.endOffset > 0 && (a = b.endContainer.childNodes[b.endOffset - 1]) && 1 == a.nodeType && !K(a).isSingle();) b.setEnd(a, a.childNodes.length);
  1590. return b
  1591. },
  1592. createBookmark: function(a) {
  1593. var b, c = this,
  1594. d = c.doc,
  1595. e = K('<span style="display:none;"></span>', d)[0];
  1596. return e.id = "__kindeditor_bookmark_start_" + _BOOKMARK_ID+++"__",
  1597. c.collapsed || (b = e.cloneNode(!0), b.id = "__kindeditor_bookmark_end_" + _BOOKMARK_ID+++"__"),
  1598. b && c.cloneRange().collapse(!1).insertNode(b).setEndBefore(b),
  1599. c.insertNode(e).setStartAfter(e),
  1600. {
  1601. start: a ? "#" + e.id: e,
  1602. end: b ? a ? "#" + b.id: b: null
  1603. }
  1604. },
  1605. moveToBookmark: function(a) {
  1606. var b = this,
  1607. c = b.doc,
  1608. d = K(a.start, c),
  1609. e = a.end ? K(a.end, c) : null;
  1610. return ! d || d.length < 1 ? b: (b.setStartBefore(d[0]), d.remove(), e && e.length > 0 ? (b.setEndBefore(e[0]), e.remove()) : b.collapse(!0), b)
  1611. },
  1612. dump: function() {
  1613. console.log("--------------------"),
  1614. console.log(3 == this.startContainer.nodeType ? this.startContainer.nodeValue: this.startContainer, this.startOffset),
  1615. console.log(3 == this.endContainer.nodeType ? this.endContainer.nodeValue: this.endContainer, this.endOffset)
  1616. }
  1617. }),
  1618. K.RangeClass = KRange,
  1619. K.range = _range,
  1620. K.START_TO_START = _START_TO_START,
  1621. K.START_TO_END = _START_TO_END,
  1622. K.END_TO_END = _END_TO_END,
  1623. K.END_TO_START = _END_TO_START,
  1624. _extend(KCmd, {
  1625. init: function(a) {
  1626. var b = this,
  1627. c = a.doc;
  1628. b.doc = c,
  1629. b.win = _getWin(c),
  1630. b.sel = _getSel(c),
  1631. b.range = a
  1632. },
  1633. selection: function(a) {
  1634. var b = this,
  1635. c = b.doc,
  1636. d = _getRng(c);
  1637. return b.sel = _getSel(c),
  1638. d ? (b.range = _range(d), "html" == K(b.range.startContainer).name && b.range.selectNodeContents(c.body).collapse(!1), b) : (a && b.range.selectNodeContents(c.body).collapse(!1), b)
  1639. },
  1640. select: function(a) {
  1641. a = _undef(a, !0);
  1642. var b, c = this,
  1643. d = c.sel,
  1644. e = c.range.cloneRange().shrink(),
  1645. f = e.startContainer,
  1646. g = e.startOffset,
  1647. h = (e.endContainer, e.endOffset, _getDoc(f)),
  1648. i = c.win,
  1649. j = !1;
  1650. if (a && 1 == f.nodeType && e.collapsed) {
  1651. if (_IERANGE) {
  1652. var k = K("<span>&nbsp;</span>", h);
  1653. e.insertNode(k[0]),
  1654. b = h.body.createTextRange();
  1655. try {
  1656. b.moveToElementText(k[0])
  1657. } catch(l) {}
  1658. return b.collapse(!1),
  1659. b.select(),
  1660. k.remove(),
  1661. i.focus(),
  1662. c
  1663. }
  1664. if (_WEBKIT) {
  1665. var m = f.childNodes; (K(f).isInline() || g > 0 && K(m[g - 1]).isInline() || m[g] && K(m[g]).isInline()) && (e.insertNode(h.createTextNode("​")), j = !0)
  1666. }
  1667. }
  1668. if (_IERANGE) try {
  1669. b = e.get(!0),
  1670. b.select()
  1671. } catch(n) {} else if (j && e.collapse(!1), b = e.get(!0), d.removeAllRanges(), d.addRange(b), h !== document) {
  1672. var o = K(b.endContainer).pos();
  1673. i.scrollTo(o.x, o.y)
  1674. }
  1675. return i.focus(),
  1676. c
  1677. },
  1678. wrap: function(a) {
  1679. var b, c = this,
  1680. d = c.doc,
  1681. e = c.range;
  1682. if (b = K(a, d), e.collapsed) return e.shrink(),
  1683. e.insertNode(b[0]).selectNodeContents(b[0]),
  1684. c;
  1685. if (b.isBlock()) {
  1686. for (var f = b.clone(!0), g = f; g.first();) g = g.first();
  1687. return g.append(e.extractContents()),
  1688. e.insertNode(f[0]).selectNode(f[0]),
  1689. c
  1690. }
  1691. e.enlarge();
  1692. var h = e.createBookmark(),
  1693. i = e.commonAncestor(),
  1694. j = !1;
  1695. return K(i).scan(function(a) {
  1696. if (!j && a == h.start) return void(j = !0);
  1697. if (j) {
  1698. if (a == h.end) return ! 1;
  1699. var c = K(a);
  1700. if (_inPreElement(c)) return;
  1701. if (3 == c.type && _trim(a.nodeValue).length > 0) {
  1702. for (var d; (d = c.parent()) && d.isStyle() && 1 == d.children().length;) c = d;
  1703. _wrapNode(c, b)
  1704. }
  1705. }
  1706. }),
  1707. e.moveToBookmark(h),
  1708. c
  1709. },
  1710. split: function(a, b) {
  1711. for (var c, d = this.range,
  1712. e = d.doc,
  1713. f = d.cloneRange().collapse(a), g = f.startContainer, h = f.startOffset, i = 3 == g.nodeType ? g.parentNode: g, j = !1; i && i.parentNode;) {
  1714. if (c = K(i), b) {
  1715. if (!c.isStyle()) break;
  1716. if (!_hasAttrOrCss(c, b)) break
  1717. } else if (_NOSPLIT_TAG_MAP[c.name]) break;
  1718. j = !0,
  1719. i = i.parentNode
  1720. }
  1721. if (j) {
  1722. var k = e.createElement("span");
  1723. d.cloneRange().collapse(!a).insertNode(k),
  1724. a ? f.setStartBefore(i.firstChild).setEnd(g, h) : f.setStart(g, h).setEndAfter(i.lastChild);
  1725. var l = f.extractContents(),
  1726. m = l.firstChild,
  1727. n = l.lastChild;
  1728. a ? (f.insertNode(l), d.setStartAfter(n).setEndBefore(k)) : (i.appendChild(l), d.setStartBefore(k).setEndBefore(m));
  1729. var o = k.parentNode;
  1730. if (o == d.endContainer) {
  1731. var p = K(k).prev(),
  1732. q = K(k).next();
  1733. p && q && 3 == p.type && 3 == q.type ? d.setEnd(p[0], p[0].nodeValue.length) : a || d.setEnd(d.endContainer, d.endOffset - 1)
  1734. }
  1735. o.removeChild(k)
  1736. }
  1737. return this
  1738. },
  1739. remove: function(a) {
  1740. var b = this,
  1741. c = b.doc,
  1742. d = b.range;
  1743. if (d.enlarge(), 0 === d.startOffset) {
  1744. for (var e, f = K(d.startContainer); (e = f.parent()) && e.isStyle() && 1 == e.children().length;) f = e;
  1745. d.setStart(f[0], 0),
  1746. f = K(d.startContainer),
  1747. f.isBlock() && _removeAttrOrCss(f, a);
  1748. var g = f.parent();
  1749. g && g.isBlock() && _removeAttrOrCss(g, a)
  1750. }
  1751. var h, i;
  1752. if (d.collapsed) {
  1753. if (b.split(!0, a), h = d.startContainer, i = d.startOffset, i > 0) {
  1754. var j = K(h.childNodes[i - 1]);
  1755. j && _isEmptyNode(j) && (j.remove(), d.setStart(h, i - 1))
  1756. }
  1757. var k = K(h.childNodes[i]);
  1758. return k && _isEmptyNode(k) && k.remove(),
  1759. _isEmptyNode(h) && (d.startBefore(h), h.remove()),
  1760. d.collapse(!0),
  1761. b
  1762. }
  1763. b.split(!0, a),
  1764. b.split(!1, a);
  1765. var l = c.createElement("span"),
  1766. m = c.createElement("span");
  1767. d.cloneRange().collapse(!1).insertNode(m),
  1768. d.cloneRange().collapse(!0).insertNode(l);
  1769. var n = [],
  1770. o = !1;
  1771. K(d.commonAncestor()).scan(function(a) {
  1772. return o || a != l ? a == m ? !1 : void(o && n.push(a)) : void(o = !0)
  1773. }),
  1774. K(l).remove(),
  1775. K(m).remove(),
  1776. h = d.startContainer,
  1777. i = d.startOffset;
  1778. var p = d.endContainer,
  1779. q = d.endOffset;
  1780. if (i > 0) {
  1781. var r = K(h.childNodes[i - 1]);
  1782. r && _isEmptyNode(r) && (r.remove(), d.setStart(h, i - 1), h == p && d.setEnd(p, q - 1));
  1783. var s = K(h.childNodes[i]);
  1784. s && _isEmptyNode(s) && (s.remove(), h == p && d.setEnd(p, q - 1))
  1785. }
  1786. var t = K(p.childNodes[d.endOffset]);
  1787. t && _isEmptyNode(t) && t.remove();
  1788. var u = d.createBookmark(!0);
  1789. return _each(n,
  1790. function(b, c) {
  1791. _removeAttrOrCss(K(c), a)
  1792. }),
  1793. d.moveToBookmark(u),
  1794. b
  1795. },
  1796. commonNode: function(a) {
  1797. function b(b) {
  1798. for (var c = b,
  1799. d = b; d;) {
  1800. if (_hasAttrOrCss(K(d), a)) return K(d);
  1801. d = d.parentNode
  1802. }
  1803. for (; c && (c = c.lastChild);) if (_hasAttrOrCss(K(c), a)) return K(c);
  1804. return null
  1805. }
  1806. var c = this.range,
  1807. d = c.endContainer,
  1808. e = c.endOffset,
  1809. f = 3 == d.nodeType || 0 === e ? d: d.childNodes[e - 1],
  1810. g = b(f);
  1811. if (g) return g;
  1812. if (1 == f.nodeType || 3 == d.nodeType && 0 === e) {
  1813. var h = K(f).prev();
  1814. if (h) return b(h)
  1815. }
  1816. return null
  1817. },
  1818. commonAncestor: function(a) {
  1819. function b(b) {
  1820. for (; b;) {
  1821. if (1 == b.nodeType && b.tagName.toLowerCase() === a) return b;
  1822. b = b.parentNode
  1823. }
  1824. return null
  1825. }
  1826. var c = this.range,
  1827. d = c.startContainer,
  1828. e = c.startOffset,
  1829. f = c.endContainer,
  1830. g = c.endOffset,
  1831. h = 3 == d.nodeType || 0 === e ? d: d.childNodes[e - 1],
  1832. i = 3 == f.nodeType || 0 === g ? f: f.childNodes[g - 1],
  1833. j = b(h),
  1834. k = b(i);
  1835. return j && k && j === k ? K(j) : null
  1836. },
  1837. state: function(a) {
  1838. var b = this,
  1839. c = b.doc,
  1840. d = !1;
  1841. try {
  1842. d = c.queryCommandState(a)
  1843. } catch(e) {}
  1844. return d
  1845. },
  1846. val: function(a) {
  1847. function b(a) {
  1848. return a.toLowerCase()
  1849. } {
  1850. var c = this,
  1851. d = c.doc;
  1852. c.range
  1853. }
  1854. a = b(a);
  1855. var e, f = "";
  1856. return "fontfamily" === a || "fontname" === a ? (f = _nativeCommandValue(d, "fontname"), f = f.replace(/['"]/g, ""), b(f)) : "formatblock" === a ? (f = _nativeCommandValue(d, a), "" === f && (e = c.commonNode({
  1857. "h1,h2,h3,h4,h5,h6,p,div,pre,address": "*"
  1858. }), e && (f = e.name)), "Normal" === f && (f = "p"), b(f)) : "fontsize" === a ? (e = c.commonNode({
  1859. "*": ".font-size"
  1860. }), e && (f = e.css("font-size")), b(f)) : "forecolor" === a ? (e = c.commonNode({
  1861. "*": ".color"
  1862. }), e && (f = e.css("color")), f = _toHex(f), "" === f && (f = "default"), b(f)) : "hilitecolor" === a ? (e = c.commonNode({
  1863. "*": ".background-color"
  1864. }), e && (f = e.css("background-color")), f = _toHex(f), "" === f && (f = "default"), b(f)) : f
  1865. },
  1866. toggle: function(a, b) {
  1867. var c = this;
  1868. return c.commonNode(b) ? c.remove(b) : c.wrap(a),
  1869. c.select()
  1870. },
  1871. bold: function() {
  1872. return this.toggle("<strong></strong>", {
  1873. span: ".font-weight=bold",
  1874. strong: "*",
  1875. b: "*"
  1876. })
  1877. },
  1878. italic: function() {
  1879. return this.toggle("<em></em>", {
  1880. span: ".font-style=italic",
  1881. em: "*",
  1882. i: "*"
  1883. })
  1884. },
  1885. underline: function() {
  1886. return this.toggle("<u></u>", {
  1887. span: ".text-decoration=underline",
  1888. u: "*"
  1889. })
  1890. },
  1891. strikethrough: function() {
  1892. return this.toggle("<s></s>", {
  1893. span: ".text-decoration=line-through",
  1894. s: "*"
  1895. })
  1896. },
  1897. forecolor: function(a) {
  1898. return this.wrap('<span style="color:' + a + ';"></span>').select()
  1899. },
  1900. hilitecolor: function(a) {
  1901. return this.wrap('<span style="background-color:' + a + ';"></span>').select()
  1902. },
  1903. fontsize: function(a) {
  1904. return this.wrap('<span style="font-size:' + a + ';"></span>').select()
  1905. },
  1906. fontname: function(a) {
  1907. return this.fontfamily(a)
  1908. },
  1909. fontfamily: function(a) {
  1910. return this.wrap('<span style="font-family:' + a + ';"></span>').select()
  1911. },
  1912. removeformat: function() {
  1913. var a = {
  1914. "*": ".font-weight,.font-style,.text-decoration,.color,.background-color,.font-size,.font-family,.text-indent"
  1915. },
  1916. b = _STYLE_TAG_MAP;
  1917. return _each(b,
  1918. function(b) {
  1919. a[b] = "*"
  1920. }),
  1921. this.remove(a),
  1922. this.select()
  1923. },
  1924. inserthtml: function(a, b) {
  1925. function c(a, b) {
  1926. b = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + b;
  1927. var c = a.get();
  1928. c.item ? c.item(0).outerHTML = b: c.pasteHTML(b);
  1929. var d = a.doc.getElementById("__kindeditor_temp_tag__");
  1930. d.parentNode.removeChild(d);
  1931. var f = _toRange(c);
  1932. a.setEnd(f.endContainer, f.endOffset),
  1933. a.collapse(!1),
  1934. e.select(!1)
  1935. }
  1936. function d(a, b) {
  1937. var c = a.doc,
  1938. d = c.createDocumentFragment();
  1939. K("@" + b, c).each(function() {
  1940. d.appendChild(this)
  1941. }),
  1942. a.deleteContents(),
  1943. a.insertNode(d),
  1944. a.collapse(!1),
  1945. e.select(!1)
  1946. }
  1947. var e = this,
  1948. f = e.range;
  1949. if ("" === a) return e;
  1950. if (_IERANGE && b) {
  1951. try {
  1952. c(f, a)
  1953. } catch(g) {
  1954. d(f, a)
  1955. }
  1956. return e
  1957. }
  1958. return d(f, a),
  1959. e
  1960. },
  1961. hr: function() {
  1962. return this.inserthtml("<hr />")
  1963. },
  1964. print: function() {
  1965. return this.win.print(),
  1966. this
  1967. },
  1968. insertimage: function(a, b, c, d, e, f) {
  1969. b = _undef(b, ""),
  1970. e = _undef(e, 0);
  1971. var g = '<img src="' + _escape(a) + '" data-ke-src="' + _escape(a) + '" ';
  1972. return c && (g += 'width="' + _escape(c) + '" '),
  1973. d && (g += 'height="' + _escape(d) + '" '),
  1974. b && (g += 'title="' + _escape(b) + '" '),
  1975. f && (g += 'align="' + _escape(f) + '" '),
  1976. g += 'alt="' + _escape(b) + '" ',
  1977. g += "/>",
  1978. this.inserthtml(g)
  1979. },
  1980. createlink: function(a, b) {
  1981. function c(a, b, c) {
  1982. K(a).attr("href", b).attr("data-ke-src", b),
  1983. c ? K(a).attr("target", c) : K(a).removeAttr("target")
  1984. }
  1985. var d = this,
  1986. e = d.doc,
  1987. f = d.range;
  1988. d.select();
  1989. var g = d.commonNode({
  1990. a: "*"
  1991. });
  1992. g && !f.isControl() && (f.selectNode(g.get()), d.select());
  1993. var h = '<a href="' + _escape(a) + '" data-ke-src="' + _escape(a) + '" ';
  1994. if (b && (h += ' target="' + _escape(b) + '"'), f.collapsed) return h += ">" + _escape(a) + "</a>",
  1995. d.inserthtml(h);
  1996. if (f.isControl()) {
  1997. var i = K(f.startContainer.childNodes[f.startOffset]);
  1998. return h += "></a>",
  1999. i.after(K(h, e)),
  2000. i.next().append(i),
  2001. f.selectNode(i[0]),
  2002. d.select()
  2003. }
  2004. var j = f.startContainer,
  2005. k = f.startOffset,
  2006. l = f.endContainer,
  2007. m = f.endOffset;
  2008. if (1 == j.nodeType && j === l && k + 1 === m) {
  2009. var n = j.childNodes[k];
  2010. if ("a" == n.nodeName.toLowerCase()) return c(n, a, b),
  2011. d
  2012. }
  2013. return _nativeCommand(e, "createlink", "__kindeditor_temp_url__"),
  2014. K('a[href="__kindeditor_temp_url__"]', e).each(function() {
  2015. c(this, a, b)
  2016. }),
  2017. d
  2018. },
  2019. unlink: function() {
  2020. var a = this,
  2021. b = a.doc,
  2022. c = a.range;
  2023. if (a.select(), c.collapsed) {
  2024. var d = a.commonNode({
  2025. a: "*"
  2026. });
  2027. if (d && (c.selectNode(d.get()), a.select()), _nativeCommand(b, "unlink", null), _WEBKIT && "img" === K(c.startContainer).name) {
  2028. var e = K(c.startContainer).parent();
  2029. "a" === e.name && e.remove(!0)
  2030. }
  2031. } else _nativeCommand(b, "unlink", null);
  2032. return a
  2033. }
  2034. }),
  2035. _each("formatblock,selectall,justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,indent,outdent,subscript,superscript".split(","),
  2036. function(a, b) {
  2037. KCmd.prototype[b] = function(a) {
  2038. var c = this;
  2039. return c.select(),
  2040. _nativeCommand(c.doc, b, a),
  2041. _IERANGE && _inArray(b, "justifyleft,justifycenter,justifyright,justifyfull".split(",")) >= 0 && c.selection(),
  2042. (!_IERANGE || _inArray(b, "formatblock,selectall,insertorderedlist,insertunorderedlist".split(",")) >= 0) && c.selection(),
  2043. c
  2044. }
  2045. }),
  2046. _each("cut,copy,paste".split(","),
  2047. function(a, b) {
  2048. KCmd.prototype[b] = function() {
  2049. var a = this;
  2050. if (!a.doc.queryCommandSupported(b)) throw "not supported";
  2051. return a.select(),
  2052. _nativeCommand(a.doc, b, null),
  2053. a
  2054. }
  2055. }),
  2056. K.CmdClass = KCmd,
  2057. K.cmd = _cmd,
  2058. _extend(KWidget, {
  2059. init: function(a) {
  2060. var b = this;
  2061. if (b.name = a.name || "", b.doc = a.doc || document, b.win = _getWin(b.doc), b.x = _addUnit(a.x), b.y = _addUnit(a.y), b.z = a.z, b.width = _addUnit(a.width), b.height = _addUnit(a.height), b.div = K('<div style="display:block;"></div>'), b.options = a, b._alignEl = a.alignEl, b.width && b.div.css("width", b.width), b.height && b.div.css("height", b.height), b.z && b.div.css({
  2062. position: "absolute",
  2063. left: b.x,
  2064. top: b.y,
  2065. "z-index": b.z
  2066. }), !b.z || b.x !== undefined && b.y !== undefined || b.autoPos(b.width, b.height), a.cls && b.div.addClass(a.cls), a.shadowMode && b.div.addClass("ke-shadow"), a.css && b.div.css(a.css), a.src ? K(a.src).replaceWith(b.div) : K(b.doc.body).append(b.div), a.html && b.div.html(a.html), a.autoScroll) if (_IE && 7 > _V || _QUIRKS) {
  2067. var c = _getScrollPos();
  2068. K(b.win).bind("scroll",
  2069. function() {
  2070. var a = _getScrollPos(),
  2071. d = a.x - c.x,
  2072. e = a.y - c.y;
  2073. b.pos(_removeUnit(b.x) + d, _removeUnit(b.y) + e, !1)
  2074. })
  2075. } else b.div.css("position", "fixed")
  2076. },
  2077. pos: function(a, b, c) {
  2078. var d = this;
  2079. return c = _undef(c, !0),
  2080. null !== a && (a = 0 > a ? 0 : _addUnit(a), d.div.css("left", a), c && (d.x = a)),
  2081. null !== b && (b = 0 > b ? 0 : _addUnit(b), d.div.css("top", b), c && (d.y = b)),
  2082. d
  2083. },
  2084. autoPos: function(a, b) {
  2085. var c = this,
  2086. d = _removeUnit(a) || 0,
  2087. e = _removeUnit(b) || 0,
  2088. f = _getScrollPos();
  2089. if (c._alignEl) {
  2090. var g = K(c._alignEl),
  2091. h = g.pos(),
  2092. i = _round(g[0].clientWidth / 2 - d / 2),
  2093. j = _round(g[0].clientHeight / 2 - e / 2);
  2094. x = 0 > i ? h.x: h.x + i,
  2095. y = 0 > j ? h.y: h.y + j
  2096. } else {
  2097. var k = _docElement(c.doc);
  2098. x = _round(f.x + (k.clientWidth - d) / 2),
  2099. y = _round(f.y + (k.clientHeight - e) / 2)
  2100. }
  2101. return _IE && 7 > _V || _QUIRKS || (x -= f.x, y -= f.y),
  2102. c.pos(x, y)
  2103. },
  2104. remove: function() {
  2105. var a = this;
  2106. return (_IE && 7 > _V || _QUIRKS) && K(a.win).unbind("scroll"),
  2107. a.div.remove(),
  2108. _each(a,
  2109. function(b) {
  2110. a[b] = null
  2111. }),
  2112. this
  2113. },
  2114. show: function() {
  2115. return this.div.show(),
  2116. this
  2117. },
  2118. hide: function() {
  2119. return this.div.hide(),
  2120. this
  2121. },
  2122. draggable: function(a) {
  2123. var b = this;
  2124. return a = a || {},
  2125. a.moveEl = b.div,
  2126. a.moveFn = function(a, c, d, e, f, g) { (a += f) < 0 && (a = 0),
  2127. (c += g) < 0 && (c = 0),
  2128. b.pos(a, c)
  2129. },
  2130. _drag(a),
  2131. b
  2132. }
  2133. }),
  2134. K.WidgetClass = KWidget,
  2135. K.widget = _widget;
  2136. var html, _direction = ""; (html = document.getElementsByTagName("html")) && (_direction = html[0].dir),
  2137. _extend(KEdit, KWidget, {
  2138. init: function(a) {
  2139. function b() {
  2140. var b = _iframeDoc(c.iframe);
  2141. b.open(),
  2142. h && (b.domain = document.domain),
  2143. b.write(_getInitHtml(d, e, f, g)),
  2144. b.close(),
  2145. c.win = c.iframe[0].contentWindow,
  2146. c.doc = b;
  2147. var i = _cmd(b);
  2148. c.afterChange(function() {
  2149. i.selection()
  2150. }),
  2151. _WEBKIT && K(b).click(function(a) {
  2152. "img" === K(a.target).name && (i.selection(!0), i.range.selectNode(a.target), i.select())
  2153. }),
  2154. _IE && (c._mousedownHandler = function() {
  2155. var a = i.range.cloneRange();
  2156. a.shrink(),
  2157. a.isControl() && c.blur()
  2158. },
  2159. K(document).mousedown(c._mousedownHandler), K(b).keydown(function(a) {
  2160. if (8 == a.which) {
  2161. i.selection();
  2162. var b = i.range;
  2163. b.isControl() && (b.collapse(!0), K(b.startContainer.childNodes[b.startOffset]).remove(), a.preventDefault())
  2164. }
  2165. })),
  2166. c.cmd = i,
  2167. c.html(_elementVal(c.srcElement)),
  2168. _IE ? (b.body.disabled = !0, b.body.contentEditable = !0, b.body.removeAttribute("disabled")) : b.designMode = "on",
  2169. a.afterCreate && a.afterCreate.call(c)
  2170. }
  2171. var c = this;
  2172. KEdit.parent.init.call(c, a),
  2173. c.srcElement = K(a.srcElement),
  2174. c.div.addClass("ke-edit"),
  2175. c.designMode = _undef(a.designMode, !0),
  2176. c.beforeGetHtml = a.beforeGetHtml,
  2177. c.beforeSetHtml = a.beforeSetHtml,
  2178. c.afterSetHtml = a.afterSetHtml;
  2179. var d = _undef(a.themesPath, ""),
  2180. e = a.bodyClass,
  2181. f = a.cssPath,
  2182. g = a.cssData,
  2183. h = "res:" != location.protocol && location.host.replace(/:\d+/, "") !== document.domain,
  2184. i = "document.open();" + (h ? 'document.domain="' + document.domain + '";': "") + "document.close();",
  2185. j = _IE ? ' src="javascript:void(function(){' + encodeURIComponent(i) + '}())"': "";
  2186. c.iframe = K('<iframe class="ke-edit-iframe" hidefocus="true" frameborder="0"' + j + "></iframe>").css("width", "100%"),
  2187. c.textarea = K('<textarea class="ke-edit-textarea" hidefocus="true"></textarea>').css("width", "100%"),
  2188. c.tabIndex = isNaN(parseInt(a.tabIndex, 10)) ? c.srcElement.attr("tabindex") : parseInt(a.tabIndex, 10),
  2189. c.iframe.attr("tabindex", c.tabIndex),
  2190. c.textarea.attr("tabindex", c.tabIndex),
  2191. c.width && c.setWidth(c.width),
  2192. c.height && c.setHeight(c.height),
  2193. c.designMode ? c.textarea.hide() : c.iframe.hide(),
  2194. h && c.iframe.bind("load",
  2195. function() {
  2196. c.iframe.unbind("load"),
  2197. _IE ? b() : setTimeout(b, 0)
  2198. }),
  2199. c.div.append(c.iframe),
  2200. c.div.append(c.textarea),
  2201. c.srcElement.hide(),
  2202. !h && b()
  2203. },
  2204. setWidth: function(a) {
  2205. var b = this;
  2206. return a = _addUnit(a),
  2207. b.width = a,
  2208. b.div.css("width", a),
  2209. b
  2210. },
  2211. setHeight: function(a) {
  2212. var b = this;
  2213. return a = _addUnit(a),
  2214. b.height = a,
  2215. b.div.css("height", a),
  2216. b.iframe.css("height", a),
  2217. (_IE && 8 > _V || _QUIRKS) && (a = _addUnit(_removeUnit(a) - 2)),
  2218. b.textarea.css("height", a),
  2219. b
  2220. },
  2221. remove: function() {
  2222. var a = this,
  2223. b = a.doc;
  2224. K(b.body).unbind(),
  2225. K(b).unbind(),
  2226. K(a.win).unbind(),
  2227. a._mousedownHandler && K(document).unbind("mousedown", a._mousedownHandler),
  2228. _elementVal(a.srcElement, a.html()),
  2229. a.srcElement.show(),
  2230. a.iframe.unbind(),
  2231. a.textarea.unbind(),
  2232. KEdit.parent.remove.call(a)
  2233. },
  2234. html: function(a, b) {
  2235. var c = this,
  2236. d = c.doc;
  2237. if (c.designMode) {
  2238. var e = d.body;
  2239. return a === undefined ? (a = b ? "<!doctype html><html>" + e.parentNode.innerHTML + "</html>": e.innerHTML, c.beforeGetHtml && (a = c.beforeGetHtml(a)), _GECKO && "<br />" == a && (a = ""), a) : (c.beforeSetHtml && (a = c.beforeSetHtml(a)), _IE && _V >= 9 && (a = a.replace(/(<.*?checked=")checked(".*>)/gi, "$1$2")), K(e).html(a), c.afterSetHtml && c.afterSetHtml(), c)
  2240. }
  2241. return a === undefined ? c.textarea.val() : (c.textarea.val(a), c)
  2242. },
  2243. design: function(a) {
  2244. var b, c = this;
  2245. if (a === undefined ? !c.designMode: a) {
  2246. if (!c.designMode) {
  2247. b = c.html(),
  2248. c.designMode = !0,
  2249. c.textarea.hide(),
  2250. c.html(b);
  2251. var d = c.iframe,
  2252. e = _removeUnit(c.height);
  2253. d.height(e - 2),
  2254. d.show(),
  2255. setTimeout(function() {
  2256. d.height(e)
  2257. },
  2258. 0)
  2259. }
  2260. } else c.designMode && (b = c.html(), c.designMode = !1, c.html(b), c.iframe.hide(), c.textarea.show());
  2261. return c.focus()
  2262. },
  2263. focus: function() {
  2264. var a = this;
  2265. return a.designMode ? a.win.focus() : a.textarea[0].focus(),
  2266. a
  2267. },
  2268. blur: function() {
  2269. var a = this;
  2270. if (_IE) {
  2271. var b = K('<input type="text" style="float:left;width:0;height:0;padding:0;margin:0;border:0;" value="" />', a.div);
  2272. a.div.append(b),
  2273. b[0].focus(),
  2274. b.remove()
  2275. } else a.designMode ? a.win.blur() : a.textarea[0].blur();
  2276. return a
  2277. },
  2278. afterChange: function(a) {
  2279. function b(b) {
  2280. setTimeout(function() {
  2281. a(b)
  2282. },
  2283. 1)
  2284. }
  2285. var c = this,
  2286. d = c.doc,
  2287. e = d.body;
  2288. return K(d).keyup(function(b) {
  2289. b.ctrlKey || b.altKey || !_CHANGE_KEY_MAP[b.which] || a(b)
  2290. }),
  2291. K(d).mouseup(a).contextmenu(a),
  2292. K(c.win).blur(a),
  2293. K(e).bind("paste", b),
  2294. K(e).bind("cut", b),
  2295. c
  2296. }
  2297. }),
  2298. K.EditClass = KEdit,
  2299. K.edit = _edit,
  2300. K.iframeDoc = _iframeDoc,
  2301. _extend(KToolbar, KWidget, {
  2302. init: function(a) {
  2303. function b(a) {
  2304. var b = K(a);
  2305. return b.hasClass("ke-outline") ? b: b.hasClass("ke-toolbar-icon") ? b.parent() : void 0
  2306. }
  2307. function c(a, c) {
  2308. var d = b(a.target);
  2309. if (d) {
  2310. if (d.hasClass("ke-disabled")) return;
  2311. if (d.hasClass("ke-selected")) return;
  2312. d[c]("ke-on")
  2313. }
  2314. }
  2315. var d = this;
  2316. KToolbar.parent.init.call(d, a),
  2317. d.disableMode = _undef(a.disableMode, !1),
  2318. d.noDisableItemMap = _toMap(_undef(a.noDisableItems, [])),
  2319. d._itemMap = {},
  2320. d.div.addClass("ke-toolbar").bind("contextmenu,mousedown,mousemove",
  2321. function(a) {
  2322. a.preventDefault()
  2323. }).attr("unselectable", "on"),
  2324. d.div.mouseover(function(a) {
  2325. c(a, "addClass")
  2326. }).mouseout(function(a) {
  2327. c(a, "removeClass")
  2328. }).click(function(a) {
  2329. var c = b(a.target);
  2330. if (c) {
  2331. if (c.hasClass("ke-disabled")) return;
  2332. d.options.click.call(this, a, c.attr("data-name"))
  2333. }
  2334. })
  2335. },
  2336. get: function(a) {
  2337. return this._itemMap[a] ? this._itemMap[a] : this._itemMap[a] = K("span.ke-icon-" + a, this.div).parent()
  2338. },
  2339. select: function(a) {
  2340. return _selectToolbar.call(this, a,
  2341. function(a) {
  2342. a.addClass("ke-selected")
  2343. }),
  2344. self
  2345. },
  2346. unselect: function(a) {
  2347. return _selectToolbar.call(this, a,
  2348. function(a) {
  2349. a.removeClass("ke-selected").removeClass("ke-on")
  2350. }),
  2351. self
  2352. },
  2353. enable: function(a) {
  2354. var b = this,
  2355. c = a.get ? a: b.get(a);
  2356. return c && (c.removeClass("ke-disabled"), c.opacity(1)),
  2357. b
  2358. },
  2359. disable: function(a) {
  2360. var b = this,
  2361. c = a.get ? a: b.get(a);
  2362. return c && (c.removeClass("ke-selected").addClass("ke-disabled"), c.opacity(.5)),
  2363. b
  2364. },
  2365. disableAll: function(a, b) {
  2366. var c = this,
  2367. d = c.noDisableItemMap;
  2368. return b && (d = _toMap(b)),
  2369. (a === undefined ? !c.disableMode: a) ? (K("span.ke-outline", c.div).each(function() {
  2370. var a = K(this),
  2371. b = a[0].getAttribute("data-name", 2);
  2372. d[b] || c.disable(a)
  2373. }), c.disableMode = !0) : (K("span.ke-outline", c.div).each(function() {
  2374. var a = K(this),
  2375. b = a[0].getAttribute("data-name", 2);
  2376. d[b] || c.enable(a)
  2377. }), c.disableMode = !1),
  2378. c
  2379. }
  2380. }),
  2381. K.ToolbarClass = KToolbar,
  2382. K.toolbar = _toolbar,
  2383. _extend(KMenu, KWidget, {
  2384. init: function(a) {
  2385. var b = this;
  2386. a.z = a.z || 811213,
  2387. KMenu.parent.init.call(b, a),
  2388. b.centerLineMode = _undef(a.centerLineMode, !0),
  2389. b.div.addClass("ke-menu").bind("click,mousedown",
  2390. function(a) {
  2391. a.stopPropagation()
  2392. }).attr("unselectable", "on")
  2393. },
  2394. addItem: function(a) {
  2395. var b = this;
  2396. if ("-" === a.title) return void b.div.append(K('<div class="ke-menu-separator"></div>'));
  2397. var c = K('<div class="ke-menu-item" unselectable="on"></div>'),
  2398. d = K('<div class="ke-inline-block ke-menu-item-left"></div>'),
  2399. e = K('<div class="ke-inline-block ke-menu-item-right"></div>'),
  2400. f = _addUnit(a.height),
  2401. g = _undef(a.iconClass, "");
  2402. b.div.append(c),
  2403. f && (c.css("height", f), e.css("line-height", f));
  2404. var h;
  2405. return b.centerLineMode && (h = K('<div class="ke-inline-block ke-menu-item-center"></div>'), f && h.css("height", f)),
  2406. c.mouseover(function() {
  2407. K(this).addClass("ke-menu-item-on"),
  2408. h && h.addClass("ke-menu-item-center-on")
  2409. }).mouseout(function() {
  2410. K(this).removeClass("ke-menu-item-on"),
  2411. h && h.removeClass("ke-menu-item-center-on")
  2412. }).click(function(b) {
  2413. a.click.call(K(this)),
  2414. b.stopPropagation()
  2415. }).append(d),
  2416. h && c.append(h),
  2417. c.append(e),
  2418. a.checked && (g = "ke-icon-checked"),
  2419. "" !== g && d.html('<span class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ' + g + '"></span>'),
  2420. e.html(a.title),
  2421. b
  2422. },
  2423. remove: function() {
  2424. var a = this;
  2425. return a.options.beforeRemove && a.options.beforeRemove.call(a),
  2426. K(".ke-menu-item", a.div[0]).unbind(),
  2427. KMenu.parent.remove.call(a),
  2428. a
  2429. }
  2430. }),
  2431. K.MenuClass = KMenu,
  2432. K.menu = _menu,
  2433. _extend(KColorPicker, KWidget, {
  2434. init: function(a) {
  2435. var b = this;
  2436. a.z = a.z || 811213,
  2437. KColorPicker.parent.init.call(b, a);
  2438. var c = a.colors || [["#E53333", "#E56600", "#FF9900", "#64451D", "#DFC5A4", "#FFE500"], ["#009900", "#006600", "#99BB00", "#B8D100", "#60D978", "#00D5FF"], ["#337FE5", "#003399", "#4C33E5", "#9933E5", "#CC33E5", "#EE33EE"], ["#FFFFFF", "#CCCCCC", "#999999", "#666666", "#333333", "#000000"]];
  2439. b.selectedColor = (a.selectedColor || "").toLowerCase(),
  2440. b._cells = [],
  2441. b.div.addClass("ke-colorpicker").bind("click,mousedown",
  2442. function(a) {
  2443. a.stopPropagation()
  2444. }).attr("unselectable", "on");
  2445. var d = b.doc.createElement("table");
  2446. b.div.append(d),
  2447. d.className = "ke-colorpicker-table",
  2448. d.cellPadding = 0,
  2449. d.cellSpacing = 0,
  2450. d.border = 0;
  2451. var e = d.insertRow(0),
  2452. f = e.insertCell(0);
  2453. f.colSpan = c[0].length,
  2454. b._addAttr(f, "", "ke-colorpicker-cell-top");
  2455. for (var g = 0; g < c.length; g++) {
  2456. e = d.insertRow(g + 1);
  2457. for (var h = 0; h < c[g].length; h++) f = e.insertCell(h),
  2458. b._addAttr(f, c[g][h], "ke-colorpicker-cell")
  2459. }
  2460. },
  2461. _addAttr: function(a, b, c) {
  2462. var d = this;
  2463. a = K(a).addClass(c),
  2464. d.selectedColor === b.toLowerCase() && a.addClass("ke-colorpicker-cell-selected"),
  2465. a.attr("title", b || d.options.noColor),
  2466. a.mouseover(function() {
  2467. K(this).addClass("ke-colorpicker-cell-on")
  2468. }),
  2469. a.mouseout(function() {
  2470. K(this).removeClass("ke-colorpicker-cell-on")
  2471. }),
  2472. a.click(function(a) {
  2473. a.stop(),
  2474. d.options.click.call(K(this), b)
  2475. }),
  2476. b ? a.append(K('<div class="ke-colorpicker-cell-color" unselectable="on"></div>').css("background-color", b)) : a.html(d.options.noColor),
  2477. K(a).attr("unselectable", "on"),
  2478. d._cells.push(a)
  2479. },
  2480. remove: function() {
  2481. var a = this;
  2482. return _each(a._cells,
  2483. function() {
  2484. this.unbind()
  2485. }),
  2486. KColorPicker.parent.remove.call(a),
  2487. a
  2488. }
  2489. }),
  2490. K.ColorPickerClass = KColorPicker,
  2491. K.colorpicker = _colorpicker,
  2492. _extend(KUploadButton, {
  2493. init: function(a) {
  2494. var b = this,
  2495. c = K(a.button),
  2496. d = a.fieldName || "file",
  2497. e = a.url || "",
  2498. f = c.val(),
  2499. g = a.extraParams || {},
  2500. h = c[0].className || "",
  2501. i = a.target || "kindeditor_upload_iframe_" + (new Date).getTime();
  2502. a.afterError = a.afterError ||
  2503. function(a) {
  2504. alert(a)
  2505. };
  2506. var j = [];
  2507. for (var k in g) j.push('<input type="hidden" name="' + k + '" value="' + g[k] + '" />');
  2508. var l = ['<div class="ke-inline-block ' + h + '">', a.target ? "": '<iframe name="' + i + '" style="display:none;"></iframe>', a.form ? '<div class="ke-upload-area">': '<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + i + '" action="' + e + '">', '<span class="ke-button-common">', j.join(""), '<input type="button" class="ke-button-common ke-button" value="' + f + '" />', "</span>", '<input type="file" class="ke-upload-file" name="' + d + '" tabindex="-1" />', a.form ? "</div>": "</form>", "</div>"].join(""),
  2509. m = K(l, c.doc);
  2510. c.hide(),
  2511. c.before(m),
  2512. b.div = m,
  2513. b.button = c,
  2514. b.iframe = a.target ? K('iframe[name="' + i + '"]') : K("iframe", m),
  2515. b.form = a.form ? K(a.form) : K("form", m),
  2516. b.fileBox = K(".ke-upload-file", m);
  2517. var n = a.width || K(".ke-button-common", m).width();
  2518. K(".ke-upload-area", m).width(n),
  2519. b.options = a
  2520. },
  2521. submit: function() {
  2522. var a = this,
  2523. b = a.iframe;
  2524. return b.bind("load",
  2525. function() {
  2526. b.unbind();
  2527. var c = document.createElement("form");
  2528. a.fileBox.before(c),
  2529. K(c).append(a.fileBox),
  2530. c.reset(),
  2531. K(c).remove(!0);
  2532. var d, e = K.iframeDoc(b),
  2533. f = e.getElementsByTagName("pre")[0],
  2534. g = "";
  2535. g = f ? f.innerHTML: e.body.innerHTML,
  2536. g = _unescape(g),
  2537. b[0].src = "javascript:false";
  2538. try {
  2539. d = K.json(g)
  2540. } catch(h) {
  2541. a.options.afterError.call(a, "<!doctype html><html>" + e.body.parentNode.innerHTML + "</html>")
  2542. }
  2543. d && a.options.afterUpload.call(a, d)
  2544. }),
  2545. a.form[0].submit(),
  2546. a
  2547. },
  2548. remove: function() {
  2549. var a = this;
  2550. return a.fileBox && a.fileBox.unbind(),
  2551. a.iframe.remove(),
  2552. a.div.remove(),
  2553. a.button.show(),
  2554. a
  2555. }
  2556. }),
  2557. K.UploadButtonClass = KUploadButton,
  2558. K.uploadbutton = _uploadbutton,
  2559. _extend(KDialog, KWidget, {
  2560. init: function(a) {
  2561. var b = this,
  2562. c = _undef(a.shadowMode, !0);
  2563. a.z = a.z || 811213,
  2564. a.shadowMode = !1,
  2565. a.autoScroll = _undef(a.autoScroll, !0),
  2566. KDialog.parent.init.call(b, a);
  2567. var d = a.title,
  2568. e = K(a.body, b.doc),
  2569. f = a.previewBtn,
  2570. g = a.yesBtn,
  2571. h = a.noBtn,
  2572. i = a.closeBtn,
  2573. j = _undef(a.showMask, !0);
  2574. b.div.addClass("ke-dialog").bind("click,mousedown",
  2575. function(a) {
  2576. a.stopPropagation()
  2577. });
  2578. var k = K('<div class="ke-dialog-content"></div>').appendTo(b.div);
  2579. _IE && 7 > _V ? b.iframeMask = K('<iframe src="about:blank" class="ke-dialog-shadow"></iframe>').appendTo(b.div) : c && K('<div class="ke-dialog-shadow"></div>').appendTo(b.div);
  2580. var l = K('<div class="ke-dialog-header"></div>');
  2581. k.append(l),
  2582. l.html(d),
  2583. b.closeIcon = K('<span class="ke-dialog-icon-close" title="' + i.name + '"></span>').click(i.click),
  2584. l.append(b.closeIcon),
  2585. b.draggable({
  2586. clickEl: l,
  2587. beforeDrag: a.beforeDrag
  2588. });
  2589. var m = K('<div class="ke-dialog-body"></div>');
  2590. k.append(m),
  2591. m.append(e);
  2592. var n = K('<div class="ke-dialog-footer"></div>');
  2593. if ((f || g || h) && k.append(n), _each([{
  2594. btn: f,
  2595. name: "preview"
  2596. },
  2597. {
  2598. btn: g,
  2599. name: "yes"
  2600. },
  2601. {
  2602. btn: h,
  2603. name: "no"
  2604. }],
  2605. function() {
  2606. if (this.btn) {
  2607. var a = _createButton(this.btn);
  2608. a.addClass("ke-dialog-" + this.name),
  2609. n.append(a)
  2610. }
  2611. }), b.height && m.height(_removeUnit(b.height) - l.height() - n.height()), b.div.width(b.div.width()), b.div.height(b.div.height()), b.mask = null, j) {
  2612. var o = _docElement(b.doc),
  2613. p = Math.max(o.scrollWidth, o.clientWidth),
  2614. q = Math.max(o.scrollHeight, o.clientHeight);
  2615. b.mask = _widget({
  2616. x: 0,
  2617. y: 0,
  2618. z: b.z - 1,
  2619. cls: "ke-dialog-mask",
  2620. width: p,
  2621. height: q
  2622. })
  2623. }
  2624. b.autoPos(b.div.width(), b.div.height()),
  2625. b.footerDiv = n,
  2626. b.bodyDiv = m,
  2627. b.headerDiv = l,
  2628. b.isLoading = !1
  2629. },
  2630. setMaskIndex: function(a) {
  2631. var b = this;
  2632. b.mask.div.css("z-index", a)
  2633. },
  2634. showLoading: function(a) {
  2635. a = _undef(a, "");
  2636. var b = this,
  2637. c = b.bodyDiv;
  2638. return b.loading = K('<div class="ke-dialog-loading"><div class="ke-inline-block ke-dialog-loading-content" style="margin-top:' + Math.round(c.height() / 3) + 'px;">' + a + "</div></div>").width(c.width()).height(c.height()).css("top", b.headerDiv.height() + "px"),
  2639. c.css("visibility", "hidden").after(b.loading),
  2640. b.isLoading = !0,
  2641. b
  2642. },
  2643. hideLoading: function() {
  2644. return this.loading && this.loading.remove(),
  2645. this.bodyDiv.css("visibility", "visible"),
  2646. this.isLoading = !1,
  2647. this
  2648. },
  2649. remove: function() {
  2650. var a = this;
  2651. return a.options.beforeRemove && a.options.beforeRemove.call(a),
  2652. a.mask && a.mask.remove(),
  2653. a.iframeMask && a.iframeMask.remove(),
  2654. a.closeIcon.unbind(),
  2655. K("input", a.div).unbind(),
  2656. K("button", a.div).unbind(),
  2657. a.footerDiv.unbind(),
  2658. a.bodyDiv.unbind(),
  2659. a.headerDiv.unbind(),
  2660. K("iframe", a.div).each(function() {
  2661. K(this).remove()
  2662. }),
  2663. KDialog.parent.remove.call(a),
  2664. a
  2665. }
  2666. }),
  2667. K.DialogClass = KDialog,
  2668. K.dialog = _dialog,
  2669. K.tabs = _tabs,
  2670. K.loadScript = _loadScript,
  2671. K.loadStyle = _loadStyle,
  2672. K.ajax = _ajax;
  2673. var _plugins = {},
  2674. _language = {};
  2675. KEditor.prototype = {
  2676. lang: function(a) {
  2677. return _lang(a, this.langType)
  2678. },
  2679. loadPlugin: function(a, b) {
  2680. var c = this,
  2681. d = this._pluginStatus;
  2682. return d || (d = this._pluginStatus = {}),
  2683. _plugins[a] ? _isFunction(_plugins[a]) ? (d[a] || (_plugins[a].call(c, KindEditor), d[a] = "inited"), b && b.call(c), c) : (setTimeout(function() {
  2684. c.loadPlugin(a, b)
  2685. },
  2686. 100), c) : (_plugins[a] = "loading", _loadScript(c.pluginsPath + a + "/" + a + ".js?ver=" + encodeURIComponent(K.DEBUG ? _TIME: _VERSION),
  2687. function() {
  2688. setTimeout(function() {
  2689. _plugins[a] && c.loadPlugin(a, b)
  2690. },
  2691. 0)
  2692. }), c)
  2693. },
  2694. handler: function(a, b) {
  2695. var c = this;
  2696. return c._handlers[a] || (c._handlers[a] = []),
  2697. _isFunction(b) ? (c._handlers[a].push(b), c) : (_each(c._handlers[a],
  2698. function() {
  2699. b = this.call(c, b)
  2700. }), b)
  2701. },
  2702. clickToolbar: function(a, b) {
  2703. var c = this,
  2704. d = "clickToolbar" + a;
  2705. return b === undefined ? c._handlers[d] ? c.handler(d) : (c.loadPlugin(a,
  2706. function() {
  2707. c.handler(d)
  2708. }), c) : c.handler(d, b)
  2709. },
  2710. updateState: function() {
  2711. var a = this;
  2712. return _each("justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,subscript,superscript,bold,italic,underline,strikethrough".split(","),
  2713. function(b, c) {
  2714. a.cmd.state(c) ? a.toolbar.select(c) : a.toolbar.unselect(c)
  2715. }),
  2716. a
  2717. },
  2718. addContextmenu: function(a) {
  2719. return this._contextmenus.push(a),
  2720. this
  2721. },
  2722. afterCreate: function(a) {
  2723. return this.handler("afterCreate", a)
  2724. },
  2725. beforeRemove: function(a) {
  2726. return this.handler("beforeRemove", a)
  2727. },
  2728. beforeGetHtml: function(a) {
  2729. return this.handler("beforeGetHtml", a)
  2730. },
  2731. beforeSetHtml: function(a) {
  2732. return this.handler("beforeSetHtml", a)
  2733. },
  2734. afterSetHtml: function(a) {
  2735. return this.handler("afterSetHtml", a)
  2736. },
  2737. create: function() {
  2738. function a() {
  2739. return 0 === i.height() ? void setTimeout(a, 100) : void b.resize(d, e, !1)
  2740. }
  2741. var b = this,
  2742. c = b.fullscreenMode;
  2743. if (b.isCreated) return b;
  2744. if (b.srcElement.data("kindeditor")) return b;
  2745. b.srcElement.data("kindeditor", "true"),
  2746. _docElement().style.overflow = c ? "hidden": "";
  2747. var d = c ? _docElement().clientWidth + "px": b.width,
  2748. e = c ? _docElement().clientHeight + "px": b.height; (_IE && 8 > _V || _QUIRKS) && (e = _addUnit(_removeUnit(e) + 2));
  2749. var f = b.container = K(b.layout);
  2750. c ? K(document.body).append(f) : b.srcElement.before(f);
  2751. var g = K(".toolbar", f),
  2752. h = K(".edit", f),
  2753. i = b.statusbar = K(".statusbar", f);
  2754. f.removeClass("container").addClass("ke-container ke-container-" + b.themeType).css("width", d),
  2755. c ? (f.css({
  2756. position: "absolute",
  2757. left: 0,
  2758. top: 0,
  2759. "z-index": 811211
  2760. }), _GECKO || (b._scrollPos = _getScrollPos()), window.scrollTo(0, 0), K(document.body).css({
  2761. height: "1px",
  2762. overflow: "hidden"
  2763. }), K(document.body.parentNode).css("overflow", "hidden"), b._fullscreenExecuted = !0) : (b._fullscreenExecuted && (K(document.body).css({
  2764. height: "",
  2765. overflow: ""
  2766. }), K(document.body.parentNode).css("overflow", "")), b._scrollPos && window.scrollTo(b._scrollPos.x, b._scrollPos.y));
  2767. var j = [];
  2768. K.each(b.items,
  2769. function(a, c) {
  2770. "|" == c ? j.push('<span class="ke-inline-block ke-separator"></span>') : "/" == c ? j.push('<div class="ke-hr"></div>') : (j.push('<span class="ke-outline" data-name="' + c + '" title="' + b.lang(c) + '" unselectable="on">'), j.push('<span class="ke-toolbar-icon ke-toolbar-icon-url ke-icon-' + c + '" unselectable="on"></span></span>'))
  2771. });
  2772. var k = b.toolbar = _toolbar({
  2773. src: g,
  2774. html: j.join(""),
  2775. noDisableItems: b.noDisableItems,
  2776. click: function(a, c) {
  2777. if (a.stop(), b.menu) {
  2778. var d = b.menu.name;
  2779. if (b.hideMenu(), d === c) return
  2780. }
  2781. b.clickToolbar(c)
  2782. }
  2783. }),
  2784. l = _removeUnit(e) - k.div.height(),
  2785. m = b.edit = _edit({
  2786. height: l > 0 && _removeUnit(e) > b.minHeight ? l: b.minHeight,
  2787. src: h,
  2788. srcElement: b.srcElement,
  2789. designMode: b.designMode,
  2790. themesPath: b.themesPath,
  2791. bodyClass: b.bodyClass,
  2792. cssPath: b.cssPath,
  2793. cssData: b.cssData,
  2794. beforeGetHtml: function(a) {
  2795. return a = b.beforeGetHtml(a),
  2796. a = _removeBookmarkTag(_removeTempTag(a)),
  2797. _formatHtml(a, b.filterMode ? b.htmlTags: null, b.urlType, b.wellFormatMode, b.indentChar)
  2798. },
  2799. beforeSetHtml: function(a) {
  2800. return a = _formatHtml(a, b.filterMode ? b.htmlTags: null, "", !1),
  2801. b.beforeSetHtml(a)
  2802. },
  2803. afterSetHtml: function() {
  2804. b.edit = m = this,
  2805. b.afterSetHtml()
  2806. },
  2807. afterCreate: function() {
  2808. if (b.edit = m = this, b.cmd = m.cmd, b._docMousedownFn = function() {
  2809. b.menu && b.hideMenu()
  2810. },
  2811. K(m.doc, document).mousedown(b._docMousedownFn), _bindContextmenuEvent.call(b), _bindNewlineEvent.call(b), _bindTabEvent.call(b), _bindFocusEvent.call(b), m.afterChange(function() {
  2812. m.designMode && (b.updateState(), b.addBookmark(), b.options.afterChange && b.options.afterChange.call(b))
  2813. }), m.textarea.keyup(function(a) {
  2814. a.ctrlKey || a.altKey || !_INPUT_KEY_MAP[a.which] || b.options.afterChange && b.options.afterChange.call(b)
  2815. }), b.readonlyMode && b.readonly(), b.isCreated = !0, "" === b.initContent && (b.initContent = b.html()), b._undoStack.length > 0) {
  2816. var a = b._undoStack.pop();
  2817. a.start && (b.html(a.html), m.cmd.range.moveToBookmark(a), b.select())
  2818. }
  2819. b.afterCreate(),
  2820. b.options.afterCreate && b.options.afterCreate.call(b)
  2821. }
  2822. });
  2823. return i.removeClass("statusbar").addClass("ke-statusbar").append('<span class="ke-inline-block ke-statusbar-center-icon"></span>').append('<span class="ke-inline-block ke-statusbar-right-icon"></span>'),
  2824. b._fullscreenResizeHandler && (K(window).unbind("resize", b._fullscreenResizeHandler), b._fullscreenResizeHandler = null),
  2825. a(),
  2826. c ? (b._fullscreenResizeHandler = function() {
  2827. b.isCreated && b.resize(_docElement().clientWidth, _docElement().clientHeight, !1)
  2828. },
  2829. K(window).bind("resize", b._fullscreenResizeHandler), k.select("fullscreen"), i.first().css("visibility", "hidden"), i.last().css("visibility", "hidden")) : (_GECKO && K(window).bind("scroll",
  2830. function() {
  2831. b._scrollPos = _getScrollPos()
  2832. }), b.resizeType > 0 ? _drag({
  2833. moveEl: f,
  2834. clickEl: i,
  2835. moveFn: function(a, c, d, e, f, g) {
  2836. e += g,
  2837. b.resize(null, e)
  2838. }
  2839. }) : i.first().css("visibility", "hidden"), 2 === b.resizeType ? _drag({
  2840. moveEl: f,
  2841. clickEl: i.last(),
  2842. moveFn: function(a, c, d, e, f, g) {
  2843. d += f,
  2844. e += g,
  2845. b.resize(d, e)
  2846. }
  2847. }) : i.last().css("visibility", "hidden")),
  2848. b
  2849. },
  2850. remove: function() {
  2851. var a = this;
  2852. return a.isCreated ? (a.beforeRemove(), a.srcElement.data("kindeditor", ""), a.menu && a.hideMenu(), _each(a.dialogs,
  2853. function() {
  2854. a.hideDialog()
  2855. }), K(document).unbind("mousedown", a._docMousedownFn), a.toolbar.remove(), a.edit.remove(), a.statusbar.last().unbind(), a.statusbar.unbind(), a.container.remove(), a.container = a.toolbar = a.edit = a.menu = null, a.dialogs = [], a.isCreated = !1, a) : a
  2856. },
  2857. resize: function(a, b, c) {
  2858. var d = this;
  2859. return c = _undef(c, !0),
  2860. a && (/%/.test(a) || (a = _removeUnit(a), a = a < d.minWidth ? d.minWidth: a), d.container.css("width", _addUnit(a)), c && (d.width = _addUnit(a))),
  2861. b && (b = _removeUnit(b), editHeight = _removeUnit(b) - d.toolbar.div.height() - d.statusbar.height(), editHeight = editHeight < d.minHeight ? d.minHeight: editHeight, d.edit.setHeight(editHeight), c && (d.height = _addUnit(b))),
  2862. d
  2863. },
  2864. select: function() {
  2865. return this.isCreated && this.cmd.select(),
  2866. this
  2867. },
  2868. html: function(a) {
  2869. var b = this;
  2870. return a === undefined ? b.isCreated ? b.edit.html() : _elementVal(b.srcElement) : (b.isCreated ? b.edit.html(a) : _elementVal(b.srcElement, a), b.isCreated && b.cmd.selection(), b)
  2871. },
  2872. fullHtml: function() {
  2873. return this.isCreated ? this.edit.html(undefined, !0) : ""
  2874. },
  2875. text: function(a) {
  2876. var b = this;
  2877. return a === undefined ? _trim(b.html().replace(/<(?!img|embed).*?>/gi, "").replace(/&nbsp;/gi, " ")) : b.html(_escape(a))
  2878. },
  2879. isEmpty: function() {
  2880. return "" === _trim(this.text().replace(/\r\n|\n|\r/, ""))
  2881. },
  2882. isDirty: function() {
  2883. return _trim(this.initContent.replace(/\r\n|\n|\r|t/g, "")) !== _trim(this.html().replace(/\r\n|\n|\r|t/g, ""))
  2884. },
  2885. selectedHtml: function() {
  2886. var a = this.isCreated ? this.cmd.range.html() : "";
  2887. return a = _removeBookmarkTag(_removeTempTag(a))
  2888. },
  2889. count: function(a) {
  2890. var b = this;
  2891. return a = (a || "html").toLowerCase(),
  2892. "html" === a ? b.html().length: "text" === a ? b.text().replace(/<(?:img|embed).*?>/gi, "K").replace(/\r\n|\n|\r/g, "").length: 0
  2893. },
  2894. exec: function(a) {
  2895. a = a.toLowerCase();
  2896. var b = this,
  2897. c = b.cmd,
  2898. d = _inArray(a, "selectall,copy,paste,print".split(",")) < 0;
  2899. return d && b.addBookmark(!1),
  2900. c[a].apply(c, _toArray(arguments, 1)),
  2901. d && (b.updateState(), b.addBookmark(!1), b.options.afterChange && b.options.afterChange.call(b)),
  2902. b
  2903. },
  2904. insertHtml: function(a, b) {
  2905. return this.isCreated ? (a = this.beforeSetHtml(a), this.exec("inserthtml", a, b), this) : this
  2906. },
  2907. appendHtml: function(a) {
  2908. if (this.html(this.html() + a), this.isCreated) {
  2909. var b = this.cmd;
  2910. b.range.selectNodeContents(b.doc.body).collapse(!1),
  2911. b.select()
  2912. }
  2913. return this
  2914. },
  2915. sync: function() {
  2916. return _elementVal(this.srcElement, this.html()),
  2917. this
  2918. },
  2919. focus: function() {
  2920. return this.isCreated ? this.edit.focus() : this.srcElement[0].focus(),
  2921. this
  2922. },
  2923. blur: function() {
  2924. return this.isCreated ? this.edit.blur() : this.srcElement[0].blur(),
  2925. this
  2926. },
  2927. addBookmark: function(a) {
  2928. a = _undef(a, !0);
  2929. var b, c = this,
  2930. d = c.edit,
  2931. e = d.doc.body,
  2932. f = _removeTempTag(e.innerHTML);
  2933. if (a && c._undoStack.length > 0) {
  2934. var g = c._undoStack[c._undoStack.length - 1];
  2935. if (Math.abs(f.length - _removeBookmarkTag(g.html).length) < c.minChangeSize) return c
  2936. }
  2937. if (d.designMode && !c._firstAddBookmark) {
  2938. var h = c.cmd.range;
  2939. b = h.createBookmark(!0),
  2940. b.html = _removeTempTag(e.innerHTML),
  2941. h.moveToBookmark(b)
  2942. } else b = {
  2943. html: f
  2944. };
  2945. return c._firstAddBookmark = !1,
  2946. _addBookmarkToStack(c._undoStack, b),
  2947. c
  2948. },
  2949. undo: function() {
  2950. return _undoToRedo.call(this, this._undoStack, this._redoStack)
  2951. },
  2952. redo: function() {
  2953. return _undoToRedo.call(this, this._redoStack, this._undoStack)
  2954. },
  2955. fullscreen: function(a) {
  2956. return this.fullscreenMode = a === undefined ? !this.fullscreenMode: a,
  2957. this.addBookmark(!1),
  2958. this.remove().create()
  2959. },
  2960. readonly: function(a) {
  2961. a = _undef(a, !0);
  2962. var b = this,
  2963. c = b.edit,
  2964. d = c.doc;
  2965. b.designMode ? b.toolbar.disableAll(a, []) : _each(b.noDisableItems,
  2966. function() {
  2967. b.toolbar[a ? "disable": "enable"](this)
  2968. }),
  2969. _IE ? d.body.contentEditable = !a: d.designMode = a ? "off": "on",
  2970. c.textarea[0].disabled = a
  2971. },
  2972. createMenu: function(a) {
  2973. var b = this,
  2974. c = a.name,
  2975. d = b.toolbar.get(c),
  2976. e = d.pos();
  2977. return a.x = e.x,
  2978. a.y = e.y + d.height(),
  2979. a.z = b.options.zIndex,
  2980. a.shadowMode = _undef(a.shadowMode, b.shadowMode),
  2981. a.selectedColor !== undefined ? (a.cls = "ke-colorpicker-" + b.themeType, a.noColor = b.lang("noColor"), b.menu = _colorpicker(a)) : (a.cls = "ke-menu-" + b.themeType, a.centerLineMode = !1, b.menu = _menu(a)),
  2982. b.menu
  2983. },
  2984. hideMenu: function() {
  2985. return this.menu.remove(),
  2986. this.menu = null,
  2987. this
  2988. },
  2989. hideContextmenu: function() {
  2990. return this.contextmenu.remove(),
  2991. this.contextmenu = null,
  2992. this
  2993. },
  2994. createDialog: function(a) {
  2995. {
  2996. var b = this;
  2997. a.name
  2998. }
  2999. if (a.z = b.options.zIndex, a.shadowMode = _undef(a.shadowMode, b.shadowMode), a.closeBtn = _undef(a.closeBtn, {
  3000. name: b.lang("close"),
  3001. click: function() {
  3002. b.hideDialog(),
  3003. _IE && b.cmd && b.cmd.select()
  3004. }
  3005. }), a.noBtn = _undef(a.noBtn, {
  3006. name: b.lang(a.yesBtn ? "no": "close"),
  3007. click: function() {
  3008. b.hideDialog(),
  3009. _IE && b.cmd && b.cmd.select()
  3010. }
  3011. }), "page" != b.dialogAlignType && (a.alignEl = b.container), a.cls = "ke-dialog-" + b.themeType, b.dialogs.length > 0) {
  3012. var c = b.dialogs[0],
  3013. d = b.dialogs[b.dialogs.length - 1];
  3014. c.setMaskIndex(d.z + 2),
  3015. a.z = d.z + 3,
  3016. a.showMask = !1
  3017. }
  3018. var e = _dialog(a);
  3019. return b.dialogs.push(e),
  3020. e
  3021. },
  3022. hideDialog: function() {
  3023. var a = this;
  3024. if (a.dialogs.length > 0 && a.dialogs.pop().remove(), a.dialogs.length > 0) {
  3025. var b = a.dialogs[0],
  3026. c = a.dialogs[a.dialogs.length - 1];
  3027. b.setMaskIndex(c.z - 1)
  3028. }
  3029. return a
  3030. },
  3031. errorDialog: function(a) {
  3032. var b = this,
  3033. c = b.createDialog({
  3034. width: 750,
  3035. title: b.lang("uploadError"),
  3036. body: '<div style="padding:10px 20px;"><iframe frameborder="0" style="width:708px;height:400px;"></iframe></div>'
  3037. }),
  3038. d = K("iframe", c.div),
  3039. e = K.iframeDoc(d);
  3040. return e.open(),
  3041. e.write(a),
  3042. e.close(),
  3043. K(e.body).css("background-color", "#FFF"),
  3044. d[0].contentWindow.focus(),
  3045. b
  3046. }
  3047. },
  3048. _instances = [],
  3049. K.remove = function(a) {
  3050. _eachEditor(a,
  3051. function(a) {
  3052. this.remove(),
  3053. _instances.splice(a, 1)
  3054. })
  3055. },
  3056. K.sync = function(a) {
  3057. _eachEditor(a,
  3058. function() {
  3059. this.sync()
  3060. })
  3061. },
  3062. K.html = function(a, b) {
  3063. _eachEditor(a,
  3064. function() {
  3065. this.html(b)
  3066. })
  3067. },
  3068. K.insertHtml = function(a, b) {
  3069. _eachEditor(a,
  3070. function() {
  3071. this.insertHtml(b)
  3072. })
  3073. },
  3074. K.appendHtml = function(a, b) {
  3075. _eachEditor(a,
  3076. function() {
  3077. this.appendHtml(b)
  3078. })
  3079. },
  3080. _IE && 7 > _V && _nativeCommand(document, "BackgroundImageCache", !0),
  3081. K.EditorClass = KEditor,
  3082. K.editor = _editor,
  3083. K.create = _create,
  3084. K.instances = _instances,
  3085. K.plugin = _plugin,
  3086. K.lang = _lang,
  3087. _plugin("core",
  3088. function(a) {
  3089. var b = this,
  3090. c = {
  3091. undo: "Z",
  3092. redo: "Y",
  3093. bold: "B",
  3094. italic: "I",
  3095. underline: "U",
  3096. print: "P",
  3097. selectall: "A"
  3098. };
  3099. if (b.afterSetHtml(function() {
  3100. b.options.afterChange && b.options.afterChange.call(b)
  3101. }), b.afterCreate(function() {
  3102. if ("form" == b.syncType) {
  3103. for (var c = a(b.srcElement), d = !1; c = c.parent();) if ("form" == c.name) {
  3104. d = !0;
  3105. break
  3106. }
  3107. if (d) {
  3108. c.bind("submit",
  3109. function() {
  3110. b.sync(),
  3111. a(window).bind("unload",
  3112. function() {
  3113. b.edit.textarea.remove()
  3114. })
  3115. });
  3116. var e = a('[type="reset"]', c);
  3117. e.click(function() {
  3118. b.html(b.initContent),
  3119. b.cmd.selection()
  3120. }),
  3121. b.beforeRemove(function() {
  3122. c.unbind(),
  3123. e.unbind()
  3124. })
  3125. }
  3126. }
  3127. }), b.clickToolbar("source",
  3128. function() {
  3129. b.edit.designMode ? (b.toolbar.disableAll(!0), b.edit.design(!1), b.toolbar.select("source")) : (b.toolbar.disableAll(!1), b.edit.design(!0), b.toolbar.unselect("source"), _GECKO ? setTimeout(function() {
  3130. b.cmd.selection()
  3131. },
  3132. 0) : b.cmd.selection()),
  3133. b.designMode = b.edit.designMode
  3134. }), b.afterCreate(function() {
  3135. b.designMode || b.toolbar.disableAll(!0).select("source")
  3136. }), b.clickToolbar("fullscreen",
  3137. function() {
  3138. b.fullscreen()
  3139. }), b.fullscreenShortcut) {
  3140. var d = !1;
  3141. b.afterCreate(function() {
  3142. if (a(b.edit.doc, b.edit.textarea).keyup(function(a) {
  3143. 27 == a.which && setTimeout(function() {
  3144. b.fullscreen()
  3145. },
  3146. 0)
  3147. }), d) {
  3148. if (_IE && !b.designMode) return;
  3149. b.focus()
  3150. }
  3151. d || (d = !0)
  3152. })
  3153. }
  3154. _each("undo,redo".split(","),
  3155. function(a, d) {
  3156. c[d] && b.afterCreate(function() {
  3157. _ctrl(this.edit.doc, c[d],
  3158. function() {
  3159. b.clickToolbar(d)
  3160. })
  3161. }),
  3162. b.clickToolbar(d,
  3163. function() {
  3164. b[d]()
  3165. })
  3166. }),
  3167. b.clickToolbar("formatblock",
  3168. function() {
  3169. var a = b.lang("formatblock.formatBlock"),
  3170. c = {
  3171. h1: 28,
  3172. h2: 24,
  3173. h3: 18,
  3174. H4: 14,
  3175. p: 12
  3176. },
  3177. d = b.cmd.val("formatblock"),
  3178. e = b.createMenu({
  3179. name: "formatblock",
  3180. width: "en" == b.langType ? 200 : 150
  3181. });
  3182. _each(a,
  3183. function(a, f) {
  3184. var g = "font-size:" + c[a] + "px;";
  3185. "h" === a.charAt(0) && (g += "font-weight:bold;"),
  3186. e.addItem({
  3187. title: '<span style="' + g + '" unselectable="on">' + f + "</span>",
  3188. height: c[a] + 12,
  3189. checked: d === a || d === f,
  3190. click: function() {
  3191. b.select().exec("formatblock", "<" + a + ">").hideMenu()
  3192. }
  3193. })
  3194. })
  3195. }),
  3196. b.clickToolbar("fontname",
  3197. function() {
  3198. var a = b.cmd.val("fontname"),
  3199. c = b.createMenu({
  3200. name: "fontname",
  3201. width: 150
  3202. });
  3203. _each(b.lang("fontname.fontName"),
  3204. function(d, e) {
  3205. c.addItem({
  3206. title: '<span style="font-family: ' + d + ';" unselectable="on">' + e + "</span>",
  3207. checked: a === d.toLowerCase() || a === e.toLowerCase(),
  3208. click: function() {
  3209. b.exec("fontname", d).hideMenu()
  3210. }
  3211. })
  3212. })
  3213. }),
  3214. b.clickToolbar("fontsize",
  3215. function() {
  3216. var a = b.cmd.val("fontsize"),
  3217. c = b.createMenu({
  3218. name: "fontsize",
  3219. width: 150
  3220. });
  3221. _each(b.fontSizeTable,
  3222. function(d, e) {
  3223. c.addItem({
  3224. title: '<span style="font-size:' + e + ';" unselectable="on">' + e + "</span>",
  3225. height: _removeUnit(e) + 12,
  3226. checked: a === e,
  3227. click: function() {
  3228. b.exec("fontsize", e).hideMenu()
  3229. }
  3230. })
  3231. })
  3232. }),
  3233. _each("forecolor,hilitecolor".split(","),
  3234. function(a, c) {
  3235. b.clickToolbar(c,
  3236. function() {
  3237. b.createMenu({
  3238. name: c,
  3239. selectedColor: b.cmd.val(c) || "default",
  3240. colors: b.colorTable,
  3241. click: function(a) {
  3242. b.exec(c, a).hideMenu()
  3243. }
  3244. })
  3245. })
  3246. }),
  3247. _each("cut,copy,paste".split(","),
  3248. function(a, c) {
  3249. b.clickToolbar(c,
  3250. function() {
  3251. b.focus();
  3252. try {
  3253. b.exec(c, null)
  3254. } catch(a) {
  3255. alert(b.lang(c + "Error"))
  3256. }
  3257. })
  3258. }),
  3259. b.clickToolbar("about",
  3260. function() {
  3261. var a = '<div style="margin:20px;"><div>KindEditor ' + _VERSION + '</div><div>Copyright &copy; <a href="http://www.kindsoft.net/" target="_blank">kindsoft.net</a> All rights reserved.</div></div>';
  3262. b.createDialog({
  3263. name: "about",
  3264. width: 350,
  3265. title: b.lang("about"),
  3266. body: a
  3267. })
  3268. }),
  3269. b.plugin.getSelectedLink = function() {
  3270. return b.cmd.commonAncestor("a")
  3271. },
  3272. b.plugin.getSelectedImage = function() {
  3273. return _getImageFromRange(b.edit.cmd.range,
  3274. function(a) {
  3275. return ! /^ke-\w+$/i.test(a[0].className)
  3276. })
  3277. },
  3278. b.plugin.getSelectedFlash = function() {
  3279. return _getImageFromRange(b.edit.cmd.range,
  3280. function(a) {
  3281. return "ke-flash" == a[0].className
  3282. })
  3283. },
  3284. b.plugin.getSelectedMedia = function() {
  3285. return _getImageFromRange(b.edit.cmd.range,
  3286. function(a) {
  3287. return "ke-media" == a[0].className || "ke-rm" == a[0].className
  3288. })
  3289. },
  3290. b.plugin.getSelectedAnchor = function() {
  3291. return _getImageFromRange(b.edit.cmd.range,
  3292. function(a) {
  3293. return "ke-anchor" == a[0].className
  3294. })
  3295. },
  3296. _each("link,image,flash,media,anchor".split(","),
  3297. function(a, c) {
  3298. var d = c.charAt(0).toUpperCase() + c.substr(1);
  3299. _each("edit,delete".split(","),
  3300. function(a, e) {
  3301. b.addContextmenu({
  3302. title: b.lang(e + d),
  3303. click: function() {
  3304. b.loadPlugin(c,
  3305. function() {
  3306. b.plugin[c][e](),
  3307. b.hideMenu()
  3308. })
  3309. },
  3310. cond: b.plugin["getSelected" + d],
  3311. width: 150,
  3312. iconClass: "edit" == e ? "ke-icon-" + c: undefined
  3313. })
  3314. }),
  3315. b.addContextmenu({
  3316. title: "-"
  3317. })
  3318. }),
  3319. b.plugin.getSelectedTable = function() {
  3320. return b.cmd.commonAncestor("table")
  3321. },
  3322. b.plugin.getSelectedRow = function() {
  3323. return b.cmd.commonAncestor("tr")
  3324. },
  3325. b.plugin.getSelectedCell = function() {
  3326. return b.cmd.commonAncestor("td")
  3327. },
  3328. _each("prop,cellprop,colinsertleft,colinsertright,rowinsertabove,rowinsertbelow,rowmerge,colmerge,rowsplit,colsplit,coldelete,rowdelete,insert,delete".split(","),
  3329. function(a, c) {
  3330. var d = _inArray(c, ["prop", "delete"]) < 0 ? b.plugin.getSelectedCell: b.plugin.getSelectedTable;
  3331. b.addContextmenu({
  3332. title: b.lang("table" + c),
  3333. click: function() {
  3334. b.loadPlugin("table",
  3335. function() {
  3336. b.plugin.table[c](),
  3337. b.hideMenu()
  3338. })
  3339. },
  3340. cond: d,
  3341. width: 170,
  3342. iconClass: "ke-icon-table" + c
  3343. })
  3344. }),
  3345. b.addContextmenu({
  3346. title: "-"
  3347. }),
  3348. _each("selectall,justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,indent,outdent,subscript,superscript,hr,print,bold,italic,underline,strikethrough,removeformat,unlink".split(","),
  3349. function(a, d) {
  3350. c[d] && b.afterCreate(function() {
  3351. _ctrl(this.edit.doc, c[d],
  3352. function() {
  3353. b.cmd.selection(),
  3354. b.clickToolbar(d)
  3355. })
  3356. }),
  3357. b.clickToolbar(d,
  3358. function() {
  3359. b.focus().exec(d, null)
  3360. })
  3361. }),
  3362. b.afterCreate(function() {
  3363. function c() {
  3364. d.range.moveToBookmark(e),
  3365. d.select(),
  3366. _WEBKIT && (a("div." + h, f).each(function() {
  3367. a(this).after("<br />").remove(!0)
  3368. }), a("span.Apple-style-span", f).remove(!0), a("span.Apple-tab-span", f).remove(!0), a("span[style]", f).each(function() {
  3369. "nowrap" == a(this).css("white-space") && a(this).remove(!0)
  3370. }), a("meta", f).remove());
  3371. var c = f[0].innerHTML;
  3372. f.remove(),
  3373. "" !== c && (_WEBKIT && (c = c.replace(/(<br>)\1/gi, "$1")), 2 === b.pasteType && (c = c.replace(/(<(?:p|p\s[^>]*)>) *(<\/p>)/gi, ""), /schemas-microsoft-com|worddocument|mso-\w+/i.test(c) ? c = _clearMsWord(c, b.filterMode ? b.htmlTags: a.options.htmlTags) : (c = _formatHtml(c, b.filterMode ? b.htmlTags: null), c = b.beforeSetHtml(c))), 1 === b.pasteType && (c = c.replace(/&nbsp;/gi, " "), c = c.replace(/\n\s*\n/g, "\n"), c = c.replace(/<br[^>]*>/gi, "\n"), c = c.replace(/<\/p><p[^>]*>/gi, "\n"), c = c.replace(/<[^>]+>/g, ""), c = c.replace(/ {2}/g, " &nbsp;"), "p" == b.newlineTag ? /\n/.test(c) && (c = c.replace(/^/, "<p>").replace(/$/, "<br /></p>").replace(/\n/g, "<br /></p><p>")) : c = c.replace(/\n/g, "<br />$&")), b.insertHtml(c, !0))
  3374. }
  3375. var d, e, f, g = b.edit.doc,
  3376. h = "__kindeditor_paste__",
  3377. i = !1;
  3378. a(g.body).bind("paste",
  3379. function(j) {
  3380. if (0 === b.pasteType) return void j.stop();
  3381. if (!i) {
  3382. if (i = !0, a("div." + h, g).remove(), d = b.cmd.selection(), e = d.range.createBookmark(), f = a('<div class="' + h + '"></div>', g).css({
  3383. position: "absolute",
  3384. width: "1px",
  3385. height: "1px",
  3386. overflow: "hidden",
  3387. left: "-1981px",
  3388. top: a(e.start).pos().y + "px",
  3389. "white-space": "nowrap"
  3390. }), a(g.body).append(f), _IE) {
  3391. var k = d.range.get(!0);
  3392. k.moveToElementText(f[0]),
  3393. k.select(),
  3394. k.execCommand("paste"),
  3395. j.preventDefault()
  3396. } else d.range.selectNodeContents(f[0]),
  3397. d.select(),
  3398. f[0].tabIndex = -1,
  3399. f[0].focus();
  3400. setTimeout(function() {
  3401. c(),
  3402. i = !1
  3403. },
  3404. 0)
  3405. }
  3406. })
  3407. }),
  3408. b.beforeGetHtml(function(a) {
  3409. return _IE && 8 >= _V && (a = a.replace(/<div\s+[^>]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/gi,
  3410. function(a, b) {
  3411. return unescape(b)
  3412. }), a = a.replace(/(<input)((?:\s+[^>]*)?>)/gi,
  3413. function(a, b, c) {
  3414. return /\s+type="[^"]+"/i.test(a) ? a: b + ' type="text"' + c
  3415. })),
  3416. a.replace(/(<(?:noscript|noscript\s[^>]*)>)([\s\S]*?)(<\/noscript>)/gi,
  3417. function(a, b, c, d) {
  3418. return b + _unescape(c).replace(/\s+/g, " ") + d
  3419. }).replace(/<img[^>]*class="?ke-(flash|rm|media)"?[^>]*>/gi,
  3420. function(a) {
  3421. var b = _getAttrList(a),
  3422. c = _getCssList(b.style || ""),
  3423. d = _mediaAttrs(b["data-ke-tag"]),
  3424. e = _undef(c.width, ""),
  3425. f = _undef(c.height, "");
  3426. return /px/i.test(e) && (e = _removeUnit(e)),
  3427. /px/i.test(f) && (f = _removeUnit(f)),
  3428. d.width = _undef(b.width, e),
  3429. d.height = _undef(b.height, f),
  3430. _mediaEmbed(d)
  3431. }).replace(/<img[^>]*class="?ke-anchor"?[^>]*>/gi,
  3432. function(a) {
  3433. var b = _getAttrList(a);
  3434. return '<a name="' + unescape(b["data-ke-name"]) + '"></a>'
  3435. }).replace(/<div\s+[^>]*data-ke-script-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/gi,
  3436. function(a, b, c) {
  3437. return "<script" + unescape(b) + ">" + unescape(c) + "</script>"
  3438. }).replace(/<div\s+[^>]*data-ke-noscript-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/gi,
  3439. function(a, b, c) {
  3440. return "<noscript" + unescape(b) + ">" + unescape(c) + "</noscript>"
  3441. }).replace(/(<[^>]*)data-ke-src="([^"]*)"([^>]*>)/gi,
  3442. function(a, b, c) {
  3443. return a = a.replace(/(\s+(?:href|src)=")[^"]*(")/i,
  3444. function(a, b, d) {
  3445. return b + _unescape(c) + d
  3446. }),
  3447. a = a.replace(/\s+data-ke-src="[^"]*"/i, "")
  3448. }).replace(/(<[^>]+\s)data-ke-(on\w+="[^"]*"[^>]*>)/gi,
  3449. function(a, b, c) {
  3450. return b + c
  3451. })
  3452. }),
  3453. b.beforeSetHtml(function(a) {
  3454. return _IE && 8 >= _V && (a = a.replace(/<input[^>]*>|<(select|button)[^>]*>[\s\S]*?<\/\1>/gi,
  3455. function(a) {
  3456. var b = _getAttrList(a),
  3457. c = _getCssList(b.style || "");
  3458. return "none" == c.display ? '<div class="ke-display-none" data-ke-input-tag="' + escape(a) + '"></div>': a
  3459. })),
  3460. a.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/gi,
  3461. function(a) {
  3462. var c = _getAttrList(a);
  3463. return c.src = _undef(c.src, ""),
  3464. c.width = _undef(c.width, 0),
  3465. c.height = _undef(c.height, 0),
  3466. _mediaImg(b.themesPath + "common/blank.gif", c)
  3467. }).replace(/<a[^>]*name="([^"]+)"[^>]*>(?:<\/a>)?/gi,
  3468. function(a) {
  3469. var c = _getAttrList(a);
  3470. return c.href !== undefined ? a: '<img class="ke-anchor" src="' + b.themesPath + 'common/anchor.gif" data-ke-name="' + escape(c.name) + '" />'
  3471. }).replace(/<script([^>]*)>([\s\S]*?)<\/script>/gi,
  3472. function(a, b, c) {
  3473. return '<div class="ke-script" data-ke-script-attr="' + escape(b) + '">' + escape(c) + "</div>"
  3474. }).replace(/<noscript([^>]*)>([\s\S]*?)<\/noscript>/gi,
  3475. function(a, b, c) {
  3476. return '<div class="ke-noscript" data-ke-noscript-attr="' + escape(b) + '">' + escape(c) + "</div>"
  3477. }).replace(/(<[^>]*)(href|src)="([^"]*)"([^>]*>)/gi,
  3478. function(a, b, c, d, e) {
  3479. return a.match(/\sdata-ke-src="[^"]*"/i) ? a: a = b + c + '="' + d + '" data-ke-src="' + _escape(d) + '"' + e
  3480. }).replace(/(<[^>]+\s)(on\w+="[^"]*"[^>]*>)/gi,
  3481. function(a, b, c) {
  3482. return b + "data-ke-" + c
  3483. }).replace(/<table[^>]*\s+border="0"[^>]*>/gi,
  3484. function(a) {
  3485. return a.indexOf("ke-zeroborder") >= 0 ? a: _addClassToTag(a, "ke-zeroborder")
  3486. })
  3487. })
  3488. })
  3489. }
  3490. } (window),
  3491. KindEditor.lang({
  3492. source: "HTML代码",
  3493. preview: "预览",
  3494. undo: "后退(Ctrl+Z)",
  3495. redo: "前进(Ctrl+Y)",
  3496. cut: "剪切(Ctrl+X)",
  3497. copy: "复制(Ctrl+C)",
  3498. paste: "粘贴(Ctrl+V)",
  3499. plainpaste: "粘贴为无格式文本",
  3500. wordpaste: "从Word粘贴",
  3501. selectall: "全选(Ctrl+A)",
  3502. justifyleft: "左对齐",
  3503. justifycenter: "居中",
  3504. justifyright: "右对齐",
  3505. justifyfull: "两端对齐",
  3506. insertorderedlist: "编号",
  3507. insertunorderedlist: "项目符号",
  3508. indent: "增加缩进",
  3509. outdent: "减少缩进",
  3510. subscript: "下标",
  3511. superscript: "上标",
  3512. formatblock: "段落",
  3513. fontname: "字体",
  3514. fontsize: "文字大小",
  3515. forecolor: "文字颜色",
  3516. hilitecolor: "文字背景",
  3517. bold: "粗体(Ctrl+B)",
  3518. italic: "斜体(Ctrl+I)",
  3519. underline: "下划线(Ctrl+U)",
  3520. strikethrough: "删除线",
  3521. removeformat: "删除格式",
  3522. image: "图片",
  3523. multiimage: "批量图片上传",
  3524. flash: "Flash",
  3525. media: "视音频",
  3526. table: "表格",
  3527. tablecell: "单元格",
  3528. hr: "插入横线",
  3529. emoticons: "插入表情",
  3530. link: "超级链接",
  3531. unlink: "取消超级链接",
  3532. fullscreen: "全屏显示",
  3533. about: "关于",
  3534. print: "打印(Ctrl+P)",
  3535. filemanager: "文件空间",
  3536. code: "插入程序代码",
  3537. map: "Google地图",
  3538. baidumap: "百度地图",
  3539. lineheight: "行距",
  3540. clearhtml: "清理HTML代码",
  3541. pagebreak: "插入分页符",
  3542. quickformat: "一键排版",
  3543. insertfile: "插入文件",
  3544. template: "插入模板",
  3545. anchor: "锚点",
  3546. yes: "确定",
  3547. no: "取消",
  3548. close: "关闭",
  3549. editImage: "图片属性",
  3550. deleteImage: "删除图片",
  3551. editFlash: "Flash属性",
  3552. deleteFlash: "删除Flash",
  3553. editMedia: "视音频属性",
  3554. deleteMedia: "删除视音频",
  3555. editLink: "超级链接属性",
  3556. deleteLink: "取消超级链接",
  3557. editAnchor: "锚点属性",
  3558. deleteAnchor: "删除锚点",
  3559. tableprop: "表格属性",
  3560. tablecellprop: "单元格属性",
  3561. tableinsert: "插入表格",
  3562. tabledelete: "删除表格",
  3563. tablecolinsertleft: "左侧插入列",
  3564. tablecolinsertright: "右侧插入列",
  3565. tablerowinsertabove: "上方插入行",
  3566. tablerowinsertbelow: "下方插入行",
  3567. tablerowmerge: "向下合并单元格",
  3568. tablecolmerge: "向右合并单元格",
  3569. tablerowsplit: "拆分行",
  3570. tablecolsplit: "拆分列",
  3571. tablecoldelete: "删除列",
  3572. tablerowdelete: "删除行",
  3573. noColor: "无颜色",
  3574. pleaseSelectFile: "请选择文件。",
  3575. invalidImg: "请输入有效的URL地址。\n只允许jpg,gif,bmp,png格式。",
  3576. invalidMedia: "请输入有效的URL地址。\n只允许swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
  3577. invalidWidth: "宽度必须为数字。",
  3578. invalidHeight: "高度必须为数字。",
  3579. invalidBorder: "边框必须为数字。",
  3580. invalidUrl: "请输入有效的URL地址。",
  3581. invalidRows: "行数为必选项,只允许输入大于0的数字。",
  3582. invalidCols: "列数为必选项,只允许输入大于0的数字。",
  3583. invalidPadding: "边距必须为数字。",
  3584. invalidSpacing: "间距必须为数字。",
  3585. invalidJson: "服务器发生故障。",
  3586. uploadSuccess: "上传成功。",
  3587. cutError: "您的浏览器安全设置不允许使用剪切操作,请使用快捷键(Ctrl+X)来完成。",
  3588. copyError: "您的浏览器安全设置不允许使用复制操作,请使用快捷键(Ctrl+C)来完成。",
  3589. pasteError: "您的浏览器安全设置不允许使用粘贴操作,请使用快捷键(Ctrl+V)来完成。",
  3590. ajaxLoading: "加载中,请稍候 ...",
  3591. uploadLoading: "上传中,请稍候 ...",
  3592. uploadError: "上传错误",
  3593. "plainpaste.comment": "请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。",
  3594. "wordpaste.comment": "请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。",
  3595. "code.pleaseInput": "请输入程序代码。",
  3596. "link.url": "URL",
  3597. "link.linkType": "打开类型",
  3598. "link.newWindow": "新窗口",
  3599. "link.selfWindow": "当前窗口",
  3600. "flash.url": "URL",
  3601. "flash.width": "宽度",
  3602. "flash.height": "高度",
  3603. "flash.upload": "上传",
  3604. "flash.viewServer": "文件空间",
  3605. "media.url": "URL",
  3606. "media.width": "宽度",
  3607. "media.height": "高度",
  3608. "media.autostart": "自动播放",
  3609. "media.upload": "上传",
  3610. "media.viewServer": "文件空间",
  3611. "image.remoteImage": "图片属性",
  3612. "image.localImage": "本地上传",
  3613. "image.remoteUrl": "图片地址",
  3614. "image.localUrl": "上传文件",
  3615. "image.size": "图片大小",
  3616. "image.width": "宽",
  3617. "image.height": "高",
  3618. "image.resetSize": "重置大小",
  3619. "image.align": "对齐方式",
  3620. "image.defaultAlign": "默认方式",
  3621. "image.leftAlign": "左对齐",
  3622. "image.rightAlign": "右对齐",
  3623. "image.imgTitle": "图片说明",
  3624. "image.upload": "浏览...",
  3625. "image.viewServer": "图片空间",
  3626. "multiimage.uploadDesc": "允许用户同时上传<%=uploadLimit%>张图片,单张图片容量不超过<%=sizeLimit%>",
  3627. "multiimage.startUpload": "开始上传",
  3628. "multiimage.clearAll": "全部清空",
  3629. "multiimage.insertAll": "全部插入",
  3630. "multiimage.queueLimitExceeded": "文件数量超过限制。",
  3631. "multiimage.fileExceedsSizeLimit": "文件大小超过限制。",
  3632. "multiimage.zeroByteFile": "无法上传空文件。",
  3633. "multiimage.invalidFiletype": "文件类型不正确。",
  3634. "multiimage.unknownError": "发生异常,无法上传。",
  3635. "multiimage.pending": "等待上传",
  3636. "multiimage.uploadError": "上传失败",
  3637. "filemanager.emptyFolder": "空文件夹",
  3638. "filemanager.moveup": "移到上一级文件夹",
  3639. "filemanager.viewType": "显示方式:",
  3640. "filemanager.viewImage": "缩略图",
  3641. "filemanager.listImage": "详细信息",
  3642. "filemanager.orderType": "排序方式:",
  3643. "filemanager.fileName": "名称",
  3644. "filemanager.fileSize": "大小",
  3645. "filemanager.fileType": "类型",
  3646. "insertfile.url": "URL",
  3647. "insertfile.title": "文件说明",
  3648. "insertfile.upload": "上传",
  3649. "insertfile.viewServer": "文件空间",
  3650. "table.cells": "单元格数",
  3651. "table.rows": "行数",
  3652. "table.cols": "列数",
  3653. "table.size": "大小",
  3654. "table.width": "宽度",
  3655. "table.height": "高度",
  3656. "table.percent": "%",
  3657. "table.px": "px",
  3658. "table.space": "边距间距",
  3659. "table.padding": "边距",
  3660. "table.spacing": "间距",
  3661. "table.align": "对齐方式",
  3662. "table.textAlign": "水平对齐",
  3663. "table.verticalAlign": "垂直对齐",
  3664. "table.alignDefault": "默认",
  3665. "table.alignLeft": "左对齐",
  3666. "table.alignCenter": "居中",
  3667. "table.alignRight": "右对齐",
  3668. "table.alignTop": "顶部",
  3669. "table.alignMiddle": "中部",
  3670. "table.alignBottom": "底部",
  3671. "table.alignBaseline": "基线",
  3672. "table.border": "边框",
  3673. "table.borderWidth": "边框",
  3674. "table.borderColor": "颜色",
  3675. "table.backgroundColor": "背景颜色",
  3676. "map.address": "地址: ",
  3677. "map.search": "搜索",
  3678. "baidumap.address": "地址: ",
  3679. "baidumap.search": "搜索",
  3680. "baidumap.insertDynamicMap": "插入动态地图",
  3681. "anchor.name": "锚点名称",
  3682. "formatblock.formatBlock": {
  3683. h1: "标题 1",
  3684. h2: "标题 2",
  3685. h3: "标题 3",
  3686. h4: "标题 4",
  3687. p: "正 文"
  3688. },
  3689. "fontname.fontName": {
  3690. SimSun: "宋体",
  3691. NSimSun: "新宋体",
  3692. FangSong_GB2312: "仿宋_GB2312",
  3693. KaiTi_GB2312: "楷体_GB2312",
  3694. SimHei: "黑体",
  3695. "Microsoft YaHei": "微软雅黑",
  3696. Arial: "Arial",
  3697. "Arial Black": "Arial Black",
  3698. "Times New Roman": "Times New Roman",
  3699. "Courier New": "Courier New",
  3700. Tahoma: "Tahoma",
  3701. Verdana: "Verdana"
  3702. },
  3703. "lineheight.lineHeight": [{
  3704. 1 : "单倍行距"
  3705. },
  3706. {
  3707. 1.5 : "1.5倍行距"
  3708. },
  3709. {
  3710. 2 : "2倍行距"
  3711. },
  3712. {
  3713. 2.5 : "2.5倍行距"
  3714. },
  3715. {
  3716. 3 : "3倍行距"
  3717. }],
  3718. "template.selectTemplate": "可选模板",
  3719. "template.replaceContent": "替换当前内容",
  3720. "template.fileList": {
  3721. "1.html": "图片和文字",
  3722. "2.html": "表格",
  3723. "3.html": "项目编号"
  3724. }
  3725. },
  3726. "zh-CN"),
  3727. KindEditor.options.langType = "zh-CN",
  3728. KindEditor.plugin("anchor",
  3729. function(a) {
  3730. var b = this,
  3731. c = "anchor",
  3732. d = b.lang(c + ".");
  3733. b.plugin.anchor = {
  3734. edit: function() {
  3735. var e = ['<div style="padding:20px;">', '<div class="ke-dialog-row">', '<label for="keName">' + d.name + "</label>", '<input class="ke-input-text" type="text" id="keName" name="name" value="" style="width:100px;" />', "</div>", "</div>"].join(""),
  3736. f = b.createDialog({
  3737. name: c,
  3738. width: 300,
  3739. title: b.lang(c),
  3740. body: e,
  3741. yesBtn: {
  3742. name: b.lang("yes"),
  3743. click: function() {
  3744. b.insertHtml('<a name="' + h.val() + '">').hideDialog().focus()
  3745. }
  3746. }
  3747. }),
  3748. g = f.div,
  3749. h = a('input[name="name"]', g),
  3750. i = b.plugin.getSelectedAnchor();
  3751. i && h.val(unescape(i.attr("data-ke-name"))),
  3752. h[0].focus(),
  3753. h[0].select()
  3754. },
  3755. "delete": function() {
  3756. b.plugin.getSelectedAnchor().remove()
  3757. }
  3758. },
  3759. b.clickToolbar(c, b.plugin.anchor.edit)
  3760. }),
  3761. KindEditor.plugin("autoheight",
  3762. function(a) {
  3763. function b() {
  3764. var a = e.edit,
  3765. b = a.doc.body;
  3766. a.iframe[0].scroll = "no",
  3767. b.style.overflowY = "hidden"
  3768. }
  3769. function c() {
  3770. var b = e.edit,
  3771. c = b.doc.body;
  3772. b.iframe.height(f),
  3773. e.resize(null, Math.max((a.IE ? c.scrollHeight: c.offsetHeight) + 76, f))
  3774. }
  3775. function d() {
  3776. f = a.removeUnit(e.height),
  3777. e.edit.afterChange(c),
  3778. b(),
  3779. c()
  3780. }
  3781. var e = this;
  3782. if (e.autoHeightMode) {
  3783. var f;
  3784. e.isCreated ? d() : e.afterCreate(d)
  3785. }
  3786. }),
  3787. KindEditor.plugin("baidumap",
  3788. function(a) {
  3789. var b = this,
  3790. c = "baidumap",
  3791. d = b.lang(c + "."),
  3792. e = a.undef(b.mapWidth, 558),
  3793. f = a.undef(b.mapHeight, 360);
  3794. b.clickToolbar(c,
  3795. function() {
  3796. function g() {
  3797. h = p[0].contentWindow,
  3798. i = a.iframeDoc(p)
  3799. }
  3800. var h, i, j = ['<div style="padding:10px 20px;">', '<div class="ke-header">', '<div class="ke-left">', d.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ', '<span class="ke-button-common ke-button-outer">', '<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + d.search + '" />', "</span>", "</div>", '<div class="ke-right">', '<input type="checkbox" id="keInsertDynamicMap" name="insertDynamicMap" value="1" /> <label for="keInsertDynamicMap">' + d.insertDynamicMap + "</label>", "</div>", '<div class="ke-clearfix"></div>', "</div>", '<div class="ke-map" style="width:' + e + "px;height:" + f + 'px;"></div>', "</div>"].join(""),
  3801. k = b.createDialog({
  3802. name: c,
  3803. width: e + 42,
  3804. title: b.lang(c),
  3805. body: j,
  3806. yesBtn: {
  3807. name: b.lang("yes"),
  3808. click: function() {
  3809. var a = h.map,
  3810. c = a.getCenter(),
  3811. d = c.lng + "," + c.lat,
  3812. g = a.getZoom(),
  3813. i = [o[0].checked ? b.pluginsPath + "baidumap/index.html": "http://api.map.baidu.com/staticimage", "?center=" + encodeURIComponent(d), "&zoom=" + encodeURIComponent(g), "&width=" + e, "&height=" + f, "&markers=" + encodeURIComponent(d), "&markerStyles=" + encodeURIComponent("l,A")].join("");
  3814. o[0].checked ? b.insertHtml('<iframe src="' + i + '" frameborder="0" style="width:' + (e + 2) + "px;height:" + (f + 2) + 'px;"></iframe>') : b.exec("insertimage", i),
  3815. b.hideDialog().focus()
  3816. }
  3817. },
  3818. beforeRemove: function() {
  3819. n.remove(),
  3820. i && i.write(""),
  3821. p.remove()
  3822. }
  3823. }),
  3824. l = k.div,
  3825. m = a('[name="address"]', l),
  3826. n = a('[name="searchBtn"]', l),
  3827. o = a('[name="insertDynamicMap"]', k.div),
  3828. p = a('<iframe class="ke-textarea" frameborder="0" src="' + b.pluginsPath + 'baidumap/map.html" style="width:' + e + "px;height:" + f + 'px;"></iframe>');
  3829. p.bind("load",
  3830. function() {
  3831. p.unbind("load"),
  3832. a.IE ? g() : setTimeout(g, 0)
  3833. }),
  3834. a(".ke-map", l).replaceWith(p),
  3835. n.click(function() {
  3836. h.search(m.val())
  3837. })
  3838. })
  3839. }),
  3840. KindEditor.plugin("map",
  3841. function(a) {
  3842. var b = this,
  3843. c = "map",
  3844. d = b.lang(c + ".");
  3845. b.clickToolbar(c,
  3846. function() {
  3847. function e() {
  3848. f = m[0].contentWindow,
  3849. g = a.iframeDoc(m)
  3850. }
  3851. var f, g, h = ['<div style="padding:10px 20px;">', '<div class="ke-dialog-row">', d.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ', '<span class="ke-button-common ke-button-outer">', '<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + d.search + '" />', "</span>", "</div>", '<div class="ke-map" style="width:558px;height:360px;"></div>', "</div>"].join(""),
  3852. i = b.createDialog({
  3853. name: c,
  3854. width: 600,
  3855. title: b.lang(c),
  3856. body: h,
  3857. yesBtn: {
  3858. name: b.lang("yes"),
  3859. click: function() {
  3860. var a = (f.geocoder, f.map),
  3861. c = a.getCenter().lat() + "," + a.getCenter().lng(),
  3862. d = a.getZoom(),
  3863. e = a.getMapTypeId(),
  3864. g = "http://maps.googleapis.com/maps/api/staticmap";
  3865. g += "?center=" + encodeURIComponent(c),
  3866. g += "&zoom=" + encodeURIComponent(d),
  3867. g += "&size=558x360",
  3868. g += "&maptype=" + encodeURIComponent(e),
  3869. g += "&markers=" + encodeURIComponent(c),
  3870. g += "&language=" + b.langType,
  3871. g += "&sensor=false",
  3872. b.exec("insertimage", g).hideDialog().focus()
  3873. }
  3874. },
  3875. beforeRemove: function() {
  3876. l.remove(),
  3877. g && g.write(""),
  3878. m.remove()
  3879. }
  3880. }),
  3881. j = i.div,
  3882. k = a('[name="address"]', j),
  3883. l = a('[name="searchBtn"]', j),
  3884. m = (["<!doctype html><html><head>", '<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />', "<style>", " html { height: 100% }", " body { height: 100%; margin: 0; padding: 0; background-color: #FFF }", " #map_canvas { height: 100% }", "</style>", '<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=' + b.langType + '"></script>', "<script>", "var map, geocoder;", "function initialize() {", " var latlng = new google.maps.LatLng(31.230393, 121.473704);", " var options = {", " zoom: 11,", " center: latlng,", " disableDefaultUI: true,", " panControl: true,", " zoomControl: true,", " mapTypeControl: true,", " scaleControl: true,", " streetViewControl: false,", " overviewMapControl: true,", " mapTypeId: google.maps.MapTypeId.ROADMAP", " };", ' map = new google.maps.Map(document.getElementById("map_canvas"), options);', " geocoder = new google.maps.Geocoder();", " geocoder.geocode({latLng: latlng}, function(results, status) {", " if (status == google.maps.GeocoderStatus.OK) {", " if (results[3]) {", ' parent.document.getElementById("kindeditor_plugin_map_address").value = results[3].formatted_address;', " }", " }", " });", "}", "function search(address) {", " if (!map) return;", " geocoder.geocode({address : address}, function(results, status) {", " if (status == google.maps.GeocoderStatus.OK) {", " map.setZoom(11);", " map.setCenter(results[0].geometry.location);", " var marker = new google.maps.Marker({", " map: map,", " position: results[0].geometry.location", " });", " } else {", ' alert("Invalid address: " + address);', " }", " });", "}", "</script>", "</head>", '<body onload="initialize();">', '<div id="map_canvas" style="width:100%; height:100%"></div>', "</body></html>"].join("\n"), a('<iframe class="ke-textarea" frameborder="0" src="' + b.pluginsPath + 'map/map.html" style="width:558px;height:360px;"></iframe>'));
  3885. m.bind("load",
  3886. function() {
  3887. m.unbind("load"),
  3888. a.IE ? e() : setTimeout(e, 0)
  3889. }),
  3890. a(".ke-map", j).replaceWith(m),
  3891. l.click(function() {
  3892. f.search(k.val())
  3893. })
  3894. })
  3895. }),
  3896. KindEditor.plugin("clearhtml",
  3897. function(a) {
  3898. var b = this,
  3899. c = "clearhtml";
  3900. b.clickToolbar(c,
  3901. function() {
  3902. b.focus();
  3903. var c = b.html();
  3904. c = c.replace(/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi, ""),
  3905. c = c.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/gi, ""),
  3906. c = a.formatHtml(c, {
  3907. a: ["href", "target"],
  3908. embed: ["src", "width", "height", "type", "loop", "autostart", "quality", ".width", ".height", "align", "allowscriptaccess"],
  3909. img: ["src", "width", "height", "border", "alt", "title", ".width", ".height"],
  3910. table: ["border"],
  3911. "td,th": ["rowspan", "colspan"],
  3912. "div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6": []
  3913. }),
  3914. b.html(c),
  3915. b.cmd.selection(!0),
  3916. b.addBookmark()
  3917. })
  3918. }),
  3919. KindEditor.plugin("code",
  3920. function(a) {
  3921. var b = this,
  3922. c = "code";
  3923. b.clickToolbar(c,
  3924. function() {
  3925. var d = b.lang(c + "."),
  3926. e = ['<div style="padding:10px 20px;">', '<div class="ke-dialog-row">', '<select class="ke-code-type">', '<option value="js">JavaScript</option>', '<option value="html">HTML</option>', '<option value="css">CSS</option>', '<option value="php">PHP</option>', '<option value="pl">Perl</option>', '<option value="py">Python</option>', '<option value="rb">Ruby</option>', '<option value="java">Java</option>', '<option value="vb">ASP/VB</option>', '<option value="cpp">C/C++</option>', '<option value="cs">C#</option>', '<option value="xml">XML</option>', '<option value="bsh">Shell</option>', '<option value="">Other</option>', "</select>", "</div>", '<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>', "</div>"].join(""),
  3927. f = b.createDialog({
  3928. name: c,
  3929. width: 450,
  3930. title: b.lang(c),
  3931. body: e,
  3932. yesBtn: {
  3933. name: b.lang("yes"),
  3934. click: function() {
  3935. var c = a(".ke-code-type", f.div).val(),
  3936. e = g.val(),
  3937. h = "" === c ? "": " lang-" + c,
  3938. i = '<pre class="prettyprint' + h + '">\n' + a.escape(e) + "</pre> ";
  3939. return "" === a.trim(e) ? (alert(d.pleaseInput), void g[0].focus()) : void b.insertHtml(i).hideDialog().focus()
  3940. }
  3941. }
  3942. }),
  3943. g = a("textarea", f.div);
  3944. g[0].focus()
  3945. })
  3946. }),
  3947. KindEditor.plugin("emoticons",
  3948. function(a) {
  3949. var b = this,
  3950. c = "emoticons",
  3951. d = b.emoticonsPath || b.pluginsPath + "emoticons/images/",
  3952. e = void 0 === b.allowPreviewEmoticons ? !0 : b.allowPreviewEmoticons,
  3953. f = 1;
  3954. b.clickToolbar(c,
  3955. function() {
  3956. function g(c, e, f) {
  3957. c.mouseover(v ?
  3958. function() {
  3959. e > r ? (v.css("left", 0), v.css("right", "")) : (v.css("left", ""), v.css("right", 0)),
  3960. w.attr("src", d + f + ".gif"),
  3961. a(this).addClass("ke-on")
  3962. }: function() {
  3963. a(this).addClass("ke-on")
  3964. }),
  3965. c.mouseout(function() {
  3966. a(this).removeClass("ke-on")
  3967. }),
  3968. c.click(function(a) {
  3969. b.insertHtml('<img src="' + d + f + '.gif" border="0" alt="" />').hideMenu().focus(),
  3970. a.stop()
  3971. })
  3972. }
  3973. function h(b, c) {
  3974. var e = document.createElement("table");
  3975. c.append(e),
  3976. v && (a(e).mouseover(function() {
  3977. v.show("block")
  3978. }), a(e).mouseout(function() {
  3979. v.hide()
  3980. }), t.push(a(e))),
  3981. e.className = "ke-table",
  3982. e.cellPadding = 0,
  3983. e.cellSpacing = 0,
  3984. e.border = 0;
  3985. for (var f = (b - 1) * p + o, h = 0; l > h; h++) for (var i = e.insertRow(h), j = 0; m > j; j++) {
  3986. var k = a(i.insertCell(j));
  3987. k.addClass("ke-cell"),
  3988. g(k, j, f);
  3989. var n = a('<span class="ke-img"></span>').css("background-position", "-" + 24 * f + "px 0px").css("background-image", "url(" + d + "static.gif)");
  3990. k.append(n),
  3991. t.push(k),
  3992. f++
  3993. }
  3994. return e
  3995. }
  3996. function i() {
  3997. a.each(t,
  3998. function() {
  3999. this.unbind()
  4000. })
  4001. }
  4002. function j(a, b) {
  4003. a.click(function(a) {
  4004. i(),
  4005. y.parentNode.removeChild(y),
  4006. x.remove(),
  4007. y = h(b, s),
  4008. k(b),
  4009. f = b,
  4010. a.stop()
  4011. })
  4012. }
  4013. function k(b) {
  4014. x = a('<div class="ke-page"></div>'),
  4015. s.append(x);
  4016. for (var c = 1; q >= c; c++) {
  4017. if (b !== c) {
  4018. var d = a('<a href="javascript:;">[' + c + "]</a>");
  4019. j(d, c),
  4020. x.append(d),
  4021. t.push(d)
  4022. } else x.append(a("@[" + c + "]"));
  4023. x.append(a("@&nbsp;"))
  4024. }
  4025. }
  4026. var l = 5,
  4027. m = 9,
  4028. n = 135,
  4029. o = 0,
  4030. p = l * m,
  4031. q = Math.ceil(n / p),
  4032. r = Math.floor(m / 2),
  4033. s = a('<div class="ke-plugin-emoticons"></div>'),
  4034. t = [],
  4035. u = b.createMenu({
  4036. name: c,
  4037. beforeRemove: function() {
  4038. i()
  4039. }
  4040. });
  4041. u.div.append(s);
  4042. var v, w;
  4043. e && (v = a('<div class="ke-preview"></div>').css("right", 0), w = a('<img class="ke-preview-img" src="' + d + o + '.gif" />'), s.append(v), v.append(w));
  4044. var x, y = h(f, s);
  4045. k(f)
  4046. })
  4047. }),
  4048. KindEditor.plugin("filemanager",
  4049. function(a) {
  4050. function b(a, b, c) {
  4051. return a + " (" + Math.ceil(b / 1024) + "KB, " + c + ")"
  4052. }
  4053. function c(a, c) {
  4054. c.is_dir ? a.attr("title", c.filename) : a.attr("title", b(c.filename, c.filesize, c.datetime))
  4055. }
  4056. var d = this,
  4057. e = "filemanager",
  4058. f = a.undef(d.fileManagerJson, d.basePath + "php/file_manager_json.php"),
  4059. g = d.pluginsPath + e + "/images/",
  4060. h = d.lang(e + ".");
  4061. d.plugin.filemanagerDialog = function(b) {
  4062. function i(b, c, e) {
  4063. var g = "path=" + b + "&order=" + c + "&dir=" + p;
  4064. t.showLoading(d.lang("ajaxLoading")),
  4065. a.ajax(a.addParam(f, g + "&" + (new Date).getTime()),
  4066. function(a) {
  4067. t.hideLoading(),
  4068. e(a)
  4069. })
  4070. }
  4071. function j(b, c, d, e) {
  4072. var f = a.formatUrl(c.current_url + d.filename, "absolute"),
  4073. g = encodeURIComponent(c.current_dir_path + d.filename + "/");
  4074. b.click(d.is_dir ?
  4075. function() {
  4076. i(g, y.val(), e)
  4077. }: d.is_photo ?
  4078. function() {
  4079. r.call(this, f, d.filename)
  4080. }: function() {
  4081. r.call(this, f, d.filename)
  4082. }),
  4083. z.push(b)
  4084. }
  4085. function k(b, c) {
  4086. function d() {
  4087. "VIEW" == x.val() ? i(b.current_dir_path, y.val(), m) : i(b.current_dir_path, y.val(), l)
  4088. }
  4089. a.each(z,
  4090. function() {
  4091. this.unbind()
  4092. }),
  4093. w.unbind(),
  4094. x.unbind(),
  4095. y.unbind(),
  4096. b.current_dir_path && w.click(function() {
  4097. i(b.moveup_dir_path, y.val(), c)
  4098. }),
  4099. x.change(d),
  4100. y.change(d),
  4101. v.html("")
  4102. }
  4103. function l(b) {
  4104. k(b, l);
  4105. var c = document.createElement("table");
  4106. c.className = "ke-table",
  4107. c.cellPadding = 0,
  4108. c.cellSpacing = 0,
  4109. c.border = 0,
  4110. v.append(c);
  4111. for (var d = b.file_list,
  4112. e = 0,
  4113. f = d.length; f > e; e++) {
  4114. var i = d[e],
  4115. m = a(c.insertRow(e));
  4116. m.mouseover(function() {
  4117. a(this).addClass("ke-on")
  4118. }).mouseout(function() {
  4119. a(this).removeClass("ke-on")
  4120. });
  4121. var n = g + (i.is_dir ? "folder-16.gif": "file-16.gif"),
  4122. o = a('<img src="' + n + '" width="16" height="16" alt="' + i.filename + '" align="absmiddle" />'),
  4123. p = a(m[0].insertCell(0)).addClass("ke-cell ke-name").append(o).append(document.createTextNode(" " + i.filename)); ! i.is_dir || i.has_file ? (m.css("cursor", "pointer"), p.attr("title", i.filename), j(p, b, i, l)) : p.attr("title", h.emptyFolder),
  4124. a(m[0].insertCell(1)).addClass("ke-cell ke-size").html(i.is_dir ? "-": Math.ceil(i.filesize / 1024) + "KB"),
  4125. a(m[0].insertCell(2)).addClass("ke-cell ke-datetime").html(i.datetime)
  4126. }
  4127. }
  4128. function m(b) {
  4129. k(b, m);
  4130. for (var d = b.file_list,
  4131. e = 0,
  4132. f = d.length; f > e; e++) {
  4133. var i = d[e],
  4134. l = a('<div class="ke-inline-block ke-item"></div>');
  4135. v.append(l);
  4136. var n = a('<div class="ke-inline-block ke-photo"></div>').mouseover(function() {
  4137. a(this).addClass("ke-on")
  4138. }).mouseout(function() {
  4139. a(this).removeClass("ke-on")
  4140. });
  4141. l.append(n);
  4142. var o = b.current_url + i.filename,
  4143. p = i.is_dir ? g + "folder-64.gif": i.is_photo ? o: g + "file-64.gif",
  4144. q = a('<img src="' + p + '" width="80" height="80" alt="' + i.filename + '" />'); ! i.is_dir || i.has_file ? (n.css("cursor", "pointer"), c(n, i), j(n, b, i, m)) : n.attr("title", h.emptyFolder),
  4145. n.append(q),
  4146. l.append('<div class="ke-name" title="' + i.filename + '">' + i.filename + "</div>")
  4147. }
  4148. }
  4149. var n = a.undef(b.width, 650),
  4150. o = a.undef(b.height, 510),
  4151. p = a.undef(b.dirName, ""),
  4152. q = a.undef(b.viewType, "VIEW").toUpperCase(),
  4153. r = b.clickFn,
  4154. s = ['<div style="padding:10px 20px;">', '<div class="ke-plugin-filemanager-header">', '<div class="ke-left">', '<img class="ke-inline-block" name="moveupImg" src="' + g + 'go-up.gif" width="16" height="16" border="0" alt="" /> ', '<a class="ke-inline-block" name="moveupLink" href="javascript:;">' + h.moveup + "</a>", "</div>", '<div class="ke-right">', h.viewType + ' <select class="ke-inline-block" name="viewType">', '<option value="VIEW">' + h.viewImage + "</option>", '<option value="LIST">' + h.listImage + "</option>", "</select> ", h.orderType + ' <select class="ke-inline-block" name="orderType">', '<option value="NAME">' + h.fileName + "</option>", '<option value="SIZE">' + h.fileSize + "</option>", '<option value="TYPE">' + h.fileType + "</option>", "</select>", "</div>", '<div class="ke-clearfix"></div>', "</div>", '<div class="ke-plugin-filemanager-body"></div>', "</div>"].join(""),
  4155. t = d.createDialog({
  4156. name: e,
  4157. width: n,
  4158. height: o,
  4159. title: d.lang(e),
  4160. body: s
  4161. }),
  4162. u = t.div,
  4163. v = a(".ke-plugin-filemanager-body", u),
  4164. w = (a('[name="moveupImg"]', u), a('[name="moveupLink"]', u)),
  4165. x = (a('[name="viewServer"]', u), a('[name="viewType"]', u)),
  4166. y = a('[name="orderType"]', u),
  4167. z = [];
  4168. return x.val(q),
  4169. i("", y.val(), "VIEW" == q ? m: l),
  4170. t
  4171. }
  4172. }),
  4173. KindEditor.plugin("flash",
  4174. function(a) {
  4175. var b = this,
  4176. c = "flash",
  4177. d = b.lang(c + "."),
  4178. e = a.undef(b.allowFlashUpload, !0),
  4179. f = a.undef(b.allowFileManager, !1),
  4180. g = a.undef(b.formatUploadUrl, !0),
  4181. h = a.undef(b.extraFileUploadParams, {}),
  4182. i = a.undef(b.filePostName, "imgFile"),
  4183. j = a.undef(b.uploadJson, b.basePath + "php/upload_json.php");
  4184. b.plugin.flash = {
  4185. edit: function() {
  4186. var k = ['<div style="padding:20px;">', '<div class="ke-dialog-row">', '<label for="keUrl" style="width:60px;">' + d.url + "</label>", '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;', '<input type="button" class="ke-upload-button" value="' + d.upload + '" /> &nbsp;', '<span class="ke-button-common ke-button-outer">', '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + d.viewServer + '" />', "</span>", "</div>", '<div class="ke-dialog-row">', '<label for="keWidth" style="width:60px;">' + d.width + "</label>", '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" /> ', "</div>", '<div class="ke-dialog-row">', '<label for="keHeight" style="width:60px;">' + d.height + "</label>", '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" /> ', "</div>", "</div>"].join(""),
  4187. l = b.createDialog({
  4188. name: c,
  4189. width: 450,
  4190. title: b.lang(c),
  4191. body: k,
  4192. yesBtn: {
  4193. name: b.lang("yes"),
  4194. click: function() {
  4195. var c = a.trim(n.val()),
  4196. d = p.val(),
  4197. e = q.val();
  4198. if ("http://" == c || a.invalidUrl(c)) return alert(b.lang("invalidUrl")),
  4199. void n[0].focus();
  4200. if (!/^\d*$/.test(d)) return alert(b.lang("invalidWidth")),
  4201. void p[0].focus();
  4202. if (!/^\d*$/.test(e)) return alert(b.lang("invalidHeight")),
  4203. void q[0].focus();
  4204. var f = a.mediaImg(b.themesPath + "common/blank.gif", {
  4205. src: c,
  4206. type: a.mediaType(".swf"),
  4207. width: d,
  4208. height: e,
  4209. quality: "high"
  4210. });
  4211. b.insertHtml(f).hideDialog().focus()
  4212. }
  4213. }
  4214. }),
  4215. m = l.div,
  4216. n = a('[name="url"]', m),
  4217. o = a('[name="viewServer"]', m),
  4218. p = a('[name="width"]', m),
  4219. q = a('[name="height"]', m);
  4220. if (n.val("http://"), e) {
  4221. var r = a.uploadbutton({
  4222. button: a(".ke-upload-button", m)[0],
  4223. fieldName: i,
  4224. extraParams: h,
  4225. url: a.addParam(j, "dir=flash"),
  4226. afterUpload: function(d) {
  4227. if (l.hideLoading(), 0 === d.error) {
  4228. var e = d.url;
  4229. g && (e = a.formatUrl(e, "absolute")),
  4230. n.val(e),
  4231. b.afterUpload && b.afterUpload.call(b, e, d, c),
  4232. alert(b.lang("uploadSuccess"))
  4233. } else alert(d.message)
  4234. },
  4235. afterError: function(a) {
  4236. l.hideLoading(),
  4237. b.errorDialog(a)
  4238. }
  4239. });
  4240. r.fileBox.change(function() {
  4241. l.showLoading(b.lang("uploadLoading")),
  4242. r.submit()
  4243. })
  4244. } else a(".ke-upload-button", m).hide();
  4245. f ? o.click(function() {
  4246. b.loadPlugin("filemanager",
  4247. function() {
  4248. b.plugin.filemanagerDialog({
  4249. viewType: "LIST",
  4250. dirName: "flash",
  4251. clickFn: function(c) {
  4252. b.dialogs.length > 1 && (a('[name="url"]', m).val(c), b.afterSelectFile && b.afterSelectFile.call(b, c), b.hideDialog())
  4253. }
  4254. })
  4255. })
  4256. }) : o.hide();
  4257. var s = b.plugin.getSelectedFlash();
  4258. if (s) {
  4259. var t = a.mediaAttrs(s.attr("data-ke-tag"));
  4260. n.val(t.src),
  4261. p.val(a.removeUnit(s.css("width")) || t.width || 0),
  4262. q.val(a.removeUnit(s.css("height")) || t.height || 0)
  4263. }
  4264. n[0].focus(),
  4265. n[0].select()
  4266. },
  4267. "delete": function() {
  4268. b.plugin.getSelectedFlash().remove(),
  4269. b.addBookmark()
  4270. }
  4271. },
  4272. b.clickToolbar(c, b.plugin.flash.edit)
  4273. }),
  4274. KindEditor.plugin("image",
  4275. function(a) {
  4276. var b = this,
  4277. c = "image",
  4278. d = a.undef(b.allowImageUpload, !0),
  4279. e = a.undef(b.allowImageRemote, !0),
  4280. f = a.undef(b.formatUploadUrl, !0),
  4281. g = a.undef(b.allowFileManager, !1),
  4282. h = a.undef(b.uploadJson, b.basePath + "php/upload_json.php"),
  4283. i = a.undef(b.imageTabIndex, 0),
  4284. j = b.pluginsPath + "image/images/",
  4285. k = a.undef(b.extraFileUploadParams, {}),
  4286. l = a.undef(b.filePostName, "imgFile"),
  4287. m = a.undef(b.fillDescAfterUploadImage, !1),
  4288. n = b.lang(c + ".");
  4289. b.plugin.imageDialog = function(d) {
  4290. function e(a, b) {
  4291. D.val(a),
  4292. E.val(b),
  4293. J = a,
  4294. K = b
  4295. }
  4296. var i = (d.imageUrl, a.undef(d.imageWidth, ""), a.undef(d.imageHeight, ""), a.undef(d.imageTitle, ""), a.undef(d.imageAlign, ""), a.undef(d.showRemote, !0)),
  4297. o = a.undef(d.showLocal, !0),
  4298. p = a.undef(d.tabIndex, 0),
  4299. q = d.clickFn,
  4300. r = "kindeditor_upload_iframe_" + (new Date).getTime(),
  4301. s = [];
  4302. for (var t in k) s.push('<input type="hidden" name="' + t + '" value="' + k[t] + '" />');
  4303. var u, v = ['<div style="padding:20px;">', '<div class="tabs"></div>', '<div class="tab1" style="display:none;">', '<div class="ke-dialog-row">', '<label for="remoteUrl" style="width:60px;">' + n.remoteUrl + "</label>", '<input type="text" id="remoteUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> &nbsp;', '<span class="ke-button-common ke-button-outer">', '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + n.viewServer + '" />', "</span>", "</div>", '<div class="ke-dialog-row">', '<label for="remoteWidth" style="width:60px;">' + n.size + "</label>", n.width + ' <input type="text" id="remoteWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ', n.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ', '<img class="ke-refresh-btn" src="' + j + 'refresh.png" width="16" height="16" alt="" style="cursor:pointer;" title="' + n.resetSize + '" />', "</div>", '<div class="ke-dialog-row">', '<label style="width:60px;">' + n.align + "</label>", '<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + j + 'align_top.gif" width="23" height="25" alt="" />', ' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + j + 'align_left.gif" width="23" height="25" alt="" />', ' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + j + 'align_right.gif" width="23" height="25" alt="" />', "</div>", '<div class="ke-dialog-row">', '<label for="remoteTitle" style="width:60px;">' + n.imgTitle + "</label>", '<input type="text" id="remoteTitle" class="ke-input-text" name="title" value="" style="width:200px;" />', "</div>", "</div>", '<div class="tab2" style="display:none;">', '<iframe name="' + r + '" style="display:none;"></iframe>', '<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + r + '" action="' + a.addParam(h, "dir=image") + '">', '<div class="ke-dialog-row">', s.join(""), '<label style="width:60px;">' + n.localUrl + "</label>", '<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> &nbsp;', '<input type="button" class="ke-upload-button" value="' + n.upload + '" />', "</div>", "</form>", "</div>", "</div>"].join(""),
  4304. w = o || g ? 450 : 400,
  4305. x = o && i ? 300 : 250,
  4306. y = b.createDialog({
  4307. name: c,
  4308. width: w,
  4309. height: x,
  4310. title: b.lang(c),
  4311. body: v,
  4312. yesBtn: {
  4313. name: b.lang("yes"),
  4314. click: function() {
  4315. if (!y.isLoading) {
  4316. if (o && i && u && 1 === u.selectedIndex || !i) return "" == I.fileBox.val() ? void alert(b.lang("pleaseSelectFile")) : (y.showLoading(b.lang("uploadLoading")), I.submit(), void B.val(""));
  4317. var c = a.trim(A.val()),
  4318. d = D.val(),
  4319. e = E.val(),
  4320. f = G.val(),
  4321. g = "";
  4322. return H.each(function() {
  4323. return this.checked ? (g = this.value, !1) : void 0
  4324. }),
  4325. "http://" == c || a.invalidUrl(c) ? (alert(b.lang("invalidUrl")), void A[0].focus()) : /^\d*$/.test(d) ? /^\d*$/.test(e) ? void q.call(b, c, f, d, e, 0, g) : (alert(b.lang("invalidHeight")), void E[0].focus()) : (alert(b.lang("invalidWidth")), void D[0].focus())
  4326. }
  4327. }
  4328. },
  4329. beforeRemove: function() {
  4330. C.unbind(),
  4331. D.unbind(),
  4332. E.unbind(),
  4333. F.unbind()
  4334. }
  4335. }),
  4336. z = y.div,
  4337. A = a('[name="url"]', z),
  4338. B = a('[name="localUrl"]', z),
  4339. C = a('[name="viewServer"]', z),
  4340. D = a('.tab1 [name="width"]', z),
  4341. E = a('.tab1 [name="height"]', z),
  4342. F = a(".ke-refresh-btn", z),
  4343. G = a('.tab1 [name="title"]', z),
  4344. H = a('.tab1 [name="align"]', z);
  4345. i && o ? (u = a.tabs({
  4346. src: a(".tabs", z),
  4347. afterSelect: function() {}
  4348. }), u.add({
  4349. title: n.remoteImage,
  4350. panel: a(".tab1", z)
  4351. }), u.add({
  4352. title: n.localImage,
  4353. panel: a(".tab2", z)
  4354. }), u.select(p)) : i ? a(".tab1", z).show() : o && a(".tab2", z).show();
  4355. var I = a.uploadbutton({
  4356. button: a(".ke-upload-button", z)[0],
  4357. fieldName: l,
  4358. form: a(".ke-form", z),
  4359. target: r,
  4360. width: 60,
  4361. afterUpload: function(d) {
  4362. if (y.hideLoading(), 0 === d.error) {
  4363. var e = d.url;
  4364. f && (e = a.formatUrl(e, "absolute")),
  4365. b.afterUpload && b.afterUpload.call(b, e, d, c),
  4366. m ? (a(".ke-dialog-row #remoteUrl", z).val(e), a(".ke-tabs-li", z)[0].click(), a(".ke-refresh-btn", z).click()) : q.call(b, e, d.title, d.width, d.height, d.border, d.align)
  4367. } else alert(d.message)
  4368. },
  4369. afterError: function(a) {
  4370. y.hideLoading(),
  4371. b.errorDialog(a)
  4372. }
  4373. });
  4374. I.fileBox.change(function() {
  4375. B.val(I.fileBox.val())
  4376. }),
  4377. g ? C.click(function() {
  4378. b.loadPlugin("filemanager",
  4379. function() {
  4380. b.plugin.filemanagerDialog({
  4381. viewType: "VIEW",
  4382. dirName: "image",
  4383. clickFn: function(c) {
  4384. b.dialogs.length > 1 && (a('[name="url"]', z).val(c), b.afterSelectFile && b.afterSelectFile.call(b, c), b.hideDialog())
  4385. }
  4386. })
  4387. })
  4388. }) : C.hide();
  4389. var J = 0,
  4390. K = 0;
  4391. return F.click(function() {
  4392. var b = a('<img src="' + A.val() + '" />', document).css({
  4393. position: "absolute",
  4394. visibility: "hidden",
  4395. top: 0,
  4396. left: "-1000px"
  4397. });
  4398. b.bind("load",
  4399. function() {
  4400. e(b.width(), b.height()),
  4401. b.remove()
  4402. }),
  4403. a(document.body).append(b)
  4404. }),
  4405. D.change(function() {
  4406. J > 0 && E.val(Math.round(K / J * parseInt(this.value, 10)))
  4407. }),
  4408. E.change(function() {
  4409. K > 0 && D.val(Math.round(J / K * parseInt(this.value, 10)))
  4410. }),
  4411. A.val(d.imageUrl),
  4412. e(d.imageWidth, d.imageHeight),
  4413. G.val(d.imageTitle),
  4414. H.each(function() {
  4415. return this.value === d.imageAlign ? (this.checked = !0, !1) : void 0
  4416. }),
  4417. i && 0 === p && (A[0].focus(), A[0].select()),
  4418. y
  4419. },
  4420. b.plugin.image = {
  4421. edit: function() {
  4422. var a = b.plugin.getSelectedImage();
  4423. b.plugin.imageDialog({
  4424. imageUrl: a ? a.attr("data-ke-src") : "http://",
  4425. imageWidth: a ? a.width() : "",
  4426. imageHeight: a ? a.height() : "",
  4427. imageTitle: a ? a.attr("title") : "",
  4428. imageAlign: a ? a.attr("align") : "",
  4429. showRemote: e,
  4430. showLocal: d,
  4431. tabIndex: a ? 0 : i,
  4432. clickFn: function(c, d, e, f, g, h) {
  4433. a ? (a.attr("src", c), a.attr("data-ke-src", c), a.attr("width", e), a.attr("height", f), a.attr("title", d), a.attr("align", h), a.attr("alt", d)) : b.exec("insertimage", c, d, e, f, g, h),
  4434. setTimeout(function() {
  4435. b.hideDialog().focus()
  4436. },
  4437. 0)
  4438. }
  4439. })
  4440. },
  4441. "delete": function() {
  4442. var a = b.plugin.getSelectedImage();
  4443. "a" == a.parent().name && (a = a.parent()),
  4444. a.remove(),
  4445. b.addBookmark()
  4446. }
  4447. },
  4448. b.clickToolbar(c, b.plugin.image.edit)
  4449. }),
  4450. KindEditor.plugin("insertfile",
  4451. function(a) {
  4452. var b = this,
  4453. c = "insertfile",
  4454. d = a.undef(b.allowFileUpload, !0),
  4455. e = a.undef(b.allowFileManager, !1),
  4456. f = a.undef(b.formatUploadUrl, !0),
  4457. g = a.undef(b.uploadJson, b.basePath + "php/upload_json.php"),
  4458. h = a.undef(b.extraFileUploadParams, {}),
  4459. i = a.undef(b.filePostName, "imgFile"),
  4460. j = b.lang(c + ".");
  4461. b.plugin.fileDialog = function(k) {
  4462. var l = a.undef(k.fileUrl, "http://"),
  4463. m = a.undef(k.fileTitle, ""),
  4464. n = k.clickFn,
  4465. o = ['<div style="padding:20px;">', '<div class="ke-dialog-row">', '<label for="keUrl" style="width:60px;">' + j.url + "</label>", '<input type="text" id="keUrl" name="url" class="ke-input-text" style="width:160px;" /> &nbsp;', '<input type="button" class="ke-upload-button" value="' + j.upload + '" /> &nbsp;', '<span class="ke-button-common ke-button-outer">', '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + j.viewServer + '" />', "</span>", "</div>", '<div class="ke-dialog-row">', '<label for="keTitle" style="width:60px;">' + j.title + "</label>", '<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:160px;" /></div>', "</div>", "</form>", "</div>"].join(""),
  4466. p = b.createDialog({
  4467. name: c,
  4468. width: 450,
  4469. title: b.lang(c),
  4470. body: o,
  4471. yesBtn: {
  4472. name: b.lang("yes"),
  4473. click: function() {
  4474. var c = a.trim(r.val()),
  4475. d = t.val();
  4476. return "http://" == c || a.invalidUrl(c) ? (alert(b.lang("invalidUrl")), void r[0].focus()) : ("" === a.trim(d) && (d = c), void n.call(b, c, d))
  4477. }
  4478. }
  4479. }),
  4480. q = p.div,
  4481. r = a('[name="url"]', q),
  4482. s = a('[name="viewServer"]', q),
  4483. t = a('[name="title"]', q);
  4484. if (d) {
  4485. var u = a.uploadbutton({
  4486. button: a(".ke-upload-button", q)[0],
  4487. fieldName: i,
  4488. url: a.addParam(g, "dir=file"),
  4489. extraParams: h,
  4490. afterUpload: function(d) {
  4491. if (p.hideLoading(), 0 === d.error) {
  4492. var e = d.url;
  4493. f && (e = a.formatUrl(e, "absolute")),
  4494. r.val(e),
  4495. b.afterUpload && b.afterUpload.call(b, e, d, c),
  4496. alert(b.lang("uploadSuccess"))
  4497. } else alert(d.message)
  4498. },
  4499. afterError: function(a) {
  4500. p.hideLoading(),
  4501. b.errorDialog(a)
  4502. }
  4503. });
  4504. u.fileBox.change(function() {
  4505. p.showLoading(b.lang("uploadLoading")),
  4506. u.submit()
  4507. })
  4508. } else a(".ke-upload-button", q).hide();
  4509. e ? s.click(function() {
  4510. b.loadPlugin("filemanager",
  4511. function() {
  4512. b.plugin.filemanagerDialog({
  4513. viewType: "LIST",
  4514. dirName: "file",
  4515. clickFn: function(c) {
  4516. b.dialogs.length > 1 && (a('[name="url"]', q).val(c), b.afterSelectFile && b.afterSelectFile.call(b, c), b.hideDialog())
  4517. }
  4518. })
  4519. })
  4520. }) : s.hide(),
  4521. r.val(l),
  4522. t.val(m),
  4523. r[0].focus(),
  4524. r[0].select()
  4525. },
  4526. b.clickToolbar(c,
  4527. function() {
  4528. b.plugin.fileDialog({
  4529. clickFn: function(a, c) {
  4530. var d = '<a class="ke-insertfile" href="' + a + '" data-ke-src="' + a + '" target="_blank">' + c + "</a>";
  4531. b.insertHtml(d).hideDialog().focus()
  4532. }
  4533. })
  4534. })
  4535. }),
  4536. KindEditor.plugin("lineheight",
  4537. function(a) {
  4538. var b = this,
  4539. c = "lineheight",
  4540. d = b.lang(c + ".");
  4541. b.clickToolbar(c,
  4542. function() {
  4543. var e = "",
  4544. f = b.cmd.commonNode({
  4545. "*": ".line-height"
  4546. });
  4547. f && (e = f.css("line-height"));
  4548. var g = b.createMenu({
  4549. name: c,
  4550. width: 150
  4551. });
  4552. a.each(d.lineHeight,
  4553. function(c, d) {
  4554. a.each(d,
  4555. function(a, c) {
  4556. g.addItem({
  4557. title: c,
  4558. checked: e === a,
  4559. click: function() {
  4560. b.cmd.toggle('<span style="line-height:' + a + ';"></span>', {
  4561. span: ".line-height=" + a
  4562. }),
  4563. b.updateState(),
  4564. b.addBookmark(),
  4565. b.hideMenu()
  4566. }
  4567. })
  4568. })
  4569. })
  4570. })
  4571. }),
  4572. KindEditor.plugin("link",
  4573. function(a) {
  4574. var b = this,
  4575. c = "link";
  4576. b.plugin.link = {
  4577. edit: function() {
  4578. var d = b.lang(c + "."),
  4579. e = '<div style="padding:20px;"><div class="ke-dialog-row"><label for="keUrl" style="width:60px;">' + d.url + '</label><input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:260px;" /></div><div class="ke-dialog-row""><label for="keType" style="width:60px;">' + d.linkType + '</label><select id="keType" name="type"></select></div></div>',
  4580. f = b.createDialog({
  4581. name: c,
  4582. width: 450,
  4583. title: b.lang(c),
  4584. body: e,
  4585. yesBtn: {
  4586. name: b.lang("yes"),
  4587. click: function() {
  4588. var c = a.trim(h.val());
  4589. return "http://" == c || a.invalidUrl(c) ? (alert(b.lang("invalidUrl")), void h[0].focus()) : void b.exec("createlink", c, i.val()).hideDialog().focus()
  4590. }
  4591. }
  4592. }),
  4593. g = f.div,
  4594. h = a('input[name="url"]', g),
  4595. i = a('select[name="type"]', g);
  4596. h.val("http://"),
  4597. i[0].options[0] = new Option(d.newWindow, "_blank"),
  4598. i[0].options[1] = new Option(d.selfWindow, ""),
  4599. b.cmd.selection();
  4600. var j = b.plugin.getSelectedLink();
  4601. j && (b.cmd.range.selectNode(j[0]), b.cmd.select(), h.val(j.attr("data-ke-src")), i.val(j.attr("target"))),
  4602. h[0].focus(),
  4603. h[0].select()
  4604. },
  4605. "delete": function() {
  4606. b.exec("unlink", null)
  4607. }
  4608. },
  4609. b.clickToolbar(c, b.plugin.link.edit)
  4610. }),
  4611. KindEditor.plugin("media",
  4612. function(a) {
  4613. var b = this,
  4614. c = "media",
  4615. d = b.lang(c + "."),
  4616. e = a.undef(b.allowMediaUpload, !0),
  4617. f = a.undef(b.allowFileManager, !1),
  4618. g = a.undef(b.formatUploadUrl, !0),
  4619. h = a.undef(b.extraFileUploadParams, {}),
  4620. i = a.undef(b.filePostName, "imgFile"),
  4621. j = a.undef(b.uploadJson, b.basePath + "php/upload_json.php");
  4622. b.plugin.media = {
  4623. edit: function() {
  4624. var k = ['<div style="padding:20px;">', '<div class="ke-dialog-row">', '<label for="keUrl" style="width:60px;">' + d.url + "</label>", '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;', '<input type="button" class="ke-upload-button" value="' + d.upload + '" /> &nbsp;', '<span class="ke-button-common ke-button-outer">', '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + d.viewServer + '" />', "</span>", "</div>", '<div class="ke-dialog-row">', '<label for="keWidth" style="width:60px;">' + d.width + "</label>", '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" />', "</div>", '<div class="ke-dialog-row">', '<label for="keHeight" style="width:60px;">' + d.height + "</label>", '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />', "</div>", '<div class="ke-dialog-row">', '<label for="keAutostart">' + d.autostart + "</label>", '<input type="checkbox" id="keAutostart" name="autostart" value="" /> ', "</div>", "</div>"].join(""),
  4625. l = b.createDialog({
  4626. name: c,
  4627. width: 450,
  4628. height: 230,
  4629. title: b.lang(c),
  4630. body: k,
  4631. yesBtn: {
  4632. name: b.lang("yes"),
  4633. click: function() {
  4634. var c = a.trim(n.val()),
  4635. d = p.val(),
  4636. e = q.val();
  4637. if ("http://" == c || a.invalidUrl(c)) return alert(b.lang("invalidUrl")),
  4638. void n[0].focus();
  4639. if (!/^\d*$/.test(d)) return alert(b.lang("invalidWidth")),
  4640. void p[0].focus();
  4641. if (!/^\d*$/.test(e)) return alert(b.lang("invalidHeight")),
  4642. void q[0].focus();
  4643. var f = a.mediaImg(b.themesPath + "common/blank.gif", {
  4644. src: c,
  4645. type: a.mediaType(c),
  4646. width: d,
  4647. height: e,
  4648. autostart: r[0].checked ? "true": "false",
  4649. loop: "true"
  4650. });
  4651. b.insertHtml(f).hideDialog().focus()
  4652. }
  4653. }
  4654. }),
  4655. m = l.div,
  4656. n = a('[name="url"]', m),
  4657. o = a('[name="viewServer"]', m),
  4658. p = a('[name="width"]', m),
  4659. q = a('[name="height"]', m),
  4660. r = a('[name="autostart"]', m);
  4661. if (n.val("http://"), e) {
  4662. var s = a.uploadbutton({
  4663. button: a(".ke-upload-button", m)[0],
  4664. fieldName: i,
  4665. extraParams: h,
  4666. url: a.addParam(j, "dir=media"),
  4667. afterUpload: function(d) {
  4668. if (l.hideLoading(), 0 === d.error) {
  4669. var e = d.url;
  4670. g && (e = a.formatUrl(e, "absolute")),
  4671. n.val(e),
  4672. b.afterUpload && b.afterUpload.call(b, e, d, c),
  4673. alert(b.lang("uploadSuccess"))
  4674. } else alert(d.message)
  4675. },
  4676. afterError: function(a) {
  4677. l.hideLoading(),
  4678. b.errorDialog(a)
  4679. }
  4680. });
  4681. s.fileBox.change(function() {
  4682. l.showLoading(b.lang("uploadLoading")),
  4683. s.submit()
  4684. })
  4685. } else a(".ke-upload-button", m).hide();
  4686. f ? o.click(function() {
  4687. b.loadPlugin("filemanager",
  4688. function() {
  4689. b.plugin.filemanagerDialog({
  4690. viewType: "LIST",
  4691. dirName: "media",
  4692. clickFn: function(c) {
  4693. b.dialogs.length > 1 && (a('[name="url"]', m).val(c), b.afterSelectFile && b.afterSelectFile.call(b, c), b.hideDialog())
  4694. }
  4695. })
  4696. })
  4697. }) : o.hide();
  4698. var t = b.plugin.getSelectedMedia();
  4699. if (t) {
  4700. var u = a.mediaAttrs(t.attr("data-ke-tag"));
  4701. n.val(u.src),
  4702. p.val(a.removeUnit(t.css("width")) || u.width || 0),
  4703. q.val(a.removeUnit(t.css("height")) || u.height || 0),
  4704. r[0].checked = "true" === u.autostart
  4705. }
  4706. n[0].focus(),
  4707. n[0].select()
  4708. },
  4709. "delete": function() {
  4710. b.plugin.getSelectedMedia().remove(),
  4711. b.addBookmark()
  4712. }
  4713. },
  4714. b.clickToolbar(c, b.plugin.media.edit)
  4715. }),
  4716. function(a) {
  4717. function b(a) {
  4718. this.init(a)
  4719. }
  4720. a.extend(b, {
  4721. init: function(b) {
  4722. function c(b, c) {
  4723. a(".ke-status > div", b).hide(),
  4724. a(".ke-message", b).addClass("ke-error").show().html(a.escape(c))
  4725. }
  4726. var d = this;
  4727. b.afterError = b.afterError ||
  4728. function(a) {
  4729. alert(a)
  4730. },
  4731. d.options = b,
  4732. d.progressbars = {},
  4733. d.div = a(b.container).html(['<div class="ke-swfupload">', '<div class="ke-swfupload-top">', '<div class="ke-inline-block ke-swfupload-button">', '<input type="button" value="Browse" />', "</div>", '<div class="ke-inline-block ke-swfupload-desc">' + b.uploadDesc + "</div>", '<span class="ke-button-common ke-button-outer ke-swfupload-startupload">', '<input type="button" class="ke-button-common ke-button" value="' + b.startButtonValue + '" />', "</span>", "</div>", '<div class="ke-swfupload-body"></div>', "</div>"].join("")),
  4734. d.bodyDiv = a(".ke-swfupload-body", d.div);
  4735. var e = {
  4736. debug: !1,
  4737. upload_url: b.uploadUrl,
  4738. flash_url: b.flashUrl,
  4739. file_post_name: b.filePostName,
  4740. button_placeholder: a(".ke-swfupload-button > input", d.div)[0],
  4741. button_image_url: b.buttonImageUrl,
  4742. button_width: b.buttonWidth,
  4743. button_height: b.buttonHeight,
  4744. button_cursor: SWFUpload.CURSOR.HAND,
  4745. file_types: b.fileTypes,
  4746. file_types_description: b.fileTypesDesc,
  4747. file_upload_limit: b.fileUploadLimit,
  4748. file_size_limit: b.fileSizeLimit,
  4749. post_params: b.postParams,
  4750. file_queued_handler: function(a) {
  4751. a.url = d.options.fileIconUrl,
  4752. d.appendFile(a)
  4753. },
  4754. file_queue_error_handler: function(c, d) {
  4755. var e = "";
  4756. switch (d) {
  4757. case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
  4758. e = b.queueLimitExceeded;
  4759. break;
  4760. case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
  4761. e = b.fileExceedsSizeLimit;
  4762. break;
  4763. case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
  4764. e = b.zeroByteFile;
  4765. break;
  4766. case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
  4767. e = b.invalidFiletype;
  4768. break;
  4769. default:
  4770. e = b.unknownError
  4771. }
  4772. a.DEBUG && alert(e)
  4773. },
  4774. upload_start_handler: function(b) {
  4775. var c = this,
  4776. d = a('div[data-id="' + b.id + '"]', c.bodyDiv);
  4777. a(".ke-status > div", d).hide(),
  4778. a(".ke-progressbar", d).show()
  4779. },
  4780. upload_progress_handler: function(a, b, c) {
  4781. var e = Math.round(100 * b / c),
  4782. f = d.progressbars[a.id];
  4783. f.bar.css("width", Math.round(80 * e / 100) + "px"),
  4784. f.percent.html(e + "%")
  4785. },
  4786. upload_error_handler: function(b) {
  4787. if (b && b.filestatus == SWFUpload.FILE_STATUS.ERROR) {
  4788. var e = a('div[data-id="' + b.id + '"]', d.bodyDiv).eq(0);
  4789. c(e, d.options.errorMessage)
  4790. }
  4791. },
  4792. upload_success_handler: function(b, e) {
  4793. var f = a('div[data-id="' + b.id + '"]', d.bodyDiv).eq(0),
  4794. g = {};
  4795. try {
  4796. g = a.json(e)
  4797. } catch(h) {
  4798. d.options.afterError.call(this, "<!doctype html><html>" + e + "</html>")
  4799. }
  4800. return 0 !== g.error ? void c(f, a.DEBUG ? g.message: d.options.errorMessage) : (b.url = g.url, a(".ke-img", f).attr("src", b.url).attr("data-status", b.filestatus).data("data", g), void a(".ke-status > div", f).hide())
  4801. }
  4802. };
  4803. d.swfu = new SWFUpload(e),
  4804. a(".ke-swfupload-startupload input", d.div).click(function() {
  4805. d.swfu.startUpload()
  4806. })
  4807. },
  4808. getUrlList: function() {
  4809. var b = [];
  4810. return a(".ke-img", self.bodyDiv).each(function() {
  4811. var c = a(this),
  4812. d = c.attr("data-status");
  4813. d == SWFUpload.FILE_STATUS.COMPLETE && b.push(c.data("data"))
  4814. }),
  4815. b
  4816. },
  4817. removeFile: function(b) {
  4818. var c = this;
  4819. c.swfu.cancelUpload(b);
  4820. var d = a('div[data-id="' + b + '"]', c.bodyDiv);
  4821. a(".ke-photo", d).unbind(),
  4822. a(".ke-delete", d).unbind(),
  4823. d.remove()
  4824. },
  4825. removeFiles: function() {
  4826. var b = this;
  4827. a(".ke-item", b.bodyDiv).each(function() {
  4828. b.removeFile(a(this).attr("data-id"))
  4829. })
  4830. },
  4831. appendFile: function(b) {
  4832. var c = this,
  4833. d = a('<div class="ke-inline-block ke-item" data-id="' + b.id + '"></div>');
  4834. c.bodyDiv.append(d);
  4835. var e = a('<div class="ke-inline-block ke-photo"></div>').mouseover(function() {
  4836. a(this).addClass("ke-on")
  4837. }).mouseout(function() {
  4838. a(this).removeClass("ke-on")
  4839. });
  4840. d.append(e);
  4841. var f = a('<img src="' + b.url + '" class="ke-img" data-status="' + b.filestatus + '" width="80" height="80" alt="' + b.name + '" />');
  4842. e.append(f),
  4843. a('<span class="ke-delete"></span>').appendTo(e).click(function() {
  4844. c.removeFile(b.id)
  4845. });
  4846. var g = a('<div class="ke-status"></div>').appendTo(e);
  4847. a(['<div class="ke-progressbar">', '<div class="ke-progressbar-bar"><div class="ke-progressbar-bar-inner"></div></div>', '<div class="ke-progressbar-percent">0%</div></div>'].join("")).hide().appendTo(g),
  4848. a('<div class="ke-message">' + c.options.pendingMessage + "</div>").appendTo(g),
  4849. d.append('<div class="ke-name">' + b.name + "</div>"),
  4850. c.progressbars[b.id] = {
  4851. bar: a(".ke-progressbar-bar-inner", e),
  4852. percent: a(".ke-progressbar-percent", e)
  4853. }
  4854. },
  4855. remove: function() {
  4856. this.removeFiles(),
  4857. this.swfu.destroy(),
  4858. this.div.html("")
  4859. }
  4860. }),
  4861. a.swfupload = function(a, c) {
  4862. return new b(a, c)
  4863. }
  4864. } (KindEditor),
  4865. KindEditor.plugin("multiimage",
  4866. function(a) {
  4867. var b = this,
  4868. c = "multiimage",
  4869. d = (a.undef(b.formatUploadUrl, !0), a.undef(b.uploadJson, b.basePath + "php/upload_json.php")),
  4870. e = b.pluginsPath + "multiimage/images/",
  4871. f = a.undef(b.imageSizeLimit, "1MB"),
  4872. g = (a.undef(b.imageFileTypes, "*.jpg;*.gif;*.png"), a.undef(b.imageUploadLimit, 20)),
  4873. h = a.undef(b.filePostName, "imgFile"),
  4874. i = b.lang(c + ".");
  4875. b.plugin.multiImageDialog = function(j) {
  4876. var k = j.clickFn,
  4877. l = a.tmpl(i.uploadDesc, {
  4878. uploadLimit: g,
  4879. sizeLimit: f
  4880. }),
  4881. m = ['<div style="padding:20px;">', '<div class="swfupload">', "</div>", "</div>"].join(""),
  4882. n = b.createDialog({
  4883. name: c,
  4884. width: 650,
  4885. height: 510,
  4886. title: b.lang(c),
  4887. body: m,
  4888. previewBtn: {
  4889. name: i.insertAll,
  4890. click: function() {
  4891. k.call(b, p.getUrlList())
  4892. }
  4893. },
  4894. yesBtn: {
  4895. name: i.clearAll,
  4896. click: function() {
  4897. p.removeFiles()
  4898. }
  4899. },
  4900. beforeRemove: function() { (!a.IE || a.V <= 8) && p.remove()
  4901. }
  4902. }),
  4903. o = n.div,
  4904. p = a.swfupload({
  4905. container: a(".swfupload", o),
  4906. buttonImageUrl: e + ("zh-CN" == b.langType ? "select-files-zh-CN.png": "select-files-en.png"),
  4907. buttonWidth: "zh-CN" == b.langType ? 72 : 88,
  4908. buttonHeight: 23,
  4909. fileIconUrl: e + "image.png",
  4910. uploadDesc: l,
  4911. startButtonValue: i.startUpload,
  4912. uploadUrl: a.addParam(d, "dir=image"),
  4913. flashUrl: e + "swfupload.swf",
  4914. filePostName: h,
  4915. fileTypes: "*.jpg;*.jpeg;*.gif;*.png;*.bmp",
  4916. fileTypesDesc: "Image Files",
  4917. fileUploadLimit: g,
  4918. fileSizeLimit: f,
  4919. postParams: a.undef(b.extraFileUploadParams, {}),
  4920. queueLimitExceeded: i.queueLimitExceeded,
  4921. fileExceedsSizeLimit: i.fileExceedsSizeLimit,
  4922. zeroByteFile: i.zeroByteFile,
  4923. invalidFiletype: i.invalidFiletype,
  4924. unknownError: i.unknownError,
  4925. pendingMessage: i.pending,
  4926. errorMessage: i.uploadError,
  4927. afterError: function(a) {
  4928. b.errorDialog(a)
  4929. }
  4930. });
  4931. return n
  4932. },
  4933. b.clickToolbar(c,
  4934. function() {
  4935. b.plugin.multiImageDialog({
  4936. clickFn: function(c) {
  4937. 0 !== c.length && (a.each(c,
  4938. function(a, c) {
  4939. b.afterUpload && b.afterUpload.call(b, c.url, c, "multiimage"),
  4940. b.exec("insertimage", c.url, c.title, c.width, c.height, c.border, c.align)
  4941. }), setTimeout(function() {
  4942. b.hideDialog().focus()
  4943. },
  4944. 0))
  4945. }
  4946. })
  4947. })
  4948. }),
  4949. function() {
  4950. window.SWFUpload = function(a) {
  4951. this.initSWFUpload(a)
  4952. },
  4953. SWFUpload.prototype.initSWFUpload = function(a) {
  4954. try {
  4955. this.customSettings = {},
  4956. this.settings = a,
  4957. this.eventQueue = [],
  4958. this.movieName = "KindEditor_SWFUpload_" + SWFUpload.movieCount++,
  4959. this.movieElement = null,
  4960. SWFUpload.instances[this.movieName] = this,
  4961. this.initSettings(),
  4962. this.loadFlash(),
  4963. this.displayDebugInfo()
  4964. } catch(b) {
  4965. throw delete SWFUpload.instances[this.movieName],
  4966. b
  4967. }
  4968. },
  4969. SWFUpload.instances = {},
  4970. SWFUpload.movieCount = 0,
  4971. SWFUpload.version = "2.2.0 2009-03-25",
  4972. SWFUpload.QUEUE_ERROR = {
  4973. QUEUE_LIMIT_EXCEEDED: -100,
  4974. FILE_EXCEEDS_SIZE_LIMIT: -110,
  4975. ZERO_BYTE_FILE: -120,
  4976. INVALID_FILETYPE: -130
  4977. },
  4978. SWFUpload.UPLOAD_ERROR = {
  4979. HTTP_ERROR: -200,
  4980. MISSING_UPLOAD_URL: -210,
  4981. IO_ERROR: -220,
  4982. SECURITY_ERROR: -230,
  4983. UPLOAD_LIMIT_EXCEEDED: -240,
  4984. UPLOAD_FAILED: -250,
  4985. SPECIFIED_FILE_ID_NOT_FOUND: -260,
  4986. FILE_VALIDATION_FAILED: -270,
  4987. FILE_CANCELLED: -280,
  4988. UPLOAD_STOPPED: -290
  4989. },
  4990. SWFUpload.FILE_STATUS = {
  4991. QUEUED: -1,
  4992. IN_PROGRESS: -2,
  4993. ERROR: -3,
  4994. COMPLETE: -4,
  4995. CANCELLED: -5
  4996. },
  4997. SWFUpload.BUTTON_ACTION = {
  4998. SELECT_FILE: -100,
  4999. SELECT_FILES: -110,
  5000. START_UPLOAD: -120
  5001. },
  5002. SWFUpload.CURSOR = {
  5003. ARROW: -1,
  5004. HAND: -2
  5005. },
  5006. SWFUpload.WINDOW_MODE = {
  5007. WINDOW: "window",
  5008. TRANSPARENT: "transparent",
  5009. OPAQUE: "opaque"
  5010. },
  5011. SWFUpload.completeURL = function(a) {
  5012. if ("string" != typeof a || a.match(/^https?:\/\//i) || a.match(/^\//)) return a;
  5013. var b = (window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port: ""), window.location.pathname.lastIndexOf("/"));
  5014. return path = 0 >= b ? "/": window.location.pathname.substr(0, b) + "/",
  5015. path + a
  5016. },
  5017. SWFUpload.prototype.initSettings = function() {
  5018. this.ensureDefault = function(a, b) {
  5019. this.settings[a] = void 0 == this.settings[a] ? b: this.settings[a]
  5020. },
  5021. this.ensureDefault("upload_url", ""),
  5022. this.ensureDefault("preserve_relative_urls", !1),
  5023. this.ensureDefault("file_post_name", "Filedata"),
  5024. this.ensureDefault("post_params", {}),
  5025. this.ensureDefault("use_query_string", !1),
  5026. this.ensureDefault("requeue_on_error", !1),
  5027. this.ensureDefault("http_success", []),
  5028. this.ensureDefault("assume_success_timeout", 0),
  5029. this.ensureDefault("file_types", "*.*"),
  5030. this.ensureDefault("file_types_description", "All Files"),
  5031. this.ensureDefault("file_size_limit", 0),
  5032. this.ensureDefault("file_upload_limit", 0),
  5033. this.ensureDefault("file_queue_limit", 0),
  5034. this.ensureDefault("flash_url", "swfupload.swf"),
  5035. this.ensureDefault("prevent_swf_caching", !0),
  5036. this.ensureDefault("button_image_url", ""),
  5037. this.ensureDefault("button_width", 1),
  5038. this.ensureDefault("button_height", 1),
  5039. this.ensureDefault("button_text", ""),
  5040. this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"),
  5041. this.ensureDefault("button_text_top_padding", 0),
  5042. this.ensureDefault("button_text_left_padding", 0),
  5043. this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES),
  5044. this.ensureDefault("button_disabled", !1),
  5045. this.ensureDefault("button_placeholder_id", ""),
  5046. this.ensureDefault("button_placeholder", null),
  5047. this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW),
  5048. this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW),
  5049. this.ensureDefault("debug", !1),
  5050. this.settings.debug_enabled = this.settings.debug,
  5051. this.settings.return_upload_start_handler = this.returnUploadStart,
  5052. this.ensureDefault("swfupload_loaded_handler", null),
  5053. this.ensureDefault("file_dialog_start_handler", null),
  5054. this.ensureDefault("file_queued_handler", null),
  5055. this.ensureDefault("file_queue_error_handler", null),
  5056. this.ensureDefault("file_dialog_complete_handler", null),
  5057. this.ensureDefault("upload_start_handler", null),
  5058. this.ensureDefault("upload_progress_handler", null),
  5059. this.ensureDefault("upload_error_handler", null),
  5060. this.ensureDefault("upload_success_handler", null),
  5061. this.ensureDefault("upload_complete_handler", null),
  5062. this.ensureDefault("debug_handler", this.debugMessage),
  5063. this.ensureDefault("custom_settings", {}),
  5064. this.customSettings = this.settings.custom_settings,
  5065. this.settings.prevent_swf_caching && (this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?": "&") + "preventswfcaching=" + (new Date).getTime()),
  5066. this.settings.preserve_relative_urls || (this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url), this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url)),
  5067. delete this.ensureDefault
  5068. },
  5069. SWFUpload.prototype.loadFlash = function() {
  5070. var a, b;
  5071. if (null !== document.getElementById(this.movieName)) throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
  5072. if (a = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder, void 0 == a) throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
  5073. b = document.createElement("div"),
  5074. b.innerHTML = this.getFlashHTML(),
  5075. a.parentNode.replaceChild(b.firstChild, a),
  5076. void 0 == window[this.movieName] && (window[this.movieName] = this.getMovieElement())
  5077. },
  5078. SWFUpload.prototype.getFlashHTML = function() {
  5079. var a = "";
  5080. return KindEditor.IE && KindEditor.V > 8 && (a = ' classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'),
  5081. ['<object id="', this.movieName, '"' + a + ' type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">', '<param name="wmode" value="', this.settings.button_window_mode, '" />', '<param name="movie" value="', this.settings.flash_url, '" />', '<param name="quality" value="high" />', '<param name="menu" value="false" />', '<param name="allowScriptAccess" value="always" />', '<param name="flashvars" value="' + this.getFlashVars() + '" />', "</object>"].join("")
  5082. },
  5083. SWFUpload.prototype.getFlashVars = function() {
  5084. var a = this.buildParamString(),
  5085. b = this.settings.http_success.join(",");
  5086. return ["movieName=", encodeURIComponent(this.movieName), "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url), "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string), "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), "&amp;httpSuccess=", encodeURIComponent(b), "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), "&amp;params=", encodeURIComponent(a), "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name), "&amp;fileTypes=", encodeURIComponent(this.settings.file_types), "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled), "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url), "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width), "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height), "&amp;buttonText=", encodeURIComponent(this.settings.button_text), "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), "&amp;buttonAction=", encodeURIComponent(this.settings.button_action), "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled), "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)].join("")
  5087. },
  5088. SWFUpload.prototype.getMovieElement = function() {
  5089. if (void 0 == this.movieElement && (this.movieElement = document.getElementById(this.movieName)), null === this.movieElement) throw "Could not find Flash element";
  5090. return this.movieElement
  5091. },
  5092. SWFUpload.prototype.buildParamString = function() {
  5093. var a = this.settings.post_params,
  5094. b = [];
  5095. if ("object" == typeof a) for (var c in a) a.hasOwnProperty(c) && b.push(encodeURIComponent(c.toString()) + "=" + encodeURIComponent(a[c].toString()));
  5096. return b.join("&amp;")
  5097. },
  5098. SWFUpload.prototype.destroy = function() {
  5099. try {
  5100. this.cancelUpload(null, !1);
  5101. var a = null;
  5102. if (a = this.getMovieElement(), a && "unknown" == typeof a.CallFunction) {
  5103. for (var b in a) try {
  5104. "function" == typeof a[b] && (a[b] = null)
  5105. } catch(c) {}
  5106. try {
  5107. a.parentNode.removeChild(a)
  5108. } catch(d) {}
  5109. }
  5110. return window[this.movieName] = null,
  5111. SWFUpload.instances[this.movieName] = null,
  5112. delete SWFUpload.instances[this.movieName],
  5113. this.movieElement = null,
  5114. this.settings = null,
  5115. this.customSettings = null,
  5116. this.eventQueue = null,
  5117. this.movieName = null,
  5118. !0
  5119. } catch(e) {
  5120. return ! 1
  5121. }
  5122. },
  5123. SWFUpload.prototype.displayDebugInfo = function() {
  5124. this.debug(["---SWFUpload Instance Info---\n", "Version: ", SWFUpload.version, "\n", "Movie Name: ", this.movieName, "\n", "Settings:\n", " ", "upload_url: ", this.settings.upload_url, "\n", " ", "flash_url: ", this.settings.flash_url, "\n", " ", "use_query_string: ", this.settings.use_query_string.toString(), "\n", " ", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", " ", "http_success: ", this.settings.http_success.join(", "), "\n", " ", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", " ", "file_post_name: ", this.settings.file_post_name, "\n", " ", "post_params: ", this.settings.post_params.toString(), "\n", " ", "file_types: ", this.settings.file_types, "\n", " ", "file_types_description: ", this.settings.file_types_description, "\n", " ", "file_size_limit: ", this.settings.file_size_limit, "\n", " ", "file_upload_limit: ", this.settings.file_upload_limit, "\n", " ", "file_queue_limit: ", this.settings.file_queue_limit, "\n", " ", "debug: ", this.settings.debug.toString(), "\n", " ", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", " ", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", " ", "button_placeholder: ", this.settings.button_placeholder ? "Set": "Not Set", "\n", " ", "button_image_url: ", this.settings.button_image_url.toString(), "\n", " ", "button_width: ", this.settings.button_width.toString(), "\n", " ", "button_height: ", this.settings.button_height.toString(), "\n", " ", "button_text: ", this.settings.button_text.toString(), "\n", " ", "button_text_style: ", this.settings.button_text_style.toString(), "\n", " ", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", " ", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", " ", "button_action: ", this.settings.button_action.toString(), "\n", " ", "button_disabled: ", this.settings.button_disabled.toString(), "\n", " ", "custom_settings: ", this.settings.custom_settings.toString(), "\n", "Event Handlers:\n", " ", "swfupload_loaded_handler assigned: ", ("function" == typeof this.settings.swfupload_loaded_handler).toString(), "\n", " ", "file_dialog_start_handler assigned: ", ("function" == typeof this.settings.file_dialog_start_handler).toString(), "\n", " ", "file_queued_handler assigned: ", ("function" == typeof this.settings.file_queued_handler).toString(), "\n", " ", "file_queue_error_handler assigned: ", ("function" == typeof this.settings.file_queue_error_handler).toString(), "\n", " ", "upload_start_handler assigned: ", ("function" == typeof this.settings.upload_start_handler).toString(), "\n", " ", "upload_progress_handler assigned: ", ("function" == typeof this.settings.upload_progress_handler).toString(), "\n", " ", "upload_error_handler assigned: ", ("function" == typeof this.settings.upload_error_handler).toString(), "\n", " ", "upload_success_handler assigned: ", ("function" == typeof this.settings.upload_success_handler).toString(), "\n", " ", "upload_complete_handler assigned: ", ("function" == typeof this.settings.upload_complete_handler).toString(), "\n", " ", "debug_handler assigned: ", ("function" == typeof this.settings.debug_handler).toString(), "\n"].join(""))
  5125. },
  5126. SWFUpload.prototype.addSetting = function(a, b, c) {
  5127. return this.settings[a] = void 0 == b ? c: b
  5128. },
  5129. SWFUpload.prototype.getSetting = function(a) {
  5130. return void 0 != this.settings[a] ? this.settings[a] : ""
  5131. },
  5132. SWFUpload.prototype.callFlash = function(functionName, argumentArray) {
  5133. argumentArray = argumentArray || [];
  5134. var movieElement = this.getMovieElement(),
  5135. returnValue,
  5136. returnString;
  5137. try {
  5138. returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + "</invoke>"),
  5139. returnValue = eval(returnString)
  5140. } catch(ex) {
  5141. throw "Call to " + functionName + " failed"
  5142. }
  5143. return void 0 != returnValue && "object" == typeof returnValue.post && (returnValue = this.unescapeFilePostParams(returnValue)),
  5144. returnValue
  5145. },
  5146. SWFUpload.prototype.selectFile = function() {
  5147. this.callFlash("SelectFile")
  5148. },
  5149. SWFUpload.prototype.selectFiles = function() {
  5150. this.callFlash("SelectFiles")
  5151. },
  5152. SWFUpload.prototype.startUpload = function(a) {
  5153. this.callFlash("StartUpload", [a])
  5154. },
  5155. SWFUpload.prototype.cancelUpload = function(a, b) {
  5156. b !== !1 && (b = !0),
  5157. this.callFlash("CancelUpload", [a, b])
  5158. },
  5159. SWFUpload.prototype.stopUpload = function() {
  5160. this.callFlash("StopUpload")
  5161. },
  5162. SWFUpload.prototype.getStats = function() {
  5163. return this.callFlash("GetStats")
  5164. },
  5165. SWFUpload.prototype.setStats = function(a) {
  5166. this.callFlash("SetStats", [a])
  5167. },
  5168. SWFUpload.prototype.getFile = function(a) {
  5169. return "number" == typeof a ? this.callFlash("GetFileByIndex", [a]) : this.callFlash("GetFile", [a])
  5170. },
  5171. SWFUpload.prototype.addFileParam = function(a, b, c) {
  5172. return this.callFlash("AddFileParam", [a, b, c])
  5173. },
  5174. SWFUpload.prototype.removeFileParam = function(a, b) {
  5175. this.callFlash("RemoveFileParam", [a, b])
  5176. },
  5177. SWFUpload.prototype.setUploadURL = function(a) {
  5178. this.settings.upload_url = a.toString(),
  5179. this.callFlash("SetUploadURL", [a])
  5180. },
  5181. SWFUpload.prototype.setPostParams = function(a) {
  5182. this.settings.post_params = a,
  5183. this.callFlash("SetPostParams", [a])
  5184. },
  5185. SWFUpload.prototype.addPostParam = function(a, b) {
  5186. this.settings.post_params[a] = b,
  5187. this.callFlash("SetPostParams", [this.settings.post_params])
  5188. },
  5189. SWFUpload.prototype.removePostParam = function(a) {
  5190. delete this.settings.post_params[a],
  5191. this.callFlash("SetPostParams", [this.settings.post_params])
  5192. },
  5193. SWFUpload.prototype.setFileTypes = function(a, b) {
  5194. this.settings.file_types = a,
  5195. this.settings.file_types_description = b,
  5196. this.callFlash("SetFileTypes", [a, b])
  5197. },
  5198. SWFUpload.prototype.setFileSizeLimit = function(a) {
  5199. this.settings.file_size_limit = a,
  5200. this.callFlash("SetFileSizeLimit", [a])
  5201. },
  5202. SWFUpload.prototype.setFileUploadLimit = function(a) {
  5203. this.settings.file_upload_limit = a,
  5204. this.callFlash("SetFileUploadLimit", [a])
  5205. },
  5206. SWFUpload.prototype.setFileQueueLimit = function(a) {
  5207. this.settings.file_queue_limit = a,
  5208. this.callFlash("SetFileQueueLimit", [a])
  5209. },
  5210. SWFUpload.prototype.setFilePostName = function(a) {
  5211. this.settings.file_post_name = a,
  5212. this.callFlash("SetFilePostName", [a])
  5213. },
  5214. SWFUpload.prototype.setUseQueryString = function(a) {
  5215. this.settings.use_query_string = a,
  5216. this.callFlash("SetUseQueryString", [a])
  5217. },
  5218. SWFUpload.prototype.setRequeueOnError = function(a) {
  5219. this.settings.requeue_on_error = a,
  5220. this.callFlash("SetRequeueOnError", [a])
  5221. },
  5222. SWFUpload.prototype.setHTTPSuccess = function(a) {
  5223. "string" == typeof a && (a = a.replace(" ", "").split(",")),
  5224. this.settings.http_success = a,
  5225. this.callFlash("SetHTTPSuccess", [a])
  5226. },
  5227. SWFUpload.prototype.setAssumeSuccessTimeout = function(a) {
  5228. this.settings.assume_success_timeout = a,
  5229. this.callFlash("SetAssumeSuccessTimeout", [a])
  5230. },
  5231. SWFUpload.prototype.setDebugEnabled = function(a) {
  5232. this.settings.debug_enabled = a,
  5233. this.callFlash("SetDebugEnabled", [a])
  5234. },
  5235. SWFUpload.prototype.setButtonImageURL = function(a) {
  5236. void 0 == a && (a = ""),
  5237. this.settings.button_image_url = a,
  5238. this.callFlash("SetButtonImageURL", [a])
  5239. },
  5240. SWFUpload.prototype.setButtonDimensions = function(a, b) {
  5241. this.settings.button_width = a,
  5242. this.settings.button_height = b;
  5243. var c = this.getMovieElement();
  5244. void 0 != c && (c.style.width = a + "px", c.style.height = b + "px"),
  5245. this.callFlash("SetButtonDimensions", [a, b])
  5246. },
  5247. SWFUpload.prototype.setButtonText = function(a) {
  5248. this.settings.button_text = a,
  5249. this.callFlash("SetButtonText", [a])
  5250. },
  5251. SWFUpload.prototype.setButtonTextPadding = function(a, b) {
  5252. this.settings.button_text_top_padding = b,
  5253. this.settings.button_text_left_padding = a,
  5254. this.callFlash("SetButtonTextPadding", [a, b])
  5255. },
  5256. SWFUpload.prototype.setButtonTextStyle = function(a) {
  5257. this.settings.button_text_style = a,
  5258. this.callFlash("SetButtonTextStyle", [a])
  5259. },
  5260. SWFUpload.prototype.setButtonDisabled = function(a) {
  5261. this.settings.button_disabled = a,
  5262. this.callFlash("SetButtonDisabled", [a])
  5263. },
  5264. SWFUpload.prototype.setButtonAction = function(a) {
  5265. this.settings.button_action = a,
  5266. this.callFlash("SetButtonAction", [a])
  5267. },
  5268. SWFUpload.prototype.setButtonCursor = function(a) {
  5269. this.settings.button_cursor = a,
  5270. this.callFlash("SetButtonCursor", [a])
  5271. },
  5272. SWFUpload.prototype.queueEvent = function(a, b) {
  5273. void 0 == b ? b = [] : b instanceof Array || (b = [b]);
  5274. var c = this;
  5275. if ("function" == typeof this.settings[a]) this.eventQueue.push(function() {
  5276. this.settings[a].apply(this, b)
  5277. }),
  5278. setTimeout(function() {
  5279. c.executeNextEvent()
  5280. },
  5281. 0);
  5282. else if (null !== this.settings[a]) throw "Event handler " + a + " is unknown or is not a function"
  5283. },
  5284. SWFUpload.prototype.executeNextEvent = function() {
  5285. var a = this.eventQueue ? this.eventQueue.shift() : null;
  5286. "function" == typeof a && a.apply(this)
  5287. },
  5288. SWFUpload.prototype.unescapeFilePostParams = function(a) {
  5289. var b, c = /[$]([0-9a-f]{4})/i,
  5290. d = {};
  5291. if (void 0 != a) {
  5292. for (var e in a.post) if (a.post.hasOwnProperty(e)) {
  5293. b = e;
  5294. for (var f; null !== (f = c.exec(b));) b = b.replace(f[0], String.fromCharCode(parseInt("0x" + f[1], 16)));
  5295. d[b] = a.post[e]
  5296. }
  5297. a.post = d
  5298. }
  5299. return a
  5300. },
  5301. SWFUpload.prototype.testExternalInterface = function() {
  5302. try {
  5303. return this.callFlash("TestExternalInterface")
  5304. } catch(a) {
  5305. return ! 1
  5306. }
  5307. },
  5308. SWFUpload.prototype.flashReady = function() {
  5309. var a = this.getMovieElement();
  5310. return a ? (this.cleanUp(a), void this.queueEvent("swfupload_loaded_handler")) : void this.debug("Flash called back ready but the flash movie can't be found.")
  5311. },
  5312. SWFUpload.prototype.cleanUp = function(a) {
  5313. try {
  5314. if (this.movieElement && "unknown" == typeof a.CallFunction) {
  5315. this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
  5316. for (var b in a) try {
  5317. "function" == typeof a[b] && (a[b] = null)
  5318. } catch(c) {}
  5319. }
  5320. } catch(d) {}
  5321. window.__flash__removeCallback = function(a, b) {
  5322. try {
  5323. a && (a[b] = null)
  5324. } catch(c) {}
  5325. }
  5326. },
  5327. SWFUpload.prototype.fileDialogStart = function() {
  5328. this.queueEvent("file_dialog_start_handler")
  5329. },
  5330. SWFUpload.prototype.fileQueued = function(a) {
  5331. a = this.unescapeFilePostParams(a),
  5332. this.queueEvent("file_queued_handler", a)
  5333. },
  5334. SWFUpload.prototype.fileQueueError = function(a, b, c) {
  5335. a = this.unescapeFilePostParams(a),
  5336. this.queueEvent("file_queue_error_handler", [a, b, c])
  5337. },
  5338. SWFUpload.prototype.fileDialogComplete = function(a, b, c) {
  5339. this.queueEvent("file_dialog_complete_handler", [a, b, c])
  5340. },
  5341. SWFUpload.prototype.uploadStart = function(a) {
  5342. a = this.unescapeFilePostParams(a),
  5343. this.queueEvent("return_upload_start_handler", a)
  5344. },
  5345. SWFUpload.prototype.returnUploadStart = function(a) {
  5346. var b;
  5347. if ("function" == typeof this.settings.upload_start_handler) a = this.unescapeFilePostParams(a),
  5348. b = this.settings.upload_start_handler.call(this, a);
  5349. else if (void 0 != this.settings.upload_start_handler) throw "upload_start_handler must be a function";
  5350. void 0 === b && (b = !0),
  5351. b = !!b,
  5352. this.callFlash("ReturnUploadStart", [b])
  5353. },
  5354. SWFUpload.prototype.uploadProgress = function(a, b, c) {
  5355. a = this.unescapeFilePostParams(a),
  5356. this.queueEvent("upload_progress_handler", [a, b, c])
  5357. },
  5358. SWFUpload.prototype.uploadError = function(a, b, c) {
  5359. a = this.unescapeFilePostParams(a),
  5360. this.queueEvent("upload_error_handler", [a, b, c])
  5361. },
  5362. SWFUpload.prototype.uploadSuccess = function(a, b, c) {
  5363. a = this.unescapeFilePostParams(a),
  5364. this.queueEvent("upload_success_handler", [a, b, c])
  5365. },
  5366. SWFUpload.prototype.uploadComplete = function(a) {
  5367. a = this.unescapeFilePostParams(a),
  5368. this.queueEvent("upload_complete_handler", a)
  5369. },
  5370. SWFUpload.prototype.debug = function(a) {
  5371. this.queueEvent("debug_handler", a)
  5372. },
  5373. SWFUpload.prototype.debugMessage = function(a) {
  5374. if (this.settings.debug) {
  5375. var b, c = [];
  5376. if ("object" == typeof a && "string" == typeof a.name && "string" == typeof a.message) {
  5377. for (var d in a) a.hasOwnProperty(d) && c.push(d + ": " + a[d]);
  5378. b = c.join("\n") || "",
  5379. c = b.split("\n"),
  5380. b = "EXCEPTION: " + c.join("\nEXCEPTION: "),
  5381. SWFUpload.Console.writeLine(b)
  5382. } else SWFUpload.Console.writeLine(a)
  5383. }
  5384. },
  5385. SWFUpload.Console = {},
  5386. SWFUpload.Console.writeLine = function(a) {
  5387. var b, c;
  5388. try {
  5389. b = document.getElementById("SWFUpload_Console"),
  5390. b || (c = document.createElement("form"), document.getElementsByTagName("body")[0].appendChild(c), b = document.createElement("textarea"), b.id = "SWFUpload_Console", b.style.fontFamily = "monospace", b.setAttribute("wrap", "off"), b.wrap = "off", b.style.overflow = "auto", b.style.width = "700px", b.style.height = "350px", b.style.margin = "5px", c.appendChild(b)),
  5391. b.value += a + "\n",
  5392. b.scrollTop = b.scrollHeight - b.clientHeight
  5393. } catch(d) {
  5394. alert("Exception: " + d.name + " Message: " + d.message)
  5395. }
  5396. }
  5397. } (),
  5398. function() {
  5399. "function" == typeof SWFUpload && (SWFUpload.queue = {},
  5400. SWFUpload.prototype.initSettings = function(a) {
  5401. return function() {
  5402. "function" == typeof a && a.call(this),
  5403. this.queueSettings = {},
  5404. this.queueSettings.queue_cancelled_flag = !1,
  5405. this.queueSettings.queue_upload_count = 0,
  5406. this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler,
  5407. this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler,
  5408. this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler,
  5409. this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler,
  5410. this.settings.queue_complete_handler = this.settings.queue_complete_handler || null
  5411. }
  5412. } (SWFUpload.prototype.initSettings), SWFUpload.prototype.startUpload = function(a) {
  5413. this.queueSettings.queue_cancelled_flag = !1,
  5414. this.callFlash("StartUpload", [a])
  5415. },
  5416. SWFUpload.prototype.cancelQueue = function() {
  5417. this.queueSettings.queue_cancelled_flag = !0,
  5418. this.stopUpload();
  5419. for (var a = this.getStats(); a.files_queued > 0;) this.cancelUpload(),
  5420. a = this.getStats()
  5421. },
  5422. SWFUpload.queue.uploadStartHandler = function(a) {
  5423. var b;
  5424. return "function" == typeof this.queueSettings.user_upload_start_handler && (b = this.queueSettings.user_upload_start_handler.call(this, a)),
  5425. b = b === !1 ? !1 : !0,
  5426. this.queueSettings.queue_cancelled_flag = !b,
  5427. b
  5428. },
  5429. SWFUpload.queue.uploadCompleteHandler = function(a) {
  5430. var b, c = this.queueSettings.user_upload_complete_handler;
  5431. if (a.filestatus === SWFUpload.FILE_STATUS.COMPLETE && this.queueSettings.queue_upload_count++, b = "function" == typeof c ? c.call(this, a) === !1 ? !1 : !0 : a.filestatus === SWFUpload.FILE_STATUS.QUEUED ? !1 : !0) {
  5432. var d = this.getStats();
  5433. d.files_queued > 0 && this.queueSettings.queue_cancelled_flag === !1 ? this.startUpload() : this.queueSettings.queue_cancelled_flag === !1 ? (this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]), this.queueSettings.queue_upload_count = 0) : (this.queueSettings.queue_cancelled_flag = !1, this.queueSettings.queue_upload_count = 0)
  5434. }
  5435. })
  5436. } (),
  5437. KindEditor.plugin("pagebreak",
  5438. function(a) {
  5439. var b = this,
  5440. c = "pagebreak",
  5441. d = a.undef(b.pagebreakHtml, '<hr style="page-break-after: always;" class="ke-pagebreak" />');
  5442. b.clickToolbar(c,
  5443. function() {
  5444. var c = b.cmd,
  5445. e = c.range;
  5446. b.focus();
  5447. var f = "br" == b.newlineTag || a.WEBKIT ? "": '<span id="__kindeditor_tail_tag__"></span>';
  5448. if (b.insertHtml(d + f), "" !== f) {
  5449. var g = a("#__kindeditor_tail_tag__", b.edit.doc);
  5450. e.selectNodeContents(g[0]),
  5451. g.removeAttr("id"),
  5452. c.select()
  5453. }
  5454. })
  5455. }),
  5456. KindEditor.plugin("plainpaste",
  5457. function(a) {
  5458. var b = this,
  5459. c = "plainpaste";
  5460. b.clickToolbar(c,
  5461. function() {
  5462. var d = b.lang(c + "."),
  5463. e = '<div style="padding:10px 20px;"><div style="margin-bottom:10px;">' + d.comment + '</div><textarea class="ke-textarea" style="width:408px;height:260px;"></textarea></div>',
  5464. f = b.createDialog({
  5465. name: c,
  5466. width: 450,
  5467. title: b.lang(c),
  5468. body: e,
  5469. yesBtn: {
  5470. name: b.lang("yes"),
  5471. click: function() {
  5472. var c = g.val();
  5473. c = a.escape(c),
  5474. c = c.replace(/ {2}/g, " &nbsp;"),
  5475. c = "p" == b.newlineTag ? c.replace(/^/, "<p>").replace(/$/, "</p>").replace(/\n/g, "</p><p>") : c.replace(/\n/g, "<br />$&"),
  5476. b.insertHtml(c).hideDialog().focus()
  5477. }
  5478. }
  5479. }),
  5480. g = a("textarea", f.div);
  5481. g[0].focus()
  5482. })
  5483. }),
  5484. KindEditor.plugin("preview",
  5485. function(a) {
  5486. var b = this,
  5487. c = "preview";
  5488. b.clickToolbar(c,
  5489. function() {
  5490. var d = (b.lang(c + "."), '<div style="padding:10px 20px;"><iframe class="ke-textarea" frameborder="0" style="width:708px;height:400px;"></iframe></div>'),
  5491. e = b.createDialog({
  5492. name: c,
  5493. width: 750,
  5494. title: b.lang(c),
  5495. body: d
  5496. }),
  5497. f = a("iframe", e.div),
  5498. g = a.iframeDoc(f);
  5499. g.open(),
  5500. g.write(b.fullHtml()),
  5501. g.close(),
  5502. a(g.body).css("background-color", "#FFF"),
  5503. f[0].contentWindow.focus()
  5504. })
  5505. }),
  5506. KindEditor.plugin("quickformat",
  5507. function(a) {
  5508. function b(a) {
  5509. for (var b = a.first(); b && b.first();) b = b.first();
  5510. return b
  5511. }
  5512. var c = this,
  5513. d = "quickformat",
  5514. e = a.toMap("blockquote,center,div,h1,h2,h3,h4,h5,h6,p");
  5515. c.clickToolbar(d,
  5516. function() {
  5517. c.focus();
  5518. for (var d, f = c.edit.doc,
  5519. g = c.cmd.range,
  5520. h = a(f.body).first(), i = [], j = [], k = g.createBookmark(!0); h;) {
  5521. d = h.next();
  5522. var l = b(h);
  5523. l && "img" == l.name || (e[h.name] ? (h.html(h.html().replace(/^(\s|&nbsp;| )+/gi, "")), h.css("text-indent", "2em")) : j.push(h), (!d || e[d.name] || e[h.name] && !e[d.name]) && (j.length > 0 && i.push(j), j = [])),
  5524. h = d
  5525. }
  5526. a.each(i,
  5527. function(b, c) {
  5528. var d = a('<p style="text-indent:2em;"></p>', f);
  5529. c[0].before(d),
  5530. a.each(c,
  5531. function(a, b) {
  5532. d.append(b)
  5533. })
  5534. }),
  5535. g.moveToBookmark(k),
  5536. c.addBookmark()
  5537. })
  5538. }),
  5539. KindEditor.plugin("table",
  5540. function(a) {
  5541. function b(a, b) {
  5542. b = b.toUpperCase(),
  5543. a.css("background-color", b),
  5544. a.css("color", "#000000" === b ? "#FFFFFF": "#000000"),
  5545. a.html(b)
  5546. }
  5547. function c(c, d) {
  5548. function f() {
  5549. a.each(i,
  5550. function() {
  5551. this.remove()
  5552. }),
  5553. i = [],
  5554. a(document).unbind("click,mousedown", f),
  5555. c.unbind("click,mousedown", f)
  5556. }
  5557. d.bind("click,mousedown",
  5558. function(a) {
  5559. a.stopPropagation()
  5560. }),
  5561. d.click(function() {
  5562. f();
  5563. var d = a(this),
  5564. g = d.pos(),
  5565. h = a.colorpicker({
  5566. x: g.x,
  5567. y: g.y + d.height(),
  5568. z: 811214,
  5569. selectedColor: a(this).html(),
  5570. colors: e.colorTable,
  5571. noColor: e.lang("noColor"),
  5572. shadowMode: e.shadowMode,
  5573. click: function(a) {
  5574. b(d, a),
  5575. f()
  5576. }
  5577. });
  5578. i.push(h),
  5579. a(document).bind("click,mousedown", f),
  5580. c.bind("click,mousedown", f)
  5581. })
  5582. }
  5583. function d(a, b, c) {
  5584. for (var d = 0,
  5585. e = 0,
  5586. f = b.cells.length; f > e && b.cells[e] != c; e++) d += b.cells[e].rowSpan - 1;
  5587. return c.cellIndex - d
  5588. }
  5589. var e = this,
  5590. f = "table",
  5591. g = e.lang(f + "."),
  5592. h = "ke-zeroborder",
  5593. i = [];
  5594. e.plugin.table = {
  5595. prop: function(d) {
  5596. var i = ['<div style="padding:20px;">', '<div class="ke-dialog-row">', '<label for="keRows" style="width:90px;">' + g.cells + "</label>", g.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> &nbsp; ', g.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />', "</div>", '<div class="ke-dialog-row">', '<label for="keWidth" style="width:90px;">' + g.size + "</label>", g.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ', '<select name="widthType">', '<option value="%">' + g.percent + "</option>", '<option value="px">' + g.px + "</option>", "</select> &nbsp; ", g.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ', '<select name="heightType">', '<option value="%">' + g.percent + "</option>", '<option value="px">' + g.px + "</option>", "</select>", "</div>", '<div class="ke-dialog-row">', '<label for="kePadding" style="width:90px;">' + g.space + "</label>", g.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> &nbsp; ', g.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />', "</div>", '<div class="ke-dialog-row">', '<label for="keAlign" style="width:90px;">' + g.align + "</label>", '<select id="keAlign" name="align">', '<option value="">' + g.alignDefault + "</option>", '<option value="left">' + g.alignLeft + "</option>", '<option value="center">' + g.alignCenter + "</option>", '<option value="right">' + g.alignRight + "</option>", "</select>", "</div>", '<div class="ke-dialog-row">', '<label for="keBorder" style="width:90px;">' + g.border + "</label>", g.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ', g.borderColor + ' <span class="ke-inline-block ke-input-color"></span>', "</div>", '<div class="ke-dialog-row">', '<label for="keBgColor" style="width:90px;">' + g.backgroundColor + "</label>", '<span class="ke-inline-block ke-input-color"></span>', "</div>", "</div>"].join(""),
  5597. j = e.cmd.range.createBookmark(),
  5598. k = e.createDialog({
  5599. name: f,
  5600. width: 500,
  5601. title: e.lang(f),
  5602. body: i,
  5603. beforeRemove: function() {
  5604. w.unbind()
  5605. },
  5606. yesBtn: {
  5607. name: e.lang("yes"),
  5608. click: function() {
  5609. var b = m.val(),
  5610. c = n.val(),
  5611. d = o.val(),
  5612. f = p.val(),
  5613. g = q.val(),
  5614. i = r.val(),
  5615. k = s.val(),
  5616. l = t.val(),
  5617. y = u.val(),
  5618. z = v.val(),
  5619. A = a(w[0]).html() || "",
  5620. B = a(w[1]).html() || "";
  5621. if (0 == b || !/^\d+$/.test(b)) return alert(e.lang("invalidRows")),
  5622. void m[0].focus();
  5623. if (0 == c || !/^\d+$/.test(c)) return alert(e.lang("invalidRows")),
  5624. void n[0].focus();
  5625. if (!/^\d*$/.test(d)) return alert(e.lang("invalidWidth")),
  5626. void o[0].focus();
  5627. if (!/^\d*$/.test(f)) return alert(e.lang("invalidHeight")),
  5628. void p[0].focus();
  5629. if (!/^\d*$/.test(k)) return alert(e.lang("invalidPadding")),
  5630. void s[0].focus();
  5631. if (!/^\d*$/.test(l)) return alert(e.lang("invalidSpacing")),
  5632. void t[0].focus();
  5633. if (!/^\d*$/.test(z)) return alert(e.lang("invalidBorder")),
  5634. void v[0].focus();
  5635. if (x) return "" !== d ? x.width(d + g) : x.css("width", ""),
  5636. void 0 !== x[0].width && x.removeAttr("width"),
  5637. "" !== f ? x.height(f + i) : x.css("height", ""),
  5638. void 0 !== x[0].height && x.removeAttr("height"),
  5639. x.css("background-color", B),
  5640. void 0 !== x[0].bgColor && x.removeAttr("bgColor"),
  5641. "" !== k ? x[0].cellPadding = k: x.removeAttr("cellPadding"),
  5642. "" !== l ? x[0].cellSpacing = l: x.removeAttr("cellSpacing"),
  5643. "" !== y ? x[0].align = y: x.removeAttr("align"),
  5644. "" !== z ? x.attr("border", z) : x.removeAttr("border"),
  5645. "" === z || "0" === z ? x.addClass(h) : x.removeClass(h),
  5646. "" !== A ? x.attr("borderColor", A) : x.removeAttr("borderColor"),
  5647. e.hideDialog().focus(),
  5648. e.cmd.range.moveToBookmark(j),
  5649. e.cmd.select(),
  5650. void e.addBookmark();
  5651. var C = "";
  5652. "" !== d && (C += "width:" + d + g + ";"),
  5653. "" !== f && (C += "height:" + f + i + ";"),
  5654. "" !== B && (C += "background-color:" + B + ";");
  5655. var D = "<table";
  5656. "" !== C && (D += ' style="' + C + '"'),
  5657. "" !== k && (D += ' cellpadding="' + k + '"'),
  5658. "" !== l && (D += ' cellspacing="' + l + '"'),
  5659. "" !== y && (D += ' align="' + y + '"'),
  5660. "" !== z && (D += ' border="' + z + '"'),
  5661. ("" === z || "0" === z) && (D += ' class="' + h + '"'),
  5662. "" !== A && (D += ' bordercolor="' + A + '"'),
  5663. D += ">";
  5664. for (var E = 0; b > E; E++) {
  5665. D += "<tr>";
  5666. for (var F = 0; c > F; F++) D += "<td>" + (a.IE ? "&nbsp;": "<br />") + "</td>";
  5667. D += "</tr>"
  5668. }
  5669. D += "</table>",
  5670. a.IE || (D += "<br />"),
  5671. e.insertHtml(D),
  5672. e.select().hideDialog().focus(),
  5673. e.addBookmark()
  5674. }
  5675. }
  5676. }),
  5677. l = k.div,
  5678. m = a('[name="rows"]', l).val(3),
  5679. n = a('[name="cols"]', l).val(2),
  5680. o = a('[name="width"]', l).val(100),
  5681. p = a('[name="height"]', l),
  5682. q = a('[name="widthType"]', l),
  5683. r = a('[name="heightType"]', l),
  5684. s = a('[name="padding"]', l).val(2),
  5685. t = a('[name="spacing"]', l).val(0),
  5686. u = a('[name="align"]', l),
  5687. v = a('[name="border"]', l).val(1),
  5688. w = a(".ke-input-color", l);
  5689. c(l, w.eq(0)),
  5690. c(l, w.eq(1)),
  5691. b(w.eq(0), "#000000"),
  5692. b(w.eq(1), ""),
  5693. m[0].focus(),
  5694. m[0].select();
  5695. var x;
  5696. if (!d && (x = e.plugin.getSelectedTable())) {
  5697. m.val(x[0].rows.length),
  5698. n.val(x[0].rows.length > 0 ? x[0].rows[0].cells.length: 0),
  5699. m.attr("disabled", !0),
  5700. n.attr("disabled", !0);
  5701. var y, z = x[0].style.width || x[0].width,
  5702. A = x[0].style.height || x[0].height;
  5703. void 0 !== z && (y = /^(\d+)((?:px|%)*)$/.exec(z)) ? (o.val(y[1]), q.val(y[2])) : o.val(""),
  5704. void 0 !== A && (y = /^(\d+)((?:px|%)*)$/.exec(A)) && (p.val(y[1]), r.val(y[2])),
  5705. s.val(x[0].cellPadding || ""),
  5706. t.val(x[0].cellSpacing || ""),
  5707. u.val(x[0].align || ""),
  5708. v.val(void 0 === x[0].border ? "": x[0].border),
  5709. b(w.eq(0), a.toHex(x.attr("borderColor") || "")),
  5710. b(w.eq(1), a.toHex(x[0].style.backgroundColor || x[0].bgColor || "")),
  5711. o[0].focus(),
  5712. o[0].select()
  5713. }
  5714. },
  5715. cellprop: function() {
  5716. var d = ['<div style="padding:20px;">', '<div class="ke-dialog-row">', '<label for="keWidth" style="width:90px;">' + g.size + "</label>", g.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ', '<select name="widthType">', '<option value="%">' + g.percent + "</option>", '<option value="px">' + g.px + "</option>", "</select> &nbsp; ", g.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ', '<select name="heightType">', '<option value="%">' + g.percent + "</option>", '<option value="px">' + g.px + "</option>", "</select>", "</div>", '<div class="ke-dialog-row">', '<label for="keAlign" style="width:90px;">' + g.align + "</label>", g.textAlign + ' <select id="keAlign" name="textAlign">', '<option value="">' + g.alignDefault + "</option>", '<option value="left">' + g.alignLeft + "</option>", '<option value="center">' + g.alignCenter + "</option>", '<option value="right">' + g.alignRight + "</option>", "</select> ", g.verticalAlign + ' <select name="verticalAlign">', '<option value="">' + g.alignDefault + "</option>", '<option value="top">' + g.alignTop + "</option>", '<option value="middle">' + g.alignMiddle + "</option>", '<option value="bottom">' + g.alignBottom + "</option>", '<option value="baseline">' + g.alignBaseline + "</option>", "</select>", "</div>", '<div class="ke-dialog-row">', '<label for="keBorder" style="width:90px;">' + g.border + "</label>", g.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ', g.borderColor + ' <span class="ke-inline-block ke-input-color"></span>', "</div>", '<div class="ke-dialog-row">', '<label for="keBgColor" style="width:90px;">' + g.backgroundColor + "</label>", '<span class="ke-inline-block ke-input-color"></span>', "</div>", "</div>"].join(""),
  5717. h = e.cmd.range.createBookmark(),
  5718. i = e.createDialog({
  5719. name: f,
  5720. width: 500,
  5721. title: e.lang("tablecell"),
  5722. body: d,
  5723. beforeRemove: function() {
  5724. t.unbind()
  5725. },
  5726. yesBtn: {
  5727. name: e.lang("yes"),
  5728. click: function() {
  5729. var b = k.val(),
  5730. c = l.val(),
  5731. d = m.val(),
  5732. f = n.val(),
  5733. g = (o.val(), p.val(), q.val()),
  5734. i = r.val(),
  5735. j = s.val(),
  5736. u = a(t[0]).html() || "",
  5737. w = a(t[1]).html() || "";
  5738. return /^\d*$/.test(b) ? /^\d*$/.test(c) ? /^\d*$/.test(j) ? (v.css({
  5739. width: "" !== b ? b + d: "",
  5740. height: "" !== c ? c + f: "",
  5741. "background-color": w,
  5742. "text-align": g,
  5743. "vertical-align": i,
  5744. "border-width": j,
  5745. "border-style": "" !== j ? "solid": "",
  5746. "border-color": u
  5747. }), e.hideDialog().focus(), e.cmd.range.moveToBookmark(h), e.cmd.select(), void e.addBookmark()) : (alert(e.lang("invalidBorder")), void s[0].focus()) : (alert(e.lang("invalidHeight")), void l[0].focus()) : (alert(e.lang("invalidWidth")), void k[0].focus())
  5748. }
  5749. }
  5750. }),
  5751. j = i.div,
  5752. k = a('[name="width"]', j).val(100),
  5753. l = a('[name="height"]', j),
  5754. m = a('[name="widthType"]', j),
  5755. n = a('[name="heightType"]', j),
  5756. o = a('[name="padding"]', j).val(2),
  5757. p = a('[name="spacing"]', j).val(0),
  5758. q = a('[name="textAlign"]', j),
  5759. r = a('[name="verticalAlign"]', j),
  5760. s = a('[name="border"]', j).val(1),
  5761. t = a(".ke-input-color", j);
  5762. c(j, t.eq(0)),
  5763. c(j, t.eq(1)),
  5764. b(t.eq(0), "#000000"),
  5765. b(t.eq(1), ""),
  5766. k[0].focus(),
  5767. k[0].select();
  5768. var u, v = e.plugin.getSelectedCell(),
  5769. w = v[0].style.width || v[0].width || "",
  5770. x = v[0].style.height || v[0].height || ""; (u = /^(\d+)((?:px|%)*)$/.exec(w)) ? (k.val(u[1]), m.val(u[2])) : k.val(""),
  5771. (u = /^(\d+)((?:px|%)*)$/.exec(x)) && (l.val(u[1]), n.val(u[2])),
  5772. q.val(v[0].style.textAlign || ""),
  5773. r.val(v[0].style.verticalAlign || "");
  5774. var y = v[0].style.borderWidth || "";
  5775. y && (y = parseInt(y)),
  5776. s.val(y),
  5777. b(t.eq(0), a.toHex(v[0].style.borderColor || "")),
  5778. b(t.eq(1), a.toHex(v[0].style.backgroundColor || "")),
  5779. k[0].focus(),
  5780. k[0].select()
  5781. },
  5782. insert: function() {
  5783. this.prop(!0)
  5784. },
  5785. "delete": function() {
  5786. var a = e.plugin.getSelectedTable();
  5787. e.cmd.range.setStartBefore(a[0]).collapse(!0),
  5788. e.cmd.select(),
  5789. a.remove(),
  5790. e.addBookmark()
  5791. },
  5792. colinsert: function(b) {
  5793. var c = e.plugin.getSelectedTable()[0],
  5794. f = e.plugin.getSelectedRow()[0],
  5795. g = e.plugin.getSelectedCell()[0],
  5796. h = g.cellIndex + b;
  5797. h += c.rows[0].cells.length - f.cells.length;
  5798. for (var i = 0,
  5799. j = c.rows.length; j > i; i++) {
  5800. var k = c.rows[i],
  5801. l = k.insertCell(h);
  5802. l.innerHTML = a.IE ? "": "<br />",
  5803. h = d(c, k, l)
  5804. }
  5805. e.cmd.range.selectNodeContents(g).collapse(!0),
  5806. e.cmd.select(),
  5807. e.addBookmark()
  5808. },
  5809. colinsertleft: function() {
  5810. this.colinsert(0)
  5811. },
  5812. colinsertright: function() {
  5813. this.colinsert(1)
  5814. },
  5815. rowinsert: function(b) {
  5816. var c = e.plugin.getSelectedTable()[0],
  5817. d = e.plugin.getSelectedRow()[0],
  5818. f = e.plugin.getSelectedCell()[0],
  5819. g = d.rowIndex;
  5820. 1 === b && (g = d.rowIndex + (f.rowSpan - 1) + b);
  5821. for (var h = c.insertRow(g), i = 0, j = d.cells.length; j > i; i++) {
  5822. d.cells[i].rowSpan > 1 && (j -= d.cells[i].rowSpan - 1);
  5823. var k = h.insertCell(i);
  5824. 1 === b && d.cells[i].colSpan > 1 && (k.colSpan = d.cells[i].colSpan),
  5825. k.innerHTML = a.IE ? "": "<br />"
  5826. }
  5827. for (var l = g; l >= 0; l--) {
  5828. var m = c.rows[l].cells;
  5829. if (m.length > i) {
  5830. for (var n = f.cellIndex; n >= 0; n--) m[n].rowSpan > 1 && (m[n].rowSpan += 1);
  5831. break
  5832. }
  5833. }
  5834. e.cmd.range.selectNodeContents(f).collapse(!0),
  5835. e.cmd.select(),
  5836. e.addBookmark()
  5837. },
  5838. rowinsertabove: function() {
  5839. this.rowinsert(0)
  5840. },
  5841. rowinsertbelow: function() {
  5842. this.rowinsert(1)
  5843. },
  5844. rowmerge: function() {
  5845. var a = e.plugin.getSelectedTable()[0],
  5846. b = e.plugin.getSelectedRow()[0],
  5847. c = e.plugin.getSelectedCell()[0],
  5848. d = b.rowIndex,
  5849. f = d + c.rowSpan,
  5850. g = a.rows[f];
  5851. if (! (a.rows.length <= f)) {
  5852. var h = c.cellIndex;
  5853. if (! (g.cells.length <= h)) {
  5854. var i = g.cells[h];
  5855. c.colSpan === i.colSpan && (c.rowSpan += i.rowSpan, g.deleteCell(h), e.cmd.range.selectNodeContents(c).collapse(!0), e.cmd.select(), e.addBookmark())
  5856. }
  5857. }
  5858. },
  5859. colmerge: function() {
  5860. var a = (e.plugin.getSelectedTable()[0], e.plugin.getSelectedRow()[0]),
  5861. b = e.plugin.getSelectedCell()[0],
  5862. c = (a.rowIndex, b.cellIndex),
  5863. d = c + 1;
  5864. if (! (a.cells.length <= d)) {
  5865. var f = a.cells[d];
  5866. b.rowSpan === f.rowSpan && (b.colSpan += f.colSpan, a.deleteCell(d), e.cmd.range.selectNodeContents(b).collapse(!0), e.cmd.select(), e.addBookmark())
  5867. }
  5868. },
  5869. rowsplit: function() {
  5870. var b = e.plugin.getSelectedTable()[0],
  5871. c = e.plugin.getSelectedRow()[0],
  5872. f = e.plugin.getSelectedCell()[0],
  5873. g = c.rowIndex;
  5874. if (1 !== f.rowSpan) {
  5875. for (var h = d(b, c, f), i = 1, j = f.rowSpan; j > i; i++) {
  5876. var k = b.rows[g + i],
  5877. l = k.insertCell(h);
  5878. f.colSpan > 1 && (l.colSpan = f.colSpan),
  5879. l.innerHTML = a.IE ? "": "<br />",
  5880. h = d(b, k, l)
  5881. }
  5882. a(f).removeAttr("rowSpan"),
  5883. e.cmd.range.selectNodeContents(f).collapse(!0),
  5884. e.cmd.select(),
  5885. e.addBookmark()
  5886. }
  5887. },
  5888. colsplit: function() {
  5889. var b = (e.plugin.getSelectedTable()[0], e.plugin.getSelectedRow()[0]),
  5890. c = e.plugin.getSelectedCell()[0],
  5891. d = c.cellIndex;
  5892. if (1 !== c.colSpan) {
  5893. for (var f = 1,
  5894. g = c.colSpan; g > f; f++) {
  5895. var h = b.insertCell(d + f);
  5896. c.rowSpan > 1 && (h.rowSpan = c.rowSpan),
  5897. h.innerHTML = a.IE ? "": "<br />"
  5898. }
  5899. a(c).removeAttr("colSpan"),
  5900. e.cmd.range.selectNodeContents(c).collapse(!0),
  5901. e.cmd.select(),
  5902. e.addBookmark()
  5903. }
  5904. },
  5905. coldelete: function() {
  5906. for (var b = e.plugin.getSelectedTable()[0], c = e.plugin.getSelectedRow()[0], d = e.plugin.getSelectedCell()[0], f = d.cellIndex, g = 0, h = b.rows.length; h > g; g++) {
  5907. var i = b.rows[g],
  5908. j = i.cells[f];
  5909. j.colSpan > 1 ? (j.colSpan -= 1, 1 === j.colSpan && a(j).removeAttr("colSpan")) : i.deleteCell(f),
  5910. j.rowSpan > 1 && (g += j.rowSpan - 1)
  5911. }
  5912. 0 === c.cells.length ? (e.cmd.range.setStartBefore(b).collapse(!0), e.cmd.select(), a(b).remove()) : e.cmd.selection(!0),
  5913. e.addBookmark()
  5914. },
  5915. rowdelete: function() {
  5916. for (var b = e.plugin.getSelectedTable()[0], c = e.plugin.getSelectedRow()[0], d = e.plugin.getSelectedCell()[0], f = c.rowIndex, g = d.rowSpan - 1; g >= 0; g--) b.deleteRow(f + g);
  5917. 0 === b.rows.length ? (e.cmd.range.setStartBefore(b).collapse(!0), e.cmd.select(), a(b).remove()) : e.cmd.selection(!0),
  5918. e.addBookmark()
  5919. }
  5920. },
  5921. e.clickToolbar(f, e.plugin.table.prop)
  5922. }),
  5923. KindEditor.plugin("template",
  5924. function(a) {
  5925. function b(b) {
  5926. return e + b + "?ver=" + encodeURIComponent(a.DEBUG ? a.TIME: a.VERSION)
  5927. }
  5928. var c = this,
  5929. d = "template",
  5930. e = (c.lang(d + "."), c.pluginsPath + d + "/html/");
  5931. c.clickToolbar(d,
  5932. function() {
  5933. var e = c.lang(d + "."),
  5934. f = ['<div style="padding:10px 20px;">', '<div class="ke-header">', '<div class="ke-left">', e.selectTemplate + " <select>"];
  5935. a.each(e.fileList,
  5936. function(a, b) {
  5937. f.push('<option value="' + a + '">' + b + "</option>")
  5938. }),
  5939. html = [f.join(""), "</select></div>", '<div class="ke-right">', '<input type="checkbox" id="keReplaceFlag" name="replaceFlag" value="1" /> <label for="keReplaceFlag">' + e.replaceContent + "</label>", "</div>", '<div class="ke-clearfix"></div>', "</div>", '<iframe class="ke-textarea" frameborder="0" style="width:458px;height:260px;background-color:#FFF;"></iframe>', "</div>"].join("");
  5940. var g = c.createDialog({
  5941. name: d,
  5942. width: 500,
  5943. title: c.lang(d),
  5944. body: html,
  5945. yesBtn: {
  5946. name: c.lang("yes"),
  5947. click: function() {
  5948. var b = a.iframeDoc(j);
  5949. c[i[0].checked ? "html": "insertHtml"](b.body.innerHTML).hideDialog().focus()
  5950. }
  5951. }
  5952. }),
  5953. h = a("select", g.div),
  5954. i = a('[name="replaceFlag"]', g.div),
  5955. j = a("iframe", g.div);
  5956. i[0].checked = !0,
  5957. j.attr("src", b(h.val())),
  5958. h.change(function() {
  5959. j.attr("src", b(this.value))
  5960. })
  5961. })
  5962. }),
  5963. KindEditor.plugin("wordpaste",
  5964. function(a) {
  5965. var b = this,
  5966. c = "wordpaste";
  5967. b.clickToolbar(c,
  5968. function() {
  5969. var d = b.lang(c + "."),
  5970. e = '<div style="padding:10px 20px;"><div style="margin-bottom:10px;">' + d.comment + '</div><iframe class="ke-textarea" frameborder="0" style="width:408px;height:260px;"></iframe></div>',
  5971. f = b.createDialog({
  5972. name: c,
  5973. width: 450,
  5974. title: b.lang(c),
  5975. body: e,
  5976. yesBtn: {
  5977. name: b.lang("yes"),
  5978. click: function() {
  5979. var c = i.body.innerHTML;
  5980. c = a.clearMsWord(c, b.filterMode ? b.htmlTags: a.options.htmlTags),
  5981. b.insertHtml(c).hideDialog().focus()
  5982. }
  5983. }
  5984. }),
  5985. g = f.div,
  5986. h = a("iframe", g),
  5987. i = a.iframeDoc(h);
  5988. a.IE || (i.designMode = "on"),
  5989. i.open(),
  5990. i.write("<!doctype html><html><head><title>WordPaste</title></head>"),
  5991. i.write('<body style="background-color:#FFF;font-size:12px;margin:2px;">'),
  5992. a.IE || i.write("<br />"),
  5993. i.write("</body></html>"),
  5994. i.close(),
  5995. a.IE && (i.body.contentEditable = "true"),
  5996. h[0].contentWindow.focus()
  5997. })
  5998. }),
  5999. KindEditor.plugin("fixtoolbar",
  6000. function(a) {
  6001. function b() {
  6002. var b = a(".ke-toolbar"),
  6003. c = b.pos().y;
  6004. a(window).bind("scroll",
  6005. function() {
  6006. "fixed" == b.css("position") ? document.body.scrollTop - c < 0 && (b.css("position", "static"), b.css("top", "auto")) : b.pos().y - document.body.scrollTop < 0 && (b.css("position", "fixed"), b.css("top", 0))
  6007. })
  6008. }
  6009. var c = this;
  6010. c.fixToolBar && (c.isCreated ? b() : c.afterCreate(b))
  6011. });