handler.js 245 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734
  1. import mobileinit from './mobile';
  2. import luckysheetConfigsetting from './luckysheetConfigsetting';
  3. import luckysheetFreezen from './freezen';
  4. import pivotTable from './pivotTable';
  5. import luckysheetDropCell from './dropCell';
  6. import luckysheetPostil from './postil';
  7. import imageCtrl from './imageCtrl';
  8. import hyperlinkCtrl from './hyperlinkCtrl';
  9. import dataVerificationCtrl from './dataVerificationCtrl';
  10. import menuButton from './menuButton';
  11. import conditionformat from './conditionformat';
  12. import alternateformat from './alternateformat';
  13. import ifFormulaGenerator from './ifFormulaGenerator';
  14. import sheetmanage from './sheetmanage';
  15. import server from './server';
  16. import {luckysheetupdateCell} from './updateCell';
  17. import { luckysheet_searcharray } from './sheetSearch';
  18. import luckysheetsizeauto from './resize';
  19. import {
  20. luckysheetMoveHighlightCell,
  21. } from './sheetMove';
  22. import { selectHightlightShow, selectIsOverlap, selectionCopyShow, luckysheet_count_show,selectHelpboxFill } from './select';
  23. import selection from './selection';
  24. import controlHistory from './controlHistory';
  25. import splitColumn from './splitColumn';
  26. import {hideMenuByCancel} from '../global/cursorPos';
  27. import { luckysheetdefaultstyle } from './constant';
  28. import {checkProtectionLockedRangeList,checkProtectionAllSelected,checkProtectionSelectLockedOrUnLockedCells,checkProtectionNotEnable,checkProtectionAuthorityNormal} from './protection';
  29. import { openCellFormatModel } from './cellFormat';
  30. import {
  31. replaceHtml,
  32. getObjType,
  33. chatatABC,
  34. ArrayUnique,
  35. showrightclickmenu,
  36. luckysheetactiveCell,
  37. luckysheetContainerFocus,
  38. $$
  39. } from '../utils/util';
  40. import { getSheetIndex, getRangetxt } from '../methods/get';
  41. import {
  42. rowLocation,
  43. colLocation,
  44. mouseposition
  45. } from '../global/location';
  46. import { rowlenByRange } from '../global/getRowlen';
  47. import { isRealNull, hasPartMC, isEditMode, checkIsAllowEdit } from '../global/validate';
  48. import { countfunc } from '../global/count';
  49. import browser from '../global/browser';
  50. import formula from '../global/formula';
  51. import { luckysheetextendtable } from '../global/extend';
  52. import luckysheetscrollevent from '../global/scroll';
  53. import {
  54. jfrefreshgrid,
  55. jfrefreshgrid_rhcw,
  56. luckysheetrefreshgrid,
  57. } from '../global/refresh';
  58. import { getdatabyselection, datagridgrowth } from '../global/getdata';
  59. import tooltip from '../global/tooltip';
  60. import editor from '../global/editor';
  61. import { genarate } from '../global/format';
  62. import method from '../global/method';
  63. import { getBorderInfoCompute } from '../global/border';
  64. import { luckysheetDrawMain } from '../global/draw';
  65. import locale from '../locale/locale';
  66. import Store from '../store';
  67. import { createLuckyChart, hideAllNeedRangeShow } from '../expendPlugins/chart/plugin'
  68. //, columeflowset, rowflowset
  69. export default function luckysheetHandler() {
  70. const os = browser.detectOS(), isMobile = browser.mobilecheck();
  71. //移动端
  72. if(isMobile){
  73. mobileinit();
  74. }
  75. if (!Date.now)
  76. Date.now = function() { return new Date().getTime(); };
  77. //requestAnimationFrame method
  78. (function() {
  79. 'use strict';
  80. var vendors = ['webkit', 'moz'];
  81. for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
  82. var vp = vendors[i];
  83. window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
  84. window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
  85. || window[vp+'CancelRequestAnimationFrame']);
  86. }
  87. if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
  88. || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
  89. var lastTime = 0;
  90. window.requestAnimationFrame = function(callback) {
  91. var now = Date.now();
  92. var nextTime = Math.max(lastTime + 16, now);
  93. return setTimeout(function() { callback(lastTime = nextTime); },
  94. nextTime - now);
  95. };
  96. window.cancelAnimationFrame = clearTimeout;
  97. }
  98. }());
  99. $("#luckysheet-sheet-container-c").mousewheel(function (event, delta) {
  100. let scrollNum = event.deltaFactor<40?1:(event.deltaFactor<80?2:3);
  101. let scrollLeft = $(this).scrollLeft();
  102. if(event.deltaY != 0){
  103. if(event.deltaY <0){
  104. scrollLeft = scrollLeft + 10*scrollNum;
  105. }
  106. else{
  107. scrollLeft = scrollLeft - 10*scrollNum;
  108. }
  109. }
  110. else if(event.deltaX != 0){
  111. if(event.deltaX >0){
  112. scrollLeft = scrollLeft + 10*scrollNum;
  113. }
  114. else{
  115. scrollLeft = scrollLeft - 10*scrollNum;
  116. }
  117. }
  118. $(this).scrollLeft(scrollLeft);
  119. event.preventDefault();
  120. });
  121. //滚动监听
  122. $("#luckysheet-cell-main").scroll(function () {
  123. })
  124. .mousewheel(function (event, delta) {
  125. event.preventDefault();
  126. });
  127. const _locale = locale();
  128. const locale_drag = _locale.drag;
  129. const locale_info = _locale.info;
  130. let prev, mousewheelArrayUniqueTimeout;
  131. $("#luckysheet-grid-window-1").mousewheel(function (event, delta) {
  132. let scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(),
  133. scrollTop = $("#luckysheet-scrollbar-y").scrollTop();
  134. let visibledatacolumn_c = Store.visibledatacolumn,
  135. visibledatarow_c = Store.visibledatarow;
  136. if (luckysheetFreezen.freezenhorizontaldata != null) {
  137. visibledatarow_c = luckysheetFreezen.freezenhorizontaldata[3];
  138. }
  139. if (luckysheetFreezen.freezenverticaldata != null) {
  140. visibledatacolumn_c = luckysheetFreezen.freezenverticaldata[3];
  141. }
  142. clearTimeout(mousewheelArrayUniqueTimeout);
  143. // if(Store.visibledatacolumn.length!=visibledatacolumn_c.length){
  144. if(Store.visibledatacolumn_unique!=null){
  145. visibledatacolumn_c = Store.visibledatacolumn_unique;
  146. }
  147. else{
  148. visibledatacolumn_c = ArrayUnique(visibledatacolumn_c);
  149. Store.visibledatacolumn_unique = visibledatacolumn_c;
  150. }
  151. // }
  152. // if(Store.visibledatarow.length!=visibledatarow_c.length){
  153. if(Store.visibledatarow_unique!=null){
  154. visibledatarow_c = Store.visibledatarow_unique;
  155. }
  156. else{
  157. visibledatarow_c = ArrayUnique(visibledatarow_c);
  158. Store.visibledatarow_unique = visibledatarow_c;
  159. }
  160. // }
  161. // visibledatacolumn_c = ArrayUnique(visibledatacolumn_c);
  162. // visibledatarow_c = ArrayUnique(visibledatarow_c);
  163. let col_st = luckysheet_searcharray(visibledatacolumn_c, scrollLeft);
  164. let row_st = luckysheet_searcharray(visibledatarow_c, scrollTop);
  165. if (luckysheetFreezen.freezenhorizontaldata != null) {
  166. row_st = luckysheet_searcharray(visibledatarow_c, scrollTop + luckysheetFreezen.freezenhorizontaldata[0]);
  167. }
  168. let colscroll = 0;
  169. let rowscroll = 0;
  170. let scrollNum = event.deltaFactor<40?1:(event.deltaFactor<80?2:3);
  171. //一次滚动三行或三列
  172. if(event.deltaY != 0){
  173. let row_ed,step=Math.round(scrollNum/Store.zoomRatio);
  174. step = step<1?1:step;
  175. if(event.deltaY < 0){
  176. row_ed = row_st + step;
  177. if(row_ed >= visibledatarow_c.length){
  178. row_ed = visibledatarow_c.length - 1;
  179. }
  180. }
  181. else{
  182. row_ed = row_st - step;
  183. if(row_ed < 0){
  184. row_ed = 0;
  185. }
  186. }
  187. rowscroll = row_ed == 0 ? 0 : visibledatarow_c[row_ed - 1];
  188. if (luckysheetFreezen.freezenhorizontaldata != null) {
  189. rowscroll -= luckysheetFreezen.freezenhorizontaldata[0];
  190. }
  191. $("#luckysheet-scrollbar-y").scrollTop(rowscroll);
  192. }
  193. else if(event.deltaX != 0){
  194. let col_ed;
  195. // if((isMac && event.deltaX >0 ) || (!isMac && event.deltaX < 0)){
  196. if(event.deltaX >0){
  197. scrollLeft = scrollLeft + 20*Store.zoomRatio;
  198. // if(col_ed >= visibledatacolumn_c.length){
  199. // col_ed = visibledatacolumn_c.length - 1;
  200. // }
  201. }
  202. else{
  203. scrollLeft = scrollLeft - 20*Store.zoomRatio;
  204. // if(col_ed < 0){
  205. // col_ed = 0;
  206. // }
  207. }
  208. // colscroll = col_ed == 0 ? 0 : visibledatacolumn_c[col_ed - 1];
  209. $("#luckysheet-scrollbar-x").scrollLeft(scrollLeft);
  210. }
  211. mousewheelArrayUniqueTimeout = setTimeout(() => {
  212. Store.visibledatacolumn_unique = null;
  213. Store.visibledatarow_unique = null;
  214. }, 500);
  215. });
  216. $("#luckysheet-scrollbar-x").scroll(function(){
  217. // setTimeout(function(){
  218. luckysheetscrollevent();
  219. // },10);
  220. })
  221. .mousewheel(function (event, delta) {
  222. event.preventDefault();
  223. });
  224. $("#luckysheet-scrollbar-y").scroll(function(){
  225. // setTimeout(function(){
  226. luckysheetscrollevent();
  227. // },10);
  228. })
  229. .mousewheel(function (event, delta) {
  230. event.preventDefault();
  231. });
  232. //页面resize
  233. $(window).resize(function () {
  234. let luckysheetDocument = document.getElementById(Store.container);
  235. if(luckysheetDocument){
  236. luckysheetsizeauto();
  237. }
  238. });
  239. $("#luckysheet-rich-text-editor").mouseup(function(e){
  240. menuButton.inputMenuButtonFocus(e.target);
  241. });
  242. //表格mousedown
  243. $("#luckysheet-cell-main, #luckysheetTableContent").mousedown(function (event) {
  244. if($(event.target).hasClass('luckysheet-mousedown-cancel')){
  245. return;
  246. }
  247. // 协同编辑其他用户不在操作的时候,用户名框隐藏
  248. hideUsername();
  249. $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
  250. .css("cursor","default")
  251. .end()
  252. .find(".luckysheet-cs-draghandle")
  253. .css("cursor","default");
  254. $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor","default");
  255. //有批注在编辑时
  256. luckysheetPostil.removeActivePs();
  257. //图片 active/cropping
  258. if($("#luckysheet-modal-dialog-activeImage").is(":visible") || $("#luckysheet-modal-dialog-cropping").is(":visible")){
  259. imageCtrl.cancelActiveImgItem();
  260. }
  261. //luckysheetautoadjustmousedown = 1;
  262. let mouse = mouseposition(event.pageX, event.pageY);
  263. if (mouse[0] >= Store.cellmainWidth - Store.cellMainSrollBarSize || mouse[1] >= Store.cellmainHeight - Store.cellMainSrollBarSize) {
  264. return;
  265. }
  266. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  267. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  268. if(luckysheetFreezen.freezenverticaldata != null && mouse[0] < (luckysheetFreezen.freezenverticaldata[0] - luckysheetFreezen.freezenverticaldata[2])){
  269. x = mouse[0] + luckysheetFreezen.freezenverticaldata[2];
  270. }
  271. if(luckysheetFreezen.freezenhorizontaldata != null && mouse[1] < (luckysheetFreezen.freezenhorizontaldata[0] - luckysheetFreezen.freezenhorizontaldata[2])){
  272. y = mouse[1] + luckysheetFreezen.freezenhorizontaldata[2];
  273. }
  274. let sheetFile = sheetmanage.getSheetByIndex();
  275. let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
  276. let row_location = rowLocation(y),
  277. row = row_location[1],
  278. row_pre = row_location[0],
  279. row_index = row_location[2];
  280. let col_location = colLocation(x),
  281. col = col_location[1],
  282. col_pre = col_location[0],
  283. col_index = col_location[2];
  284. let row_index_ed = row_index, col_index_ed = col_index;
  285. let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
  286. if (!!margeset) {
  287. row = margeset.row[1];
  288. row_pre = margeset.row[0];
  289. row_index = margeset.row[2];
  290. row_index_ed = margeset.row[3];
  291. col = margeset.column[1];
  292. col_pre = margeset.column[0];
  293. col_index = margeset.column[2];
  294. col_index_ed = margeset.column[3];
  295. }
  296. //单元格单击之前
  297. if(!method.createHookFunction("cellMousedownBefore", Store.flowdata[row_index][col_index], {
  298. r:row_index,
  299. c:col_index,
  300. "start_r": row_pre,
  301. "start_c": col_pre,
  302. "end_r": row,
  303. "end_c": col
  304. }, sheetFile,luckysheetTableContent)){ return; }
  305. //数据验证 单元格聚焦
  306. dataVerificationCtrl.cellFocus(row_index, col_index, true);
  307. //若点击单元格部分不在视图内
  308. if (col_pre < $("#luckysheet-cell-main").scrollLeft()) {
  309. $("#luckysheet-scrollbar-x").scrollLeft(col_pre);
  310. }
  311. if (row_pre < $("#luckysheet-cell-main").scrollTop()) {
  312. $("#luckysheet-scrollbar-y").scrollTop(row_pre);
  313. }
  314. //mousedown是右键
  315. if (event.which == "3") {
  316. $("#luckysheet-dataVerification-showHintBox").hide();
  317. let isright = false;
  318. for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
  319. if (Store.luckysheet_select_save[s]["row"] != null && (row_index >= Store.luckysheet_select_save[s]["row"][0] && row_index <= Store.luckysheet_select_save[s]["row"][1] && col_index >= Store.luckysheet_select_save[s]["column"][0] && col_index <= Store.luckysheet_select_save[s]["column"][1])) {
  320. isright = true;
  321. break;
  322. }
  323. }
  324. if (isright) {
  325. return;
  326. }
  327. }
  328. //单元格数据下钻
  329. if (Store.flowdata[row_index] != null && Store.flowdata[row_index][col_index] != null && Store.flowdata[row_index][col_index].dd != null) {
  330. if (luckysheetConfigsetting.fireMousedown != null && getObjType(luckysheetConfigsetting.fireMousedown) == "function") {
  331. luckysheetConfigsetting.fireMousedown(Store.flowdata[row_index][col_index].dd);
  332. return;
  333. }
  334. }
  335. //链接 单元格聚焦
  336. if(hyperlinkCtrl.hyperlink && hyperlinkCtrl.hyperlink[row_index + "_" + col_index] && event.which != "3"){
  337. hyperlinkCtrl.cellFocus(row_index, col_index);
  338. return;
  339. }
  340. Store.luckysheet_scroll_status = true;
  341. //公式相关
  342. let $input = $("#luckysheet-input-box");
  343. if (parseInt($input.css("top")) > 0) {
  344. if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()) {
  345. //公式选区
  346. let rowseleted = [row_index, row_index_ed];
  347. let columnseleted = [col_index, col_index_ed];
  348. let left = col_pre;
  349. let width = col - col_pre - 1;
  350. let top = row_pre;
  351. let height = row - row_pre - 1;
  352. if (event.shiftKey) {
  353. let last = formula.func_selectedrange;
  354. let top = 0, height = 0, rowseleted = [];
  355. if (last.top > row_pre) {
  356. top = row_pre;
  357. height = last.top + last.height - row_pre;
  358. if (last.row[1] > last.row_focus) {
  359. last.row[1] = last.row_focus;
  360. }
  361. rowseleted = [row_index, last.row[1]];
  362. }
  363. else if (last.top == row_pre) {
  364. top = row_pre;
  365. height = last.top + last.height - row_pre;
  366. rowseleted = [row_index, last.row[0]];
  367. }
  368. else {
  369. top = last.top;
  370. height = row - last.top - 1;
  371. if (last.row[0] < last.row_focus) {
  372. last.row[0] = last.row_focus;
  373. }
  374. rowseleted = [last.row[0], row_index];
  375. }
  376. let left = 0, width = 0, columnseleted = [];
  377. if (last.left > col_pre) {
  378. left = col_pre;
  379. width = last.left + last.width - col_pre;
  380. if (last.column[1] > last.column_focus) {
  381. last.column[1] = last.column_focus;
  382. }
  383. columnseleted = [col_index, last.column[1]];
  384. }
  385. else if (last.left == col_pre) {
  386. left = col_pre;
  387. width = last.left + last.width - col_pre;
  388. columnseleted = [col_index, last.column[0]];
  389. }
  390. else {
  391. left = last.left;
  392. width = col - last.left - 1;
  393. if (last.column[0] < last.column_focus) {
  394. last.column[0] = last.column_focus;
  395. }
  396. columnseleted = [last.column[0], col_index];
  397. }
  398. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  399. if (changeparam != null) {
  400. columnseleted = changeparam[0];
  401. rowseleted = changeparam[1];
  402. top = changeparam[2];
  403. height = changeparam[3];
  404. left = changeparam[4];
  405. width = changeparam[5];
  406. }
  407. luckysheet_count_show(left, top, width, height, rowseleted, columnseleted);
  408. last["row"] = rowseleted;
  409. last["column"] = columnseleted;
  410. last["left_move"] = left;
  411. last["width_move"] = width;
  412. last["top_move"] = top;
  413. last["height_move"] = height;
  414. formula.func_selectedrange = last;
  415. }
  416. else if (event.ctrlKey && $("#luckysheet-rich-text-editor").find("span").last().text() != ",") {
  417. //按住ctrl 选择选区时 先处理上一个选区
  418. let vText = $("#luckysheet-rich-text-editor").text();
  419. if(vText[vText.length -1 ] === ")"){
  420. vText = vText.substr(0,vText.length - 1); //先删除最后侧的圆括号)
  421. }
  422. if(vText.length > 0){
  423. let lastWord = vText.substr(vText.length-1,1);
  424. if(lastWord!="," && lastWord!="=" && lastWord!="("){
  425. vText += ",";
  426. }
  427. }
  428. if (vText.length > 0 && vText.substr(0, 1) == "=") {
  429. vText = formula.functionHTMLGenerate(vText);
  430. if (window.getSelection) { // all browsers, except IE before version 9
  431. let currSelection = window.getSelection();
  432. formula.functionRangeIndex = [$(currSelection.anchorNode).parent().index(), currSelection.anchorOffset];
  433. }
  434. else { // Internet Explorer before version 9
  435. let textRange = document.selection.createRange();
  436. formula.functionRangeIndex = textRange;
  437. }
  438. /* 在显示前重新 + 右侧的圆括号) */
  439. $("#luckysheet-rich-text-editor").html(vText + ")");
  440. formula.canceFunctionrangeSelected();
  441. formula.createRangeHightlight();
  442. }
  443. formula.rangestart = false;
  444. formula.rangedrag_column_start = false;
  445. formula.rangedrag_row_start = false;
  446. $("#luckysheet-functionbox-cell").html(vText + ")");
  447. formula.rangeHightlightselected($("#luckysheet-rich-text-editor"));
  448. //再进行 选区的选择
  449. formula.israngeseleciton();
  450. formula.func_selectedrange = {
  451. "left": left,
  452. "width": width,
  453. "top": top,
  454. "height": height,
  455. "left_move": left,
  456. "width_move": width,
  457. "top_move": top,
  458. "height_move": height,
  459. "row": rowseleted,
  460. "column": columnseleted,
  461. "row_focus": row_index,
  462. "column_focus": col_index
  463. };
  464. }
  465. else {
  466. formula.func_selectedrange = {
  467. "left": left,
  468. "width": width,
  469. "top": top,
  470. "height": height,
  471. "left_move": left,
  472. "width_move": width,
  473. "top_move": top,
  474. "height_move": height,
  475. "row": rowseleted,
  476. "column": columnseleted,
  477. "row_focus": row_index,
  478. "column_focus": col_index
  479. };
  480. }
  481. formula.rangeSetValue({ "row": rowseleted, "column": columnseleted });
  482. formula.rangestart = true;
  483. formula.rangedrag_column_start = false;
  484. formula.rangedrag_row_start = false;
  485. $("#luckysheet-formula-functionrange-select").css({
  486. "left": left,
  487. "width": width,
  488. "top": top,
  489. "height": height
  490. }).show();
  491. $("#luckysheet-formula-help-c").hide();
  492. luckysheet_count_show(left, top, width, height, rowseleted, columnseleted);
  493. setTimeout(function () {
  494. let currSelection = window.getSelection();
  495. let anchorOffset = currSelection.anchorNode;
  496. let $editor;
  497. if ($("#luckysheet-search-formula-parm").is(":visible") || $("#luckysheet-search-formula-parm-select").is(":visible")) {
  498. $editor = $("#luckysheet-rich-text-editor");
  499. formula.rangechangeindex = formula.data_parm_index;
  500. }
  501. else {
  502. $editor = $(anchorOffset).closest("div");
  503. }
  504. let $span = $editor.find("span[rangeindex='" + formula.rangechangeindex + "']");
  505. formula.setCaretPosition($span.get(0), 0, $span.html().length);
  506. }, 1);
  507. return;
  508. }
  509. else {
  510. formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
  511. Store.luckysheet_select_status = true;
  512. if ($("#luckysheet-info").is(":visible")) {
  513. Store.luckysheet_select_status = false;
  514. }
  515. }
  516. }
  517. else {
  518. if(checkProtectionSelectLockedOrUnLockedCells(row_index, col_index, Store.currentSheetIndex)){
  519. Store.luckysheet_select_status = true;
  520. }
  521. }
  522. //条件格式 应用范围可选择多个单元格
  523. if ($("#luckysheet-multiRange-dialog").is(":visible")) {
  524. conditionformat.selectStatus = true;
  525. Store.luckysheet_select_status = false;
  526. if (event.shiftKey) {
  527. let last = conditionformat.selectRange[conditionformat.selectRange.length - 1];
  528. let top = 0, height = 0, rowseleted = [];
  529. if (last.top > row_pre) {
  530. top = row_pre;
  531. height = last.top + last.height - row_pre;
  532. if (last.row[1] > last.row_focus) {
  533. last.row[1] = last.row_focus;
  534. }
  535. rowseleted = [row_index, last.row[1]];
  536. }
  537. else if (last.top == row_pre) {
  538. top = row_pre;
  539. height = last.top + last.height - row_pre;
  540. rowseleted = [row_index, last.row[0]];
  541. }
  542. else {
  543. top = last.top;
  544. height = row - last.top - 1;
  545. if (last.row[0] < last.row_focus) {
  546. last.row[0] = last.row_focus;
  547. }
  548. rowseleted = [last.row[0], row_index];
  549. }
  550. let left = 0, width = 0, columnseleted = [];
  551. if (last.left > col_pre) {
  552. left = col_pre;
  553. width = last.left + last.width - col_pre;
  554. if (last.column[1] > last.column_focus) {
  555. last.column[1] = last.column_focus;
  556. }
  557. columnseleted = [col_index, last.column[1]];
  558. }
  559. else if (last.left == col_pre) {
  560. left = col_pre;
  561. width = last.left + last.width - col_pre;
  562. columnseleted = [col_index, last.column[0]];
  563. }
  564. else {
  565. left = last.left;
  566. width = col - last.left - 1;
  567. if (last.column[0] < last.column_focus) {
  568. last.column[0] = last.column_focus;
  569. }
  570. columnseleted = [last.column[0], col_index];
  571. }
  572. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  573. if (changeparam != null) {
  574. columnseleted = changeparam[0];
  575. rowseleted = changeparam[1];
  576. top = changeparam[2];
  577. height = changeparam[3];
  578. left = changeparam[4];
  579. width = changeparam[5];
  580. }
  581. last["row"] = rowseleted;
  582. last["column"] = columnseleted;
  583. last["left_move"] = left;
  584. last["width_move"] = width;
  585. last["top_move"] = top;
  586. last["height_move"] = height;
  587. conditionformat.selectRange[conditionformat.selectRange.length - 1] = last;
  588. }
  589. else if (event.ctrlKey) {
  590. conditionformat.selectRange.push({
  591. "left": col_pre,
  592. "width": col - col_pre - 1,
  593. "top": row_pre,
  594. "height": row - row_pre - 1,
  595. "left_move": col_pre,
  596. "width_move": col - col_pre - 1,
  597. "top_move": row_pre,
  598. "height_move": row - row_pre - 1,
  599. "row": [row_index, row_index_ed],
  600. "column": [col_index, col_index_ed],
  601. "row_focus": row_index,
  602. "column_focus": col_index
  603. });
  604. }
  605. else {
  606. conditionformat.selectRange = [];
  607. conditionformat.selectRange.push({
  608. "left": col_pre,
  609. "width": col - col_pre - 1,
  610. "top": row_pre,
  611. "height": row - row_pre - 1,
  612. "left_move": col_pre,
  613. "width_move": col - col_pre - 1,
  614. "top_move": row_pre,
  615. "height_move": row - row_pre - 1,
  616. "row": [row_index, row_index_ed],
  617. "column": [col_index, col_index_ed],
  618. "row_focus": row_index,
  619. "column_focus": col_index
  620. });
  621. }
  622. selectionCopyShow(conditionformat.selectRange);
  623. let range = conditionformat.getTxtByRange(conditionformat.selectRange);
  624. $("#luckysheet-multiRange-dialog input").val(range);
  625. return;
  626. }
  627. else {
  628. conditionformat.selectStatus = false;
  629. conditionformat.selectRange = [];
  630. }
  631. //条件格式 条件值只能选择单个单元格
  632. if ($("#luckysheet-singleRange-dialog").is(":visible")) {
  633. Store.luckysheet_select_status = false;
  634. selectionCopyShow([{ "row": [row_index, row_index], "column": [col_index, col_index] }]);
  635. let range = getRangetxt(
  636. Store.currentSheetIndex,
  637. { "row": [row_index, row_index], "column": [col_index, col_index] },
  638. Store.currentSheetIndex
  639. );
  640. $("#luckysheet-singleRange-dialog input").val(range);
  641. return;
  642. }
  643. //数据验证 单元格范围选择
  644. if($("#luckysheet-dataVerificationRange-dialog").is(":visible")){
  645. dataVerificationCtrl.selectStatus = true;
  646. Store.luckysheet_select_status = false;
  647. if (event.shiftKey) {
  648. let last = dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1];
  649. let top = 0, height = 0, rowseleted = [];
  650. if (last.top > row_pre) {
  651. top = row_pre;
  652. height = last.top + last.height - row_pre;
  653. if (last.row[1] > last.row_focus) {
  654. last.row[1] = last.row_focus;
  655. }
  656. rowseleted = [row_index, last.row[1]];
  657. }
  658. else if (last.top == row_pre) {
  659. top = row_pre;
  660. height = last.top + last.height - row_pre;
  661. rowseleted = [row_index, last.row[0]];
  662. }
  663. else {
  664. top = last.top;
  665. height = row - last.top - 1;
  666. if (last.row[0] < last.row_focus) {
  667. last.row[0] = last.row_focus;
  668. }
  669. rowseleted = [last.row[0], row_index];
  670. }
  671. let left = 0, width = 0, columnseleted = [];
  672. if (last.left > col_pre) {
  673. left = col_pre;
  674. width = last.left + last.width - col_pre;
  675. if (last.column[1] > last.column_focus) {
  676. last.column[1] = last.column_focus;
  677. }
  678. columnseleted = [col_index, last.column[1]];
  679. }
  680. else if (last.left == col_pre) {
  681. left = col_pre;
  682. width = last.left + last.width - col_pre;
  683. columnseleted = [col_index, last.column[0]];
  684. }
  685. else {
  686. left = last.left;
  687. width = col - last.left - 1;
  688. if (last.column[0] < last.column_focus) {
  689. last.column[0] = last.column_focus;
  690. }
  691. columnseleted = [last.column[0], col_index];
  692. }
  693. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  694. if (changeparam != null) {
  695. columnseleted = changeparam[0];
  696. rowseleted = changeparam[1];
  697. top = changeparam[2];
  698. height = changeparam[3];
  699. left = changeparam[4];
  700. width = changeparam[5];
  701. }
  702. last["row"] = rowseleted;
  703. last["column"] = columnseleted;
  704. last["left_move"] = left;
  705. last["width_move"] = width;
  706. last["top_move"] = top;
  707. last["height_move"] = height;
  708. dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1] = last;
  709. }
  710. else {
  711. dataVerificationCtrl.selectRange = [];
  712. dataVerificationCtrl.selectRange.push({
  713. "left": col_pre,
  714. "width": col - col_pre - 1,
  715. "top": row_pre,
  716. "height": row - row_pre - 1,
  717. "left_move": col_pre,
  718. "width_move": col - col_pre - 1,
  719. "top_move": row_pre,
  720. "height_move": row - row_pre - 1,
  721. "row": [row_index, row_index_ed],
  722. "column": [col_index, col_index_ed],
  723. "row_focus": row_index,
  724. "column_focus": col_index
  725. });
  726. }
  727. selectionCopyShow(dataVerificationCtrl.selectRange);
  728. let range = dataVerificationCtrl.getTxtByRange(dataVerificationCtrl.selectRange);
  729. if(formula.rangetosheet != Store.currentSheetIndex){
  730. range = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].name + '!' + range;
  731. }
  732. $("#luckysheet-dataVerificationRange-dialog input").val(range);
  733. return;
  734. }
  735. else{
  736. dataVerificationCtrl.selectStatus = false;
  737. dataVerificationCtrl.selectRange = [];
  738. }
  739. //if公式生成器
  740. if (ifFormulaGenerator.singleRangeFocus) {
  741. $("#luckysheet-ifFormulaGenerator-dialog .singRange").click();
  742. }
  743. if ($("#luckysheet-ifFormulaGenerator-singleRange-dialog").is(":visible")) {
  744. //选择单个单元格
  745. Store.luckysheet_select_status = false;
  746. formula.rangestart = false;
  747. $("#luckysheet-formula-functionrange-select").css({
  748. "left": col_pre,
  749. "width": col - col_pre - 1,
  750. "top": row_pre,
  751. "height": row - row_pre - 1
  752. }).show();
  753. $("#luckysheet-formula-help-c").hide();
  754. let range = getRangetxt(
  755. Store.currentSheetIndex,
  756. { "row": [row_index, row_index], "column": [col_index, col_index] },
  757. Store.currentSheetIndex
  758. );
  759. $("#luckysheet-ifFormulaGenerator-singleRange-dialog input").val(range);
  760. return;
  761. }
  762. if ($("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")) {
  763. //选择范围
  764. Store.luckysheet_select_status = false;
  765. formula.func_selectedrange = {
  766. "left": col_pre,
  767. "width": col - col_pre - 1,
  768. "top": row_pre,
  769. "height": row - row_pre - 1,
  770. "left_move": col_pre,
  771. "width_move": col - col_pre - 1,
  772. "top_move": row_pre,
  773. "height_move": row - row_pre - 1,
  774. "row": [row_index, row_index],
  775. "column": [col_index, col_index],
  776. "row_focus": row_index,
  777. "column_focus": col_index
  778. };
  779. formula.rangestart = true;
  780. $("#luckysheet-formula-functionrange-select").css({
  781. "left": col_pre,
  782. "width": col - col_pre - 1,
  783. "top": row_pre,
  784. "height": row - row_pre - 1
  785. }).show();
  786. $("#luckysheet-formula-help-c").hide();
  787. let range = getRangetxt(
  788. Store.currentSheetIndex,
  789. { "row": [row_index, row_index], "column": [col_index, col_index] },
  790. Store.currentSheetIndex
  791. );
  792. $("#luckysheet-ifFormulaGenerator-multiRange-dialog input").val(range);
  793. $("#luckysheet-row-count-show").hide();
  794. $("#luckysheet-column-count-show").hide();
  795. return;
  796. }
  797. if (Store.luckysheet_select_status) {
  798. if (event.shiftKey) {
  799. //按住shift点击,选择范围
  800. let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); //选区最后一个
  801. let top = 0, height = 0, rowseleted = [];
  802. if (last.top > row_pre) {
  803. top = row_pre;
  804. height = last.top + last.height - row_pre;
  805. if (last.row[1] > last.row_focus) {
  806. last.row[1] = last.row_focus;
  807. }
  808. rowseleted = [row_index, last.row[1]];
  809. }
  810. else if (last.top == row_pre) {
  811. top = row_pre;
  812. height = last.top + last.height - row_pre;
  813. rowseleted = [row_index, last.row[0]];
  814. }
  815. else {
  816. top = last.top;
  817. height = row - last.top - 1;
  818. if (last.row[0] < last.row_focus) {
  819. last.row[0] = last.row_focus;
  820. }
  821. rowseleted = [last.row[0], row_index];
  822. }
  823. let left = 0, width = 0, columnseleted = [];
  824. if (last.left > col_pre) {
  825. left = col_pre;
  826. width = last.left + last.width - col_pre;
  827. if (last.column[1] > last.column_focus) {
  828. last.column[1] = last.column_focus;
  829. }
  830. columnseleted = [col_index, last.column[1]];
  831. }
  832. else if (last.left == col_pre) {
  833. left = col_pre;
  834. width = last.left + last.width - col_pre;
  835. columnseleted = [col_index, last.column[0]];
  836. }
  837. else {
  838. left = last.left;
  839. width = col - last.left - 1;
  840. if (last.column[0] < last.column_focus) {
  841. last.column[0] = last.column_focus;
  842. }
  843. columnseleted = [last.column[0], col_index];
  844. }
  845. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  846. if (changeparam != null) {
  847. columnseleted = changeparam[0];
  848. rowseleted = changeparam[1];
  849. top = changeparam[2];
  850. height = changeparam[3];
  851. left = changeparam[4];
  852. width = changeparam[5];
  853. }
  854. last["row"] = rowseleted;
  855. last["column"] = columnseleted;
  856. last["left_move"] = left;
  857. last["width_move"] = width;
  858. last["top_move"] = top;
  859. last["height_move"] = height;
  860. Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
  861. //交替颜色选择范围
  862. if ($("#luckysheet-alternateformat-rangeDialog").is(":visible")) {
  863. $("#luckysheet-alternateformat-rangeDialog input").val(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save));
  864. }
  865. if (pivotTable.luckysheet_pivotTable_select_state) {
  866. $("#luckysheet-pivotTable-range-selection-input").val(Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].name + "!" + chatatABC(Store.luckysheet_select_save[0]["column"][0]) + (Store.luckysheet_select_save[0]["row"][0] + 1) + ":" + chatatABC(Store.luckysheet_select_save[0]["column"][1]) + (Store.luckysheet_select_save[0]["row"][1] + 1));
  867. }
  868. }
  869. else if (event.ctrlKey) {
  870. //选区添加
  871. Store.luckysheet_select_save.push({
  872. "left": col_pre,
  873. "width": col - col_pre - 1,
  874. "top": row_pre,
  875. "height": row - row_pre - 1,
  876. "left_move": col_pre,
  877. "width_move": col - col_pre - 1,
  878. "top_move": row_pre,
  879. "height_move": row - row_pre - 1,
  880. "row": [row_index, row_index_ed],
  881. "column": [col_index, col_index_ed],
  882. "row_focus": row_index,
  883. "column_focus": col_index
  884. });
  885. }
  886. else {
  887. Store.luckysheet_select_save.length = 0;
  888. Store.luckysheet_select_save.push({
  889. "left": col_pre,
  890. "width": col - col_pre - 1,
  891. "top": row_pre,
  892. "height": row - row_pre - 1,
  893. "left_move": col_pre,
  894. "width_move": col - col_pre - 1,
  895. "top_move": row_pre,
  896. "height_move": row - row_pre - 1,
  897. "row": [row_index, row_index_ed],
  898. "column": [col_index, col_index_ed],
  899. "row_focus": row_index,
  900. "column_focus": col_index
  901. });
  902. //单元格格式icon对应
  903. menuButton.menuButtonFocus(Store.flowdata, row_index, col_index);
  904. //函数公式显示栏
  905. formula.fucntionboxshow(row_index, col_index);
  906. }
  907. selectHightlightShow();
  908. if (luckysheetFreezen.freezenhorizontaldata != null || luckysheetFreezen.freezenverticaldata != null) {
  909. luckysheetFreezen.scrollAdaptOfselect();
  910. }
  911. if (!browser.mobilecheck()) { //非移动端聚焦输入框
  912. luckysheetactiveCell();
  913. }
  914. //允许编辑后的后台更新时
  915. server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
  916. }
  917. //交替颜色
  918. if (alternateformat.rangefocus) {
  919. alternateformat.rangefocus = false;
  920. $("#luckysheet-alternateformat-range .fa-table").click();
  921. }
  922. $("#luckysheet-row-count-show, #luckysheet-column-count-show").hide();
  923. if (!isEditMode()) {
  924. //chartMix 隐藏当前页的数据选择区域高亮
  925. hideAllNeedRangeShow();
  926. }
  927. // selectHelpboxFill();
  928. //数据透视表
  929. pivotTable.pivotclick(row_index, col_index, Store.currentSheetIndex);
  930. luckysheetContainerFocus();
  931. method.createHookFunction("cellMousedown", Store.flowdata[row_index][col_index], {
  932. r:row_index,
  933. c:col_index,
  934. "start_r": row_pre,
  935. "start_c": col_pre,
  936. "end_r": row,
  937. "end_c": col
  938. }, sheetFile,luckysheetTableContent);
  939. //$("#luckysheet-cols-h-c .luckysheet-cols-h-cells-c .luckysheet-cols-h-cells-clip .luckysheet-cols-h-cell-sel").removeClass("luckysheet-cols-h-cell-sel").addClass("luckysheet-cols-h-cell-nosel");
  940. //$("#luckysheet-rows-h .luckysheet-rows-h-cells .luckysheet-rows-h-cells-c .luckysheet-rows-h-cells-clip .luckysheet-rows-h-cell-sel").removeClass("luckysheet-rows-h-cell-sel").addClass("luckysheet-rows-h-cell-nosel");
  941. //$("#luckysheet-cols-h-c .luckysheet-cols-h-cells-c .luckysheet-cols-h-cells-clip .luckysheet-cols-h-cell-nosel").eq(col_index).removeClass("luckysheet-cols-h-cell-nosel").addClass("luckysheet-cols-h-cell-sel");
  942. //$("#luckysheet-rows-h .luckysheet-rows-h-cells .luckysheet-rows-h-cells-c .luckysheet-rows-h-cells-clip .luckysheet-rows-h-cell-nosel").eq(row_index).removeClass("luckysheet-rows-h-cell-nosel").addClass("luckysheet-rows-h-cell-sel");
  943. //event.stopImmediatePropagation();
  944. }).mouseup(function (event) {
  945. if (event.which == "3") {
  946. //禁止前台编辑(只可 框选单元格、滚动查看表格)
  947. if (!Store.allowEdit) {
  948. return;
  949. }
  950. if (isEditMode()) { //非编辑模式下禁止右键功能框
  951. return;
  952. }
  953. let x = event.pageX;
  954. let y = event.pageY;
  955. let data = Store.flowdata;
  956. let obj_s = Store.luckysheet_select_save[0];
  957. const cellRightClickConfig = luckysheetConfigsetting.cellRightClickConfig;
  958. $("#luckysheet-cols-rows-data").show();
  959. $("#luckysheet-cols-rows-handleincell").show();
  960. $("#luckysheet-cols-rows-add, #luckysheet-cols-rows-shift").hide();
  961. $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'block';
  962. $$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'block';
  963. if (obj_s["row"] != null && obj_s["row"][0] == 0 && obj_s["row"][1] == Store.flowdata.length - 1) {
  964. // 如果全部按钮都隐藏,则整个菜单容器也要隐藏
  965. if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth && !cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
  966. return;
  967. }
  968. Store.luckysheetRightHeadClickIs = "column";
  969. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column);
  970. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.width);
  971. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.left);
  972. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right);
  973. $("#luckysheet-cols-rows-add").show();
  974. // $("#luckysheet-cols-rows-data").show();
  975. $("#luckysheet-cols-rows-shift").hide();
  976. $("#luckysheet-cols-rows-handleincell").hide();
  977. Store.luckysheet_cols_menu_status = true;
  978. $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'block';
  979. // 自定义右键菜单:向左向右增加列,删除列,隐藏显示列,设置列宽
  980. $$('#luckysheet-top-left-add-selected').style.display = cellRightClickConfig.insertColumn ? 'block' : 'none';
  981. $$('#luckysheet-bottom-right-add-selected').style.display = cellRightClickConfig.insertColumn ? 'block' : 'none';
  982. $$('#luckysheet-del-selected').style.display = cellRightClickConfig.deleteColumn ? 'block' : 'none';
  983. $$('#luckysheet-hide-selected').style.display = cellRightClickConfig.hideColumn ? 'block' : 'none';
  984. $$('#luckysheet-show-selected').style.display = cellRightClickConfig.hideColumn ? 'block' : 'none';
  985. $$('#luckysheet-column-row-width-selected').style.display = cellRightClickConfig.columnWidth ? 'block' : 'none';
  986. // 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
  987. if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
  988. $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
  989. if(!cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth){
  990. $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
  991. }
  992. }
  993. // 2.当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
  994. if(!cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth){
  995. $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
  996. }
  997. //列宽默认值
  998. let cfg = $.extend(true, {}, Store.config);
  999. if (cfg["columnlen"] == null) {
  1000. cfg["columnlen"] = {};
  1001. }
  1002. let first_collen = cfg["columnlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columnlen"][Store.luckysheet_select_save[0].column[0]];
  1003. let isSame = true;
  1004. for (let i = 0; i < Store.luckysheet_select_save.length; i++) {
  1005. let s = Store.luckysheet_select_save[i];
  1006. let c1 = s.column[0], c2 = s.column[1];
  1007. for (let c = c1; c <= c2; c++) {
  1008. let collen = cfg["columnlen"][c] == null ? Store.defaultcollen : cfg["columnlen"][c];
  1009. if (collen != first_collen) {
  1010. isSame = false;
  1011. break;
  1012. }
  1013. }
  1014. }
  1015. if (isSame) {
  1016. $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_collen);
  1017. }
  1018. else {
  1019. $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val("");
  1020. }
  1021. }
  1022. else if (obj_s["column"] != null && obj_s["column"][0] == 0 && obj_s["column"][1] == Store.flowdata[0].length - 1) {
  1023. // 如果全部按钮都隐藏,则整个菜单容器也要隐藏
  1024. if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight && !cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
  1025. return;
  1026. }
  1027. Store.luckysheetRightHeadClickIs = "row";
  1028. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.row);
  1029. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.height);
  1030. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.top);
  1031. $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.bottom);
  1032. $("#luckysheet-cols-rows-add").show();
  1033. // $("#luckysheet-cols-rows-data").show();
  1034. $("#luckysheet-cols-rows-shift").hide();
  1035. $("#luckysheet-cols-rows-handleincell").hide();
  1036. Store.luckysheet_cols_menu_status = true;
  1037. $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'block';
  1038. // 自定义右键菜单:向上向下增加行,删除行,隐藏显示行,设置行高
  1039. $$('#luckysheet-top-left-add-selected').style.display = cellRightClickConfig.insertRow ? 'block' : 'none';
  1040. $$('#luckysheet-bottom-right-add-selected').style.display = cellRightClickConfig.insertRow ? 'block' : 'none';
  1041. $$('#luckysheet-del-selected').style.display = cellRightClickConfig.deleteRow ? 'block' : 'none';
  1042. $$('#luckysheet-hide-selected').style.display = cellRightClickConfig.hideRow ? 'block' : 'none';
  1043. $$('#luckysheet-show-selected').style.display = cellRightClickConfig.hideRow ? 'block' : 'none';
  1044. $$('#luckysheet-column-row-width-selected').style.display = cellRightClickConfig.rowHeight ? 'block' : 'none';
  1045. // 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
  1046. if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
  1047. $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
  1048. if(!cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight){
  1049. $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
  1050. }
  1051. }
  1052. // 2. 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
  1053. if(!cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight){
  1054. $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
  1055. }
  1056. //行高默认值
  1057. let cfg = $.extend(true, {}, Store.config);
  1058. if (cfg["rowlen"] == null) {
  1059. cfg["rowlen"] = {};
  1060. }
  1061. let first_rowlen = cfg["rowlen"][Store.luckysheet_select_save[0].row[0]] == null ? Store.defaultrowlen : cfg["rowlen"][Store.luckysheet_select_save[0].row[0]];
  1062. let isSame = true;
  1063. for (let i = 0; i < Store.luckysheet_select_save.length; i++) {
  1064. let s = Store.luckysheet_select_save[i];
  1065. let r1 = s.row[0], r2 = s.row[1];
  1066. for (let r = r1; r <= r2; r++) {
  1067. let rowlen = cfg["rowlen"][r] == null ? Store.defaultrowlen : cfg["rowlen"][r];
  1068. if (rowlen != first_rowlen) {
  1069. isSame = false;
  1070. break;
  1071. }
  1072. }
  1073. }
  1074. if (isSame) {
  1075. $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_rowlen);
  1076. }
  1077. else {
  1078. $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val("");
  1079. }
  1080. }else{
  1081. // 如果全部按钮都隐藏,则整个菜单容器也要隐藏
  1082. if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste && !cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell && !cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
  1083. return;
  1084. }
  1085. // 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
  1086. if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
  1087. $$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'none';
  1088. if(!cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell){
  1089. $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
  1090. }
  1091. }
  1092. if(!cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell){
  1093. $$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'none';
  1094. }
  1095. }
  1096. // 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
  1097. if(!cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
  1098. $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
  1099. }
  1100. showrightclickmenu($("#luckysheet-rightclick-menu"), x, y);
  1101. }
  1102. // 备注:在mousedown中发送光标信息会漏处理部分(选区)范围
  1103. server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
  1104. }).dblclick(function (event) {
  1105. if($(event.target).hasClass('luckysheet-mousedown-cancel')){
  1106. return;
  1107. }
  1108. //禁止前台编辑(只可 框选单元格、滚动查看表格)
  1109. if (!Store.allowEdit) {
  1110. return;
  1111. }
  1112. if (parseInt($("#luckysheet-input-box").css("top")) > 0) {
  1113. return;
  1114. }
  1115. let mouse = mouseposition(event.pageX, event.pageY);
  1116. if (mouse[0] >= Store.cellmainWidth - Store.cellMainSrollBarSize || mouse[1] >= Store.cellmainHeight - Store.cellMainSrollBarSize) {
  1117. return;
  1118. }
  1119. let scrollLeft = $("#luckysheet-cell-main").scrollLeft(),
  1120. scrollTop = $("#luckysheet-cell-main").scrollTop();
  1121. let x = mouse[0] + scrollLeft;
  1122. let y = mouse[1] + scrollTop;
  1123. if(luckysheetFreezen.freezenverticaldata != null && mouse[0] < (luckysheetFreezen.freezenverticaldata[0] - luckysheetFreezen.freezenverticaldata[2])){
  1124. x = mouse[0] + luckysheetFreezen.freezenverticaldata[2];
  1125. }
  1126. if(luckysheetFreezen.freezenhorizontaldata != null && mouse[1] < (luckysheetFreezen.freezenhorizontaldata[0] - luckysheetFreezen.freezenhorizontaldata[2])){
  1127. y = mouse[1] + luckysheetFreezen.freezenhorizontaldata[2];
  1128. }
  1129. let row_location = rowLocation(y),
  1130. row_index = row_location[2];
  1131. let col_location = colLocation(x),
  1132. col_index = col_location[2];
  1133. let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
  1134. if (!!margeset) {
  1135. row_index = margeset.row[2];
  1136. col_index = margeset.column[2];
  1137. }
  1138. if (pivotTable.isPivotRange(row_index, col_index)) {
  1139. //数据透视表没有 任何数据
  1140. if ((pivotTable.filter == null || pivotTable.filter.length == 0) && (pivotTable.row == null || pivotTable.row.length == 0) && (pivotTable.column == null || pivotTable.column.length == 0) && (pivotTable.values == null || pivotTable.values.length == 0)) {
  1141. return;
  1142. }
  1143. //数据透视表没有 数值数据
  1144. if (pivotTable.values == null || pivotTable.values.length == 0) {
  1145. return;
  1146. }
  1147. //点击位置不是 数值数据 所在区域
  1148. if (row_index == 0 || col_index == 0) {
  1149. return;
  1150. }
  1151. if (pivotTable.column != null && pivotTable.column.length > 0) {
  1152. if (pivotTable.values.length >= 2 && pivotTable.showType == "column") {
  1153. if (row_index <= pivotTable.column.length || col_index >= pivotTable.pivotDatas[0].length - pivotTable.values.length) {
  1154. return;
  1155. }
  1156. }
  1157. else {
  1158. if (row_index <= pivotTable.column.length - 1 || col_index >= pivotTable.pivotDatas[0].length - 1) {
  1159. return;
  1160. }
  1161. }
  1162. }
  1163. if (pivotTable.row != null && pivotTable.row.length > 0) {
  1164. if (pivotTable.values.length >= 2 && pivotTable.showType == "row") {
  1165. if (col_index <= pivotTable.row.length || row_index >= pivotTable.pivotDatas.length - pivotTable.values.length) {
  1166. return;
  1167. }
  1168. }
  1169. else {
  1170. if (col_index <= pivotTable.row.length - 1 || row_index >= pivotTable.pivotDatas.length - 1) {
  1171. return;
  1172. }
  1173. }
  1174. }
  1175. sheetmanage.addNewSheet(event);
  1176. pivotTable.drillDown(row_index, col_index);
  1177. return;
  1178. }
  1179. if ($("#luckysheet-search-formula-parm").is(":visible") || $("#luckysheet-search-formula-parm-select").is(":visible")) {
  1180. //公式参数栏显示
  1181. $("#luckysheet-cell-selected").hide();
  1182. }
  1183. else if ($("#luckysheet-conditionformat-dialog").is(":visible") || $("#luckysheet-administerRule-dialog").is(":visible") || $("#luckysheet-newConditionRule-dialog").is(":visible") || $("#luckysheet-editorConditionRule-dialog").is(":visible") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) {
  1184. //条件格式
  1185. return;
  1186. }
  1187. else if ($("#luckysheet-modal-dialog-slider-alternateformat").is(":visible") || $("#luckysheet-alternateformat-rangeDialog").is(":visible")) {
  1188. //交替颜色
  1189. return;
  1190. }
  1191. else {
  1192. if (menuButton.luckysheetPaintModelOn) {
  1193. menuButton.cancelPaintModel();
  1194. }
  1195. // 检查当前坐标和焦点坐标是否一致,如果不一致那么进行修正
  1196. let column_focus = Store.luckysheet_select_save[0]["column_focus"];
  1197. let row_focus = Store.luckysheet_select_save[0]["row_focus"];
  1198. if(column_focus !== col_index || row_focus !== row_index){
  1199. row_index = row_focus;
  1200. col_index = column_focus;
  1201. };
  1202. luckysheetupdateCell(row_index, col_index, Store.flowdata);
  1203. /* 设置选区高亮 */
  1204. selectHightlightShow();
  1205. }
  1206. });
  1207. //监听拖拽
  1208. document.getElementById('luckysheet-cell-main').addEventListener('drop', function(e){
  1209. e.preventDefault();
  1210. e.stopPropagation();
  1211. let files = e.dataTransfer.files;
  1212. //拖拽插入图片
  1213. if(files.length == 1 && files[0].type.indexOf('image') > -1){
  1214. if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
  1215. return;
  1216. }
  1217. imageCtrl.insertImg(files[0]);
  1218. }
  1219. handleCellDragStopEvent(e);
  1220. }, false);
  1221. document.getElementById('luckysheet-cell-main').addEventListener('dragover', function(e){
  1222. e.preventDefault();
  1223. e.stopPropagation();
  1224. }, false);
  1225. /**
  1226. * 处理单元格上鼠标拖拽停止事件
  1227. * @param {DragEvent} event
  1228. */
  1229. function handleCellDragStopEvent(event) {
  1230. if (luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.cellDragStop) {
  1231. let mouse = mouseposition(event.pageX, event.pageY);
  1232. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  1233. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  1234. let row_location = rowLocation(y),
  1235. row = row_location[1],
  1236. row_pre = row_location[0],
  1237. row_index = row_location[2];
  1238. let col_location = colLocation(x),
  1239. col = col_location[1],
  1240. col_pre = col_location[0],
  1241. col_index = col_location[2];
  1242. let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
  1243. if (!!margeset) {
  1244. row = margeset.row[1];
  1245. row_pre = margeset.row[0];
  1246. row_index = margeset.row[2];
  1247. col = margeset.column[1];
  1248. col_pre = margeset.column[0];
  1249. col_index = margeset.column[2];
  1250. }
  1251. let sheetFile = sheetmanage.getSheetByIndex();
  1252. let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
  1253. method.createHookFunction("cellDragStop", Store.flowdata[row_index][col_index], {
  1254. r: row_index,
  1255. c: col_index,
  1256. "start_r": row_pre,
  1257. "start_c": col_pre,
  1258. "end_r": row,
  1259. "end_c": col
  1260. }, sheetFile, luckysheetTableContent, event);
  1261. }
  1262. }
  1263. //表格mousemove
  1264. $(document).on("mousemove.luckysheetEvent",function (event) {
  1265. luckysheetPostil.overshow(event); //有批注显示
  1266. hyperlinkCtrl.overshow(event); //链接提示显示
  1267. window.cancelAnimationFrame(Store.jfautoscrollTimeout);
  1268. if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMousemove){
  1269. let mouse = mouseposition(event.pageX, event.pageY);
  1270. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  1271. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  1272. let row_location = rowLocation(y),
  1273. row = row_location[1],
  1274. row_pre = row_location[0],
  1275. row_index = row_location[2];
  1276. let col_location = colLocation(x),
  1277. col = col_location[1],
  1278. col_pre = col_location[0],
  1279. col_index = col_location[2];
  1280. let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
  1281. if (!!margeset) {
  1282. row = margeset.row[1];
  1283. row_pre = margeset.row[0];
  1284. row_index = margeset.row[2];
  1285. col = margeset.column[1];
  1286. col_pre = margeset.column[0];
  1287. col_index = margeset.column[2];
  1288. }
  1289. // if(Store.flowdata[row_index] && Store.flowdata[row_index][col_index]){
  1290. let sheetFile = sheetmanage.getSheetByIndex();
  1291. let moveState = {
  1292. functionResizeStatus:formula.functionResizeStatus,
  1293. horizontalmoveState:!!luckysheetFreezen.horizontalmovestate,
  1294. verticalmoveState:!!luckysheetFreezen.verticalmovestate,
  1295. pivotTableMoveState:!!pivotTable && pivotTable.movestate,
  1296. sheetMoveStatus:Store.luckysheet_sheet_move_status,
  1297. scrollStatus:!!Store.luckysheet_scroll_status,
  1298. selectStatus:!!Store.luckysheet_select_status,
  1299. rowsSelectedStatus:!!Store.luckysheet_rows_selected_status,
  1300. colsSelectedStatus:!!Store.luckysheet_cols_selected_status,
  1301. cellSelectedMove:!!Store.luckysheet_cell_selected_move,
  1302. cellSelectedExtend:!!Store.luckysheet_cell_selected_extend,
  1303. colsChangeSize:!!Store.luckysheet_cols_change_size,
  1304. rowsChangeSize:!!Store.luckysheet_rows_change_size,
  1305. chartMove:!!Store.chartparam.luckysheetCurrentChartMove,
  1306. chartResize:!!Store.chartparam.luckysheetCurrentChartResize,
  1307. rangeResize:!!formula.rangeResize ,
  1308. rangeMove:!!formula.rangeMove,
  1309. }
  1310. let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
  1311. if(Store.flowdata && Store.flowdata[row_index]){
  1312. method.createHookFunction("sheetMousemove", Store.flowdata[row_index][col_index], {
  1313. r:row_index,
  1314. c:col_index,
  1315. "start_r": row_pre,
  1316. "start_c": col_pre,
  1317. "end_r": row,
  1318. "end_c": col
  1319. }, sheetFile,moveState,luckysheetTableContent);
  1320. }
  1321. // }
  1322. }
  1323. if(formula.functionResizeStatus){
  1324. let y = event.pageY;
  1325. let movepx = y - formula.functionResizeData.y;
  1326. let mpx = formula.functionResizeData.calculatebarHeight + movepx;
  1327. let winh = Math.round($(window).height() / 2);
  1328. if (mpx <= 28) {
  1329. if (mpx <= 20) {
  1330. return;
  1331. }
  1332. mpx = 28;
  1333. }
  1334. else if (mpx >= winh) {
  1335. if (mpx >= winh + 8) {
  1336. return;
  1337. }
  1338. mpx = winh;
  1339. }
  1340. Store.calculatebarHeight = mpx;
  1341. $("#luckysheet-wa-calculate").css("height", Store.calculatebarHeight - 2);
  1342. $("#luckysheet-wa-calculate-size").css({ "background": "#5e5e5e", "cursor": "ns-resize" });
  1343. clearTimeout(formula.functionResizeTimeout);
  1344. formula.functionResizeTimeout = setTimeout(function () {
  1345. luckysheetsizeauto();
  1346. }, 15);
  1347. }
  1348. else if (!!luckysheetFreezen.horizontalmovestate) {
  1349. let mouse = mouseposition(event.pageX, event.pageY);
  1350. let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  1351. let scrollTop = $("#luckysheet-cell-main").scrollTop();
  1352. let x = mouse[0] + scrollLeft;
  1353. let y = mouse[1] + scrollTop;
  1354. let row_location = rowLocation(y),
  1355. row = row_location[1],
  1356. row_pre = row_location[0],
  1357. row_index = row_location[2];
  1358. let top = mouse[1] + Store.columnHeaderHeight;
  1359. if (top < Store.columnHeaderHeight) {
  1360. top = Store.columnHeaderHeight;
  1361. }
  1362. if (top > luckysheetFreezen.windowHeight - 4) {
  1363. top = luckysheetFreezen.windowHeight - 4;
  1364. }
  1365. $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css({ "top": top });
  1366. if (top + scrollTop - Store.columnHeaderHeight >= row_pre + (row - row_pre) / 2) {
  1367. top = row - 2 - scrollTop + Store.columnHeaderHeight;
  1368. luckysheetFreezen.freezenhorizontaldata = [row, row_index + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_index + 1), top];
  1369. }
  1370. else {
  1371. top = row_pre - 2 - scrollTop + Store.columnHeaderHeight;
  1372. luckysheetFreezen.freezenhorizontaldata = [row_pre, row_index, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_index), top];
  1373. }
  1374. $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-drop").css({ "top": top });
  1375. luckysheetFreezen.saveFreezen(luckysheetFreezen.freezenhorizontaldata, top, null, null);
  1376. }
  1377. else if (!!luckysheetFreezen.verticalmovestate) {
  1378. let mouse = mouseposition(event.pageX, event.pageY);
  1379. let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  1380. let scrollTop = $("#luckysheet-cell-main").scrollTop();
  1381. let x = mouse[0] + scrollLeft;
  1382. let y = mouse[1] + scrollTop;
  1383. let col_location = colLocation(x),
  1384. col = col_location[1],
  1385. col_pre = col_location[0],
  1386. col_index = col_location[2];
  1387. let left = mouse[0] + Store.rowHeaderWidth;
  1388. if (left < Store.rowHeaderWidth) {
  1389. left = Store.rowHeaderWidth;
  1390. }
  1391. if (left > luckysheetFreezen.windowWidth - 4) {
  1392. left = luckysheetFreezen.windowWidth - 4;
  1393. }
  1394. $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css({ "left": left });
  1395. if (left + scrollLeft - Store.rowHeaderWidth >= col_pre + (col - col_pre) / 2) {
  1396. left = col - 2 - scrollLeft + Store.rowHeaderWidth;
  1397. luckysheetFreezen.freezenverticaldata = [col, col_index + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_index + 1), left];
  1398. }
  1399. else {
  1400. left = col_pre - 2 - scrollLeft + Store.rowHeaderWidth;
  1401. luckysheetFreezen.freezenverticaldata = [col_pre, col_index, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_index), left];
  1402. }
  1403. $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-drop").css({ "left": left });
  1404. luckysheetFreezen.saveFreezen(null, null, luckysheetFreezen.freezenverticaldata, left);
  1405. luckysheetsizeauto();//调节选区时下部单元格溢出
  1406. }
  1407. else if (!!pivotTable && pivotTable.movestate) {
  1408. let x = event.pageX, y = event.pageY;
  1409. $("#luckysheet-modal-dialog-slider-pivot-move").css({
  1410. "left": x - pivotTable.movesave.width / 2,
  1411. "top": y - pivotTable.movesave.height
  1412. });
  1413. }
  1414. else if (Store.luckysheet_sheet_move_status) {
  1415. let scrollLeft = $("#luckysheet-sheet-container-c").scrollLeft();
  1416. let x = event.pageX + scrollLeft;
  1417. if (Math.abs(event.pageX - Store.luckysheet_sheet_move_data.pageX) < 3) {
  1418. return;
  1419. }
  1420. let winW = $("#luckysheet-sheet-container").width();
  1421. let left = x - Store.luckysheet_sheet_move_data.curleft - $("#luckysheet-sheet-container").offset().left;
  1422. Store.luckysheet_sheet_move_data.activeobject.css({ "left": left });
  1423. let row_index = luckysheet_searcharray(Store.luckysheet_sheet_move_data.widthlist, left + Store.luckysheet_sheet_move_data.curleft);
  1424. Store.luckysheet_sheet_move_data.cursorobject.css({ "cursor": "move" });
  1425. if (left - scrollLeft <= 6) {
  1426. $("#luckysheet-sheets-leftscroll").click();
  1427. }
  1428. if (left - scrollLeft >= winW - 40) {
  1429. $("#luckysheet-sheets-rightscroll").click();
  1430. }
  1431. if (row_index != Store.luckysheet_sheet_move_data.curindex) {
  1432. if (row_index == -1 && left > 0) {
  1433. row_index = Store.luckysheet_sheet_move_data.widthlist.length - 1;
  1434. $("#luckysheet-sheets-item-clone").insertAfter($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").eq(row_index));
  1435. }
  1436. else if (row_index == -1 && left <= 0) {
  1437. $("#luckysheet-sheets-item-clone").insertBefore($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").eq(0));
  1438. }
  1439. else {
  1440. $("#luckysheet-sheets-item-clone").insertAfter($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").eq(row_index));
  1441. }
  1442. Store.luckysheet_sheet_move_data.widthlist = [];
  1443. $("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").each(function (i) {
  1444. if (i == 0) {
  1445. Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()));
  1446. }
  1447. else {
  1448. Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()) + Store.luckysheet_sheet_move_data.widthlist[i - 1]);
  1449. }
  1450. });
  1451. Store.luckysheet_sheet_move_data.curindex = $("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").index($("#luckysheet-sheets-item-clone"));
  1452. }
  1453. }
  1454. else if (Store.luckysheet_model_move_state) {
  1455. let scrollTop = $(document).scrollTop(), scrollLeft = $(document).scrollLeft();
  1456. let y = event.pageY + scrollTop, x = event.pageX + scrollLeft;
  1457. let winH = $(window).height(), winW = $(window).width();
  1458. let myh = Store.luckysheet_model_move_obj.height(),
  1459. myw = Store.luckysheet_model_move_obj.width();
  1460. let top = y - Store.luckysheet_model_xy[1],
  1461. left = x - Store.luckysheet_model_xy[0];
  1462. if (top < 0) {
  1463. top = 0;
  1464. }
  1465. if (top + myh + 62 > winH) {
  1466. top = winH - myh - 62;
  1467. }
  1468. if (left < 0) {
  1469. left = 0;
  1470. }
  1471. if (left + myw + 86 > winW) {
  1472. left = winW - myw - 86;
  1473. }
  1474. Store.luckysheet_model_move_obj.css({ "top": top, "left": left });
  1475. event.preventDefault();
  1476. }
  1477. else if (!!Store.luckysheet_scroll_status || !!Store.luckysheet_select_status || !!Store.luckysheet_rows_selected_status || !!Store.luckysheet_cols_selected_status || !!Store.luckysheet_cell_selected_move || !!Store.luckysheet_cell_selected_extend || !!Store.luckysheet_cols_change_size || !!Store.luckysheet_rows_change_size || !!Store.chartparam.luckysheetCurrentChartMove || !!Store.chartparam.luckysheetCurrentChartResize || !!formula.rangeResize || !!formula.rangeMove) {
  1478. if (Store.luckysheet_select_status) {
  1479. clearTimeout(Store.countfuncTimeout);
  1480. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  1481. }
  1482. function mouseRender() {
  1483. if (Store.luckysheet_scroll_status && !Store.luckysheet_cols_change_size && !Store.luckysheet_rows_change_size) {
  1484. let mouse = mouseposition(event.pageX, event.pageY);
  1485. let left = $("#luckysheet-scrollbar-x").scrollLeft(),
  1486. top = $("#luckysheet-scrollbar-y").scrollTop();
  1487. let x = mouse[0];
  1488. let y = mouse[1];
  1489. let winH = $("#luckysheet-cell-main").height() - 20*Store.zoomRatio,
  1490. winW = $("#luckysheet-cell-main").width() - 60*Store.zoomRatio;
  1491. if (y < 0 || y > winH) {
  1492. let stop;
  1493. if (y < 0) {
  1494. stop = top + y / 2;
  1495. }
  1496. else {
  1497. stop = top + (y - winH) / 2;
  1498. }
  1499. $("#luckysheet-scrollbar-y").scrollTop(stop);
  1500. }
  1501. if (x < 0 || x > winW) {
  1502. let sleft;
  1503. if (x < 0) {
  1504. sleft = left + x / 2;
  1505. }
  1506. else {
  1507. sleft = left + (x - winW) / 2;
  1508. }
  1509. $("#luckysheet-scrollbar-x").scrollLeft(sleft);
  1510. }
  1511. }
  1512. if (Store.luckysheet_select_status) {
  1513. let mouse = mouseposition(event.pageX, event.pageY);
  1514. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  1515. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  1516. let row_location = rowLocation(y),
  1517. row = row_location[1],
  1518. row_pre = row_location[0],
  1519. row_index = row_location[2];
  1520. let col_location = colLocation(x),
  1521. col = col_location[1],
  1522. col_pre = col_location[0],
  1523. col_index = col_location[2];
  1524. if(!checkProtectionSelectLockedOrUnLockedCells(row_index, col_index, Store.currentSheetIndex)){
  1525. // Store.luckysheet_select_status = false;
  1526. return;
  1527. }
  1528. let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]);
  1529. let top = 0, height = 0, rowseleted = [];
  1530. if (last.top > row_pre) {
  1531. top = row_pre;
  1532. height = last.top + last.height - row_pre;
  1533. if (last.row[1] > last.row_focus) {
  1534. last.row[1] = last.row_focus;
  1535. }
  1536. rowseleted = [row_index, last.row[1]];
  1537. }
  1538. else if (last.top == row_pre) {
  1539. top = row_pre;
  1540. height = last.top + last.height - row_pre;
  1541. rowseleted = [row_index, last.row[0]];
  1542. }
  1543. else {
  1544. top = last.top;
  1545. height = row - last.top - 1;
  1546. if (last.row[0] < last.row_focus) {
  1547. last.row[0] = last.row_focus;
  1548. }
  1549. rowseleted = [last.row[0], row_index];
  1550. }
  1551. let left = 0, width = 0, columnseleted = [];
  1552. if (last.left > col_pre) {
  1553. left = col_pre;
  1554. width = last.left + last.width - col_pre;
  1555. if (last.column[1] > last.column_focus) {
  1556. last.column[1] = last.column_focus;
  1557. }
  1558. columnseleted = [col_index, last.column[1]];
  1559. }
  1560. else if (last.left == col_pre) {
  1561. left = col_pre;
  1562. width = last.left + last.width - col_pre;
  1563. columnseleted = [col_index, last.column[0]];
  1564. }
  1565. else {
  1566. left = last.left;
  1567. width = col - last.left - 1;
  1568. if (last.column[0] < last.column_focus) {
  1569. last.column[0] = last.column_focus;
  1570. }
  1571. columnseleted = [last.column[0], col_index];
  1572. }
  1573. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  1574. if (changeparam != null) {
  1575. columnseleted = changeparam[0];
  1576. rowseleted = changeparam[1];
  1577. top = changeparam[2];
  1578. height = changeparam[3];
  1579. left = changeparam[4];
  1580. width = changeparam[5];
  1581. }
  1582. last["row"] = rowseleted;
  1583. last["column"] = columnseleted;
  1584. last["left_move"] = left;
  1585. last["width_move"] = width;
  1586. last["top_move"] = top;
  1587. last["height_move"] = height;
  1588. Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
  1589. selectHightlightShow();
  1590. luckysheetFreezen.scrollFreezen();
  1591. // selectHelpboxFill();
  1592. //交替颜色选择范围
  1593. if ($("#luckysheet-alternateformat-rangeDialog").is(":visible")) {
  1594. $("#luckysheet-alternateformat-rangeDialog input").val(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]));
  1595. }
  1596. if (pivotTable.luckysheet_pivotTable_select_state) {
  1597. $("#luckysheet-pivotTable-range-selection-input").val(Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].name + "!" + chatatABC(Store.luckysheet_select_save[0]["column"][0]) + (Store.luckysheet_select_save[0]["row"][0] + 1) + ":" + chatatABC(Store.luckysheet_select_save[0]["column"][1]) + (Store.luckysheet_select_save[0]["row"][1] + 1));
  1598. }
  1599. }
  1600. else if (conditionformat.selectStatus) {
  1601. let mouse = mouseposition(event.pageX, event.pageY);
  1602. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  1603. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  1604. let row_location = rowLocation(y),
  1605. row = row_location[1],
  1606. row_pre = row_location[0],
  1607. row_index = row_location[2];
  1608. let col_location = colLocation(x),
  1609. col = col_location[1],
  1610. col_pre = col_location[0],
  1611. col_index = col_location[2];
  1612. let last = conditionformat.selectRange[conditionformat.selectRange.length - 1];
  1613. let top = 0, height = 0, rowseleted = [];
  1614. if (last.top > row_pre) {
  1615. top = row_pre;
  1616. height = last.top + last.height - row_pre;
  1617. if (last.row[1] > last.row_focus) {
  1618. last.row[1] = last.row_focus;
  1619. }
  1620. rowseleted = [row_index, last.row[1]];
  1621. }
  1622. else if (last.top == row_pre) {
  1623. top = row_pre;
  1624. height = last.top + last.height - row_pre;
  1625. rowseleted = [row_index, last.row[0]];
  1626. }
  1627. else {
  1628. top = last.top;
  1629. height = row - last.top - 1;
  1630. if (last.row[0] < last.row_focus) {
  1631. last.row[0] = last.row_focus;
  1632. }
  1633. rowseleted = [last.row[0], row_index];
  1634. }
  1635. let left = 0, width = 0, columnseleted = [];
  1636. if (last.left > col_pre) {
  1637. left = col_pre;
  1638. width = last.left + last.width - col_pre;
  1639. if (last.column[1] > last.column_focus) {
  1640. last.column[1] = last.column_focus;
  1641. }
  1642. columnseleted = [col_index, last.column[1]];
  1643. }
  1644. else if (last.left == col_pre) {
  1645. left = col_pre;
  1646. width = last.left + last.width - col_pre;
  1647. columnseleted = [col_index, last.column[0]];
  1648. }
  1649. else {
  1650. left = last.left;
  1651. width = col - last.left - 1;
  1652. if (last.column[0] < last.column_focus) {
  1653. last.column[0] = last.column_focus;
  1654. }
  1655. columnseleted = [last.column[0], col_index];
  1656. }
  1657. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  1658. if (changeparam != null) {
  1659. columnseleted = changeparam[0];
  1660. rowseleted = changeparam[1];
  1661. top = changeparam[2];
  1662. height = changeparam[3];
  1663. left = changeparam[4];
  1664. width = changeparam[5];
  1665. }
  1666. last["row"] = rowseleted;
  1667. last["column"] = columnseleted;
  1668. last["left_move"] = left;
  1669. last["width_move"] = width;
  1670. last["top_move"] = top;
  1671. last["height_move"] = height;
  1672. conditionformat.selectRange[conditionformat.selectRange.length - 1] = last;
  1673. selectionCopyShow(conditionformat.selectRange);
  1674. let range = conditionformat.getTxtByRange(conditionformat.selectRange);
  1675. $("#luckysheet-multiRange-dialog input").val(range);
  1676. }
  1677. else if (dataVerificationCtrl.selectStatus) {
  1678. let mouse = mouseposition(event.pageX, event.pageY);
  1679. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  1680. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  1681. let row_location = rowLocation(y),
  1682. row = row_location[1],
  1683. row_pre = row_location[0],
  1684. row_index = row_location[2];
  1685. let col_location = colLocation(x),
  1686. col = col_location[1],
  1687. col_pre = col_location[0],
  1688. col_index = col_location[2];
  1689. let last = dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1];
  1690. let top = 0, height = 0, rowseleted = [];
  1691. if (last.top > row_pre) {
  1692. top = row_pre;
  1693. height = last.top + last.height - row_pre;
  1694. if (last.row[1] > last.row_focus) {
  1695. last.row[1] = last.row_focus;
  1696. }
  1697. rowseleted = [row_index, last.row[1]];
  1698. }
  1699. else if (last.top == row_pre) {
  1700. top = row_pre;
  1701. height = last.top + last.height - row_pre;
  1702. rowseleted = [row_index, last.row[0]];
  1703. }
  1704. else {
  1705. top = last.top;
  1706. height = row - last.top - 1;
  1707. if (last.row[0] < last.row_focus) {
  1708. last.row[0] = last.row_focus;
  1709. }
  1710. rowseleted = [last.row[0], row_index];
  1711. }
  1712. let left = 0, width = 0, columnseleted = [];
  1713. if (last.left > col_pre) {
  1714. left = col_pre;
  1715. width = last.left + last.width - col_pre;
  1716. if (last.column[1] > last.column_focus) {
  1717. last.column[1] = last.column_focus;
  1718. }
  1719. columnseleted = [col_index, last.column[1]];
  1720. }
  1721. else if (last.left == col_pre) {
  1722. left = col_pre;
  1723. width = last.left + last.width - col_pre;
  1724. columnseleted = [col_index, last.column[0]];
  1725. }
  1726. else {
  1727. left = last.left;
  1728. width = col - last.left - 1;
  1729. if (last.column[0] < last.column_focus) {
  1730. last.column[0] = last.column_focus;
  1731. }
  1732. columnseleted = [last.column[0], col_index];
  1733. }
  1734. let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
  1735. if (changeparam != null) {
  1736. columnseleted = changeparam[0];
  1737. rowseleted = changeparam[1];
  1738. top = changeparam[2];
  1739. height = changeparam[3];
  1740. left = changeparam[4];
  1741. width = changeparam[5];
  1742. }
  1743. last["row"] = rowseleted;
  1744. last["column"] = columnseleted;
  1745. last["left_move"] = left;
  1746. last["width_move"] = width;
  1747. last["top_move"] = top;
  1748. last["height_move"] = height;
  1749. dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1] = last;
  1750. selectionCopyShow(dataVerificationCtrl.selectRange);
  1751. let range = dataVerificationCtrl.getTxtByRange(dataVerificationCtrl.selectRange);
  1752. if(formula.rangetosheet != Store.currentSheetIndex){
  1753. range = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].name + '!' + range;
  1754. }
  1755. $("#luckysheet-dataVerificationRange-dialog input").val(range);
  1756. }
  1757. else if (formula.rangestart) {
  1758. formula.rangedrag(event);
  1759. }
  1760. else if (formula.rangedrag_row_start) {
  1761. formula.rangedrag_row(event);
  1762. }
  1763. else if (formula.rangedrag_column_start) {
  1764. formula.rangedrag_column(event);
  1765. }
  1766. else if (Store.luckysheet_rows_selected_status) {
  1767. let mouse = mouseposition(event.pageX, event.pageY);
  1768. let y = mouse[1] + $("#luckysheet-rows-h").scrollTop();
  1769. if (y < 0) {
  1770. return false;
  1771. }
  1772. let row_location = rowLocation(y),
  1773. row = row_location[1],
  1774. row_pre = row_location[0],
  1775. row_index = row_location[2];
  1776. let col_index = Store.visibledatacolumn.length - 1,
  1777. col = Store.visibledatacolumn[col_index],
  1778. col_pre = 0;
  1779. let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]);
  1780. let top = 0, height = 0, rowseleted = [];
  1781. if (last.top > row_pre) {
  1782. top = row_pre;
  1783. height = last.top + last.height - row_pre;
  1784. if (last.row[1] > last.row_focus) {
  1785. last.row[1] = last.row_focus;
  1786. }
  1787. rowseleted = [row_index, last.row[1]];
  1788. }
  1789. else if (last.top == row_pre) {
  1790. top = row_pre;
  1791. height = last.top + last.height - row_pre;
  1792. rowseleted = [row_index, last.row[0]];
  1793. }
  1794. else {
  1795. top = last.top;
  1796. height = row - last.top - 1;
  1797. if (last.row[0] < last.row_focus) {
  1798. last.row[0] = last.row_focus;
  1799. }
  1800. rowseleted = [last.row[0], row_index];
  1801. }
  1802. last["row"] = rowseleted;
  1803. last["top_move"] = top;
  1804. last["height_move"] = height;
  1805. Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
  1806. selectHightlightShow();
  1807. clearTimeout(Store.countfuncTimeout);
  1808. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  1809. }
  1810. else if (Store.luckysheet_cols_selected_status) {
  1811. let mouse = mouseposition(event.pageX, event.pageY);
  1812. let x = mouse[0] + $("#luckysheet-cols-h-c").scrollLeft();
  1813. if (x < 0) {
  1814. return false;
  1815. }
  1816. let row_index = Store.visibledatarow.length - 1,
  1817. row = Store.visibledatarow[row_index],
  1818. row_pre = 0;
  1819. let col_location = colLocation(x),
  1820. col = col_location[1],
  1821. col_pre = col_location[0],
  1822. col_index = col_location[2];
  1823. let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]);
  1824. let left = 0, width = 0, columnseleted = [];
  1825. if (last.left > col_pre) {
  1826. left = col_pre;
  1827. width = last.left + last.width - col_pre;
  1828. if (last.column[1] > last.column_focus) {
  1829. last.column[1] = last.column_focus;
  1830. }
  1831. columnseleted = [col_index, last.column[1]];
  1832. }
  1833. else if (last.left == col_pre) {
  1834. left = col_pre;
  1835. width = last.left + last.width - col_pre;
  1836. columnseleted = [col_index, last.column[0]];
  1837. }
  1838. else {
  1839. left = last.left;
  1840. width = col - last.left - 1;
  1841. if (last.column[0] < last.column_focus) {
  1842. last.column[0] = last.column_focus;
  1843. }
  1844. columnseleted = [last.column[0], col_index];
  1845. }
  1846. last["column"] = columnseleted;
  1847. last["left_move"] = left;
  1848. last["width_move"] = width;
  1849. Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
  1850. selectHightlightShow();
  1851. clearTimeout(Store.countfuncTimeout);
  1852. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  1853. }
  1854. else if (Store.luckysheet_cell_selected_move) {
  1855. let mouse = mouseposition(event.pageX, event.pageY);
  1856. let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  1857. let scrollTop = $("#luckysheet-cell-main").scrollTop();
  1858. let x = mouse[0] + scrollLeft;
  1859. let y = mouse[1] + scrollTop;
  1860. let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
  1861. winW = $(window).width() + scrollLeft;
  1862. let row_location = rowLocation(y),
  1863. row = row_location[1],
  1864. row_pre = row_location[0],
  1865. row_index = row_location[2];
  1866. let col_location = colLocation(x),
  1867. col = col_location[1],
  1868. col_pre = col_location[0],
  1869. col_index = col_location[2];
  1870. let row_index_original = Store.luckysheet_cell_selected_move_index[0],
  1871. col_index_original = Store.luckysheet_cell_selected_move_index[1];
  1872. let row_s = Store.luckysheet_select_save[0]["row"][0] - row_index_original + row_index,
  1873. row_e = Store.luckysheet_select_save[0]["row"][1] - row_index_original + row_index;
  1874. let col_s = Store.luckysheet_select_save[0]["column"][0] - col_index_original + col_index,
  1875. col_e = Store.luckysheet_select_save[0]["column"][1] - col_index_original + col_index;
  1876. if (row_s < 0 || y < 0) {
  1877. row_s = 0;
  1878. row_e = Store.luckysheet_select_save[0]["row"][1] - Store.luckysheet_select_save[0]["row"][0];
  1879. }
  1880. if (col_s < 0 || x < 0) {
  1881. col_s = 0;
  1882. col_e = Store.luckysheet_select_save[0]["column"][1] - Store.luckysheet_select_save[0]["column"][0];
  1883. }
  1884. if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
  1885. row_s = Store.visibledatarow.length - 1 - Store.luckysheet_select_save[0]["row"][1] + Store.luckysheet_select_save[0]["row"][0];
  1886. row_e = Store.visibledatarow.length - 1;
  1887. }
  1888. if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
  1889. col_s = Store.visibledatacolumn.length - 1 - Store.luckysheet_select_save[0]["column"][1] + Store.luckysheet_select_save[0]["column"][0];
  1890. col_e = Store.visibledatacolumn.length - 1;
  1891. }
  1892. col_pre = col_s - 1 == -1 ? 0 : Store.visibledatacolumn[col_s - 1];
  1893. col = Store.visibledatacolumn[col_e];
  1894. row_pre = row_s - 1 == -1 ? 0 : Store.visibledatarow[row_s - 1];
  1895. row = Store.visibledatarow[row_e];
  1896. $("#luckysheet-cell-selected-move").css({
  1897. "left": col_pre,
  1898. "width": col - col_pre - 2,
  1899. "top": row_pre,
  1900. "height": row - row_pre - 2,
  1901. "display": "block"
  1902. });
  1903. }
  1904. else if (Store.luckysheet_cell_selected_extend) {
  1905. let mouse = mouseposition(event.pageX, event.pageY);
  1906. let scrollLeft = $("#luckysheet-cell-main").scrollLeft() - 5;
  1907. let scrollTop = $("#luckysheet-cell-main").scrollTop() - 5;
  1908. let x = mouse[0] + scrollLeft;
  1909. let y = mouse[1] + scrollTop;
  1910. let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
  1911. winW = $(window).width() + scrollLeft;
  1912. let row_location = rowLocation(y),
  1913. row = row_location[1],
  1914. row_pre = row_location[0],
  1915. row_index = row_location[2];
  1916. let col_location = colLocation(x),
  1917. col = col_location[1],
  1918. col_pre = col_location[0],
  1919. col_index = col_location[2];
  1920. let row_index_original = Store.luckysheet_cell_selected_extend_index[0],
  1921. col_index_original = Store.luckysheet_cell_selected_extend_index[1];
  1922. let row_s = Store.luckysheet_select_save[0]["row"][0],
  1923. row_e = Store.luckysheet_select_save[0]["row"][1];
  1924. let col_s = Store.luckysheet_select_save[0]["column"][0],
  1925. col_e = Store.luckysheet_select_save[0]["column"][1];
  1926. if (row_s < 0 || y < 0) {
  1927. row_s = 0;
  1928. row_e = Store.luckysheet_select_save[0]["row"][1] - Store.luckysheet_select_save[0]["row"][0];
  1929. }
  1930. if (col_s < 0 || x < 0) {
  1931. col_s = 0;
  1932. col_e = Store.luckysheet_select_save[0]["column"][1] - Store.luckysheet_select_save[0]["column"][0];
  1933. }
  1934. if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
  1935. row_s = Store.visibledatarow.length - 1 - Store.luckysheet_select_save[0]["row"][1] + Store.luckysheet_select_save[0]["row"][0];
  1936. row_e = Store.visibledatarow.length - 1;
  1937. }
  1938. if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
  1939. col_s = Store.visibledatacolumn.length - 1 - Store.luckysheet_select_save[0]["column"][1] + Store.luckysheet_select_save[0]["column"][0];
  1940. col_e = Store.visibledatacolumn.length - 1;
  1941. }
  1942. let top = Store.luckysheet_select_save[0].top_move,
  1943. height = Store.luckysheet_select_save[0].height_move;
  1944. let left = Store.luckysheet_select_save[0].left_move,
  1945. width = Store.luckysheet_select_save[0].width_move;
  1946. if (Math.abs(row_index_original - row_index) > Math.abs(col_index_original - col_index)) {
  1947. if (!(row_index >= row_s && row_index <= row_e)) {
  1948. if (Store.luckysheet_select_save[0].top_move >= row_pre) {
  1949. top = row_pre;
  1950. height = Store.luckysheet_select_save[0].top_move + Store.luckysheet_select_save[0].height_move - row_pre;
  1951. }
  1952. else {
  1953. top = Store.luckysheet_select_save[0].top_move;
  1954. height = row - Store.luckysheet_select_save[0].top_move - 1;
  1955. }
  1956. }
  1957. }
  1958. else {
  1959. if (!(col_index >= col_s && col_index <= col_e)) {
  1960. if (Store.luckysheet_select_save[0].left_move >= col_pre) {
  1961. left = col_pre;
  1962. width = Store.luckysheet_select_save[0].left_move + Store.luckysheet_select_save[0].width_move - col_pre;
  1963. }
  1964. else {
  1965. left = Store.luckysheet_select_save[0].left_move;
  1966. width = col - Store.luckysheet_select_save[0].left_move - 1;
  1967. }
  1968. }
  1969. }
  1970. $("#luckysheet-cell-selected-extend").css({
  1971. "left": left,
  1972. "width": width,
  1973. "top": top,
  1974. "height": height,
  1975. "display": "block"
  1976. });
  1977. }
  1978. else if (Store.luckysheet_cols_change_size) {
  1979. let mouse = mouseposition(event.pageX, event.pageY);
  1980. let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft();
  1981. let x = mouse[0] + scrollLeft;
  1982. let winW = $(window).width();
  1983. let row_index = Store.visibledatarow.length - 1,
  1984. row = Store.visibledatarow[row_index],
  1985. row_pre = 0;
  1986. let col_location = colLocation(x),
  1987. col = col_location[1],
  1988. col_pre = col_location[0],
  1989. col_index = col_location[2];
  1990. if ((x + 3) - Store.luckysheet_cols_change_size_start[0] > 30 && x < winW + scrollLeft - 100) {
  1991. $("#luckysheet-change-size-line").css({ "left": x });
  1992. $("#luckysheet-cols-change-size").css({ "left": x - 2 });
  1993. }
  1994. }
  1995. else if (Store.luckysheet_rows_change_size) {
  1996. let mouse = mouseposition(event.pageX, event.pageY);
  1997. let scrollTop = $("#luckysheet-rows-h").scrollTop();
  1998. let y = mouse[1] + scrollTop;
  1999. let winH = $(window).height();
  2000. let row_location = rowLocation(y),
  2001. row = row_location[1],
  2002. row_pre = row_location[0],
  2003. row_index = row_location[2];
  2004. if ((y + 3) - Store.luckysheet_rows_change_size_start[0] > 19 && y < winH + scrollTop - 200) {
  2005. $("#luckysheet-change-size-line").css({ "top": y });
  2006. $("#luckysheet-rows-change-size").css({ "top": y });
  2007. }
  2008. }
  2009. // chart move
  2010. else if (!!Store.chartparam.luckysheetCurrentChartMove) {
  2011. const mouse = mouseposition(event.pageX, event.pageY);
  2012. const x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  2013. const y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  2014. const myh = Store.chartparam.luckysheetCurrentChartMoveObj.height(), myw = Store.chartparam.luckysheetCurrentChartMoveObj.width();
  2015. let top = y - Store.chartparam.luckysheetCurrentChartMoveXy[1], left = x - Store.chartparam.luckysheetCurrentChartMoveXy[0];
  2016. if (top < 0) {
  2017. top = 0;
  2018. }
  2019. if (top + myh + 42 + 6 > Store.chartparam.luckysheetCurrentChartMoveWinH) {
  2020. top = Store.chartparam.luckysheetCurrentChartMoveWinH - myh - 42 - 6;
  2021. }
  2022. if (left < 0) {
  2023. left = 0;
  2024. }
  2025. if (left + myw + 22 + 36 > Store.chartparam.luckysheetCurrentChartMoveWinW) {
  2026. left = Store.chartparam.luckysheetCurrentChartMoveWinW - myw - 22 - 36;
  2027. }
  2028. Store.chartparam.luckysheetCurrentChartMoveObj.css({ "top": top, "left": left });
  2029. if (luckysheetFreezen.freezenhorizontaldata != null || luckysheetFreezen.freezenverticaldata != null) {
  2030. luckysheetFreezen.scrollAdapt();
  2031. const toffset = Store.chartparam.luckysheetCurrentChartMoveObj.offset();
  2032. const tpsition = Store.chartparam.luckysheetCurrentChartMoveObj.position();
  2033. Store.chartparam.luckysheetCurrentChartMoveXy = [event.pageX - toffset.left, event.pageY - toffset.top, tpsition.left, tpsition.top, $("#luckysheet-scrollbar-x").scrollLeft(), $("#luckysheet-scrollbar-y").scrollTop()];
  2034. }
  2035. }
  2036. // chart resize
  2037. else if (!!Store.chartparam.luckysheetCurrentChartResize) {
  2038. const scrollTop = $("#luckysheet-cell-main").scrollTop(), scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  2039. const mouse = mouseposition(event.pageX, event.pageY);
  2040. const x = mouse[0] + scrollLeft;
  2041. const y = mouse[1] + scrollTop;
  2042. if (x < 0 || y < 0) {
  2043. return false;
  2044. }
  2045. const myh = Store.chartparam.luckysheetCurrentChartResizeObj.height(), myw = Store.chartparam.luckysheetCurrentChartResizeObj.width();
  2046. const topchange = y - Store.chartparam.luckysheetCurrentChartResizeXy[1], leftchange = x - Store.chartparam.luckysheetCurrentChartResizeXy[0];
  2047. let top = Store.chartparam.luckysheetCurrentChartResizeXy[5], height = Store.chartparam.luckysheetCurrentChartResizeXy[3], left = Store.chartparam.luckysheetCurrentChartResizeXy[4], width = Store.chartparam.luckysheetCurrentChartResizeXy[2];
  2048. if (Store.chartparam.luckysheetCurrentChartResize == "lm" || Store.chartparam.luckysheetCurrentChartResize == "lt" || Store.chartparam.luckysheetCurrentChartResize == "lb") {
  2049. left = x;
  2050. width = Store.chartparam.luckysheetCurrentChartResizeXy[2] - leftchange;
  2051. if (left > Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[4] - 60) {
  2052. left = Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[4] - 60;
  2053. width = Store.chartparam.luckysheetCurrentChartResizeXy[2] - (Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[4] - 60 - Store.chartparam.luckysheetCurrentChartResizeXy[0]);
  2054. }
  2055. else if (left <= 0) {
  2056. left = 0;
  2057. width = Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[0];
  2058. }
  2059. }
  2060. if (Store.chartparam.luckysheetCurrentChartResize == "rm" || Store.chartparam.luckysheetCurrentChartResize == "rt" || Store.chartparam.luckysheetCurrentChartResize == "rb") {
  2061. width = Store.chartparam.luckysheetCurrentChartResizeXy[2] + leftchange;
  2062. if (width < 60) {
  2063. width = 60;
  2064. }
  2065. else if (width >= Store.chartparam.luckysheetCurrentChartResizeWinW - Store.chartparam.luckysheetCurrentChartResizeXy[4] - 22 - 36) {
  2066. width = Store.chartparam.luckysheetCurrentChartResizeWinW - Store.chartparam.luckysheetCurrentChartResizeXy[4] - 22 - 36;
  2067. }
  2068. }
  2069. if (Store.chartparam.luckysheetCurrentChartResize == "mt" || Store.chartparam.luckysheetCurrentChartResize == "lt" || Store.chartparam.luckysheetCurrentChartResize == "rt") {
  2070. top = y;
  2071. height = Store.chartparam.luckysheetCurrentChartResizeXy[3] - topchange;
  2072. if (top > Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[5] - 60) {
  2073. top = Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[5] - 60;
  2074. height = Store.chartparam.luckysheetCurrentChartResizeXy[3] - (Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[5] - 60 - Store.chartparam.luckysheetCurrentChartResizeXy[1]);
  2075. }
  2076. else if (top <= 0) {
  2077. top = 0;
  2078. height = Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[1];
  2079. }
  2080. }
  2081. if (Store.chartparam.luckysheetCurrentChartResize == "mb" || Store.chartparam.luckysheetCurrentChartResize == "lb" || Store.chartparam.luckysheetCurrentChartResize == "rb") {
  2082. height = Store.chartparam.luckysheetCurrentChartResizeXy[3] + topchange;
  2083. if (height < 60) {
  2084. height = 60;
  2085. }
  2086. else if (height >= Store.chartparam.luckysheetCurrentChartResizeWinH - Store.chartparam.luckysheetCurrentChartResizeXy[5] - 42 - 6) {
  2087. height = Store.chartparam.luckysheetCurrentChartResizeWinH - Store.chartparam.luckysheetCurrentChartResizeXy[5] - 42 - 6;
  2088. }
  2089. }
  2090. const resizedata = { "top": top, "left": left, "height": height, "width": width };
  2091. Store.chartparam.luckysheetCurrentChartResizeObj.css(resizedata);
  2092. // resize chart
  2093. Store.resizeChart(Store.chartparam.luckysheetCurrentChart)
  2094. }
  2095. //image move
  2096. else if (imageCtrl.move) {
  2097. let mouse = mouseposition(event.pageX, event.pageY);
  2098. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  2099. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  2100. let imgItem = imageCtrl.images[imageCtrl.currentImgId];
  2101. if(imgItem.isFixedPos){
  2102. x = event.pageX;
  2103. y = event.pageY;
  2104. }
  2105. let myh = $("#luckysheet-modal-dialog-activeImage").height(),
  2106. myw = $("#luckysheet-modal-dialog-activeImage").width();
  2107. let top = y - imageCtrl.moveXY[1],
  2108. left = x - imageCtrl.moveXY[0];
  2109. let minTop = 0,
  2110. maxTop = imageCtrl.currentWinH - myh - 42 - 6,
  2111. minLeft = 0,
  2112. maxLeft = imageCtrl.currentWinW - myw - 22 - 36;
  2113. if(imgItem.isFixedPos){
  2114. minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
  2115. maxTop = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - myh;
  2116. minLeft = Store.rowHeaderWidth;
  2117. maxLeft = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - myw;
  2118. }
  2119. if (top < minTop) {
  2120. top = minTop;
  2121. }
  2122. if (top > maxTop) {
  2123. top = maxTop;
  2124. }
  2125. if (left < minLeft) {
  2126. left = minLeft;
  2127. }
  2128. if (left > maxLeft) {
  2129. left = maxLeft;
  2130. }
  2131. $("#luckysheet-modal-dialog-activeImage").css({ "left": left, "top": top });
  2132. }
  2133. //image resize
  2134. else if (!!imageCtrl.resize) {
  2135. let mouse = mouseposition(event.pageX, event.pageY);
  2136. let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  2137. let scrollTop = $("#luckysheet-cell-main").scrollTop();
  2138. let x = mouse[0] + scrollLeft;
  2139. let y = mouse[1] + scrollTop;
  2140. if (x < 0 || y < 0) {
  2141. return false;
  2142. }
  2143. let resizeXY = imageCtrl.resizeXY;
  2144. let topchange = y - resizeXY[1],
  2145. leftchange = x - resizeXY[0];
  2146. let top = resizeXY[5],
  2147. height = resizeXY[3],
  2148. left = resizeXY[4],
  2149. width = resizeXY[2];
  2150. let resize = imageCtrl.resize;
  2151. let imgItem = imageCtrl.images[imageCtrl.currentImgId];
  2152. if(imgItem.isFixedPos){
  2153. let minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
  2154. let minLeft = Store.rowHeaderWidth;
  2155. if(resize == 'lt'){//左上
  2156. left = resizeXY[4] - resizeXY[6] + leftchange;
  2157. if(left < minLeft){
  2158. left = minLeft;
  2159. }
  2160. if(left > resizeXY[4] - resizeXY[6] + resizeXY[2] - 1){
  2161. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - 1;
  2162. }
  2163. width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left;
  2164. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2165. top = resizeXY[5] - resizeXY[7] + resizeXY[3] - height;
  2166. if(top < minTop){
  2167. top = minTop;
  2168. height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
  2169. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2170. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
  2171. }
  2172. if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){
  2173. top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1;
  2174. height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
  2175. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2176. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
  2177. }
  2178. }
  2179. else if(resize == 'lm'){//左中
  2180. left = resizeXY[4] - resizeXY[6] + leftchange;
  2181. if(left < minLeft){
  2182. left = minLeft;
  2183. }
  2184. if(left > resizeXY[4] - resizeXY[6] + resizeXY[2] - 1){
  2185. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - 1;
  2186. }
  2187. width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left;
  2188. top = resizeXY[5] - resizeXY[7];
  2189. height = resizeXY[3];
  2190. }
  2191. else if(resize == 'lb'){//左下
  2192. left = resizeXY[4] - resizeXY[6] + leftchange;
  2193. if(left < minLeft){
  2194. left = minLeft;
  2195. }
  2196. if(left > resizeXY[4] - resizeXY[6] + resizeXY[2] - 1){
  2197. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - 1;
  2198. }
  2199. width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left;
  2200. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2201. top = resizeXY[5] - resizeXY[7];
  2202. if(height < 1){
  2203. height = 1;
  2204. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2205. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
  2206. }
  2207. if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){
  2208. height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top;
  2209. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2210. left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
  2211. }
  2212. }
  2213. else if(resize == 'rt'){//右上
  2214. left = resizeXY[4] - resizeXY[6];
  2215. width = resizeXY[2] + leftchange;
  2216. if(width < 1){
  2217. width = 1;
  2218. }
  2219. if(width > minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left){
  2220. width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left;
  2221. }
  2222. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2223. top = resizeXY[5] - resizeXY[7] + resizeXY[3] - height;
  2224. if(top < minTop){
  2225. top = minTop;
  2226. height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
  2227. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2228. }
  2229. if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){
  2230. top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1;
  2231. height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
  2232. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2233. }
  2234. }
  2235. else if(resize == 'rm'){//右中
  2236. left = resizeXY[4] - resizeXY[6];
  2237. width = resizeXY[2] + leftchange;
  2238. if(width < 1){
  2239. width = 1;
  2240. }
  2241. if(width > minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left){
  2242. width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left;
  2243. }
  2244. top = resizeXY[5] - resizeXY[7];
  2245. height = resizeXY[3];
  2246. }
  2247. else if(resize == 'rb'){//右下
  2248. left = resizeXY[4] - resizeXY[6];
  2249. width = resizeXY[2] + leftchange;
  2250. if(width < 1){
  2251. width = 1;
  2252. }
  2253. if(width > minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left){
  2254. width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left;
  2255. }
  2256. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2257. top = resizeXY[5] - resizeXY[7];
  2258. if(height < 1){
  2259. height = 1;
  2260. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2261. }
  2262. if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){
  2263. height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top;
  2264. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2265. }
  2266. }
  2267. else if(resize == 'mt'){//中上
  2268. left = resizeXY[4] - resizeXY[6];
  2269. width = resizeXY[2];
  2270. top = resizeXY[5] - resizeXY[7] + topchange;
  2271. if(top < minTop){
  2272. top = minTop;
  2273. }
  2274. if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){
  2275. top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1;
  2276. }
  2277. height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
  2278. }
  2279. else if(resize == 'mb'){//中下
  2280. left = resizeXY[4] - resizeXY[6];
  2281. width = resizeXY[2];
  2282. top = resizeXY[5] - resizeXY[7];
  2283. height = resizeXY[3] + topchange;
  2284. if(height < 1){
  2285. height = 1;
  2286. }
  2287. if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){
  2288. height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top;
  2289. }
  2290. }
  2291. }
  2292. else{
  2293. if(resize == 'lt'){//左上
  2294. left = x;
  2295. width = resizeXY[2] - leftchange;
  2296. if (left > resizeXY[2] + resizeXY[4] - 1) {
  2297. left = resizeXY[2] + resizeXY[4] - 1;
  2298. width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1);
  2299. }
  2300. else if (left <= 0) {
  2301. left = 0;
  2302. width = resizeXY[2] + resizeXY[0];
  2303. }
  2304. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2305. top = resizeXY[3] + resizeXY[1] - height;
  2306. if (top > resizeXY[3] + resizeXY[5] - 1) {
  2307. top = resizeXY[3] + resizeXY[5] - 1;
  2308. height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1);
  2309. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2310. left = resizeXY[2] + resizeXY[0] - width;
  2311. }
  2312. else if (top <= 0) {
  2313. top = 0;
  2314. height = resizeXY[3] + resizeXY[1];
  2315. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2316. left = resizeXY[2] + resizeXY[0] - width;
  2317. }
  2318. }
  2319. else if(resize == 'lm'){//左中
  2320. left = x;
  2321. width = resizeXY[2] - leftchange;
  2322. if (left > resizeXY[2] + resizeXY[4] - 1) {
  2323. left = resizeXY[2] + resizeXY[4] - 1;
  2324. width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1);
  2325. }
  2326. else if (left <= 0) {
  2327. left = 0;
  2328. width = resizeXY[2] + resizeXY[0];
  2329. }
  2330. }
  2331. else if(resize == 'lb'){//左下
  2332. left = x;
  2333. width = resizeXY[2] - leftchange;
  2334. if (left > resizeXY[2] + resizeXY[4] - 1) {
  2335. left = resizeXY[2] + resizeXY[4] - 1;
  2336. width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1);
  2337. }
  2338. else if (left <= 0) {
  2339. left = 0;
  2340. width = resizeXY[2] + resizeXY[0];
  2341. }
  2342. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2343. if (height < 1) {
  2344. height = 1;
  2345. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2346. left = resizeXY[2] + resizeXY[0] - width;
  2347. }
  2348. else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
  2349. height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
  2350. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2351. left = resizeXY[2] + resizeXY[0] - width;
  2352. }
  2353. }
  2354. else if(resize == 'rt'){//右上
  2355. width = resizeXY[2] + leftchange;
  2356. if (width < 1) {
  2357. width = 1;
  2358. }
  2359. else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
  2360. width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
  2361. }
  2362. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2363. top = resizeXY[3] + resizeXY[1] - height;
  2364. if (top > resizeXY[3] + resizeXY[5] - 1) {
  2365. top = resizeXY[3] + resizeXY[5] - 1;
  2366. height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1);
  2367. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2368. }
  2369. else if (top <= 0) {
  2370. top = 0;
  2371. height = resizeXY[3] + resizeXY[1];
  2372. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2373. }
  2374. }
  2375. else if(resize == 'rm'){//右中
  2376. width = resizeXY[2] + leftchange;
  2377. if (width < 1) {
  2378. width = 1;
  2379. }
  2380. else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
  2381. width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
  2382. }
  2383. }
  2384. else if(resize == 'rb'){//右下
  2385. width = resizeXY[2] + leftchange;
  2386. if (width < 1) {
  2387. width = 1;
  2388. }
  2389. else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
  2390. width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
  2391. }
  2392. height = Math.round(width * (resizeXY[3] / resizeXY[2]));
  2393. if (height < 1) {
  2394. height = 1;
  2395. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2396. }
  2397. else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
  2398. height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
  2399. width = Math.round(height * (resizeXY[2] / resizeXY[3]));
  2400. }
  2401. }
  2402. else if(resize == 'mt'){//中上
  2403. top = y;
  2404. height = resizeXY[3] - topchange;
  2405. if (top > resizeXY[3] + resizeXY[5] - 1) {
  2406. top = resizeXY[3] + resizeXY[5] - 1;
  2407. height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1);
  2408. }
  2409. else if (top <= 0) {
  2410. top = 0;
  2411. height = resizeXY[3] + resizeXY[1];
  2412. }
  2413. }
  2414. else if(resize == 'mb'){//中下
  2415. height = resizeXY[3] + topchange;
  2416. if (height < 1) {
  2417. height = 1;
  2418. }
  2419. else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
  2420. height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
  2421. }
  2422. }
  2423. }
  2424. $("#luckysheet-modal-dialog-activeImage").css({
  2425. "width": width,
  2426. "height": height,
  2427. "left": left,
  2428. "top": top
  2429. });
  2430. let scaleX = width / imgItem.crop.width;
  2431. let scaleY = height / imgItem.crop.height;
  2432. let defaultWidth = Math.round(imgItem.default.width * scaleX);
  2433. let defaultHeight = Math.round(imgItem.default.height * scaleY);
  2434. let offsetLeft = Math.round(imgItem.crop.offsetLeft * scaleX);
  2435. let offsetTop = Math.round(imgItem.crop.offsetTop * scaleY);
  2436. $("#luckysheet-modal-dialog-activeImage .luckysheet-modal-dialog-content").css({
  2437. "background-size": defaultWidth + "px " + defaultHeight + "px",
  2438. "background-position": -offsetLeft + "px " + -offsetTop + "px"
  2439. })
  2440. }
  2441. //image cropChange
  2442. else if (!!imageCtrl.cropChange) {
  2443. let mouse = mouseposition(event.pageX, event.pageY);
  2444. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  2445. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  2446. if (x < 0 || y < 0) {
  2447. return false;
  2448. }
  2449. let cropChangeXY = imageCtrl.cropChangeXY;
  2450. let topchange = y - cropChangeXY[1],
  2451. leftchange = x - cropChangeXY[0];
  2452. let imgItem = imageCtrl.images[imageCtrl.currentImgId];
  2453. let cropChange = imageCtrl.cropChange;
  2454. let width, height, offsetLeft, offsetTop;
  2455. if(cropChange == 'lt'){//左上
  2456. offsetLeft = imgItem.crop.offsetLeft + leftchange;
  2457. if(offsetLeft < 0){
  2458. offsetLeft = 0;
  2459. }
  2460. if(offsetLeft > imgItem.crop.width + imgItem.crop.offsetLeft - 1){
  2461. offsetLeft = imgItem.crop.width + imgItem.crop.offsetLeft - 1;
  2462. }
  2463. width = imgItem.crop.width + imgItem.crop.offsetLeft - offsetLeft;
  2464. offsetTop = imgItem.crop.offsetTop + topchange;
  2465. if(offsetTop < 0){
  2466. offsetTop = 0;
  2467. }
  2468. if(offsetTop > imgItem.crop.height + imgItem.crop.offsetTop - 1){
  2469. offsetTop = imgItem.crop.height + imgItem.crop.offsetTop - 1;
  2470. }
  2471. height = imgItem.crop.height + imgItem.crop.offsetTop - offsetTop;
  2472. }
  2473. else if(cropChange == 'lm'){//左中
  2474. offsetLeft = imgItem.crop.offsetLeft + leftchange;
  2475. if(offsetLeft < 0){
  2476. offsetLeft = 0;
  2477. }
  2478. if(offsetLeft > imgItem.crop.width + imgItem.crop.offsetLeft - 1){
  2479. offsetLeft = imgItem.crop.width + imgItem.crop.offsetLeft - 1;
  2480. }
  2481. width = imgItem.crop.width + imgItem.crop.offsetLeft - offsetLeft;
  2482. offsetTop = imgItem.crop.offsetTop;
  2483. height = imgItem.crop.height;
  2484. }
  2485. else if(cropChange == 'lb'){//左下
  2486. offsetLeft = imgItem.crop.offsetLeft + leftchange;
  2487. if(offsetLeft < 0){
  2488. offsetLeft = 0;
  2489. }
  2490. if(offsetLeft > imgItem.crop.width + imgItem.crop.offsetLeft - 1){
  2491. offsetLeft = imgItem.crop.width + imgItem.crop.offsetLeft - 1;
  2492. }
  2493. width = imgItem.crop.width + imgItem.crop.offsetLeft - offsetLeft;
  2494. offsetTop = imgItem.crop.offsetTop;
  2495. height = imgItem.crop.height + topchange;
  2496. if(height < 1){
  2497. height = 1;
  2498. }
  2499. if(height > imgItem.default.height - offsetTop){
  2500. height = imgItem.default.height - offsetTop;
  2501. }
  2502. }
  2503. else if(cropChange == 'rt'){//右上
  2504. offsetLeft = imgItem.crop.offsetLeft;
  2505. width = imgItem.crop.width + leftchange;
  2506. if(width < 1){
  2507. width = 1;
  2508. }
  2509. if(width > imgItem.default.width - offsetLeft){
  2510. width = imgItem.default.width - offsetLeft;
  2511. }
  2512. offsetTop = imgItem.crop.offsetTop + topchange;
  2513. if(offsetTop < 0){
  2514. offsetTop = 0;
  2515. }
  2516. if(offsetTop > imgItem.crop.height + imgItem.crop.offsetTop - 1){
  2517. offsetTop = imgItem.crop.height + imgItem.crop.offsetTop - 1;
  2518. }
  2519. height = imgItem.crop.height + imgItem.crop.offsetTop - offsetTop;
  2520. }
  2521. else if(cropChange == 'rm'){//右中
  2522. offsetLeft = imgItem.crop.offsetLeft;
  2523. width = imgItem.crop.width + leftchange;
  2524. if(width < 1){
  2525. width = 1;
  2526. }
  2527. if(width > imgItem.default.width - offsetLeft){
  2528. width = imgItem.default.width - offsetLeft;
  2529. }
  2530. offsetTop = imgItem.crop.offsetTop;
  2531. height = imgItem.crop.height;
  2532. }
  2533. else if(cropChange == 'rb'){//右下
  2534. offsetLeft = imgItem.crop.offsetLeft;
  2535. width = imgItem.crop.width + leftchange;
  2536. if(width < 1){
  2537. width = 1;
  2538. }
  2539. if(width > imgItem.default.width - offsetLeft){
  2540. width = imgItem.default.width - offsetLeft;
  2541. }
  2542. offsetTop = imgItem.crop.offsetTop;
  2543. height = imgItem.crop.height + topchange;
  2544. if(height < 1){
  2545. height = 1;
  2546. }
  2547. if(height > imgItem.default.height - offsetTop){
  2548. height = imgItem.default.height - offsetTop;
  2549. }
  2550. }
  2551. else if(cropChange == 'mt'){//中上
  2552. offsetLeft = imgItem.crop.offsetLeft;
  2553. width = imgItem.crop.width;
  2554. offsetTop = imgItem.crop.offsetTop + topchange;
  2555. if(offsetTop < 0){
  2556. offsetTop = 0;
  2557. }
  2558. if(offsetTop > imgItem.crop.height + imgItem.crop.offsetTop - 1){
  2559. offsetTop = imgItem.crop.height + imgItem.crop.offsetTop - 1;
  2560. }
  2561. height = imgItem.crop.height + imgItem.crop.offsetTop - offsetTop;
  2562. }
  2563. else if(cropChange == 'mb'){//中下
  2564. offsetLeft = imgItem.crop.offsetLeft;
  2565. width = imgItem.crop.width;
  2566. offsetTop = imgItem.crop.offsetTop;
  2567. height = imgItem.crop.height + topchange;
  2568. if(height < 1){
  2569. height = 1;
  2570. }
  2571. if(height > imgItem.default.height - offsetTop){
  2572. height = imgItem.default.height - offsetTop;
  2573. }
  2574. }
  2575. let left = imgItem.default.left + offsetLeft;
  2576. let top = imgItem.default.top + offsetTop;
  2577. if(imgItem.isFixedPos){
  2578. left = imgItem.fixedLeft + offsetLeft;
  2579. top = imgItem.fixedTop + offsetTop;
  2580. }
  2581. $("#luckysheet-modal-dialog-cropping").show().css({
  2582. "width": width,
  2583. "height": height,
  2584. "left": left,
  2585. "top": top
  2586. });
  2587. let imageUrlHandle = Store.toJsonOptions && Store.toJsonOptions['imageUrlHandle'];
  2588. let imgSrc = typeof imageUrlHandle === 'function' ? imageUrlHandle(imgItem.src) : imgItem.src;
  2589. $("#luckysheet-modal-dialog-cropping .cropping-mask").css({
  2590. "width": imgItem.default.width,
  2591. "height": imgItem.default.height,
  2592. "background-image": "url(" + imgSrc + ")",
  2593. "left": -offsetLeft,
  2594. "top": -offsetTop
  2595. })
  2596. $("#luckysheet-modal-dialog-cropping .cropping-content").css({
  2597. "background-image": "url(" + imgSrc + ")",
  2598. "background-size": imgItem.default.width + "px " + imgItem.default.height + "px",
  2599. "background-position": -offsetLeft + "px " + -offsetTop + "px"
  2600. })
  2601. imageCtrl.cropChangeObj = {
  2602. width: width,
  2603. height: height,
  2604. offsetLeft: offsetLeft,
  2605. offsetTop: offsetTop
  2606. }
  2607. }
  2608. else if (luckysheetPostil.move) {
  2609. let mouse = mouseposition(event.pageX, event.pageY);
  2610. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  2611. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  2612. let myh = luckysheetPostil.currentObj.outerHeight(),
  2613. myw = luckysheetPostil.currentObj.outerWidth();
  2614. let top = y - luckysheetPostil.moveXY[1],
  2615. left = x - luckysheetPostil.moveXY[0];
  2616. if (top < 0) {
  2617. top = 0;
  2618. }
  2619. if (top + myh + 42 + 6 > luckysheetPostil.currentWinH) {
  2620. top = luckysheetPostil.currentWinH - myh - 42 - 6;
  2621. }
  2622. if (left < 0) {
  2623. left = 0;
  2624. }
  2625. if (left + myw + 22 + 36 > luckysheetPostil.currentWinW) {
  2626. left = luckysheetPostil.currentWinW - myw - 22 - 36;
  2627. }
  2628. luckysheetPostil.currentObj.css({ "left": left, "top": top });
  2629. }
  2630. else if (!!luckysheetPostil.resize) {
  2631. let mouse = mouseposition(event.pageX, event.pageY);
  2632. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  2633. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  2634. if (x < 0 || y < 0) {
  2635. return false;
  2636. }
  2637. let resizeXY = luckysheetPostil.resizeXY;
  2638. let topchange = y - resizeXY[1],
  2639. leftchange = x - resizeXY[0];
  2640. let top = resizeXY[5],
  2641. height = resizeXY[3],
  2642. left = resizeXY[4],
  2643. width = resizeXY[2];
  2644. let resize = luckysheetPostil.resize;
  2645. if (resize == "lm" || resize == "lt" || resize == "lb") {
  2646. left = x;
  2647. width = resizeXY[2] - leftchange;
  2648. if (left > resizeXY[2] + resizeXY[4] - 60) {
  2649. left = resizeXY[2] + resizeXY[4] - 60;
  2650. width = resizeXY[2] - (resizeXY[2] + resizeXY[4] - 60 - resizeXY[0]);
  2651. }
  2652. else if (left <= 0) {
  2653. left = 0;
  2654. width = resizeXY[2] + resizeXY[0];
  2655. }
  2656. }
  2657. if (resize == "rm" || resize == "rt" || resize == "rb") {
  2658. width = resizeXY[2] + leftchange;
  2659. if (width < 60) {
  2660. width = 60;
  2661. }
  2662. else if (width >= luckysheetPostil.currentWinW - resizeXY[4] - 22 - 36) {
  2663. width = luckysheetPostil.currentWinW - resizeXY[4] - 22 - 36;
  2664. }
  2665. }
  2666. if (resize == "mt" || resize == "lt" || resize == "rt") {
  2667. top = y;
  2668. height = resizeXY[3] - topchange;
  2669. if (top > resizeXY[3] + resizeXY[5] - 60) {
  2670. top = resizeXY[3] + resizeXY[5] - 60;
  2671. height = resizeXY[3] - (resizeXY[3] + resizeXY[5] - 60 - resizeXY[1]);
  2672. }
  2673. else if (top <= 0) {
  2674. top = 0;
  2675. height = resizeXY[3] + resizeXY[1];
  2676. }
  2677. }
  2678. if (resize == "mb" || resize == "lb" || resize == "rb") {
  2679. height = resizeXY[3] + topchange;
  2680. if (height < 60) {
  2681. height = 60;
  2682. }
  2683. else if (height >= luckysheetPostil.currentWinH - resizeXY[5] - 42 - 6) {
  2684. height = luckysheetPostil.currentWinH - resizeXY[5] - 42 - 6;
  2685. }
  2686. }
  2687. luckysheetPostil.currentObj.css({ "width": width, "height": height, "left": left, "top": top });
  2688. }
  2689. else if (!!formula.rangeResize) {
  2690. formula.rangeResizeDraging(event, formula.rangeResizeObj, formula.rangeResizexy, formula.rangeResize, formula.rangeResizeWinW, formula.rangeResizeWinH, Store.ch_width, Store.rh_height);
  2691. }
  2692. else if (!!formula.rangeMove) {
  2693. formula.rangeMoveDraging(event, formula.rangeMovexy, formula.rangeMoveObj.data("range"), formula.rangeMoveObj, Store.sheetBarHeight, Store.statisticBarHeight);
  2694. }
  2695. else if (!!Store.chart_selection.rangeResize) {
  2696. Store.chart_selection.rangeResizeDraging(event, Store.sheetBarHeight, Store.statisticBarHeight);
  2697. }
  2698. else if (!!Store.chart_selection.rangeMove) {
  2699. Store.chart_selection.rangeMoveDraging(event, Store.sheetBarHeight, Store.statisticBarHeight);
  2700. }
  2701. Store.jfautoscrollTimeout = window.requestAnimationFrame(mouseRender);
  2702. }
  2703. Store.jfautoscrollTimeout = window.requestAnimationFrame(mouseRender);
  2704. }
  2705. });
  2706. //表格mouseup
  2707. $(document).on("mouseup.luckysheetEvent",function (event) {
  2708. if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMouseup){
  2709. let mouse = mouseposition(event.pageX, event.pageY);
  2710. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  2711. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  2712. let row_location = rowLocation(y),
  2713. row = row_location[1],
  2714. row_pre = row_location[0],
  2715. row_index = row_location[2];
  2716. let col_location = colLocation(x),
  2717. col = col_location[1],
  2718. col_pre = col_location[0],
  2719. col_index = col_location[2];
  2720. let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
  2721. if (!!margeset) {
  2722. row = margeset.row[1];
  2723. row_pre = margeset.row[0];
  2724. row_index = margeset.row[2];
  2725. col = margeset.column[1];
  2726. col_pre = margeset.column[0];
  2727. col_index = margeset.column[2];
  2728. }
  2729. // if(Store.flowdata[row_index] && Store.flowdata[row_index][col_index]){
  2730. let sheetFile = sheetmanage.getSheetByIndex();
  2731. let moveState = {
  2732. functionResizeStatus:formula.functionResizeStatus,
  2733. horizontalmoveState:!!luckysheetFreezen.horizontalmovestate,
  2734. verticalmoveState:!!luckysheetFreezen.verticalmovestate,
  2735. pivotTableMoveState:!!pivotTable && pivotTable.movestate,
  2736. sheetMoveStatus:Store.luckysheet_sheet_move_status,
  2737. scrollStatus:!!Store.luckysheet_scroll_status,
  2738. selectStatus:!!Store.luckysheet_select_status,
  2739. rowsSelectedStatus:!!Store.luckysheet_rows_selected_status,
  2740. colsSelectedStatus:!!Store.luckysheet_cols_selected_status,
  2741. cellSelectedMove:!!Store.luckysheet_cell_selected_move,
  2742. cellSelectedExtend:!!Store.luckysheet_cell_selected_extend,
  2743. colsChangeSize:!!Store.luckysheet_cols_change_size,
  2744. rowsChangeSize:!!Store.luckysheet_rows_change_size,
  2745. chartMove:!!Store.chartparam.luckysheetCurrentChartMove,
  2746. chartResize:!!Store.chartparam.luckysheetCurrentChartResize,
  2747. rangeResize:!!formula.rangeResize ,
  2748. rangeMove:!!formula.rangeMove,
  2749. }
  2750. let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
  2751. method.createHookFunction("sheetMouseup", Store.flowdata[row_index][col_index], {
  2752. r:row_index,
  2753. c:col_index,
  2754. "start_r": row_pre,
  2755. "start_c": col_pre,
  2756. "end_r": row,
  2757. "end_c": col
  2758. }, sheetFile,moveState,luckysheetTableContent);
  2759. // }
  2760. }
  2761. //数据窗格主体
  2762. if (Store.luckysheet_select_status) {
  2763. clearTimeout(Store.countfuncTimeout);
  2764. Store.countfuncTimeout = setTimeout(function () {
  2765. countfunc();
  2766. }, 0);
  2767. //格式刷
  2768. if (menuButton.luckysheetPaintModelOn) {
  2769. selection.pasteHandlerOfPaintModel(Store.luckysheet_copy_save);
  2770. if (menuButton.luckysheetPaintSingle) {
  2771. //单次 格式刷
  2772. menuButton.cancelPaintModel();
  2773. }
  2774. }
  2775. }
  2776. Store.luckysheet_select_status = false;
  2777. window.cancelAnimationFrame(Store.jfautoscrollTimeout);
  2778. Store.luckysheet_scroll_status = false;
  2779. $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle").css("cursor", "crosshair").end().find(".luckysheet-cs-draghandle").css("cursor", "move");
  2780. $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor", "default");
  2781. //行标题窗格主体
  2782. Store.luckysheet_rows_selected_status = false;
  2783. //列标题窗格主体
  2784. Store.luckysheet_cols_selected_status = false;
  2785. Store.luckysheet_model_move_state = false;
  2786. if (formula.functionResizeStatus) {
  2787. formula.functionResizeStatus = false;
  2788. $("#luckysheet-wa-calculate-size").removeAttr("style");
  2789. }
  2790. if (!!luckysheetFreezen.horizontalmovestate) {
  2791. luckysheetFreezen.horizontalmovestate = false;
  2792. $("#luckysheet-freezebar-horizontal").removeClass("luckysheet-freezebar-active");
  2793. $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css("cursor", "-webkit-grab");
  2794. if (luckysheetFreezen.freezenhorizontaldata[4] <= Store.columnHeaderHeight) {
  2795. luckysheetFreezen.cancelFreezenHorizontal();
  2796. }
  2797. luckysheetFreezen.createAssistCanvas();
  2798. luckysheetrefreshgrid();
  2799. }
  2800. if (!!luckysheetFreezen.verticalmovestate) {
  2801. luckysheetFreezen.verticalmovestate = false;
  2802. $("#luckysheet-freezebar-vertical").removeClass("luckysheet-freezebar-active");
  2803. $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css("cursor", "-webkit-grab");
  2804. if (luckysheetFreezen.freezenverticaldata[4] <= Store.rowHeaderWidth) {
  2805. luckysheetFreezen.cancelFreezenVertical();
  2806. }
  2807. luckysheetFreezen.createAssistCanvas();
  2808. luckysheetrefreshgrid();
  2809. }
  2810. if (!!pivotTable && pivotTable.movestate) {
  2811. $("#luckysheet-modal-dialog-slider-pivot-move").remove();
  2812. pivotTable.movestate = false;
  2813. $("#luckysheet-modal-dialog-pivotTable-list, #luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").css("cursor", "default");
  2814. if (pivotTable.movesave.containerid != "luckysheet-modal-dialog-pivotTable-list") {
  2815. let $cur = $(event.target).closest(".luckysheet-modal-dialog-slider-config-list");
  2816. if ($cur.length == 0) {
  2817. if (pivotTable.movesave.containerid == "luckysheet-modal-dialog-config-value") {
  2818. pivotTable.resetOrderby(pivotTable.movesave.obj);
  2819. }
  2820. pivotTable.movesave.obj.remove();
  2821. pivotTable.showvaluecolrow();
  2822. $("#luckysheet-modal-dialog-pivotTable-list").find(".luckysheet-modal-dialog-slider-list-item").each(function () {
  2823. $(this).find(".luckysheet-slider-list-item-selected").find("i").remove();
  2824. });
  2825. $("#luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").find(".luckysheet-modal-dialog-slider-config-item").each(function () {
  2826. let index = $(this).data("index");
  2827. $("#luckysheet-modal-dialog-pivotTable-list").find(".luckysheet-modal-dialog-slider-list-item").each(function () {
  2828. let $seleted = $(this).find(".luckysheet-slider-list-item-selected");
  2829. if ($(this).data("index") == index && $seleted.find("i").length == 0) {
  2830. $seleted.append('<i class="fa fa-check luckysheet-mousedown-cancel"></i>');
  2831. }
  2832. });
  2833. });
  2834. pivotTable.refreshPivotTable();
  2835. }
  2836. }
  2837. }
  2838. if (Store.luckysheet_sheet_move_status) {
  2839. Store.luckysheet_sheet_move_status = false;
  2840. Store.luckysheet_sheet_move_data.activeobject.insertBefore($("#luckysheet-sheets-item-clone"));
  2841. Store.luckysheet_sheet_move_data.activeobject.removeAttr("style");
  2842. $("#luckysheet-sheets-item-clone").remove();
  2843. Store.luckysheet_sheet_move_data.cursorobject.css({ "cursor": "pointer" });
  2844. Store.luckysheet_sheet_move_data = {};
  2845. sheetmanage.reOrderAllSheet();
  2846. }
  2847. // chart move debounce timer clear
  2848. clearTimeout(Store.chartparam.luckysheetCurrentChartMoveTimeout);
  2849. //图表拖动 chartMix
  2850. if (!!Store.chartparam.luckysheetCurrentChartMove) {
  2851. Store.chartparam.luckysheetCurrentChartMove = false;
  2852. if (Store.chartparam.luckysheetInsertChartTosheetChange) {
  2853. //myTop, myLeft: 本次的chart框位置,scrollLeft,scrollTop: 上一次的滚动条位置
  2854. var myTop = Store.chartparam.luckysheetCurrentChartMoveObj.css("top"), myLeft = Store.chartparam.luckysheetCurrentChartMoveObj.css("left"), scrollLeft = $("#luckysheet-cell-main").scrollLeft(), scrollTop = $("#luckysheet-cell-main").scrollTop();
  2855. //点击时候存储的信息,即上一次操作结束的图表信息,x,y: chart框位置,scrollLeft1,scrollTop1: 滚动条位置
  2856. var x = Store.chartparam.luckysheetCurrentChartMoveXy[2];
  2857. var y = Store.chartparam.luckysheetCurrentChartMoveXy[3];
  2858. var scrollLeft1 = Store.chartparam.luckysheetCurrentChartMoveXy[4];
  2859. var scrollTop1 = Store.chartparam.luckysheetCurrentChartMoveXy[5];
  2860. var chart_id = Store.chartparam.luckysheetCurrentChartMoveObj.find(".luckysheet-modal-dialog-content").attr("id");
  2861. //去除chartobj,改用chart_id代替即可定位到此图表
  2862. Store.jfredo.push({ "type": "moveChart", "chart_id": chart_id, "sheetIndex": Store.currentSheetIndex, "myTop": myTop, "myLeft": myLeft, "scrollTop": scrollTop, "scrollLeft": scrollLeft, "x": x, "y": y, "scrollTop1": scrollTop1, "scrollLeft1": scrollLeft1 });
  2863. // luckysheet.sheetmanage.saveChart({ "chart_id": chart_id, "sheetIndex": sheetIndex, "top": myTop, "left": myLeft });
  2864. //存储滚动条位置//协同编辑时可能影响用户操作,可以考虑不存储滚动条位置,或者滚动条信息仅仅保存到后台,但是不分发到其他设备(google sheet没有存储滚动条位置)
  2865. // Store.server.saveParam("c", sheetIndex, { "left":myLeft, "top":myTop,"scrollTop": scrollTop, "scrollLeft": scrollLeft }, { "op":"xy", "cid": chart_id});
  2866. }
  2867. }
  2868. //图表改变大小 chartMix
  2869. if (!!Store.chartparam.luckysheetCurrentChartResize) {
  2870. Store.chartparam.luckysheetCurrentChartResize = null;
  2871. if (Store.chartparam.luckysheetInsertChartTosheetChange) {
  2872. var myHeight = Store.chartparam.luckysheetCurrentChartResizeObj.height(), myWidth = Store.chartparam.luckysheetCurrentChartResizeObj.width(), scrollLeft = $("#luckysheet-cell-main").scrollLeft(), scrollTop = $("#luckysheet-cell-main").scrollTop();
  2873. var myTop = Store.chartparam.luckysheetCurrentChartMoveObj.css("top"),
  2874. myLeft = Store.chartparam.luckysheetCurrentChartMoveObj.css("left");
  2875. var chart_id = Store.chartparam.luckysheetCurrentChartResizeObj.find(".luckysheet-modal-dialog-content").attr("id");
  2876. var myWidth1 = Store.chartparam.luckysheetCurrentChartResizeXy[2];
  2877. var myHeight1 = Store.chartparam.luckysheetCurrentChartResizeXy[3];
  2878. var x = Store.chartparam.luckysheetCurrentChartResizeXy[4];//增加上一次的位置x,y
  2879. var y = Store.chartparam.luckysheetCurrentChartResizeXy[5];
  2880. var scrollLeft1 = Store.chartparam.luckysheetCurrentChartResizeXy[6];
  2881. var scrollTop1 = Store.chartparam.luckysheetCurrentChartResizeXy[7];
  2882. Store.jfredo.push({ "type": "resizeChart", "chart_id": chart_id, "sheetIndex": Store.currentSheetIndex, "myTop": myTop, "myLeft": myLeft, "myHeight": myHeight, "myWidth": myWidth, "scrollTop": scrollTop, "scrollLeft": scrollLeft, "x": x, "y": y, "myWidth1": myWidth1, "myHeight1": myHeight1, "scrollTop1": scrollTop1, "scrollLeft1": scrollLeft1 });
  2883. //加上滚动条的位置
  2884. // luckysheet.sheetmanage.saveChart({ "chart_id": chart_id, "sheetIndex": sheetIndex, "height": myHeight, "width": myWidth, "top": myTop, "left": myLeft, "scrollTop": scrollTop, "scrollLeft": scrollLeft });
  2885. // Store.server.saveParam("c", sheetIndex, { "width":myWidth, "height":myHeight, "top": myTop, "left": myLeft, "scrollTop": scrollTop, "scrollLeft": scrollLeft}, { "op":"wh", "cid": chart_id});
  2886. }
  2887. }
  2888. if (!!formula.rangeResize) {
  2889. formula.rangeResizeDragged(event, formula.rangeResizeObj, formula.rangeResize, formula.rangeResizexy, formula.rangeResizeWinW, formula.rangeResizeWinH);
  2890. }
  2891. //image move
  2892. if (imageCtrl.move) {
  2893. imageCtrl.moveImgItem();
  2894. }
  2895. //image resize
  2896. if (imageCtrl.resize) {
  2897. imageCtrl.resizeImgItem();
  2898. }
  2899. //image cropChange
  2900. if (imageCtrl.cropChange) {
  2901. imageCtrl.cropChangeImgItem();
  2902. }
  2903. //批注框 移动
  2904. if (luckysheetPostil.move) {
  2905. luckysheetPostil.move = false;
  2906. let ps_id = luckysheetPostil.currentObj.closest(".luckysheet-postil-show").attr("id");
  2907. let ps_r = ps_id.split("luckysheet-postil-show_")[1].split("_")[0];
  2908. let ps_c = ps_id.split("luckysheet-postil-show_")[1].split("_")[1];
  2909. let d = editor.deepCopyFlowData(Store.flowdata);
  2910. let rc = [];
  2911. d[ps_r][ps_c].ps.left = luckysheetPostil.currentObj.position().left;
  2912. d[ps_r][ps_c].ps.top = luckysheetPostil.currentObj.position().top;
  2913. d[ps_r][ps_c].ps.value = luckysheetPostil.currentObj.find(".formulaInputFocus").html().replaceAll('<div>', '\n').replaceAll(/<(.*)>.*?|<(.*) \/>/g, '').trim();
  2914. rc.push(ps_r + "_" + ps_c);
  2915. luckysheetPostil.ref(d, rc);
  2916. $("#" + ps_id).remove();
  2917. if (d[ps_r][ps_c].ps.isshow) {
  2918. luckysheetPostil.buildPs(ps_r, ps_c, d[ps_r][ps_c].ps);
  2919. $("#" + ps_id).addClass("luckysheet-postil-show-active");
  2920. $("#" + ps_id).find(".luckysheet-postil-dialog-resize").show();
  2921. }
  2922. else {
  2923. luckysheetPostil.editPs(ps_r, ps_c);
  2924. }
  2925. }
  2926. //批注框 改变大小
  2927. if (!!luckysheetPostil.resize) {
  2928. luckysheetPostil.resize = null;
  2929. let ps_id = luckysheetPostil.currentObj.closest(".luckysheet-postil-show").attr("id");
  2930. let ps_r = ps_id.split("luckysheet-postil-show_")[1].split("_")[0];
  2931. let ps_c = ps_id.split("luckysheet-postil-show_")[1].split("_")[1];
  2932. let d = editor.deepCopyFlowData(Store.flowdata);
  2933. let rc = [];
  2934. d[ps_r][ps_c].ps.left = luckysheetPostil.currentObj.position().left;
  2935. d[ps_r][ps_c].ps.top = luckysheetPostil.currentObj.position().top;
  2936. d[ps_r][ps_c].ps.width = luckysheetPostil.currentObj.outerWidth();
  2937. d[ps_r][ps_c].ps.height = luckysheetPostil.currentObj.outerHeight();
  2938. d[ps_r][ps_c].ps.value = luckysheetPostil.currentObj.find(".formulaInputFocus").html().replaceAll('<div>', '\n').replaceAll(/<(.*)>.*?|<(.*) \/>/g, '').trim();
  2939. rc.push(ps_r + "_" + ps_c);
  2940. luckysheetPostil.ref(d, rc);
  2941. $("#" + ps_id).remove();
  2942. if (d[ps_r][ps_c].ps.isshow) {
  2943. luckysheetPostil.buildPs(ps_r, ps_c, d[ps_r][ps_c].ps);
  2944. $("#" + ps_id).addClass("luckysheet-postil-show-active");
  2945. $("#" + ps_id).find(".luckysheet-postil-dialog-resize").show();
  2946. }
  2947. else {
  2948. luckysheetPostil.editPs(ps_r, ps_c);
  2949. }
  2950. }
  2951. //改变行高
  2952. if (Store.luckysheet_rows_change_size) {
  2953. Store.luckysheet_rows_change_size = false;
  2954. $("#luckysheet-change-size-line").hide();
  2955. $("#luckysheet-rows-change-size").css("opacity", 0);
  2956. $("#luckysheet-sheettable, #luckysheet-rows-h, #luckysheet-rows-h canvas").css("cursor", "default");
  2957. let mouse = mouseposition(event.pageX, event.pageY);
  2958. let scrollTop = $("#luckysheet-rows-h").scrollTop();
  2959. let y = mouse[1] + scrollTop;
  2960. let winH = $(window).height();
  2961. let row_location = rowLocation(y),
  2962. row = row_location[1],
  2963. row_pre = row_location[0],
  2964. row_index = row_location[2];
  2965. let size = (y + 3) - Store.luckysheet_rows_change_size_start[0];
  2966. if ((y + 3) - Store.luckysheet_rows_change_size_start[0] < 19) {
  2967. size = 19;
  2968. }
  2969. if (y >= winH - 200 + scrollTop) {
  2970. size = winH - 200 - Store.luckysheet_rows_change_size_start[0] + scrollTop;
  2971. }
  2972. let cfg = $.extend(true, {}, Store.config);
  2973. if (cfg["rowlen"] == null) {
  2974. cfg["rowlen"] = {};
  2975. }
  2976. if (cfg["customHeight"] == null) {
  2977. cfg["customHeight"] = {};
  2978. }
  2979. cfg["customHeight"][Store.luckysheet_rows_change_size_start[1]] = 1;
  2980. const changeRowIndex = Store.luckysheet_rows_change_size_start[1];
  2981. let changeRowSelected = false;
  2982. if(Store["luckysheet_select_save"].length > 0) {
  2983. Store["luckysheet_select_save"].filter(select => select.row_select).some((select) => {
  2984. if(changeRowIndex >= select.row[0] && changeRowIndex <= select.row[1]) {
  2985. changeRowSelected = true;
  2986. }
  2987. return changeRowSelected;
  2988. });
  2989. }
  2990. if(changeRowSelected) {
  2991. Store["luckysheet_select_save"].filter(select => select.row_select).forEach(select => {
  2992. for(let r = select.row[0]; r <= select.row[1]; r++) {
  2993. cfg["rowlen"][r] = Math.ceil(size/Store.zoomRatio);
  2994. }
  2995. })
  2996. }
  2997. else {
  2998. cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
  2999. }
  3000. let images = imageCtrl.moveChangeSize("row", Store.luckysheet_rows_change_size_start[1], size);
  3001. if (Store.clearjfundo) {
  3002. Store.jfundo.length = 0;
  3003. Store.jfredo.push({
  3004. "type": "resize",
  3005. "ctrlType": "resizeR",
  3006. "sheetIndex": Store.currentSheetIndex,
  3007. "config": $.extend(true, {}, Store.config),
  3008. "curconfig": $.extend(true, {}, cfg),
  3009. "images": $.extend(true, {}, imageCtrl.images),
  3010. "curImages": $.extend(true, {}, images)
  3011. });
  3012. }
  3013. //config
  3014. Store.config = cfg;
  3015. Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
  3016. server.saveParam("cg", Store.currentSheetIndex, cfg["rowlen"], { "k": "rowlen" });
  3017. //images
  3018. Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].images = images;
  3019. server.saveParam("all", Store.currentSheetIndex, images, { "k": "images" });
  3020. imageCtrl.images = images;
  3021. imageCtrl.allImagesShow();
  3022. jfrefreshgrid_rhcw(Store.flowdata.length, null);
  3023. }
  3024. //改变列宽
  3025. if (Store.luckysheet_cols_change_size) {
  3026. Store.luckysheet_cols_change_size = false;
  3027. $("#luckysheet-change-size-line").hide();
  3028. $("#luckysheet-cols-change-size").css("opacity", 0);
  3029. $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "default");
  3030. let mouse = mouseposition(event.pageX, event.pageY);
  3031. let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft();
  3032. let x = mouse[0] + scrollLeft;
  3033. let winW = $(window).width();
  3034. let row_index = Store.visibledatarow.length - 1,
  3035. row = Store.visibledatarow[row_index],
  3036. row_pre = 0;
  3037. let col_location = colLocation(x),
  3038. col = col_location[1],
  3039. col_pre = col_location[0],
  3040. col_index = col_location[2];
  3041. let size = (x + 3) - Store.luckysheet_cols_change_size_start[0];
  3042. let firstcolumnlen = Store.defaultcollen;
  3043. if (Store.config["columnlen"] != null && Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]] != null) {
  3044. firstcolumnlen = Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]];
  3045. }
  3046. if (Math.abs(size - firstcolumnlen) < 3) {
  3047. return;
  3048. }
  3049. if ((x + 3) - Store.luckysheet_cols_change_size_start[0] < 30) {
  3050. size = 30;
  3051. }
  3052. if (x >= winW - 100 + scrollLeft) {
  3053. size = winW - 100 - Store.luckysheet_cols_change_size_start[0] + scrollLeft;
  3054. }
  3055. let cfg = $.extend(true, {}, Store.config);
  3056. if (cfg["columnlen"] == null) {
  3057. cfg["columnlen"] = {};
  3058. }
  3059. if (cfg["customWidth"] == null) {
  3060. cfg["customWidth"] = {};
  3061. }
  3062. cfg["customWidth"][Store.luckysheet_cols_change_size_start[1]] = 1;
  3063. const changeColumnIndex = Store.luckysheet_cols_change_size_start[1];
  3064. let changeColumnSelected = false;
  3065. if(Store["luckysheet_select_save"].length > 0) {
  3066. Store["luckysheet_select_save"].filter(select => select.column_select).some((select) => {
  3067. if(changeColumnIndex >= select.column[0] && changeColumnIndex <= select.column[1]) {
  3068. changeColumnSelected = true;
  3069. }
  3070. return changeColumnSelected;
  3071. });
  3072. }
  3073. if(changeColumnSelected) {
  3074. Store["luckysheet_select_save"].filter(select => select.column_select).forEach(select => {
  3075. for(let r = select.column[0]; r <= select.column[1]; r++) {
  3076. cfg["columnlen"][r] = Math.ceil(size/Store.zoomRatio);
  3077. }
  3078. })
  3079. }
  3080. else {
  3081. cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
  3082. }
  3083. let images = imageCtrl.moveChangeSize("column", Store.luckysheet_cols_change_size_start[1], size);
  3084. if (Store.clearjfundo) {
  3085. Store.jfundo.length = 0;
  3086. Store.jfredo.push({
  3087. "type": "resize",
  3088. "ctrlType": "resizeC",
  3089. "sheetIndex": Store.currentSheetIndex,
  3090. "config": $.extend(true, {}, Store.config),
  3091. "curconfig": $.extend(true, {}, cfg),
  3092. "images": $.extend(true, {}, imageCtrl.images),
  3093. "curImages": $.extend(true, {}, images)
  3094. });
  3095. }
  3096. //config
  3097. Store.config = cfg;
  3098. Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
  3099. server.saveParam("cg", Store.currentSheetIndex, cfg["columnlen"], { "k": "columnlen" });
  3100. //images
  3101. Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].images = images;
  3102. server.saveParam("all", Store.currentSheetIndex, images, { "k": "images" });
  3103. imageCtrl.images = images;
  3104. imageCtrl.allImagesShow();
  3105. jfrefreshgrid_rhcw(null, Store.flowdata[0].length);
  3106. setTimeout(function () {
  3107. luckysheetrefreshgrid();
  3108. }, 1);
  3109. }
  3110. if (formula.rangeMove) {
  3111. formula.rangeMoveDragged(formula.rangeMoveObj);
  3112. }
  3113. //改变选择框的位置并替换目标单元格
  3114. if (Store.luckysheet_cell_selected_move) {
  3115. $("#luckysheet-cell-selected-move").hide();
  3116. Store.luckysheet_cell_selected_move = false;
  3117. let mouse = mouseposition(event.pageX, event.pageY);
  3118. if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){
  3119. return;
  3120. }
  3121. let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  3122. let scrollTop = $("#luckysheet-cell-main").scrollTop();
  3123. let x = mouse[0] + scrollLeft;
  3124. let y = mouse[1] + scrollTop;
  3125. let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
  3126. winW = $(window).width() + scrollLeft;
  3127. let row_index = rowLocation(y)[2];
  3128. let col_index = colLocation(x)[2];
  3129. let row_index_original = Store.luckysheet_cell_selected_move_index[0],
  3130. col_index_original = Store.luckysheet_cell_selected_move_index[1];
  3131. if (row_index == row_index_original && col_index == col_index_original) {
  3132. return;
  3133. }
  3134. let d = editor.deepCopyFlowData(Store.flowdata);
  3135. let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
  3136. let data = getdatabyselection(last);
  3137. let cfg = $.extend(true, {}, Store.config);
  3138. if (cfg["merge"] == null) {
  3139. cfg["merge"] = {};
  3140. }
  3141. if (cfg["rowlen"] == null) {
  3142. cfg["rowlen"] = {};
  3143. }
  3144. //选区包含部分单元格
  3145. if (hasPartMC(cfg, last["row"][0], last["row"][1], last["column"][0], last["column"][1])) {
  3146. if (isEditMode()) {
  3147. alert(locale_drag.noMerge);
  3148. }
  3149. else {
  3150. tooltip.info('<i class="fa fa-exclamation-triangle"></i>', locale_drag.noMerge);
  3151. }
  3152. return;
  3153. }
  3154. let row_s = last["row"][0] - row_index_original + row_index,
  3155. row_e = last["row"][1] - row_index_original + row_index;
  3156. let col_s = last["column"][0] - col_index_original + col_index,
  3157. col_e = last["column"][1] - col_index_original + col_index;
  3158. if(!checkProtectionLockedRangeList([{row:[row_s, row_e], column:[col_s, col_e]}], Store.currentSheetIndex)){
  3159. return;
  3160. }
  3161. if (row_s < 0 || y < 0) {
  3162. row_s = 0;
  3163. row_e = last["row"][1] - last["row"][0];
  3164. }
  3165. if (col_s < 0 || x < 0) {
  3166. col_s = 0;
  3167. col_e = last["column"][1] - last["column"][0];
  3168. }
  3169. if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
  3170. row_s = Store.visibledatarow.length - 1 - last["row"][1] + last["row"][0];
  3171. row_e = Store.visibledatarow.length - 1;
  3172. }
  3173. if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
  3174. col_s = Store.visibledatacolumn.length - 1 - last["column"][1] + last["column"][0];
  3175. col_e = Store.visibledatacolumn.length - 1;
  3176. }
  3177. //替换的位置包含部分单元格
  3178. if (hasPartMC(cfg, row_s, row_e, col_s, col_e)) {
  3179. if (isEditMode()) {
  3180. alert(locale_drag.noMerge);
  3181. }
  3182. else {
  3183. tooltip.info('<i class="fa fa-exclamation-triangle"></i>', locale_drag.noMerge);
  3184. }
  3185. return;
  3186. }
  3187. let borderInfoCompute = getBorderInfoCompute(Store.currentSheetIndex);
  3188. //删除原本位置的数据
  3189. let RowlChange = null;
  3190. for (let r = last["row"][0]; r <= last["row"][1]; r++) {
  3191. if (r in cfg["rowlen"]) {
  3192. RowlChange = true;
  3193. }
  3194. for (let c = last["column"][0]; c <= last["column"][1]; c++) {
  3195. let cell = d[r][c];
  3196. if (getObjType(cell) == "object" && ("mc" in cell)) {
  3197. if ((cell["mc"].r + "_" + cell["mc"].c) in cfg["merge"]) {
  3198. delete cfg["merge"][cell["mc"].r + "_" + cell["mc"].c];
  3199. }
  3200. }
  3201. d[r][c] = null;
  3202. }
  3203. }
  3204. //边框
  3205. if (cfg["borderInfo"] && cfg["borderInfo"].length > 0) {
  3206. let borderInfo = [];
  3207. for (let i = 0; i < cfg["borderInfo"].length; i++) {
  3208. let bd_rangeType = cfg["borderInfo"][i].rangeType;
  3209. if (bd_rangeType == "range") {
  3210. let bd_range = cfg["borderInfo"][i].range;
  3211. let bd_emptyRange = [];
  3212. for (let j = 0; j < bd_range.length; j++) {
  3213. bd_emptyRange = bd_emptyRange.concat(conditionformat.CFSplitRange(bd_range[j], { "row": last["row"], "column": last["column"] }, { "row": [row_s, row_e], "column": [col_s, col_e] }, "restPart"));
  3214. }
  3215. cfg["borderInfo"][i].range = bd_emptyRange;
  3216. borderInfo.push(cfg["borderInfo"][i]);
  3217. }
  3218. else if (bd_rangeType == "cell") {
  3219. let bd_r = cfg["borderInfo"][i].value.row_index;
  3220. let bd_c = cfg["borderInfo"][i].value.col_index;
  3221. if (!(bd_r >= last["row"][0] && bd_r <= last["row"][1] && bd_c >= last["column"][0] && bd_c <= last["column"][1])) {
  3222. borderInfo.push(cfg["borderInfo"][i]);
  3223. }
  3224. }
  3225. }
  3226. cfg["borderInfo"] = borderInfo;
  3227. }
  3228. //替换位置数据更新
  3229. let offsetMC = {};
  3230. for (let r = 0; r < data.length; r++) {
  3231. for (let c = 0; c < data[0].length; c++) {
  3232. if (borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])]) {
  3233. let bd_obj = {
  3234. "rangeType": "cell",
  3235. "value": {
  3236. "row_index": r + row_s,
  3237. "col_index": c + col_s,
  3238. "l": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].l,
  3239. "r": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].r,
  3240. "t": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].t,
  3241. "b": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].b
  3242. }
  3243. }
  3244. if (cfg["borderInfo"] == null) {
  3245. cfg["borderInfo"] = [];
  3246. }
  3247. cfg["borderInfo"].push(bd_obj);
  3248. }
  3249. let value = "";
  3250. if (data[r] != null && data[r][c] != null) {
  3251. value = data[r][c];
  3252. }
  3253. if (getObjType(value) == "object" && ("mc" in value)) {
  3254. let mc = $.extend(true, {}, value["mc"]);
  3255. if ("rs" in value["mc"]) {
  3256. offsetMC[mc.r + "_" + mc.c] = [r + row_s, c + col_s];
  3257. value["mc"].r = r + row_s;
  3258. value["mc"].c = c + col_s;
  3259. cfg["merge"][(r + row_s) + "_" + (c + col_s)] = value["mc"];
  3260. }
  3261. else {
  3262. value["mc"].r = offsetMC[mc.r + "_" + mc.c][0];
  3263. value["mc"].c = offsetMC[mc.r + "_" + mc.c][1];
  3264. }
  3265. }
  3266. d[r + row_s][c + col_s] = value;
  3267. }
  3268. }
  3269. if (RowlChange) {
  3270. cfg = rowlenByRange(d, last["row"][0], last["row"][1], cfg);
  3271. cfg = rowlenByRange(d, row_s, row_e, cfg);
  3272. }
  3273. //条件格式
  3274. let cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
  3275. if (cdformat != null && cdformat.length > 0) {
  3276. for (let i = 0; i < cdformat.length; i++) {
  3277. let cdformat_cellrange = cdformat[i].cellrange;
  3278. let emptyRange = [];
  3279. for (let j = 0; j < cdformat_cellrange.length; j++) {
  3280. let range = conditionformat.CFSplitRange(cdformat_cellrange[j], { "row": last["row"], "column": last["column"] }, { "row": [row_s, row_e], "column": [col_s, col_e] }, "allPart");
  3281. emptyRange = emptyRange.concat(range);
  3282. }
  3283. cdformat[i].cellrange = emptyRange;
  3284. }
  3285. }
  3286. let rf;
  3287. if (Store.luckysheet_select_save[0].row_focus == Store.luckysheet_select_save[0].row[0]) {
  3288. rf = row_s;
  3289. }
  3290. else {
  3291. rf = row_e;
  3292. }
  3293. let cf;
  3294. if (Store.luckysheet_select_save[0].column_focus == Store.luckysheet_select_save[0].column[0]) {
  3295. cf = col_s;
  3296. }
  3297. else {
  3298. cf = col_e;
  3299. }
  3300. let range = [];
  3301. range.push({ "row": last["row"], "column": last["column"] });
  3302. range.push({ "row": [row_s, row_e], "column": [col_s, col_e] });
  3303. last["row"] = [row_s, row_e];
  3304. last["column"] = [col_s, col_e];
  3305. last["row_focus"] = rf;
  3306. last["column_focus"] = cf;
  3307. let allParam = {
  3308. "cfg": cfg,
  3309. "RowlChange": RowlChange,
  3310. "cdformat": cdformat
  3311. }
  3312. jfrefreshgrid(d, range, allParam);
  3313. selectHightlightShow();
  3314. $("#luckysheet-sheettable").css("cursor", "default");
  3315. clearTimeout(Store.countfuncTimeout);
  3316. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  3317. }
  3318. //图表选区拖拽移动
  3319. if (Store.chart_selection.rangeMove) {
  3320. Store.chart_selection.rangeMoveDragged();
  3321. }
  3322. //图表选区拖拽拉伸
  3323. if (!!Store.chart_selection.rangeResize) {
  3324. Store.chart_selection.rangeResizeDragged();
  3325. }
  3326. //选区下拉
  3327. if (Store.luckysheet_cell_selected_extend) {
  3328. Store.luckysheet_cell_selected_extend = false;
  3329. $("#luckysheet-cell-selected-extend").hide();
  3330. if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){
  3331. return;
  3332. }
  3333. let mouse = mouseposition(event.pageX, event.pageY);
  3334. let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
  3335. let scrollTop = $("#luckysheet-cell-main").scrollTop();
  3336. let x = mouse[0] + scrollLeft - 5;
  3337. let y = mouse[1] + scrollTop - 5;
  3338. let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
  3339. winW = $(window).width() + scrollLeft;
  3340. let row_location = rowLocation(y),
  3341. row = row_location[1],
  3342. row_pre = row_location[0],
  3343. row_index = row_location[2];
  3344. let col_location = colLocation(x),
  3345. col = col_location[1],
  3346. col_pre = col_location[0],
  3347. col_index = col_location[2];
  3348. let row_index_original = Store.luckysheet_cell_selected_extend_index[0],
  3349. col_index_original = Store.luckysheet_cell_selected_extend_index[1];
  3350. let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
  3351. let row_s = last["row"][0], row_e = last["row"][1];
  3352. let col_s = last["column"][0], col_e = last["column"][1];
  3353. if (row_s < 0 || y < 0) {
  3354. row_s = 0;
  3355. row_e = last["row"][1] - last["row"][0];
  3356. }
  3357. if (col_s < 0 || x < 0) {
  3358. col_s = 0;
  3359. col_e = last["column"][1] - last["column"][0];
  3360. }
  3361. if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
  3362. row_s = Store.visibledatarow.length - 1 - last["row"][1] + last["row"][0];
  3363. row_e = Store.visibledatarow.length - 1;
  3364. }
  3365. if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
  3366. col_s = Store.visibledatacolumn.length - 1 - last["column"][1] + last["column"][0];
  3367. col_e = Store.visibledatacolumn.length - 1;
  3368. }
  3369. //复制范围
  3370. luckysheetDropCell.copyRange = { "row": $.extend(true, [], last["row"]), "column": $.extend(true, [], last["column"]) };
  3371. //applyType
  3372. let typeItemHide = luckysheetDropCell.typeItemHide();
  3373. if (!typeItemHide[0] && !typeItemHide[1] && !typeItemHide[2] && !typeItemHide[3] && !typeItemHide[4] && !typeItemHide[5] && !typeItemHide[6]) {
  3374. luckysheetDropCell.applyType = "0";
  3375. }
  3376. else {
  3377. luckysheetDropCell.applyType = "1";
  3378. }
  3379. if (Math.abs(row_index_original - row_index) > Math.abs(col_index_original - col_index)) {
  3380. if (!(row_index >= row_s && row_index <= row_e)) {
  3381. if (Store.luckysheet_select_save[0].top_move >= row_pre) {//当往上拖拽时
  3382. luckysheetDropCell.applyRange = { "row": [row_index, last["row"][0] - 1], "column": last["column"] };
  3383. luckysheetDropCell.direction = "up";
  3384. row_s -= last["row"][0] - row_index;
  3385. //是否有数据透视表范围
  3386. if (pivotTable.isPivotRange(row_s, col_e)) {
  3387. tooltip.info(locale_drag.affectPivot, "");
  3388. return;
  3389. }
  3390. }
  3391. else {//当往下拖拽时
  3392. luckysheetDropCell.applyRange = { "row": [last["row"][1] + 1, row_index], "column": last["column"] };
  3393. luckysheetDropCell.direction = "down";
  3394. row_e += row_index - last["row"][1];
  3395. //是否有数据透视表范围
  3396. if (pivotTable.isPivotRange(row_e, col_e)) {
  3397. tooltip.info(locale_drag.affectPivot, "");
  3398. return;
  3399. }
  3400. }
  3401. }
  3402. else {
  3403. return;
  3404. }
  3405. }
  3406. else {
  3407. if (!(col_index >= col_s && col_index <= col_e)) {
  3408. if (Store.luckysheet_select_save[0].left_move >= col_pre) {//当往左拖拽时
  3409. luckysheetDropCell.applyRange = { "row": last["row"], "column": [col_index, last["column"][0] - 1] };
  3410. luckysheetDropCell.direction = "left";
  3411. col_s -= last["column"][0] - col_index;
  3412. //是否有数据透视表范围
  3413. if (pivotTable.isPivotRange(row_e, col_s)) {
  3414. tooltip.info(locale_drag.affectPivot, "");
  3415. return;
  3416. }
  3417. }
  3418. else {//当往右拖拽时
  3419. luckysheetDropCell.applyRange = { "row": last["row"], "column": [last["column"][1] + 1, col_index] };
  3420. luckysheetDropCell.direction = "right";
  3421. col_e += col_index - last["column"][1];
  3422. //是否有数据透视表范围
  3423. if (pivotTable.isPivotRange(row_e, col_e)) {
  3424. tooltip.info(locale_drag.affectPivot, "");
  3425. return;
  3426. }
  3427. }
  3428. }
  3429. else {
  3430. return;
  3431. }
  3432. }
  3433. if (Store.config["merge"] != null) {
  3434. let hasMc = false;
  3435. for (let r = last["row"][0]; r <= last["row"][1]; r++) {
  3436. for (let c = last["column"][0]; c <= last["column"][1]; c++) {
  3437. let cell = Store.flowdata[r][c];
  3438. if (cell != null && cell.mc != null) {
  3439. hasMc = true;
  3440. break;
  3441. }
  3442. }
  3443. }
  3444. if (hasMc) {
  3445. if (isEditMode()) {
  3446. alert(locale_drag.noMerge);
  3447. }
  3448. else {
  3449. tooltip.info(locale_drag.noMerge, "");
  3450. }
  3451. return;
  3452. }
  3453. for (let r = row_s; r <= row_e; r++) {
  3454. for (let c = col_s; c <= col_e; c++) {
  3455. let cell = Store.flowdata[r][c];
  3456. if (cell != null && cell.mc != null) {
  3457. hasMc = true;
  3458. break;
  3459. }
  3460. }
  3461. }
  3462. if (hasMc) {
  3463. if (isEditMode()) {
  3464. alert(locale_drag.noMerge);
  3465. }
  3466. else {
  3467. tooltip.info(locale_drag.noMerge, "");
  3468. }
  3469. return;
  3470. }
  3471. }
  3472. last["row"] = [row_s, row_e];
  3473. last["column"] = [col_s, col_e];
  3474. luckysheetDropCell.update();
  3475. luckysheetDropCell.createIcon();
  3476. $("#luckysheet-cell-selected-move").hide();
  3477. $("#luckysheet-sheettable").css("cursor", "default");
  3478. clearTimeout(Store.countfuncTimeout);
  3479. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  3480. }
  3481. });
  3482. //禁止浏览器 右键默认菜单
  3483. $(".luckysheet-grid-container, #luckysheet-rightclick-menu").on("contextmenu", function (e) {
  3484. e.preventDefault();
  3485. });
  3486. // //禁止前台编辑(只可 框选单元格、滚动查看表格)
  3487. // if(!Store.allowEdit){
  3488. // return;
  3489. // }
  3490. //选区拖动替换
  3491. $("#luckysheet-cell-main div.luckysheet-cs-draghandle").mousedown(function (event) {
  3492. if(isEditMode() || Store.allowEdit===false){//此模式下禁用选区拖动
  3493. return;
  3494. }
  3495. $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
  3496. .css("cursor", "move")
  3497. .end()
  3498. .find(".luckysheet-cs-draghandle")
  3499. .css("cursor", "move");
  3500. $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor", "move");
  3501. Store.luckysheet_cell_selected_move = true;
  3502. Store.luckysheet_scroll_status = true;
  3503. let mouse = mouseposition(event.pageX, event.pageY);
  3504. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  3505. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  3506. let row_location = rowLocation(y),
  3507. row_pre = row_location[0],
  3508. row = row_location[1],
  3509. row_index = row_location[2];
  3510. let col_location = colLocation(x),
  3511. col_pre = col_location[0],
  3512. col = col_location[1],
  3513. col_index = col_location[2];
  3514. Store.luckysheet_cell_selected_move_index = [row_index, col_index];
  3515. $("#luckysheet-cell-selected-move").css({
  3516. "left": col_pre,
  3517. "width": col - col_pre - 1,
  3518. "top": row_pre,
  3519. "height": row - row_pre - 1,
  3520. "display": "block"
  3521. });
  3522. event.stopPropagation();
  3523. });
  3524. //选区下拉
  3525. $("#luckysheet-cell-main div.luckysheet-cs-fillhandle").mousedown(function (event) {
  3526. if(isEditMode() || Store.allowEdit===false){//此模式下禁用选区下拉
  3527. return;
  3528. }
  3529. $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
  3530. .css("cursor", "crosshair")
  3531. .end()
  3532. .find(".luckysheet-cs-draghandle")
  3533. .css("cursor", "crosshair");
  3534. $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor", "crosshair");
  3535. Store.luckysheet_cell_selected_extend_time = setTimeout(function () {
  3536. Store.luckysheet_cell_selected_extend = true;
  3537. Store.luckysheet_scroll_status = true;
  3538. let mouse = mouseposition(event.pageX, event.pageY);
  3539. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft() - 5;
  3540. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop() - 5;
  3541. let row_location = rowLocation(y),
  3542. row_pre = row_location[0],
  3543. row = row_location[1],
  3544. row_index = row_location[2];
  3545. let col_location = colLocation(x),
  3546. col_pre = col_location[0],
  3547. col = col_location[1],
  3548. col_index = col_location[2];
  3549. Store.luckysheet_cell_selected_extend_index = [row_index, col_index];
  3550. $("#luckysheet-cell-selected-extend").css({
  3551. "left": col_pre,
  3552. "width": col - col_pre - 1,
  3553. "top": row_pre,
  3554. "height": row - row_pre - 1,
  3555. "display": "block"
  3556. });
  3557. }, 100);
  3558. event.stopPropagation();
  3559. }).click(function () {
  3560. clearTimeout(Store.luckysheet_cell_selected_extend_time);
  3561. event.stopPropagation();
  3562. }).dblclick(function () {
  3563. let last = Store.luckysheet_select_save[0];
  3564. let r0 = last.row[0],
  3565. r1 = last.row[1],
  3566. c0 = last.column[0],
  3567. c1 = last.column[1];
  3568. if (pivotTable.isPivotRange(r0, c0)) {
  3569. return;
  3570. }
  3571. let dropCellState = false;
  3572. let step = 0;
  3573. for (let r = r1 + 1; r < Store.flowdata.length; r++) {
  3574. if (c0 - 1 >= 0 && c1 + 1 < Store.flowdata[0].length) {
  3575. let cell1 = Store.flowdata[r][c0 - 1];
  3576. let cell2 = Store.flowdata[r][c1 + 1];
  3577. if (r == r1 + 1) {
  3578. if ((cell1 == null || isRealNull(cell1.v)) && (cell2 == null || isRealNull(cell2.v))) {
  3579. dropCellState = false;
  3580. break;
  3581. }
  3582. else {
  3583. dropCellState = true;
  3584. step++;
  3585. }
  3586. }
  3587. else {
  3588. if ((cell1 == null || isRealNull(cell1.v)) && (cell2 == null || isRealNull(cell2.v))) {
  3589. break;
  3590. }
  3591. step++;
  3592. }
  3593. }
  3594. else if (c0 - 1 >= 0) {
  3595. let cell = Store.flowdata[r][c0 - 1];
  3596. if (r == r1 + 1) {
  3597. if (cell == null || isRealNull(cell.v)) {
  3598. dropCellState = false;
  3599. break;
  3600. }
  3601. else {
  3602. dropCellState = true;
  3603. step++;
  3604. }
  3605. }
  3606. else {
  3607. if (cell == null || isRealNull(cell.v)) {
  3608. break;
  3609. }
  3610. step++;
  3611. }
  3612. }
  3613. else if (c1 + 1 < Store.flowdata[0].length) {
  3614. let cell = Store.flowdata[r][c1 + 1];
  3615. if (r == r1 + 1) {
  3616. if (cell == null || isRealNull(cell.v)) {
  3617. dropCellState = false;
  3618. break;
  3619. }
  3620. else {
  3621. dropCellState = true;
  3622. step++;
  3623. }
  3624. }
  3625. else {
  3626. if (cell == null || isRealNull(cell.v)) {
  3627. break;
  3628. }
  3629. step++;
  3630. }
  3631. }
  3632. }
  3633. if (!dropCellState || step == 0) {
  3634. event.stopPropagation();
  3635. return;
  3636. }
  3637. //复制范围
  3638. luckysheetDropCell.copyRange = { "row": [r0, r1], "column": [c0, c1] };
  3639. //applyType
  3640. let typeItemHide = luckysheetDropCell.typeItemHide();
  3641. if (!typeItemHide[0] && !typeItemHide[1] && !typeItemHide[2] && !typeItemHide[3] && !typeItemHide[4] && !typeItemHide[5] && !typeItemHide[6]) {
  3642. luckysheetDropCell.applyType = "0";
  3643. }
  3644. else {
  3645. luckysheetDropCell.applyType = "1";
  3646. }
  3647. luckysheetDropCell.applyRange = { "row": [r1 + 1, r1 + step], "column": [c0, c1] };
  3648. luckysheetDropCell.direction = "down";
  3649. Store.luckysheet_select_save = [{ "row": [r0, r1 + step], "column": [c0, c1] }];
  3650. luckysheetDropCell.update();
  3651. luckysheetDropCell.createIcon();
  3652. $("#luckysheet-cell-selected-move").hide();
  3653. $("#luckysheet-sheettable").css("cursor", "default");
  3654. clearTimeout(Store.countfuncTimeout);
  3655. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  3656. event.stopPropagation();
  3657. });
  3658. //
  3659. $("#luckysheet-bottom-add-row, #luckysheet-bottom-add-row-input, #luckysheet-bottom-return-top").on("mousedown dblclick mouseup", function (e) {
  3660. e.stopPropagation();
  3661. });
  3662. //底部添加行按钮
  3663. $("#luckysheet-bottom-add-row").on("click", function (e) {
  3664. $("#luckysheet-rightclick-menu").hide();
  3665. luckysheetContainerFocus();
  3666. let $t = $(this), value = $("#luckysheet-bottom-add-row-input").val();
  3667. if (value == "") {
  3668. value = luckysheetConfigsetting.addRowCount || 100;
  3669. }
  3670. if (isNaN(parseInt(value))) {
  3671. if (isEditMode()) {
  3672. alert(locale_info.tipInputNumber);
  3673. }
  3674. else {
  3675. tooltip.info("error", locale_info.tipInputNumber);
  3676. }
  3677. return;
  3678. }
  3679. value = parseInt(value);
  3680. if (value < 1 || value > 100) {
  3681. if (isEditMode()) {
  3682. alert(locale_info.tipInputNumberLimit);
  3683. }
  3684. else {
  3685. tooltip.info("error", locale_info.tipInputNumberLimit);
  3686. }
  3687. return;
  3688. }
  3689. luckysheetextendtable("row", Store.flowdata.length - 1, value);
  3690. });
  3691. $("#luckysheet-bottom-return-top").on("click", function (e) {
  3692. $("#luckysheet-scrollbar-y").scrollTop(0);
  3693. });
  3694. //右键菜单 复制按钮
  3695. $("#luckysheet-copy-btn, #luckysheet-cols-copy-btn, #luckysheet-paste-btn-title").click(function (event) {
  3696. $(this).parent().hide();
  3697. //复制范围内包含部分合并单元格,提示
  3698. if (Store.config["merge"] != null) {
  3699. let has_PartMC = false;
  3700. for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
  3701. let r1 = Store.luckysheet_select_save[s].row[0],
  3702. r2 = Store.luckysheet_select_save[s].row[1];
  3703. let c1 = Store.luckysheet_select_save[s].column[0],
  3704. c2 = Store.luckysheet_select_save[s].column[1];
  3705. has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2);
  3706. if (has_PartMC) {
  3707. break;
  3708. }
  3709. }
  3710. if (has_PartMC) {
  3711. if (isEditMode()) {
  3712. alert(locale_drag.noPartMerge);
  3713. }
  3714. else {
  3715. tooltip.info(locale_drag.noPartMerge, "");
  3716. }
  3717. return;
  3718. }
  3719. }
  3720. //多重选区 有条件格式时 提示
  3721. let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save;
  3722. if (Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0) {
  3723. let hasCF = false;
  3724. let cf_compute = conditionformat.getComputeMap();
  3725. label:
  3726. for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
  3727. if (hasCF) {
  3728. break;
  3729. }
  3730. let r1 = Store.luckysheet_select_save[s].row[0],
  3731. r2 = Store.luckysheet_select_save[s].row[1];
  3732. let c1 = Store.luckysheet_select_save[s].column[0],
  3733. c2 = Store.luckysheet_select_save[s].column[1];
  3734. for (let r = r1; r <= r2; r++) {
  3735. for (let c = c1; c <= c2; c++) {
  3736. if (conditionformat.checksCF(r, c, cf_compute) != null) {
  3737. hasCF = true;
  3738. continue label;
  3739. }
  3740. }
  3741. }
  3742. }
  3743. if (hasCF) {
  3744. if (isEditMode()) {
  3745. alert(locale_drag.noMulti);
  3746. }
  3747. else {
  3748. tooltip.info(locale_drag.noMulti, "");
  3749. }
  3750. return;
  3751. }
  3752. }
  3753. //多重选区 行不一样且列不一样时 提示
  3754. if (Store.luckysheet_select_save.length > 1) {
  3755. let isSameRow = true,
  3756. str_r = Store.luckysheet_select_save[0].row[0],
  3757. end_r = Store.luckysheet_select_save[0].row[1];
  3758. let isSameCol = true,
  3759. str_c = Store.luckysheet_select_save[0].column[0],
  3760. end_c = Store.luckysheet_select_save[0].column[1];
  3761. for (let s = 1; s < Store.luckysheet_select_save.length; s++) {
  3762. if (Store.luckysheet_select_save[s].row[0] != str_r || Store.luckysheet_select_save[s].row[1] != end_r) {
  3763. isSameRow = false;
  3764. }
  3765. if (Store.luckysheet_select_save[s].column[0] != str_c || Store.luckysheet_select_save[s].column[1] != end_c) {
  3766. isSameCol = false;
  3767. }
  3768. }
  3769. if ((!isSameRow && !isSameCol) || selectIsOverlap()) {
  3770. if (isEditMode()) {
  3771. alert(locale_drag.noMulti);
  3772. }
  3773. else {
  3774. tooltip.info(locale_drag.noMulti, "");
  3775. }
  3776. return;
  3777. }
  3778. }
  3779. selection.copy(event);
  3780. });
  3781. //右键菜单 粘贴按钮
  3782. $("#luckysheet-copy-paste, #luckysheet-cols-paste-btn, #luckysheet-paste-btn-title").click(function (event) {
  3783. selection.paste(event, "btn");
  3784. $(this).parent().hide();
  3785. });
  3786. //Menu bar, Chart button
  3787. $("#luckysheet-chart-btn-title").click(function () {
  3788. createLuckyChart();
  3789. });
  3790. // Right-click the menu, chart generation
  3791. $("#luckysheetdatavisual").click(function () {
  3792. createLuckyChart();
  3793. $("#luckysheet-rightclick-menu").hide();
  3794. });
  3795. //菜单栏 数据透视表
  3796. $("#luckysheet-pivot-btn-title").click(function (e) {
  3797. if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "usePivotTablereports")){
  3798. return;
  3799. }
  3800. pivotTable.createPivotTable(e);
  3801. });
  3802. //菜单栏 截图按钮
  3803. $("#luckysheet-chart-btn-screenshot").click(function () {
  3804. const locale_screenshot = _locale.screenshot;
  3805. if (Store.luckysheet_select_save.length == 0) {
  3806. if (isEditMode()) {
  3807. alert(locale_screenshot.screenshotTipNoSelection);
  3808. }
  3809. else {
  3810. tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipNoSelection);
  3811. }
  3812. return;
  3813. }
  3814. if (Store.luckysheet_select_save.length > 1) {
  3815. if (isEditMode()) {
  3816. alert(locale_screenshot.screenshotTipHasMulti);
  3817. }
  3818. else {
  3819. tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMulti);
  3820. }
  3821. return;
  3822. }
  3823. //截图范围内包含部分合并单元格,提示
  3824. if (Store.config["merge"] != null) {
  3825. let has_PartMC = false;
  3826. for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
  3827. let r1 = Store.luckysheet_select_save[s].row[0],
  3828. r2 = Store.luckysheet_select_save[s].row[1];
  3829. let c1 = Store.luckysheet_select_save[s].column[0],
  3830. c2 = Store.luckysheet_select_save[s].column[1];
  3831. has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2);
  3832. if (has_PartMC) {
  3833. break;
  3834. }
  3835. }
  3836. if (has_PartMC) {
  3837. if (isEditMode()) {
  3838. alert(locale_screenshot.screenshotTipHasMerge);
  3839. }
  3840. else {
  3841. tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMerge);
  3842. }
  3843. return;
  3844. }
  3845. }
  3846. let st_r = Store.luckysheet_select_save[0].row[0],
  3847. ed_r = Store.luckysheet_select_save[0].row[1];
  3848. let st_c = Store.luckysheet_select_save[0].column[0],
  3849. ed_c = Store.luckysheet_select_save[0].column[1];
  3850. let scrollHeight, rh_height;
  3851. if (st_r - 1 < 0) {
  3852. scrollHeight = 0;
  3853. rh_height = Store.visibledatarow[ed_r];
  3854. }
  3855. else {
  3856. scrollHeight = Store.visibledatarow[st_r - 1];
  3857. rh_height = Store.visibledatarow[ed_r] - Store.visibledatarow[st_r - 1];
  3858. }
  3859. let scrollWidth, ch_width;
  3860. if (st_c - 1 < 0) {
  3861. scrollWidth = 0;
  3862. ch_width = Store.visibledatacolumn[ed_c];
  3863. }
  3864. else {
  3865. scrollWidth = Store.visibledatacolumn[st_c - 1];
  3866. ch_width = Store.visibledatacolumn[ed_c] - Store.visibledatacolumn[st_c - 1];
  3867. }
  3868. let newCanvas = $("<canvas>").attr({
  3869. width: Math.ceil(ch_width * devicePixelRatio),
  3870. height: Math.ceil(rh_height * devicePixelRatio)
  3871. }).css({ width: ch_width, height: rh_height });
  3872. luckysheetDrawMain(scrollWidth, scrollHeight, ch_width, rh_height, 1, 1, null, null, newCanvas);
  3873. let ctx_newCanvas = newCanvas.get(0).getContext("2d");
  3874. //补上 左边框和上边框
  3875. ctx_newCanvas.beginPath();
  3876. ctx_newCanvas.moveTo(
  3877. 0,
  3878. 0
  3879. );
  3880. ctx_newCanvas.lineTo(
  3881. 0,
  3882. Store.devicePixelRatio * rh_height
  3883. );
  3884. ctx_newCanvas.lineWidth = Store.devicePixelRatio * 2;
  3885. ctx_newCanvas.strokeStyle = luckysheetdefaultstyle.strokeStyle;
  3886. ctx_newCanvas.stroke();
  3887. ctx_newCanvas.closePath();
  3888. ctx_newCanvas.beginPath();
  3889. ctx_newCanvas.moveTo(
  3890. 0,
  3891. 0
  3892. );
  3893. ctx_newCanvas.lineTo(
  3894. Store.devicePixelRatio * ch_width,
  3895. 0
  3896. );
  3897. ctx_newCanvas.lineWidth = Store.devicePixelRatio * 2;
  3898. ctx_newCanvas.strokeStyle = luckysheetdefaultstyle.strokeStyle;
  3899. ctx_newCanvas.stroke();
  3900. ctx_newCanvas.closePath();
  3901. let image = new Image();
  3902. let url = newCanvas.get(0).toDataURL("image/png");
  3903. image.src = url;
  3904. if (ch_width > rh_height) {
  3905. image.style.width = "100%";
  3906. }
  3907. else {
  3908. image.style.height = "100%";
  3909. }
  3910. let maxHeight = $(window).height() - 200;
  3911. tooltip.screenshot(locale_screenshot.screenshotTipSuccess, '<div id="luckysheet-confirm-screenshot-save" style="height:' + maxHeight + 'px;overflow:auto;"></div>', url);
  3912. $("#luckysheet-confirm-screenshot-save").append(image);
  3913. newCanvas.remove();
  3914. });
  3915. //截图下载
  3916. $(document).on("click.luckysheetEvent", "a.download", function () {
  3917. let dataURI = $("#luckysheet-confirm-screenshot-save img").attr("src");
  3918. const locale_screenshot = _locale.screenshot;
  3919. let binStr = atob(dataURI.split(",")[1]),
  3920. len = binStr.length,
  3921. arr = new Uint8Array(len);
  3922. for (let i = 0; i < len; i++) {
  3923. arr[i] = binStr.charCodeAt(i);
  3924. }
  3925. let blob = new Blob([arr]);
  3926. let element = document.createElement('a');
  3927. element.setAttribute('href', URL.createObjectURL(blob));
  3928. element.setAttribute('download', locale_screenshot.screenshotImageName + '.png');
  3929. element.style.display = 'none';
  3930. document.body.appendChild(element);
  3931. element.click();
  3932. let clickHandler;
  3933. element.addEventListener('click', clickHandler = function () {
  3934. requestAnimationFrame(function () {
  3935. URL.revokeObjectURL(element.href);
  3936. });
  3937. element.removeAttribute('href');
  3938. element.removeEventListener('click', clickHandler);
  3939. })
  3940. document.body.removeChild(element);
  3941. })
  3942. //菜单栏 分列按钮
  3943. $("#luckysheet-splitColumn-btn-title").click(function () {
  3944. if(!checkProtectionNotEnable(Store.currentSheetIndex)){
  3945. return;
  3946. }
  3947. if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
  3948. return;
  3949. }
  3950. const locale_splitText = _locale.splitText;
  3951. if (Store.luckysheet_select_save.length > 1) {
  3952. tooltip.info(locale_splitText.tipNoMulti, "");
  3953. return;
  3954. }
  3955. if (Store.luckysheet_select_save[0].column[0] != Store.luckysheet_select_save[0].column[1]) {
  3956. tooltip.info(locale_splitText.tipNoMultiColumn, "");
  3957. return;
  3958. }
  3959. splitColumn.createDialog();
  3960. splitColumn.init();
  3961. });
  3962. //菜单栏 插入图片按钮
  3963. $("#luckysheet-insertImg-btn-title").click(function () {
  3964. // *如果禁止前台编辑,则中止下一步操作
  3965. if (!checkIsAllowEdit()) {
  3966. tooltip.info("", locale().pivotTable.errorNotAllowEdit);
  3967. return
  3968. }
  3969. if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
  3970. return;
  3971. }
  3972. $("#luckysheet-imgUpload").click();
  3973. });
  3974. $("#luckysheetInsertImage").click(function () {
  3975. if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
  3976. return;
  3977. }
  3978. $("#luckysheet-imgUpload").click();
  3979. $("#luckysheet-rightclick-menu").hide();
  3980. })
  3981. $("#luckysheet-imgUpload").click(function (e) {
  3982. e.stopPropagation();
  3983. });
  3984. $("#luckysheet-imgUpload").on("change", function(e){
  3985. if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects",false)){
  3986. return;
  3987. }
  3988. let file = e.currentTarget.files[0];
  3989. imageCtrl.insertImg(file);
  3990. });
  3991. //菜单栏 插入链接按钮
  3992. $("#luckysheet-insertLink-btn-title").click(function () {
  3993. // *如果禁止前台编辑,则中止下一步操作
  3994. if (!checkIsAllowEdit()) {
  3995. tooltip.info("", locale().pivotTable.errorNotAllowEdit);
  3996. return
  3997. }
  3998. if(!checkProtectionNotEnable(Store.currentSheetIndex)){
  3999. return;
  4000. }
  4001. if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
  4002. return;
  4003. }
  4004. hyperlinkCtrl.createDialog();
  4005. hyperlinkCtrl.init();
  4006. })
  4007. $("#luckysheetInsertLink").click(function () {
  4008. $("#luckysheet-insertLink-btn-title").click();
  4009. $("#luckysheet-rightclick-menu").hide();
  4010. })
  4011. //菜单栏 数据验证按钮
  4012. $("#luckysheet-dataVerification-btn-title").click(function () {
  4013. if(!checkProtectionNotEnable(Store.currentSheetIndex)){
  4014. return;
  4015. }
  4016. if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
  4017. return;
  4018. }
  4019. dataVerificationCtrl.createDialog();
  4020. dataVerificationCtrl.init();
  4021. });
  4022. $("#luckysheetDataVerification").click(function () {
  4023. $("#luckysheet-dataVerification-btn-title").click();
  4024. $("#luckysheet-rightclick-menu").hide();
  4025. });
  4026. //Cell format
  4027. $("#luckysheetCellFormatRightClickMenu").click(function () {
  4028. openCellFormatModel();
  4029. });
  4030. //冻结行列
  4031. $("#luckysheet-freezen-btn-horizontal").click(function () {
  4032. if ($.trim($(this).text()) == locale().freezen.freezenCancel) {
  4033. luckysheetFreezen.saveFrozen("freezenCancel");
  4034. if (luckysheetFreezen.freezenverticaldata != null) {
  4035. luckysheetFreezen.cancelFreezenVertical();
  4036. luckysheetFreezen.createAssistCanvas();
  4037. luckysheetrefreshgrid();
  4038. }
  4039. if (luckysheetFreezen.freezenhorizontaldata != null) {
  4040. luckysheetFreezen.cancelFreezenHorizontal();
  4041. luckysheetFreezen.createAssistCanvas();
  4042. luckysheetrefreshgrid();
  4043. }
  4044. luckysheetFreezen.scrollAdapt();
  4045. // cancel 之后 勾勾取消
  4046. $('#luckysheet-icon-freezen-menu-menuButton').find('.fa.fa-check').remove();
  4047. }
  4048. else {
  4049. luckysheetFreezen.saveFrozen("freezenRow");
  4050. if (luckysheetFreezen.freezenverticaldata != null) {
  4051. luckysheetFreezen.cancelFreezenVertical();
  4052. luckysheetFreezen.createAssistCanvas();
  4053. luckysheetrefreshgrid();
  4054. }
  4055. if (luckysheetFreezen.freezenhorizontaldata == null) {
  4056. luckysheetFreezen.createFreezenHorizontal();
  4057. luckysheetFreezen.createAssistCanvas();
  4058. }
  4059. }
  4060. });
  4061. $("#luckysheet-freezen-btn-vertical").click(function () {
  4062. if (luckysheetFreezen.freezenverticaldata != null) {
  4063. luckysheetFreezen.saveFrozen("freezenCancel");
  4064. luckysheetFreezen.cancelFreezenVertical();
  4065. luckysheetrefreshgrid();
  4066. }
  4067. else {
  4068. luckysheetFreezen.saveFrozen("freezenColumn");
  4069. luckysheetFreezen.createFreezenVertical();
  4070. }
  4071. luckysheetFreezen.createAssistCanvas();
  4072. });
  4073. $("#luckysheet-rightclick-menu input").on("keydown", function (e) {
  4074. e.stopPropagation();
  4075. });
  4076. $("#luckysheet-modal-dialog-mask").on("click dbclick mousedown mousemove mouseup", function (e) {
  4077. e.stopPropagation();
  4078. e.preventDefault();
  4079. });
  4080. let copychange = function () {
  4081. if (document.hidden || document.webkitHidden || document.msHidden) {
  4082. Store.iscopyself = false;
  4083. }
  4084. }
  4085. $(document).on("visibilitychange.luckysheetEvent webkitvisibilitychange.luckysheetEvent msvisibilitychange.luckysheetEvent", copychange).on("mouseleave.luckysheetEvent", function () {
  4086. Store.iscopyself = false;
  4087. }).on("mousedown.luckysheetEvent", function (event) {
  4088. //有批注在编辑时
  4089. luckysheetPostil.removeActivePs();
  4090. hideMenuByCancel(event);
  4091. //点击功能栏时 如果是单元格编辑模式 则退出编辑模式
  4092. if ($(event.target).closest("#luckysheet-wa-editor").length > 0 && parseInt($("#luckysheet-input-box").css("top")) > 0) {
  4093. formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
  4094. luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
  4095. }
  4096. });
  4097. //表格左上角点击 全选表格
  4098. $("#luckysheet-left-top").click(function (event) {
  4099. if(!checkProtectionAllSelected(Store.currentSheetIndex)){
  4100. return;
  4101. }
  4102. $("#luckysheet-wa-functionbox-confirm").click();
  4103. Store.luckysheet_select_status = false;
  4104. Store.luckysheet_select_save = [{ "row": [0, Store.flowdata.length - 1], "column": [0, Store.flowdata[0].length - 1], "row_focus": 0, "column_focus": 0, row_select: true, column_select: true }];
  4105. selectHightlightShow();
  4106. clearTimeout(Store.countfuncTimeout);
  4107. Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
  4108. /* 选中区域:发送网络请求 */
  4109. server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
  4110. event.stopPropagation();
  4111. });
  4112. //回退 重做 按钮
  4113. $("#luckysheet-icon-undo").click(function (event) {
  4114. if ($(this).hasClass('disabled')) {
  4115. return;
  4116. }
  4117. controlHistory.redo(event);
  4118. });
  4119. $("#luckysheet-icon-redo").click(function (event) {
  4120. if ($(this).hasClass('disabled')) {
  4121. return;
  4122. }
  4123. controlHistory.undo(event);
  4124. });
  4125. //模态框拖动
  4126. $(document).on("mousedown.luckysheetEvent", "div.luckysheet-modal-dialog", function (e) {
  4127. if (!$(e.target).is(".luckysheet-modal-dialog")) {
  4128. return;
  4129. }
  4130. Store.luckysheet_model_move_state = true;
  4131. Store.luckysheet_model_move_obj = $(e.currentTarget);
  4132. let toffset = Store.luckysheet_model_move_obj.offset();
  4133. Store.luckysheet_model_xy = [e.pageX - toffset.left, e.pageY - toffset.top];
  4134. });
  4135. //模态框关闭
  4136. $(document).on("click.luckysheetEvent", ".luckysheet-modal-dialog-title-close, .luckysheet-model-close-btn", function (e) {
  4137. //选择文本颜色和单元格颜色弹出框取消
  4138. if ($("#textcolorselect").is(":visible") || $("#cellcolorselect").is(":visible")) {
  4139. $("#luckysheet-conditionformat-dialog").show();
  4140. }
  4141. $(e.currentTarget).parents(".luckysheet-modal-dialog").hide();
  4142. $("#luckysheet-modal-dialog-mask").hide();
  4143. //函数查找功能所有弹出框关闭和取消
  4144. if ($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula")) {
  4145. formula.dontupdate();
  4146. luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
  4147. }
  4148. if ($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm")) {
  4149. formula.dontupdate();
  4150. luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
  4151. }
  4152. if ($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm-select")) {
  4153. formula.dontupdate();
  4154. luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
  4155. }
  4156. luckysheetContainerFocus();
  4157. });
  4158. //左上角返回按钮
  4159. $("#luckysheet_info_detail_title").click(function () {
  4160. window.open(luckysheetConfigsetting.myFolderUrl, "_self");
  4161. });
  4162. //图表选区mousedown
  4163. $("#luckysheet-chart-rangeShow").on("mousedown.chartRangeShowMove", ".luckysheet-chart-rangeShow-move", function (event) {
  4164. Store.chart_selection.rangeMove = true;
  4165. Store.luckysheet_scroll_status = true;
  4166. Store.chart_selection.rangeMoveObj = $(this).parent();
  4167. let chart_json = Store.currentChart
  4168. let $id = $(this).parent().attr("id");
  4169. if ($id == "luckysheet-chart-rangeShow-content") {
  4170. let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.content.row[0];
  4171. let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.content.column[0];
  4172. Store.chart_selection.rangeMoveIndex = [row_s, col_s];
  4173. }
  4174. else if ($id == "luckysheet-chart-rangeShow-rowtitle") {
  4175. let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.rowtitle.row[0];
  4176. let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.rowtitle.column[0];
  4177. Store.chart_selection.rangeMoveIndex = [row_s, col_s];
  4178. }
  4179. else if ($id == "luckysheet-chart-rangeShow-coltitle") {
  4180. let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.coltitle.row[0];
  4181. let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.coltitle.column[0];
  4182. Store.chart_selection.rangeMoveIndex = [row_s, col_s];
  4183. }
  4184. let mouse = mouseposition(event.pageX, event.pageY);
  4185. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  4186. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  4187. let type = $(this).data("type");
  4188. if (type == "top") {
  4189. y += 3;
  4190. }
  4191. else if (type == "right") {
  4192. x -= 3;
  4193. }
  4194. else if (type == "bottom") {
  4195. y -= 3;
  4196. }
  4197. else if (type == "left") {
  4198. x += 3;
  4199. }
  4200. let row_index = rowLocation(y)[2];
  4201. let col_index = colLocation(x)[2];
  4202. Store.chart_selection.rangeMovexy = [row_index, col_index];
  4203. event.stopPropagation();
  4204. });
  4205. $("#luckysheet-chart-rangeShow").on("mousedown.chartRangeShowResize", ".luckysheet-chart-rangeShow-resize", function (event) {
  4206. Store.chart_selection.rangeResize = $(this).data("type");//开始状态resize
  4207. Store.luckysheet_scroll_status = true;
  4208. Store.chart_selection.rangeResizeObj = $(this).parent();
  4209. let chart_json = Store.currentChart
  4210. let row_s
  4211. let row_e
  4212. let col_s
  4213. let col_e
  4214. let $id = $(this).parent().attr("id");
  4215. if ($id == "luckysheet-chart-rangeShow-content") {
  4216. if (chart_json.rangeRowCheck.exits) {
  4217. row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.content.row[0];
  4218. row_e = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.content.row[1];
  4219. }
  4220. else {
  4221. row_s = chart_json.rangeSplitArray.content.row[0];
  4222. row_e = chart_json.rangeSplitArray.content.row[0];
  4223. }
  4224. if (chart_json.rangeColCheck.exits) {
  4225. col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.content.column[0];
  4226. col_e = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.content.column[1];
  4227. }
  4228. else {
  4229. col_s = chart_json.rangeSplitArray.content.column[0];
  4230. col_e = chart_json.rangeSplitArray.content.column[1];
  4231. }
  4232. Store.chart_selection.rangeResizeIndex = { "row": [row_s, row_e], "column": [col_s, col_e] };
  4233. }
  4234. else if ($id == "luckysheet-chart-rangeShow-rowtitle") {
  4235. let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.rowtitle.row[0];
  4236. let row_e = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.rowtitle.row[1];
  4237. let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.rowtitle.column[0];
  4238. let col_e = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.rowtitle.column[1];
  4239. Store.chart_selection.rangeResizeIndex = { "row": [row_s, row_e], "column": [col_s, col_e] };
  4240. }
  4241. else if ($id == "luckysheet-chart-rangeShow-coltitle") {
  4242. let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.coltitle.row[0];
  4243. let row_e = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.coltitle.row[1];
  4244. let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.coltitle.column[0];
  4245. let col_e = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.coltitle.column[1];
  4246. Store.chart_selection.rangeResizeIndex = { "row": [row_s, row_e], "column": [col_s, col_e] };
  4247. }
  4248. let mouse = mouseposition(event.pageX, event.pageY);
  4249. let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
  4250. let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
  4251. if (Store.chart_selection.rangeResize == "lt") {
  4252. x += 3;
  4253. y += 3;
  4254. }
  4255. else if (Store.chart_selection.rangeResize == "lb") {
  4256. x += 3;
  4257. y -= 3;
  4258. }
  4259. else if (Store.chart_selection.rangeResize == "rt") {
  4260. x -= 3;
  4261. y += 3;
  4262. }
  4263. else if (Store.chart_selection.rangeResize == "rb") {
  4264. x -= 3;
  4265. y -= 3;
  4266. }
  4267. let row_index = rowLocation(y)[2];
  4268. let col_index = colLocation(x)[2];
  4269. Store.chart_selection.rangeResizexy = [row_index, col_index];
  4270. event.stopPropagation();
  4271. })
  4272. $("#luckysheet-wa-calculate-size").mousedown(function (e) {
  4273. let y = e.pageY;
  4274. formula.functionResizeData.y = y;
  4275. formula.functionResizeStatus = true;
  4276. formula.functionResizeData.calculatebarHeight = Store.calculatebarHeight;
  4277. if (formula.rangetosheet != null) {
  4278. formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
  4279. }
  4280. });
  4281. // 点击设置字体大小的下拉箭头,把自动聚焦输入框去除(认为下拉设置字体大小,不需要聚焦输入框)
  4282. // //toolbar菜单
  4283. // $("#" + Store.container + " .luckysheet-wa-editor").on("click", ".luckysheet-toolbar-zoom-combobox", function (e) {
  4284. // $(e.currentTarget).addClass("luckysheet-toolbar-combo-button-open");
  4285. // $(e.currentTarget).find(".luckysheet-toolbar-combo-button-input").focus();
  4286. // });
  4287. // $("#" + Store.container + " .luckysheet-wa-editor").on("blur", ".luckysheet-toolbar-combo-button-input", function (e) {
  4288. // $(e.currentTarget).closest(".luckysheet-toolbar-zoom-combobox").removeClass("luckysheet-toolbar-combo-button-open");
  4289. // });
  4290. //表格格式处理
  4291. menuButton.initialMenuButton();
  4292. let dpi_x = document.getElementById('testdpidiv').offsetWidth * Store.devicePixelRatio;
  4293. let dpi_y = document.getElementById('testdpidiv').offsetHeight * Store.devicePixelRatio;
  4294. //粘贴事件处理
  4295. $(document).on("paste.luckysheetEvent", function (e) {
  4296. if (isEditMode()) {//此模式下禁用粘贴
  4297. return;
  4298. }
  4299. if (selection.isPasteAction) {
  4300. $("#luckysheet-rich-text-editor").blur();
  4301. selection.isPasteAction = false;
  4302. let clipboardData = window.clipboardData; //for IE
  4303. if (!clipboardData) { // for chrome
  4304. clipboardData = e.originalEvent.clipboardData;
  4305. }
  4306. let txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
  4307. //如果标示是qksheet复制的内容,判断剪贴板内容是否是当前页面复制的内容
  4308. let isEqual = true;
  4309. if (txtdata.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0) {
  4310. //剪贴板内容解析
  4311. let cpDataArr = [];
  4312. let reg = new RegExp('<tr.*?>(.*?)</tr>', 'gs');
  4313. let reg2 = new RegExp('<td.*?>(.*?)</td>', 'gs');
  4314. let regArr = txtdata.match(reg) || [];
  4315. for (let i = 0; i < regArr.length; i++) {
  4316. let cpRowArr = [];
  4317. let reg2Arr = regArr[i].match(reg2);
  4318. if (reg2Arr != null) {
  4319. for (let j = 0; j < reg2Arr.length; j++) {
  4320. let cpValue = reg2Arr[j].replace(/<td.*?>/gs, "").replace(/<\/td>/gs, "");
  4321. cpRowArr.push(cpValue);
  4322. }
  4323. }
  4324. cpDataArr.push(cpRowArr);
  4325. }
  4326. //当前页面复制区内容
  4327. let copy_r1 = Store.luckysheet_copy_save["copyRange"][0].row[0],
  4328. copy_r2 = Store.luckysheet_copy_save["copyRange"][0].row[1],
  4329. copy_c1 = Store.luckysheet_copy_save["copyRange"][0].column[0],
  4330. copy_c2 = Store.luckysheet_copy_save["copyRange"][0].column[1];
  4331. let copy_index = Store.luckysheet_copy_save["dataSheetIndex"];
  4332. let d;
  4333. if(copy_index == Store.currentSheetIndex){
  4334. d = editor.deepCopyFlowData(Store.flowdata);
  4335. }
  4336. else{
  4337. d = Store.luckysheetfile[getSheetIndex(copy_index)].data;
  4338. }
  4339. for(let r = copy_r1; r <= copy_r2; r++){
  4340. if(r - copy_r1 > cpDataArr.length - 1){
  4341. break;
  4342. }
  4343. for(let c = copy_c1; c <= copy_c2; c++){
  4344. let cell = d[r][c];
  4345. let isInlineStr = false
  4346. if(cell != null && cell.mc != null && cell.mc.rs == null){
  4347. continue;
  4348. }
  4349. let v;
  4350. if(cell != null){
  4351. if(cell.ct != null && cell.ct.fa.indexOf("w") > -1){
  4352. v = d[r][c].v;
  4353. }
  4354. else{
  4355. v = d[r][c].m;
  4356. }
  4357. }
  4358. else{
  4359. v = "";
  4360. }
  4361. if(v == null && d[r][c] && d[r][c].ct && d[r][c].ct.t == 'inlineStr') {
  4362. v = d[r][c].ct.s.map(val=>val.v).join('');
  4363. isInlineStr = true;
  4364. }
  4365. if(v == null){
  4366. v = "";
  4367. }
  4368. if(isInlineStr){
  4369. const cpData = $(cpDataArr[r - copy_r1][c - copy_c1]).text().replace(/\s|\n/g,' ')
  4370. const storeValue = v.replace(/\n/g,'').replace(/\s/g,' ')
  4371. if(cpData != storeValue){
  4372. isEqual = false;
  4373. break;
  4374. }
  4375. }
  4376. else{
  4377. if(cpDataArr[r - copy_r1][c - copy_c1] != v){
  4378. isEqual = false;
  4379. break;
  4380. }
  4381. }
  4382. }
  4383. }
  4384. }
  4385. const locale_fontjson = locale().fontjson;
  4386. // hook
  4387. if(!method.createHookFunction('rangePasteBefore',Store.luckysheet_select_save,txtdata)){
  4388. return;
  4389. }
  4390. if (txtdata.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0 && isEqual) {
  4391. //剪切板内容 和 luckysheet本身复制的内容 一致
  4392. if (Store.luckysheet_paste_iscut) {
  4393. Store.luckysheet_paste_iscut = false;
  4394. selection.pasteHandlerOfCutPaste(Store.luckysheet_copy_save);
  4395. selection.clearcopy(e);
  4396. }
  4397. else {
  4398. selection.pasteHandlerOfCopyPaste(Store.luckysheet_copy_save);
  4399. }
  4400. }
  4401. else if(txtdata.indexOf("luckysheet_copy_action_image") > - 1){
  4402. imageCtrl.pasteImgItem();
  4403. }
  4404. else {
  4405. if (txtdata.indexOf("table") > -1) {
  4406. $("#luckysheet-copy-content").html(txtdata);
  4407. let data = new Array($("#luckysheet-copy-content").find("table tr").length);
  4408. let colLen = 0;
  4409. const cellElements = "th, td";
  4410. $("#luckysheet-copy-content").find("table tr").eq(0).find(cellElements).each(function () {
  4411. let colspan = parseInt($(this).attr("colspan"));
  4412. if (isNaN(colspan)) {
  4413. colspan = 1;
  4414. }
  4415. colLen += colspan;
  4416. });
  4417. for (let i = 0; i < data.length; i++) {
  4418. data[i] = new Array(colLen);
  4419. }
  4420. let r = 0;
  4421. let borderInfo = {};
  4422. $("#luckysheet-copy-content").find("table tr").each(function () {
  4423. let $tr = $(this);
  4424. let c = 0;
  4425. $tr.find(cellElements).each(function () {
  4426. let $td = $(this);
  4427. let cell = {};
  4428. let txt = $td.text();
  4429. if ($.trim(txt).length == 0) {
  4430. cell.v = null;
  4431. cell.m = "";
  4432. }
  4433. else {
  4434. let mask = genarate($td.text());
  4435. cell.v = mask[2];
  4436. cell.ct = mask[1];
  4437. cell.m = mask[0];
  4438. }
  4439. let bg = $td.css("background-color");
  4440. if (bg == "rgba(0, 0, 0, 0)") {
  4441. bg = null;
  4442. }
  4443. cell.bg = bg;
  4444. let bl = $td.css("font-weight");
  4445. if (bl == 400 || bl == "normal") {
  4446. cell.bl = 0;
  4447. }
  4448. else {
  4449. cell.bl = 1;
  4450. }
  4451. // 检测下划线
  4452. let un = $td.css('text-decoration')
  4453. if (un.indexOf('underline') != -1) {
  4454. cell.un = 1;
  4455. }
  4456. let it = $td.css("font-style");
  4457. if (it == "normal") {
  4458. cell.it = 0;
  4459. }
  4460. else {
  4461. cell.it = 1;
  4462. }
  4463. let ff = $td.css("font-family");
  4464. let ffs = ff.split(",");
  4465. for (let i = 0; i < ffs.length; i++) {
  4466. let fa = $.trim(ffs[i].toLowerCase());
  4467. fa = locale_fontjson[fa];
  4468. if (fa == null) {
  4469. cell.ff = 0;
  4470. }
  4471. else {
  4472. cell.ff = fa;
  4473. break;
  4474. }
  4475. }
  4476. let fs = Math.round(parseInt($td.css("font-size")) * 72 / 96);
  4477. cell.fs = fs;
  4478. let fc = $td.css("color");
  4479. cell.fc = fc;
  4480. // 水平对齐属性
  4481. let ht = $td.css("text-align");
  4482. if (ht == "center") {
  4483. cell.ht = 0;
  4484. }
  4485. else if (ht == "right") {
  4486. cell.ht = 2;
  4487. }
  4488. else {
  4489. cell.ht = 1;
  4490. }
  4491. // 垂直对齐属性
  4492. let vt = $td.css("vertical-align");
  4493. if (vt == "middle") {
  4494. cell.vt = 0;
  4495. }
  4496. else if (vt == "top" || vt == "text-top") {
  4497. cell.vt = 1;
  4498. }
  4499. else {
  4500. cell.vt = 2;
  4501. }
  4502. while (c < colLen && data[r][c] != null) {
  4503. c++;
  4504. }
  4505. if (c == colLen) {
  4506. return true;
  4507. }
  4508. if (data[r][c] == null) {
  4509. data[r][c] = cell;
  4510. let rowspan = parseInt($td.attr("rowspan"));
  4511. let colspan = parseInt($td.attr("colspan"));
  4512. if (isNaN(rowspan)) {
  4513. rowspan = 1;
  4514. }
  4515. if (isNaN(colspan)) {
  4516. colspan = 1;
  4517. }
  4518. let r_ab = Store.luckysheet_select_save[0]["row"][0] + r;
  4519. let c_ab = Store.luckysheet_select_save[0]["column"][0] + c;
  4520. for (let rp = 0; rp < rowspan; rp++) {
  4521. for (let cp = 0; cp < colspan; cp++) {
  4522. if (rp == 0) {
  4523. let bt = $td.css("border-top");
  4524. if (bt != null && bt.length > 0 && bt.substr(0, 3).toLowerCase() != "0px") {
  4525. let width = $td.css("border-top-width");
  4526. let type = $td.css("border-top-style");
  4527. let color = $td.css("border-top-color");
  4528. let borderconfig = menuButton.getQKBorder(width, type, color);
  4529. if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
  4530. borderInfo[(r + rp) + "_" + (c + cp)] = {};
  4531. }
  4532. borderInfo[(r + rp) + "_" + (c + cp)].t = { "style": borderconfig[0], "color": borderconfig[1] };
  4533. }
  4534. }
  4535. if (rp == rowspan - 1) {
  4536. let bb = $td.css("border-bottom");
  4537. if (bb != null && bb.length > 0 && bb.substr(0, 3).toLowerCase() != "0px") {
  4538. let width = $td.css("border-bottom-width");
  4539. let type = $td.css("border-bottom-style");
  4540. let color = $td.css("border-bottom-color");
  4541. let borderconfig = menuButton.getQKBorder(width, type, color);
  4542. if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
  4543. borderInfo[(r + rp) + "_" + (c + cp)] = {};
  4544. }
  4545. borderInfo[(r + rp) + "_" + (c + cp)].b = { "style": borderconfig[0], "color": borderconfig[1] };
  4546. }
  4547. }
  4548. if (cp == 0) {
  4549. let bl = $td.css("border-left");
  4550. if (bl != null && bl.length > 0 && bl.substr(0, 3).toLowerCase() != "0px") {
  4551. let width = $td.css("border-left-width");
  4552. let type = $td.css("border-left-style");
  4553. let color = $td.css("border-left-color");
  4554. let borderconfig = menuButton.getQKBorder(width, type, color);
  4555. if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
  4556. borderInfo[(r + rp) + "_" + (c + cp)] = {};
  4557. }
  4558. borderInfo[(r + rp) + "_" + (c + cp)].l = { "style": borderconfig[0], "color": borderconfig[1] };
  4559. }
  4560. }
  4561. if (cp == colspan - 1) {
  4562. let br = $td.css("border-right");
  4563. if (br != null && br.length > 0 && br.substr(0, 3).toLowerCase() != "0px") {
  4564. let width = $td.css("border-right-width");
  4565. let type = $td.css("border-right-style");
  4566. let color = $td.css("border-right-color");
  4567. let borderconfig = menuButton.getQKBorder(width, type, color);
  4568. if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
  4569. borderInfo[(r + rp) + "_" + (c + cp)] = {};
  4570. }
  4571. borderInfo[(r + rp) + "_" + (c + cp)].r = { "style": borderconfig[0], "color": borderconfig[1] };
  4572. }
  4573. }
  4574. if (rp == 0 && cp == 0) {
  4575. continue;
  4576. }
  4577. data[r + rp][c + cp] = { "mc": { "r": r_ab, "c": c_ab } };
  4578. }
  4579. }
  4580. if (rowspan > 1 || colspan > 1) {
  4581. let first = { "rs": rowspan, "cs": colspan, "r": r_ab, "c": c_ab };
  4582. data[r][c].mc = first;
  4583. }
  4584. }
  4585. c++;
  4586. if (c == colLen) {
  4587. return true;
  4588. }
  4589. });
  4590. r++;
  4591. });
  4592. Store.luckysheet_selection_range = [];
  4593. selection.pasteHandler(data, borderInfo);
  4594. $("#luckysheet-copy-content").empty();
  4595. }
  4596. //复制的是图片
  4597. else if(clipboardData.files.length == 1 && clipboardData.files[0].type.indexOf('image') > -1){
  4598. imageCtrl.insertImg(clipboardData.files[0]);
  4599. return;
  4600. }
  4601. else {
  4602. txtdata = clipboardData.getData("text/plain");
  4603. selection.pasteHandler(txtdata);
  4604. }
  4605. }
  4606. }
  4607. else if($(e.target).closest('#luckysheet-rich-text-editor').length > 0) {
  4608. // 阻止默认粘贴
  4609. e.preventDefault();
  4610. let clipboardData = window.clipboardData; //for IE
  4611. if (!clipboardData) { // for chrome
  4612. clipboardData = e.originalEvent.clipboardData;
  4613. }
  4614. let text = clipboardData.getData('text/plain');
  4615. // 插入
  4616. document.execCommand("insertText", false, text);
  4617. }
  4618. });
  4619. //是否允许加载下一页
  4620. if (luckysheetConfigsetting.enablePage) {
  4621. $("#luckysheet-bottom-page-next").click(function () {
  4622. let queryExps = luckysheetConfigsetting.pageInfo.queryExps;
  4623. let reportId = luckysheetConfigsetting.pageInfo.reportId;
  4624. let fields = luckysheetConfigsetting.pageInfo.fields;
  4625. let mobile = luckysheetConfigsetting.pageInfo.mobile;
  4626. let frezon = luckysheetConfigsetting.pageInfo.frezon;
  4627. let currentPage = luckysheetConfigsetting.pageInfo.currentPage;
  4628. let totalPage = luckysheetConfigsetting.pageInfo.totalPage;
  4629. let pageUrl = luckysheetConfigsetting.pageInfo.pageUrl;
  4630. method.addDataAjax({
  4631. "queryExps": queryExps,
  4632. "reportId": reportId,
  4633. "fields": fields,
  4634. "mobile": mobile,
  4635. "frezon": frezon,
  4636. "pageIndex": currentPage,
  4637. "currentPage": currentPage
  4638. }, Store.currentSheetIndex, pageUrl, function () {
  4639. luckysheetConfigsetting.pageInfo.currentPage++;
  4640. if (luckysheetConfigsetting.pageInfo.totalPage == (luckysheetConfigsetting.pageInfo.currentPage)) {
  4641. $("#luckysheet-bottom-page-next").hide();
  4642. let pageInfoFull = replaceHtml(locale_info.pageInfoFull, {
  4643. total: luckysheetConfigsetting.total,
  4644. totalPage: luckysheetConfigsetting.pageInfo.totalPage,
  4645. });
  4646. $("#luckysheet-bottom-page-info").html(pageInfoFull);
  4647. }
  4648. else {
  4649. let pageInfo = replaceHtml(locale_info.pageInfo, {
  4650. total: luckysheetConfigsetting.total,
  4651. totalPage: luckysheetConfigsetting.pageInfo.totalPage,
  4652. currentPage: luckysheetConfigsetting.pageInfo.currentPage
  4653. });
  4654. $("#luckysheet-bottom-page-info").html(pageInfo);
  4655. }
  4656. });
  4657. }).mousedown(function (e) {
  4658. e.stopPropagation();
  4659. });
  4660. }
  4661. //回到顶部
  4662. $("#luckysheet-bottom-bottom-top").click(function () {
  4663. $("#luckysheet-scrollbar-y").scrollTop(0);
  4664. }).mousedown(function (e) {
  4665. e.stopPropagation();
  4666. });
  4667. $('#luckysheet-wa-editor,#luckysheet-icon-morebtn-div,.luckysheet-toolbar-button').click(function(e){
  4668. if(this.id != 'luckysheet-icon-paintformat' && menuButton.luckysheetPaintModelOn){
  4669. menuButton.cancelPaintModel();
  4670. }
  4671. })
  4672. }
  4673. // 协同编辑其他用户不在操作的时候,且已经展示了用户名10秒,则用户名框隐藏
  4674. function hideUsername(){
  4675. let $showEle = $$('.luckysheet-multipleRange-show');
  4676. if($showEle.length === undefined){
  4677. $showEle = [$showEle];
  4678. }
  4679. $showEle.forEach((ele)=>{
  4680. const id = ele.id.replace('luckysheet-multipleRange-show-','');
  4681. if(Store.cooperativeEdit.usernameTimeout['user' + id] === null){
  4682. $$('.username',ele).style.display = 'none';
  4683. }
  4684. })
  4685. }