1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734 |
- import mobileinit from './mobile';
- import luckysheetConfigsetting from './luckysheetConfigsetting';
- import luckysheetFreezen from './freezen';
- import pivotTable from './pivotTable';
- import luckysheetDropCell from './dropCell';
- import luckysheetPostil from './postil';
- import imageCtrl from './imageCtrl';
- import hyperlinkCtrl from './hyperlinkCtrl';
- import dataVerificationCtrl from './dataVerificationCtrl';
- import menuButton from './menuButton';
- import conditionformat from './conditionformat';
- import alternateformat from './alternateformat';
- import ifFormulaGenerator from './ifFormulaGenerator';
- import sheetmanage from './sheetmanage';
- import server from './server';
- import {luckysheetupdateCell} from './updateCell';
- import { luckysheet_searcharray } from './sheetSearch';
- import luckysheetsizeauto from './resize';
- import {
- luckysheetMoveHighlightCell,
- } from './sheetMove';
- import { selectHightlightShow, selectIsOverlap, selectionCopyShow, luckysheet_count_show,selectHelpboxFill } from './select';
- import selection from './selection';
- import controlHistory from './controlHistory';
- import splitColumn from './splitColumn';
- import {hideMenuByCancel} from '../global/cursorPos';
- import { luckysheetdefaultstyle } from './constant';
- import {checkProtectionLockedRangeList,checkProtectionAllSelected,checkProtectionSelectLockedOrUnLockedCells,checkProtectionNotEnable,checkProtectionAuthorityNormal} from './protection';
- import { openCellFormatModel } from './cellFormat';
- import {
- replaceHtml,
- getObjType,
- chatatABC,
- ArrayUnique,
- showrightclickmenu,
- luckysheetactiveCell,
- luckysheetContainerFocus,
- $$
- } from '../utils/util';
- import { getSheetIndex, getRangetxt } from '../methods/get';
- import {
- rowLocation,
- colLocation,
- mouseposition
- } from '../global/location';
- import { rowlenByRange } from '../global/getRowlen';
- import { isRealNull, hasPartMC, isEditMode, checkIsAllowEdit } from '../global/validate';
- import { countfunc } from '../global/count';
- import browser from '../global/browser';
- import formula from '../global/formula';
- import { luckysheetextendtable } from '../global/extend';
- import luckysheetscrollevent from '../global/scroll';
- import {
- jfrefreshgrid,
- jfrefreshgrid_rhcw,
- luckysheetrefreshgrid,
- } from '../global/refresh';
- import { getdatabyselection, datagridgrowth } from '../global/getdata';
- import tooltip from '../global/tooltip';
- import editor from '../global/editor';
- import { genarate } from '../global/format';
- import method from '../global/method';
- import { getBorderInfoCompute } from '../global/border';
- import { luckysheetDrawMain } from '../global/draw';
- import locale from '../locale/locale';
- import Store from '../store';
- import { createLuckyChart, hideAllNeedRangeShow } from '../expendPlugins/chart/plugin'
- //, columeflowset, rowflowset
- export default function luckysheetHandler() {
- const os = browser.detectOS(), isMobile = browser.mobilecheck();
- //移动端
- if(isMobile){
- mobileinit();
- }
- if (!Date.now)
- Date.now = function() { return new Date().getTime(); };
- //requestAnimationFrame method
- (function() {
- 'use strict';
-
- var vendors = ['webkit', 'moz'];
- for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
- var vp = vendors[i];
- window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
- window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
- || window[vp+'CancelRequestAnimationFrame']);
- }
- if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
- || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
- var lastTime = 0;
- window.requestAnimationFrame = function(callback) {
- var now = Date.now();
- var nextTime = Math.max(lastTime + 16, now);
- return setTimeout(function() { callback(lastTime = nextTime); },
- nextTime - now);
- };
- window.cancelAnimationFrame = clearTimeout;
- }
- }());
-
- $("#luckysheet-sheet-container-c").mousewheel(function (event, delta) {
- let scrollNum = event.deltaFactor<40?1:(event.deltaFactor<80?2:3);
- let scrollLeft = $(this).scrollLeft();
- if(event.deltaY != 0){
- if(event.deltaY <0){
- scrollLeft = scrollLeft + 10*scrollNum;
-
- }
- else{
- scrollLeft = scrollLeft - 10*scrollNum;
-
- }
- }
- else if(event.deltaX != 0){
- if(event.deltaX >0){
- scrollLeft = scrollLeft + 10*scrollNum;
-
- }
- else{
- scrollLeft = scrollLeft - 10*scrollNum;
-
- }
- }
- $(this).scrollLeft(scrollLeft);
- event.preventDefault();
- });
-
- //滚动监听
- $("#luckysheet-cell-main").scroll(function () {
-
- })
- .mousewheel(function (event, delta) {
- event.preventDefault();
- });
- const _locale = locale();
- const locale_drag = _locale.drag;
- const locale_info = _locale.info;
- let prev, mousewheelArrayUniqueTimeout;
- $("#luckysheet-grid-window-1").mousewheel(function (event, delta) {
- let scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(),
- scrollTop = $("#luckysheet-scrollbar-y").scrollTop();
- let visibledatacolumn_c = Store.visibledatacolumn,
- visibledatarow_c = Store.visibledatarow;
- if (luckysheetFreezen.freezenhorizontaldata != null) {
- visibledatarow_c = luckysheetFreezen.freezenhorizontaldata[3];
- }
- if (luckysheetFreezen.freezenverticaldata != null) {
- visibledatacolumn_c = luckysheetFreezen.freezenverticaldata[3];
- }
- clearTimeout(mousewheelArrayUniqueTimeout);
-
- // if(Store.visibledatacolumn.length!=visibledatacolumn_c.length){
- if(Store.visibledatacolumn_unique!=null){
- visibledatacolumn_c = Store.visibledatacolumn_unique;
- }
- else{
- visibledatacolumn_c = ArrayUnique(visibledatacolumn_c);
- Store.visibledatacolumn_unique = visibledatacolumn_c;
- }
- // }
- // if(Store.visibledatarow.length!=visibledatarow_c.length){
- if(Store.visibledatarow_unique!=null){
- visibledatarow_c = Store.visibledatarow_unique;
- }
- else{
- visibledatarow_c = ArrayUnique(visibledatarow_c);
- Store.visibledatarow_unique = visibledatarow_c;
- }
- // }
- // visibledatacolumn_c = ArrayUnique(visibledatacolumn_c);
- // visibledatarow_c = ArrayUnique(visibledatarow_c);
- let col_st = luckysheet_searcharray(visibledatacolumn_c, scrollLeft);
- let row_st = luckysheet_searcharray(visibledatarow_c, scrollTop);
- if (luckysheetFreezen.freezenhorizontaldata != null) {
- row_st = luckysheet_searcharray(visibledatarow_c, scrollTop + luckysheetFreezen.freezenhorizontaldata[0]);
- }
- let colscroll = 0;
- let rowscroll = 0;
- let scrollNum = event.deltaFactor<40?1:(event.deltaFactor<80?2:3);
- //一次滚动三行或三列
- if(event.deltaY != 0){
- let row_ed,step=Math.round(scrollNum/Store.zoomRatio);
- step = step<1?1:step;
- if(event.deltaY < 0){
- row_ed = row_st + step;
-
- if(row_ed >= visibledatarow_c.length){
- row_ed = visibledatarow_c.length - 1;
- }
- }
- else{
- row_ed = row_st - step;
-
- if(row_ed < 0){
- row_ed = 0;
- }
- }
- rowscroll = row_ed == 0 ? 0 : visibledatarow_c[row_ed - 1];
- if (luckysheetFreezen.freezenhorizontaldata != null) {
- rowscroll -= luckysheetFreezen.freezenhorizontaldata[0];
- }
- $("#luckysheet-scrollbar-y").scrollTop(rowscroll);
- }
- else if(event.deltaX != 0){
- let col_ed;
-
- // if((isMac && event.deltaX >0 ) || (!isMac && event.deltaX < 0)){
- if(event.deltaX >0){
- scrollLeft = scrollLeft + 20*Store.zoomRatio;
-
- // if(col_ed >= visibledatacolumn_c.length){
- // col_ed = visibledatacolumn_c.length - 1;
- // }
- }
- else{
- scrollLeft = scrollLeft - 20*Store.zoomRatio;
-
- // if(col_ed < 0){
- // col_ed = 0;
- // }
- }
- // colscroll = col_ed == 0 ? 0 : visibledatacolumn_c[col_ed - 1];
- $("#luckysheet-scrollbar-x").scrollLeft(scrollLeft);
- }
- mousewheelArrayUniqueTimeout = setTimeout(() => {
- Store.visibledatacolumn_unique = null;
- Store.visibledatarow_unique = null;
- }, 500);
- });
- $("#luckysheet-scrollbar-x").scroll(function(){
- // setTimeout(function(){
- luckysheetscrollevent();
- // },10);
- })
- .mousewheel(function (event, delta) {
- event.preventDefault();
- });
- $("#luckysheet-scrollbar-y").scroll(function(){
- // setTimeout(function(){
- luckysheetscrollevent();
- // },10);
- })
- .mousewheel(function (event, delta) {
- event.preventDefault();
- });
- //页面resize
- $(window).resize(function () {
- let luckysheetDocument = document.getElementById(Store.container);
- if(luckysheetDocument){
- luckysheetsizeauto();
- }
- });
- $("#luckysheet-rich-text-editor").mouseup(function(e){
- menuButton.inputMenuButtonFocus(e.target);
- });
- //表格mousedown
- $("#luckysheet-cell-main, #luckysheetTableContent").mousedown(function (event) {
- if($(event.target).hasClass('luckysheet-mousedown-cancel')){
- return;
- }
- // 协同编辑其他用户不在操作的时候,用户名框隐藏
- hideUsername();
- $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
- .css("cursor","default")
- .end()
- .find(".luckysheet-cs-draghandle")
- .css("cursor","default");
- $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor","default");
- //有批注在编辑时
- luckysheetPostil.removeActivePs();
- //图片 active/cropping
- if($("#luckysheet-modal-dialog-activeImage").is(":visible") || $("#luckysheet-modal-dialog-cropping").is(":visible")){
- imageCtrl.cancelActiveImgItem();
- }
- //luckysheetautoadjustmousedown = 1;
- let mouse = mouseposition(event.pageX, event.pageY);
- if (mouse[0] >= Store.cellmainWidth - Store.cellMainSrollBarSize || mouse[1] >= Store.cellmainHeight - Store.cellMainSrollBarSize) {
- return;
- }
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- if(luckysheetFreezen.freezenverticaldata != null && mouse[0] < (luckysheetFreezen.freezenverticaldata[0] - luckysheetFreezen.freezenverticaldata[2])){
- x = mouse[0] + luckysheetFreezen.freezenverticaldata[2];
- }
- if(luckysheetFreezen.freezenhorizontaldata != null && mouse[1] < (luckysheetFreezen.freezenhorizontaldata[0] - luckysheetFreezen.freezenhorizontaldata[2])){
- y = mouse[1] + luckysheetFreezen.freezenhorizontaldata[2];
- }
- let sheetFile = sheetmanage.getSheetByIndex();
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
-
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let row_index_ed = row_index, col_index_ed = col_index;
- let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- row_index = margeset.row[2];
- row_index_ed = margeset.row[3];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- col_index = margeset.column[2];
- col_index_ed = margeset.column[3];
- }
- //单元格单击之前
- if(!method.createHookFunction("cellMousedownBefore", Store.flowdata[row_index][col_index], {
- r:row_index,
- c:col_index,
- "start_r": row_pre,
- "start_c": col_pre,
- "end_r": row,
- "end_c": col
- }, sheetFile,luckysheetTableContent)){ return; }
- //数据验证 单元格聚焦
- dataVerificationCtrl.cellFocus(row_index, col_index, true);
- //若点击单元格部分不在视图内
- if (col_pre < $("#luckysheet-cell-main").scrollLeft()) {
- $("#luckysheet-scrollbar-x").scrollLeft(col_pre);
- }
- if (row_pre < $("#luckysheet-cell-main").scrollTop()) {
- $("#luckysheet-scrollbar-y").scrollTop(row_pre);
- }
- //mousedown是右键
- if (event.which == "3") {
- $("#luckysheet-dataVerification-showHintBox").hide();
- let isright = false;
- for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
- 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])) {
- isright = true;
- break;
- }
- }
- if (isright) {
- return;
- }
- }
- //单元格数据下钻
- if (Store.flowdata[row_index] != null && Store.flowdata[row_index][col_index] != null && Store.flowdata[row_index][col_index].dd != null) {
- if (luckysheetConfigsetting.fireMousedown != null && getObjType(luckysheetConfigsetting.fireMousedown) == "function") {
- luckysheetConfigsetting.fireMousedown(Store.flowdata[row_index][col_index].dd);
- return;
- }
- }
- //链接 单元格聚焦
- if(hyperlinkCtrl.hyperlink && hyperlinkCtrl.hyperlink[row_index + "_" + col_index] && event.which != "3"){
- hyperlinkCtrl.cellFocus(row_index, col_index);
- return;
- }
- Store.luckysheet_scroll_status = true;
- //公式相关
- let $input = $("#luckysheet-input-box");
- if (parseInt($input.css("top")) > 0) {
- if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()) {
- //公式选区
- let rowseleted = [row_index, row_index_ed];
- let columnseleted = [col_index, col_index_ed];
- let left = col_pre;
- let width = col - col_pre - 1;
- let top = row_pre;
- let height = row - row_pre - 1;
- if (event.shiftKey) {
- let last = formula.func_selectedrange;
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- luckysheet_count_show(left, top, width, height, rowseleted, columnseleted);
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- formula.func_selectedrange = last;
- }
- else if (event.ctrlKey && $("#luckysheet-rich-text-editor").find("span").last().text() != ",") {
- //按住ctrl 选择选区时 先处理上一个选区
- let vText = $("#luckysheet-rich-text-editor").text();
-
- if(vText[vText.length -1 ] === ")"){
- vText = vText.substr(0,vText.length - 1); //先删除最后侧的圆括号)
- }
-
- if(vText.length > 0){
- let lastWord = vText.substr(vText.length-1,1);
- if(lastWord!="," && lastWord!="=" && lastWord!="("){
- vText += ",";
- }
- }
- if (vText.length > 0 && vText.substr(0, 1) == "=") {
- vText = formula.functionHTMLGenerate(vText);
- if (window.getSelection) { // all browsers, except IE before version 9
- let currSelection = window.getSelection();
- formula.functionRangeIndex = [$(currSelection.anchorNode).parent().index(), currSelection.anchorOffset];
- }
- else { // Internet Explorer before version 9
- let textRange = document.selection.createRange();
- formula.functionRangeIndex = textRange;
- }
- /* 在显示前重新 + 右侧的圆括号) */
- $("#luckysheet-rich-text-editor").html(vText + ")");
- formula.canceFunctionrangeSelected();
- formula.createRangeHightlight();
- }
- formula.rangestart = false;
- formula.rangedrag_column_start = false;
- formula.rangedrag_row_start = false;
- $("#luckysheet-functionbox-cell").html(vText + ")");
- formula.rangeHightlightselected($("#luckysheet-rich-text-editor"));
- //再进行 选区的选择
- formula.israngeseleciton();
- formula.func_selectedrange = {
- "left": left,
- "width": width,
- "top": top,
- "height": height,
- "left_move": left,
- "width_move": width,
- "top_move": top,
- "height_move": height,
- "row": rowseleted,
- "column": columnseleted,
- "row_focus": row_index,
- "column_focus": col_index
- };
- }
- else {
- formula.func_selectedrange = {
- "left": left,
- "width": width,
- "top": top,
- "height": height,
- "left_move": left,
- "width_move": width,
- "top_move": top,
- "height_move": height,
- "row": rowseleted,
- "column": columnseleted,
- "row_focus": row_index,
- "column_focus": col_index
- };
- }
-
- formula.rangeSetValue({ "row": rowseleted, "column": columnseleted });
- formula.rangestart = true;
- formula.rangedrag_column_start = false;
- formula.rangedrag_row_start = false;
- $("#luckysheet-formula-functionrange-select").css({
- "left": left,
- "width": width,
- "top": top,
- "height": height
- }).show();
- $("#luckysheet-formula-help-c").hide();
- luckysheet_count_show(left, top, width, height, rowseleted, columnseleted);
- setTimeout(function () {
- let currSelection = window.getSelection();
- let anchorOffset = currSelection.anchorNode;
- let $editor;
- if ($("#luckysheet-search-formula-parm").is(":visible") || $("#luckysheet-search-formula-parm-select").is(":visible")) {
- $editor = $("#luckysheet-rich-text-editor");
- formula.rangechangeindex = formula.data_parm_index;
- }
- else {
- $editor = $(anchorOffset).closest("div");
- }
- let $span = $editor.find("span[rangeindex='" + formula.rangechangeindex + "']");
- formula.setCaretPosition($span.get(0), 0, $span.html().length);
- }, 1);
- return;
- }
- else {
- formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
- Store.luckysheet_select_status = true;
- if ($("#luckysheet-info").is(":visible")) {
- Store.luckysheet_select_status = false;
- }
- }
- }
- else {
- if(checkProtectionSelectLockedOrUnLockedCells(row_index, col_index, Store.currentSheetIndex)){
- Store.luckysheet_select_status = true;
- }
- }
- //条件格式 应用范围可选择多个单元格
- if ($("#luckysheet-multiRange-dialog").is(":visible")) {
- conditionformat.selectStatus = true;
- Store.luckysheet_select_status = false;
- if (event.shiftKey) {
- let last = conditionformat.selectRange[conditionformat.selectRange.length - 1];
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- conditionformat.selectRange[conditionformat.selectRange.length - 1] = last;
- }
- else if (event.ctrlKey) {
- conditionformat.selectRange.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [row_index, row_index_ed],
- "column": [col_index, col_index_ed],
- "row_focus": row_index,
- "column_focus": col_index
- });
- }
- else {
- conditionformat.selectRange = [];
- conditionformat.selectRange.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [row_index, row_index_ed],
- "column": [col_index, col_index_ed],
- "row_focus": row_index,
- "column_focus": col_index
- });
- }
- selectionCopyShow(conditionformat.selectRange);
- let range = conditionformat.getTxtByRange(conditionformat.selectRange);
- $("#luckysheet-multiRange-dialog input").val(range);
- return;
- }
- else {
- conditionformat.selectStatus = false;
- conditionformat.selectRange = [];
- }
- //条件格式 条件值只能选择单个单元格
- if ($("#luckysheet-singleRange-dialog").is(":visible")) {
- Store.luckysheet_select_status = false;
- selectionCopyShow([{ "row": [row_index, row_index], "column": [col_index, col_index] }]);
- let range = getRangetxt(
- Store.currentSheetIndex,
- { "row": [row_index, row_index], "column": [col_index, col_index] },
- Store.currentSheetIndex
- );
- $("#luckysheet-singleRange-dialog input").val(range);
- return;
- }
- //数据验证 单元格范围选择
- if($("#luckysheet-dataVerificationRange-dialog").is(":visible")){
- dataVerificationCtrl.selectStatus = true;
- Store.luckysheet_select_status = false;
- if (event.shiftKey) {
- let last = dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1];
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1] = last;
- }
- else {
- dataVerificationCtrl.selectRange = [];
- dataVerificationCtrl.selectRange.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [row_index, row_index_ed],
- "column": [col_index, col_index_ed],
- "row_focus": row_index,
- "column_focus": col_index
- });
- }
- selectionCopyShow(dataVerificationCtrl.selectRange);
- let range = dataVerificationCtrl.getTxtByRange(dataVerificationCtrl.selectRange);
- if(formula.rangetosheet != Store.currentSheetIndex){
- range = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].name + '!' + range;
- }
- $("#luckysheet-dataVerificationRange-dialog input").val(range);
- return;
- }
- else{
- dataVerificationCtrl.selectStatus = false;
- dataVerificationCtrl.selectRange = [];
- }
- //if公式生成器
- if (ifFormulaGenerator.singleRangeFocus) {
- $("#luckysheet-ifFormulaGenerator-dialog .singRange").click();
- }
- if ($("#luckysheet-ifFormulaGenerator-singleRange-dialog").is(":visible")) {
- //选择单个单元格
- Store.luckysheet_select_status = false;
- formula.rangestart = false;
- $("#luckysheet-formula-functionrange-select").css({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1
- }).show();
- $("#luckysheet-formula-help-c").hide();
- let range = getRangetxt(
- Store.currentSheetIndex,
- { "row": [row_index, row_index], "column": [col_index, col_index] },
- Store.currentSheetIndex
- );
- $("#luckysheet-ifFormulaGenerator-singleRange-dialog input").val(range);
- return;
- }
- if ($("#luckysheet-ifFormulaGenerator-multiRange-dialog").is(":visible")) {
- //选择范围
- Store.luckysheet_select_status = false;
- formula.func_selectedrange = {
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [row_index, row_index],
- "column": [col_index, col_index],
- "row_focus": row_index,
- "column_focus": col_index
- };
- formula.rangestart = true;
- $("#luckysheet-formula-functionrange-select").css({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1
- }).show();
- $("#luckysheet-formula-help-c").hide();
- let range = getRangetxt(
- Store.currentSheetIndex,
- { "row": [row_index, row_index], "column": [col_index, col_index] },
- Store.currentSheetIndex
- );
- $("#luckysheet-ifFormulaGenerator-multiRange-dialog input").val(range);
- $("#luckysheet-row-count-show").hide();
- $("#luckysheet-column-count-show").hide();
- return;
- }
- if (Store.luckysheet_select_status) {
- if (event.shiftKey) {
- //按住shift点击,选择范围
- let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); //选区最后一个
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
- //交替颜色选择范围
- if ($("#luckysheet-alternateformat-rangeDialog").is(":visible")) {
- $("#luckysheet-alternateformat-rangeDialog input").val(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save));
- }
- if (pivotTable.luckysheet_pivotTable_select_state) {
- $("#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));
- }
- }
- else if (event.ctrlKey) {
- //选区添加
- Store.luckysheet_select_save.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [row_index, row_index_ed],
- "column": [col_index, col_index_ed],
- "row_focus": row_index,
- "column_focus": col_index
- });
- }
- else {
- Store.luckysheet_select_save.length = 0;
- Store.luckysheet_select_save.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [row_index, row_index_ed],
- "column": [col_index, col_index_ed],
- "row_focus": row_index,
- "column_focus": col_index
- });
- //单元格格式icon对应
- menuButton.menuButtonFocus(Store.flowdata, row_index, col_index);
- //函数公式显示栏
- formula.fucntionboxshow(row_index, col_index);
- }
- selectHightlightShow();
- if (luckysheetFreezen.freezenhorizontaldata != null || luckysheetFreezen.freezenverticaldata != null) {
- luckysheetFreezen.scrollAdaptOfselect();
- }
- if (!browser.mobilecheck()) { //非移动端聚焦输入框
- luckysheetactiveCell();
- }
- //允许编辑后的后台更新时
- server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
- }
- //交替颜色
- if (alternateformat.rangefocus) {
- alternateformat.rangefocus = false;
- $("#luckysheet-alternateformat-range .fa-table").click();
- }
- $("#luckysheet-row-count-show, #luckysheet-column-count-show").hide();
- if (!isEditMode()) {
- //chartMix 隐藏当前页的数据选择区域高亮
- hideAllNeedRangeShow();
- }
- // selectHelpboxFill();
- //数据透视表
- pivotTable.pivotclick(row_index, col_index, Store.currentSheetIndex);
- luckysheetContainerFocus();
- method.createHookFunction("cellMousedown", Store.flowdata[row_index][col_index], {
- r:row_index,
- c:col_index,
- "start_r": row_pre,
- "start_c": col_pre,
- "end_r": row,
- "end_c": col
- }, sheetFile,luckysheetTableContent);
- //$("#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");
- //$("#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");
- //$("#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");
- //$("#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");
- //event.stopImmediatePropagation();
- }).mouseup(function (event) {
- if (event.which == "3") {
- //禁止前台编辑(只可 框选单元格、滚动查看表格)
- if (!Store.allowEdit) {
- return;
- }
- if (isEditMode()) { //非编辑模式下禁止右键功能框
- return;
- }
- let x = event.pageX;
- let y = event.pageY;
- let data = Store.flowdata;
- let obj_s = Store.luckysheet_select_save[0];
- const cellRightClickConfig = luckysheetConfigsetting.cellRightClickConfig;
- $("#luckysheet-cols-rows-data").show();
- $("#luckysheet-cols-rows-handleincell").show();
- $("#luckysheet-cols-rows-add, #luckysheet-cols-rows-shift").hide();
- $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'block';
- $$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'block';
- if (obj_s["row"] != null && obj_s["row"][0] == 0 && obj_s["row"][1] == Store.flowdata.length - 1) {
- // 如果全部按钮都隐藏,则整个菜单容器也要隐藏
- 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){
- return;
- }
- Store.luckysheetRightHeadClickIs = "column";
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.column);
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.width);
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.left);
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.right);
- $("#luckysheet-cols-rows-add").show();
- // $("#luckysheet-cols-rows-data").show();
- $("#luckysheet-cols-rows-shift").hide();
- $("#luckysheet-cols-rows-handleincell").hide();
- Store.luckysheet_cols_menu_status = true;
- $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'block';
- // 自定义右键菜单:向左向右增加列,删除列,隐藏显示列,设置列宽
- $$('#luckysheet-top-left-add-selected').style.display = cellRightClickConfig.insertColumn ? 'block' : 'none';
- $$('#luckysheet-bottom-right-add-selected').style.display = cellRightClickConfig.insertColumn ? 'block' : 'none';
- $$('#luckysheet-del-selected').style.display = cellRightClickConfig.deleteColumn ? 'block' : 'none';
- $$('#luckysheet-hide-selected').style.display = cellRightClickConfig.hideColumn ? 'block' : 'none';
- $$('#luckysheet-show-selected').style.display = cellRightClickConfig.hideColumn ? 'block' : 'none';
- $$('#luckysheet-column-row-width-selected').style.display = cellRightClickConfig.columnWidth ? 'block' : 'none';
- // 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
- if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
- $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
- if(!cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth){
- $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
- }
- }
- // 2.当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
- if(!cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.hideColumn && !cellRightClickConfig.columnWidth){
- $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
- }
- //列宽默认值
- let cfg = $.extend(true, {}, Store.config);
- if (cfg["columnlen"] == null) {
- cfg["columnlen"] = {};
- }
- let first_collen = cfg["columnlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columnlen"][Store.luckysheet_select_save[0].column[0]];
- let isSame = true;
- for (let i = 0; i < Store.luckysheet_select_save.length; i++) {
- let s = Store.luckysheet_select_save[i];
- let c1 = s.column[0], c2 = s.column[1];
- for (let c = c1; c <= c2; c++) {
- let collen = cfg["columnlen"][c] == null ? Store.defaultcollen : cfg["columnlen"][c];
- if (collen != first_collen) {
- isSame = false;
- break;
- }
- }
- }
- if (isSame) {
- $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_collen);
- }
- else {
- $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val("");
- }
- }
- else if (obj_s["column"] != null && obj_s["column"][0] == 0 && obj_s["column"][1] == Store.flowdata[0].length - 1) {
- // 如果全部按钮都隐藏,则整个菜单容器也要隐藏
- 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){
- return;
- }
- Store.luckysheetRightHeadClickIs = "row";
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-word").text(locale().rightclick.row);
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-size").text(locale().rightclick.height);
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-left").text(locale().rightclick.top);
- $("#luckysheet-rightclick-menu .luckysheet-cols-rows-shift-right").text(locale().rightclick.bottom);
- $("#luckysheet-cols-rows-add").show();
- // $("#luckysheet-cols-rows-data").show();
- $("#luckysheet-cols-rows-shift").hide();
- $("#luckysheet-cols-rows-handleincell").hide();
- Store.luckysheet_cols_menu_status = true;
- $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'block';
- // 自定义右键菜单:向上向下增加行,删除行,隐藏显示行,设置行高
- $$('#luckysheet-top-left-add-selected').style.display = cellRightClickConfig.insertRow ? 'block' : 'none';
- $$('#luckysheet-bottom-right-add-selected').style.display = cellRightClickConfig.insertRow ? 'block' : 'none';
- $$('#luckysheet-del-selected').style.display = cellRightClickConfig.deleteRow ? 'block' : 'none';
- $$('#luckysheet-hide-selected').style.display = cellRightClickConfig.hideRow ? 'block' : 'none';
- $$('#luckysheet-show-selected').style.display = cellRightClickConfig.hideRow ? 'block' : 'none';
- $$('#luckysheet-column-row-width-selected').style.display = cellRightClickConfig.rowHeight ? 'block' : 'none';
- // 1. 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
- if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
- $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
- if(!cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight){
- $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
- }
- }
- // 2. 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
- if(!cellRightClickConfig.insertRow && !cellRightClickConfig.deleteRow && !cellRightClickConfig.hideRow && !cellRightClickConfig.rowHeight){
- $$('#luckysheet-cols-rows-add .luckysheet-menuseparator').style.display = 'none';
- }
- //行高默认值
- let cfg = $.extend(true, {}, Store.config);
- if (cfg["rowlen"] == null) {
- cfg["rowlen"] = {};
- }
- let first_rowlen = cfg["rowlen"][Store.luckysheet_select_save[0].row[0]] == null ? Store.defaultrowlen : cfg["rowlen"][Store.luckysheet_select_save[0].row[0]];
- let isSame = true;
- for (let i = 0; i < Store.luckysheet_select_save.length; i++) {
- let s = Store.luckysheet_select_save[i];
- let r1 = s.row[0], r2 = s.row[1];
- for (let r = r1; r <= r2; r++) {
- let rowlen = cfg["rowlen"][r] == null ? Store.defaultrowlen : cfg["rowlen"][r];
- if (rowlen != first_rowlen) {
- isSame = false;
- break;
- }
- }
- }
- if (isSame) {
- $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val(first_rowlen);
- }
- else {
- $("#luckysheet-cols-rows-add").find("input[type='number'].rcsize").val("");
- }
- }else{
- // 如果全部按钮都隐藏,则整个菜单容器也要隐藏
- 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){
- return;
- }
- // 当一个功能菜单块上方的功能块按钮都隐藏的时候,下方的功能块的顶部分割线也需要隐藏
- if(!cellRightClickConfig.copy && !cellRightClickConfig.copyAs && !cellRightClickConfig.paste){
- $$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'none';
- if(!cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell){
- $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
- }
- }
- if(!cellRightClickConfig.insertRow && !cellRightClickConfig.insertColumn && !cellRightClickConfig.deleteRow && !cellRightClickConfig.deleteColumn && !cellRightClickConfig.deleteCell){
- $$('#luckysheet-cols-rows-handleincell .luckysheet-menuseparator').style.display = 'none';
- }
- }
- // 当一个功能菜单块内所有的按钮都隐藏的时候,它顶部的分割线也需要隐藏掉
- if(!cellRightClickConfig.clear && !cellRightClickConfig.matrix && !cellRightClickConfig.sort && !cellRightClickConfig.filter && !cellRightClickConfig.chart && !cellRightClickConfig.image && !cellRightClickConfig.link && !cellRightClickConfig.data && !cellRightClickConfig.cellFormat){
- $$('#luckysheet-cols-rows-data .luckysheet-menuseparator').style.display = 'none';
- }
-
- showrightclickmenu($("#luckysheet-rightclick-menu"), x, y);
- }
- // 备注:在mousedown中发送光标信息会漏处理部分(选区)范围
- server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
- }).dblclick(function (event) {
- if($(event.target).hasClass('luckysheet-mousedown-cancel')){
- return;
- }
-
- //禁止前台编辑(只可 框选单元格、滚动查看表格)
- if (!Store.allowEdit) {
- return;
- }
- if (parseInt($("#luckysheet-input-box").css("top")) > 0) {
- return;
- }
- let mouse = mouseposition(event.pageX, event.pageY);
- if (mouse[0] >= Store.cellmainWidth - Store.cellMainSrollBarSize || mouse[1] >= Store.cellmainHeight - Store.cellMainSrollBarSize) {
- return;
- }
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft(),
- scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- if(luckysheetFreezen.freezenverticaldata != null && mouse[0] < (luckysheetFreezen.freezenverticaldata[0] - luckysheetFreezen.freezenverticaldata[2])){
- x = mouse[0] + luckysheetFreezen.freezenverticaldata[2];
- }
- if(luckysheetFreezen.freezenhorizontaldata != null && mouse[1] < (luckysheetFreezen.freezenhorizontaldata[0] - luckysheetFreezen.freezenhorizontaldata[2])){
- y = mouse[1] + luckysheetFreezen.freezenhorizontaldata[2];
- }
- let row_location = rowLocation(y),
- row_index = row_location[2];
- let col_location = colLocation(x),
- col_index = col_location[2];
- let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
- if (!!margeset) {
- row_index = margeset.row[2];
- col_index = margeset.column[2];
- }
- if (pivotTable.isPivotRange(row_index, col_index)) {
- //数据透视表没有 任何数据
- 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)) {
- return;
- }
- //数据透视表没有 数值数据
- if (pivotTable.values == null || pivotTable.values.length == 0) {
- return;
- }
- //点击位置不是 数值数据 所在区域
- if (row_index == 0 || col_index == 0) {
- return;
- }
- if (pivotTable.column != null && pivotTable.column.length > 0) {
- if (pivotTable.values.length >= 2 && pivotTable.showType == "column") {
- if (row_index <= pivotTable.column.length || col_index >= pivotTable.pivotDatas[0].length - pivotTable.values.length) {
- return;
- }
- }
- else {
- if (row_index <= pivotTable.column.length - 1 || col_index >= pivotTable.pivotDatas[0].length - 1) {
- return;
- }
- }
- }
- if (pivotTable.row != null && pivotTable.row.length > 0) {
- if (pivotTable.values.length >= 2 && pivotTable.showType == "row") {
- if (col_index <= pivotTable.row.length || row_index >= pivotTable.pivotDatas.length - pivotTable.values.length) {
- return;
- }
- }
- else {
- if (col_index <= pivotTable.row.length - 1 || row_index >= pivotTable.pivotDatas.length - 1) {
- return;
- }
- }
- }
- sheetmanage.addNewSheet(event);
- pivotTable.drillDown(row_index, col_index);
- return;
- }
- if ($("#luckysheet-search-formula-parm").is(":visible") || $("#luckysheet-search-formula-parm-select").is(":visible")) {
- //公式参数栏显示
- $("#luckysheet-cell-selected").hide();
- }
- 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")) {
- //条件格式
- return;
- }
- else if ($("#luckysheet-modal-dialog-slider-alternateformat").is(":visible") || $("#luckysheet-alternateformat-rangeDialog").is(":visible")) {
- //交替颜色
- return;
- }
- else {
- if (menuButton.luckysheetPaintModelOn) {
- menuButton.cancelPaintModel();
- }
- // 检查当前坐标和焦点坐标是否一致,如果不一致那么进行修正
- let column_focus = Store.luckysheet_select_save[0]["column_focus"];
- let row_focus = Store.luckysheet_select_save[0]["row_focus"];
- if(column_focus !== col_index || row_focus !== row_index){
- row_index = row_focus;
- col_index = column_focus;
- };
- luckysheetupdateCell(row_index, col_index, Store.flowdata);
-
- /* 设置选区高亮 */
- selectHightlightShow();
- }
- });
- //监听拖拽
- document.getElementById('luckysheet-cell-main').addEventListener('drop', function(e){
- e.preventDefault();
- e.stopPropagation();
- let files = e.dataTransfer.files;
- //拖拽插入图片
- if(files.length == 1 && files[0].type.indexOf('image') > -1){
- if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
- return;
- }
- imageCtrl.insertImg(files[0]);
- }
- handleCellDragStopEvent(e);
- }, false);
- document.getElementById('luckysheet-cell-main').addEventListener('dragover', function(e){
- e.preventDefault();
- e.stopPropagation();
- }, false);
- /**
- * 处理单元格上鼠标拖拽停止事件
- * @param {DragEvent} event
- */
- function handleCellDragStopEvent(event) {
- if (luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.cellDragStop) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
-
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
-
- let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- row_index = margeset.row[2];
-
- col = margeset.column[1];
- col_pre = margeset.column[0];
- col_index = margeset.column[2];
- }
-
- let sheetFile = sheetmanage.getSheetByIndex();
-
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- method.createHookFunction("cellDragStop", Store.flowdata[row_index][col_index], {
- r: row_index,
- c: col_index,
- "start_r": row_pre,
- "start_c": col_pre,
- "end_r": row,
- "end_c": col
- }, sheetFile, luckysheetTableContent, event);
- }
- }
- //表格mousemove
- $(document).on("mousemove.luckysheetEvent",function (event) {
- luckysheetPostil.overshow(event); //有批注显示
- hyperlinkCtrl.overshow(event); //链接提示显示
- window.cancelAnimationFrame(Store.jfautoscrollTimeout);
- if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMousemove){
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- row_index = margeset.row[2];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- col_index = margeset.column[2];
- }
- // if(Store.flowdata[row_index] && Store.flowdata[row_index][col_index]){
- let sheetFile = sheetmanage.getSheetByIndex();
- let moveState = {
- functionResizeStatus:formula.functionResizeStatus,
- horizontalmoveState:!!luckysheetFreezen.horizontalmovestate,
- verticalmoveState:!!luckysheetFreezen.verticalmovestate,
- pivotTableMoveState:!!pivotTable && pivotTable.movestate,
- sheetMoveStatus:Store.luckysheet_sheet_move_status,
- scrollStatus:!!Store.luckysheet_scroll_status,
- selectStatus:!!Store.luckysheet_select_status,
- rowsSelectedStatus:!!Store.luckysheet_rows_selected_status,
- colsSelectedStatus:!!Store.luckysheet_cols_selected_status,
- cellSelectedMove:!!Store.luckysheet_cell_selected_move,
- cellSelectedExtend:!!Store.luckysheet_cell_selected_extend,
- colsChangeSize:!!Store.luckysheet_cols_change_size,
- rowsChangeSize:!!Store.luckysheet_rows_change_size,
- chartMove:!!Store.chartparam.luckysheetCurrentChartMove,
- chartResize:!!Store.chartparam.luckysheetCurrentChartResize,
- rangeResize:!!formula.rangeResize ,
- rangeMove:!!formula.rangeMove,
- }
-
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- if(Store.flowdata && Store.flowdata[row_index]){
- method.createHookFunction("sheetMousemove", Store.flowdata[row_index][col_index], {
- r:row_index,
- c:col_index,
- "start_r": row_pre,
- "start_c": col_pre,
- "end_r": row,
- "end_c": col
- }, sheetFile,moveState,luckysheetTableContent);
- }
- // }
- }
-
- if(formula.functionResizeStatus){
- let y = event.pageY;
- let movepx = y - formula.functionResizeData.y;
- let mpx = formula.functionResizeData.calculatebarHeight + movepx;
- let winh = Math.round($(window).height() / 2);
- if (mpx <= 28) {
- if (mpx <= 20) {
- return;
- }
- mpx = 28;
- }
- else if (mpx >= winh) {
- if (mpx >= winh + 8) {
- return;
- }
- mpx = winh;
- }
- Store.calculatebarHeight = mpx;
- $("#luckysheet-wa-calculate").css("height", Store.calculatebarHeight - 2);
- $("#luckysheet-wa-calculate-size").css({ "background": "#5e5e5e", "cursor": "ns-resize" });
- clearTimeout(formula.functionResizeTimeout);
- formula.functionResizeTimeout = setTimeout(function () {
- luckysheetsizeauto();
- }, 15);
- }
- else if (!!luckysheetFreezen.horizontalmovestate) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let top = mouse[1] + Store.columnHeaderHeight;
- if (top < Store.columnHeaderHeight) {
- top = Store.columnHeaderHeight;
- }
- if (top > luckysheetFreezen.windowHeight - 4) {
- top = luckysheetFreezen.windowHeight - 4;
- }
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css({ "top": top });
- if (top + scrollTop - Store.columnHeaderHeight >= row_pre + (row - row_pre) / 2) {
- top = row - 2 - scrollTop + Store.columnHeaderHeight;
- luckysheetFreezen.freezenhorizontaldata = [row, row_index + 1, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_index + 1), top];
- }
- else {
- top = row_pre - 2 - scrollTop + Store.columnHeaderHeight;
- luckysheetFreezen.freezenhorizontaldata = [row_pre, row_index, scrollTop, luckysheetFreezen.cutVolumn(Store.visibledatarow, row_index), top];
- }
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-drop").css({ "top": top });
- luckysheetFreezen.saveFreezen(luckysheetFreezen.freezenhorizontaldata, top, null, null);
- }
- else if (!!luckysheetFreezen.verticalmovestate) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let left = mouse[0] + Store.rowHeaderWidth;
- if (left < Store.rowHeaderWidth) {
- left = Store.rowHeaderWidth;
- }
- if (left > luckysheetFreezen.windowWidth - 4) {
- left = luckysheetFreezen.windowWidth - 4;
- }
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css({ "left": left });
- if (left + scrollLeft - Store.rowHeaderWidth >= col_pre + (col - col_pre) / 2) {
- left = col - 2 - scrollLeft + Store.rowHeaderWidth;
- luckysheetFreezen.freezenverticaldata = [col, col_index + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_index + 1), left];
- }
- else {
- left = col_pre - 2 - scrollLeft + Store.rowHeaderWidth;
- luckysheetFreezen.freezenverticaldata = [col_pre, col_index, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_index), left];
- }
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-drop").css({ "left": left });
- luckysheetFreezen.saveFreezen(null, null, luckysheetFreezen.freezenverticaldata, left);
- luckysheetsizeauto();//调节选区时下部单元格溢出
- }
- else if (!!pivotTable && pivotTable.movestate) {
- let x = event.pageX, y = event.pageY;
- $("#luckysheet-modal-dialog-slider-pivot-move").css({
- "left": x - pivotTable.movesave.width / 2,
- "top": y - pivotTable.movesave.height
- });
- }
- else if (Store.luckysheet_sheet_move_status) {
- let scrollLeft = $("#luckysheet-sheet-container-c").scrollLeft();
- let x = event.pageX + scrollLeft;
- if (Math.abs(event.pageX - Store.luckysheet_sheet_move_data.pageX) < 3) {
- return;
- }
- let winW = $("#luckysheet-sheet-container").width();
- let left = x - Store.luckysheet_sheet_move_data.curleft - $("#luckysheet-sheet-container").offset().left;
- Store.luckysheet_sheet_move_data.activeobject.css({ "left": left });
- let row_index = luckysheet_searcharray(Store.luckysheet_sheet_move_data.widthlist, left + Store.luckysheet_sheet_move_data.curleft);
- Store.luckysheet_sheet_move_data.cursorobject.css({ "cursor": "move" });
- if (left - scrollLeft <= 6) {
- $("#luckysheet-sheets-leftscroll").click();
- }
- if (left - scrollLeft >= winW - 40) {
- $("#luckysheet-sheets-rightscroll").click();
- }
- if (row_index != Store.luckysheet_sheet_move_data.curindex) {
- if (row_index == -1 && left > 0) {
- row_index = Store.luckysheet_sheet_move_data.widthlist.length - 1;
- $("#luckysheet-sheets-item-clone").insertAfter($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").eq(row_index));
- }
- else if (row_index == -1 && left <= 0) {
- $("#luckysheet-sheets-item-clone").insertBefore($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").eq(0));
- }
- else {
- $("#luckysheet-sheets-item-clone").insertAfter($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").eq(row_index));
- }
- Store.luckysheet_sheet_move_data.widthlist = [];
- $("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").each(function (i) {
- if (i == 0) {
- Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()));
- }
- else {
- Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()) + Store.luckysheet_sheet_move_data.widthlist[i - 1]);
- }
- });
- Store.luckysheet_sheet_move_data.curindex = $("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").index($("#luckysheet-sheets-item-clone"));
- }
- }
- else if (Store.luckysheet_model_move_state) {
- let scrollTop = $(document).scrollTop(), scrollLeft = $(document).scrollLeft();
- let y = event.pageY + scrollTop, x = event.pageX + scrollLeft;
- let winH = $(window).height(), winW = $(window).width();
- let myh = Store.luckysheet_model_move_obj.height(),
- myw = Store.luckysheet_model_move_obj.width();
- let top = y - Store.luckysheet_model_xy[1],
- left = x - Store.luckysheet_model_xy[0];
- if (top < 0) {
- top = 0;
- }
- if (top + myh + 62 > winH) {
- top = winH - myh - 62;
- }
- if (left < 0) {
- left = 0;
- }
- if (left + myw + 86 > winW) {
- left = winW - myw - 86;
- }
- Store.luckysheet_model_move_obj.css({ "top": top, "left": left });
- event.preventDefault();
- }
- 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) {
- if (Store.luckysheet_select_status) {
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- }
-
- function mouseRender() {
- if (Store.luckysheet_scroll_status && !Store.luckysheet_cols_change_size && !Store.luckysheet_rows_change_size) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let left = $("#luckysheet-scrollbar-x").scrollLeft(),
- top = $("#luckysheet-scrollbar-y").scrollTop();
- let x = mouse[0];
- let y = mouse[1];
- let winH = $("#luckysheet-cell-main").height() - 20*Store.zoomRatio,
- winW = $("#luckysheet-cell-main").width() - 60*Store.zoomRatio;
- if (y < 0 || y > winH) {
- let stop;
- if (y < 0) {
- stop = top + y / 2;
- }
- else {
- stop = top + (y - winH) / 2;
- }
- $("#luckysheet-scrollbar-y").scrollTop(stop);
- }
- if (x < 0 || x > winW) {
- let sleft;
- if (x < 0) {
- sleft = left + x / 2;
- }
- else {
- sleft = left + (x - winW) / 2;
- }
- $("#luckysheet-scrollbar-x").scrollLeft(sleft);
- }
- }
- if (Store.luckysheet_select_status) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- if(!checkProtectionSelectLockedOrUnLockedCells(row_index, col_index, Store.currentSheetIndex)){
- // Store.luckysheet_select_status = false;
- return;
- }
- let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]);
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
- selectHightlightShow();
- luckysheetFreezen.scrollFreezen();
- // selectHelpboxFill();
- //交替颜色选择范围
- if ($("#luckysheet-alternateformat-rangeDialog").is(":visible")) {
- $("#luckysheet-alternateformat-rangeDialog input").val(getRangetxt(Store.currentSheetIndex, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]));
- }
- if (pivotTable.luckysheet_pivotTable_select_state) {
- $("#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));
- }
- }
- else if (conditionformat.selectStatus) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let last = conditionformat.selectRange[conditionformat.selectRange.length - 1];
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- conditionformat.selectRange[conditionformat.selectRange.length - 1] = last;
- selectionCopyShow(conditionformat.selectRange);
- let range = conditionformat.getTxtByRange(conditionformat.selectRange);
- $("#luckysheet-multiRange-dialog input").val(range);
- }
- else if (dataVerificationCtrl.selectStatus) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let last = dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1];
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- let changeparam = menuButton.mergeMoveMain(columnseleted, rowseleted, last, top, height, left, width);
- if (changeparam != null) {
- columnseleted = changeparam[0];
- rowseleted = changeparam[1];
- top = changeparam[2];
- height = changeparam[3];
- left = changeparam[4];
- width = changeparam[5];
- }
- last["row"] = rowseleted;
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- last["top_move"] = top;
- last["height_move"] = height;
- dataVerificationCtrl.selectRange[dataVerificationCtrl.selectRange.length - 1] = last;
- selectionCopyShow(dataVerificationCtrl.selectRange);
- let range = dataVerificationCtrl.getTxtByRange(dataVerificationCtrl.selectRange);
- if(formula.rangetosheet != Store.currentSheetIndex){
- range = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].name + '!' + range;
- }
- $("#luckysheet-dataVerificationRange-dialog input").val(range);
- }
- else if (formula.rangestart) {
- formula.rangedrag(event);
- }
- else if (formula.rangedrag_row_start) {
- formula.rangedrag_row(event);
- }
- else if (formula.rangedrag_column_start) {
- formula.rangedrag_column(event);
- }
- else if (Store.luckysheet_rows_selected_status) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let y = mouse[1] + $("#luckysheet-rows-h").scrollTop();
- if (y < 0) {
- return false;
- }
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_index = Store.visibledatacolumn.length - 1,
- col = Store.visibledatacolumn[col_index],
- col_pre = 0;
- let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]);
- let top = 0, height = 0, rowseleted = [];
- if (last.top > row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- if (last.row[1] > last.row_focus) {
- last.row[1] = last.row_focus;
- }
- rowseleted = [row_index, last.row[1]];
- }
- else if (last.top == row_pre) {
- top = row_pre;
- height = last.top + last.height - row_pre;
- rowseleted = [row_index, last.row[0]];
- }
- else {
- top = last.top;
- height = row - last.top - 1;
- if (last.row[0] < last.row_focus) {
- last.row[0] = last.row_focus;
- }
- rowseleted = [last.row[0], row_index];
- }
- last["row"] = rowseleted;
- last["top_move"] = top;
- last["height_move"] = height;
- Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
- selectHightlightShow();
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- }
- else if (Store.luckysheet_cols_selected_status) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cols-h-c").scrollLeft();
- if (x < 0) {
- return false;
- }
- let row_index = Store.visibledatarow.length - 1,
- row = Store.visibledatarow[row_index],
- row_pre = 0;
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let last = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]);
- let left = 0, width = 0, columnseleted = [];
- if (last.left > col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- if (last.column[1] > last.column_focus) {
- last.column[1] = last.column_focus;
- }
- columnseleted = [col_index, last.column[1]];
- }
- else if (last.left == col_pre) {
- left = col_pre;
- width = last.left + last.width - col_pre;
- columnseleted = [col_index, last.column[0]];
- }
- else {
- left = last.left;
- width = col - last.left - 1;
- if (last.column[0] < last.column_focus) {
- last.column[0] = last.column_focus;
- }
- columnseleted = [last.column[0], col_index];
- }
- last["column"] = columnseleted;
- last["left_move"] = left;
- last["width_move"] = width;
- Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1] = last;
- selectHightlightShow();
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- }
- else if (Store.luckysheet_cell_selected_move) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
- winW = $(window).width() + scrollLeft;
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let row_index_original = Store.luckysheet_cell_selected_move_index[0],
- col_index_original = Store.luckysheet_cell_selected_move_index[1];
- let row_s = Store.luckysheet_select_save[0]["row"][0] - row_index_original + row_index,
- row_e = Store.luckysheet_select_save[0]["row"][1] - row_index_original + row_index;
- let col_s = Store.luckysheet_select_save[0]["column"][0] - col_index_original + col_index,
- col_e = Store.luckysheet_select_save[0]["column"][1] - col_index_original + col_index;
- if (row_s < 0 || y < 0) {
- row_s = 0;
- row_e = Store.luckysheet_select_save[0]["row"][1] - Store.luckysheet_select_save[0]["row"][0];
- }
- if (col_s < 0 || x < 0) {
- col_s = 0;
- col_e = Store.luckysheet_select_save[0]["column"][1] - Store.luckysheet_select_save[0]["column"][0];
- }
- if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
- row_s = Store.visibledatarow.length - 1 - Store.luckysheet_select_save[0]["row"][1] + Store.luckysheet_select_save[0]["row"][0];
- row_e = Store.visibledatarow.length - 1;
- }
- if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
- col_s = Store.visibledatacolumn.length - 1 - Store.luckysheet_select_save[0]["column"][1] + Store.luckysheet_select_save[0]["column"][0];
- col_e = Store.visibledatacolumn.length - 1;
- }
- col_pre = col_s - 1 == -1 ? 0 : Store.visibledatacolumn[col_s - 1];
- col = Store.visibledatacolumn[col_e];
- row_pre = row_s - 1 == -1 ? 0 : Store.visibledatarow[row_s - 1];
- row = Store.visibledatarow[row_e];
- $("#luckysheet-cell-selected-move").css({
- "left": col_pre,
- "width": col - col_pre - 2,
- "top": row_pre,
- "height": row - row_pre - 2,
- "display": "block"
- });
- }
- else if (Store.luckysheet_cell_selected_extend) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft() - 5;
- let scrollTop = $("#luckysheet-cell-main").scrollTop() - 5;
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
- winW = $(window).width() + scrollLeft;
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let row_index_original = Store.luckysheet_cell_selected_extend_index[0],
- col_index_original = Store.luckysheet_cell_selected_extend_index[1];
- let row_s = Store.luckysheet_select_save[0]["row"][0],
- row_e = Store.luckysheet_select_save[0]["row"][1];
- let col_s = Store.luckysheet_select_save[0]["column"][0],
- col_e = Store.luckysheet_select_save[0]["column"][1];
- if (row_s < 0 || y < 0) {
- row_s = 0;
- row_e = Store.luckysheet_select_save[0]["row"][1] - Store.luckysheet_select_save[0]["row"][0];
- }
- if (col_s < 0 || x < 0) {
- col_s = 0;
- col_e = Store.luckysheet_select_save[0]["column"][1] - Store.luckysheet_select_save[0]["column"][0];
- }
- if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
- row_s = Store.visibledatarow.length - 1 - Store.luckysheet_select_save[0]["row"][1] + Store.luckysheet_select_save[0]["row"][0];
- row_e = Store.visibledatarow.length - 1;
- }
- if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
- col_s = Store.visibledatacolumn.length - 1 - Store.luckysheet_select_save[0]["column"][1] + Store.luckysheet_select_save[0]["column"][0];
- col_e = Store.visibledatacolumn.length - 1;
- }
- let top = Store.luckysheet_select_save[0].top_move,
- height = Store.luckysheet_select_save[0].height_move;
- let left = Store.luckysheet_select_save[0].left_move,
- width = Store.luckysheet_select_save[0].width_move;
- if (Math.abs(row_index_original - row_index) > Math.abs(col_index_original - col_index)) {
- if (!(row_index >= row_s && row_index <= row_e)) {
- if (Store.luckysheet_select_save[0].top_move >= row_pre) {
- top = row_pre;
- height = Store.luckysheet_select_save[0].top_move + Store.luckysheet_select_save[0].height_move - row_pre;
- }
- else {
- top = Store.luckysheet_select_save[0].top_move;
- height = row - Store.luckysheet_select_save[0].top_move - 1;
- }
- }
- }
- else {
- if (!(col_index >= col_s && col_index <= col_e)) {
- if (Store.luckysheet_select_save[0].left_move >= col_pre) {
- left = col_pre;
- width = Store.luckysheet_select_save[0].left_move + Store.luckysheet_select_save[0].width_move - col_pre;
- }
- else {
- left = Store.luckysheet_select_save[0].left_move;
- width = col - Store.luckysheet_select_save[0].left_move - 1;
- }
- }
- }
- $("#luckysheet-cell-selected-extend").css({
- "left": left,
- "width": width,
- "top": top,
- "height": height,
- "display": "block"
- });
- }
- else if (Store.luckysheet_cols_change_size) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft();
- let x = mouse[0] + scrollLeft;
- let winW = $(window).width();
- let row_index = Store.visibledatarow.length - 1,
- row = Store.visibledatarow[row_index],
- row_pre = 0;
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
-
- if ((x + 3) - Store.luckysheet_cols_change_size_start[0] > 30 && x < winW + scrollLeft - 100) {
- $("#luckysheet-change-size-line").css({ "left": x });
- $("#luckysheet-cols-change-size").css({ "left": x - 2 });
- }
- }
- else if (Store.luckysheet_rows_change_size) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollTop = $("#luckysheet-rows-h").scrollTop();
- let y = mouse[1] + scrollTop;
- let winH = $(window).height();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- if ((y + 3) - Store.luckysheet_rows_change_size_start[0] > 19 && y < winH + scrollTop - 200) {
- $("#luckysheet-change-size-line").css({ "top": y });
- $("#luckysheet-rows-change-size").css({ "top": y });
- }
- }
- // chart move
- else if (!!Store.chartparam.luckysheetCurrentChartMove) {
- const mouse = mouseposition(event.pageX, event.pageY);
- const x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- const y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- const myh = Store.chartparam.luckysheetCurrentChartMoveObj.height(), myw = Store.chartparam.luckysheetCurrentChartMoveObj.width();
- let top = y - Store.chartparam.luckysheetCurrentChartMoveXy[1], left = x - Store.chartparam.luckysheetCurrentChartMoveXy[0];
- if (top < 0) {
- top = 0;
- }
- if (top + myh + 42 + 6 > Store.chartparam.luckysheetCurrentChartMoveWinH) {
- top = Store.chartparam.luckysheetCurrentChartMoveWinH - myh - 42 - 6;
- }
- if (left < 0) {
- left = 0;
- }
- if (left + myw + 22 + 36 > Store.chartparam.luckysheetCurrentChartMoveWinW) {
- left = Store.chartparam.luckysheetCurrentChartMoveWinW - myw - 22 - 36;
- }
- Store.chartparam.luckysheetCurrentChartMoveObj.css({ "top": top, "left": left });
- if (luckysheetFreezen.freezenhorizontaldata != null || luckysheetFreezen.freezenverticaldata != null) {
- luckysheetFreezen.scrollAdapt();
- const toffset = Store.chartparam.luckysheetCurrentChartMoveObj.offset();
- const tpsition = Store.chartparam.luckysheetCurrentChartMoveObj.position();
- Store.chartparam.luckysheetCurrentChartMoveXy = [event.pageX - toffset.left, event.pageY - toffset.top, tpsition.left, tpsition.top, $("#luckysheet-scrollbar-x").scrollLeft(), $("#luckysheet-scrollbar-y").scrollTop()];
- }
- }
- // chart resize
- else if (!!Store.chartparam.luckysheetCurrentChartResize) {
- const scrollTop = $("#luckysheet-cell-main").scrollTop(), scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- const mouse = mouseposition(event.pageX, event.pageY);
- const x = mouse[0] + scrollLeft;
- const y = mouse[1] + scrollTop;
- if (x < 0 || y < 0) {
- return false;
- }
- const myh = Store.chartparam.luckysheetCurrentChartResizeObj.height(), myw = Store.chartparam.luckysheetCurrentChartResizeObj.width();
- const topchange = y - Store.chartparam.luckysheetCurrentChartResizeXy[1], leftchange = x - Store.chartparam.luckysheetCurrentChartResizeXy[0];
- let top = Store.chartparam.luckysheetCurrentChartResizeXy[5], height = Store.chartparam.luckysheetCurrentChartResizeXy[3], left = Store.chartparam.luckysheetCurrentChartResizeXy[4], width = Store.chartparam.luckysheetCurrentChartResizeXy[2];
- if (Store.chartparam.luckysheetCurrentChartResize == "lm" || Store.chartparam.luckysheetCurrentChartResize == "lt" || Store.chartparam.luckysheetCurrentChartResize == "lb") {
- left = x;
- width = Store.chartparam.luckysheetCurrentChartResizeXy[2] - leftchange;
- if (left > Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[4] - 60) {
- left = Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[4] - 60;
- width = Store.chartparam.luckysheetCurrentChartResizeXy[2] - (Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[4] - 60 - Store.chartparam.luckysheetCurrentChartResizeXy[0]);
- }
- else if (left <= 0) {
- left = 0;
- width = Store.chartparam.luckysheetCurrentChartResizeXy[2] + Store.chartparam.luckysheetCurrentChartResizeXy[0];
- }
- }
- if (Store.chartparam.luckysheetCurrentChartResize == "rm" || Store.chartparam.luckysheetCurrentChartResize == "rt" || Store.chartparam.luckysheetCurrentChartResize == "rb") {
- width = Store.chartparam.luckysheetCurrentChartResizeXy[2] + leftchange;
- if (width < 60) {
- width = 60;
- }
- else if (width >= Store.chartparam.luckysheetCurrentChartResizeWinW - Store.chartparam.luckysheetCurrentChartResizeXy[4] - 22 - 36) {
- width = Store.chartparam.luckysheetCurrentChartResizeWinW - Store.chartparam.luckysheetCurrentChartResizeXy[4] - 22 - 36;
- }
- }
- if (Store.chartparam.luckysheetCurrentChartResize == "mt" || Store.chartparam.luckysheetCurrentChartResize == "lt" || Store.chartparam.luckysheetCurrentChartResize == "rt") {
- top = y;
- height = Store.chartparam.luckysheetCurrentChartResizeXy[3] - topchange;
- if (top > Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[5] - 60) {
- top = Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[5] - 60;
- height = Store.chartparam.luckysheetCurrentChartResizeXy[3] - (Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[5] - 60 - Store.chartparam.luckysheetCurrentChartResizeXy[1]);
- }
- else if (top <= 0) {
- top = 0;
- height = Store.chartparam.luckysheetCurrentChartResizeXy[3] + Store.chartparam.luckysheetCurrentChartResizeXy[1];
- }
- }
- if (Store.chartparam.luckysheetCurrentChartResize == "mb" || Store.chartparam.luckysheetCurrentChartResize == "lb" || Store.chartparam.luckysheetCurrentChartResize == "rb") {
- height = Store.chartparam.luckysheetCurrentChartResizeXy[3] + topchange;
- if (height < 60) {
- height = 60;
- }
- else if (height >= Store.chartparam.luckysheetCurrentChartResizeWinH - Store.chartparam.luckysheetCurrentChartResizeXy[5] - 42 - 6) {
- height = Store.chartparam.luckysheetCurrentChartResizeWinH - Store.chartparam.luckysheetCurrentChartResizeXy[5] - 42 - 6;
- }
- }
- const resizedata = { "top": top, "left": left, "height": height, "width": width };
- Store.chartparam.luckysheetCurrentChartResizeObj.css(resizedata);
- // resize chart
- Store.resizeChart(Store.chartparam.luckysheetCurrentChart)
- }
- //image move
- else if (imageCtrl.move) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let imgItem = imageCtrl.images[imageCtrl.currentImgId];
- if(imgItem.isFixedPos){
- x = event.pageX;
- y = event.pageY;
- }
- let myh = $("#luckysheet-modal-dialog-activeImage").height(),
- myw = $("#luckysheet-modal-dialog-activeImage").width();
- let top = y - imageCtrl.moveXY[1],
- left = x - imageCtrl.moveXY[0];
- let minTop = 0,
- maxTop = imageCtrl.currentWinH - myh - 42 - 6,
- minLeft = 0,
- maxLeft = imageCtrl.currentWinW - myw - 22 - 36;
- if(imgItem.isFixedPos){
- minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
- maxTop = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - myh;
- minLeft = Store.rowHeaderWidth;
- maxLeft = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - myw;
- }
- if (top < minTop) {
- top = minTop;
- }
- if (top > maxTop) {
- top = maxTop;
- }
- if (left < minLeft) {
- left = minLeft;
- }
- if (left > maxLeft) {
- left = maxLeft;
- }
- $("#luckysheet-modal-dialog-activeImage").css({ "left": left, "top": top });
- }
- //image resize
- else if (!!imageCtrl.resize) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- if (x < 0 || y < 0) {
- return false;
- }
- let resizeXY = imageCtrl.resizeXY;
- let topchange = y - resizeXY[1],
- leftchange = x - resizeXY[0];
- let top = resizeXY[5],
- height = resizeXY[3],
- left = resizeXY[4],
- width = resizeXY[2];
- let resize = imageCtrl.resize;
- let imgItem = imageCtrl.images[imageCtrl.currentImgId];
- if(imgItem.isFixedPos){
- let minTop = Store.infobarHeight + Store.toolbarHeight + Store.calculatebarHeight + Store.columnHeaderHeight;
- let minLeft = Store.rowHeaderWidth;
- if(resize == 'lt'){//左上
- left = resizeXY[4] - resizeXY[6] + leftchange;
- if(left < minLeft){
- left = minLeft;
- }
- if(left > resizeXY[4] - resizeXY[6] + resizeXY[2] - 1){
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - 1;
- }
- width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left;
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- top = resizeXY[5] - resizeXY[7] + resizeXY[3] - height;
- if(top < minTop){
- top = minTop;
- height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
- }
- if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){
- top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1;
- height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
- }
- }
- else if(resize == 'lm'){//左中
- left = resizeXY[4] - resizeXY[6] + leftchange;
- if(left < minLeft){
- left = minLeft;
- }
- if(left > resizeXY[4] - resizeXY[6] + resizeXY[2] - 1){
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - 1;
- }
- width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left;
- top = resizeXY[5] - resizeXY[7];
- height = resizeXY[3];
- }
- else if(resize == 'lb'){//左下
- left = resizeXY[4] - resizeXY[6] + leftchange;
- if(left < minLeft){
- left = minLeft;
- }
- if(left > resizeXY[4] - resizeXY[6] + resizeXY[2] - 1){
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - 1;
- }
- width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left;
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- top = resizeXY[5] - resizeXY[7];
- if(height < 1){
- height = 1;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
- }
- if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){
- height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top;
-
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width;
- }
- }
- else if(resize == 'rt'){//右上
- left = resizeXY[4] - resizeXY[6];
- width = resizeXY[2] + leftchange;
- if(width < 1){
- width = 1;
- }
- if(width > minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left){
- width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left;
- }
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- top = resizeXY[5] - resizeXY[7] + resizeXY[3] - height;
- if(top < minTop){
- top = minTop;
- height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){
- top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1;
- height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- }
- else if(resize == 'rm'){//右中
- left = resizeXY[4] - resizeXY[6];
- width = resizeXY[2] + leftchange;
- if(width < 1){
- width = 1;
- }
- if(width > minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left){
- width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left;
- }
- top = resizeXY[5] - resizeXY[7];
- height = resizeXY[3];
- }
- else if(resize == 'rb'){//右下
- left = resizeXY[4] - resizeXY[6];
- width = resizeXY[2] + leftchange;
- if(width < 1){
- width = 1;
- }
- if(width > minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left){
- width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left;
- }
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- top = resizeXY[5] - resizeXY[7];
- if(height < 1){
- height = 1;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){
- height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top;
-
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- }
- else if(resize == 'mt'){//中上
- left = resizeXY[4] - resizeXY[6];
- width = resizeXY[2];
- top = resizeXY[5] - resizeXY[7] + topchange;
- if(top < minTop){
- top = minTop;
- }
- if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){
- top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1;
- }
- height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top;
- }
- else if(resize == 'mb'){//中下
- left = resizeXY[4] - resizeXY[6];
- width = resizeXY[2];
- top = resizeXY[5] - resizeXY[7];
- height = resizeXY[3] + topchange;
- if(height < 1){
- height = 1;
- }
- if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){
- height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top;
- }
- }
- }
- else{
- if(resize == 'lt'){//左上
- left = x;
- width = resizeXY[2] - leftchange;
-
- if (left > resizeXY[2] + resizeXY[4] - 1) {
- left = resizeXY[2] + resizeXY[4] - 1;
- width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1);
- }
- else if (left <= 0) {
- left = 0;
- width = resizeXY[2] + resizeXY[0];
- }
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- top = resizeXY[3] + resizeXY[1] - height;
-
- if (top > resizeXY[3] + resizeXY[5] - 1) {
- top = resizeXY[3] + resizeXY[5] - 1;
- height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1);
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[2] + resizeXY[0] - width;
- }
- else if (top <= 0) {
- top = 0;
- height = resizeXY[3] + resizeXY[1];
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[2] + resizeXY[0] - width;
- }
- }
- else if(resize == 'lm'){//左中
- left = x;
- width = resizeXY[2] - leftchange;
-
- if (left > resizeXY[2] + resizeXY[4] - 1) {
- left = resizeXY[2] + resizeXY[4] - 1;
- width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1);
- }
- else if (left <= 0) {
- left = 0;
- width = resizeXY[2] + resizeXY[0];
- }
- }
- else if(resize == 'lb'){//左下
- left = x;
- width = resizeXY[2] - leftchange;
-
- if (left > resizeXY[2] + resizeXY[4] - 1) {
- left = resizeXY[2] + resizeXY[4] - 1;
- width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1);
- }
- else if (left <= 0) {
- left = 0;
- width = resizeXY[2] + resizeXY[0];
- }
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- if (height < 1) {
- height = 1;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[2] + resizeXY[0] - width;
- }
- else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
- height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- left = resizeXY[2] + resizeXY[0] - width;
- }
- }
- else if(resize == 'rt'){//右上
- width = resizeXY[2] + leftchange;
-
- if (width < 1) {
- width = 1;
- }
- else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
- width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
- }
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
- top = resizeXY[3] + resizeXY[1] - height;
-
- if (top > resizeXY[3] + resizeXY[5] - 1) {
- top = resizeXY[3] + resizeXY[5] - 1;
- height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1);
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- else if (top <= 0) {
- top = 0;
- height = resizeXY[3] + resizeXY[1];
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- }
- else if(resize == 'rm'){//右中
- width = resizeXY[2] + leftchange;
-
- if (width < 1) {
- width = 1;
- }
- else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
- width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
- }
- }
- else if(resize == 'rb'){//右下
- width = resizeXY[2] + leftchange;
-
- if (width < 1) {
- width = 1;
- }
- else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) {
- width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36;
- }
- height = Math.round(width * (resizeXY[3] / resizeXY[2]));
-
- if (height < 1) {
- height = 1;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
- height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
- width = Math.round(height * (resizeXY[2] / resizeXY[3]));
- }
- }
- else if(resize == 'mt'){//中上
- top = y;
- height = resizeXY[3] - topchange;
-
- if (top > resizeXY[3] + resizeXY[5] - 1) {
- top = resizeXY[3] + resizeXY[5] - 1;
- height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1);
- }
- else if (top <= 0) {
- top = 0;
- height = resizeXY[3] + resizeXY[1];
- }
- }
- else if(resize == 'mb'){//中下
- height = resizeXY[3] + topchange;
-
- if (height < 1) {
- height = 1;
- }
- else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) {
- height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6;
- }
- }
- }
- $("#luckysheet-modal-dialog-activeImage").css({
- "width": width,
- "height": height,
- "left": left,
- "top": top
- });
-
- let scaleX = width / imgItem.crop.width;
- let scaleY = height / imgItem.crop.height;
- let defaultWidth = Math.round(imgItem.default.width * scaleX);
- let defaultHeight = Math.round(imgItem.default.height * scaleY);
- let offsetLeft = Math.round(imgItem.crop.offsetLeft * scaleX);
- let offsetTop = Math.round(imgItem.crop.offsetTop * scaleY);
-
- $("#luckysheet-modal-dialog-activeImage .luckysheet-modal-dialog-content").css({
- "background-size": defaultWidth + "px " + defaultHeight + "px",
- "background-position": -offsetLeft + "px " + -offsetTop + "px"
- })
- }
- //image cropChange
- else if (!!imageCtrl.cropChange) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- if (x < 0 || y < 0) {
- return false;
- }
- let cropChangeXY = imageCtrl.cropChangeXY;
- let topchange = y - cropChangeXY[1],
- leftchange = x - cropChangeXY[0];
- let imgItem = imageCtrl.images[imageCtrl.currentImgId];
- let cropChange = imageCtrl.cropChange;
- let width, height, offsetLeft, offsetTop;
- if(cropChange == 'lt'){//左上
- offsetLeft = imgItem.crop.offsetLeft + leftchange;
- if(offsetLeft < 0){
- offsetLeft = 0;
- }
- if(offsetLeft > imgItem.crop.width + imgItem.crop.offsetLeft - 1){
- offsetLeft = imgItem.crop.width + imgItem.crop.offsetLeft - 1;
- }
- width = imgItem.crop.width + imgItem.crop.offsetLeft - offsetLeft;
- offsetTop = imgItem.crop.offsetTop + topchange;
- if(offsetTop < 0){
- offsetTop = 0;
- }
- if(offsetTop > imgItem.crop.height + imgItem.crop.offsetTop - 1){
- offsetTop = imgItem.crop.height + imgItem.crop.offsetTop - 1;
- }
- height = imgItem.crop.height + imgItem.crop.offsetTop - offsetTop;
- }
- else if(cropChange == 'lm'){//左中
- offsetLeft = imgItem.crop.offsetLeft + leftchange;
- if(offsetLeft < 0){
- offsetLeft = 0;
- }
- if(offsetLeft > imgItem.crop.width + imgItem.crop.offsetLeft - 1){
- offsetLeft = imgItem.crop.width + imgItem.crop.offsetLeft - 1;
- }
- width = imgItem.crop.width + imgItem.crop.offsetLeft - offsetLeft;
- offsetTop = imgItem.crop.offsetTop;
- height = imgItem.crop.height;
- }
- else if(cropChange == 'lb'){//左下
- offsetLeft = imgItem.crop.offsetLeft + leftchange;
- if(offsetLeft < 0){
- offsetLeft = 0;
- }
- if(offsetLeft > imgItem.crop.width + imgItem.crop.offsetLeft - 1){
- offsetLeft = imgItem.crop.width + imgItem.crop.offsetLeft - 1;
- }
- width = imgItem.crop.width + imgItem.crop.offsetLeft - offsetLeft;
- offsetTop = imgItem.crop.offsetTop;
- height = imgItem.crop.height + topchange;
-
- if(height < 1){
- height = 1;
- }
- if(height > imgItem.default.height - offsetTop){
- height = imgItem.default.height - offsetTop;
- }
- }
- else if(cropChange == 'rt'){//右上
- offsetLeft = imgItem.crop.offsetLeft;
- width = imgItem.crop.width + leftchange;
- if(width < 1){
- width = 1;
- }
- if(width > imgItem.default.width - offsetLeft){
- width = imgItem.default.width - offsetLeft;
- }
- offsetTop = imgItem.crop.offsetTop + topchange;
- if(offsetTop < 0){
- offsetTop = 0;
- }
- if(offsetTop > imgItem.crop.height + imgItem.crop.offsetTop - 1){
- offsetTop = imgItem.crop.height + imgItem.crop.offsetTop - 1;
- }
- height = imgItem.crop.height + imgItem.crop.offsetTop - offsetTop;
- }
- else if(cropChange == 'rm'){//右中
- offsetLeft = imgItem.crop.offsetLeft;
- width = imgItem.crop.width + leftchange;
- if(width < 1){
- width = 1;
- }
- if(width > imgItem.default.width - offsetLeft){
- width = imgItem.default.width - offsetLeft;
- }
- offsetTop = imgItem.crop.offsetTop;
- height = imgItem.crop.height;
- }
- else if(cropChange == 'rb'){//右下
- offsetLeft = imgItem.crop.offsetLeft;
- width = imgItem.crop.width + leftchange;
- if(width < 1){
- width = 1;
- }
- if(width > imgItem.default.width - offsetLeft){
- width = imgItem.default.width - offsetLeft;
- }
- offsetTop = imgItem.crop.offsetTop;
- height = imgItem.crop.height + topchange;
- if(height < 1){
- height = 1;
- }
- if(height > imgItem.default.height - offsetTop){
- height = imgItem.default.height - offsetTop;
- }
- }
- else if(cropChange == 'mt'){//中上
- offsetLeft = imgItem.crop.offsetLeft;
- width = imgItem.crop.width;
- offsetTop = imgItem.crop.offsetTop + topchange;
- if(offsetTop < 0){
- offsetTop = 0;
- }
- if(offsetTop > imgItem.crop.height + imgItem.crop.offsetTop - 1){
- offsetTop = imgItem.crop.height + imgItem.crop.offsetTop - 1;
- }
- height = imgItem.crop.height + imgItem.crop.offsetTop - offsetTop;
- }
- else if(cropChange == 'mb'){//中下
- offsetLeft = imgItem.crop.offsetLeft;
- width = imgItem.crop.width;
- offsetTop = imgItem.crop.offsetTop;
- height = imgItem.crop.height + topchange;
- if(height < 1){
- height = 1;
- }
- if(height > imgItem.default.height - offsetTop){
- height = imgItem.default.height - offsetTop;
- }
- }
- let left = imgItem.default.left + offsetLeft;
- let top = imgItem.default.top + offsetTop;
- if(imgItem.isFixedPos){
- left = imgItem.fixedLeft + offsetLeft;
- top = imgItem.fixedTop + offsetTop;
- }
- $("#luckysheet-modal-dialog-cropping").show().css({
- "width": width,
- "height": height,
- "left": left,
- "top": top
- });
- let imageUrlHandle = Store.toJsonOptions && Store.toJsonOptions['imageUrlHandle'];
- let imgSrc = typeof imageUrlHandle === 'function' ? imageUrlHandle(imgItem.src) : imgItem.src;
-
- $("#luckysheet-modal-dialog-cropping .cropping-mask").css({
- "width": imgItem.default.width,
- "height": imgItem.default.height,
- "background-image": "url(" + imgSrc + ")",
- "left": -offsetLeft,
- "top": -offsetTop
- })
-
- $("#luckysheet-modal-dialog-cropping .cropping-content").css({
- "background-image": "url(" + imgSrc + ")",
- "background-size": imgItem.default.width + "px " + imgItem.default.height + "px",
- "background-position": -offsetLeft + "px " + -offsetTop + "px"
- })
- imageCtrl.cropChangeObj = {
- width: width,
- height: height,
- offsetLeft: offsetLeft,
- offsetTop: offsetTop
- }
- }
- else if (luckysheetPostil.move) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let myh = luckysheetPostil.currentObj.outerHeight(),
- myw = luckysheetPostil.currentObj.outerWidth();
- let top = y - luckysheetPostil.moveXY[1],
- left = x - luckysheetPostil.moveXY[0];
- if (top < 0) {
- top = 0;
- }
- if (top + myh + 42 + 6 > luckysheetPostil.currentWinH) {
- top = luckysheetPostil.currentWinH - myh - 42 - 6;
- }
- if (left < 0) {
- left = 0;
- }
- if (left + myw + 22 + 36 > luckysheetPostil.currentWinW) {
- left = luckysheetPostil.currentWinW - myw - 22 - 36;
- }
- luckysheetPostil.currentObj.css({ "left": left, "top": top });
- }
- else if (!!luckysheetPostil.resize) {
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- if (x < 0 || y < 0) {
- return false;
- }
- let resizeXY = luckysheetPostil.resizeXY;
- let topchange = y - resizeXY[1],
- leftchange = x - resizeXY[0];
- let top = resizeXY[5],
- height = resizeXY[3],
- left = resizeXY[4],
- width = resizeXY[2];
- let resize = luckysheetPostil.resize;
- if (resize == "lm" || resize == "lt" || resize == "lb") {
- left = x;
- width = resizeXY[2] - leftchange;
- if (left > resizeXY[2] + resizeXY[4] - 60) {
- left = resizeXY[2] + resizeXY[4] - 60;
- width = resizeXY[2] - (resizeXY[2] + resizeXY[4] - 60 - resizeXY[0]);
- }
- else if (left <= 0) {
- left = 0;
- width = resizeXY[2] + resizeXY[0];
- }
- }
- if (resize == "rm" || resize == "rt" || resize == "rb") {
- width = resizeXY[2] + leftchange;
- if (width < 60) {
- width = 60;
- }
- else if (width >= luckysheetPostil.currentWinW - resizeXY[4] - 22 - 36) {
- width = luckysheetPostil.currentWinW - resizeXY[4] - 22 - 36;
- }
- }
- if (resize == "mt" || resize == "lt" || resize == "rt") {
- top = y;
- height = resizeXY[3] - topchange;
- if (top > resizeXY[3] + resizeXY[5] - 60) {
- top = resizeXY[3] + resizeXY[5] - 60;
- height = resizeXY[3] - (resizeXY[3] + resizeXY[5] - 60 - resizeXY[1]);
- }
- else if (top <= 0) {
- top = 0;
- height = resizeXY[3] + resizeXY[1];
- }
- }
- if (resize == "mb" || resize == "lb" || resize == "rb") {
- height = resizeXY[3] + topchange;
- if (height < 60) {
- height = 60;
- }
- else if (height >= luckysheetPostil.currentWinH - resizeXY[5] - 42 - 6) {
- height = luckysheetPostil.currentWinH - resizeXY[5] - 42 - 6;
- }
- }
- luckysheetPostil.currentObj.css({ "width": width, "height": height, "left": left, "top": top });
- }
- else if (!!formula.rangeResize) {
- formula.rangeResizeDraging(event, formula.rangeResizeObj, formula.rangeResizexy, formula.rangeResize, formula.rangeResizeWinW, formula.rangeResizeWinH, Store.ch_width, Store.rh_height);
- }
- else if (!!formula.rangeMove) {
- formula.rangeMoveDraging(event, formula.rangeMovexy, formula.rangeMoveObj.data("range"), formula.rangeMoveObj, Store.sheetBarHeight, Store.statisticBarHeight);
- }
- else if (!!Store.chart_selection.rangeResize) {
- Store.chart_selection.rangeResizeDraging(event, Store.sheetBarHeight, Store.statisticBarHeight);
- }
- else if (!!Store.chart_selection.rangeMove) {
- Store.chart_selection.rangeMoveDraging(event, Store.sheetBarHeight, Store.statisticBarHeight);
- }
- Store.jfautoscrollTimeout = window.requestAnimationFrame(mouseRender);
- }
- Store.jfautoscrollTimeout = window.requestAnimationFrame(mouseRender);
- }
- });
- //表格mouseup
- $(document).on("mouseup.luckysheetEvent",function (event) {
- if(luckysheetConfigsetting && luckysheetConfigsetting.hook && luckysheetConfigsetting.hook.sheetMouseup){
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- row_index = margeset.row[2];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- col_index = margeset.column[2];
- }
- // if(Store.flowdata[row_index] && Store.flowdata[row_index][col_index]){
- let sheetFile = sheetmanage.getSheetByIndex();
- let moveState = {
- functionResizeStatus:formula.functionResizeStatus,
- horizontalmoveState:!!luckysheetFreezen.horizontalmovestate,
- verticalmoveState:!!luckysheetFreezen.verticalmovestate,
- pivotTableMoveState:!!pivotTable && pivotTable.movestate,
- sheetMoveStatus:Store.luckysheet_sheet_move_status,
- scrollStatus:!!Store.luckysheet_scroll_status,
- selectStatus:!!Store.luckysheet_select_status,
- rowsSelectedStatus:!!Store.luckysheet_rows_selected_status,
- colsSelectedStatus:!!Store.luckysheet_cols_selected_status,
- cellSelectedMove:!!Store.luckysheet_cell_selected_move,
- cellSelectedExtend:!!Store.luckysheet_cell_selected_extend,
- colsChangeSize:!!Store.luckysheet_cols_change_size,
- rowsChangeSize:!!Store.luckysheet_rows_change_size,
- chartMove:!!Store.chartparam.luckysheetCurrentChartMove,
- chartResize:!!Store.chartparam.luckysheetCurrentChartResize,
- rangeResize:!!formula.rangeResize ,
- rangeMove:!!formula.rangeMove,
- }
-
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
-
- method.createHookFunction("sheetMouseup", Store.flowdata[row_index][col_index], {
- r:row_index,
- c:col_index,
- "start_r": row_pre,
- "start_c": col_pre,
- "end_r": row,
- "end_c": col
- }, sheetFile,moveState,luckysheetTableContent);
- // }
- }
- //数据窗格主体
- if (Store.luckysheet_select_status) {
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () {
- countfunc();
- }, 0);
- //格式刷
- if (menuButton.luckysheetPaintModelOn) {
- selection.pasteHandlerOfPaintModel(Store.luckysheet_copy_save);
- if (menuButton.luckysheetPaintSingle) {
- //单次 格式刷
- menuButton.cancelPaintModel();
- }
- }
- }
- Store.luckysheet_select_status = false;
- window.cancelAnimationFrame(Store.jfautoscrollTimeout);
- Store.luckysheet_scroll_status = false;
- $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle").css("cursor", "crosshair").end().find(".luckysheet-cs-draghandle").css("cursor", "move");
- $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor", "default");
- //行标题窗格主体
- Store.luckysheet_rows_selected_status = false;
- //列标题窗格主体
- Store.luckysheet_cols_selected_status = false;
- Store.luckysheet_model_move_state = false;
- if (formula.functionResizeStatus) {
- formula.functionResizeStatus = false;
- $("#luckysheet-wa-calculate-size").removeAttr("style");
- }
- if (!!luckysheetFreezen.horizontalmovestate) {
- luckysheetFreezen.horizontalmovestate = false;
- $("#luckysheet-freezebar-horizontal").removeClass("luckysheet-freezebar-active");
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css("cursor", "-webkit-grab");
- if (luckysheetFreezen.freezenhorizontaldata[4] <= Store.columnHeaderHeight) {
- luckysheetFreezen.cancelFreezenHorizontal();
- }
- luckysheetFreezen.createAssistCanvas();
- luckysheetrefreshgrid();
- }
- if (!!luckysheetFreezen.verticalmovestate) {
- luckysheetFreezen.verticalmovestate = false;
- $("#luckysheet-freezebar-vertical").removeClass("luckysheet-freezebar-active");
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css("cursor", "-webkit-grab");
- if (luckysheetFreezen.freezenverticaldata[4] <= Store.rowHeaderWidth) {
- luckysheetFreezen.cancelFreezenVertical();
- }
- luckysheetFreezen.createAssistCanvas();
- luckysheetrefreshgrid();
- }
- if (!!pivotTable && pivotTable.movestate) {
- $("#luckysheet-modal-dialog-slider-pivot-move").remove();
- pivotTable.movestate = false;
- $("#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");
- if (pivotTable.movesave.containerid != "luckysheet-modal-dialog-pivotTable-list") {
- let $cur = $(event.target).closest(".luckysheet-modal-dialog-slider-config-list");
- if ($cur.length == 0) {
- if (pivotTable.movesave.containerid == "luckysheet-modal-dialog-config-value") {
- pivotTable.resetOrderby(pivotTable.movesave.obj);
- }
- pivotTable.movesave.obj.remove();
- pivotTable.showvaluecolrow();
- $("#luckysheet-modal-dialog-pivotTable-list").find(".luckysheet-modal-dialog-slider-list-item").each(function () {
- $(this).find(".luckysheet-slider-list-item-selected").find("i").remove();
- });
- $("#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 () {
- let index = $(this).data("index");
- $("#luckysheet-modal-dialog-pivotTable-list").find(".luckysheet-modal-dialog-slider-list-item").each(function () {
- let $seleted = $(this).find(".luckysheet-slider-list-item-selected");
- if ($(this).data("index") == index && $seleted.find("i").length == 0) {
- $seleted.append('<i class="fa fa-check luckysheet-mousedown-cancel"></i>');
- }
- });
- });
- pivotTable.refreshPivotTable();
- }
- }
- }
- if (Store.luckysheet_sheet_move_status) {
- Store.luckysheet_sheet_move_status = false;
- Store.luckysheet_sheet_move_data.activeobject.insertBefore($("#luckysheet-sheets-item-clone"));
- Store.luckysheet_sheet_move_data.activeobject.removeAttr("style");
- $("#luckysheet-sheets-item-clone").remove();
- Store.luckysheet_sheet_move_data.cursorobject.css({ "cursor": "pointer" });
- Store.luckysheet_sheet_move_data = {};
- sheetmanage.reOrderAllSheet();
- }
- // chart move debounce timer clear
- clearTimeout(Store.chartparam.luckysheetCurrentChartMoveTimeout);
- //图表拖动 chartMix
- if (!!Store.chartparam.luckysheetCurrentChartMove) {
- Store.chartparam.luckysheetCurrentChartMove = false;
- if (Store.chartparam.luckysheetInsertChartTosheetChange) {
- //myTop, myLeft: 本次的chart框位置,scrollLeft,scrollTop: 上一次的滚动条位置
- var myTop = Store.chartparam.luckysheetCurrentChartMoveObj.css("top"), myLeft = Store.chartparam.luckysheetCurrentChartMoveObj.css("left"), scrollLeft = $("#luckysheet-cell-main").scrollLeft(), scrollTop = $("#luckysheet-cell-main").scrollTop();
- //点击时候存储的信息,即上一次操作结束的图表信息,x,y: chart框位置,scrollLeft1,scrollTop1: 滚动条位置
- var x = Store.chartparam.luckysheetCurrentChartMoveXy[2];
- var y = Store.chartparam.luckysheetCurrentChartMoveXy[3];
- var scrollLeft1 = Store.chartparam.luckysheetCurrentChartMoveXy[4];
- var scrollTop1 = Store.chartparam.luckysheetCurrentChartMoveXy[5];
- var chart_id = Store.chartparam.luckysheetCurrentChartMoveObj.find(".luckysheet-modal-dialog-content").attr("id");
- //去除chartobj,改用chart_id代替即可定位到此图表
- 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 });
- // luckysheet.sheetmanage.saveChart({ "chart_id": chart_id, "sheetIndex": sheetIndex, "top": myTop, "left": myLeft });
- //存储滚动条位置//协同编辑时可能影响用户操作,可以考虑不存储滚动条位置,或者滚动条信息仅仅保存到后台,但是不分发到其他设备(google sheet没有存储滚动条位置)
- // Store.server.saveParam("c", sheetIndex, { "left":myLeft, "top":myTop,"scrollTop": scrollTop, "scrollLeft": scrollLeft }, { "op":"xy", "cid": chart_id});
- }
- }
- //图表改变大小 chartMix
- if (!!Store.chartparam.luckysheetCurrentChartResize) {
- Store.chartparam.luckysheetCurrentChartResize = null;
- if (Store.chartparam.luckysheetInsertChartTosheetChange) {
- var myHeight = Store.chartparam.luckysheetCurrentChartResizeObj.height(), myWidth = Store.chartparam.luckysheetCurrentChartResizeObj.width(), scrollLeft = $("#luckysheet-cell-main").scrollLeft(), scrollTop = $("#luckysheet-cell-main").scrollTop();
- var myTop = Store.chartparam.luckysheetCurrentChartMoveObj.css("top"),
- myLeft = Store.chartparam.luckysheetCurrentChartMoveObj.css("left");
- var chart_id = Store.chartparam.luckysheetCurrentChartResizeObj.find(".luckysheet-modal-dialog-content").attr("id");
- var myWidth1 = Store.chartparam.luckysheetCurrentChartResizeXy[2];
- var myHeight1 = Store.chartparam.luckysheetCurrentChartResizeXy[3];
- var x = Store.chartparam.luckysheetCurrentChartResizeXy[4];//增加上一次的位置x,y
- var y = Store.chartparam.luckysheetCurrentChartResizeXy[5];
- var scrollLeft1 = Store.chartparam.luckysheetCurrentChartResizeXy[6];
- var scrollTop1 = Store.chartparam.luckysheetCurrentChartResizeXy[7];
- 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 });
- //加上滚动条的位置
- // luckysheet.sheetmanage.saveChart({ "chart_id": chart_id, "sheetIndex": sheetIndex, "height": myHeight, "width": myWidth, "top": myTop, "left": myLeft, "scrollTop": scrollTop, "scrollLeft": scrollLeft });
- // Store.server.saveParam("c", sheetIndex, { "width":myWidth, "height":myHeight, "top": myTop, "left": myLeft, "scrollTop": scrollTop, "scrollLeft": scrollLeft}, { "op":"wh", "cid": chart_id});
- }
- }
- if (!!formula.rangeResize) {
- formula.rangeResizeDragged(event, formula.rangeResizeObj, formula.rangeResize, formula.rangeResizexy, formula.rangeResizeWinW, formula.rangeResizeWinH);
- }
- //image move
- if (imageCtrl.move) {
- imageCtrl.moveImgItem();
- }
- //image resize
- if (imageCtrl.resize) {
- imageCtrl.resizeImgItem();
- }
- //image cropChange
- if (imageCtrl.cropChange) {
- imageCtrl.cropChangeImgItem();
- }
- //批注框 移动
- if (luckysheetPostil.move) {
- luckysheetPostil.move = false;
- let ps_id = luckysheetPostil.currentObj.closest(".luckysheet-postil-show").attr("id");
- let ps_r = ps_id.split("luckysheet-postil-show_")[1].split("_")[0];
- let ps_c = ps_id.split("luckysheet-postil-show_")[1].split("_")[1];
- let d = editor.deepCopyFlowData(Store.flowdata);
- let rc = [];
- d[ps_r][ps_c].ps.left = luckysheetPostil.currentObj.position().left;
- d[ps_r][ps_c].ps.top = luckysheetPostil.currentObj.position().top;
- d[ps_r][ps_c].ps.value = luckysheetPostil.currentObj.find(".formulaInputFocus").html().replaceAll('<div>', '\n').replaceAll(/<(.*)>.*?|<(.*) \/>/g, '').trim();
- rc.push(ps_r + "_" + ps_c);
- luckysheetPostil.ref(d, rc);
- $("#" + ps_id).remove();
- if (d[ps_r][ps_c].ps.isshow) {
- luckysheetPostil.buildPs(ps_r, ps_c, d[ps_r][ps_c].ps);
- $("#" + ps_id).addClass("luckysheet-postil-show-active");
- $("#" + ps_id).find(".luckysheet-postil-dialog-resize").show();
- }
- else {
- luckysheetPostil.editPs(ps_r, ps_c);
- }
- }
- //批注框 改变大小
- if (!!luckysheetPostil.resize) {
- luckysheetPostil.resize = null;
- let ps_id = luckysheetPostil.currentObj.closest(".luckysheet-postil-show").attr("id");
- let ps_r = ps_id.split("luckysheet-postil-show_")[1].split("_")[0];
- let ps_c = ps_id.split("luckysheet-postil-show_")[1].split("_")[1];
- let d = editor.deepCopyFlowData(Store.flowdata);
- let rc = [];
- d[ps_r][ps_c].ps.left = luckysheetPostil.currentObj.position().left;
- d[ps_r][ps_c].ps.top = luckysheetPostil.currentObj.position().top;
- d[ps_r][ps_c].ps.width = luckysheetPostil.currentObj.outerWidth();
- d[ps_r][ps_c].ps.height = luckysheetPostil.currentObj.outerHeight();
- d[ps_r][ps_c].ps.value = luckysheetPostil.currentObj.find(".formulaInputFocus").html().replaceAll('<div>', '\n').replaceAll(/<(.*)>.*?|<(.*) \/>/g, '').trim();
- rc.push(ps_r + "_" + ps_c);
- luckysheetPostil.ref(d, rc);
- $("#" + ps_id).remove();
- if (d[ps_r][ps_c].ps.isshow) {
- luckysheetPostil.buildPs(ps_r, ps_c, d[ps_r][ps_c].ps);
- $("#" + ps_id).addClass("luckysheet-postil-show-active");
- $("#" + ps_id).find(".luckysheet-postil-dialog-resize").show();
- }
- else {
- luckysheetPostil.editPs(ps_r, ps_c);
- }
- }
- //改变行高
- if (Store.luckysheet_rows_change_size) {
- Store.luckysheet_rows_change_size = false;
- $("#luckysheet-change-size-line").hide();
- $("#luckysheet-rows-change-size").css("opacity", 0);
- $("#luckysheet-sheettable, #luckysheet-rows-h, #luckysheet-rows-h canvas").css("cursor", "default");
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollTop = $("#luckysheet-rows-h").scrollTop();
- let y = mouse[1] + scrollTop;
- let winH = $(window).height();
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let size = (y + 3) - Store.luckysheet_rows_change_size_start[0];
- if ((y + 3) - Store.luckysheet_rows_change_size_start[0] < 19) {
- size = 19;
- }
- if (y >= winH - 200 + scrollTop) {
- size = winH - 200 - Store.luckysheet_rows_change_size_start[0] + scrollTop;
- }
- let cfg = $.extend(true, {}, Store.config);
- if (cfg["rowlen"] == null) {
- cfg["rowlen"] = {};
- }
- if (cfg["customHeight"] == null) {
- cfg["customHeight"] = {};
- }
- cfg["customHeight"][Store.luckysheet_rows_change_size_start[1]] = 1;
- const changeRowIndex = Store.luckysheet_rows_change_size_start[1];
- let changeRowSelected = false;
- if(Store["luckysheet_select_save"].length > 0) {
- Store["luckysheet_select_save"].filter(select => select.row_select).some((select) => {
- if(changeRowIndex >= select.row[0] && changeRowIndex <= select.row[1]) {
- changeRowSelected = true;
- }
- return changeRowSelected;
- });
- }
- if(changeRowSelected) {
- Store["luckysheet_select_save"].filter(select => select.row_select).forEach(select => {
- for(let r = select.row[0]; r <= select.row[1]; r++) {
- cfg["rowlen"][r] = Math.ceil(size/Store.zoomRatio);
- }
- })
- }
- else {
- cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
- }
- let images = imageCtrl.moveChangeSize("row", Store.luckysheet_rows_change_size_start[1], size);
- if (Store.clearjfundo) {
- Store.jfundo.length = 0;
- Store.jfredo.push({
- "type": "resize",
- "ctrlType": "resizeR",
- "sheetIndex": Store.currentSheetIndex,
- "config": $.extend(true, {}, Store.config),
- "curconfig": $.extend(true, {}, cfg),
- "images": $.extend(true, {}, imageCtrl.images),
- "curImages": $.extend(true, {}, images)
- });
- }
- //config
- Store.config = cfg;
- Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
- server.saveParam("cg", Store.currentSheetIndex, cfg["rowlen"], { "k": "rowlen" });
- //images
- Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].images = images;
- server.saveParam("all", Store.currentSheetIndex, images, { "k": "images" });
- imageCtrl.images = images;
- imageCtrl.allImagesShow();
- jfrefreshgrid_rhcw(Store.flowdata.length, null);
- }
-
- //改变列宽
- if (Store.luckysheet_cols_change_size) {
- Store.luckysheet_cols_change_size = false;
- $("#luckysheet-change-size-line").hide();
- $("#luckysheet-cols-change-size").css("opacity", 0);
- $("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "default");
-
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft();
- let x = mouse[0] + scrollLeft;
- let winW = $(window).width();
- let row_index = Store.visibledatarow.length - 1,
- row = Store.visibledatarow[row_index],
- row_pre = 0;
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let size = (x + 3) - Store.luckysheet_cols_change_size_start[0];
-
- let firstcolumnlen = Store.defaultcollen;
- if (Store.config["columnlen"] != null && Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]] != null) {
- firstcolumnlen = Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]];
- }
- if (Math.abs(size - firstcolumnlen) < 3) {
- return;
- }
- if ((x + 3) - Store.luckysheet_cols_change_size_start[0] < 30) {
- size = 30;
- }
- if (x >= winW - 100 + scrollLeft) {
- size = winW - 100 - Store.luckysheet_cols_change_size_start[0] + scrollLeft;
- }
- let cfg = $.extend(true, {}, Store.config);
- if (cfg["columnlen"] == null) {
- cfg["columnlen"] = {};
- }
- if (cfg["customWidth"] == null) {
- cfg["customWidth"] = {};
- }
- cfg["customWidth"][Store.luckysheet_cols_change_size_start[1]] = 1;
- const changeColumnIndex = Store.luckysheet_cols_change_size_start[1];
- let changeColumnSelected = false;
- if(Store["luckysheet_select_save"].length > 0) {
- Store["luckysheet_select_save"].filter(select => select.column_select).some((select) => {
- if(changeColumnIndex >= select.column[0] && changeColumnIndex <= select.column[1]) {
- changeColumnSelected = true;
- }
- return changeColumnSelected;
- });
- }
- if(changeColumnSelected) {
- Store["luckysheet_select_save"].filter(select => select.column_select).forEach(select => {
- for(let r = select.column[0]; r <= select.column[1]; r++) {
- cfg["columnlen"][r] = Math.ceil(size/Store.zoomRatio);
- }
- })
- }
- else {
- cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
- }
-
- let images = imageCtrl.moveChangeSize("column", Store.luckysheet_cols_change_size_start[1], size);
- if (Store.clearjfundo) {
- Store.jfundo.length = 0;
- Store.jfredo.push({
- "type": "resize",
- "ctrlType": "resizeC",
- "sheetIndex": Store.currentSheetIndex,
- "config": $.extend(true, {}, Store.config),
- "curconfig": $.extend(true, {}, cfg),
- "images": $.extend(true, {}, imageCtrl.images),
- "curImages": $.extend(true, {}, images)
- });
- }
- //config
- Store.config = cfg;
- Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
- server.saveParam("cg", Store.currentSheetIndex, cfg["columnlen"], { "k": "columnlen" });
- //images
- Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].images = images;
- server.saveParam("all", Store.currentSheetIndex, images, { "k": "images" });
- imageCtrl.images = images;
- imageCtrl.allImagesShow();
- jfrefreshgrid_rhcw(null, Store.flowdata[0].length);
- setTimeout(function () {
- luckysheetrefreshgrid();
- }, 1);
- }
- if (formula.rangeMove) {
- formula.rangeMoveDragged(formula.rangeMoveObj);
- }
- //改变选择框的位置并替换目标单元格
- if (Store.luckysheet_cell_selected_move) {
- $("#luckysheet-cell-selected-move").hide();
- Store.luckysheet_cell_selected_move = false;
- let mouse = mouseposition(event.pageX, event.pageY);
- if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){
- return;
- }
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
- winW = $(window).width() + scrollLeft;
- let row_index = rowLocation(y)[2];
- let col_index = colLocation(x)[2];
- let row_index_original = Store.luckysheet_cell_selected_move_index[0],
- col_index_original = Store.luckysheet_cell_selected_move_index[1];
- if (row_index == row_index_original && col_index == col_index_original) {
- return;
- }
- let d = editor.deepCopyFlowData(Store.flowdata);
- let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
- let data = getdatabyselection(last);
- let cfg = $.extend(true, {}, Store.config);
- if (cfg["merge"] == null) {
- cfg["merge"] = {};
- }
- if (cfg["rowlen"] == null) {
- cfg["rowlen"] = {};
- }
- //选区包含部分单元格
- if (hasPartMC(cfg, last["row"][0], last["row"][1], last["column"][0], last["column"][1])) {
- if (isEditMode()) {
- alert(locale_drag.noMerge);
- }
- else {
- tooltip.info('<i class="fa fa-exclamation-triangle"></i>', locale_drag.noMerge);
- }
- return;
- }
- let row_s = last["row"][0] - row_index_original + row_index,
- row_e = last["row"][1] - row_index_original + row_index;
- let col_s = last["column"][0] - col_index_original + col_index,
- col_e = last["column"][1] - col_index_original + col_index;
- if(!checkProtectionLockedRangeList([{row:[row_s, row_e], column:[col_s, col_e]}], Store.currentSheetIndex)){
- return;
- }
- if (row_s < 0 || y < 0) {
- row_s = 0;
- row_e = last["row"][1] - last["row"][0];
- }
- if (col_s < 0 || x < 0) {
- col_s = 0;
- col_e = last["column"][1] - last["column"][0];
- }
- if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
- row_s = Store.visibledatarow.length - 1 - last["row"][1] + last["row"][0];
- row_e = Store.visibledatarow.length - 1;
- }
- if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
- col_s = Store.visibledatacolumn.length - 1 - last["column"][1] + last["column"][0];
- col_e = Store.visibledatacolumn.length - 1;
- }
- //替换的位置包含部分单元格
- if (hasPartMC(cfg, row_s, row_e, col_s, col_e)) {
- if (isEditMode()) {
- alert(locale_drag.noMerge);
- }
- else {
- tooltip.info('<i class="fa fa-exclamation-triangle"></i>', locale_drag.noMerge);
- }
- return;
- }
- let borderInfoCompute = getBorderInfoCompute(Store.currentSheetIndex);
- //删除原本位置的数据
- let RowlChange = null;
- for (let r = last["row"][0]; r <= last["row"][1]; r++) {
- if (r in cfg["rowlen"]) {
- RowlChange = true;
- }
- for (let c = last["column"][0]; c <= last["column"][1]; c++) {
- let cell = d[r][c];
- if (getObjType(cell) == "object" && ("mc" in cell)) {
- if ((cell["mc"].r + "_" + cell["mc"].c) in cfg["merge"]) {
- delete cfg["merge"][cell["mc"].r + "_" + cell["mc"].c];
- }
- }
- d[r][c] = null;
- }
- }
- //边框
- if (cfg["borderInfo"] && cfg["borderInfo"].length > 0) {
- let borderInfo = [];
- for (let i = 0; i < cfg["borderInfo"].length; i++) {
- let bd_rangeType = cfg["borderInfo"][i].rangeType;
- if (bd_rangeType == "range") {
- let bd_range = cfg["borderInfo"][i].range;
- let bd_emptyRange = [];
- for (let j = 0; j < bd_range.length; j++) {
- 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"));
- }
- cfg["borderInfo"][i].range = bd_emptyRange;
- borderInfo.push(cfg["borderInfo"][i]);
- }
- else if (bd_rangeType == "cell") {
- let bd_r = cfg["borderInfo"][i].value.row_index;
- let bd_c = cfg["borderInfo"][i].value.col_index;
- if (!(bd_r >= last["row"][0] && bd_r <= last["row"][1] && bd_c >= last["column"][0] && bd_c <= last["column"][1])) {
- borderInfo.push(cfg["borderInfo"][i]);
- }
- }
- }
- cfg["borderInfo"] = borderInfo;
- }
- //替换位置数据更新
- let offsetMC = {};
- for (let r = 0; r < data.length; r++) {
- for (let c = 0; c < data[0].length; c++) {
- if (borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": r + row_s,
- "col_index": c + col_s,
- "l": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].l,
- "r": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].r,
- "t": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].t,
- "b": borderInfoCompute[(r + last["row"][0]) + "_" + (c + last["column"][0])].b
- }
- }
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- }
- let value = "";
- if (data[r] != null && data[r][c] != null) {
- value = data[r][c];
- }
- if (getObjType(value) == "object" && ("mc" in value)) {
- let mc = $.extend(true, {}, value["mc"]);
- if ("rs" in value["mc"]) {
- offsetMC[mc.r + "_" + mc.c] = [r + row_s, c + col_s];
- value["mc"].r = r + row_s;
- value["mc"].c = c + col_s;
- cfg["merge"][(r + row_s) + "_" + (c + col_s)] = value["mc"];
- }
- else {
- value["mc"].r = offsetMC[mc.r + "_" + mc.c][0];
- value["mc"].c = offsetMC[mc.r + "_" + mc.c][1];
- }
- }
- d[r + row_s][c + col_s] = value;
- }
- }
- if (RowlChange) {
- cfg = rowlenByRange(d, last["row"][0], last["row"][1], cfg);
- cfg = rowlenByRange(d, row_s, row_e, cfg);
- }
- //条件格式
- let cdformat = $.extend(true, [], Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)]["luckysheet_conditionformat_save"]);
- if (cdformat != null && cdformat.length > 0) {
- for (let i = 0; i < cdformat.length; i++) {
- let cdformat_cellrange = cdformat[i].cellrange;
- let emptyRange = [];
- for (let j = 0; j < cdformat_cellrange.length; j++) {
- let range = conditionformat.CFSplitRange(cdformat_cellrange[j], { "row": last["row"], "column": last["column"] }, { "row": [row_s, row_e], "column": [col_s, col_e] }, "allPart");
- emptyRange = emptyRange.concat(range);
- }
- cdformat[i].cellrange = emptyRange;
- }
- }
- let rf;
- if (Store.luckysheet_select_save[0].row_focus == Store.luckysheet_select_save[0].row[0]) {
- rf = row_s;
- }
- else {
- rf = row_e;
- }
- let cf;
- if (Store.luckysheet_select_save[0].column_focus == Store.luckysheet_select_save[0].column[0]) {
- cf = col_s;
- }
- else {
- cf = col_e;
- }
- let range = [];
- range.push({ "row": last["row"], "column": last["column"] });
- range.push({ "row": [row_s, row_e], "column": [col_s, col_e] });
- last["row"] = [row_s, row_e];
- last["column"] = [col_s, col_e];
- last["row_focus"] = rf;
- last["column_focus"] = cf;
- let allParam = {
- "cfg": cfg,
- "RowlChange": RowlChange,
- "cdformat": cdformat
- }
- jfrefreshgrid(d, range, allParam);
- selectHightlightShow();
- $("#luckysheet-sheettable").css("cursor", "default");
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- }
- //图表选区拖拽移动
- if (Store.chart_selection.rangeMove) {
- Store.chart_selection.rangeMoveDragged();
- }
- //图表选区拖拽拉伸
- if (!!Store.chart_selection.rangeResize) {
- Store.chart_selection.rangeResizeDragged();
- }
- //选区下拉
- if (Store.luckysheet_cell_selected_extend) {
-
- Store.luckysheet_cell_selected_extend = false;
- $("#luckysheet-cell-selected-extend").hide();
- if(!checkProtectionLockedRangeList(Store.luckysheet_select_save, Store.currentSheetIndex)){
- return;
- }
- let mouse = mouseposition(event.pageX, event.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft - 5;
- let y = mouse[1] + scrollTop - 5;
- let winH = $(window).height() + scrollTop - Store.sheetBarHeight - Store.statisticBarHeight,
- winW = $(window).width() + scrollLeft;
- let row_location = rowLocation(y),
- row = row_location[1],
- row_pre = row_location[0],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col = col_location[1],
- col_pre = col_location[0],
- col_index = col_location[2];
- let row_index_original = Store.luckysheet_cell_selected_extend_index[0],
- col_index_original = Store.luckysheet_cell_selected_extend_index[1];
- let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1];
- let row_s = last["row"][0], row_e = last["row"][1];
- let col_s = last["column"][0], col_e = last["column"][1];
- if (row_s < 0 || y < 0) {
- row_s = 0;
- row_e = last["row"][1] - last["row"][0];
- }
- if (col_s < 0 || x < 0) {
- col_s = 0;
- col_e = last["column"][1] - last["column"][0];
- }
- if (row_e >= Store.visibledatarow[Store.visibledatarow.length - 1] || y > winH) {
- row_s = Store.visibledatarow.length - 1 - last["row"][1] + last["row"][0];
- row_e = Store.visibledatarow.length - 1;
- }
- if (col_e >= Store.visibledatacolumn[Store.visibledatacolumn.length - 1] || x > winW) {
- col_s = Store.visibledatacolumn.length - 1 - last["column"][1] + last["column"][0];
- col_e = Store.visibledatacolumn.length - 1;
- }
- //复制范围
- luckysheetDropCell.copyRange = { "row": $.extend(true, [], last["row"]), "column": $.extend(true, [], last["column"]) };
- //applyType
- let typeItemHide = luckysheetDropCell.typeItemHide();
- if (!typeItemHide[0] && !typeItemHide[1] && !typeItemHide[2] && !typeItemHide[3] && !typeItemHide[4] && !typeItemHide[5] && !typeItemHide[6]) {
- luckysheetDropCell.applyType = "0";
- }
- else {
- luckysheetDropCell.applyType = "1";
- }
- if (Math.abs(row_index_original - row_index) > Math.abs(col_index_original - col_index)) {
- if (!(row_index >= row_s && row_index <= row_e)) {
- if (Store.luckysheet_select_save[0].top_move >= row_pre) {//当往上拖拽时
- luckysheetDropCell.applyRange = { "row": [row_index, last["row"][0] - 1], "column": last["column"] };
- luckysheetDropCell.direction = "up";
- row_s -= last["row"][0] - row_index;
- //是否有数据透视表范围
- if (pivotTable.isPivotRange(row_s, col_e)) {
- tooltip.info(locale_drag.affectPivot, "");
- return;
- }
- }
- else {//当往下拖拽时
- luckysheetDropCell.applyRange = { "row": [last["row"][1] + 1, row_index], "column": last["column"] };
- luckysheetDropCell.direction = "down";
- row_e += row_index - last["row"][1];
- //是否有数据透视表范围
- if (pivotTable.isPivotRange(row_e, col_e)) {
- tooltip.info(locale_drag.affectPivot, "");
- return;
- }
- }
- }
- else {
- return;
- }
- }
- else {
- if (!(col_index >= col_s && col_index <= col_e)) {
- if (Store.luckysheet_select_save[0].left_move >= col_pre) {//当往左拖拽时
- luckysheetDropCell.applyRange = { "row": last["row"], "column": [col_index, last["column"][0] - 1] };
- luckysheetDropCell.direction = "left";
- col_s -= last["column"][0] - col_index;
- //是否有数据透视表范围
- if (pivotTable.isPivotRange(row_e, col_s)) {
- tooltip.info(locale_drag.affectPivot, "");
- return;
- }
- }
- else {//当往右拖拽时
- luckysheetDropCell.applyRange = { "row": last["row"], "column": [last["column"][1] + 1, col_index] };
- luckysheetDropCell.direction = "right";
- col_e += col_index - last["column"][1];
- //是否有数据透视表范围
- if (pivotTable.isPivotRange(row_e, col_e)) {
- tooltip.info(locale_drag.affectPivot, "");
- return;
- }
- }
- }
- else {
- return;
- }
- }
- if (Store.config["merge"] != null) {
- let hasMc = false;
- for (let r = last["row"][0]; r <= last["row"][1]; r++) {
- for (let c = last["column"][0]; c <= last["column"][1]; c++) {
- let cell = Store.flowdata[r][c];
- if (cell != null && cell.mc != null) {
- hasMc = true;
- break;
- }
- }
- }
- if (hasMc) {
- if (isEditMode()) {
- alert(locale_drag.noMerge);
- }
- else {
- tooltip.info(locale_drag.noMerge, "");
- }
- return;
- }
- for (let r = row_s; r <= row_e; r++) {
- for (let c = col_s; c <= col_e; c++) {
- let cell = Store.flowdata[r][c];
- if (cell != null && cell.mc != null) {
- hasMc = true;
- break;
- }
- }
- }
- if (hasMc) {
- if (isEditMode()) {
- alert(locale_drag.noMerge);
- }
- else {
- tooltip.info(locale_drag.noMerge, "");
- }
- return;
- }
- }
- last["row"] = [row_s, row_e];
- last["column"] = [col_s, col_e];
- luckysheetDropCell.update();
- luckysheetDropCell.createIcon();
- $("#luckysheet-cell-selected-move").hide();
- $("#luckysheet-sheettable").css("cursor", "default");
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- }
- });
- //禁止浏览器 右键默认菜单
- $(".luckysheet-grid-container, #luckysheet-rightclick-menu").on("contextmenu", function (e) {
- e.preventDefault();
- });
- // //禁止前台编辑(只可 框选单元格、滚动查看表格)
- // if(!Store.allowEdit){
- // return;
- // }
- //选区拖动替换
- $("#luckysheet-cell-main div.luckysheet-cs-draghandle").mousedown(function (event) {
- if(isEditMode() || Store.allowEdit===false){//此模式下禁用选区拖动
- return;
- }
- $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
- .css("cursor", "move")
- .end()
- .find(".luckysheet-cs-draghandle")
- .css("cursor", "move");
- $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor", "move");
- Store.luckysheet_cell_selected_move = true;
- Store.luckysheet_scroll_status = true;
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let row_location = rowLocation(y),
- row_pre = row_location[0],
- row = row_location[1],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col_pre = col_location[0],
- col = col_location[1],
- col_index = col_location[2];
- Store.luckysheet_cell_selected_move_index = [row_index, col_index];
- $("#luckysheet-cell-selected-move").css({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "display": "block"
- });
- event.stopPropagation();
- });
- //选区下拉
- $("#luckysheet-cell-main div.luckysheet-cs-fillhandle").mousedown(function (event) {
- if(isEditMode() || Store.allowEdit===false){//此模式下禁用选区下拉
- return;
- }
- $("#luckysheet-cell-selected").find(".luckysheet-cs-fillhandle")
- .css("cursor", "crosshair")
- .end()
- .find(".luckysheet-cs-draghandle")
- .css("cursor", "crosshair");
- $("#luckysheet-cell-main, #luckysheetTableContent, #luckysheet-sheettable_0").css("cursor", "crosshair");
- Store.luckysheet_cell_selected_extend_time = setTimeout(function () {
- Store.luckysheet_cell_selected_extend = true;
- Store.luckysheet_scroll_status = true;
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft() - 5;
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop() - 5;
- let row_location = rowLocation(y),
- row_pre = row_location[0],
- row = row_location[1],
- row_index = row_location[2];
- let col_location = colLocation(x),
- col_pre = col_location[0],
- col = col_location[1],
- col_index = col_location[2];
- Store.luckysheet_cell_selected_extend_index = [row_index, col_index];
- $("#luckysheet-cell-selected-extend").css({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "display": "block"
- });
- }, 100);
- event.stopPropagation();
- }).click(function () {
- clearTimeout(Store.luckysheet_cell_selected_extend_time);
- event.stopPropagation();
- }).dblclick(function () {
- let last = Store.luckysheet_select_save[0];
- let r0 = last.row[0],
- r1 = last.row[1],
- c0 = last.column[0],
- c1 = last.column[1];
- if (pivotTable.isPivotRange(r0, c0)) {
- return;
- }
- let dropCellState = false;
- let step = 0;
- for (let r = r1 + 1; r < Store.flowdata.length; r++) {
- if (c0 - 1 >= 0 && c1 + 1 < Store.flowdata[0].length) {
- let cell1 = Store.flowdata[r][c0 - 1];
- let cell2 = Store.flowdata[r][c1 + 1];
- if (r == r1 + 1) {
- if ((cell1 == null || isRealNull(cell1.v)) && (cell2 == null || isRealNull(cell2.v))) {
- dropCellState = false;
- break;
- }
- else {
- dropCellState = true;
- step++;
- }
- }
- else {
- if ((cell1 == null || isRealNull(cell1.v)) && (cell2 == null || isRealNull(cell2.v))) {
- break;
- }
- step++;
- }
- }
- else if (c0 - 1 >= 0) {
- let cell = Store.flowdata[r][c0 - 1];
- if (r == r1 + 1) {
- if (cell == null || isRealNull(cell.v)) {
- dropCellState = false;
- break;
- }
- else {
- dropCellState = true;
- step++;
- }
- }
- else {
- if (cell == null || isRealNull(cell.v)) {
- break;
- }
- step++;
- }
- }
- else if (c1 + 1 < Store.flowdata[0].length) {
- let cell = Store.flowdata[r][c1 + 1];
- if (r == r1 + 1) {
- if (cell == null || isRealNull(cell.v)) {
- dropCellState = false;
- break;
- }
- else {
- dropCellState = true;
- step++;
- }
- }
- else {
- if (cell == null || isRealNull(cell.v)) {
- break;
- }
- step++;
- }
- }
- }
- if (!dropCellState || step == 0) {
- event.stopPropagation();
- return;
- }
- //复制范围
- luckysheetDropCell.copyRange = { "row": [r0, r1], "column": [c0, c1] };
- //applyType
- let typeItemHide = luckysheetDropCell.typeItemHide();
- if (!typeItemHide[0] && !typeItemHide[1] && !typeItemHide[2] && !typeItemHide[3] && !typeItemHide[4] && !typeItemHide[5] && !typeItemHide[6]) {
- luckysheetDropCell.applyType = "0";
- }
- else {
- luckysheetDropCell.applyType = "1";
- }
- luckysheetDropCell.applyRange = { "row": [r1 + 1, r1 + step], "column": [c0, c1] };
- luckysheetDropCell.direction = "down";
- Store.luckysheet_select_save = [{ "row": [r0, r1 + step], "column": [c0, c1] }];
- luckysheetDropCell.update();
- luckysheetDropCell.createIcon();
- $("#luckysheet-cell-selected-move").hide();
- $("#luckysheet-sheettable").css("cursor", "default");
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- event.stopPropagation();
- });
- //
- $("#luckysheet-bottom-add-row, #luckysheet-bottom-add-row-input, #luckysheet-bottom-return-top").on("mousedown dblclick mouseup", function (e) {
- e.stopPropagation();
- });
- //底部添加行按钮
- $("#luckysheet-bottom-add-row").on("click", function (e) {
- $("#luckysheet-rightclick-menu").hide();
- luckysheetContainerFocus();
- let $t = $(this), value = $("#luckysheet-bottom-add-row-input").val();
- if (value == "") {
- value = luckysheetConfigsetting.addRowCount || 100;
- }
- if (isNaN(parseInt(value))) {
- if (isEditMode()) {
- alert(locale_info.tipInputNumber);
- }
- else {
- tooltip.info("error", locale_info.tipInputNumber);
- }
- return;
- }
- value = parseInt(value);
- if (value < 1 || value > 100) {
- if (isEditMode()) {
- alert(locale_info.tipInputNumberLimit);
- }
- else {
- tooltip.info("error", locale_info.tipInputNumberLimit);
- }
- return;
- }
- luckysheetextendtable("row", Store.flowdata.length - 1, value);
- });
- $("#luckysheet-bottom-return-top").on("click", function (e) {
- $("#luckysheet-scrollbar-y").scrollTop(0);
- });
- //右键菜单 复制按钮
- $("#luckysheet-copy-btn, #luckysheet-cols-copy-btn, #luckysheet-paste-btn-title").click(function (event) {
- $(this).parent().hide();
- //复制范围内包含部分合并单元格,提示
- if (Store.config["merge"] != null) {
- let has_PartMC = false;
- for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
- let r1 = Store.luckysheet_select_save[s].row[0],
- r2 = Store.luckysheet_select_save[s].row[1];
- let c1 = Store.luckysheet_select_save[s].column[0],
- c2 = Store.luckysheet_select_save[s].column[1];
- has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2);
- if (has_PartMC) {
- break;
- }
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_drag.noPartMerge);
- }
- else {
- tooltip.info(locale_drag.noPartMerge, "");
- }
- return;
- }
- }
- //多重选区 有条件格式时 提示
- let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save;
- if (Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0) {
- let hasCF = false;
- let cf_compute = conditionformat.getComputeMap();
- label:
- for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
- if (hasCF) {
- break;
- }
- let r1 = Store.luckysheet_select_save[s].row[0],
- r2 = Store.luckysheet_select_save[s].row[1];
- let c1 = Store.luckysheet_select_save[s].column[0],
- c2 = Store.luckysheet_select_save[s].column[1];
- for (let r = r1; r <= r2; r++) {
- for (let c = c1; c <= c2; c++) {
- if (conditionformat.checksCF(r, c, cf_compute) != null) {
- hasCF = true;
- continue label;
- }
- }
- }
- }
- if (hasCF) {
- if (isEditMode()) {
- alert(locale_drag.noMulti);
- }
- else {
- tooltip.info(locale_drag.noMulti, "");
- }
- return;
- }
- }
- //多重选区 行不一样且列不一样时 提示
- if (Store.luckysheet_select_save.length > 1) {
- let isSameRow = true,
- str_r = Store.luckysheet_select_save[0].row[0],
- end_r = Store.luckysheet_select_save[0].row[1];
- let isSameCol = true,
- str_c = Store.luckysheet_select_save[0].column[0],
- end_c = Store.luckysheet_select_save[0].column[1];
- for (let s = 1; s < Store.luckysheet_select_save.length; s++) {
- if (Store.luckysheet_select_save[s].row[0] != str_r || Store.luckysheet_select_save[s].row[1] != end_r) {
- isSameRow = false;
- }
- if (Store.luckysheet_select_save[s].column[0] != str_c || Store.luckysheet_select_save[s].column[1] != end_c) {
- isSameCol = false;
- }
- }
- if ((!isSameRow && !isSameCol) || selectIsOverlap()) {
- if (isEditMode()) {
- alert(locale_drag.noMulti);
- }
- else {
- tooltip.info(locale_drag.noMulti, "");
- }
- return;
- }
- }
- selection.copy(event);
- });
- //右键菜单 粘贴按钮
- $("#luckysheet-copy-paste, #luckysheet-cols-paste-btn, #luckysheet-paste-btn-title").click(function (event) {
- selection.paste(event, "btn");
- $(this).parent().hide();
- });
- //Menu bar, Chart button
- $("#luckysheet-chart-btn-title").click(function () {
- createLuckyChart();
- });
- // Right-click the menu, chart generation
- $("#luckysheetdatavisual").click(function () {
- createLuckyChart();
- $("#luckysheet-rightclick-menu").hide();
- });
- //菜单栏 数据透视表
- $("#luckysheet-pivot-btn-title").click(function (e) {
- if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "usePivotTablereports")){
- return;
- }
- pivotTable.createPivotTable(e);
- });
- //菜单栏 截图按钮
- $("#luckysheet-chart-btn-screenshot").click(function () {
- const locale_screenshot = _locale.screenshot;
- if (Store.luckysheet_select_save.length == 0) {
- if (isEditMode()) {
- alert(locale_screenshot.screenshotTipNoSelection);
- }
- else {
- tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipNoSelection);
- }
- return;
- }
- if (Store.luckysheet_select_save.length > 1) {
- if (isEditMode()) {
- alert(locale_screenshot.screenshotTipHasMulti);
- }
- else {
- tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMulti);
- }
- return;
- }
- //截图范围内包含部分合并单元格,提示
- if (Store.config["merge"] != null) {
- let has_PartMC = false;
- for (let s = 0; s < Store.luckysheet_select_save.length; s++) {
- let r1 = Store.luckysheet_select_save[s].row[0],
- r2 = Store.luckysheet_select_save[s].row[1];
- let c1 = Store.luckysheet_select_save[s].column[0],
- c2 = Store.luckysheet_select_save[s].column[1];
- has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2);
- if (has_PartMC) {
- break;
- }
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_screenshot.screenshotTipHasMerge);
- }
- else {
- tooltip.info(locale_screenshot.screenshotTipTitle, locale_screenshot.screenshotTipHasMerge);
- }
- return;
- }
- }
- let st_r = Store.luckysheet_select_save[0].row[0],
- ed_r = Store.luckysheet_select_save[0].row[1];
- let st_c = Store.luckysheet_select_save[0].column[0],
- ed_c = Store.luckysheet_select_save[0].column[1];
- let scrollHeight, rh_height;
- if (st_r - 1 < 0) {
- scrollHeight = 0;
- rh_height = Store.visibledatarow[ed_r];
- }
- else {
- scrollHeight = Store.visibledatarow[st_r - 1];
- rh_height = Store.visibledatarow[ed_r] - Store.visibledatarow[st_r - 1];
- }
- let scrollWidth, ch_width;
- if (st_c - 1 < 0) {
- scrollWidth = 0;
- ch_width = Store.visibledatacolumn[ed_c];
- }
- else {
- scrollWidth = Store.visibledatacolumn[st_c - 1];
- ch_width = Store.visibledatacolumn[ed_c] - Store.visibledatacolumn[st_c - 1];
- }
- let newCanvas = $("<canvas>").attr({
- width: Math.ceil(ch_width * devicePixelRatio),
- height: Math.ceil(rh_height * devicePixelRatio)
- }).css({ width: ch_width, height: rh_height });
- luckysheetDrawMain(scrollWidth, scrollHeight, ch_width, rh_height, 1, 1, null, null, newCanvas);
- let ctx_newCanvas = newCanvas.get(0).getContext("2d");
- //补上 左边框和上边框
- ctx_newCanvas.beginPath();
- ctx_newCanvas.moveTo(
- 0,
- 0
- );
- ctx_newCanvas.lineTo(
- 0,
- Store.devicePixelRatio * rh_height
- );
- ctx_newCanvas.lineWidth = Store.devicePixelRatio * 2;
- ctx_newCanvas.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- ctx_newCanvas.stroke();
- ctx_newCanvas.closePath();
- ctx_newCanvas.beginPath();
- ctx_newCanvas.moveTo(
- 0,
- 0
- );
- ctx_newCanvas.lineTo(
- Store.devicePixelRatio * ch_width,
- 0
- );
- ctx_newCanvas.lineWidth = Store.devicePixelRatio * 2;
- ctx_newCanvas.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- ctx_newCanvas.stroke();
- ctx_newCanvas.closePath();
- let image = new Image();
- let url = newCanvas.get(0).toDataURL("image/png");
- image.src = url;
- if (ch_width > rh_height) {
- image.style.width = "100%";
- }
- else {
- image.style.height = "100%";
- }
- let maxHeight = $(window).height() - 200;
- tooltip.screenshot(locale_screenshot.screenshotTipSuccess, '<div id="luckysheet-confirm-screenshot-save" style="height:' + maxHeight + 'px;overflow:auto;"></div>', url);
- $("#luckysheet-confirm-screenshot-save").append(image);
- newCanvas.remove();
- });
- //截图下载
- $(document).on("click.luckysheetEvent", "a.download", function () {
- let dataURI = $("#luckysheet-confirm-screenshot-save img").attr("src");
- const locale_screenshot = _locale.screenshot;
- let binStr = atob(dataURI.split(",")[1]),
- len = binStr.length,
- arr = new Uint8Array(len);
- for (let i = 0; i < len; i++) {
- arr[i] = binStr.charCodeAt(i);
- }
- let blob = new Blob([arr]);
- let element = document.createElement('a');
- element.setAttribute('href', URL.createObjectURL(blob));
- element.setAttribute('download', locale_screenshot.screenshotImageName + '.png');
- element.style.display = 'none';
- document.body.appendChild(element);
- element.click();
- let clickHandler;
- element.addEventListener('click', clickHandler = function () {
- requestAnimationFrame(function () {
- URL.revokeObjectURL(element.href);
- });
- element.removeAttribute('href');
- element.removeEventListener('click', clickHandler);
- })
- document.body.removeChild(element);
- })
- //菜单栏 分列按钮
- $("#luckysheet-splitColumn-btn-title").click(function () {
- if(!checkProtectionNotEnable(Store.currentSheetIndex)){
- return;
- }
- if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
- return;
- }
- const locale_splitText = _locale.splitText;
- if (Store.luckysheet_select_save.length > 1) {
- tooltip.info(locale_splitText.tipNoMulti, "");
- return;
- }
- if (Store.luckysheet_select_save[0].column[0] != Store.luckysheet_select_save[0].column[1]) {
- tooltip.info(locale_splitText.tipNoMultiColumn, "");
- return;
- }
- splitColumn.createDialog();
- splitColumn.init();
- });
- //菜单栏 插入图片按钮
- $("#luckysheet-insertImg-btn-title").click(function () {
- // *如果禁止前台编辑,则中止下一步操作
- if (!checkIsAllowEdit()) {
- tooltip.info("", locale().pivotTable.errorNotAllowEdit);
- return
- }
- if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
- return;
- }
- $("#luckysheet-imgUpload").click();
- });
- $("#luckysheetInsertImage").click(function () {
- if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects")){
- return;
- }
- $("#luckysheet-imgUpload").click();
- $("#luckysheet-rightclick-menu").hide();
- })
- $("#luckysheet-imgUpload").click(function (e) {
- e.stopPropagation();
- });
- $("#luckysheet-imgUpload").on("change", function(e){
- if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "editObjects",false)){
- return;
- }
- let file = e.currentTarget.files[0];
- imageCtrl.insertImg(file);
- });
- //菜单栏 插入链接按钮
- $("#luckysheet-insertLink-btn-title").click(function () {
- // *如果禁止前台编辑,则中止下一步操作
- if (!checkIsAllowEdit()) {
- tooltip.info("", locale().pivotTable.errorNotAllowEdit);
- return
- }
- if(!checkProtectionNotEnable(Store.currentSheetIndex)){
- return;
- }
- if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
- return;
- }
- hyperlinkCtrl.createDialog();
- hyperlinkCtrl.init();
- })
- $("#luckysheetInsertLink").click(function () {
- $("#luckysheet-insertLink-btn-title").click();
- $("#luckysheet-rightclick-menu").hide();
- })
- //菜单栏 数据验证按钮
- $("#luckysheet-dataVerification-btn-title").click(function () {
- if(!checkProtectionNotEnable(Store.currentSheetIndex)){
- return;
- }
- if (Store.luckysheet_select_save == null || Store.luckysheet_select_save.length == 0) {
- return;
- }
- dataVerificationCtrl.createDialog();
- dataVerificationCtrl.init();
- });
- $("#luckysheetDataVerification").click(function () {
- $("#luckysheet-dataVerification-btn-title").click();
- $("#luckysheet-rightclick-menu").hide();
- });
- //Cell format
- $("#luckysheetCellFormatRightClickMenu").click(function () {
- openCellFormatModel();
- });
- //冻结行列
- $("#luckysheet-freezen-btn-horizontal").click(function () {
- if ($.trim($(this).text()) == locale().freezen.freezenCancel) {
- luckysheetFreezen.saveFrozen("freezenCancel");
- if (luckysheetFreezen.freezenverticaldata != null) {
- luckysheetFreezen.cancelFreezenVertical();
- luckysheetFreezen.createAssistCanvas();
- luckysheetrefreshgrid();
- }
- if (luckysheetFreezen.freezenhorizontaldata != null) {
- luckysheetFreezen.cancelFreezenHorizontal();
- luckysheetFreezen.createAssistCanvas();
- luckysheetrefreshgrid();
- }
- luckysheetFreezen.scrollAdapt();
- // cancel 之后 勾勾取消
- $('#luckysheet-icon-freezen-menu-menuButton').find('.fa.fa-check').remove();
- }
- else {
- luckysheetFreezen.saveFrozen("freezenRow");
- if (luckysheetFreezen.freezenverticaldata != null) {
- luckysheetFreezen.cancelFreezenVertical();
- luckysheetFreezen.createAssistCanvas();
- luckysheetrefreshgrid();
- }
- if (luckysheetFreezen.freezenhorizontaldata == null) {
- luckysheetFreezen.createFreezenHorizontal();
- luckysheetFreezen.createAssistCanvas();
- }
- }
- });
- $("#luckysheet-freezen-btn-vertical").click(function () {
- if (luckysheetFreezen.freezenverticaldata != null) {
- luckysheetFreezen.saveFrozen("freezenCancel");
- luckysheetFreezen.cancelFreezenVertical();
- luckysheetrefreshgrid();
- }
- else {
- luckysheetFreezen.saveFrozen("freezenColumn");
- luckysheetFreezen.createFreezenVertical();
- }
- luckysheetFreezen.createAssistCanvas();
- });
- $("#luckysheet-rightclick-menu input").on("keydown", function (e) {
- e.stopPropagation();
- });
- $("#luckysheet-modal-dialog-mask").on("click dbclick mousedown mousemove mouseup", function (e) {
- e.stopPropagation();
- e.preventDefault();
- });
- let copychange = function () {
- if (document.hidden || document.webkitHidden || document.msHidden) {
- Store.iscopyself = false;
- }
- }
- $(document).on("visibilitychange.luckysheetEvent webkitvisibilitychange.luckysheetEvent msvisibilitychange.luckysheetEvent", copychange).on("mouseleave.luckysheetEvent", function () {
- Store.iscopyself = false;
- }).on("mousedown.luckysheetEvent", function (event) {
- //有批注在编辑时
- luckysheetPostil.removeActivePs();
- hideMenuByCancel(event);
- //点击功能栏时 如果是单元格编辑模式 则退出编辑模式
- if ($(event.target).closest("#luckysheet-wa-editor").length > 0 && parseInt($("#luckysheet-input-box").css("top")) > 0) {
-
- formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
- luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
- }
- });
- //表格左上角点击 全选表格
- $("#luckysheet-left-top").click(function (event) {
- if(!checkProtectionAllSelected(Store.currentSheetIndex)){
- return;
- }
- $("#luckysheet-wa-functionbox-confirm").click();
- Store.luckysheet_select_status = false;
- 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 }];
- selectHightlightShow();
- clearTimeout(Store.countfuncTimeout);
- Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
- /* 选中区域:发送网络请求 */
- server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
- event.stopPropagation();
- });
- //回退 重做 按钮
- $("#luckysheet-icon-undo").click(function (event) {
- if ($(this).hasClass('disabled')) {
- return;
- }
- controlHistory.redo(event);
- });
- $("#luckysheet-icon-redo").click(function (event) {
- if ($(this).hasClass('disabled')) {
- return;
- }
- controlHistory.undo(event);
- });
- //模态框拖动
- $(document).on("mousedown.luckysheetEvent", "div.luckysheet-modal-dialog", function (e) {
- if (!$(e.target).is(".luckysheet-modal-dialog")) {
- return;
- }
- Store.luckysheet_model_move_state = true;
- Store.luckysheet_model_move_obj = $(e.currentTarget);
- let toffset = Store.luckysheet_model_move_obj.offset();
- Store.luckysheet_model_xy = [e.pageX - toffset.left, e.pageY - toffset.top];
- });
- //模态框关闭
- $(document).on("click.luckysheetEvent", ".luckysheet-modal-dialog-title-close, .luckysheet-model-close-btn", function (e) {
- //选择文本颜色和单元格颜色弹出框取消
- if ($("#textcolorselect").is(":visible") || $("#cellcolorselect").is(":visible")) {
- $("#luckysheet-conditionformat-dialog").show();
- }
- $(e.currentTarget).parents(".luckysheet-modal-dialog").hide();
- $("#luckysheet-modal-dialog-mask").hide();
- //函数查找功能所有弹出框关闭和取消
- if ($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula")) {
- formula.dontupdate();
- luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
- }
- if ($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm")) {
- formula.dontupdate();
- luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
- }
- if ($(this).parents(".luckysheet-modal-dialog").hasClass("luckysheet-search-formula-parm-select")) {
- formula.dontupdate();
- luckysheetMoveHighlightCell("down", 0, "rangeOfSelect");
- }
- luckysheetContainerFocus();
- });
- //左上角返回按钮
- $("#luckysheet_info_detail_title").click(function () {
- window.open(luckysheetConfigsetting.myFolderUrl, "_self");
- });
- //图表选区mousedown
- $("#luckysheet-chart-rangeShow").on("mousedown.chartRangeShowMove", ".luckysheet-chart-rangeShow-move", function (event) {
- Store.chart_selection.rangeMove = true;
- Store.luckysheet_scroll_status = true;
- Store.chart_selection.rangeMoveObj = $(this).parent();
- let chart_json = Store.currentChart
- let $id = $(this).parent().attr("id");
- if ($id == "luckysheet-chart-rangeShow-content") {
- let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.content.row[0];
- let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.content.column[0];
- Store.chart_selection.rangeMoveIndex = [row_s, col_s];
- }
- else if ($id == "luckysheet-chart-rangeShow-rowtitle") {
- let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.rowtitle.row[0];
- let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.rowtitle.column[0];
- Store.chart_selection.rangeMoveIndex = [row_s, col_s];
- }
- else if ($id == "luckysheet-chart-rangeShow-coltitle") {
- let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.coltitle.row[0];
- let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.coltitle.column[0];
- Store.chart_selection.rangeMoveIndex = [row_s, col_s];
- }
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- let type = $(this).data("type");
- if (type == "top") {
- y += 3;
- }
- else if (type == "right") {
- x -= 3;
- }
- else if (type == "bottom") {
- y -= 3;
- }
- else if (type == "left") {
- x += 3;
- }
- let row_index = rowLocation(y)[2];
- let col_index = colLocation(x)[2];
- Store.chart_selection.rangeMovexy = [row_index, col_index];
- event.stopPropagation();
- });
- $("#luckysheet-chart-rangeShow").on("mousedown.chartRangeShowResize", ".luckysheet-chart-rangeShow-resize", function (event) {
- Store.chart_selection.rangeResize = $(this).data("type");//开始状态resize
- Store.luckysheet_scroll_status = true;
- Store.chart_selection.rangeResizeObj = $(this).parent();
- let chart_json = Store.currentChart
- let row_s
- let row_e
- let col_s
- let col_e
- let $id = $(this).parent().attr("id");
- if ($id == "luckysheet-chart-rangeShow-content") {
- if (chart_json.rangeRowCheck.exits) {
- row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.content.row[0];
- row_e = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.content.row[1];
- }
- else {
- row_s = chart_json.rangeSplitArray.content.row[0];
- row_e = chart_json.rangeSplitArray.content.row[0];
- }
- if (chart_json.rangeColCheck.exits) {
- col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.content.column[0];
- col_e = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.content.column[1];
- }
- else {
- col_s = chart_json.rangeSplitArray.content.column[0];
- col_e = chart_json.rangeSplitArray.content.column[1];
- }
- Store.chart_selection.rangeResizeIndex = { "row": [row_s, row_e], "column": [col_s, col_e] };
- }
- else if ($id == "luckysheet-chart-rangeShow-rowtitle") {
- let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.rowtitle.row[0];
- let row_e = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.rowtitle.row[1];
- let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.rowtitle.column[0];
- let col_e = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.rowtitle.column[1];
- Store.chart_selection.rangeResizeIndex = { "row": [row_s, row_e], "column": [col_s, col_e] };
- }
- else if ($id == "luckysheet-chart-rangeShow-coltitle") {
- let row_s = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.coltitle.row[0];
- let row_e = chart_json.rangeArray[0].row[0] + chart_json.rangeSplitArray.coltitle.row[1];
- let col_s = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.coltitle.column[0];
- let col_e = chart_json.rangeArray[0].column[0] + chart_json.rangeSplitArray.coltitle.column[1];
- Store.chart_selection.rangeResizeIndex = { "row": [row_s, row_e], "column": [col_s, col_e] };
- }
- let mouse = mouseposition(event.pageX, event.pageY);
- let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft();
- let y = mouse[1] + $("#luckysheet-cell-main").scrollTop();
- if (Store.chart_selection.rangeResize == "lt") {
- x += 3;
- y += 3;
- }
- else if (Store.chart_selection.rangeResize == "lb") {
- x += 3;
- y -= 3;
- }
- else if (Store.chart_selection.rangeResize == "rt") {
- x -= 3;
- y += 3;
- }
- else if (Store.chart_selection.rangeResize == "rb") {
- x -= 3;
- y -= 3;
- }
- let row_index = rowLocation(y)[2];
- let col_index = colLocation(x)[2];
- Store.chart_selection.rangeResizexy = [row_index, col_index];
- event.stopPropagation();
- })
- $("#luckysheet-wa-calculate-size").mousedown(function (e) {
- let y = e.pageY;
- formula.functionResizeData.y = y;
- formula.functionResizeStatus = true;
- formula.functionResizeData.calculatebarHeight = Store.calculatebarHeight;
- if (formula.rangetosheet != null) {
- formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]);
- }
- });
- // 点击设置字体大小的下拉箭头,把自动聚焦输入框去除(认为下拉设置字体大小,不需要聚焦输入框)
- // //toolbar菜单
- // $("#" + Store.container + " .luckysheet-wa-editor").on("click", ".luckysheet-toolbar-zoom-combobox", function (e) {
- // $(e.currentTarget).addClass("luckysheet-toolbar-combo-button-open");
- // $(e.currentTarget).find(".luckysheet-toolbar-combo-button-input").focus();
- // });
- // $("#" + Store.container + " .luckysheet-wa-editor").on("blur", ".luckysheet-toolbar-combo-button-input", function (e) {
- // $(e.currentTarget).closest(".luckysheet-toolbar-zoom-combobox").removeClass("luckysheet-toolbar-combo-button-open");
- // });
- //表格格式处理
- menuButton.initialMenuButton();
- let dpi_x = document.getElementById('testdpidiv').offsetWidth * Store.devicePixelRatio;
- let dpi_y = document.getElementById('testdpidiv').offsetHeight * Store.devicePixelRatio;
- //粘贴事件处理
- $(document).on("paste.luckysheetEvent", function (e) {
- if (isEditMode()) {//此模式下禁用粘贴
- return;
- }
- if (selection.isPasteAction) {
- $("#luckysheet-rich-text-editor").blur();
- selection.isPasteAction = false;
- let clipboardData = window.clipboardData; //for IE
- if (!clipboardData) { // for chrome
- clipboardData = e.originalEvent.clipboardData;
- }
- let txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
- //如果标示是qksheet复制的内容,判断剪贴板内容是否是当前页面复制的内容
- let isEqual = true;
- if (txtdata.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0) {
- //剪贴板内容解析
- let cpDataArr = [];
-
- let reg = new RegExp('<tr.*?>(.*?)</tr>', 'gs');
- let reg2 = new RegExp('<td.*?>(.*?)</td>', 'gs');
- let regArr = txtdata.match(reg) || [];
- for (let i = 0; i < regArr.length; i++) {
- let cpRowArr = [];
- let reg2Arr = regArr[i].match(reg2);
- if (reg2Arr != null) {
- for (let j = 0; j < reg2Arr.length; j++) {
- let cpValue = reg2Arr[j].replace(/<td.*?>/gs, "").replace(/<\/td>/gs, "");
- cpRowArr.push(cpValue);
- }
- }
- cpDataArr.push(cpRowArr);
- }
- //当前页面复制区内容
- let copy_r1 = Store.luckysheet_copy_save["copyRange"][0].row[0],
- copy_r2 = Store.luckysheet_copy_save["copyRange"][0].row[1],
- copy_c1 = Store.luckysheet_copy_save["copyRange"][0].column[0],
- copy_c2 = Store.luckysheet_copy_save["copyRange"][0].column[1];
- let copy_index = Store.luckysheet_copy_save["dataSheetIndex"];
- let d;
- if(copy_index == Store.currentSheetIndex){
- d = editor.deepCopyFlowData(Store.flowdata);
- }
- else{
- d = Store.luckysheetfile[getSheetIndex(copy_index)].data;
- }
- for(let r = copy_r1; r <= copy_r2; r++){
- if(r - copy_r1 > cpDataArr.length - 1){
- break;
- }
- for(let c = copy_c1; c <= copy_c2; c++){
- let cell = d[r][c];
- let isInlineStr = false
- if(cell != null && cell.mc != null && cell.mc.rs == null){
- continue;
- }
- let v;
- if(cell != null){
- if(cell.ct != null && cell.ct.fa.indexOf("w") > -1){
- v = d[r][c].v;
- }
- else{
- v = d[r][c].m;
- }
- }
- else{
- v = "";
- }
-
- if(v == null && d[r][c] && d[r][c].ct && d[r][c].ct.t == 'inlineStr') {
- v = d[r][c].ct.s.map(val=>val.v).join('');
- isInlineStr = true;
- }
- if(v == null){
- v = "";
- }
- if(isInlineStr){
- const cpData = $(cpDataArr[r - copy_r1][c - copy_c1]).text().replace(/\s|\n/g,' ')
- const storeValue = v.replace(/\n/g,'').replace(/\s/g,' ')
- if(cpData != storeValue){
- isEqual = false;
- break;
- }
- }
- else{
- if(cpDataArr[r - copy_r1][c - copy_c1] != v){
- isEqual = false;
- break;
- }
- }
- }
- }
- }
- const locale_fontjson = locale().fontjson;
-
- // hook
- if(!method.createHookFunction('rangePasteBefore',Store.luckysheet_select_save,txtdata)){
- return;
- }
- if (txtdata.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0 && isEqual) {
- //剪切板内容 和 luckysheet本身复制的内容 一致
- if (Store.luckysheet_paste_iscut) {
- Store.luckysheet_paste_iscut = false;
- selection.pasteHandlerOfCutPaste(Store.luckysheet_copy_save);
- selection.clearcopy(e);
- }
- else {
- selection.pasteHandlerOfCopyPaste(Store.luckysheet_copy_save);
- }
- }
- else if(txtdata.indexOf("luckysheet_copy_action_image") > - 1){
- imageCtrl.pasteImgItem();
- }
- else {
- if (txtdata.indexOf("table") > -1) {
- $("#luckysheet-copy-content").html(txtdata);
- let data = new Array($("#luckysheet-copy-content").find("table tr").length);
- let colLen = 0;
- const cellElements = "th, td";
- $("#luckysheet-copy-content").find("table tr").eq(0).find(cellElements).each(function () {
- let colspan = parseInt($(this).attr("colspan"));
- if (isNaN(colspan)) {
- colspan = 1;
- }
- colLen += colspan;
- });
- for (let i = 0; i < data.length; i++) {
- data[i] = new Array(colLen);
- }
- let r = 0;
- let borderInfo = {};
- $("#luckysheet-copy-content").find("table tr").each(function () {
- let $tr = $(this);
- let c = 0;
- $tr.find(cellElements).each(function () {
- let $td = $(this);
- let cell = {};
- let txt = $td.text();
- if ($.trim(txt).length == 0) {
- cell.v = null;
- cell.m = "";
- }
- else {
- let mask = genarate($td.text());
- cell.v = mask[2];
- cell.ct = mask[1];
- cell.m = mask[0];
- }
- let bg = $td.css("background-color");
- if (bg == "rgba(0, 0, 0, 0)") {
- bg = null;
- }
- cell.bg = bg;
- let bl = $td.css("font-weight");
- if (bl == 400 || bl == "normal") {
- cell.bl = 0;
- }
- else {
- cell.bl = 1;
- }
- // 检测下划线
- let un = $td.css('text-decoration')
- if (un.indexOf('underline') != -1) {
- cell.un = 1;
- }
-
- let it = $td.css("font-style");
- if (it == "normal") {
- cell.it = 0;
- }
- else {
- cell.it = 1;
- }
- let ff = $td.css("font-family");
- let ffs = ff.split(",");
- for (let i = 0; i < ffs.length; i++) {
- let fa = $.trim(ffs[i].toLowerCase());
- fa = locale_fontjson[fa];
- if (fa == null) {
- cell.ff = 0;
- }
- else {
- cell.ff = fa;
- break;
- }
- }
- let fs = Math.round(parseInt($td.css("font-size")) * 72 / 96);
- cell.fs = fs;
- let fc = $td.css("color");
- cell.fc = fc;
- // 水平对齐属性
- let ht = $td.css("text-align");
- if (ht == "center") {
- cell.ht = 0;
- }
- else if (ht == "right") {
- cell.ht = 2;
- }
- else {
- cell.ht = 1;
- }
- // 垂直对齐属性
- let vt = $td.css("vertical-align");
- if (vt == "middle") {
- cell.vt = 0;
- }
- else if (vt == "top" || vt == "text-top") {
- cell.vt = 1;
- }
- else {
- cell.vt = 2;
- }
- while (c < colLen && data[r][c] != null) {
- c++;
- }
- if (c == colLen) {
- return true;
- }
- if (data[r][c] == null) {
- data[r][c] = cell;
- let rowspan = parseInt($td.attr("rowspan"));
- let colspan = parseInt($td.attr("colspan"));
- if (isNaN(rowspan)) {
- rowspan = 1;
- }
- if (isNaN(colspan)) {
- colspan = 1;
- }
- let r_ab = Store.luckysheet_select_save[0]["row"][0] + r;
- let c_ab = Store.luckysheet_select_save[0]["column"][0] + c;
- for (let rp = 0; rp < rowspan; rp++) {
- for (let cp = 0; cp < colspan; cp++) {
- if (rp == 0) {
- let bt = $td.css("border-top");
- if (bt != null && bt.length > 0 && bt.substr(0, 3).toLowerCase() != "0px") {
- let width = $td.css("border-top-width");
- let type = $td.css("border-top-style");
- let color = $td.css("border-top-color");
- let borderconfig = menuButton.getQKBorder(width, type, color);
- if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
- borderInfo[(r + rp) + "_" + (c + cp)] = {};
- }
- borderInfo[(r + rp) + "_" + (c + cp)].t = { "style": borderconfig[0], "color": borderconfig[1] };
- }
- }
- if (rp == rowspan - 1) {
- let bb = $td.css("border-bottom");
- if (bb != null && bb.length > 0 && bb.substr(0, 3).toLowerCase() != "0px") {
- let width = $td.css("border-bottom-width");
- let type = $td.css("border-bottom-style");
- let color = $td.css("border-bottom-color");
- let borderconfig = menuButton.getQKBorder(width, type, color);
- if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
- borderInfo[(r + rp) + "_" + (c + cp)] = {};
- }
- borderInfo[(r + rp) + "_" + (c + cp)].b = { "style": borderconfig[0], "color": borderconfig[1] };
- }
- }
- if (cp == 0) {
- let bl = $td.css("border-left");
- if (bl != null && bl.length > 0 && bl.substr(0, 3).toLowerCase() != "0px") {
- let width = $td.css("border-left-width");
- let type = $td.css("border-left-style");
- let color = $td.css("border-left-color");
- let borderconfig = menuButton.getQKBorder(width, type, color);
- if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
- borderInfo[(r + rp) + "_" + (c + cp)] = {};
- }
- borderInfo[(r + rp) + "_" + (c + cp)].l = { "style": borderconfig[0], "color": borderconfig[1] };
- }
- }
- if (cp == colspan - 1) {
- let br = $td.css("border-right");
- if (br != null && br.length > 0 && br.substr(0, 3).toLowerCase() != "0px") {
- let width = $td.css("border-right-width");
- let type = $td.css("border-right-style");
- let color = $td.css("border-right-color");
- let borderconfig = menuButton.getQKBorder(width, type, color);
- if (borderInfo[(r + rp) + "_" + (c + cp)] == null) {
- borderInfo[(r + rp) + "_" + (c + cp)] = {};
- }
- borderInfo[(r + rp) + "_" + (c + cp)].r = { "style": borderconfig[0], "color": borderconfig[1] };
- }
- }
- if (rp == 0 && cp == 0) {
- continue;
- }
- data[r + rp][c + cp] = { "mc": { "r": r_ab, "c": c_ab } };
- }
- }
- if (rowspan > 1 || colspan > 1) {
- let first = { "rs": rowspan, "cs": colspan, "r": r_ab, "c": c_ab };
- data[r][c].mc = first;
- }
- }
- c++;
- if (c == colLen) {
- return true;
- }
- });
- r++;
- });
- Store.luckysheet_selection_range = [];
- selection.pasteHandler(data, borderInfo);
- $("#luckysheet-copy-content").empty();
- }
- //复制的是图片
- else if(clipboardData.files.length == 1 && clipboardData.files[0].type.indexOf('image') > -1){
- imageCtrl.insertImg(clipboardData.files[0]);
- return;
- }
- else {
- txtdata = clipboardData.getData("text/plain");
- selection.pasteHandler(txtdata);
- }
- }
- }
- else if($(e.target).closest('#luckysheet-rich-text-editor').length > 0) {
-
- // 阻止默认粘贴
- e.preventDefault();
- let clipboardData = window.clipboardData; //for IE
- if (!clipboardData) { // for chrome
- clipboardData = e.originalEvent.clipboardData;
- }
- let text = clipboardData.getData('text/plain');
- // 插入
- document.execCommand("insertText", false, text);
- }
- });
- //是否允许加载下一页
- if (luckysheetConfigsetting.enablePage) {
- $("#luckysheet-bottom-page-next").click(function () {
- let queryExps = luckysheetConfigsetting.pageInfo.queryExps;
- let reportId = luckysheetConfigsetting.pageInfo.reportId;
- let fields = luckysheetConfigsetting.pageInfo.fields;
- let mobile = luckysheetConfigsetting.pageInfo.mobile;
- let frezon = luckysheetConfigsetting.pageInfo.frezon;
- let currentPage = luckysheetConfigsetting.pageInfo.currentPage;
- let totalPage = luckysheetConfigsetting.pageInfo.totalPage;
- let pageUrl = luckysheetConfigsetting.pageInfo.pageUrl;
-
- method.addDataAjax({
- "queryExps": queryExps,
- "reportId": reportId,
- "fields": fields,
- "mobile": mobile,
- "frezon": frezon,
- "pageIndex": currentPage,
- "currentPage": currentPage
- }, Store.currentSheetIndex, pageUrl, function () {
- luckysheetConfigsetting.pageInfo.currentPage++;
- if (luckysheetConfigsetting.pageInfo.totalPage == (luckysheetConfigsetting.pageInfo.currentPage)) {
- $("#luckysheet-bottom-page-next").hide();
- let pageInfoFull = replaceHtml(locale_info.pageInfoFull, {
- total: luckysheetConfigsetting.total,
- totalPage: luckysheetConfigsetting.pageInfo.totalPage,
- });
- $("#luckysheet-bottom-page-info").html(pageInfoFull);
- }
- else {
- let pageInfo = replaceHtml(locale_info.pageInfo, {
- total: luckysheetConfigsetting.total,
- totalPage: luckysheetConfigsetting.pageInfo.totalPage,
- currentPage: luckysheetConfigsetting.pageInfo.currentPage
- });
- $("#luckysheet-bottom-page-info").html(pageInfo);
- }
- });
- }).mousedown(function (e) {
- e.stopPropagation();
- });
- }
- //回到顶部
- $("#luckysheet-bottom-bottom-top").click(function () {
- $("#luckysheet-scrollbar-y").scrollTop(0);
- }).mousedown(function (e) {
- e.stopPropagation();
- });
- $('#luckysheet-wa-editor,#luckysheet-icon-morebtn-div,.luckysheet-toolbar-button').click(function(e){
- if(this.id != 'luckysheet-icon-paintformat' && menuButton.luckysheetPaintModelOn){
- menuButton.cancelPaintModel();
- }
- })
- }
- // 协同编辑其他用户不在操作的时候,且已经展示了用户名10秒,则用户名框隐藏
- function hideUsername(){
- let $showEle = $$('.luckysheet-multipleRange-show');
- if($showEle.length === undefined){
- $showEle = [$showEle];
- }
- $showEle.forEach((ele)=>{
- const id = ele.id.replace('luckysheet-multipleRange-show-','');
-
- if(Store.cooperativeEdit.usernameTimeout['user' + id] === null){
- $$('.username',ele).style.display = 'none';
- }
- })
- }
|