UNPKG

@mikezimm/npmfunctions

Version:
159 lines (158 loc) 9.29 kB
"use strict"; /** * This is modeled after npmFunctions/Services/DOM/FPSExpandoramic.ts * * @returns */ Object.defineProperty(exports, "__esModule", { value: true }); exports.FPSPinMe = exports.checkIsInVerticalSection = exports.getDefaultFPSPinState = void 0; var domSearch_1 = require("../domSearch"); // import { updateByClassNameEleChild } from '../otherDOMAttempts'; var sp_core_library_1 = require("@microsoft/sp-core-library"); require('./FPSPinMe.css'); /** * getDefaultFPSPinState gets the default defPinState depending on if the page is in Edit Mode. * Edit Mode requires the pinMode to change so that it does not hide the Edit/Save buttons. * Originally copied from FPSPageInfo.tsx * @param prevfpsPinMenu * @param currfpsPinMenu * @param displayMode - basically current component must have displayMode in it's props and passed in here. * @returns */ function getDefaultFPSPinState(prevfpsPinMenu, currfpsPinMenu, displayMode) { var refresh = false; var defPinState = currfpsPinMenu.defPinState; if (defPinState !== prevfpsPinMenu.defPinState) { refresh = true; } else if (prevfpsPinMenu.forcePinState !== currfpsPinMenu.forcePinState) { refresh = true; } //This fixed https://github.com/mikezimm/PageInfo/issues/47 if (displayMode === sp_core_library_1.DisplayMode.Edit) { defPinState = 'normal'; } var result = { defPinState: defPinState, refresh: refresh }; return result; } exports.getDefaultFPSPinState = getDefaultFPSPinState; function checkIsInVerticalSection(domElement) { //CanvasVerticalSection var isVertical = false; var verticalSection = (0, domSearch_1.findParentElementLikeThis)(domElement, 'classList', 'CanvasVerticalSection', 10, 'contains', false, true); if (verticalSection) { isVertical = true; } return isVertical; } exports.checkIsInVerticalSection = checkIsInVerticalSection; function FPSPinMe(domElement, pinState, controlStyle, alertError, consoleResult, pinMePadding, host, displayMode) { if (alertError === void 0) { alertError = true; } if (consoleResult === void 0) { consoleResult = false; } //https://github.com/mikezimm/drilldown7/issues/184 //Had to add || host === "SingleWebPartAppPageLayout" because that is what layout was consoled in Drilldown 1.3.1.1 if (host === "SharePointFullPage" || host === "SingleWebPartAppPageLayout") { //If this is a SPA, then there is no reason to do PinMe since there is nothing else to show. //Just return console.log('FPSPinMe host == SPA: host=', host); return; } else { console.log('FPSPinMe host !== NOT SPA: host=', host); //This might be option to bring this line of code in from FetchBannerElement.tsx //Just need to change the incoming paramter from pinState to tempPinState // let pinState: IPinMeState = displayMode === DisplayMode.Edit ? 'normal' : tempPinState; var searchParams = window.location.search ? window.location.search : ''; searchParams = searchParams.split('%3a').join(':'); //Had to add this just as a precaution.... //the classnames change depending on if the page is in EditMode. //When in EditMode, they have single -, in View mode, the have -- var findClass = searchParams.indexOf('Mode=Edit') > -1 ? ['ControlZone-control', 'ControlZone--control'] : ['ControlZone--control', 'ControlZone-control']; // let thisControlZome: Element = null; var thisControlZome_1 = null; var thisCanvasSection_1 = null; var foundElement_1 = false; //Need to be any to pass tslint findClass.map(function (checkClass) { if (foundElement_1 === false) { thisControlZome_1 = (0, domSearch_1.findParentElementLikeThis)(domElement, 'classList', checkClass, 10, 'contains', false, true); if (thisControlZome_1) { foundElement_1 = true; thisCanvasSection_1 = thisControlZome_1.parentElement; } } }); var classList = thisControlZome_1.classList; console.log('FPSPinMe thisControlZome, thisCanvasSection = ', thisControlZome_1, thisCanvasSection_1); if (thisControlZome_1 && thisCanvasSection_1) { if (foundElement_1 === true && pinState === 'disabled') { //Added this if to resolve https://github.com/mikezimm/pivottiles7/issues/190 - if pinCanvasDefault class is found, it shrinks the panel title width if (thisControlZome_1.classList.contains('pinMeWebPartDefault')) thisControlZome_1.classList.remove('pinMeWebPartDefault'); if (thisCanvasSection_1.classList.contains('pinCanvasDefault')) thisCanvasSection_1.classList.remove('pinCanvasDefault'); if (thisCanvasSection_1.classList.contains('pinMeCanvasMinimize')) thisCanvasSection_1.classList.remove('pinMeCanvasMinimize'); } else { if (foundElement_1 === true) { // console.log( 'classList b4 = ', classList ); if (classList) { thisControlZome_1.classList.add('pinMeWebPartDefault'); } // console.log( 'classList af = ', thisControlZome.classList ); } if (displayMode !== sp_core_library_1.DisplayMode.Edit && pinState === 'pinFull') { if (!thisControlZome_1.classList.contains('pinMeTop')) thisControlZome_1.classList.add('pinMeTop'); if (!thisControlZome_1.classList.contains('pinMeFull')) thisControlZome_1.classList.add('pinMeFull'); if (thisControlZome_1.classList.contains('pinMeMini')) thisControlZome_1.classList.remove('pinMeMini'); // thisControlZome.classList.remove( 'pinMeNormal' ) ; if (!thisCanvasSection_1.classList.contains('pinCanvasDefault')) thisCanvasSection_1.classList.add('pinCanvasDefault'); if (!thisCanvasSection_1.classList.contains('pinMeCanvasMinimize')) thisCanvasSection_1.classList.add('pinMeCanvasMinimize'); } else if ((displayMode === sp_core_library_1.DisplayMode.Edit && pinState === 'pinFull') || pinState === 'pinMini') { if (!thisControlZome_1.classList.contains('pinMeTop')) thisControlZome_1.classList.add('pinMeTop'); if (!thisControlZome_1.classList.contains('pinMeMini')) thisControlZome_1.classList.add('pinMeMini'); if (thisControlZome_1.classList.contains('pinMeFull')) thisControlZome_1.classList.remove('pinMeFull'); if (thisControlZome_1.classList.contains('pinMeNormal')) thisControlZome_1.classList.remove('pinMeNormal'); if (displayMode === sp_core_library_1.DisplayMode.Edit) { if (thisCanvasSection_1.classList.contains('pinCanvasDefault')) thisCanvasSection_1.classList.remove('pinCanvasDefault'); if (thisCanvasSection_1.classList.contains('pinMeCanvasMinimize')) thisCanvasSection_1.classList.remove('pinMeCanvasMinimize'); } else { //Is display mode and state === 'pinFull' or 'pinMini' if (!thisCanvasSection_1.classList.contains('pinCanvasDefault')) thisCanvasSection_1.classList.add('pinCanvasDefault'); if (!thisCanvasSection_1.classList.contains('pinMeCanvasMinimize')) thisCanvasSection_1.classList.add('pinMeCanvasMinimize'); } } else if (pinState === 'normal') { // thisControlZome.classList.add( 'pinMeNormal' ) ; if (thisControlZome_1.classList.contains('pinMeTop')) thisControlZome_1.classList.remove('pinMeTop'); if (thisControlZome_1.classList.contains('pinMeMini')) thisControlZome_1.classList.remove('pinMeMini'); if (thisControlZome_1.classList.contains('pinMeFull')) thisControlZome_1.classList.remove('pinMeFull'); if (thisCanvasSection_1.classList.contains('pinCanvasDefault')) thisCanvasSection_1.classList.remove('pinCanvasDefault'); if (thisCanvasSection_1.classList.contains('pinMeCanvasMinimize')) thisCanvasSection_1.classList.remove('pinMeCanvasMinimize'); } } // console.log( 'classList af = ', thisControlZome.classList ); } } } exports.FPSPinMe = FPSPinMe; //# sourceMappingURL=FPSPinMenu.js.map