Best JavaScript code snippet using storybook-root
presentation.js
Source:presentation.js
...97 this.open(callback);98 }99 }, this));100 };101 DownloadPresentation.prototype = new BasePresentation();102 DownloadPresentation.prototype.constructor = DownloadPresentation;103 DownloadPresentation.prototype.open = function(callback) {104 if (this.downloading) {105 console.log("Presentation download not finished yet, not showing", this);106 this.openCallback = callback;107 return;108 }109 if (this.url && this.url.indexOf("blob:") === 0) {110 callback(this.url);111 return;112 }113 if (this.file.hasOwnProperty("writer")) {114 callback(this.file);115 } else {116 this.file.file(function(fp) {117 callback(fp);118 });119 }120 };121 DownloadPresentation.prototype.browserOpen = function(target) {122 target = target || "_blank";123 if (this.downloading) {124 console.log("Presentation download not finished yet, not opening", this);125 return;126 }127 $window.open(this.url, target);128 };129 DownloadPresentation.prototype.close = function() {130 this.openCallback = null;131 };132 DownloadPresentation.prototype.start = function() {133 this.handler = mediaStream.tokens.on(this.token, _.bind(function(event, currenttoken, to, data, type, to2, from, xfer) {134 //console.log("Presentation token request", currenttoken, data, type);135 fileDownload.handleRequest(this.scope, xfer, data);136 }, this), "xfer");137 this.session = fileDownload.startDownload(this.scope, this.owner, this.token);138 };139 DownloadPresentation.prototype.stop = function() {140 BasePresentation.prototype.stop.call(this);141 if (this.session) {142 this.session.cancel();143 this.session = null;144 }145 };146 DownloadPresentation.prototype.clear = function() {147 this.stop();148 if (this.scope) {149 this.scope.$emit("cancelDownload");150 this.scope.$destroy();151 this.scope = null;152 }153 this.openCallback = null;154 BasePresentation.prototype.clear.call(this);155 };156 var UploadPresentation = function(scope, file, token) {157 BasePresentation.call(this, scope, file.info, token);158 this.file = file;159 this.presentable = true;160 this.uploaded = true;161 this.fileid = token;162 };163 UploadPresentation.prototype = new BasePresentation();164 UploadPresentation.prototype.constructor = UploadPresentation;165 UploadPresentation.prototype.open = function(callback) {166 callback(this.file);167 };168 UploadPresentation.prototype.browserOpen = function(target) {169 target = target || "_blank";170 if (!this.url) {171 this.url = URL.createObjectURL(this.file.file);172 }173 $window.open(this.url, target);174 };175 UploadPresentation.prototype.close = function() {176 };177 UploadPresentation.prototype.start = function() {178 this.session = fileUpload.startUpload(this.scope, this.token);179 // This binds the token to transfer and ui.180 this.handler = mediaStream.tokens.on(this.token, _.bind(function(event, currenttoken, to, data, type, to2, from, xfer) {181 this.session.handleRequest(this.scope, xfer, data);182 }, this), "xfer");183 };184 UploadPresentation.prototype.stop = function() {185 BasePresentation.prototype.stop.call(this);186 };187 UploadPresentation.prototype.clear = function() {188 this.stop();189 this.close();190 if (this.scope) {191 this.scope.$emit("cancelUpload");192 this.scope.$destroy();193 this.scope = null;194 }195 if (this.url) {196 URL.revokeObjectURL(this.url);197 this.url = null;198 }199 this.session = null;200 BasePresentation.prototype.clear.call(this);201 };202 var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {203 var presentationsCount = 0;204 var pane = $element.find(".presentationpane");205 $scope.layout.presentation = false;206 $scope.hideControlsBar = true;207 $scope.currentPageNumber = -1;208 $scope.maxPageNumber = -1;209 $scope.pendingPageRequest = null;210 $scope.presentationLoaded = false;211 $scope.currentPresentation = null;212 $scope.currentPage = null;213 $scope.receivedPage = null;214 $scope.loading = false;215 $scope.activeDownloads = [];216 $scope.availablePresentations = [];217 $scope.getPresentation = function(token) {218 // TODO(fancycode): better not use linear search,219 // however we need a list for "ng-repeat" to allow220 // sorting.221 var result = _.find($scope.availablePresentations, function(presentation) {222 return (presentation.token === token);223 });224 return result || null;225 };226 $scope.resetProperties = function() {227 $scope.currentPageNumber = -1;228 $scope.maxPageNumber = -1;229 $scope.pendingPageRequest = null;230 $scope.presentationLoaded = false;231 $scope.currentPresentation = null;232 $scope.currentPage = null;233 $scope.receivedPage = null;234 $scope.loading = false;235 };236 $scope.$on("presentationOpening", function(event, presentation) {237 $scope.loading = true;238 });239 $scope.$on("presentationLoaded", function(event, source, doc) {240 $scope.maxPageNumber = doc.numPages;241 if ($scope.currentPresentation && $scope.currentPresentation.presentable) {242 $scope.currentPageNumber = 1;243 } else if ($scope.pendingPageRequest !== null) {244 $scope.currentPageNumber = $scope.pendingPageRequest;245 $scope.pendingPageRequest = null;246 }247 $scope.presentationLoaded = true;248 });249 $scope.$on("presentationLoadError", function(event, source, errorMessage, moreInfo) {250 $scope.loading = false;251 alertify.dialog.alert(errorMessage);252 });253 var downloadPresentation = function(fileInfo, from) {254 var token = fileInfo.id;255 var existing = $scope.getPresentation(token);256 if (existing) {257 console.log("Found existing presentation", existing);258 return;259 }260 var download = _.find($scope.activeDownloads, function(download) {261 return (download.token === token);262 });263 if (download) {264 // already downloading presentation, wait for completion265 console.log("Still downloading presentation", download);266 return;267 }268 download = new DownloadPresentation($scope, fileInfo, token, from);269 download.e.one("available", function(event, download, url, fileInfo) {270 var pos = _.indexOf($scope.activeDownloads, download);271 if (pos !== -1) {272 $scope.activeDownloads.splice(pos, 1);273 }274 });275 $scope.activeDownloads.push(download);276 $scope.availablePresentations.push(download);277 download.start();278 };279 var uploadPresentation = function(file) {280 var token = file.info.id;281 var existing = $scope.getPresentation(token);282 if (existing) {283 console.log("Already uploaded presentation", existing);284 return existing;285 }286 var upload = new UploadPresentation($scope, file, token);287 $scope.availablePresentations.push(upload);288 upload.start();289 return upload;290 };291 mediaStream.api.e.on("received.presentation", function(event, id, from, data, p2p) {292 if (!p2p) {293 console.warn("Received presentation info without p2p. This should not happen!");294 return;295 }296 if (data.Type) {297 switch (data.Type) {298 case "FileInfo":299 console.log("Received presentation file request", data);300 $scope.$apply(function(scope) {301 downloadPresentation(data.FileInfo, from);302 });303 break;304 case "Delete":305 console.log("Received presentation delete request", data);306 $scope.$apply(function(scope) {307 var token = data.Delete;308 var existing = _.find(scope.availablePresentations, function(presentation) {309 // only allow deleting of presentations we downloaded310 return (!presentation.uploaded && presentation.token === token);311 });312 if (existing) {313 scope.deletePresentation(existing);314 }315 });316 break;317 case "Show":318 console.log("Received presentation show request", data);319 $scope.$apply(function(scope) {320 if (!scope.layout.presentation) {321 scope.resetProperties();322 scope.layout.presentation = true;323 }324 });325 break;326 case "Hide":327 console.log("Received presentation hide request", data);328 $scope.$apply(function(scope) {329 scope.layout.presentation = false;330 });331 break;332 case "Select":333 console.log("Received presentation select request", data);334 $scope.$apply(function(scope) {335 var token = data.Select;336 var existing = _.find(scope.availablePresentations, function(presentation) {337 // only allow deleting of presentations we downloaded338 return (!presentation.uploaded && presentation.token === token);339 });340 if (existing) {341 scope.doSelectPresentation(existing);342 } else {343 console.log("No presentation found for token", token);344 }345 });346 break;347 case "Page":348 $scope.$apply(function(scope) {349 scope.receivedPage = data.Page;350 if (!scope.presentationLoaded) {351 console.log("Queuing presentation page request, not loaded yet", data);352 scope.pendingPageRequest = data.Page;353 } else {354 console.log("Received presentation page request", data);355 scope.currentPageNumber = data.Page;356 }357 });358 break;359 default:360 console.log("Received unknown presentation event", data);361 }362 }363 });364 var peers = {};365 var presentations = [];366 var currentToken = null;367 var tokenHandler = null;368 var mediaStreamSendPresentation = function(peercall, token, params) {369 mediaStream.api.apply("sendPresentation", {370 send: function(type, data) {371 if (!peercall.peerconnection.datachannelReady) {372 return peercall.e.one("dataReady", function() {373 peercall.peerconnection.send(data);374 });375 } else {376 return peercall.peerconnection.send(data);377 }378 }379 })(peercall.id, token, params);380 };381 var connector = function(token, peercall) {382 //console.log("XXX connector", token, peercall, peers);383 if (peers.hasOwnProperty(peercall.id)) {384 // Already got a connection.385 return;386 }387 peers[peercall.id] = true;388 mediaStreamSendPresentation(peercall, token, {389 Type: "Show",390 Show: true391 });392 _.each($scope.availablePresentations, function(presentation) {393 if (presentation.uploaded) {394 mediaStreamSendPresentation(peercall, token, {395 Type: "FileInfo",396 FileInfo: presentation.info397 });398 }399 });400 if ($scope.currentPresentation && $scope.currentPresentation.uploaded) {401 mediaStreamSendPresentation(peercall, token, {402 Type: "Select",403 Select: $scope.currentPresentation.token404 });405 if ($scope.currentPage !== null) {406 mediaStreamSendPresentation(peercall, token, {407 Type: "Page",408 Page: $scope.currentPage409 });410 }411 }412 };413 // Updater function to bring in new calls.414 var updater = function(event, state, currentcall) {415 switch (state) {416 case "completed":417 case "connected":418 connector(currentToken, currentcall);419 break;420 case "closed":421 delete peers[currentcall.id];422 if (_.isEmpty(peers)) {423 console.log("All peers disconnected, stopping presentation");424 $scope.$apply(function(scope) {425 scope.hidePresentation();426 });427 }428 break;429 }430 };431 $scope.$on("presentationPageLoading", function(event, page) {432 $scope.loading = false;433 $scope.currentPageNumber = page;434 if ($scope.receivedPage === page) {435 // we received this page request, don't publish to others436 $scope.receivedPage = null;437 return;438 }439 $scope.currentPage = page;440 mediaStream.webrtc.callForEachCall(function(peercall) {441 mediaStreamSendPresentation(peercall, currentToken, {442 Type: "Page",443 Page: page444 });445 });446 });447 $scope.$on("presentationPageLoadError", function(event, page, errorMessage) {448 $scope.loading = false;449 alertify.dialog.alert(errorMessage);450 });451 $scope.$on("presentationPageRenderError", function(event, pageNumber, maxPageNumber, errorMessage) {452 $scope.loading = false;453 alertify.dialog.alert(errorMessage);454 });455 $scope.advertiseFile = function(file) {456 console.log("Advertising file", file);457 var fileInfo = file.info;458 // TODO(fancycode): other peers should either request the file or subscribe rendered images (e.g. for mobile app), for now we send the whole file459 mediaStream.webrtc.callForEachCall(function(peercall) {460 mediaStreamSendPresentation(peercall, currentToken, {461 Type: "FileInfo",462 FileInfo: fileInfo463 });464 });465 var presentation = uploadPresentation(file);466 if (!$scope.currentPresentation) {467 // no presentation active, show immediately468 $scope.selectPresentation(presentation);469 }470 };471 var filesSelected = function(files) {472 var valid_files = [];473 _.each(files, function(f) {474 if (!SUPPORTED_TYPES.hasOwnProperty(f.info.type)) {475 console.log("Not sharing file", f);476 alertify.dialog.alert(translation._("Only PDF documents and OpenDocument files can be shared at this time."));477 valid_files = null;478 return;479 }480 if (valid_files !== null) {481 valid_files.push(f);482 }483 });484 $scope.$apply(function(scope) {485 _.each(valid_files, function(f) {486 if (!f.info.hasOwnProperty("id")) {487 f.info.id = f.id;488 }489 scope.advertiseFile(f);490 });491 });492 };493 // create drag-drop target494 var namespace = "file_" + $scope.id;495 var binder = fileUpload.bindDrop(namespace, $element, function(files) {496 console.log("Files dragged", files);497 filesSelected(files);498 });499 binder.namespace = function() {500 // Inject own id into namespace.501 return namespace + "_" + $scope.myid;502 };503 var clickBinder = fileUpload.bindClick(namespace, $element.find('.welcome button')[0], function(files) {504 console.log("Files selected", files);505 filesSelected(files);506 });507 clickBinder.namespace = function() {508 // Inject own id into namespace.509 return namespace + "_" + $scope.myid;510 };511 var uploadBinder = fileUpload.bindClick(namespace, $element.find('.thumbnail button')[0], function(files) {512 console.log("Files selected", files);513 filesSelected(files);514 });515 uploadBinder.namespace = function() {516 // Inject own id into namespace.517 return namespace + "_" + $scope.myid;518 };519 $scope.showPresentation = function() {520 console.log("Presentation active");521 $scope.layout.presentation = true;522 $scope.$emit("mainview", "presentation", true);523 if (currentToken) {524 mediaStream.tokens.off(currentToken, tokenHandler);525 }526 // Create token to register with us and send token out to all peers.527 // Peers when connect to us with the token and we answer.528 currentToken = "presentation_" + $scope.id + "_" + (presentationsCount++);529 // Create callbacks are called for each incoming connections.530 tokenHandler = mediaStream.tokens.create(currentToken, function(event, currenttoken, to, data, type, to2, from, peerpresentation) {531 console.log("Presentation create", currenttoken, data, type, peerpresentation);532 presentations.push(peerpresentation);533 //usermedia.addToPeerConnection(peerscreenshare.peerconnection);534 }, "presentation");535 // Connect all current calls.536 mediaStream.webrtc.callForEachCall(function(peercall) {537 connector(currentToken, peercall);538 });539 // Catch later calls too.540 mediaStream.webrtc.e.on("statechange", updater);541 };542 $scope.hidePresentation = function() {543 console.log("Presentation disabled");544 if (currentToken) {545 mediaStream.webrtc.callForEachCall(function(peercall) {546 mediaStreamSendPresentation(peercall, currentToken, {547 Type: "Hide",548 Hide: true549 });550 });551 mediaStream.tokens.off(currentToken, tokenHandler);552 currentToken = null;553 }554 $scope.resetProperties();555 $scope.layout.presentation = false;556 peers = {};557 $scope.$emit("mainview", "presentation", false);558 mediaStream.webrtc.e.off("statechange", updater);559 };560 $scope.selectPresentation = function(presentation) {561 if (!presentation.presentable) {562 // can't show this presentation563 return;564 }565 if ($scope.currentPresentation === presentation) {566 // switch back to first page when clicked on current presentation567 $scope.currentPageNumber = 1;568 return;569 }570 mediaStream.webrtc.callForEachCall(function(peercall) {571 mediaStreamSendPresentation(peercall, currentToken, {572 Type: "Select",573 Select: presentation.token574 });575 });576 $scope.doSelectPresentation(presentation);577 }578 $scope.doSelectPresentation = function(presentation) {579 console.log("Selected", presentation);580 $scope.resetProperties();581 $scope.currentPresentation = presentation;582 };583 $scope.deletePresentation = function(presentation, $event) {584 if ($event) {585 $event.preventDefault();586 }587 var pos = _.indexOf($scope.availablePresentations, presentation);588 if (pos !== -1) {589 $scope.availablePresentations.splice(pos, 1);590 }591 if (presentation.uploaded) {592 mediaStream.webrtc.callForEachCall(function(peercall) {593 mediaStreamSendPresentation(peercall, currentToken, {594 Type: "Delete",595 Delete: presentation.token596 });597 });598 }599 if ($scope.currentPresentation === presentation) {600 $scope.currentPresentation = null;601 $scope.resetProperties();602 }603 presentation.clear();604 };605 $scope.downloadPresentation = function(presentation, $event) {606 if ($event) {607 $event.preventDefault();608 }609 presentation.browserOpen();610 };611 $scope.toggleFullscreen = function(elem) {612 if (BigScreen.enabled) {613 if (elem) {614 BigScreen.toggle(elem);615 } else {616 BigScreen.toggle(pane[0]);617 }618 }619 };620 $scope.prevPage = function() {621 if ($scope.currentPageNumber > 1) {622 $scope.currentPageNumber -= 1;623 }624 };625 $scope.nextPage = function() {626 if ($scope.currentPageNumber < $scope.maxPageNumber) {627 $scope.currentPageNumber += 1;628 }629 };630 mediaStream.webrtc.e.on("done", function() {631 $scope.$apply(function() {632 _.each($scope.availablePresentations, function(presentation) {633 presentation.clear();634 });635 $scope.availablePresentations = [];636 $scope.activeDownloads = [];637 });638 });639 $scope.$on("keyUp", function(event, keyCode) {640 switch (keyCode) {641 case 37:642 // left arrow643 $scope.prevPage();644 break;645 case 39:646 // right arrow647 case 32:648 // space649 $scope.nextPage();650 break;651 }652 })653 $(document).on("keyup", function(event) {654 if (!$scope.layout.presentation) {655 return;656 }657 if ($(event.target).is("input,textarea,select")) {658 return;659 }660 $scope.$apply(function(scope) {661 scope.$emit("keyUp", event.keyCode);662 });663 event.preventDefault();664 });665 $scope.$watch("layout.presentation", function(newval, oldval) {666 if (newval && !oldval) {667 $scope.showPresentation();668 } else if (!newval && oldval) {669 $scope.hidePresentation();670 }671 });672 $scope.$watch("layout.main", function(newval, oldval) {673 if (newval && newval !== "presentation") {674 $scope.hidePresentation();675 }676 });677 }];678 var compile = function(tElement, tAttr) {679 return function(scope, iElement, iAttrs, controller) {680 $(iElement).on("dblclick", ".canvasContainer", _.debounce(function(event) {681 scope.toggleFullscreen(event.delegateTarget);682 }, 100, true));683 }684 };685 return {686 restrict: 'E',687 replace: true,688 scope: true,...
presentation.class.ts
Source:presentation.class.ts
...81 async createPresentationEntity (presentation: DecryptedPresentation, params?: Params, presentationRequestId?: string): Promise<PresentationEntity> {82 const decryptedPresentation: Presentation = presentation.presentation as Presentation;83 // const pres: Presentation84 const presentationWithVerification: PresentationWithVerificationDeprecated = { isVerified: presentation.isVerified, presentation: decryptedPresentation };85 const options = makePresentationEntityOptionsFromPresentation(presentationWithVerification);86 try {87 return this.presentationDataService.create(options, params);88 } catch (e) {89 logger.error('PresentationService.createPresentationEntity caught an error thrown by PresentationDataService.create', e);90 throw e;91 }92 }93 async createNoPresentationEntity (noPresentation: DecryptedPresentation, params?: Params): Promise<NoPresentationEntity> {94 const decryptedPresentation: NoPresentation = noPresentation.presentation as NoPresentation;95 const noPresentationWithVerification: NoPresentationWithVerificationDeprecated = { isVerified: noPresentation.isVerified, noPresentation: decryptedPresentation };96 const options = makeNoPresentationEntityOptionsFromNoPresentation(noPresentationWithVerification);97 try {98 return this.noPresentationDataService.create(options, params);99 } catch (e) {100 logger.error('PresentationService.crateNoPresentationEntity caught an error thrown by NoPresentationDataService.create', e);101 throw e;102 }103 }104 async create (105 data: WithVersion<EncryptedPresentation>,106 params?: Params107 ): Promise<VerificationResponse | VerificationResponseDeprecated> {108 try {109 const presentationRequestService = this.app.service('presentationRequestData');110 const presentationWebsocketService = this.app.service('presentationWebsocket');111 const presentationServiceV2 = this.app.service('presentationV2');112 /**113 * Note: actually not necessary anymore due to the full presentation request object being sent with the EncryptedPresentation type.114 * However leaving here as an example in case additional contextual info needs to be saved on the request object115 * one should query on the id field, not uuid, thanks to UnumId under the hood handling of potential request versioning.116 */117 const presentationRequest = await presentationRequestService.get(null, { where: { prId: data.presentationRequestInfo.presentationRequest.id } });118 if (!presentationRequest) {119 throw new NotFound('PresentationRequest not found.');120 }121 const verifierDataService = this.app.service('verifierData');122 const verifier = await verifierDataService.getDefaultVerifierEntity();123 // Needed to roll over the old attribute value that wasn't storing the Bearer as part of the token. Ought to remove once the roll over is complete. Figured simple to enough to just handle in app code.124 const authToken = verifier.authToken.startsWith('Bearer ') ? verifier.authToken : `Bearer ${verifier.authToken}`;125 // if request is made with version header 2.0.0+ then use the new server-sdk other wise use the old126 if (lt(data.version, '2.0.0')) {127 const response = await verifyPresentation(authToken, data.encryptedPresentation, verifier.verifierDid, verifier.encryptionPrivateKey, data.presentationRequestInfo);128 const result: DecryptedPresentation = response.body;129 logger.info(`response from server sdk ${JSON.stringify(result)}`);130 // need to update the verifier auth token131 await verifierDataService.patch(verifier.uuid, { authToken: response.authToken });132 // return early if the presentation could not be verified133 if (!result.isVerified) {134 logger.warn(`Presentation verification failed: ${result.message}`);135 throw new BadRequest(`Verification failed: ${result.message ? result.message : ''}`);136 }137 if (result.type === 'VerifiablePresentation') {138 try {139 // Persist the Presentation entity and add the version for the websocket handler140 const entity = {141 ...await this.createPresentationEntity(result, params, data.presentationRequestInfo.presentationRequest.id),...
presentation_mode.js
Source:presentation_mode.js
1/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */2/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */3/* Copyright 2012 Mozilla Foundation4 *5 * Licensed under the Apache License, Version 2.0 (the "License");6 * you may not use this file except in compliance with the License.7 * You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17/* globals PDFView, scrollIntoView, HandTool */18'use strict';19var DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms20var SELECTOR = 'presentationControls';21var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1000; // in ms22var PresentationMode = {23 active: false,24 args: null,25 contextMenuOpen: false,26//#if (GENERIC || CHROME)27 prevCoords: { x: null, y: null },28//#endif29 initialize: function presentationModeInitialize(options) {30 this.container = options.container;31 this.secondaryToolbar = options.secondaryToolbar;32 this.viewer = this.container.firstElementChild;33 this.firstPage = options.firstPage;34 this.lastPage = options.lastPage;35 this.pageRotateCw = options.pageRotateCw;36 this.pageRotateCcw = options.pageRotateCcw;37 this.firstPage.addEventListener('click', function() {38 this.contextMenuOpen = false;39 this.secondaryToolbar.firstPageClick();40 }.bind(this));41 this.lastPage.addEventListener('click', function() {42 this.contextMenuOpen = false;43 this.secondaryToolbar.lastPageClick();44 }.bind(this));45 this.pageRotateCw.addEventListener('click', function() {46 this.contextMenuOpen = false;47 this.secondaryToolbar.pageRotateCwClick();48 }.bind(this));49 this.pageRotateCcw.addEventListener('click', function() {50 this.contextMenuOpen = false;51 this.secondaryToolbar.pageRotateCcwClick();52 }.bind(this));53 },54 get isFullscreen() {55 return (document.fullscreenElement ||56 document.mozFullScreen ||57 document.webkitIsFullScreen ||58 document.msFullscreenElement);59 },60 /**61 * Initialize a timeout that is used to reset PDFView.currentPosition when the62 * browser transitions to fullscreen mode. Since resize events are triggered63 * multiple times during the switch to fullscreen mode, this is necessary in64 * order to prevent the page from being scrolled partially, or completely,65 * out of view when Presentation Mode is enabled.66 * Note: This is only an issue at certain zoom levels, e.g. 'page-width'.67 */68 _setSwitchInProgress: function presentationMode_setSwitchInProgress() {69 if (this.switchInProgress) {70 clearTimeout(this.switchInProgress);71 }72 this.switchInProgress = setTimeout(function switchInProgressTimeout() {73 delete this.switchInProgress;74 }.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);75 PDFView.currentPosition = null;76 },77 _resetSwitchInProgress: function presentationMode_resetSwitchInProgress() {78 if (this.switchInProgress) {79 clearTimeout(this.switchInProgress);80 delete this.switchInProgress;81 }82 },83 request: function presentationModeRequest() {84 if (!PDFView.supportsFullscreen || this.isFullscreen ||85 !this.viewer.hasChildNodes()) {86 return false;87 }88 this._setSwitchInProgress();89 if (this.container.requestFullscreen) {90 this.container.requestFullscreen();91 } else if (this.container.mozRequestFullScreen) {92 this.container.mozRequestFullScreen();93 } else if (this.container.webkitRequestFullScreen) {94 this.container.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);95 } else if (this.container.msRequestFullscreen) {96 this.container.msRequestFullscreen();97 } else {98 return false;99 }100 this.args = {101 page: PDFView.page,102 previousScale: PDFView.currentScaleValue103 };104 return true;105 },106 enter: function presentationModeEnter() {107 this.active = true;108 this._resetSwitchInProgress();109 // Ensure that the correct page is scrolled into view when entering110 // Presentation Mode, by waiting until fullscreen mode in enabled.111 // Note: This is only necessary in non-Mozilla browsers.112 setTimeout(function enterPresentationModeTimeout() {113 PDFView.page = this.args.page;114 PDFView.setScale('page-fit', true);115 }.bind(this), 0);116 window.addEventListener('mousemove', this.mouseMove, false);117 window.addEventListener('mousedown', this.mouseDown, false);118 window.addEventListener('contextmenu', this.contextMenu, false);119 this.showControls();120 HandTool.enterPresentationMode();121 this.contextMenuOpen = false;122 this.container.setAttribute('contextmenu', 'viewerContextMenu');123 },124 exit: function presentationModeExit() {125 var page = PDFView.page;126 // Ensure that the correct page is scrolled into view when exiting127 // Presentation Mode, by waiting until fullscreen mode is disabled.128 // Note: This is only necessary in non-Mozilla browsers.129 setTimeout(function exitPresentationModeTimeout() {130 this.active = false;131 PDFView.setScale(this.args.previousScale);132 PDFView.page = page;133 this.args = null;134 }.bind(this), 0);135 window.removeEventListener('mousemove', this.mouseMove, false);136 window.removeEventListener('mousedown', this.mouseDown, false);137 window.removeEventListener('contextmenu', this.contextMenu, false);138 this.hideControls();139 PDFView.clearMouseScrollState();140 HandTool.exitPresentationMode();141 this.container.removeAttribute('contextmenu');142 this.contextMenuOpen = false;143 // Ensure that the thumbnail of the current page is visible144 // when exiting presentation mode.145 scrollIntoView(document.getElementById('thumbnailContainer' + page));146 },147 showControls: function presentationModeShowControls() {148 if (this.controlsTimeout) {149 clearTimeout(this.controlsTimeout);150 } else {151 this.container.classList.add(SELECTOR);152 }153 this.controlsTimeout = setTimeout(function hideControlsTimeout() {154 this.container.classList.remove(SELECTOR);155 delete this.controlsTimeout;156 }.bind(this), DELAY_BEFORE_HIDING_CONTROLS);157 },158 hideControls: function presentationModeHideControls() {159 if (!this.controlsTimeout) {160 return;161 }162 this.container.classList.remove(SELECTOR);163 clearTimeout(this.controlsTimeout);164 delete this.controlsTimeout;165 },166 mouseMove: function presentationModeMouseMove(evt) {167//#if (GENERIC || CHROME)168 // Workaround for a bug in WebKit browsers that causes the 'mousemove' event169 // to be fired when the cursor is changed. For details, see:170 // http://code.google.com/p/chromium/issues/detail?id=103041.171 var currCoords = { x: evt.clientX, y: evt.clientY };172 var prevCoords = PresentationMode.prevCoords;173 PresentationMode.prevCoords = currCoords;174 if (currCoords.x === prevCoords.x && currCoords.y === prevCoords.y) {175 return;176 }177//#endif178 PresentationMode.showControls();179 },180 mouseDown: function presentationModeMouseDown(evt) {181 var self = PresentationMode;182 if (self.contextMenuOpen) {183 self.contextMenuOpen = false;184 evt.preventDefault();185 return;186 }187 if (evt.button === 0) {188 // Enable clicking of links in presentation mode. Please note:189 // Only links pointing to destinations in the current PDF document work.190 var isInternalLink = (evt.target.href &&191 evt.target.classList.contains('internalLink'));192 if (!isInternalLink) {193 // Unless an internal link was clicked, advance one page.194 evt.preventDefault();195 PDFView.page += (evt.shiftKey ? -1 : 1);196 }197 }198 },199 contextMenu: function presentationModeContextMenu(evt) {200 PresentationMode.contextMenuOpen = true;201 }202};203(function presentationModeClosure() {204 function presentationModeChange(e) {205 if (PresentationMode.isFullscreen) {206 PresentationMode.enter();207 } else {208 PresentationMode.exit();209 }210 }211 window.addEventListener('fullscreenchange', presentationModeChange, false);212 window.addEventListener('mozfullscreenchange', presentationModeChange, false);213 window.addEventListener('webkitfullscreenchange', presentationModeChange,214 false);215 window.addEventListener('MSFullscreenChange', presentationModeChange, false);...
Using AI Code Generation
1import { Presentation } from 'storybook-root'2import { Presentation } from 'storybook-root'3export { Presentation } from './Presentation'4export { Presentation } from './Presentation'5export { Presentation } from './Presentation'6export { Presentation } from './Presentation'7export { Presentation } from './Presentation'8export { Presentation } from './Presentation'9export { Presentation } from './Presentation'10export { Presentation } from './Presentation'11export { Presentation } from './Presentation'12export { Presentation } from './Presentation'13export { Presentation } from './Presentation'14export { Presentation } from './Presentation'15export { Presentation } from './Presentation'16export { Presentation } from './Presentation'17export { Presentation } from './Presentation'
Using AI Code Generation
1import { Presentation } from 'storybook-root';2const presentation = new Presentation();3presentation.addSlide('Hello World');4presentation.addSlide('Hello World 2');5presentation.addSlide('Hello World 3');6presentation.addSlide('Hello World 4');7presentation.addSlide('Hello World 5');8presentation.addSlide('Hello World 6');9presentation.addSlide('Hello World 7');10presentation.addSlide('Hello World 8');11const presentation = new Presentation();12presentation.addSlide('Hello World');13presentation.addSlide('Hello World 2');14presentation.addSlide('Hello World 3');15presentation.addSlide('Hello World 4');16presentation.addSlide('Hello World 5');17presentation.addSlide('Hello World 6');18presentation.addSlide('Hello World 7');19presentation.addSlide('Hello World 8');20const presentation = new Presentation();21presentation.addSlide('Hello World');22presentation.addSlide('Hello World 2');23presentation.addSlide('Hello World 3');24presentation.addSlide('Hello World 4');25presentation.addSlide('Hello World 5');26presentation.addSlide('Hello World 6');27presentation.addSlide('Hello World 7');28presentation.addSlide('Hello World 8');29const presentation = new Presentation();30presentation.addSlide('Hello World');31presentation.addSlide('Hello World 2');32presentation.addSlide('Hello World 3');33presentation.addSlide('Hello World 4');34presentation.addSlide('Hello World 5');35presentation.addSlide('Hello World 6');36presentation.addSlide('Hello World 7');37presentation.addSlide('Hello World 8');38const presentation = new Presentation();39presentation.addSlide('Hello World');40presentation.addSlide('Hello World 2');41presentation.addSlide('Hello World 3');42presentation.addSlide('Hello World 4');43presentation.addSlide('Hello World 5');44presentation.addSlide('Hello World 6');45presentation.addSlide('Hello World 7');46presentation.addSlide('Hello World 8');47const presentation = new Presentation();48presentation.addSlide('Hello World');49presentation.addSlide('Hello World 2');50presentation.addSlide('Hello World 3');51presentation.addSlide('Hello World 4');52presentation.addSlide('
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!