You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/10/30 14:43:32 UTC
[38/52] [partial] Remove unneeded ace files and codemirror
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/chromevox.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/chromevox.js b/src/fauxton/assets/js/libs/ace/ext/chromevox.js
deleted file mode 100644
index 9f7a799..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/chromevox.js
+++ /dev/null
@@ -1,980 +0,0 @@
-define(function(require, exports, module) {
-
-/* ChromeVox Ace namespace. */
-var cvoxAce = {};
-
-/* Typedefs for Closure compiler. */
-/**
- * @typedef {{
- rate: number,
- pitch: number,
- volume: number,
- relativePitch: number,
- punctuationEcho: string
- }}
- */
-/* TODO(peterxiao): Export this typedef through cvox.Api. */
-cvoxAce.SpeechProperty;
-
-/**
- * @typedef {{
- * row: number,
- * column: number
- * }}
- */
-cvoxAce.Cursor;
-
-/**
- * @typedef {{
- type: string,
- value: string
- }}
- }
- */
-cvoxAce.Token;
-
-/**
- * These are errors and information that Ace will display in the gutter.
- * @typedef {{
- row: number,
- column: number,
- value: string
- }}
- }
- */
-cvoxAce.Annotation;
-
-/* Speech Properties. */
-/**
- * Speech property for speaking constant tokens.
- * @type {cvoxAce.SpeechProperty}
- */
-var CONSTANT_PROP = {
- 'rate': 0.8,
- 'pitch': 0.4,
- 'volume': 0.9
-};
-
-/**
- * Default speech property for speaking tokens.
- * @type {cvoxAce.SpeechProperty}
- */
-var DEFAULT_PROP = {
- 'rate': 1,
- 'pitch': 0.5,
- 'volume': 0.9
-};
-
-/**
- * Speech property for speaking entity tokens.
- * @type {cvoxAce.SpeechProperty}
- */
-var ENTITY_PROP = {
- 'rate': 0.8,
- 'pitch': 0.8,
- 'volume': 0.9
-};
-
-/**
- * Speech property for speaking keywords.
- * @type {cvoxAce.SpeechProperty}
- */
-var KEYWORD_PROP = {
- 'rate': 0.8,
- 'pitch': 0.3,
- 'volume': 0.9
-};
-
-/**
- * Speech property for speaking storage tokens.
- * @type {cvoxAce.SpeechProperty}
- */
-var STORAGE_PROP = {
- 'rate': 0.8,
- 'pitch': 0.7,
- 'volume': 0.9
-};
-
-/**
- * Speech property for speaking variable tokens.
- * @type {cvoxAce.SpeechProperty}
- */
-var VARIABLE_PROP = {
- 'rate': 0.8,
- 'pitch': 0.8,
- 'volume': 0.9
-};
-
-/**
- * Speech property for speaking deleted text.
- * @type {cvoxAce.SpeechProperty}
- */
-var DELETED_PROP = {
- 'punctuationEcho': 'none',
- 'relativePitch': -0.6
-};
-
-/* Constants for Earcons. */
-var ERROR_EARCON = 'ALERT_NONMODAL';
-var MODE_SWITCH_EARCON = 'ALERT_MODAL';
-var NO_MATCH_EARCON = 'INVALID_KEYPRESS';
-
-/* Constants for vim state. */
-var INSERT_MODE_STATE = 'insertMode';
-var COMMAND_MODE_STATE = 'start';
-
-var REPLACE_LIST = [
- {
- substr: ';',
- newSubstr: ' semicolon '
- },
- {
- substr: ':',
- newSubstr: ' colon '
- }
-];
-
-/**
- * Context menu commands.
- */
-var Command = {
- SPEAK_ANNOT: 'annots',
- SPEAK_ALL_ANNOTS: 'all_annots',
- TOGGLE_LOCATION: 'toggle_location',
- SPEAK_MODE: 'mode',
- SPEAK_ROW_COL: 'row_col',
- TOGGLE_DISPLACEMENT: 'toggle_displacement',
- FOCUS_TEXT: 'focus_text'
-};
-
-/**
- * Key prefix for each shortcut.
- */
-var KEY_PREFIX = 'CONTROL + SHIFT ';
-
-/* Globals. */
-cvoxAce.editor = null;
-/**
- * Last cursor position.
- * @type {cvoxAce.Cursor}
- */
-var lastCursor = null;
-
-/**
- * Table of annotations.
- * @typedef {!Object.<number, Object<number, cvoxAce.Annotation>>}
- */
-var annotTable = {};
-
-/**
- * Whether to speak character, word, and then line. This allows blind users
- * to know the location of the cursor when they change lines.
- * @typedef {boolean}
- */
-var shouldSpeakRowLocation = false;
-
-/**
- * Whether to speak displacement.
- * @typedef {boolean}
- */
-var shouldSpeakDisplacement = false;
-
-/**
- * Whether text was changed to cause a cursor change event.
- * @typedef {boolean}
- */
-var changed = false;
-
-/**
- * Current state vim is in.
- */
-var vimState = null;
-
-/**
- * Mapping from key code to shortcut.
- */
-var keyCodeToShortcutMap = {};
-
-/**
- * Mapping from command to shortcut.
- */
-var cmdToShortcutMap = {};
-
-/**
- * Get shortcut string from keyCode.
- * @param {number} keyCode Key code of shortcut.
- * @return {string} String representation of shortcut.
- */
-var getKeyShortcutString = function(keyCode) {
- return KEY_PREFIX + String.fromCharCode(keyCode);
-};
-
-/**
- * Return if in vim mode.
- * @return {boolean} True if in Vim mode.
- */
-var isVimMode = function() {
- var keyboardHandler = cvoxAce.editor.keyBinding.getKeyboardHandler();
- return keyboardHandler.$id === 'ace/keyboard/vim';
-};
-
-/**
- * Gets the current token.
- * @param {!cvoxAce.Cursor} cursor Current position of the cursor.
- * @return {!cvoxAce.Token} Token at the current position.
- */
-var getCurrentToken = function(cursor) {
- return cvoxAce.editor.getSession().getTokenAt(cursor.row, cursor.column + 1);
-};
-
-/**
- * Gets the current line the cursor is under.
- * @param {!cvoxAce.Cursor} cursor Current cursor position.
- */
-var getCurrentLine = function(cursor) {
- return cvoxAce.editor.getSession().getLine(cursor.row);
-};
-
-/**
- * Event handler for row changes. When the user changes rows we want to speak
- * the line so the user can work on this line. If shouldSpeakRowLocation is on
- * then we speak the character, then the row, then the line so the user knows
- * where the cursor is.
- * @param {!cvoxAce.Cursor} currCursor Current cursor position.
- */
-var onRowChange = function(currCursor) {
- /* Notify that this line has an annotation. */
- if (annotTable[currCursor.row]) {
- cvox.Api.playEarcon(ERROR_EARCON);
- }
- if (shouldSpeakRowLocation) {
- cvox.Api.stop();
- speakChar(currCursor);
- speakTokenQueue(getCurrentToken(currCursor));
- speakLine(currCursor.row, 1);
- } else {
- speakLine(currCursor.row, 0);
- }
-};
-
-/**
- * Returns whether the cursor is at the beginning of a word. A word is
- * a grouping of alphanumeric characters including underscores.
- * @param {!cvoxAce.Cursor} cursor Current cursor position.
- * @return {boolean} Whether there is word.
- */
-var isWord = function(cursor) {
- var line = getCurrentLine(cursor);
- var lineSuffix = line.substr(cursor.column - 1);
- if (cursor.column === 0) {
- lineSuffix = ' ' + line;
- }
- /* Use regex to tell if the suffix is at the start of a new word. */
- var firstWordRegExp = /^\W(\w+)/;
- var words = firstWordRegExp.exec(lineSuffix);
- return words !== null;
-};
-
-/**
- * A mapping of syntax type to speech properties / expanding rules.
- */
-var rules = {
- 'constant': {
- prop: CONSTANT_PROP
- },
- 'entity': {
- prop: ENTITY_PROP
- },
- 'keyword': {
- prop: KEYWORD_PROP
- },
- 'storage': {
- prop: STORAGE_PROP
- },
- 'variable': {
- prop: VARIABLE_PROP
- },
- 'meta': {
- prop: DEFAULT_PROP,
- replace: [
- {
- substr: '</',
- newSubstr: ' closing tag '
- },
- {
- substr: '/>',
- newSubstr: ' close tag '
- },
- {
- substr: '<',
- newSubstr: ' tag start '
- },
- {
- substr: '>',
- newSubstr: ' tag end '
- }
- ]
- }
-};
-
-/**
- * Default rule to be used.
- */
-var DEFAULT_RULE = {
- prop: DEFAULT_RULE
-};
-
-/**
- * Expands substrings to how they are read based on the given rules.
- * @param {string} value Text to be expanded.
- * @param {Array.<Object>} replaceRules Rules to determine expansion.
- * @return {string} New expanded value.
- */
-var expand = function(value, replaceRules) {
- var newValue = value;
- for (var i = 0; i < replaceRules.length; i++) {
- var replaceRule = replaceRules[i];
- var regexp = new RegExp(replaceRule.substr, 'g');
- newValue = newValue.replace(regexp, replaceRule.newSubstr);
- }
- return newValue;
-};
-
-/**
- * Merges tokens from start inclusive to end exclusive.
- * @param {Array.<cvoxAce.Token>} Tokens to be merged.
- * @param {number} start Start index inclusive.
- * @param {number} end End index exclusive.
- * @return {cvoxAce.Token} Merged token.
- */
-var mergeTokens = function(tokens, start, end) {
- /* Different type of token found! Merge all previous like tokens. */
- var newToken = {};
- newToken.value = '';
- newToken.type = tokens[start].type;
- for (var j = start; j < end; j++) {
- newToken.value += tokens[j].value;
- }
- return newToken;
-};
-
-/**
- * Merges tokens that use the same speech properties.
- * @param {Array.<cvoxAce.Token>} tokens Tokens to be merged.
- * @return {Array.<cvoxAce.Token>} Merged tokens.
- */
-var mergeLikeTokens = function(tokens) {
- if (tokens.length <= 1) {
- return tokens;
- }
- var newTokens = [];
- var lastLikeIndex = 0;
- for (var i = 1; i < tokens.length; i++) {
- var lastLikeToken = tokens[lastLikeIndex];
- var currToken = tokens[i];
- if (getTokenRule(lastLikeToken) !== getTokenRule(currToken)) {
- newTokens.push(mergeTokens(tokens, lastLikeIndex, i));
- lastLikeIndex = i;
- }
- }
- newTokens.push(mergeTokens(tokens, lastLikeIndex, tokens.length));
- return newTokens;
-};
-
-/**
- * Returns if given row is a whitespace row.
- * @param {number} row Row.
- * @return {boolean} True if row is whitespaces.
- */
-var isRowWhiteSpace = function(row) {
- var line = cvoxAce.editor.getSession().getLine(row);
- var whiteSpaceRegexp = /^\s*$/;
- return whiteSpaceRegexp.exec(line) !== null;
-};
-
-/**
- * Speak the line with syntax properties.
- * @param {number} row Row to speak.
- * @param {number} queue Queue mode to speak.
- */
-var speakLine = function(row, queue) {
- var tokens = cvoxAce.editor.getSession().getTokens(row);
- if (tokens.length === 0 || isRowWhiteSpace(row)) {
- cvox.Api.playEarcon('EDITABLE_TEXT');
- return;
- }
- tokens = mergeLikeTokens(tokens);
- var firstToken = tokens[0];
- /* Filter out first token. */
- tokens = tokens.filter(function(token) {
- return token !== firstToken;
- });
- /* Speak first token separately to flush if queue. */
- speakToken_(firstToken, queue);
- /* Speak rest of tokens. */
- tokens.forEach(speakTokenQueue);
-};
-
-/**
- * Speak the token based on the syntax of the token, flushing.
- * @param {!cvoxAce.Token} token Token to speak.
- * @param {number} queue Queue mode.
- */
-var speakTokenFlush = function(token) {
- speakToken_(token, 0);
-};
-
-/**
- * Speak the token based on the syntax of the token, queueing.
- * @param {!cvoxAce.Token} token Token to speak.
- * @param {number} queue Queue mode.
- */
-var speakTokenQueue = function(token) {
- speakToken_(token, 1);
-};
-
-/**
- * @param {!cvoxAce.Token} token Token to speak.
- * Get the token speech property.
- */
-var getTokenRule = function(token) {
- /* Types are period delimited. In this case, we only syntax speak the outer
- * most type of token. */
- if (!token || !token.type) {
- return;
- }
- var split = token.type.split('.');
- if (split.length === 0) {
- return;
- }
- var type = split[0];
- var rule = rules[type];
- if (!rule) {
- return DEFAULT_RULE;
- }
- return rule;
-};
-
-/**
- * Speak the token based on the syntax of the token.
- * @private
- * @param {!cvoxAce.Token} token Token to speak.
- * @param {number} queue Queue mode.
- */
-var speakToken_ = function(token, queue) {
- var rule = getTokenRule(token);
- var value = expand(token.value, REPLACE_LIST);
- if (rule.replace) {
- value = expand(value, rule.replace);
- }
- cvox.Api.speak(value, queue, rule.prop);
-};
-
-/**
- * Speaks the character under the cursor. This is queued.
- * @param {!cvoxAce.Cursor} cursor Current cursor position.
- * @return {string} Character.
- */
-var speakChar = function(cursor) {
- var line = getCurrentLine(cursor);
- cvox.Api.speak(line[cursor.column], 1);
-};
-
-/**
- * Speaks the jump from lastCursor to currCursor. This function assumes the
- * jump takes place on the current line.
- * @param {!cvoxAce.Cursor} lastCursor Previous cursor position.
- * @param {!cvoxAce.Cursor} currCursor Current cursor position.
- */
-var speakDisplacement = function(lastCursor, currCursor) {
- var line = getCurrentLine(currCursor);
-
- /* Get the text that we jumped past. */
- var displace = line.substring(lastCursor.column, currCursor.column);
-
- /* Speak out loud spaces. */
- displace = displace.replace(/ /g, ' space ');
- cvox.Api.speak(displace);
-};
-
-/**
- * Speaks the word if the cursor jumped to a new word or to the beginning
- * of the line. Otherwise speak the charactor.
- * @param {!cvoxAce.Cursor} lastCursor Previous cursor position.
- * @param {!cvoxAce.Cursor} currCursor Current cursor position.
- */
-var speakCharOrWordOrLine = function(lastCursor, currCursor) {
- /* Say word only if jump. */
- if (Math.abs(lastCursor.column - currCursor.column) !== 1) {
- var currLineLength = getCurrentLine(currCursor).length;
- /* Speak line if jumping to beginning or end of line. */
- if (currCursor.column === 0 || currCursor.column === currLineLength) {
- speakLine(currCursor.row, 0);
- return;
- }
- if (isWord(currCursor)) {
- cvox.Api.stop();
- speakTokenQueue(getCurrentToken(currCursor));
- return;
- }
- }
- speakChar(currCursor);
-};
-
-/**
- * Event handler for column changes. If shouldSpeakDisplacement is on, then
- * we just speak displacements in row changes. Otherwise, we either speak
- * the character for single character movements, the word when jumping to the
- * next word, or the entire line if jumping to beginning or end of the line.
- * @param {!cvoxAce.Cursor} lastCursor Previous cursor position.
- * @param {!cvoxAce.Cursor} currCursor Current cursor position.
- */
-var onColumnChange = function(lastCursor, currCursor) {
- if (!cvoxAce.editor.selection.isEmpty()) {
- speakDisplacement(lastCursor, currCursor);
- cvox.Api.speak('selected', 1);
- }
- else if (shouldSpeakDisplacement) {
- speakDisplacement(lastCursor, currCursor);
- } else {
- speakCharOrWordOrLine(lastCursor, currCursor);
- }
-};
-
-/**
- * Event handler for cursor changes. Classify cursor changes as either row or
- * column changes, then delegate accordingly.
- * @param {!Event} evt The event.
- */
-var onCursorChange = function(evt) {
- /* Do not speak if cursor change was a result of text insertion. We want to
- * speak the text that was inserted and not where the cursor lands. */
- if (changed) {
- changed = false;
- return;
- }
- var currCursor = cvoxAce.editor.selection.getCursor();
- if (currCursor.row !== lastCursor.row) {
- onRowChange(currCursor);
- } else {
- onColumnChange(lastCursor, currCursor);
- }
- lastCursor = currCursor;
-};
-
-/**
- * Event handler for selection changes.
- * @param {!Event} evt The event.
- */
-var onSelectionChange = function(evt) {
- /* Assumes that when selection changes to empty, the user has unselected. */
- if (cvoxAce.editor.selection.isEmpty()) {
- cvox.Api.speak('unselected');
- }
-};
-
-/**
- * Event handler for source changes. We want auditory feedback for inserting
- * and deleting text.
- * @param {!Event} evt The event.
- */
-var onChange = function(evt) {
- var data = evt.data;
- switch (data.action) {
- case 'removeText':
- cvox.Api.speak(data.text, 0, DELETED_PROP);
- /* Let the future cursor change event know it's from text change. */
- changed = true;
- break;
- case 'insertText':
- cvox.Api.speak(data.text, 0);
- /* Let the future cursor change event know it's from text change. */
- changed = true;
- break;
- }
-};
-
-/**
- * Returns whether or not the annotation is new.
- * @param {!cvoxAce.Annotation} annot Annotation in question.
- * @return {boolean} Whether annot is new.
- */
-var isNewAnnotation = function(annot) {
- var row = annot.row;
- var col = annot.column;
- return !annotTable[row] || !annotTable[row][col];
-};
-
-/**
- * Populates the annotation table.
- * @param {!Array.<cvoxAce.Annotation>} annotations Array of annotations.
- */
-var populateAnnotations = function(annotations) {
- annotTable = {};
- for (var i = 0; i < annotations.length; i++) {
- var annotation = annotations[i];
- var row = annotation.row;
- var col = annotation.column;
- if (!annotTable[row]) {
- annotTable[row] = {};
- }
- annotTable[row][col] = annotation;
- }
-};
-
-/**
- * Event handler for annotation changes. We want to notify the user when an
- * a new annotation appears.
- * @param {!Event} evt Event.
- */
-var onAnnotationChange = function(evt) {
- var annotations = cvoxAce.editor.getSession().getAnnotations();
- var newAnnotations = annotations.filter(isNewAnnotation);
- if (newAnnotations.length > 0) {
- cvox.Api.playEarcon(ERROR_EARCON);
- }
- populateAnnotations(annotations);
-};
-
-/**
- * Speak annotation.
- * @param {!cvoxAce.Annotation} annot Annotation to speak.
- */
-var speakAnnot = function(annot) {
- var annotText = annot.type + ' ' + annot.text + ' on ' +
- rowColToString(annot.row, annot.column);
- annotText = annotText.replace(';', 'semicolon');
- cvox.Api.speak(annotText, 1);
-};
-
-/**
- * Speak annotations in a row.
- * @param {number} row Row of annotations to speak.
- */
-var speakAnnotsByRow = function(row) {
- var annots = annotTable[row];
- for (var col in annots) {
- speakAnnot(annots[col]);
- }
-};
-
-/**
- * Get a string representation of a row and column.
- * @param {boolean} row Zero indexed row.
- * @param {boolean} col Zero indexed column.
- * @return {string} Row and column to be spoken.
- */
-var rowColToString = function(row, col) {
- return 'row ' + (row + 1) + ' column ' + (col + 1);
-};
-
-/**
- * Speaks the row and column.
- */
-var speakCurrRowAndCol = function() {
- cvox.Api.speak(rowColToString(lastCursor.row, lastCursor.column));
-};
-
-/**
- * Speaks all annotations.
- */
-var speakAllAnnots = function() {
- for (var row in annotTable) {
- speakAnnotsByRow(row);
- }
-};
-
-/**
- * Speak the vim mode. If no vim mode, this function does nothing.
- */
-var speakMode = function() {
- if (!isVimMode()) {
- return;
- }
- switch (cvoxAce.editor.keyBinding.$data.state) {
- case INSERT_MODE_STATE:
- cvox.Api.speak('Insert mode');
- break;
- case COMMAND_MODE_STATE:
- cvox.Api.speak('Command mode');
- break;
- }
-};
-
-/**
- * Toggle speak location.
- */
-var toggleSpeakRowLocation = function() {
- shouldSpeakRowLocation = !shouldSpeakRowLocation;
- /* Auditory feedback of the change. */
- if (shouldSpeakRowLocation) {
- cvox.Api.speak('Speak location on row change enabled.');
- } else {
- cvox.Api.speak('Speak location on row change disabled.');
- }
-};
-
-/**
- * Toggle speak displacement.
- */
-var toggleSpeakDisplacement = function() {
- shouldSpeakDisplacement = !shouldSpeakDisplacement;
- /* Auditory feedback of the change. */
- if (shouldSpeakDisplacement) {
- cvox.Api.speak('Speak displacement on column changes.');
- } else {
- cvox.Api.speak('Speak current character or word on column changes.');
- }
-};
-
-/**
- * Event handler for key down events. Gets the right shortcut from the map,
- * and calls the associated function.
- * @param {!Event} evt Keyboard event.
- */
-var onKeyDown = function(evt) {
- if (evt.ctrlKey && evt.shiftKey) {
- var shortcut = keyCodeToShortcutMap[evt.keyCode];
- if (shortcut) {
- shortcut.func();
- }
- }
-};
-
-/**
- * Event handler for status change events. Auditory feedback of changing
- * between vim states.
- * @param {!Event} evt Change status event.
- * @param {!Object} editor Editor state.
- */
-var onChangeStatus = function(evt, editor) {
- if (!isVimMode()) {
- return;
- }
- var state = editor.keyBinding.$data.state;
- if (state === vimState) {
- /* State hasn't changed, do nothing. */
- return;
- }
- switch (state) {
- case INSERT_MODE_STATE:
- cvox.Api.playEarcon(MODE_SWITCH_EARCON);
- /* When in insert mode, we want to speak out keys as feedback. */
- cvox.Api.setKeyEcho(true);
- break;
- case COMMAND_MODE_STATE:
- cvox.Api.playEarcon(MODE_SWITCH_EARCON);
- /* When in command mode, we want don't speak out keys because those keys
- * are not being inserted in the document. */
- cvox.Api.setKeyEcho(false);
- break;
- }
- vimState = state;
-};
-
-/**
- * Handles context menu events. This is a ChromeVox feature where hitting
- * the shortcut ChromeVox + comma will open up a search bar where you can
- * type in various commands. All keyboard shortcuts are also commands that
- * can be invoked. This handles the event that ChromeVox sends to the page.
- * @param {Event} evt Event received.
- */
-var contextMenuHandler = function(evt) {
- var cmd = evt.detail['customCommand'];
- var shortcut = cmdToShortcutMap[cmd];
- if (shortcut) {
- shortcut.func();
- /* ChromeVox will bring focus to an element near the cursor instead of the
- * text input. */
- cvoxAce.editor.focus();
- }
-};
-
-/**
- * Initialize the ChromeVox context menu.
- */
-var initContextMenu = function() {
- var ACTIONS = SHORTCUTS.map(function(shortcut) {
- return {
- desc: shortcut.desc + getKeyShortcutString(shortcut.keyCode),
- cmd: shortcut.cmd
- };
- });
-
- /* Attach ContextMenuActions. */
- var body = document.querySelector('body');
- body.setAttribute('contextMenuActions', JSON.stringify(ACTIONS));
-
- /* Listen for ContextMenu events. */
- body.addEventListener('ATCustomEvent', contextMenuHandler, true);
-};
-
-/**
- * Event handler for find events. When there is a match, we want to speak the
- * line we are now at. Otherwise, we want to notify the user there was no
- * match
- * @param {!Event} evt The event.
- */
-var onFindSearchbox = function(evt) {
- if (evt.match) {
- /* There is still a match! Speak the line. */
- speakLine(lastCursor.row, 0);
- } else {
- /* No match, give auditory feedback! */
- cvox.Api.playEarcon(NO_MATCH_EARCON);
- }
-};
-
-/**
- * Focus to text input.
- */
-var focus = function() {
- cvoxAce.editor.focus();
-};
-
-/**
- * Shortcut definitions.
- */
-var SHORTCUTS = [
- {
- /* 1 key. */
- keyCode: 49,
- func: function() {
- speakAnnotsByRow(lastCursor.row);
- },
- cmd: Command.SPEAK_ANNOT,
- desc: 'Speak annotations on line'
- },
- {
- /* 2 key. */
- keyCode: 50,
- func: speakAllAnnots,
- cmd: Command.SPEAK_ALL_ANNOTS,
- desc: 'Speak all annotations'
- },
- {
- /* 3 key. */
- keyCode: 51,
- func: speakMode,
- cmd: Command.SPEAK_MODE,
- desc: 'Speak Vim mode'
- },
- {
- /* 4 key. */
- keyCode: 52,
- func: toggleSpeakRowLocation,
- cmd: Command.TOGGLE_LOCATION,
- desc: 'Toggle speak row location'
- },
- {
- /* 5 key. */
- keyCode: 53,
- func: speakCurrRowAndCol,
- cmd: Command.SPEAK_ROW_COL,
- desc: 'Speak row and column'
- },
- {
- /* 6 key. */
- keyCode: 54,
- func: toggleSpeakDisplacement,
- cmd: Command.TOGGLE_DISPLACEMENT,
- desc: 'Toggle speak displacement'
- },
- {
- /* 7 key. */
- keyCode: 55,
- func: focus,
- cmd: Command.FOCUS_TEXT,
- desc: 'Focus text'
- }
-];
-
-/**
- * Event handler for focus events.
- */
-var onFocus = function() {
- cvoxAce.editor = editor;
-
- /* Set up listeners. */
- editor.getSession().selection.on('changeCursor', onCursorChange);
- editor.getSession().selection.on('changeSelection', onSelectionChange);
- editor.getSession().on('change', onChange);
- editor.getSession().on('changeAnnotation', onAnnotationChange);
- editor.on('changeStatus', onChangeStatus);
- editor.on('findSearchBox', onFindSearchbox);
- editor.container.addEventListener('keydown', onKeyDown);
-
- lastCursor = editor.selection.getCursor();
-};
-
-/**
- * Initialize the theme.
- * @param {Object} editor Editor to use.
- */
-var init = function(editor) {
- onFocus();
-
- /* Construct maps. */
- SHORTCUTS.forEach(function(shortcut) {
- keyCodeToShortcutMap[shortcut.keyCode] = shortcut;
- cmdToShortcutMap[shortcut.cmd] = shortcut;
- });
-
- editor.on('focus', onFocus);
-
- /* Assume we start in command mode if vim. */
- if (isVimMode()) {
- cvox.Api.setKeyEcho(false);
- }
- initContextMenu();
-};
-
-/**
- * Returns if cvox exists, and the api exists.
- * @return {boolean} Whether not Cvox Api exists.
- */
-function cvoxApiExists() {
- return (typeof(cvox) !== 'undefined') && cvox && cvox.Api;
-}
-
-/**
- * Number of tries for Cvox loading.
- * @type {number}
- */
-var tries = 0;
-
-/**
- * Max number of tries to watch for Cvox loading.
- * @type {number}
- */
-var MAX_TRIES = 15;
-
-/**
- * Check for ChromeVox load.
- * @param {Object} editor Editor to use.
- */
-function watchForCvoxLoad(editor) {
- if (cvoxApiExists()) {
- init(editor);
- } else {
- tries++;
- if (tries >= MAX_TRIES) {
- return;
- }
- window.setTimeout(watchForCvoxLoad, 500, editor);
- }
-}
-
-var Editor = require('../editor').Editor;
-require('../config').defineOptions(Editor.prototype, 'editor', {
- enableChromevoxEnhancements: {
- set: function(val) {
- if (val) {
- watchForCvoxLoad(this);
- }
- },
- value: true // turn it on by default or check for window.cvox
- }
-});
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/elastic_tabstops_lite.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/elastic_tabstops_lite.js b/src/fauxton/assets/js/libs/ace/ext/elastic_tabstops_lite.js
deleted file mode 100644
index 9901c5d..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/elastic_tabstops_lite.js
+++ /dev/null
@@ -1,319 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2012, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var ElasticTabstopsLite = function(editor) {
- this.$editor = editor;
- var self = this;
- var changedRows = [];
- var recordChanges = false;
- this.onAfterExec = function() {
- recordChanges = false;
- self.processRows(changedRows);
- changedRows = [];
- };
- this.onExec = function() {
- recordChanges = true;
- };
- this.onChange = function(e) {
- var range = e.data.range
- if (recordChanges) {
- if (changedRows.indexOf(range.start.row) == -1)
- changedRows.push(range.start.row);
- if (range.end.row != range.start.row)
- changedRows.push(range.end.row);
- }
- };
-};
-
-(function() {
- this.processRows = function(rows) {
- this.$inChange = true;
- var checkedRows = [];
-
- for (var r = 0, rowCount = rows.length; r < rowCount; r++) {
- var row = rows[r];
-
- if (checkedRows.indexOf(row) > -1)
- continue;
-
- var cellWidthObj = this.$findCellWidthsForBlock(row);
- var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);
- var rowIndex = cellWidthObj.firstRow;
-
- for (var w = 0, l = cellWidths.length; w < l; w++) {
- var widths = cellWidths[w];
- checkedRows.push(rowIndex);
- this.$adjustRow(rowIndex, widths);
- rowIndex++;
- }
- }
- this.$inChange = false;
- };
-
- this.$findCellWidthsForBlock = function(row) {
- var cellWidths = [], widths;
-
- // starting row and backward
- var rowIter = row;
- while (rowIter >= 0) {
- widths = this.$cellWidthsForRow(rowIter);
- if (widths.length == 0)
- break;
-
- cellWidths.unshift(widths);
- rowIter--;
- }
- var firstRow = rowIter + 1;
-
- // forward (not including starting row)
- rowIter = row;
- var numRows = this.$editor.session.getLength();
-
- while (rowIter < numRows - 1) {
- rowIter++;
-
- widths = this.$cellWidthsForRow(rowIter);
- if (widths.length == 0)
- break;
-
- cellWidths.push(widths);
- }
-
- return { cellWidths: cellWidths, firstRow: firstRow };
- };
-
- this.$cellWidthsForRow = function(row) {
- var selectionColumns = this.$selectionColumnsForRow(row);
- // todo: support multicursor
-
- var tabs = [-1].concat(this.$tabsForRow(row));
- var widths = tabs.map(function(el) { return 0; } ).slice(1);
- var line = this.$editor.session.getLine(row);
-
- for (var i = 0, len = tabs.length - 1; i < len; i++) {
- var leftEdge = tabs[i]+1;
- var rightEdge = tabs[i+1];
-
- var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge);
- var cell = line.substring(leftEdge, rightEdge);
- widths[i] = Math.max(cell.replace(/\s+$/g,'').length, rightmostSelection - leftEdge);
- }
-
- return widths;
- };
-
- this.$selectionColumnsForRow = function(row) {
- var selections = [], cursor = this.$editor.getCursorPosition();
- if (this.$editor.session.getSelection().isEmpty()) {
- // todo: support multicursor
- if (row == cursor.row)
- selections.push(cursor.column);
- }
-
- return selections;
- };
-
- this.$setBlockCellWidthsToMax = function(cellWidths) {
- var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth;
- var columnInfo = this.$izip_longest(cellWidths);
-
- for (var c = 0, l = columnInfo.length; c < l; c++) {
- var column = columnInfo[c];
- if (!column.push) {
- console.error(column);
- continue;
- }
- // add an extra None to the end so that the end of the column automatically
- // finishes a block
- column.push(NaN);
-
- for (var r = 0, s = column.length; r < s; r++) {
- var width = column[r];
- if (startingNewBlock) {
- blockStartRow = r;
- maxWidth = 0;
- startingNewBlock = false;
- }
- if (isNaN(width)) {
- // block ended
- blockEndRow = r;
-
- for (var j = blockStartRow; j < blockEndRow; j++) {
- cellWidths[j][c] = maxWidth;
- }
- startingNewBlock = true;
- }
-
- maxWidth = Math.max(maxWidth, width);
- }
- }
-
- return cellWidths;
- };
-
- this.$rightmostSelectionInCell = function(selectionColumns, cellRightEdge) {
- var rightmost = 0;
-
- if (selectionColumns.length) {
- var lengths = [];
- for (var s = 0, length = selectionColumns.length; s < length; s++) {
- if (selectionColumns[s] <= cellRightEdge)
- lengths.push(s);
- else
- lengths.push(0);
- }
- rightmost = Math.max.apply(Math, lengths);
- }
-
- return rightmost;
- };
-
- this.$tabsForRow = function(row) {
- var rowTabs = [], line = this.$editor.session.getLine(row),
- re = /\t/g, match;
-
- while ((match = re.exec(line)) != null) {
- rowTabs.push(match.index);
- }
-
- return rowTabs;
- };
-
- this.$adjustRow = function(row, widths) {
- var rowTabs = this.$tabsForRow(row);
-
- if (rowTabs.length == 0)
- return;
-
- var bias = 0, location = -1;
-
- // this always only contains two elements, so we're safe in the loop below
- var expandedSet = this.$izip(widths, rowTabs);
-
- for (var i = 0, l = expandedSet.length; i < l; i++) {
- var w = expandedSet[i][0], it = expandedSet[i][1];
- location += 1 + w;
- it += bias;
- var difference = location - it;
-
- if (difference == 0)
- continue;
-
- var partialLine = this.$editor.session.getLine(row).substr(0, it );
- var strippedPartialLine = partialLine.replace(/\s*$/g, "");
- var ispaces = partialLine.length - strippedPartialLine.length;
-
- if (difference > 0) {
- // put the spaces after the tab and then delete the tab, so any insertion
- // points behave as expected
- this.$editor.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
- this.$editor.session.getDocument().removeInLine(row, it, it + 1);
-
- bias += difference;
- }
-
- if (difference < 0 && ispaces >= -difference) {
- this.$editor.session.getDocument().removeInLine(row, it + difference, it);
- bias += difference;
- }
- }
- };
-
- // the is a (naive) Python port--but works for these purposes
- this.$izip_longest = function(iterables) {
- if (!iterables[0])
- return [];
- var longest = iterables[0].length;
- var iterablesLength = iterables.length;
-
- for (var i = 1; i < iterablesLength; i++) {
- var iLength = iterables[i].length;
- if (iLength > longest)
- longest = iLength;
- }
-
- var expandedSet = [];
-
- for (var l = 0; l < longest; l++) {
- var set = [];
- for (var i = 0; i < iterablesLength; i++) {
- if (iterables[i][l] === "")
- set.push(NaN);
- else
- set.push(iterables[i][l]);
- }
-
- expandedSet.push(set);
- }
-
-
- return expandedSet;
- };
-
- // an even more (naive) Python port
- this.$izip = function(widths, tabs) {
- // grab the shorter size
- var size = widths.length >= tabs.length ? tabs.length : widths.length;
-
- var expandedSet = [];
- for (var i = 0; i < size; i++) {
- var set = [ widths[i], tabs[i] ];
- expandedSet.push(set);
- }
- return expandedSet;
- };
-
-}).call(ElasticTabstopsLite.prototype);
-
-exports.ElasticTabstopsLite = ElasticTabstopsLite;
-
-var Editor = require("../editor").Editor;
-require("../config").defineOptions(Editor.prototype, "editor", {
- useElasticTabstops: {
- set: function(val) {
- if (val) {
- if (!this.elasticTabstops)
- this.elasticTabstops = new ElasticTabstopsLite(this);
- this.commands.on("afterExec", this.elasticTabstops.onAfterExec);
- this.commands.on("exec", this.elasticTabstops.onExec);
- this.on("change", this.elasticTabstops.onChange);
- } else if (this.elasticTabstops) {
- this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec);
- this.commands.removeListener("exec", this.elasticTabstops.onExec);
- this.removeListener("change", this.elasticTabstops.onChange);
- }
- }
- }
-});
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/emmet.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/emmet.js b/src/fauxton/assets/js/libs/ace/ext/emmet.js
deleted file mode 100644
index 6647da4..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/emmet.js
+++ /dev/null
@@ -1,415 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
-var Editor = require("ace/editor").Editor;
-var snippetManager = require("ace/snippets").snippetManager;
-var Range = require("ace/range").Range;
-var emmet;
-
-Editor.prototype.indexToPosition = function(index) {
- return this.session.doc.indexToPosition(index);
-};
-
-Editor.prototype.positionToIndex = function(pos) {
- return this.session.doc.positionToIndex(pos);
-};
-
-/**
- * Implementation of {@link IEmmetEditor} interface for Ace
- */
-function AceEmmetEditor() {}
-
-AceEmmetEditor.prototype = {
- setupContext: function(editor) {
- this.ace = editor;
- this.indentation = editor.session.getTabString();
- if (!emmet)
- emmet = window.emmet;
- emmet.require("resources").setVariable("indentation", this.indentation);
- this.$syntax = null;
- this.$syntax = this.getSyntax();
- },
- /**
- * Returns character indexes of selected text: object with <code>start</code>
- * and <code>end</code> properties. If there's no selection, should return
- * object with <code>start</code> and <code>end</code> properties referring
- * to current caret position
- * @return {Object}
- * @example
- * var selection = editor.getSelectionRange();
- * alert(selection.start + ', ' + selection.end);
- */
- getSelectionRange: function() {
- // TODO should start be caret position instead?
- var range = this.ace.getSelectionRange();
- return {
- start: this.ace.positionToIndex(range.start),
- end: this.ace.positionToIndex(range.end)
- };
- },
-
- /**
- * Creates selection from <code>start</code> to <code>end</code> character
- * indexes. If <code>end</code> is ommited, this method should place caret
- * and <code>start</code> index
- * @param {Number} start
- * @param {Number} [end]
- * @example
- * editor.createSelection(10, 40);
- *
- * //move caret to 15th character
- * editor.createSelection(15);
- */
- createSelection: function(start, end) {
- this.ace.selection.setRange({
- start: this.ace.indexToPosition(start),
- end: this.ace.indexToPosition(end)
- });
- },
-
- /**
- * Returns current line's start and end indexes as object with <code>start</code>
- * and <code>end</code> properties
- * @return {Object}
- * @example
- * var range = editor.getCurrentLineRange();
- * alert(range.start + ', ' + range.end);
- */
- getCurrentLineRange: function() {
- var row = this.ace.getCursorPosition().row;
- var lineLength = this.ace.session.getLine(row).length;
- var index = this.ace.positionToIndex({row: row, column: 0});
- return {
- start: index,
- end: index + lineLength
- };
- },
-
- /**
- * Returns current caret position
- * @return {Number|null}
- */
- getCaretPos: function(){
- var pos = this.ace.getCursorPosition();
- return this.ace.positionToIndex(pos);
- },
-
- /**
- * Set new caret position
- * @param {Number} index Caret position
- */
- setCaretPos: function(index){
- var pos = this.ace.indexToPosition(index);
- this.ace.clearSelection();
- this.ace.selection.moveCursorToPosition(pos);
- },
-
- /**
- * Returns content of current line
- * @return {String}
- */
- getCurrentLine: function() {
- var row = this.ace.getCursorPosition().row;
- return this.ace.session.getLine(row);
- },
-
- /**
- * Replace editor's content or it's part (from <code>start</code> to
- * <code>end</code> index). If <code>value</code> contains
- * <code>caret_placeholder</code>, the editor will put caret into
- * this position. If you skip <code>start</code> and <code>end</code>
- * arguments, the whole target's content will be replaced with
- * <code>value</code>.
- *
- * If you pass <code>start</code> argument only,
- * the <code>value</code> will be placed at <code>start</code> string
- * index of current content.
- *
- * If you pass <code>start</code> and <code>end</code> arguments,
- * the corresponding substring of current target's content will be
- * replaced with <code>value</code>.
- * @param {String} value Content you want to paste
- * @param {Number} [start] Start index of editor's content
- * @param {Number} [end] End index of editor's content
- * @param {Boolean} [noIndent] Do not auto indent <code>value</code>
- */
- replaceContent: function(value, start, end, noIndent) {
- if (end == null)
- end = start == null ? this.getContent().length : start;
- if (start == null)
- start = 0;
-
- var editor = this.ace;
- var range = Range.fromPoints(editor.indexToPosition(start), editor.indexToPosition(end));
- editor.session.remove(range);
-
- range.end = range.start;
- //editor.selection.setRange(range);
-
- value = this.$updateTabstops(value);
- snippetManager.insertSnippet(editor, value)
- },
-
- /**
- * Returns editor's content
- * @return {String}
- */
- getContent: function(){
- return this.ace.getValue();
- },
-
- /**
- * Returns current editor's syntax mode
- * @return {String}
- */
- getSyntax: function() {
- if (this.$syntax)
- return this.$syntax;
- var syntax = this.ace.session.$modeId.split("/").pop();
- if (syntax == "html" || syntax == "php") {
- var cursor = this.ace.getCursorPosition();
- var state = this.ace.session.getState(cursor.row);
- if (typeof state != "string")
- state = state[0];
- if (state) {
- state = state.split("-");
- if (state.length > 1)
- syntax = state[0];
- else if (syntax == "php")
- syntax = "html";
- }
- }
- return syntax;
- },
-
- /**
- * Returns current output profile name (@see emmet#setupProfile)
- * @return {String}
- */
- getProfileName: function() {
- switch(this.getSyntax()) {
- case "css": return "css";
- case "xml":
- case "xsl":
- return "xml";
- case "html":
- var profile = emmet.require("resources").getVariable("profile");
- // no forced profile, guess from content html or xhtml?
- if (!profile)
- profile = this.ace.session.getLines(0,2).join("").search(/<!DOCTYPE[^>]+XHTML/i) != -1 ? "xhtml": "html";
- return profile;
- }
- return "xhtml";
- },
-
- /**
- * Ask user to enter something
- * @param {String} title Dialog title
- * @return {String} Entered data
- * @since 0.65
- */
- prompt: function(title) {
- return prompt(title);
- },
-
- /**
- * Returns current selection
- * @return {String}
- * @since 0.65
- */
- getSelection: function() {
- return this.ace.session.getTextRange();
- },
-
- /**
- * Returns current editor's file path
- * @return {String}
- * @since 0.65
- */
- getFilePath: function() {
- return "";
- },
-
- // update tabstops: make sure all caret placeholders are unique
- // by default, abbreviation parser generates all unlinked (un-mirrored)
- // tabstops as ${0}, so we have upgrade all caret tabstops with unique
- // positions but make sure that all other tabstops are not linked accidentally
- // based on https://github.com/sergeche/emmet-sublime/blob/master/editor.js#L119-L171
- $updateTabstops: function(value) {
- var base = 1000;
- var zeroBase = 0;
- var lastZero = null;
- var range = emmet.require('range');
- var ts = emmet.require('tabStops');
- var settings = emmet.require('resources').getVocabulary("user");
- var tabstopOptions = {
- tabstop: function(data) {
- var group = parseInt(data.group, 10);
- var isZero = group === 0;
- if (isZero)
- group = ++zeroBase;
- else
- group += base;
-
- var placeholder = data.placeholder;
- if (placeholder) {
- // recursively update nested tabstops
- placeholder = ts.processText(placeholder, tabstopOptions);
- }
-
- var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}';
-
- if (isZero) {
- lastZero = range.create(data.start, result);
- }
-
- return result
- },
- escape: function(ch) {
- if (ch == '$') return '\\$';
- if (ch == '\\') return '\\\\';
- return ch;
- }
- };
-
- value = ts.processText(value, tabstopOptions);
-
- if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) {
- value += '${0}';
- } else if (lastZero) {
- value = emmet.require('utils').replaceSubstring(value, '${0}', lastZero);
- }
-
- return value;
- }
-};
-
-
-var keymap = {
- expand_abbreviation: {"mac": "ctrl+alt+e", "win": "alt+e"},
- match_pair_outward: {"mac": "ctrl+d", "win": "ctrl+,"},
- match_pair_inward: {"mac": "ctrl+j", "win": "ctrl+shift+0"},
- matching_pair: {"mac": "ctrl+alt+j", "win": "alt+j"},
- next_edit_point: "alt+right",
- prev_edit_point: "alt+left",
- toggle_comment: {"mac": "command+/", "win": "ctrl+/"},
- split_join_tag: {"mac": "shift+command+'", "win": "shift+ctrl+`"},
- remove_tag: {"mac": "command+'", "win": "shift+ctrl+;"},
- evaluate_math_expression: {"mac": "shift+command+y", "win": "shift+ctrl+y"},
- increment_number_by_1: "ctrl+up",
- decrement_number_by_1: "ctrl+down",
- increment_number_by_01: "alt+up",
- decrement_number_by_01: "alt+down",
- increment_number_by_10: {"mac": "alt+command+up", "win": "shift+alt+up"},
- decrement_number_by_10: {"mac": "alt+command+down", "win": "shift+alt+down"},
- select_next_item: {"mac": "shift+command+.", "win": "shift+ctrl+."},
- select_previous_item: {"mac": "shift+command+,", "win": "shift+ctrl+,"},
- reflect_css_value: {"mac": "shift+command+r", "win": "shift+ctrl+r"},
-
- encode_decode_data_url: {"mac": "shift+ctrl+d", "win": "ctrl+'"},
- // update_image_size: {"mac": "shift+ctrl+i", "win": "ctrl+u"},
- // expand_as_you_type: "ctrl+alt+enter",
- // wrap_as_you_type: {"mac": "shift+ctrl+g", "win": "shift+ctrl+g"},
- expand_abbreviation_with_tab: "Tab",
- wrap_with_abbreviation: {"mac": "shift+ctrl+a", "win": "shift+ctrl+a"}
-};
-
-var editorProxy = new AceEmmetEditor();
-exports.commands = new HashHandler();
-exports.runEmmetCommand = function(editor) {
- editorProxy.setupContext(editor);
- if (editorProxy.getSyntax() == "php")
- return false;
- var actions = emmet.require("actions");
-
- if (this.action == "expand_abbreviation_with_tab") {
- if (!editor.selection.isEmpty())
- return false;
- }
-
- if (this.action == "wrap_with_abbreviation") {
- // without setTimeout prompt doesn't work on firefox
- return setTimeout(function() {
- actions.run("wrap_with_abbreviation", editorProxy);
- }, 0);
- }
-
- try {
- var result = actions.run(this.action, editorProxy);
- } catch(e) {
- editor._signal("changeStatus", typeof e == "string" ? e : e.message);
- console.log(e);
- }
- return result;
-};
-
-for (var command in keymap) {
- exports.commands.addCommand({
- name: "emmet:" + command,
- action: command,
- bindKey: keymap[command],
- exec: exports.runEmmetCommand,
- multiSelectAction: "forEach"
- });
-}
-
-var onChangeMode = function(e, target) {
- var editor = target;
- if (!editor)
- return;
- var modeId = editor.session.$modeId;
- var enabled = modeId && /css|less|scss|sass|stylus|html|php/.test(modeId);
- if (e.enableEmmet === false)
- enabled = false;
- if (enabled)
- editor.keyBinding.addKeyboardHandler(exports.commands);
- else
- editor.keyBinding.removeKeyboardHandler(exports.commands);
-};
-
-
-exports.AceEmmetEditor = AceEmmetEditor;
-require("ace/config").defineOptions(Editor.prototype, "editor", {
- enableEmmet: {
- set: function(val) {
- this[val ? "on" : "removeListener"]("changeMode", onChangeMode);
- onChangeMode({enableEmmet: !!val}, this);
- },
- value: true
- }
-});
-
-
-exports.setCore = function(e) {emmet = e;};
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/keybinding_menu.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/keybinding_menu.js b/src/fauxton/assets/js/libs/ace/ext/keybinding_menu.js
deleted file mode 100644
index bf8189a..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/keybinding_menu.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
- * All rights reserved.
- *
- * Contributed to Ajax.org under the BSD license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
-/*global define, require */
-
-/**
- * Show Keyboard Shortcuts
- * @fileOverview Show Keyboard Shortcuts <br />
- * Generates a menu which displays the keyboard shortcuts.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
-
-define(function(require, exports, module) {
- "use strict";
- var Editor = require("ace/editor").Editor;
- /**
- * Generates a menu which displays the keyboard shortcuts.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {ace.Editor} editor An instance of the ace editor.
- */
- function showKeyboardShortcuts (editor) {
- // make sure the menu isn't open already.
- if(!document.getElementById('kbshortcutmenu')) {
- var overlayPage = require('./menu_tools/overlay_page').overlayPage;
- var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
- var kb = getEditorKeybordShortcuts(editor);
- var el = document.createElement('div');
- var commands = kb.reduce(function(previous, current) {
- return previous + '<div class="ace_optionsMenuEntry"><span class="ace_optionsMenuCommand">'
- + current.command + '</span> : '
- + '<span class="ace_optionsMenuKey">' + current.key + '</span></div>';
- }, '');
-
- el.id = 'kbshortcutmenu';
- el.innerHTML = '<h1>Keyboard Shortcuts</h1>' + commands + '</div>';
- overlayPage(editor, el, '0', '0', '0', null);
- }
- };
- module.exports.init = function(editor) {
- Editor.prototype.showKeyboardShortcuts = function() {
- showKeyboardShortcuts(this);
- };
- editor.commands.addCommands([{
- name: "showKeyboardShortcuts",
- bindKey: {win: "Ctrl-Alt-h", mac: "Command-Alt-h"},
- exec: function(editor, line) {
- editor.showKeyboardShortcuts();
- }
- }]);
- };
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/language_tools.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/language_tools.js b/src/fauxton/assets/js/libs/ace/ext/language_tools.js
deleted file mode 100644
index e5cd8bb..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/language_tools.js
+++ /dev/null
@@ -1,129 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2012, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define(function(require, exports, module) {
-"use strict";
-
-var snippetManager = require("../snippets").snippetManager;
-var Autocomplete = require("../autocomplete").Autocomplete;
-var config = require("../config");
-
-var textCompleter = require("../autocomplete/text_completer");
-var keyWordCompleter = {
- getCompletions: function(editor, session, pos, prefix, callback) {
- var state = editor.session.getState(pos.row);
- var completions = session.$mode.getCompletions(state, session, pos, prefix);
- callback(null, completions);
- }
-};
-
-var snippetCompleter = {
- getCompletions: function(editor, session, pos, prefix, callback) {
- var scope = snippetManager.$getScope(editor);
- var snippetMap = snippetManager.snippetMap;
- var completions = [];
- [scope, "_"].forEach(function(scope) {
- var snippets = snippetMap[scope] || [];
- for (var i = snippets.length; i--;) {
- var s = snippets[i];
- var caption = s.name || s.tabTrigger;
- if (!caption)
- continue;
- completions.push({
- caption: caption,
- snippet: s.content,
- meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet"
- });
- }
- }, this);
- callback(null, completions);
- }
-};
-
-var completers = [snippetCompleter, textCompleter, keyWordCompleter];
-exports.addCompleter = function(completer) {
- completers.push(completer);
-};
-
-var expandSnippet = {
- name: "expandSnippet",
- exec: function(editor) {
- var success = snippetManager.expandWithTab(editor);
- if (!success)
- editor.execCommand("indent");
- },
- bindKey: "tab"
-}
-
-var onChangeMode = function(e, editor) {
- var mode = editor.session.$mode;
- var id = mode.$id
- if (!snippetManager.files) snippetManager.files = {};
- if (id && !snippetManager.files[id]) {
- var snippetFilePath = id.replace("mode", "snippets");
- config.loadModule(snippetFilePath, function(m) {
- if (m) {
- snippetManager.files[id] = m;
- m.snippets = snippetManager.parseSnippetFile(m.snippetText);
- snippetManager.register(m.snippets, m.scope);
- }
- });
- }
-};
-
-var Editor = require("../editor").Editor;
-require("../config").defineOptions(Editor.prototype, "editor", {
- enableBasicAutocompletion: {
- set: function(val) {
- if (val) {
- this.completers = completers
- this.commands.addCommand(Autocomplete.startCommand);
- } else {
- this.commands.removeCommand(Autocomplete.startCommand);
- }
- },
- value: false
- },
- enableSnippets: {
- set: function(val) {
- if (val) {
- this.commands.addCommand(expandSnippet);
- this.on("changeMode", onChangeMode);
- onChangeMode(null, this)
- } else {
- this.commands.removeCommand(expandSnippet);
- this.off("changeMode", onChangeMode);
- }
- },
- value: false
- }
-});
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/menu_tools/add_editor_menu_options.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/menu_tools/add_editor_menu_options.js b/src/fauxton/assets/js/libs/ace/ext/menu_tools/add_editor_menu_options.js
deleted file mode 100644
index fd56859..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/menu_tools/add_editor_menu_options.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
- * All rights reserved.
- *
- * Contributed to Ajax.org under the BSD license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
-/*global define, require */
-
-/**
- * Add Editor Menu Options
- * @fileOverview Add Editor Menu Options <br />
- * The menu options property needs to be added to the editor
- * so that the settings menu can know about options for
- * selection elements and track which option is selected.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
-
-define(function(require, exports, module) {
-'use strict';
-
-/**
- * The menu options property needs to be added to the editor
- * so that the settings menu can know about options for
- * selection elements and track which option is selected.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {ace.Editor} editor An instance of the ace editor.
- */
-module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
- var modelist = require('../modelist');
- var themelist = require('../themelist');
- editor.menuOptions = {
- "setNewLineMode" : [{
- "textContent" : "unix",
- "value" : "unix"
- }, {
- "textContent" : "windows",
- "value" : "windows"
- }, {
- "textContent" : "auto",
- "value" : "auto"
- }],
- "setTheme" : [],
- "setMode" : [],
- "setKeyboardHandler": [{
- "textContent" : "ace",
- "value" : ""
- }, {
- "textContent" : "vim",
- "value" : "ace/keyboard/vim"
- }, {
- "textContent" : "emacs",
- "value" : "ace/keyboard/emacs"
- }]
- };
-
- editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
- return {
- 'textContent' : theme.desc,
- 'value' : theme.theme
- };
- });
-
- editor.menuOptions.setMode = modelist.modes.map(function(mode) {
- return {
- 'textContent' : mode.name,
- 'value' : mode.mode
- };
- });
-};
-
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/menu_tools/element_generator.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/menu_tools/element_generator.js b/src/fauxton/assets/js/libs/ace/ext/menu_tools/element_generator.js
deleted file mode 100644
index ec6ba93..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/menu_tools/element_generator.js
+++ /dev/null
@@ -1,148 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
- * All rights reserved.
- *
- * Contributed to Ajax.org under the BSD license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
-/*global define, require */
-
-/**
- * Element Generator
- * @fileOverview Element Generator <br />
- * Contains methods for generating elements.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
-
-define(function(require, exports, module) {
-'use strict';
-/**
- * Creates a DOM option element
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {object} obj An object containing properties to add to the dom
- * element. If one of those properties is named `selected` then it will be
- * added as an attribute on the element instead.
- */
-module.exports.createOption = function createOption (obj) {
- var attribute;
- var el = document.createElement('option');
- for(attribute in obj) {
- if(obj.hasOwnProperty(attribute)) {
- if(attribute === 'selected') {
- el.setAttribute(attribute, obj[attribute]);
- } else {
- el[attribute] = obj[attribute];
- }
- }
- }
- return el;
-};
-/**
- * Creates a DOM checkbox element.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {string} id The id of the element.
- * @param {boolean} checked Whether or not the element is checked.
- * @param {string} clss The class of the element.
- * @returns {DOMElement} Returns a checkbox element reference.
- */
-module.exports.createCheckbox = function createCheckbox (id, checked, clss) {
- var el = document.createElement('input');
- el.setAttribute('type', 'checkbox');
- el.setAttribute('id', id);
- el.setAttribute('name', id);
- el.setAttribute('value', checked);
- el.setAttribute('class', clss);
- if(checked) {
- el.setAttribute('checked', 'checked');
- }
- return el;
-};
-/**
- * Creates a DOM text input element.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {string} id The id of the element.
- * @param {string} value The default value of the input element.
- * @param {string} clss The class of the element.
- * @returns {DOMElement} Returns an input element reference.
- */
-module.exports.createInput = function createInput (id, value, clss) {
- var el = document.createElement('input');
- el.setAttribute('type', 'text');
- el.setAttribute('id', id);
- el.setAttribute('name', id);
- el.setAttribute('value', value);
- el.setAttribute('class', clss);
- return el;
-};
-/**
- * Creates a DOM label element.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {string} text The label text.
- * @param {string} labelFor The id of the element being labeled.
- * @returns {DOMElement} Returns a label element reference.
- */
-module.exports.createLabel = function createLabel (text, labelFor) {
- var el = document.createElement('label');
- el.setAttribute('for', labelFor);
- el.textContent = text;
- return el;
-};
-/**
- * Creates a DOM selection element.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {string} id The id of the element.
- * @param {string} values An array of objects suitable for `createOption`
- * @param {string} clss The class of the element.
- * @returns {DOMElement} Returns a selection element reference.
- * @see ace/ext/element_generator.createOption
- */
-module.exports.createSelection = function createSelection (id, values, clss) {
- var el = document.createElement('select');
- el.setAttribute('id', id);
- el.setAttribute('name', id);
- el.setAttribute('class', clss);
- values.forEach(function(item) {
- el.appendChild(module.exports.createOption(item));
- });
- return el;
-};
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5b8fb9c3/src/fauxton/assets/js/libs/ace/ext/menu_tools/generate_settings_menu.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/ace/ext/menu_tools/generate_settings_menu.js b/src/fauxton/assets/js/libs/ace/ext/menu_tools/generate_settings_menu.js
deleted file mode 100644
index 16d3a76..0000000
--- a/src/fauxton/assets/js/libs/ace/ext/menu_tools/generate_settings_menu.js
+++ /dev/null
@@ -1,258 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2013 Matthew Christopher Kastor-Inare III, Atropa Inc. Intl
- * All rights reserved.
- *
- * Contributed to Ajax.org under the BSD license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
-/*global define*/
-
-/**
- * Generates the settings menu
- * @fileOverview Generates the settings menu.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
-
-define(function(require, exports, module) {
-'use strict';
-var egen = require('./element_generator');
-var addEditorMenuOptions = require('./add_editor_menu_options').addEditorMenuOptions;
-var getSetFunctions = require('./get_set_functions').getSetFunctions;
-
-/**
- * Generates an interactive menu with settings useful to end users.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {ace.Editor} editor An instance of the ace editor.
- */
-module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
- /**
- * container for dom elements that will go in the menu.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
- var elements = [];
- /**
- * Sorts the menu entries (elements var) so they'll appear in alphabetical order
- * the sort is performed based on the value of the contains property
- * of each element. Since this is an `array.sort` the array is sorted
- * in place.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
- function cleanupElementsList() {
- elements.sort(function(a, b) {
- var x = a.getAttribute('contains');
- var y = b.getAttribute('contains');
- return x.localeCompare(y);
- });
- }
- /**
- * Wraps all dom elements contained in the elements var with a single
- * div.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- */
- function wrapElements() {
- var topmenu = document.createElement('div');
- topmenu.setAttribute('id', 'ace_settingsmenu');
- elements.forEach(function(element) {
- topmenu.appendChild(element);
- });
- return topmenu;
- }
- /**
- * Creates a new menu entry.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {object} obj This is a reference to the object containing the
- * set function. It is used to set up event listeners for when the
- * menu options change.
- * @param {string} clss Maps to the class of the dom element. This is
- * the name of the object containing the set function e.g. `editor`,
- * `session`, `renderer`.
- * @param {string} item This is the set function name. It maps to the
- * id of the dom element (check, select, input) and to the "contains"
- * attribute of the div holding both the element and its label.
- * @param {mixed} val This is the value of the setting. It is mapped to
- * the dom element's value, checked, or selected option accordingly.
- */
- function createNewEntry(obj, clss, item, val) {
- var el;
- var div = document.createElement('div');
- div.setAttribute('contains', item);
- div.setAttribute('class', 'ace_optionsMenuEntry');
- div.setAttribute('style', 'clear: both;');
-
- div.appendChild(egen.createLabel(
- item.replace(/^set/, '').replace(/([A-Z])/g, ' $1').trim(),
- item
- ));
-
- if (Array.isArray(val)) {
- el = egen.createSelection(item, val, clss);
- el.addEventListener('change', function(e) {
- try{
- editor.menuOptions[e.target.id].forEach(function(x) {
- if(x.textContent !== e.target.textContent) {
- delete x.selected;
- }
- });
- obj[e.target.id](e.target.value);
- } catch (err) {
- throw new Error(err);
- }
- });
- } else if(typeof val === 'boolean') {
- el = egen.createCheckbox(item, val, clss);
- el.addEventListener('change', function(e) {
- try{
- // renderer['setHighlightGutterLine'](true);
- obj[e.target.id](!!e.target.checked);
- } catch (err) {
- throw new Error(err);
- }
- });
- } else {
- // this aids in giving the ability to specify settings through
- // post and get requests.
- // /ace_editor.html?setMode=ace/mode/html&setOverwrite=true
- el = egen.createInput(item, val, clss);
- el.addEventListener('change', function(e) {
- try{
- if(e.target.value === 'true') {
- obj[e.target.id](true);
- } else if(e.target.value === 'false') {
- obj[e.target.id](false);
- } else {
- obj[e.target.id](e.target.value);
- }
- } catch (err) {
- throw new Error(err);
- }
- });
- }
- el.style.cssText = 'float:right;';
- div.appendChild(el);
- return div;
- }
- /**
- * Generates selection fields for the menu and populates their options
- * using information from `editor.menuOptions`
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {string} item The set function name.
- * @param {object} esr A reference to the object having the set function.
- * @param {string} clss The name of the object containing the set function.
- * @param {string} fn The matching get function's function name.
- * @returns {DOMElement} Returns a dom element containing a selection
- * element populated with options. The option whose value matches that
- * returned from `esr[fn]()` will be selected.
- */
- function makeDropdown(item, esr, clss, fn) {
- var val = editor.menuOptions[item];
- var currentVal = esr[fn]();
- if (typeof currentVal == 'object')
- currentVal = currentVal.$id;
- val.forEach(function(valuex) {
- if (valuex.value === currentVal)
- valuex.selected = 'selected';
- });
- return createNewEntry(esr, clss, item, val);
- }
- /**
- * Processes the set functions returned from `getSetFunctions`. First it
- * checks for menu options defined in `editor.menuOptions`. If no
- * options are specified then it checks whether there is a get function
- * (replace set with get) for the setting. When either of those
- * conditions are met it will attempt to create a new entry for the
- * settings menu and push it into the elements array defined above.
- * It can only do so for get functions which return
- * strings, numbers, and booleans. A special case is written in for
- * `getMode` where it looks at the returned objects `$id` property and
- * forwards that through instead. Other special cases could be written
- * in but that would get a bit ridiculous.
- * @author <a href="mailto:matthewkastor@gmail.com">
- * Matthew Christopher Kastor-Inare III </a><br />
- * ☭ Hial Atropa!! ☭
- * @param {object} setObj An item from the array returned by
- * `getSetFunctions`.
- */
- function handleSet(setObj) {
- var item = setObj.functionName;
- var esr = setObj.parentObj;
- var clss = setObj.parentName;
- var val;
- var fn = item.replace(/^set/, 'get');
- if(editor.menuOptions[item] !== undefined) {
- // has options for select element
- elements.push(makeDropdown(item, esr, clss, fn));
- } else if(typeof esr[fn] === 'function') {
- // has get function
- try {
- val = esr[fn]();
- if(typeof val === 'object') {
- // setMode takes a string, getMode returns an object
- // the $id property of that object is the string
- // which may be given to setMode...
- val = val.$id;
- }
- // the rest of the get functions return strings,
- // booleans, or numbers.
- elements.push(
- createNewEntry(esr, clss, item, val)
- );
- } catch (e) {
- // if there are errors it is because the element
- // does not belong in the settings menu
- }
- }
- }
- addEditorMenuOptions(editor);
- // gather the set functions
- getSetFunctions(editor).forEach(function(setObj) {
- // populate the elements array with good stuff.
- handleSet(setObj);
- });
- // sort the menu entries in the elements list so people can find
- // the settings in alphabetical order.
- cleanupElementsList();
- // dump the entries from the elements list and wrap them up in a div
- return wrapElements();
-};
-
-});
\ No newline at end of file