PHP Classes

File: public/js/tinymce/src/core/src/main/js/keyboard/MatchKeys.js

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra   GoLavaCMS   public/js/tinymce/src/core/src/main/js/keyboard/MatchKeys.js   Download  
File: public/js/tinymce/src/core/src/main/js/keyboard/MatchKeys.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: GoLavaCMS
Publish content on Web pages with SEO support
Author: By
Last change:
Date: 6 years ago
Size: 1,626 bytes
 

Contents

Class file image Download
/** * MatchKeys.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ define( 'tinymce.core.keyboard.MatchKeys', [ 'ephox.katamari.api.Arr', 'ephox.katamari.api.Fun', 'ephox.katamari.api.Merger' ], function (Arr, Fun, Merger) { var defaultPatterns = function (patterns) { return Arr.map(patterns, function (pattern) { return Merger.merge({ shiftKey: false, altKey: false, ctrlKey: false, metaKey: false, keyCode: 0, action: Fun.noop }, pattern); }); }; var matchesEvent = function (pattern, evt) { return ( evt.keyCode === pattern.keyCode && evt.shiftKey === pattern.shiftKey && evt.altKey === pattern.altKey && evt.ctrlKey === pattern.ctrlKey && evt.metaKey === pattern.metaKey ); }; var match = function (patterns, evt) { return Arr.bind(defaultPatterns(patterns), function (pattern) { return matchesEvent(pattern, evt) ? [pattern] : [ ]; }); }; var action = function (f) { var args = Array.prototype.slice.call(arguments, 1); return function () { return f.apply(null, args); }; }; var execute = function (patterns, evt) { return Arr.find(match(patterns, evt), function (pattern) { return pattern.action(); }); }; return { match: match, action: action, execute: execute }; } );