Abhishek Banthia
8 years ago
49 changed files with 0 additions and 69670 deletions
Binary file not shown.
@ -1,334 +0,0 @@
|
||||
ace.define("ace/ext/beautify/php_rules",["require","exports","module","ace/token_iterator"], function(require, exports, module) { |
||||
"use strict"; |
||||
var TokenIterator = require("ace/token_iterator").TokenIterator; |
||||
exports.newLines = [{ |
||||
type: 'support.php_tag', |
||||
value: '<?php' |
||||
}, { |
||||
type: 'support.php_tag', |
||||
value: '<?' |
||||
}, { |
||||
type: 'support.php_tag', |
||||
value: '?>' |
||||
}, { |
||||
type: 'paren.lparen', |
||||
value: '{', |
||||
indent: true |
||||
}, { |
||||
type: 'paren.rparen', |
||||
breakBefore: true, |
||||
value: '}', |
||||
indent: false |
||||
}, { |
||||
type: 'paren.rparen', |
||||
breakBefore: true, |
||||
value: '})', |
||||
indent: false, |
||||
dontBreak: true |
||||
}, { |
||||
type: 'comment' |
||||
}, { |
||||
type: 'text', |
||||
value: ';' |
||||
}, { |
||||
type: 'text', |
||||
value: ':', |
||||
context: 'php' |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'case', |
||||
indent: true, |
||||
dontBreak: true |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'default', |
||||
indent: true, |
||||
dontBreak: true |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'break', |
||||
indent: false, |
||||
dontBreak: true |
||||
}, { |
||||
type: 'punctuation.doctype.end', |
||||
value: '>' |
||||
}, { |
||||
type: 'meta.tag.punctuation.end', |
||||
value: '>' |
||||
}, { |
||||
type: 'meta.tag.punctuation.begin', |
||||
value: '<', |
||||
blockTag: true, |
||||
indent: true, |
||||
dontBreak: true |
||||
}, { |
||||
type: 'meta.tag.punctuation.begin', |
||||
value: '</', |
||||
indent: false, |
||||
breakBefore: true, |
||||
dontBreak: true |
||||
}, { |
||||
type: 'punctuation.operator', |
||||
value: ';' |
||||
}]; |
||||
|
||||
exports.spaces = [{ |
||||
type: 'xml-pe', |
||||
prepend: true |
||||
},{ |
||||
type: 'entity.other.attribute-name', |
||||
prepend: true |
||||
}, { |
||||
type: 'storage.type', |
||||
value: 'var', |
||||
append: true |
||||
}, { |
||||
type: 'storage.type', |
||||
value: 'function', |
||||
append: true |
||||
}, { |
||||
type: 'keyword.operator', |
||||
value: '=' |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'as', |
||||
prepend: true, |
||||
append: true |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'function', |
||||
append: true |
||||
}, { |
||||
type: 'support.function', |
||||
next: /[^\(]/, |
||||
append: true |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'or', |
||||
append: true, |
||||
prepend: true |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'and', |
||||
append: true, |
||||
prepend: true |
||||
}, { |
||||
type: 'keyword', |
||||
value: 'case', |
||||
append: true |
||||
}, { |
||||
type: 'keyword.operator', |
||||
value: '||', |
||||
append: true, |
||||
prepend: true |
||||
}, { |
||||
type: 'keyword.operator', |
||||
value: '&&', |
||||
append: true, |
||||
prepend: true |
||||
}]; |
||||
exports.singleTags = ['!doctype','area','base','br','hr','input','img','link','meta']; |
||||
|
||||
exports.transform = function(iterator, maxPos, context) { |
||||
var token = iterator.getCurrentToken(); |
||||
|
||||
var newLines = exports.newLines; |
||||
var spaces = exports.spaces; |
||||
var singleTags = exports.singleTags; |
||||
|
||||
var code = ''; |
||||
|
||||
var indentation = 0; |
||||
var dontBreak = false; |
||||
var tag; |
||||
var lastTag; |
||||
var lastToken = {}; |
||||
var nextTag; |
||||
var nextToken = {}; |
||||
var breakAdded = false; |
||||
var value = ''; |
||||
|
||||
while (token!==null) { |
||||
console.log(token); |
||||
|
||||
if( !token ){ |
||||
token = iterator.stepForward(); |
||||
continue; |
||||
} |
||||
if( token.type == 'support.php_tag' && token.value != '?>' ){ |
||||
context = 'php'; |
||||
} |
||||
else if( token.type == 'support.php_tag' && token.value == '?>' ){ |
||||
context = 'html'; |
||||
} |
||||
else if( token.type == 'meta.tag.name.style' && context != 'css' ){ |
||||
context = 'css'; |
||||
} |
||||
else if( token.type == 'meta.tag.name.style' && context == 'css' ){ |
||||
context = 'html'; |
||||
} |
||||
else if( token.type == 'meta.tag.name.script' && context != 'js' ){ |
||||
context = 'js'; |
||||
} |
||||
else if( token.type == 'meta.tag.name.script' && context == 'js' ){ |
||||
context = 'html'; |
||||
} |
||||
|
||||
nextToken = iterator.stepForward(); |
||||
if (nextToken && nextToken.type.indexOf('meta.tag.name') == 0) { |
||||
nextTag = nextToken.value; |
||||
} |
||||
if ( lastToken.type == 'support.php_tag' && lastToken.value == '<?=') { |
||||
dontBreak = true; |
||||
} |
||||
if (token.type == 'meta.tag.name') { |
||||
token.value = token.value.toLowerCase(); |
||||
} |
||||
if (token.type == 'text') { |
||||
token.value = token.value.trim(); |
||||
} |
||||
if (!token.value) { |
||||
token = nextToken; |
||||
continue; |
||||
} |
||||
value = token.value; |
||||
for (var i in spaces) { |
||||
if ( |
||||
token.type == spaces[i].type && |
||||
(!spaces[i].value || token.value == spaces[i].value) && |
||||
( |
||||
nextToken && |
||||
(!spaces[i].next || spaces[i].next.test(nextToken.value)) |
||||
) |
||||
) { |
||||
if (spaces[i].prepend) { |
||||
value = ' ' + token.value; |
||||
} |
||||
|
||||
if (spaces[i].append) { |
||||
value += ' '; |
||||
} |
||||
} |
||||
} |
||||
if (token.type.indexOf('meta.tag.name') == 0) { |
||||
tag = token.value; |
||||
} |
||||
breakAdded = false; |
||||
for (i in newLines) { |
||||
if ( |
||||
token.type == newLines[i].type && |
||||
( |
||||
!newLines[i].value || |
||||
token.value == newLines[i].value |
||||
) && |
||||
( |
||||
!newLines[i].blockTag || |
||||
singleTags.indexOf(nextTag) === -1 |
||||
) && |
||||
( |
||||
!newLines[i].context || |
||||
newLines[i].context === context |
||||
) |
||||
) { |
||||
if (newLines[i].indent === false) { |
||||
indentation--; |
||||
} |
||||
|
||||
if ( |
||||
newLines[i].breakBefore && |
||||
( !newLines[i].prev || newLines[i].prev.test(lastToken.value) ) |
||||
) { |
||||
code += "\n"; |
||||
breakAdded = true; |
||||
for (i = 0; i < indentation; i++) { |
||||
code += "\t"; |
||||
} |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (dontBreak===false) { |
||||
for (i in newLines) { |
||||
if ( |
||||
lastToken.type == newLines[i].type && |
||||
( |
||||
!newLines[i].value || lastToken.value == newLines[i].value |
||||
) && |
||||
( |
||||
!newLines[i].blockTag || |
||||
singleTags.indexOf(tag) === -1 |
||||
) && |
||||
( |
||||
!newLines[i].context || |
||||
newLines[i].context === context |
||||
) |
||||
) { |
||||
if (newLines[i].indent === true) { |
||||
indentation++; |
||||
} |
||||
|
||||
if (!newLines[i].dontBreak && !breakAdded) { |
||||
code += "\n"; |
||||
for (i = 0; i < indentation; i++) { |
||||
code += "\t"; |
||||
} |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
code += value; |
||||
if ( lastToken.type == 'support.php_tag' && lastToken.value == '?>' ) { |
||||
dontBreak = false; |
||||
} |
||||
lastTag = tag; |
||||
|
||||
lastToken = token; |
||||
|
||||
token = nextToken; |
||||
|
||||
if (token===null) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return code; |
||||
}; |
||||
|
||||
|
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator","ace/ext/beautify/php_rules"], function(require, exports, module) { |
||||
"use strict"; |
||||
var TokenIterator = require("ace/token_iterator").TokenIterator; |
||||
|
||||
var phpTransform = require("./beautify/php_rules").transform; |
||||
|
||||
exports.beautify = function(session) { |
||||
var iterator = new TokenIterator(session, 0, 0); |
||||
var token = iterator.getCurrentToken(); |
||||
|
||||
var context = session.$modeId.split("/").pop(); |
||||
|
||||
var code = phpTransform(iterator, context); |
||||
session.doc.setValue(code); |
||||
}; |
||||
|
||||
exports.commands = [{ |
||||
name: "beautify", |
||||
exec: function(editor) { |
||||
exports.beautify(editor.session); |
||||
}, |
||||
bindKey: "Ctrl-Shift-B" |
||||
}] |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/beautify"], function() {}); |
||||
})(); |
||||
|
@ -1,541 +0,0 @@
|
||||
ace.define("ace/ext/chromevox",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) { |
||||
var cvoxAce = {}; |
||||
cvoxAce.SpeechProperty; |
||||
cvoxAce.Cursor; |
||||
cvoxAce.Token; |
||||
cvoxAce.Annotation; |
||||
var CONSTANT_PROP = { |
||||
'rate': 0.8, |
||||
'pitch': 0.4, |
||||
'volume': 0.9 |
||||
}; |
||||
var DEFAULT_PROP = { |
||||
'rate': 1, |
||||
'pitch': 0.5, |
||||
'volume': 0.9 |
||||
}; |
||||
var ENTITY_PROP = { |
||||
'rate': 0.8, |
||||
'pitch': 0.8, |
||||
'volume': 0.9 |
||||
}; |
||||
var KEYWORD_PROP = { |
||||
'rate': 0.8, |
||||
'pitch': 0.3, |
||||
'volume': 0.9 |
||||
}; |
||||
var STORAGE_PROP = { |
||||
'rate': 0.8, |
||||
'pitch': 0.7, |
||||
'volume': 0.9 |
||||
}; |
||||
var VARIABLE_PROP = { |
||||
'rate': 0.8, |
||||
'pitch': 0.8, |
||||
'volume': 0.9 |
||||
}; |
||||
var DELETED_PROP = { |
||||
'punctuationEcho': 'none', |
||||
'relativePitch': -0.6 |
||||
}; |
||||
var ERROR_EARCON = 'ALERT_NONMODAL'; |
||||
var MODE_SWITCH_EARCON = 'ALERT_MODAL'; |
||||
var NO_MATCH_EARCON = 'INVALID_KEYPRESS'; |
||||
var INSERT_MODE_STATE = 'insertMode'; |
||||
var COMMAND_MODE_STATE = 'start'; |
||||
|
||||
var REPLACE_LIST = [ |
||||
{ |
||||
substr: ';', |
||||
newSubstr: ' semicolon ' |
||||
}, |
||||
{ |
||||
substr: ':', |
||||
newSubstr: ' colon ' |
||||
} |
||||
]; |
||||
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' |
||||
}; |
||||
var KEY_PREFIX = 'CONTROL + SHIFT '; |
||||
cvoxAce.editor = null; |
||||
var lastCursor = null; |
||||
var annotTable = {}; |
||||
var shouldSpeakRowLocation = false; |
||||
var shouldSpeakDisplacement = false; |
||||
var changed = false; |
||||
var vimState = null; |
||||
var keyCodeToShortcutMap = {}; |
||||
var cmdToShortcutMap = {}; |
||||
var getKeyShortcutString = function(keyCode) { |
||||
return KEY_PREFIX + String.fromCharCode(keyCode); |
||||
}; |
||||
var isVimMode = function() { |
||||
var keyboardHandler = cvoxAce.editor.keyBinding.getKeyboardHandler(); |
||||
return keyboardHandler.$id === 'ace/keyboard/vim'; |
||||
}; |
||||
var getCurrentToken = function(cursor) { |
||||
return cvoxAce.editor.getSession().getTokenAt(cursor.row, cursor.column + 1); |
||||
}; |
||||
var getCurrentLine = function(cursor) { |
||||
return cvoxAce.editor.getSession().getLine(cursor.row); |
||||
}; |
||||
var onRowChange = function(currCursor) { |
||||
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); |
||||
} |
||||
}; |
||||
var isWord = function(cursor) { |
||||
var line = getCurrentLine(cursor); |
||||
var lineSuffix = line.substr(cursor.column - 1); |
||||
if (cursor.column === 0) { |
||||
lineSuffix = ' ' + line; |
||||
} |
||||
var firstWordRegExp = /^\W(\w+)/; |
||||
var words = firstWordRegExp.exec(lineSuffix); |
||||
return words !== null; |
||||
}; |
||||
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 ' |
||||
} |
||||
] |
||||
} |
||||
}; |
||||
var DEFAULT_RULE = { |
||||
prop: DEFAULT_RULE |
||||
}; |
||||
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; |
||||
}; |
||||
var mergeTokens = function(tokens, start, end) { |
||||
var newToken = {}; |
||||
newToken.value = ''; |
||||
newToken.type = tokens[start].type; |
||||
for (var j = start; j < end; j++) { |
||||
newToken.value += tokens[j].value; |
||||
} |
||||
return newToken; |
||||
}; |
||||
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; |
||||
}; |
||||
var isRowWhiteSpace = function(row) { |
||||
var line = cvoxAce.editor.getSession().getLine(row); |
||||
var whiteSpaceRegexp = /^\s*$/; |
||||
return whiteSpaceRegexp.exec(line) !== null; |
||||
}; |
||||
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]; |
||||
tokens = tokens.filter(function(token) { |
||||
return token !== firstToken; |
||||
}); |
||||
speakToken_(firstToken, queue); |
||||
tokens.forEach(speakTokenQueue); |
||||
}; |
||||
var speakTokenFlush = function(token) { |
||||
speakToken_(token, 0); |
||||
}; |
||||
var speakTokenQueue = function(token) { |
||||
speakToken_(token, 1); |
||||
}; |
||||
var getTokenRule = function(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; |
||||
}; |
||||
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); |
||||
}; |
||||
var speakChar = function(cursor) { |
||||
var line = getCurrentLine(cursor); |
||||
cvox.Api.speak(line[cursor.column], 1); |
||||
}; |
||||
var speakDisplacement = function(lastCursor, currCursor) { |
||||
var line = getCurrentLine(currCursor); |
||||
var displace = line.substring(lastCursor.column, currCursor.column); |
||||
displace = displace.replace(/ /g, ' space '); |
||||
cvox.Api.speak(displace); |
||||
}; |
||||
var speakCharOrWordOrLine = function(lastCursor, currCursor) { |
||||
if (Math.abs(lastCursor.column - currCursor.column) !== 1) { |
||||
var currLineLength = getCurrentLine(currCursor).length; |
||||
if (currCursor.column === 0 || currCursor.column === currLineLength) { |
||||
speakLine(currCursor.row, 0); |
||||
return; |
||||
} |
||||
if (isWord(currCursor)) { |
||||
cvox.Api.stop(); |
||||
speakTokenQueue(getCurrentToken(currCursor)); |
||||
return; |
||||
} |
||||
} |
||||
speakChar(currCursor); |
||||
}; |
||||
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); |
||||
} |
||||
}; |
||||
var onCursorChange = function(evt) { |
||||
if (changed) { |
||||
changed = false; |
||||
return; |
||||
} |
||||
var currCursor = cvoxAce.editor.selection.getCursor(); |
||||
if (currCursor.row !== lastCursor.row) { |
||||
onRowChange(currCursor); |
||||
} else { |
||||
onColumnChange(lastCursor, currCursor); |
||||
} |
||||
lastCursor = currCursor; |
||||
}; |
||||
var onSelectionChange = function(evt) { |
||||
if (cvoxAce.editor.selection.isEmpty()) { |
||||
cvox.Api.speak('unselected'); |
||||
} |
||||
}; |
||||
var onChange = function(evt) { |
||||
var data = evt.data; |
||||
switch (data.action) { |
||||
case 'removeText': |
||||
cvox.Api.speak(data.text, 0, DELETED_PROP); |
||||
changed = true; |
||||
break; |
||||
case 'insertText': |
||||
cvox.Api.speak(data.text, 0); |
||||
changed = true; |
||||
break; |
||||
} |
||||
}; |
||||
var isNewAnnotation = function(annot) { |
||||
var row = annot.row; |
||||
var col = annot.column; |
||||
return !annotTable[row] || !annotTable[row][col]; |
||||
}; |
||||
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; |
||||
} |
||||
}; |
||||
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); |
||||
}; |
||||
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); |
||||
}; |
||||
var speakAnnotsByRow = function(row) { |
||||
var annots = annotTable[row]; |
||||
for (var col in annots) { |
||||
speakAnnot(annots[col]); |
||||
} |
||||
}; |
||||
var rowColToString = function(row, col) { |
||||
return 'row ' + (row + 1) + ' column ' + (col + 1); |
||||
}; |
||||
var speakCurrRowAndCol = function() { |
||||
cvox.Api.speak(rowColToString(lastCursor.row, lastCursor.column)); |
||||
}; |
||||
var speakAllAnnots = function() { |
||||
for (var row in annotTable) { |
||||
speakAnnotsByRow(row); |
||||
} |
||||
}; |
||||
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; |
||||
} |
||||
}; |
||||
var toggleSpeakRowLocation = function() { |
||||
shouldSpeakRowLocation = !shouldSpeakRowLocation; |
||||
if (shouldSpeakRowLocation) { |
||||
cvox.Api.speak('Speak location on row change enabled.'); |
||||
} else { |
||||
cvox.Api.speak('Speak location on row change disabled.'); |
||||
} |
||||
}; |
||||
var toggleSpeakDisplacement = function() { |
||||
shouldSpeakDisplacement = !shouldSpeakDisplacement; |
||||
if (shouldSpeakDisplacement) { |
||||
cvox.Api.speak('Speak displacement on column changes.'); |
||||
} else { |
||||
cvox.Api.speak('Speak current character or word on column changes.'); |
||||
} |
||||
}; |
||||
var onKeyDown = function(evt) { |
||||
if (evt.ctrlKey && evt.shiftKey) { |
||||
var shortcut = keyCodeToShortcutMap[evt.keyCode]; |
||||
if (shortcut) { |
||||
shortcut.func(); |
||||
} |
||||
} |
||||
}; |
||||
var onChangeStatus = function(evt, editor) { |
||||
if (!isVimMode()) { |
||||
return; |
||||
} |
||||
var state = editor.keyBinding.$data.state; |
||||
if (state === vimState) { |
||||
return; |
||||
} |
||||
switch (state) { |
||||
case INSERT_MODE_STATE: |
||||
cvox.Api.playEarcon(MODE_SWITCH_EARCON); |
||||
cvox.Api.setKeyEcho(true); |
||||
break; |
||||
case COMMAND_MODE_STATE: |
||||
cvox.Api.playEarcon(MODE_SWITCH_EARCON); |
||||
cvox.Api.setKeyEcho(false); |
||||
break; |
||||
} |
||||
vimState = state; |
||||
}; |
||||
var contextMenuHandler = function(evt) { |
||||
var cmd = evt.detail['customCommand']; |
||||
var shortcut = cmdToShortcutMap[cmd]; |
||||
if (shortcut) { |
||||
shortcut.func(); |
||||
cvoxAce.editor.focus(); |
||||
} |
||||
}; |
||||
var initContextMenu = function() { |
||||
var ACTIONS = SHORTCUTS.map(function(shortcut) { |
||||
return { |
||||
desc: shortcut.desc + getKeyShortcutString(shortcut.keyCode), |
||||
cmd: shortcut.cmd |
||||
}; |
||||
}); |
||||
var body = document.querySelector('body'); |
||||
body.setAttribute('contextMenuActions', JSON.stringify(ACTIONS)); |
||||
body.addEventListener('ATCustomEvent', contextMenuHandler, true); |
||||
}; |
||||
var onFindSearchbox = function(evt) { |
||||
if (evt.match) { |
||||
speakLine(lastCursor.row, 0); |
||||
} else { |
||||
cvox.Api.playEarcon(NO_MATCH_EARCON); |
||||
} |
||||
}; |
||||
var focus = function() { |
||||
cvoxAce.editor.focus(); |
||||
}; |
||||
var SHORTCUTS = [ |
||||
{ |
||||
keyCode: 49, |
||||
func: function() { |
||||
speakAnnotsByRow(lastCursor.row); |
||||
}, |
||||
cmd: Command.SPEAK_ANNOT, |
||||
desc: 'Speak annotations on line' |
||||
}, |
||||
{ |
||||
keyCode: 50, |
||||
func: speakAllAnnots, |
||||
cmd: Command.SPEAK_ALL_ANNOTS, |
||||
desc: 'Speak all annotations' |
||||
}, |
||||
{ |
||||
keyCode: 51, |
||||
func: speakMode, |
||||
cmd: Command.SPEAK_MODE, |
||||
desc: 'Speak Vim mode' |
||||
}, |
||||
{ |
||||
keyCode: 52, |
||||
func: toggleSpeakRowLocation, |
||||
cmd: Command.TOGGLE_LOCATION, |
||||
desc: 'Toggle speak row location' |
||||
}, |
||||
{ |
||||
keyCode: 53, |
||||
func: speakCurrRowAndCol, |
||||
cmd: Command.SPEAK_ROW_COL, |
||||
desc: 'Speak row and column' |
||||
}, |
||||
{ |
||||
keyCode: 54, |
||||
func: toggleSpeakDisplacement, |
||||
cmd: Command.TOGGLE_DISPLACEMENT, |
||||
desc: 'Toggle speak displacement' |
||||
}, |
||||
{ |
||||
keyCode: 55, |
||||
func: focus, |
||||
cmd: Command.FOCUS_TEXT, |
||||
desc: 'Focus text' |
||||
} |
||||
]; |
||||
var onFocus = function() { |
||||
cvoxAce.editor = editor; |
||||
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(); |
||||
}; |
||||
var init = function(editor) { |
||||
onFocus(); |
||||
SHORTCUTS.forEach(function(shortcut) { |
||||
keyCodeToShortcutMap[shortcut.keyCode] = shortcut; |
||||
cmdToShortcutMap[shortcut.cmd] = shortcut; |
||||
}); |
||||
|
||||
editor.on('focus', onFocus); |
||||
if (isVimMode()) { |
||||
cvox.Api.setKeyEcho(false); |
||||
} |
||||
initContextMenu(); |
||||
}; |
||||
function cvoxApiExists() { |
||||
return (typeof(cvox) !== 'undefined') && cvox && cvox.Api; |
||||
} |
||||
var tries = 0; |
||||
var MAX_TRIES = 15; |
||||
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
|
||||
} |
||||
}); |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/chromevox"], function() {}); |
||||
})(); |
||||
|
@ -1,275 +0,0 @@
|
||||
ace.define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"], 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; |
||||
var rowIter = row; |
||||
while (rowIter >= 0) { |
||||
widths = this.$cellWidthsForRow(rowIter); |
||||
if (widths.length == 0) |
||||
break; |
||||
|
||||
cellWidths.unshift(widths); |
||||
rowIter--; |
||||
} |
||||
var firstRow = rowIter + 1; |
||||
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); |
||||
|
||||
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()) { |
||||
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; |
||||
} |
||||
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)) { |
||||
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; |
||||
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) { |
||||
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; |
||||
} |
||||
} |
||||
}; |
||||
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; |
||||
}; |
||||
this.$izip = function(widths, tabs) { |
||||
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); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/elastic_tabstops_lite"], function() {}); |
||||
})(); |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
|
||||
; |
||||
(function() { |
||||
ace.require(["ace/ext/error_marker"], function() {}); |
||||
})(); |
||||
|
@ -1,170 +0,0 @@
|
||||
ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) { |
||||
'use strict'; |
||||
var dom = require("../../lib/dom"); |
||||
var cssText = "#ace_settingsmenu, #kbshortcutmenu {\ |
||||
background-color: #F7F7F7;\ |
||||
color: black;\ |
||||
box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\ |
||||
padding: 1em 0.5em 2em 1em;\ |
||||
overflow: auto;\ |
||||
position: absolute;\ |
||||
margin: 0;\ |
||||
bottom: 0;\ |
||||
right: 0;\ |
||||
top: 0;\ |
||||
z-index: 9991;\ |
||||
cursor: default;\ |
||||
}\ |
||||
.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\ |
||||
box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\ |
||||
background-color: rgba(255, 255, 255, 0.6);\ |
||||
color: black;\ |
||||
}\ |
||||
.ace_optionsMenuEntry:hover {\ |
||||
background-color: rgba(100, 100, 100, 0.1);\ |
||||
-webkit-transition: all 0.5s;\ |
||||
transition: all 0.3s\ |
||||
}\ |
||||
.ace_closeButton {\ |
||||
background: rgba(245, 146, 146, 0.5);\ |
||||
border: 1px solid #F48A8A;\ |
||||
border-radius: 50%;\ |
||||
padding: 7px;\ |
||||
position: absolute;\ |
||||
right: -8px;\ |
||||
top: -8px;\ |
||||
z-index: 1000;\ |
||||
}\ |
||||
.ace_closeButton{\ |
||||
background: rgba(245, 146, 146, 0.9);\ |
||||
}\ |
||||
.ace_optionsMenuKey {\ |
||||
color: darkslateblue;\ |
||||
font-weight: bold;\ |
||||
}\ |
||||
.ace_optionsMenuCommand {\ |
||||
color: darkcyan;\ |
||||
font-weight: normal;\ |
||||
}"; |
||||
dom.importCssString(cssText); |
||||
module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) { |
||||
top = top ? 'top: ' + top + ';' : ''; |
||||
bottom = bottom ? 'bottom: ' + bottom + ';' : ''; |
||||
right = right ? 'right: ' + right + ';' : ''; |
||||
left = left ? 'left: ' + left + ';' : ''; |
||||
|
||||
var closer = document.createElement('div'); |
||||
var contentContainer = document.createElement('div'); |
||||
|
||||
function documentEscListener(e) { |
||||
if (e.keyCode === 27) { |
||||
closer.click(); |
||||
} |
||||
} |
||||
|
||||
closer.style.cssText = 'margin: 0; padding: 0; ' + |
||||
'position: fixed; top:0; bottom:0; left:0; right:0;' + |
||||
'z-index: 9990; ' + |
||||
'background-color: rgba(0, 0, 0, 0.3);'; |
||||
closer.addEventListener('click', function() { |
||||
document.removeEventListener('keydown', documentEscListener); |
||||
closer.parentNode.removeChild(closer); |
||||
editor.focus(); |
||||
closer = null; |
||||
}); |
||||
document.addEventListener('keydown', documentEscListener); |
||||
|
||||
contentContainer.style.cssText = top + right + bottom + left; |
||||
contentContainer.addEventListener('click', function(e) { |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
var wrapper = dom.createElement("div"); |
||||
wrapper.style.position = "relative"; |
||||
|
||||
var closeButton = dom.createElement("div"); |
||||
closeButton.className = "ace_closeButton"; |
||||
closeButton.addEventListener('click', function() { |
||||
closer.click(); |
||||
}); |
||||
|
||||
wrapper.appendChild(closeButton); |
||||
contentContainer.appendChild(wrapper); |
||||
|
||||
contentContainer.appendChild(contentElement); |
||||
closer.appendChild(contentContainer); |
||||
document.body.appendChild(closer); |
||||
editor.blur(); |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/menu_tools/get_editor_keyboard_shortcuts",["require","exports","module","ace/lib/keys"], function(require, exports, module) { |
||||
"use strict"; |
||||
var keys = require("../../lib/keys"); |
||||
module.exports.getEditorKeybordShortcuts = function(editor) { |
||||
var KEY_MODS = keys.KEY_MODS; |
||||
var keybindings = []; |
||||
var commandMap = {}; |
||||
editor.keyBinding.$handlers.forEach(function(handler) { |
||||
var ckb = handler.commandKeyBinding; |
||||
for (var i in ckb) { |
||||
var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); }); |
||||
var commands = ckb[i]; |
||||
if (!Array.isArray(commands)) |
||||
commands = [commands]; |
||||
commands.forEach(function(command) { |
||||
if (typeof command != "string") |
||||
command = command.name |
||||
if (commandMap[command]) { |
||||
commandMap[command].key += "|" + key; |
||||
} else { |
||||
commandMap[command] = {key: key, command: command}; |
||||
keybindings.push(commandMap[command]); |
||||
}
|
||||
}); |
||||
} |
||||
}); |
||||
return keybindings; |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/keybinding_menu",["require","exports","module","ace/editor","ace/ext/menu_tools/overlay_page","ace/ext/menu_tools/get_editor_keyboard_shortcuts"], function(require, exports, module) { |
||||
"use strict"; |
||||
var Editor = require("ace/editor").Editor; |
||||
function showKeyboardShortcuts (editor) { |
||||
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(); |
||||
} |
||||
}]); |
||||
}; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/keybinding_menu"], function() {}); |
||||
})(); |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,52 +0,0 @@
|
||||
ace.define("ace/ext/linking",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) { |
||||
|
||||
var Editor = require("ace/editor").Editor; |
||||
|
||||
require("../config").defineOptions(Editor.prototype, "editor", { |
||||
enableLinking: { |
||||
set: function(val) { |
||||
if (val) { |
||||
this.on("click", onClick); |
||||
this.on("mousemove", onMouseMove); |
||||
} else { |
||||
this.off("click", onClick); |
||||
this.off("mousemove", onMouseMove); |
||||
} |
||||
}, |
||||
value: false |
||||
} |
||||
}) |
||||
|
||||
function onMouseMove(e) { |
||||
var editor = e.editor; |
||||
var ctrl = e.getAccelKey(); |
||||
|
||||
if (ctrl) { |
||||
var editor = e.editor; |
||||
var docPos = e.getDocumentPosition(); |
||||
var session = editor.session; |
||||
var token = session.getTokenAt(docPos.row, docPos.column); |
||||
|
||||
editor._emit("linkHover", {position: docPos, token: token}); |
||||
} |
||||
} |
||||
|
||||
function onClick(e) { |
||||
var ctrl = e.getAccelKey(); |
||||
var button = e.getButton(); |
||||
|
||||
if (button == 0 && ctrl) { |
||||
var editor = e.editor; |
||||
var docPos = e.getDocumentPosition(); |
||||
var session = editor.session; |
||||
var token = session.getTokenAt(docPos.row, docPos.column); |
||||
|
||||
editor._emit("linkClick", {position: docPos, token: token}); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/linking"], function() {}); |
||||
})(); |
||||
|
@ -1,191 +0,0 @@
|
||||
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var modes = []; |
||||
function getModeForPath(path) { |
||||
var mode = modesByName.text; |
||||
var fileName = path.split(/[\/\\]/).pop(); |
||||
for (var i = 0; i < modes.length; i++) { |
||||
if (modes[i].supportsFile(fileName)) { |
||||
mode = modes[i]; |
||||
break; |
||||
} |
||||
} |
||||
return mode; |
||||
} |
||||
|
||||
var Mode = function(name, caption, extensions) { |
||||
this.name = name; |
||||
this.caption = caption; |
||||
this.mode = "ace/mode/" + name; |
||||
this.extensions = extensions; |
||||
if (/\^/.test(extensions)) { |
||||
var re = extensions.replace(/\|(\^)?/g, function(a, b){ |
||||
return "$|" + (b ? "^" : "^.*\\."); |
||||
}) + "$"; |
||||
} else { |
||||
var re = "^.*\\.(" + extensions + ")$"; |
||||
} |
||||
|
||||
this.extRe = new RegExp(re, "gi"); |
||||
}; |
||||
|
||||
Mode.prototype.supportsFile = function(filename) { |
||||
return filename.match(this.extRe); |
||||
}; |
||||
var supportedModes = { |
||||
ABAP: ["abap"], |
||||
ABC: ["abc"], |
||||
ActionScript:["as"], |
||||
ADA: ["ada|adb"], |
||||
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], |
||||
AsciiDoc: ["asciidoc|adoc"], |
||||
Assembly_x86:["asm"], |
||||
AutoHotKey: ["ahk"], |
||||
BatchFile: ["bat|cmd"], |
||||
C9Search: ["c9search_results"], |
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"], |
||||
Cirru: ["cirru|cr"], |
||||
Clojure: ["clj|cljs"], |
||||
Cobol: ["CBL|COB"], |
||||
coffee: ["coffee|cf|cson|^Cakefile"], |
||||
ColdFusion: ["cfm"], |
||||
CSharp: ["cs"], |
||||
CSS: ["css"], |
||||
Curly: ["curly"], |
||||
D: ["d|di"], |
||||
Dart: ["dart"], |
||||
Diff: ["diff|patch"], |
||||
Dockerfile: ["^Dockerfile"], |
||||
Dot: ["dot"], |
||||
Dummy: ["dummy"], |
||||
DummySyntax: ["dummy"], |
||||
Eiffel: ["e"], |
||||
EJS: ["ejs"], |
||||
Elixir: ["ex|exs"], |
||||
Elm: ["elm"], |
||||
Erlang: ["erl|hrl"], |
||||
Forth: ["frt|fs|ldr"], |
||||
FTL: ["ftl"], |
||||
Gcode: ["gcode"], |
||||
Gherkin: ["feature"], |
||||
Gitignore: ["^.gitignore"], |
||||
Glsl: ["glsl|frag|vert"], |
||||
golang: ["go"], |
||||
Groovy: ["groovy"], |
||||
HAML: ["haml"], |
||||
Handlebars: ["hbs|handlebars|tpl|mustache"], |
||||
Haskell: ["hs"], |
||||
haXe: ["hx"], |
||||
HTML: ["html|htm|xhtml"], |
||||
HTML_Ruby: ["erb|rhtml|html.erb"], |
||||
INI: ["ini|conf|cfg|prefs"], |
||||
Io: ["io"], |
||||
Jack: ["jack"], |
||||
Jade: ["jade"], |
||||
Java: ["java"], |
||||
JavaScript: ["js|jsm"], |
||||
JSON: ["json"], |
||||
JSONiq: ["jq"], |
||||
JSP: ["jsp"], |
||||
JSX: ["jsx"], |
||||
Julia: ["jl"], |
||||
LaTeX: ["tex|latex|ltx|bib"], |
||||
Lean: ["lean|hlean"], |
||||
LESS: ["less"], |
||||
Liquid: ["liquid"], |
||||
Lisp: ["lisp"], |
||||
LiveScript: ["ls"], |
||||
LogiQL: ["logic|lql"], |
||||
LSL: ["lsl"], |
||||
Lua: ["lua"], |
||||
LuaPage: ["lp"], |
||||
Lucene: ["lucene"], |
||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], |
||||
Markdown: ["md|markdown"], |
||||
Mask: ["mask"], |
||||
MATLAB: ["matlab"], |
||||
MEL: ["mel"], |
||||
MUSHCode: ["mc|mush"], |
||||
MySQL: ["mysql"], |
||||
Nix: ["nix"], |
||||
ObjectiveC: ["m|mm"], |
||||
OCaml: ["ml|mli"], |
||||
Pascal: ["pas|p"], |
||||
Perl: ["pl|pm"], |
||||
pgSQL: ["pgsql"], |
||||
PHP: ["php|phtml"], |
||||
Powershell: ["ps1"], |
||||
Praat: ["praat|praatscript|psc|proc"], |
||||
Prolog: ["plg|prolog"], |
||||
Properties: ["properties"], |
||||
Protobuf: ["proto"], |
||||
Python: ["py"], |
||||
R: ["r"], |
||||
RDoc: ["Rd"], |
||||
RHTML: ["Rhtml"], |
||||
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], |
||||
Rust: ["rs"], |
||||
SASS: ["sass"], |
||||
SCAD: ["scad"], |
||||
Scala: ["scala"], |
||||
Scheme: ["scm|rkt"], |
||||
SCSS: ["scss"], |
||||
SH: ["sh|bash|^.bashrc"], |
||||
SJS: ["sjs"], |
||||
Smarty: ["smarty|tpl"], |
||||
snippets: ["snippets"], |
||||
Soy_Template:["soy"], |
||||
Space: ["space"], |
||||
SQL: ["sql"], |
||||
SQLServer: ["sqlserver"], |
||||
Stylus: ["styl|stylus"], |
||||
SVG: ["svg"], |
||||
Tcl: ["tcl"], |
||||
Tex: ["tex"], |
||||
Text: ["txt"], |
||||
Textile: ["textile"], |
||||
Toml: ["toml"], |
||||
Twig: ["twig"], |
||||
Typescript: ["ts|typescript|str"], |
||||
Vala: ["vala"], |
||||
VBScript: ["vbs|vb"], |
||||
Velocity: ["vm"], |
||||
Verilog: ["v|vh|sv|svh"], |
||||
VHDL: ["vhd|vhdl"], |
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], |
||||
XQuery: ["xq"], |
||||
YAML: ["yaml|yml"], |
||||
Django: ["html"] |
||||
}; |
||||
|
||||
var nameOverrides = { |
||||
ObjectiveC: "Objective-C", |
||||
CSharp: "C#", |
||||
golang: "Go", |
||||
C_Cpp: "C and C++", |
||||
coffee: "CoffeeScript", |
||||
HTML_Ruby: "HTML (Ruby)", |
||||
FTL: "FreeMarker" |
||||
}; |
||||
var modesByName = {}; |
||||
for (var name in supportedModes) { |
||||
var data = supportedModes[name]; |
||||
var displayName = (nameOverrides[name] || name).replace(/_/g, " "); |
||||
var filename = name.toLowerCase(); |
||||
var mode = new Mode(filename, displayName, data[0]); |
||||
modesByName[filename] = mode; |
||||
modes.push(mode); |
||||
} |
||||
|
||||
module.exports = { |
||||
getModeForPath: getModeForPath, |
||||
modes: modes, |
||||
modesByName: modesByName |
||||
}; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/modelist"], function() {}); |
||||
})(); |
||||
|
@ -1,494 +0,0 @@
|
||||
ace.define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var dom = require("../lib/dom"); |
||||
var lang = require("../lib/lang"); |
||||
var event = require("../lib/event"); |
||||
var searchboxCss = "\ |
||||
.ace_search {\ |
||||
background-color: #ddd;\ |
||||
border: 1px solid #cbcbcb;\ |
||||
border-top: 0 none;\ |
||||
max-width: 325px;\ |
||||
overflow: hidden;\ |
||||
margin: 0;\ |
||||
padding: 4px;\ |
||||
padding-right: 6px;\ |
||||
padding-bottom: 0;\ |
||||
position: absolute;\ |
||||
top: 0px;\ |
||||
z-index: 99;\ |
||||
white-space: normal;\ |
||||
}\ |
||||
.ace_search.left {\ |
||||
border-left: 0 none;\ |
||||
border-radius: 0px 0px 5px 0px;\ |
||||
left: 0;\ |
||||
}\ |
||||
.ace_search.right {\ |
||||
border-radius: 0px 0px 0px 5px;\ |
||||
border-right: 0 none;\ |
||||
right: 0;\ |
||||
}\ |
||||
.ace_search_form, .ace_replace_form {\ |
||||
border-radius: 3px;\ |
||||
border: 1px solid #cbcbcb;\ |
||||
float: left;\ |
||||
margin-bottom: 4px;\ |
||||
overflow: hidden;\ |
||||
}\ |
||||
.ace_search_form.ace_nomatch {\ |
||||
outline: 1px solid red;\ |
||||
}\ |
||||
.ace_search_field {\ |
||||
background-color: white;\ |
||||
border-right: 1px solid #cbcbcb;\ |
||||
border: 0 none;\ |
||||
-webkit-box-sizing: border-box;\ |
||||
-moz-box-sizing: border-box;\ |
||||
box-sizing: border-box;\ |
||||
float: left;\ |
||||
height: 22px;\ |
||||
outline: 0;\ |
||||
padding: 0 7px;\ |
||||
width: 214px;\ |
||||
margin: 0;\ |
||||
}\ |
||||
.ace_searchbtn,\ |
||||
.ace_replacebtn {\ |
||||
background: #fff;\ |
||||
border: 0 none;\ |
||||
border-left: 1px solid #dcdcdc;\ |
||||
cursor: pointer;\ |
||||
float: left;\ |
||||
height: 22px;\ |
||||
margin: 0;\ |
||||
padding: 0;\ |
||||
position: relative;\ |
||||
}\ |
||||
.ace_searchbtn:last-child,\ |
||||
.ace_replacebtn:last-child {\ |
||||
border-top-right-radius: 3px;\ |
||||
border-bottom-right-radius: 3px;\ |
||||
}\ |
||||
.ace_searchbtn:disabled {\ |
||||
background: none;\ |
||||
cursor: default;\ |
||||
}\ |
||||
.ace_searchbtn {\ |
||||
background-position: 50% 50%;\ |
||||
background-repeat: no-repeat;\ |
||||
width: 27px;\ |
||||
}\ |
||||
.ace_searchbtn.prev {\ |
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); \ |
||||
}\ |
||||
.ace_searchbtn.next {\ |
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); \ |
||||
}\ |
||||
.ace_searchbtn_close {\ |
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\ |
||||
border-radius: 50%;\ |
||||
border: 0 none;\ |
||||
color: #656565;\ |
||||
cursor: pointer;\ |
||||
float: right;\ |
||||
font: 16px/16px Arial;\ |
||||
height: 14px;\ |
||||
margin: 5px 1px 9px 5px;\ |
||||
padding: 0;\ |
||||
text-align: center;\ |
||||
width: 14px;\ |
||||
}\ |
||||
.ace_searchbtn_close:hover {\ |
||||
background-color: #656565;\ |
||||
background-position: 50% 100%;\ |
||||
color: white;\ |
||||
}\ |
||||
.ace_replacebtn.prev {\ |
||||
width: 54px\ |
||||
}\ |
||||
.ace_replacebtn.next {\ |
||||
width: 27px\ |
||||
}\ |
||||
.ace_button {\ |
||||
margin-left: 2px;\ |
||||
cursor: pointer;\ |
||||
-webkit-user-select: none;\ |
||||
-moz-user-select: none;\ |
||||
-o-user-select: none;\ |
||||
-ms-user-select: none;\ |
||||
user-select: none;\ |
||||
overflow: hidden;\ |
||||
opacity: 0.7;\ |
||||
border: 1px solid rgba(100,100,100,0.23);\ |
||||
padding: 1px;\ |
||||
-moz-box-sizing: border-box;\ |
||||
box-sizing: border-box;\ |
||||
color: black;\ |
||||
}\ |
||||
.ace_button:hover {\ |
||||
background-color: #eee;\ |
||||
opacity:1;\ |
||||
}\ |
||||
.ace_button:active {\ |
||||
background-color: #ddd;\ |
||||
}\ |
||||
.ace_button.checked {\ |
||||
border-color: #3399ff;\ |
||||
opacity:1;\ |
||||
}\ |
||||
.ace_search_options{\ |
||||
margin-bottom: 3px;\ |
||||
text-align: right;\ |
||||
-webkit-user-select: none;\ |
||||
-moz-user-select: none;\ |
||||
-o-user-select: none;\ |
||||
-ms-user-select: none;\ |
||||
user-select: none;\ |
||||
}"; |
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler; |
||||
var keyUtil = require("../lib/keys"); |
||||
|
||||
dom.importCssString(searchboxCss, "ace_searchbox"); |
||||
|
||||
var html = '<div class="ace_search right">\ |
||||
<button type="button" action="hide" class="ace_searchbtn_close"></button>\ |
||||
<div class="ace_search_form">\ |
||||
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\ |
||||
<button type="button" action="findNext" class="ace_searchbtn next"></button>\ |
||||
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\ |
||||
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\ |
||||
</div>\ |
||||
<div class="ace_replace_form">\ |
||||
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\ |
||||
<button type="button" action="replaceAndFindNext" class="ace_replacebtn">Replace</button>\ |
||||
<button type="button" action="replaceAll" class="ace_replacebtn">All</button>\ |
||||
</div>\ |
||||
<div class="ace_search_options">\ |
||||
<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>\ |
||||
<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>\ |
||||
<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>\ |
||||
</div>\ |
||||
</div>'.replace(/>\s+/g, ">"); |
||||
|
||||
var SearchBox = function(editor, range, showReplaceForm) { |
||||
var div = dom.createElement("div"); |
||||
div.innerHTML = html; |
||||
this.element = div.firstChild; |
||||
|
||||
this.$init(); |
||||
this.setEditor(editor); |
||||
}; |
||||
|
||||
(function() { |
||||
this.setEditor = function(editor) { |
||||
editor.searchBox = this; |
||||
editor.container.appendChild(this.element); |
||||
this.editor = editor; |
||||
}; |
||||
|
||||
this.$initElements = function(sb) { |
||||
this.searchBox = sb.querySelector(".ace_search_form"); |
||||
this.replaceBox = sb.querySelector(".ace_replace_form"); |
||||
this.searchOptions = sb.querySelector(".ace_search_options"); |
||||
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]"); |
||||
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]"); |
||||
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); |
||||
this.searchInput = this.searchBox.querySelector(".ace_search_field"); |
||||
this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); |
||||
}; |
||||
|
||||
this.$init = function() { |
||||
var sb = this.element; |
||||
|
||||
this.$initElements(sb); |
||||
|
||||
var _this = this; |
||||
event.addListener(sb, "mousedown", function(e) { |
||||
setTimeout(function(){ |
||||
_this.activeInput.focus(); |
||||
}, 0); |
||||
event.stopPropagation(e); |
||||
}); |
||||
event.addListener(sb, "click", function(e) { |
||||
var t = e.target || e.srcElement; |
||||
var action = t.getAttribute("action"); |
||||
if (action && _this[action]) |
||||
_this[action](); |
||||
else if (_this.$searchBarKb.commands[action]) |
||||
_this.$searchBarKb.commands[action].exec(_this); |
||||
event.stopPropagation(e); |
||||
}); |
||||
|
||||
event.addCommandKeyListener(sb, function(e, hashId, keyCode) { |
||||
var keyString = keyUtil.keyCodeToString(keyCode); |
||||
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString); |
||||
if (command && command.exec) { |
||||
command.exec(_this); |
||||
event.stopEvent(e); |
||||
} |
||||
}); |
||||
|
||||
this.$onChange = lang.delayedCall(function() { |
||||
_this.find(false, false); |
||||
}); |
||||
|
||||
event.addListener(this.searchInput, "input", function() { |
||||
_this.$onChange.schedule(20); |
||||
}); |
||||
event.addListener(this.searchInput, "focus", function() { |
||||
_this.activeInput = _this.searchInput; |
||||
_this.searchInput.value && _this.highlight(); |
||||
}); |
||||
event.addListener(this.replaceInput, "focus", function() { |
||||
_this.activeInput = _this.replaceInput; |
||||
_this.searchInput.value && _this.highlight(); |
||||
}); |
||||
}; |
||||
this.$closeSearchBarKb = new HashHandler([{ |
||||
bindKey: "Esc", |
||||
name: "closeSearchBar", |
||||
exec: function(editor) { |
||||
editor.searchBox.hide(); |
||||
} |
||||
}]); |
||||
this.$searchBarKb = new HashHandler(); |
||||
this.$searchBarKb.bindKeys({ |
||||
"Ctrl-f|Command-f|Ctrl-H|Command-Option-F": function(sb) { |
||||
var isReplace = sb.isReplace = !sb.isReplace; |
||||
sb.replaceBox.style.display = isReplace ? "" : "none"; |
||||
sb[isReplace ? "replaceInput" : "searchInput"].focus(); |
||||
}, |
||||
"Ctrl-G|Command-G": function(sb) { |
||||
sb.findNext(); |
||||
}, |
||||
"Ctrl-Shift-G|Command-Shift-G": function(sb) { |
||||
sb.findPrev(); |
||||
}, |
||||
"esc": function(sb) { |
||||
setTimeout(function() { sb.hide();}); |
||||
}, |
||||
"Return": function(sb) { |
||||
if (sb.activeInput == sb.replaceInput) |
||||
sb.replace(); |
||||
sb.findNext(); |
||||
}, |
||||
"Shift-Return": function(sb) { |
||||
if (sb.activeInput == sb.replaceInput) |
||||
sb.replace(); |
||||
sb.findPrev(); |
||||
}, |
||||
"Alt-Return": function(sb) { |
||||
if (sb.activeInput == sb.replaceInput) |
||||
sb.replaceAll(); |
||||
sb.findAll(); |
||||
}, |
||||
"Tab": function(sb) { |
||||
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus(); |
||||
} |
||||
}); |
||||
|
||||
this.$searchBarKb.addCommands([{ |
||||
name: "toggleRegexpMode", |
||||
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"}, |
||||
exec: function(sb) { |
||||
sb.regExpOption.checked = !sb.regExpOption.checked; |
||||
sb.$syncOptions(); |
||||
} |
||||
}, { |
||||
name: "toggleCaseSensitive", |
||||
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"}, |
||||
exec: function(sb) { |
||||
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked; |
||||
sb.$syncOptions(); |
||||
} |
||||
}, { |
||||
name: "toggleWholeWords", |
||||
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"}, |
||||
exec: function(sb) { |
||||
sb.wholeWordOption.checked = !sb.wholeWordOption.checked; |
||||
sb.$syncOptions(); |
||||
} |
||||
}]); |
||||
|
||||
this.$syncOptions = function() { |
||||
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked); |
||||
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked); |
||||
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked); |
||||
this.find(false, false); |
||||
}; |
||||
|
||||
this.highlight = function(re) { |
||||
this.editor.session.highlight(re || this.editor.$search.$options.re); |
||||
this.editor.renderer.updateBackMarkers() |
||||
}; |
||||
this.find = function(skipCurrent, backwards) { |
||||
var range = this.editor.find(this.searchInput.value, { |
||||
skipCurrent: skipCurrent, |
||||
backwards: backwards, |
||||
wrap: true, |
||||
regExp: this.regExpOption.checked, |
||||
caseSensitive: this.caseSensitiveOption.checked, |
||||
wholeWord: this.wholeWordOption.checked |
||||
}); |
||||
var noMatch = !range && this.searchInput.value; |
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); |
||||
this.editor._emit("findSearchBox", { match: !noMatch }); |
||||
this.highlight(); |
||||
}; |
||||
this.findNext = function() { |
||||
this.find(true, false); |
||||
}; |
||||
this.findPrev = function() { |
||||
this.find(true, true); |
||||
}; |
||||
this.findAll = function(){ |
||||
var range = this.editor.findAll(this.searchInput.value, {
|
||||
regExp: this.regExpOption.checked, |
||||
caseSensitive: this.caseSensitiveOption.checked, |
||||
wholeWord: this.wholeWordOption.checked |
||||
}); |
||||
var noMatch = !range && this.searchInput.value; |
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); |
||||
this.editor._emit("findSearchBox", { match: !noMatch }); |
||||
this.highlight(); |
||||
this.hide(); |
||||
}; |
||||
this.replace = function() { |
||||
if (!this.editor.getReadOnly()) |
||||
this.editor.replace(this.replaceInput.value); |
||||
};
|
||||
this.replaceAndFindNext = function() { |
||||
if (!this.editor.getReadOnly()) { |
||||
this.editor.replace(this.replaceInput.value); |
||||
this.findNext() |
||||
} |
||||
}; |
||||
this.replaceAll = function() { |
||||
if (!this.editor.getReadOnly()) |
||||
this.editor.replaceAll(this.replaceInput.value); |
||||
}; |
||||
|
||||
this.hide = function() { |
||||
this.element.style.display = "none"; |
||||
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb); |
||||
this.editor.focus(); |
||||
}; |
||||
this.show = function(value, isReplace) { |
||||
this.element.style.display = ""; |
||||
this.replaceBox.style.display = isReplace ? "" : "none"; |
||||
|
||||
this.isReplace = isReplace; |
||||
|
||||
if (value) |
||||
this.searchInput.value = value; |
||||
this.searchInput.focus(); |
||||
this.searchInput.select(); |
||||
|
||||
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb); |
||||
}; |
||||
|
||||
this.isFocused = function() { |
||||
var el = document.activeElement; |
||||
return el == this.searchInput || el == this.replaceInput; |
||||
} |
||||
}).call(SearchBox.prototype); |
||||
|
||||
exports.SearchBox = SearchBox; |
||||
|
||||
exports.Search = function(editor, isReplace) { |
||||
var sb = editor.searchBox || new SearchBox(editor); |
||||
sb.show(editor.session.getTextRange(), isReplace); |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/old_ie",["require","exports","module","ace/lib/useragent","ace/tokenizer","ace/ext/searchbox","ace/mode/text"], function(require, exports, module) { |
||||
"use strict"; |
||||
var MAX_TOKEN_COUNT = 1000; |
||||
var useragent = require("../lib/useragent"); |
||||
var TokenizerModule = require("../tokenizer"); |
||||
|
||||
function patch(obj, name, regexp, replacement) { |
||||
eval("obj['" + name + "']=" + obj[name].toString().replace( |
||||
regexp, replacement |
||||
)); |
||||
} |
||||
|
||||
if (useragent.isIE && useragent.isIE < 10 && window.top.document.compatMode === "BackCompat") |
||||
useragent.isOldIE = true; |
||||
|
||||
if (typeof document != "undefined" && !document.documentElement.querySelector) {
|
||||
useragent.isOldIE = true; |
||||
var qs = function(el, selector) { |
||||
if (selector.charAt(0) == ".") { |
||||
var classNeme = selector.slice(1); |
||||
} else { |
||||
var m = selector.match(/(\w+)=(\w+)/); |
||||
var attr = m && m[1]; |
||||
var attrVal = m && m[2]; |
||||
} |
||||
for (var i = 0; i < el.all.length; i++) { |
||||
var ch = el.all[i]; |
||||
if (classNeme) { |
||||
if (ch.className.indexOf(classNeme) != -1) |
||||
return ch; |
||||
} else if (attr) { |
||||
if (ch.getAttribute(attr) == attrVal) |
||||
return ch; |
||||
} |
||||
} |
||||
}; |
||||
var sb = require("./searchbox").SearchBox.prototype; |
||||
patch( |
||||
sb, "$initElements", |
||||
/([^\s=]*).querySelector\((".*?")\)/g,
|
||||
"qs($1, $2)" |
||||
); |
||||
} |
||||
|
||||
var compliantExecNpcg = /()??/.exec("")[1] === undefined; |
||||
if (compliantExecNpcg) |
||||
return; |
||||
var proto = TokenizerModule.Tokenizer.prototype; |
||||
TokenizerModule.Tokenizer_orig = TokenizerModule.Tokenizer; |
||||
proto.getLineTokens_orig = proto.getLineTokens; |
||||
|
||||
patch( |
||||
TokenizerModule, "Tokenizer", |
||||
"ruleRegExps.push(adjustedregex);\n",
|
||||
function(m) { |
||||
return m + '\ |
||||
if (state[i].next && RegExp(adjustedregex).test(""))\n\ |
||||
rule._qre = RegExp(adjustedregex, "g");\n\ |
||||
'; |
||||
} |
||||
); |
||||
TokenizerModule.Tokenizer.prototype = proto; |
||||
patch( |
||||
proto, "getLineTokens", |
||||
/if \(match\[i \+ 1\] === undefined\)\s*continue;/,
|
||||
"if (!match[i + 1]) {\n\ |
||||
if (value)continue;\n\ |
||||
var qre = state[mapping[i]]._qre;\n\ |
||||
if (!qre) continue;\n\ |
||||
qre.lastIndex = lastIndex;\n\ |
||||
if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\ |
||||
continue;\n\ |
||||
}" |
||||
); |
||||
|
||||
patch( |
||||
require("../mode/text").Mode.prototype, "getTokenizer", |
||||
/Tokenizer/, |
||||
"TokenizerModule.Tokenizer" |
||||
); |
||||
|
||||
useragent.isOldIE = true; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/old_ie"], function() {}); |
||||
})(); |
||||
|
@ -1,409 +0,0 @@
|
||||
ace.define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var dom = require("../lib/dom"); |
||||
var lang = require("../lib/lang"); |
||||
var event = require("../lib/event"); |
||||
var searchboxCss = "\ |
||||
.ace_search {\ |
||||
background-color: #ddd;\ |
||||
border: 1px solid #cbcbcb;\ |
||||
border-top: 0 none;\ |
||||
max-width: 325px;\ |
||||
overflow: hidden;\ |
||||
margin: 0;\ |
||||
padding: 4px;\ |
||||
padding-right: 6px;\ |
||||
padding-bottom: 0;\ |
||||
position: absolute;\ |
||||
top: 0px;\ |
||||
z-index: 99;\ |
||||
white-space: normal;\ |
||||
}\ |
||||
.ace_search.left {\ |
||||
border-left: 0 none;\ |
||||
border-radius: 0px 0px 5px 0px;\ |
||||
left: 0;\ |
||||
}\ |
||||
.ace_search.right {\ |
||||
border-radius: 0px 0px 0px 5px;\ |
||||
border-right: 0 none;\ |
||||
right: 0;\ |
||||
}\ |
||||
.ace_search_form, .ace_replace_form {\ |
||||
border-radius: 3px;\ |
||||
border: 1px solid #cbcbcb;\ |
||||
float: left;\ |
||||
margin-bottom: 4px;\ |
||||
overflow: hidden;\ |
||||
}\ |
||||
.ace_search_form.ace_nomatch {\ |
||||
outline: 1px solid red;\ |
||||
}\ |
||||
.ace_search_field {\ |
||||
background-color: white;\ |
||||
border-right: 1px solid #cbcbcb;\ |
||||
border: 0 none;\ |
||||
-webkit-box-sizing: border-box;\ |
||||
-moz-box-sizing: border-box;\ |
||||
box-sizing: border-box;\ |
||||
float: left;\ |
||||
height: 22px;\ |
||||
outline: 0;\ |
||||
padding: 0 7px;\ |
||||
width: 214px;\ |
||||
margin: 0;\ |
||||
}\ |
||||
.ace_searchbtn,\ |
||||
.ace_replacebtn {\ |
||||
background: #fff;\ |
||||
border: 0 none;\ |
||||
border-left: 1px solid #dcdcdc;\ |
||||
cursor: pointer;\ |
||||
float: left;\ |
||||
height: 22px;\ |
||||
margin: 0;\ |
||||
padding: 0;\ |
||||
position: relative;\ |
||||
}\ |
||||
.ace_searchbtn:last-child,\ |
||||
.ace_replacebtn:last-child {\ |
||||
border-top-right-radius: 3px;\ |
||||
border-bottom-right-radius: 3px;\ |
||||
}\ |
||||
.ace_searchbtn:disabled {\ |
||||
background: none;\ |
||||
cursor: default;\ |
||||
}\ |
||||
.ace_searchbtn {\ |
||||
background-position: 50% 50%;\ |
||||
background-repeat: no-repeat;\ |
||||
width: 27px;\ |
||||
}\ |
||||
.ace_searchbtn.prev {\ |
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); \ |
||||
}\ |
||||
.ace_searchbtn.next {\ |
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); \ |
||||
}\ |
||||
.ace_searchbtn_close {\ |
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\ |
||||
border-radius: 50%;\ |
||||
border: 0 none;\ |
||||
color: #656565;\ |
||||
cursor: pointer;\ |
||||
float: right;\ |
||||
font: 16px/16px Arial;\ |
||||
height: 14px;\ |
||||
margin: 5px 1px 9px 5px;\ |
||||
padding: 0;\ |
||||
text-align: center;\ |
||||
width: 14px;\ |
||||
}\ |
||||
.ace_searchbtn_close:hover {\ |
||||
background-color: #656565;\ |
||||
background-position: 50% 100%;\ |
||||
color: white;\ |
||||
}\ |
||||
.ace_replacebtn.prev {\ |
||||
width: 54px\ |
||||
}\ |
||||
.ace_replacebtn.next {\ |
||||
width: 27px\ |
||||
}\ |
||||
.ace_button {\ |
||||
margin-left: 2px;\ |
||||
cursor: pointer;\ |
||||
-webkit-user-select: none;\ |
||||
-moz-user-select: none;\ |
||||
-o-user-select: none;\ |
||||
-ms-user-select: none;\ |
||||
user-select: none;\ |
||||
overflow: hidden;\ |
||||
opacity: 0.7;\ |
||||
border: 1px solid rgba(100,100,100,0.23);\ |
||||
padding: 1px;\ |
||||
-moz-box-sizing: border-box;\ |
||||
box-sizing: border-box;\ |
||||
color: black;\ |
||||
}\ |
||||
.ace_button:hover {\ |
||||
background-color: #eee;\ |
||||
opacity:1;\ |
||||
}\ |
||||
.ace_button:active {\ |
||||
background-color: #ddd;\ |
||||
}\ |
||||
.ace_button.checked {\ |
||||
border-color: #3399ff;\ |
||||
opacity:1;\ |
||||
}\ |
||||
.ace_search_options{\ |
||||
margin-bottom: 3px;\ |
||||
text-align: right;\ |
||||
-webkit-user-select: none;\ |
||||
-moz-user-select: none;\ |
||||
-o-user-select: none;\ |
||||
-ms-user-select: none;\ |
||||
user-select: none;\ |
||||
}"; |
||||
var HashHandler = require("../keyboard/hash_handler").HashHandler; |
||||
var keyUtil = require("../lib/keys"); |
||||
|
||||
dom.importCssString(searchboxCss, "ace_searchbox"); |
||||
|
||||
var html = '<div class="ace_search right">\ |
||||
<button type="button" action="hide" class="ace_searchbtn_close"></button>\ |
||||
<div class="ace_search_form">\ |
||||
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\ |
||||
<button type="button" action="findNext" class="ace_searchbtn next"></button>\ |
||||
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\ |
||||
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\ |
||||
</div>\ |
||||
<div class="ace_replace_form">\ |
||||
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\ |
||||
<button type="button" action="replaceAndFindNext" class="ace_replacebtn">Replace</button>\ |
||||
<button type="button" action="replaceAll" class="ace_replacebtn">All</button>\ |
||||
</div>\ |
||||
<div class="ace_search_options">\ |
||||
<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>\ |
||||
<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>\ |
||||
<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>\ |
||||
</div>\ |
||||
</div>'.replace(/>\s+/g, ">"); |
||||
|
||||
var SearchBox = function(editor, range, showReplaceForm) { |
||||
var div = dom.createElement("div"); |
||||
div.innerHTML = html; |
||||
this.element = div.firstChild; |
||||
|
||||
this.$init(); |
||||
this.setEditor(editor); |
||||
}; |
||||
|
||||
(function() { |
||||
this.setEditor = function(editor) { |
||||
editor.searchBox = this; |
||||
editor.container.appendChild(this.element); |
||||
this.editor = editor; |
||||
}; |
||||
|
||||
this.$initElements = function(sb) { |
||||
this.searchBox = sb.querySelector(".ace_search_form"); |
||||
this.replaceBox = sb.querySelector(".ace_replace_form"); |
||||
this.searchOptions = sb.querySelector(".ace_search_options"); |
||||
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]"); |
||||
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]"); |
||||
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); |
||||
this.searchInput = this.searchBox.querySelector(".ace_search_field"); |
||||
this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); |
||||
}; |
||||
|
||||
this.$init = function() { |
||||
var sb = this.element; |
||||
|
||||
this.$initElements(sb); |
||||
|
||||
var _this = this; |
||||
event.addListener(sb, "mousedown", function(e) { |
||||
setTimeout(function(){ |
||||
_this.activeInput.focus(); |
||||
}, 0); |
||||
event.stopPropagation(e); |
||||
}); |
||||
event.addListener(sb, "click", function(e) { |
||||
var t = e.target || e.srcElement; |
||||
var action = t.getAttribute("action"); |
||||
if (action && _this[action]) |
||||
_this[action](); |
||||
else if (_this.$searchBarKb.commands[action]) |
||||
_this.$searchBarKb.commands[action].exec(_this); |
||||
event.stopPropagation(e); |
||||
}); |
||||
|
||||
event.addCommandKeyListener(sb, function(e, hashId, keyCode) { |
||||
var keyString = keyUtil.keyCodeToString(keyCode); |
||||
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString); |
||||
if (command && command.exec) { |
||||
command.exec(_this); |
||||
event.stopEvent(e); |
||||
} |
||||
}); |
||||
|
||||
this.$onChange = lang.delayedCall(function() { |
||||
_this.find(false, false); |
||||
}); |
||||
|
||||
event.addListener(this.searchInput, "input", function() { |
||||
_this.$onChange.schedule(20); |
||||
}); |
||||
event.addListener(this.searchInput, "focus", function() { |
||||
_this.activeInput = _this.searchInput; |
||||
_this.searchInput.value && _this.highlight(); |
||||
}); |
||||
event.addListener(this.replaceInput, "focus", function() { |
||||
_this.activeInput = _this.replaceInput; |
||||
_this.searchInput.value && _this.highlight(); |
||||
}); |
||||
}; |
||||
this.$closeSearchBarKb = new HashHandler([{ |
||||
bindKey: "Esc", |
||||
name: "closeSearchBar", |
||||
exec: function(editor) { |
||||
editor.searchBox.hide(); |
||||
} |
||||
}]); |
||||
this.$searchBarKb = new HashHandler(); |
||||
this.$searchBarKb.bindKeys({ |
||||
"Ctrl-f|Command-f|Ctrl-H|Command-Option-F": function(sb) { |
||||
var isReplace = sb.isReplace = !sb.isReplace; |
||||
sb.replaceBox.style.display = isReplace ? "" : "none"; |
||||
sb[isReplace ? "replaceInput" : "searchInput"].focus(); |
||||
}, |
||||
"Ctrl-G|Command-G": function(sb) { |
||||
sb.findNext(); |
||||
}, |
||||
"Ctrl-Shift-G|Command-Shift-G": function(sb) { |
||||
sb.findPrev(); |
||||
}, |
||||
"esc": function(sb) { |
||||
setTimeout(function() { sb.hide();}); |
||||
}, |
||||
"Return": function(sb) { |
||||
if (sb.activeInput == sb.replaceInput) |
||||
sb.replace(); |
||||
sb.findNext(); |
||||
}, |
||||
"Shift-Return": function(sb) { |
||||
if (sb.activeInput == sb.replaceInput) |
||||
sb.replace(); |
||||
sb.findPrev(); |
||||
}, |
||||
"Alt-Return": function(sb) { |
||||
if (sb.activeInput == sb.replaceInput) |
||||
sb.replaceAll(); |
||||
sb.findAll(); |
||||
}, |
||||
"Tab": function(sb) { |
||||
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus(); |
||||
} |
||||
}); |
||||
|
||||
this.$searchBarKb.addCommands([{ |
||||
name: "toggleRegexpMode", |
||||
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"}, |
||||
exec: function(sb) { |
||||
sb.regExpOption.checked = !sb.regExpOption.checked; |
||||
sb.$syncOptions(); |
||||
} |
||||
}, { |
||||
name: "toggleCaseSensitive", |
||||
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"}, |
||||
exec: function(sb) { |
||||
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked; |
||||
sb.$syncOptions(); |
||||
} |
||||
}, { |
||||
name: "toggleWholeWords", |
||||
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"}, |
||||
exec: function(sb) { |
||||
sb.wholeWordOption.checked = !sb.wholeWordOption.checked; |
||||
sb.$syncOptions(); |
||||
} |
||||
}]); |
||||
|
||||
this.$syncOptions = function() { |
||||
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked); |
||||
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked); |
||||
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked); |
||||
this.find(false, false); |
||||
}; |
||||
|
||||
this.highlight = function(re) { |
||||
this.editor.session.highlight(re || this.editor.$search.$options.re); |
||||
this.editor.renderer.updateBackMarkers() |
||||
}; |
||||
this.find = function(skipCurrent, backwards) { |
||||
var range = this.editor.find(this.searchInput.value, { |
||||
skipCurrent: skipCurrent, |
||||
backwards: backwards, |
||||
wrap: true, |
||||
regExp: this.regExpOption.checked, |
||||
caseSensitive: this.caseSensitiveOption.checked, |
||||
wholeWord: this.wholeWordOption.checked |
||||
}); |
||||
var noMatch = !range && this.searchInput.value; |
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); |
||||
this.editor._emit("findSearchBox", { match: !noMatch }); |
||||
this.highlight(); |
||||
}; |
||||
this.findNext = function() { |
||||
this.find(true, false); |
||||
}; |
||||
this.findPrev = function() { |
||||
this.find(true, true); |
||||
}; |
||||
this.findAll = function(){ |
||||
var range = this.editor.findAll(this.searchInput.value, {
|
||||
regExp: this.regExpOption.checked, |
||||
caseSensitive: this.caseSensitiveOption.checked, |
||||
wholeWord: this.wholeWordOption.checked |
||||
}); |
||||
var noMatch = !range && this.searchInput.value; |
||||
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); |
||||
this.editor._emit("findSearchBox", { match: !noMatch }); |
||||
this.highlight(); |
||||
this.hide(); |
||||
}; |
||||
this.replace = function() { |
||||
if (!this.editor.getReadOnly()) |
||||
this.editor.replace(this.replaceInput.value); |
||||
};
|
||||
this.replaceAndFindNext = function() { |
||||
if (!this.editor.getReadOnly()) { |
||||
this.editor.replace(this.replaceInput.value); |
||||
this.findNext() |
||||
} |
||||
}; |
||||
this.replaceAll = function() { |
||||
if (!this.editor.getReadOnly()) |
||||
this.editor.replaceAll(this.replaceInput.value); |
||||
}; |
||||
|
||||
this.hide = function() { |
||||
this.element.style.display = "none"; |
||||
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb); |
||||
this.editor.focus(); |
||||
}; |
||||
this.show = function(value, isReplace) { |
||||
this.element.style.display = ""; |
||||
this.replaceBox.style.display = isReplace ? "" : "none"; |
||||
|
||||
this.isReplace = isReplace; |
||||
|
||||
if (value) |
||||
this.searchInput.value = value; |
||||
this.searchInput.focus(); |
||||
this.searchInput.select(); |
||||
|
||||
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb); |
||||
}; |
||||
|
||||
this.isFocused = function() { |
||||
var el = document.activeElement; |
||||
return el == this.searchInput || el == this.replaceInput; |
||||
} |
||||
}).call(SearchBox.prototype); |
||||
|
||||
exports.SearchBox = SearchBox; |
||||
|
||||
exports.Search = function(editor, isReplace) { |
||||
var sb = editor.searchBox || new SearchBox(editor); |
||||
sb.show(editor.session.getTextRange(), isReplace); |
||||
}; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/searchbox"], function() {}); |
||||
})(); |
||||
|
@ -1,643 +0,0 @@
|
||||
ace.define("ace/ext/menu_tools/element_generator",["require","exports","module"], function(require, exports, module) { |
||||
'use strict'; |
||||
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; |
||||
}; |
||||
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; |
||||
}; |
||||
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; |
||||
}; |
||||
module.exports.createLabel = function createLabel (text, labelFor) { |
||||
var el = document.createElement('label'); |
||||
el.setAttribute('for', labelFor); |
||||
el.textContent = text; |
||||
return el; |
||||
}; |
||||
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; |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var modes = []; |
||||
function getModeForPath(path) { |
||||
var mode = modesByName.text; |
||||
var fileName = path.split(/[\/\\]/).pop(); |
||||
for (var i = 0; i < modes.length; i++) { |
||||
if (modes[i].supportsFile(fileName)) { |
||||
mode = modes[i]; |
||||
break; |
||||
} |
||||
} |
||||
return mode; |
||||
} |
||||
|
||||
var Mode = function(name, caption, extensions) { |
||||
this.name = name; |
||||
this.caption = caption; |
||||
this.mode = "ace/mode/" + name; |
||||
this.extensions = extensions; |
||||
if (/\^/.test(extensions)) { |
||||
var re = extensions.replace(/\|(\^)?/g, function(a, b){ |
||||
return "$|" + (b ? "^" : "^.*\\."); |
||||
}) + "$"; |
||||
} else { |
||||
var re = "^.*\\.(" + extensions + ")$"; |
||||
} |
||||
|
||||
this.extRe = new RegExp(re, "gi"); |
||||
}; |
||||
|
||||
Mode.prototype.supportsFile = function(filename) { |
||||
return filename.match(this.extRe); |
||||
}; |
||||
var supportedModes = { |
||||
ABAP: ["abap"], |
||||
ABC: ["abc"], |
||||
ActionScript:["as"], |
||||
ADA: ["ada|adb"], |
||||
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], |
||||
AsciiDoc: ["asciidoc|adoc"], |
||||
Assembly_x86:["asm"], |
||||
AutoHotKey: ["ahk"], |
||||
BatchFile: ["bat|cmd"], |
||||
C9Search: ["c9search_results"], |
||||
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"], |
||||
Cirru: ["cirru|cr"], |
||||
Clojure: ["clj|cljs"], |
||||
Cobol: ["CBL|COB"], |
||||
coffee: ["coffee|cf|cson|^Cakefile"], |
||||
ColdFusion: ["cfm"], |
||||
CSharp: ["cs"], |
||||
CSS: ["css"], |
||||
Curly: ["curly"], |
||||
D: ["d|di"], |
||||
Dart: ["dart"], |
||||
Diff: ["diff|patch"], |
||||
Dockerfile: ["^Dockerfile"], |
||||
Dot: ["dot"], |
||||
Dummy: ["dummy"], |
||||
DummySyntax: ["dummy"], |
||||
Eiffel: ["e"], |
||||
EJS: ["ejs"], |
||||
Elixir: ["ex|exs"], |
||||
Elm: ["elm"], |
||||
Erlang: ["erl|hrl"], |
||||
Forth: ["frt|fs|ldr"], |
||||
FTL: ["ftl"], |
||||
Gcode: ["gcode"], |
||||
Gherkin: ["feature"], |
||||
Gitignore: ["^.gitignore"], |
||||
Glsl: ["glsl|frag|vert"], |
||||
golang: ["go"], |
||||
Groovy: ["groovy"], |
||||
HAML: ["haml"], |
||||
Handlebars: ["hbs|handlebars|tpl|mustache"], |
||||
Haskell: ["hs"], |
||||
haXe: ["hx"], |
||||
HTML: ["html|htm|xhtml"], |
||||
HTML_Ruby: ["erb|rhtml|html.erb"], |
||||
INI: ["ini|conf|cfg|prefs"], |
||||
Io: ["io"], |
||||
Jack: ["jack"], |
||||
Jade: ["jade"], |
||||
Java: ["java"], |
||||
JavaScript: ["js|jsm"], |
||||
JSON: ["json"], |
||||
JSONiq: ["jq"], |
||||
JSP: ["jsp"], |
||||
JSX: ["jsx"], |
||||
Julia: ["jl"], |
||||
LaTeX: ["tex|latex|ltx|bib"], |
||||
Lean: ["lean|hlean"], |
||||
LESS: ["less"], |
||||
Liquid: ["liquid"], |
||||
Lisp: ["lisp"], |
||||
LiveScript: ["ls"], |
||||
LogiQL: ["logic|lql"], |
||||
LSL: ["lsl"], |
||||
Lua: ["lua"], |
||||
LuaPage: ["lp"], |
||||
Lucene: ["lucene"], |
||||
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], |
||||
Markdown: ["md|markdown"], |
||||
Mask: ["mask"], |
||||
MATLAB: ["matlab"], |
||||
MEL: ["mel"], |
||||
MUSHCode: ["mc|mush"], |
||||
MySQL: ["mysql"], |
||||
Nix: ["nix"], |
||||
ObjectiveC: ["m|mm"], |
||||
OCaml: ["ml|mli"], |
||||
Pascal: ["pas|p"], |
||||
Perl: ["pl|pm"], |
||||
pgSQL: ["pgsql"], |
||||
PHP: ["php|phtml"], |
||||
Powershell: ["ps1"], |
||||
Praat: ["praat|praatscript|psc|proc"], |
||||
Prolog: ["plg|prolog"], |
||||
Properties: ["properties"], |
||||
Protobuf: ["proto"], |
||||
Python: ["py"], |
||||
R: ["r"], |
||||
RDoc: ["Rd"], |
||||
RHTML: ["Rhtml"], |
||||
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], |
||||
Rust: ["rs"], |
||||
SASS: ["sass"], |
||||
SCAD: ["scad"], |
||||
Scala: ["scala"], |
||||
Scheme: ["scm|rkt"], |
||||
SCSS: ["scss"], |
||||
SH: ["sh|bash|^.bashrc"], |
||||
SJS: ["sjs"], |
||||
Smarty: ["smarty|tpl"], |
||||
snippets: ["snippets"], |
||||
Soy_Template:["soy"], |
||||
Space: ["space"], |
||||
SQL: ["sql"], |
||||
SQLServer: ["sqlserver"], |
||||
Stylus: ["styl|stylus"], |
||||
SVG: ["svg"], |
||||
Tcl: ["tcl"], |
||||
Tex: ["tex"], |
||||
Text: ["txt"], |
||||
Textile: ["textile"], |
||||
Toml: ["toml"], |
||||
Twig: ["twig"], |
||||
Typescript: ["ts|typescript|str"], |
||||
Vala: ["vala"], |
||||
VBScript: ["vbs|vb"], |
||||
Velocity: ["vm"], |
||||
Verilog: ["v|vh|sv|svh"], |
||||
VHDL: ["vhd|vhdl"], |
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], |
||||
XQuery: ["xq"], |
||||
YAML: ["yaml|yml"], |
||||
Django: ["html"] |
||||
}; |
||||
|
||||
var nameOverrides = { |
||||
ObjectiveC: "Objective-C", |
||||
CSharp: "C#", |
||||
golang: "Go", |
||||
C_Cpp: "C and C++", |
||||
coffee: "CoffeeScript", |
||||
HTML_Ruby: "HTML (Ruby)", |
||||
FTL: "FreeMarker" |
||||
}; |
||||
var modesByName = {}; |
||||
for (var name in supportedModes) { |
||||
var data = supportedModes[name]; |
||||
var displayName = (nameOverrides[name] || name).replace(/_/g, " "); |
||||
var filename = name.toLowerCase(); |
||||
var mode = new Mode(filename, displayName, data[0]); |
||||
modesByName[filename] = mode; |
||||
modes.push(mode); |
||||
} |
||||
|
||||
module.exports = { |
||||
getModeForPath: getModeForPath, |
||||
modes: modes, |
||||
modesByName: modesByName |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/themelist",["require","exports","module","ace/lib/fixoldbrowsers"], function(require, exports, module) { |
||||
"use strict"; |
||||
require("ace/lib/fixoldbrowsers"); |
||||
|
||||
var themeData = [ |
||||
["Chrome" ], |
||||
["Clouds" ], |
||||
["Crimson Editor" ], |
||||
["Dawn" ], |
||||
["Dreamweaver" ], |
||||
["Eclipse" ], |
||||
["GitHub" ], |
||||
["IPlastic" ], |
||||
["Solarized Light"], |
||||
["TextMate" ], |
||||
["Tomorrow" ], |
||||
["XCode" ], |
||||
["Kuroir"], |
||||
["KatzenMilch"], |
||||
["SQL Server" ,"sqlserver" , "light"], |
||||
["Ambiance" ,"ambiance" , "dark"], |
||||
["Chaos" ,"chaos" , "dark"], |
||||
["Clouds Midnight" ,"clouds_midnight" , "dark"], |
||||
["Cobalt" ,"cobalt" , "dark"], |
||||
["idle Fingers" ,"idle_fingers" , "dark"], |
||||
["krTheme" ,"kr_theme" , "dark"], |
||||
["Merbivore" ,"merbivore" , "dark"], |
||||
["Merbivore Soft" ,"merbivore_soft" , "dark"], |
||||
["Mono Industrial" ,"mono_industrial" , "dark"], |
||||
["Monokai" ,"monokai" , "dark"], |
||||
["Pastel on dark" ,"pastel_on_dark" , "dark"], |
||||
["Solarized Dark" ,"solarized_dark" , "dark"], |
||||
["Terminal" ,"terminal" , "dark"], |
||||
["Tomorrow Night" ,"tomorrow_night" , "dark"], |
||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"], |
||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"], |
||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"], |
||||
["Twilight" ,"twilight" , "dark"], |
||||
["Vibrant Ink" ,"vibrant_ink" , "dark"] |
||||
]; |
||||
|
||||
|
||||
exports.themesByName = {}; |
||||
exports.themes = themeData.map(function(data) { |
||||
var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); |
||||
var theme = { |
||||
caption: data[0], |
||||
theme: "ace/theme/" + name, |
||||
isDark: data[2] == "dark", |
||||
name: name |
||||
}; |
||||
exports.themesByName[name] = theme; |
||||
return theme; |
||||
}); |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/menu_tools/add_editor_menu_options",["require","exports","module","ace/ext/modelist","ace/ext/themelist"], function(require, exports, module) { |
||||
'use strict'; |
||||
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" |
||||
}, { |
||||
textContent: "textarea", |
||||
value: "ace/keyboard/textarea" |
||||
}, { |
||||
textContent: "sublime", |
||||
value: "ace/keyboard/sublime" |
||||
}] |
||||
}; |
||||
|
||||
editor.menuOptions.setTheme = themelist.themes.map(function(theme) { |
||||
return { |
||||
textContent: theme.caption, |
||||
value: theme.theme |
||||
}; |
||||
}); |
||||
|
||||
editor.menuOptions.setMode = modelist.modes.map(function(mode) { |
||||
return { |
||||
textContent: mode.name, |
||||
value: mode.mode |
||||
}; |
||||
}); |
||||
}; |
||||
|
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/menu_tools/get_set_functions",["require","exports","module"], function(require, exports, module) { |
||||
'use strict'; |
||||
module.exports.getSetFunctions = function getSetFunctions (editor) { |
||||
var out = []; |
||||
var my = { |
||||
'editor' : editor, |
||||
'session' : editor.session, |
||||
'renderer' : editor.renderer |
||||
}; |
||||
var opts = []; |
||||
var skip = [ |
||||
'setOption', |
||||
'setUndoManager', |
||||
'setDocument', |
||||
'setValue', |
||||
'setBreakpoints', |
||||
'setScrollTop', |
||||
'setScrollLeft', |
||||
'setSelectionStyle', |
||||
'setWrapLimitRange' |
||||
]; |
||||
['renderer', 'session', 'editor'].forEach(function(esra) { |
||||
var esr = my[esra]; |
||||
var clss = esra; |
||||
for(var fn in esr) { |
||||
if(skip.indexOf(fn) === -1) { |
||||
if(/^set/.test(fn) && opts.indexOf(fn) === -1) { |
||||
opts.push(fn); |
||||
out.push({ |
||||
'functionName' : fn, |
||||
'parentObj' : esr, |
||||
'parentName' : clss |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
return out; |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/menu_tools/generate_settings_menu",["require","exports","module","ace/ext/menu_tools/element_generator","ace/ext/menu_tools/add_editor_menu_options","ace/ext/menu_tools/get_set_functions"], 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; |
||||
module.exports.generateSettingsMenu = function generateSettingsMenu (editor) { |
||||
var elements = []; |
||||
function cleanupElementsList() { |
||||
elements.sort(function(a, b) { |
||||
var x = a.getAttribute('contains'); |
||||
var y = b.getAttribute('contains'); |
||||
return x.localeCompare(y); |
||||
}); |
||||
} |
||||
function wrapElements() { |
||||
var topmenu = document.createElement('div'); |
||||
topmenu.setAttribute('id', 'ace_settingsmenu'); |
||||
elements.forEach(function(element) { |
||||
topmenu.appendChild(element); |
||||
}); |
||||
|
||||
var el = topmenu.appendChild(document.createElement('div')); |
||||
var version = "1.1.9"; |
||||
el.style.padding = "1em"; |
||||
el.textContent = "Ace version " + version; |
||||
|
||||
return topmenu; |
||||
} |
||||
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{ |
||||
obj[e.target.id](!!e.target.checked); |
||||
} catch (err) { |
||||
throw new Error(err); |
||||
} |
||||
}); |
||||
} else { |
||||
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; |
||||
} |
||||
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); |
||||
} |
||||
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) { |
||||
elements.push(makeDropdown(item, esr, clss, fn)); |
||||
} else if(typeof esr[fn] === 'function') { |
||||
try { |
||||
val = esr[fn](); |
||||
if(typeof val === 'object') { |
||||
val = val.$id; |
||||
} |
||||
elements.push( |
||||
createNewEntry(esr, clss, item, val) |
||||
); |
||||
} catch (e) { |
||||
} |
||||
} |
||||
} |
||||
addEditorMenuOptions(editor); |
||||
getSetFunctions(editor).forEach(function(setObj) { |
||||
handleSet(setObj); |
||||
}); |
||||
cleanupElementsList(); |
||||
return wrapElements(); |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom"], function(require, exports, module) { |
||||
'use strict'; |
||||
var dom = require("../../lib/dom"); |
||||
var cssText = "#ace_settingsmenu, #kbshortcutmenu {\ |
||||
background-color: #F7F7F7;\ |
||||
color: black;\ |
||||
box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\ |
||||
padding: 1em 0.5em 2em 1em;\ |
||||
overflow: auto;\ |
||||
position: absolute;\ |
||||
margin: 0;\ |
||||
bottom: 0;\ |
||||
right: 0;\ |
||||
top: 0;\ |
||||
z-index: 9991;\ |
||||
cursor: default;\ |
||||
}\ |
||||
.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\ |
||||
box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\ |
||||
background-color: rgba(255, 255, 255, 0.6);\ |
||||
color: black;\ |
||||
}\ |
||||
.ace_optionsMenuEntry:hover {\ |
||||
background-color: rgba(100, 100, 100, 0.1);\ |
||||
-webkit-transition: all 0.5s;\ |
||||
transition: all 0.3s\ |
||||
}\ |
||||
.ace_closeButton {\ |
||||
background: rgba(245, 146, 146, 0.5);\ |
||||
border: 1px solid #F48A8A;\ |
||||
border-radius: 50%;\ |
||||
padding: 7px;\ |
||||
position: absolute;\ |
||||
right: -8px;\ |
||||
top: -8px;\ |
||||
z-index: 1000;\ |
||||
}\ |
||||
.ace_closeButton{\ |
||||
background: rgba(245, 146, 146, 0.9);\ |
||||
}\ |
||||
.ace_optionsMenuKey {\ |
||||
color: darkslateblue;\ |
||||
font-weight: bold;\ |
||||
}\ |
||||
.ace_optionsMenuCommand {\ |
||||
color: darkcyan;\ |
||||
font-weight: normal;\ |
||||
}"; |
||||
dom.importCssString(cssText); |
||||
module.exports.overlayPage = function overlayPage(editor, contentElement, top, right, bottom, left) { |
||||
top = top ? 'top: ' + top + ';' : ''; |
||||
bottom = bottom ? 'bottom: ' + bottom + ';' : ''; |
||||
right = right ? 'right: ' + right + ';' : ''; |
||||
left = left ? 'left: ' + left + ';' : ''; |
||||
|
||||
var closer = document.createElement('div'); |
||||
var contentContainer = document.createElement('div'); |
||||
|
||||
function documentEscListener(e) { |
||||
if (e.keyCode === 27) { |
||||
closer.click(); |
||||
} |
||||
} |
||||
|
||||
closer.style.cssText = 'margin: 0; padding: 0; ' + |
||||
'position: fixed; top:0; bottom:0; left:0; right:0;' + |
||||
'z-index: 9990; ' + |
||||
'background-color: rgba(0, 0, 0, 0.3);'; |
||||
closer.addEventListener('click', function() { |
||||
document.removeEventListener('keydown', documentEscListener); |
||||
closer.parentNode.removeChild(closer); |
||||
editor.focus(); |
||||
closer = null; |
||||
}); |
||||
document.addEventListener('keydown', documentEscListener); |
||||
|
||||
contentContainer.style.cssText = top + right + bottom + left; |
||||
contentContainer.addEventListener('click', function(e) { |
||||
e.stopPropagation(); |
||||
}); |
||||
|
||||
var wrapper = dom.createElement("div"); |
||||
wrapper.style.position = "relative"; |
||||
|
||||
var closeButton = dom.createElement("div"); |
||||
closeButton.className = "ace_closeButton"; |
||||
closeButton.addEventListener('click', function() { |
||||
closer.click(); |
||||
}); |
||||
|
||||
wrapper.appendChild(closeButton); |
||||
contentContainer.appendChild(wrapper); |
||||
|
||||
contentContainer.appendChild(contentElement); |
||||
closer.appendChild(contentContainer); |
||||
document.body.appendChild(closer); |
||||
editor.blur(); |
||||
}; |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/ext/settings_menu",["require","exports","module","ace/ext/menu_tools/generate_settings_menu","ace/ext/menu_tools/overlay_page","ace/editor"], function(require, exports, module) { |
||||
"use strict"; |
||||
var generateSettingsMenu = require('./menu_tools/generate_settings_menu').generateSettingsMenu; |
||||
var overlayPage = require('./menu_tools/overlay_page').overlayPage; |
||||
function showSettingsMenu(editor) { |
||||
var sm = document.getElementById('ace_settingsmenu'); |
||||
if (!sm)
|
||||
overlayPage(editor, generateSettingsMenu(editor), '0', '0', '0'); |
||||
} |
||||
module.exports.init = function(editor) { |
||||
var Editor = require("ace/editor").Editor; |
||||
Editor.prototype.showSettingsMenu = function() { |
||||
showSettingsMenu(this); |
||||
}; |
||||
}; |
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/settings_menu"], function() {}); |
||||
})(); |
||||
|
@ -1,71 +0,0 @@
|
||||
ace.define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"], function(require, exports, module) { |
||||
"use strict"; |
||||
var event = require("../lib/event"); |
||||
|
||||
exports.contextMenuHandler = function(e){ |
||||
var host = e.target; |
||||
var text = host.textInput.getElement(); |
||||
if (!host.selection.isEmpty()) |
||||
return; |
||||
var c = host.getCursorPosition(); |
||||
var r = host.session.getWordRange(c.row, c.column); |
||||
var w = host.session.getTextRange(r); |
||||
|
||||
host.session.tokenRe.lastIndex = 0; |
||||
if (!host.session.tokenRe.test(w)) |
||||
return; |
||||
var PLACEHOLDER = "\x01\x01"; |
||||
var value = w + " " + PLACEHOLDER; |
||||
text.value = value; |
||||
text.setSelectionRange(w.length, w.length + 1); |
||||
text.setSelectionRange(0, 0); |
||||
text.setSelectionRange(0, w.length); |
||||
|
||||
var afterKeydown = false; |
||||
event.addListener(text, "keydown", function onKeydown() { |
||||
event.removeListener(text, "keydown", onKeydown); |
||||
afterKeydown = true; |
||||
}); |
||||
|
||||
host.textInput.setInputHandler(function(newVal) { |
||||
console.log(newVal , value, text.selectionStart, text.selectionEnd) |
||||
if (newVal == value) |
||||
return ''; |
||||
if (newVal.lastIndexOf(value, 0) === 0) |
||||
return newVal.slice(value.length); |
||||
if (newVal.substr(text.selectionEnd) == value) |
||||
return newVal.slice(0, -value.length); |
||||
if (newVal.slice(-2) == PLACEHOLDER) { |
||||
var val = newVal.slice(0, -2); |
||||
if (val.slice(-1) == " ") { |
||||
if (afterKeydown) |
||||
return val.substring(0, text.selectionEnd); |
||||
val = val.slice(0, -1); |
||||
host.session.replace(r, val); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
return newVal; |
||||
}); |
||||
}; |
||||
var Editor = require("../editor").Editor; |
||||
require("../config").defineOptions(Editor.prototype, "editor", { |
||||
spellcheck: { |
||||
set: function(val) { |
||||
var text = this.textInput.getElement(); |
||||
text.spellcheck = !!val; |
||||
if (!val) |
||||
this.removeListener("nativecontextmenu", exports.contextMenuHandler); |
||||
else |
||||
this.on("nativecontextmenu", exports.contextMenuHandler); |
||||
}, |
||||
value: true |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/spellcheck"], function() {}); |
||||
})(); |
||||
|
@ -1,246 +0,0 @@
|
||||
ace.define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var oop = require("./lib/oop"); |
||||
var lang = require("./lib/lang"); |
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
||||
|
||||
var Editor = require("./editor").Editor; |
||||
var Renderer = require("./virtual_renderer").VirtualRenderer; |
||||
var EditSession = require("./edit_session").EditSession; |
||||
|
||||
|
||||
var Split = function(container, theme, splits) { |
||||
this.BELOW = 1; |
||||
this.BESIDE = 0; |
||||
|
||||
this.$container = container; |
||||
this.$theme = theme; |
||||
this.$splits = 0; |
||||
this.$editorCSS = ""; |
||||
this.$editors = []; |
||||
this.$orientation = this.BESIDE; |
||||
|
||||
this.setSplits(splits || 1); |
||||
this.$cEditor = this.$editors[0]; |
||||
|
||||
|
||||
this.on("focus", function(editor) { |
||||
this.$cEditor = editor; |
||||
}.bind(this)); |
||||
}; |
||||
|
||||
(function(){ |
||||
|
||||
oop.implement(this, EventEmitter); |
||||
|
||||
this.$createEditor = function() { |
||||
var el = document.createElement("div"); |
||||
el.className = this.$editorCSS; |
||||
el.style.cssText = "position: absolute; top:0px; bottom:0px"; |
||||
this.$container.appendChild(el); |
||||
var editor = new Editor(new Renderer(el, this.$theme)); |
||||
|
||||
editor.on("focus", function() { |
||||
this._emit("focus", editor); |
||||
}.bind(this)); |
||||
|
||||
this.$editors.push(editor); |
||||
editor.setFontSize(this.$fontSize); |
||||
return editor; |
||||
}; |
||||
|
||||
this.setSplits = function(splits) { |
||||
var editor; |
||||
if (splits < 1) { |
||||
throw "The number of splits have to be > 0!"; |
||||
} |
||||
|
||||
if (splits == this.$splits) { |
||||
return; |
||||
} else if (splits > this.$splits) { |
||||
while (this.$splits < this.$editors.length && this.$splits < splits) { |
||||
editor = this.$editors[this.$splits]; |
||||
this.$container.appendChild(editor.container); |
||||
editor.setFontSize(this.$fontSize); |
||||
this.$splits ++; |
||||
} |
||||
while (this.$splits < splits) { |
||||
this.$createEditor(); |
||||
this.$splits ++; |
||||
} |
||||
} else { |
||||
while (this.$splits > splits) { |
||||
editor = this.$editors[this.$splits - 1]; |
||||
this.$container.removeChild(editor.container); |
||||
this.$splits --; |
||||
} |
||||
} |
||||
this.resize(); |
||||
}; |
||||
this.getSplits = function() { |
||||
return this.$splits; |
||||
}; |
||||
this.getEditor = function(idx) { |
||||
return this.$editors[idx]; |
||||
}; |
||||
this.getCurrentEditor = function() { |
||||
return this.$cEditor; |
||||
}; |
||||
this.focus = function() { |
||||
this.$cEditor.focus(); |
||||
}; |
||||
this.blur = function() { |
||||
this.$cEditor.blur(); |
||||
}; |
||||
this.setTheme = function(theme) { |
||||
this.$editors.forEach(function(editor) { |
||||
editor.setTheme(theme); |
||||
}); |
||||
}; |
||||
this.setKeyboardHandler = function(keybinding) { |
||||
this.$editors.forEach(function(editor) { |
||||
editor.setKeyboardHandler(keybinding); |
||||
}); |
||||
}; |
||||
this.forEach = function(callback, scope) { |
||||
this.$editors.forEach(callback, scope); |
||||
}; |
||||
|
||||
|
||||
this.$fontSize = ""; |
||||
this.setFontSize = function(size) { |
||||
this.$fontSize = size; |
||||
this.forEach(function(editor) { |
||||
editor.setFontSize(size); |
||||
}); |
||||
}; |
||||
|
||||
this.$cloneSession = function(session) { |
||||
var s = new EditSession(session.getDocument(), session.getMode()); |
||||
|
||||
var undoManager = session.getUndoManager(); |
||||
if (undoManager) { |
||||
var undoManagerProxy = new UndoManagerProxy(undoManager, s); |
||||
s.setUndoManager(undoManagerProxy); |
||||
} |
||||
s.$informUndoManager = lang.delayedCall(function() { s.$deltas = []; }); |
||||
s.setTabSize(session.getTabSize()); |
||||
s.setUseSoftTabs(session.getUseSoftTabs()); |
||||
s.setOverwrite(session.getOverwrite()); |
||||
s.setBreakpoints(session.getBreakpoints()); |
||||
s.setUseWrapMode(session.getUseWrapMode()); |
||||
s.setUseWorker(session.getUseWorker()); |
||||
s.setWrapLimitRange(session.$wrapLimitRange.min, |
||||
session.$wrapLimitRange.max); |
||||
s.$foldData = session.$cloneFoldData(); |
||||
|
||||
return s; |
||||
}; |
||||
this.setSession = function(session, idx) { |
||||
var editor; |
||||
if (idx == null) { |
||||
editor = this.$cEditor; |
||||
} else { |
||||
editor = this.$editors[idx]; |
||||
} |
||||
var isUsed = this.$editors.some(function(editor) { |
||||
return editor.session === session; |
||||
}); |
||||
|
||||
if (isUsed) { |
||||
session = this.$cloneSession(session); |
||||
} |
||||
editor.setSession(session); |
||||
return session; |
||||
}; |
||||
this.getOrientation = function() { |
||||
return this.$orientation; |
||||
}; |
||||
this.setOrientation = function(orientation) { |
||||
if (this.$orientation == orientation) { |
||||
return; |
||||
} |
||||
this.$orientation = orientation; |
||||
this.resize(); |
||||
}; |
||||
this.resize = function() { |
||||
var width = this.$container.clientWidth; |
||||
var height = this.$container.clientHeight; |
||||
var editor; |
||||
|
||||
if (this.$orientation == this.BESIDE) { |
||||
var editorWidth = width / this.$splits; |
||||
for (var i = 0; i < this.$splits; i++) { |
||||
editor = this.$editors[i]; |
||||
editor.container.style.width = editorWidth + "px"; |
||||
editor.container.style.top = "0px"; |
||||
editor.container.style.left = i * editorWidth + "px"; |
||||
editor.container.style.height = height + "px"; |
||||
editor.resize(); |
||||
} |
||||
} else { |
||||
var editorHeight = height / this.$splits; |
||||
for (var i = 0; i < this.$splits; i++) { |
||||
editor = this.$editors[i]; |
||||
editor.container.style.width = width + "px"; |
||||
editor.container.style.top = i * editorHeight + "px"; |
||||
editor.container.style.left = "0px"; |
||||
editor.container.style.height = editorHeight + "px"; |
||||
editor.resize(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
}).call(Split.prototype); |
||||
|
||||
|
||||
function UndoManagerProxy(undoManager, session) { |
||||
this.$u = undoManager; |
||||
this.$doc = session; |
||||
} |
||||
|
||||
(function() { |
||||
this.execute = function(options) { |
||||
this.$u.execute(options); |
||||
}; |
||||
|
||||
this.undo = function() { |
||||
var selectionRange = this.$u.undo(true); |
||||
if (selectionRange) { |
||||
this.$doc.selection.setSelectionRange(selectionRange); |
||||
} |
||||
}; |
||||
|
||||
this.redo = function() { |
||||
var selectionRange = this.$u.redo(true); |
||||
if (selectionRange) { |
||||
this.$doc.selection.setSelectionRange(selectionRange); |
||||
} |
||||
}; |
||||
|
||||
this.reset = function() { |
||||
this.$u.reset(); |
||||
}; |
||||
|
||||
this.hasUndo = function() { |
||||
return this.$u.hasUndo(); |
||||
}; |
||||
|
||||
this.hasRedo = function() { |
||||
return this.$u.hasRedo(); |
||||
}; |
||||
}).call(UndoManagerProxy.prototype); |
||||
|
||||
exports.Split = Split; |
||||
}); |
||||
|
||||
ace.define("ace/ext/split",["require","exports","module","ace/split"], function(require, exports, module) { |
||||
"use strict"; |
||||
module.exports = require("../split"); |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/split"], function() {}); |
||||
})(); |
||||
|
@ -1,161 +0,0 @@
|
||||
ace.define("ace/ext/static_highlight",["require","exports","module","ace/edit_session","ace/layer/text","ace/config","ace/lib/dom"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var EditSession = require("../edit_session").EditSession; |
||||
var TextLayer = require("../layer/text").Text; |
||||
var baseStyles = ".ace_static_highlight {\ |
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace;\ |
||||
font-size: 12px;\ |
||||
white-space: pre-wrap\ |
||||
}\ |
||||
.ace_static_highlight .ace_gutter {\ |
||||
width: 2em;\ |
||||
text-align: right;\ |
||||
padding: 0 3px 0 0;\ |
||||
margin-right: 3px;\ |
||||
}\ |
||||
.ace_static_highlight.ace_show_gutter .ace_line {\ |
||||
padding-left: 2.6em;\ |
||||
}\ |
||||
.ace_static_highlight .ace_line { position: relative; }\ |
||||
.ace_static_highlight .ace_gutter-cell {\ |
||||
-moz-user-select: -moz-none;\ |
||||
-khtml-user-select: none;\ |
||||
-webkit-user-select: none;\ |
||||
user-select: none;\ |
||||
top: 0;\ |
||||
bottom: 0;\ |
||||
left: 0;\ |
||||
position: absolute;\ |
||||
}\ |
||||
.ace_static_highlight .ace_gutter-cell:before {\ |
||||
content: counter(ace_line, decimal);\ |
||||
counter-increment: ace_line;\ |
||||
}\ |
||||
.ace_static_highlight {\ |
||||
counter-reset: ace_line;\ |
||||
}\ |
||||
"; |
||||
var config = require("../config"); |
||||
var dom = require("../lib/dom"); |
||||
|
||||
|
||||
var highlight = function(el, opts, callback) { |
||||
var m = el.className.match(/lang-(\w+)/); |
||||
var mode = opts.mode || m && ("ace/mode/" + m[1]); |
||||
if (!mode) |
||||
return false; |
||||
var theme = opts.theme || "ace/theme/textmate"; |
||||
|
||||
var data = ""; |
||||
var nodes = []; |
||||
|
||||
if (el.firstElementChild) { |
||||
var textLen = 0; |
||||
for (var i = 0; i < el.childNodes.length; i++) { |
||||
var ch = el.childNodes[i]; |
||||
if (ch.nodeType == 3) { |
||||
textLen += ch.data.length; |
||||
data += ch.data; |
||||
} else { |
||||
nodes.push(textLen, ch); |
||||
} |
||||
} |
||||
} else { |
||||
data = dom.getInnerText(el); |
||||
if (opts.trim) |
||||
data = data.trim(); |
||||
} |
||||
|
||||
highlight.render(data, mode, theme, opts.firstLineNumber, !opts.showGutter, function (highlighted) { |
||||
dom.importCssString(highlighted.css, "ace_highlight"); |
||||
el.innerHTML = highlighted.html; |
||||
var container = el.firstChild.firstChild; |
||||
for (var i = 0; i < nodes.length; i += 2) { |
||||
var pos = highlighted.session.doc.indexToPosition(nodes[i]); |
||||
var node = nodes[i + 1]; |
||||
var lineEl = container.children[pos.row]; |
||||
lineEl && lineEl.appendChild(node); |
||||
} |
||||
callback && callback(); |
||||
}); |
||||
}; |
||||
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) { |
||||
var waiting = 1; |
||||
var modeCache = EditSession.prototype.$modes; |
||||
if (typeof theme == "string") { |
||||
waiting++; |
||||
config.loadModule(['theme', theme], function(m) { |
||||
theme = m; |
||||
--waiting || done(); |
||||
}); |
||||
} |
||||
var modeOptions; |
||||
if (mode && typeof mode === "object" && !mode.getTokenizer) { |
||||
modeOptions = mode; |
||||
mode = modeOptions.path; |
||||
} |
||||
if (typeof mode == "string") { |
||||
waiting++; |
||||
config.loadModule(['mode', mode], function(m) { |
||||
if (!modeCache[mode] || modeOptions) |
||||
modeCache[mode] = new m.Mode(modeOptions); |
||||
mode = modeCache[mode]; |
||||
--waiting || done(); |
||||
}); |
||||
} |
||||
function done() { |
||||
var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter); |
||||
return callback ? callback(result) : result; |
||||
} |
||||
return --waiting || done(); |
||||
}; |
||||
highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { |
||||
lineStart = parseInt(lineStart || 1, 10); |
||||
|
||||
var session = new EditSession(""); |
||||
session.setUseWorker(false); |
||||
session.setMode(mode); |
||||
|
||||
var textLayer = new TextLayer(document.createElement("div")); |
||||
textLayer.setSession(session); |
||||
textLayer.config = { |
||||
characterWidth: 10, |
||||
lineHeight: 20 |
||||
}; |
||||
|
||||
session.setValue(input); |
||||
|
||||
var stringBuilder = []; |
||||
var length = session.getLength(); |
||||
|
||||
for(var ix = 0; ix < length; ix++) { |
||||
stringBuilder.push("<div class='ace_line'>"); |
||||
if (!disableGutter) |
||||
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + /*(ix + lineStart) + */ "</span>"); |
||||
textLayer.$renderLine(stringBuilder, ix, true, false); |
||||
stringBuilder.push("\n</div>"); |
||||
} |
||||
var html = "<div class='" + theme.cssClass + "'>" + |
||||
"<div class='ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter") + |
||||
"' style='counter-reset:ace_line " + (lineStart - 1) + "'>" + |
||||
stringBuilder.join("") + |
||||
"</div>" + |
||||
"</div>"; |
||||
|
||||
textLayer.destroy(); |
||||
|
||||
return { |
||||
css: baseStyles + theme.cssText, |
||||
html: html, |
||||
session: session |
||||
}; |
||||
}; |
||||
|
||||
module.exports = highlight; |
||||
module.exports.highlight =highlight; |
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/static_highlight"], function() {}); |
||||
})(); |
||||
|
@ -1,51 +0,0 @@
|
||||
ace.define("ace/ext/statusbar",["require","exports","module","ace/lib/dom","ace/lib/lang"], function(require, exports, module) { |
||||
"use strict"; |
||||
var dom = require("ace/lib/dom"); |
||||
var lang = require("ace/lib/lang"); |
||||
|
||||
var StatusBar = function(editor, parentNode) { |
||||
this.element = dom.createElement("div"); |
||||
this.element.className = "ace_status-indicator"; |
||||
this.element.style.cssText = "display: inline-block;"; |
||||
parentNode.appendChild(this.element); |
||||
|
||||
var statusUpdate = lang.delayedCall(function(){ |
||||
this.updateStatus(editor) |
||||
}.bind(this)); |
||||
editor.on("changeStatus", function() { |
||||
statusUpdate.schedule(100); |
||||
}); |
||||
editor.on("changeSelection", function() { |
||||
statusUpdate.schedule(100); |
||||
}); |
||||
}; |
||||
|
||||
(function(){ |
||||
this.updateStatus = function(editor) { |
||||
var status = []; |
||||
function add(str, separator) { |
||||
str && status.push(str, separator || "|"); |
||||
} |
||||
|
||||
add(editor.keyBinding.getStatusText(editor)); |
||||
if (editor.commands.recording) |
||||
add("REC"); |
||||
|
||||
var c = editor.selection.lead; |
||||
add(c.row + ":" + c.column, " "); |
||||
if (!editor.selection.isEmpty()) { |
||||
var r = editor.getSelectionRange(); |
||||
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")"); |
||||
} |
||||
status.pop(); |
||||
this.element.textContent = status.join(""); |
||||
}; |
||||
}).call(StatusBar.prototype); |
||||
|
||||
exports.StatusBar = StatusBar; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/statusbar"], function() {}); |
||||
})(); |
||||
|
@ -1,632 +0,0 @@
|
||||
ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
exports.isDark = false; |
||||
exports.cssClass = "ace-tm"; |
||||
exports.cssText = ".ace-tm .ace_gutter {\ |
||||
background: #f0f0f0;\ |
||||
color: #333;\ |
||||
}\ |
||||
.ace-tm .ace_print-margin {\ |
||||
width: 1px;\ |
||||
background: #e8e8e8;\ |
||||
}\ |
||||
.ace-tm .ace_fold {\ |
||||
background-color: #6B72E6;\ |
||||
}\ |
||||
.ace-tm {\ |
||||
background-color: #FFFFFF;\ |
||||
color: black;\ |
||||
}\ |
||||
.ace-tm .ace_cursor {\ |
||||
color: black;\ |
||||
}\ |
||||
.ace-tm .ace_invisible {\ |
||||
color: rgb(191, 191, 191);\ |
||||
}\ |
||||
.ace-tm .ace_storage,\ |
||||
.ace-tm .ace_keyword {\ |
||||
color: blue;\ |
||||
}\ |
||||
.ace-tm .ace_constant {\ |
||||
color: rgb(197, 6, 11);\ |
||||
}\ |
||||
.ace-tm .ace_constant.ace_buildin {\ |
||||
color: rgb(88, 72, 246);\ |
||||
}\ |
||||
.ace-tm .ace_constant.ace_language {\ |
||||
color: rgb(88, 92, 246);\ |
||||
}\ |
||||
.ace-tm .ace_constant.ace_library {\ |
||||
color: rgb(6, 150, 14);\ |
||||
}\ |
||||
.ace-tm .ace_invalid {\ |
||||
background-color: rgba(255, 0, 0, 0.1);\ |
||||
color: red;\ |
||||
}\ |
||||
.ace-tm .ace_support.ace_function {\ |
||||
color: rgb(60, 76, 114);\ |
||||
}\ |
||||
.ace-tm .ace_support.ace_constant {\ |
||||
color: rgb(6, 150, 14);\ |
||||
}\ |
||||
.ace-tm .ace_support.ace_type,\ |
||||
.ace-tm .ace_support.ace_class {\ |
||||
color: rgb(109, 121, 222);\ |
||||
}\ |
||||
.ace-tm .ace_keyword.ace_operator {\ |
||||
color: rgb(104, 118, 135);\ |
||||
}\ |
||||
.ace-tm .ace_string {\ |
||||
color: rgb(3, 106, 7);\ |
||||
}\ |
||||
.ace-tm .ace_comment {\ |
||||
color: rgb(76, 136, 107);\ |
||||
}\ |
||||
.ace-tm .ace_comment.ace_doc {\ |
||||
color: rgb(0, 102, 255);\ |
||||
}\ |
||||
.ace-tm .ace_comment.ace_doc.ace_tag {\ |
||||
color: rgb(128, 159, 191);\ |
||||
}\ |
||||
.ace-tm .ace_constant.ace_numeric {\ |
||||
color: rgb(0, 0, 205);\ |
||||
}\ |
||||
.ace-tm .ace_variable {\ |
||||
color: rgb(49, 132, 149);\ |
||||
}\ |
||||
.ace-tm .ace_xml-pe {\ |
||||
color: rgb(104, 104, 91);\ |
||||
}\ |
||||
.ace-tm .ace_entity.ace_name.ace_function {\ |
||||
color: #0000A2;\ |
||||
}\ |
||||
.ace-tm .ace_heading {\ |
||||
color: rgb(12, 7, 255);\ |
||||
}\ |
||||
.ace-tm .ace_list {\ |
||||
color:rgb(185, 6, 144);\ |
||||
}\ |
||||
.ace-tm .ace_meta.ace_tag {\ |
||||
color:rgb(0, 22, 142);\ |
||||
}\ |
||||
.ace-tm .ace_string.ace_regex {\ |
||||
color: rgb(255, 0, 0)\ |
||||
}\ |
||||
.ace-tm .ace_marker-layer .ace_selection {\ |
||||
background: rgb(181, 213, 255);\ |
||||
}\ |
||||
.ace-tm.ace_multiselect .ace_selection.ace_start {\ |
||||
box-shadow: 0 0 3px 0px white;\ |
||||
border-radius: 2px;\ |
||||
}\ |
||||
.ace-tm .ace_marker-layer .ace_step {\ |
||||
background: rgb(252, 255, 0);\ |
||||
}\ |
||||
.ace-tm .ace_marker-layer .ace_stack {\ |
||||
background: rgb(164, 229, 101);\ |
||||
}\ |
||||
.ace-tm .ace_marker-layer .ace_bracket {\ |
||||
margin: -1px 0 0 -1px;\ |
||||
border: 1px solid rgb(192, 192, 192);\ |
||||
}\ |
||||
.ace-tm .ace_marker-layer .ace_active-line {\ |
||||
background: rgba(0, 0, 0, 0.07);\ |
||||
}\ |
||||
.ace-tm .ace_gutter-active-line {\ |
||||
background-color : #dcdcdc;\ |
||||
}\ |
||||
.ace-tm .ace_marker-layer .ace_selected-word {\ |
||||
background: rgb(250, 250, 255);\ |
||||
border: 1px solid rgb(200, 200, 250);\ |
||||
}\ |
||||
.ace-tm .ace_indent-guide {\ |
||||
background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ |
||||
}\ |
||||
"; |
||||
|
||||
var dom = require("../lib/dom"); |
||||
dom.importCssString(exports.cssText, exports.cssClass); |
||||
}); |
||||
|
||||
ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
require("./lib/fixoldbrowsers"); |
||||
|
||||
var dom = require("./lib/dom"); |
||||
var event = require("./lib/event"); |
||||
|
||||
var Editor = require("./editor").Editor; |
||||
var EditSession = require("./edit_session").EditSession; |
||||
var UndoManager = require("./undomanager").UndoManager; |
||||
var Renderer = require("./virtual_renderer").VirtualRenderer; |
||||
require("./worker/worker_client"); |
||||
require("./keyboard/hash_handler"); |
||||
require("./placeholder"); |
||||
require("./multi_select"); |
||||
require("./mode/folding/fold_mode"); |
||||
require("./theme/textmate"); |
||||
require("./ext/error_marker"); |
||||
|
||||
exports.config = require("./config"); |
||||
exports.require = require; |
||||
exports.edit = function(el) { |
||||
if (typeof(el) == "string") { |
||||
var _id = el; |
||||
el = document.getElementById(_id); |
||||
if (!el) |
||||
throw new Error("ace.edit can't find div #" + _id); |
||||
} |
||||
|
||||
if (el && el.env && el.env.editor instanceof Editor) |
||||
return el.env.editor; |
||||
|
||||
var value = ""; |
||||
if (el && /input|textarea/i.test(el.tagName)) { |
||||
var oldNode = el; |
||||
value = oldNode.value; |
||||
el = dom.createElement("pre"); |
||||
oldNode.parentNode.replaceChild(el, oldNode); |
||||
} else { |
||||
value = dom.getInnerText(el); |
||||
el.innerHTML = ''; |
||||
} |
||||
|
||||
var doc = exports.createEditSession(value); |
||||
|
||||
var editor = new Editor(new Renderer(el)); |
||||
editor.setSession(doc); |
||||
|
||||
var env = { |
||||
document: doc, |
||||
editor: editor, |
||||
onResize: editor.resize.bind(editor, null) |
||||
}; |
||||
if (oldNode) env.textarea = oldNode; |
||||
event.addListener(window, "resize", env.onResize); |
||||
editor.on("destroy", function() { |
||||
event.removeListener(window, "resize", env.onResize); |
||||
env.editor.container.env = null; // prevent memory leak on old ie
|
||||
}); |
||||
editor.container.env = editor.env = env; |
||||
return editor; |
||||
}; |
||||
exports.createEditSession = function(text, mode) { |
||||
var doc = new EditSession(text, mode); |
||||
doc.setUndoManager(new UndoManager()); |
||||
return doc; |
||||
} |
||||
exports.EditSession = EditSession; |
||||
exports.UndoManager = UndoManager; |
||||
}); |
||||
|
||||
ace.define("ace/ext/textarea",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/net","ace/ace","ace/theme/textmate"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var event = require("../lib/event"); |
||||
var UA = require("../lib/useragent"); |
||||
var net = require("../lib/net"); |
||||
var ace = require("../ace"); |
||||
|
||||
require("../theme/textmate"); |
||||
|
||||
module.exports = exports = ace; |
||||
var getCSSProperty = function(element, container, property) { |
||||
var ret = element.style[property]; |
||||
|
||||
if (!ret) { |
||||
if (window.getComputedStyle) { |
||||
ret = window.getComputedStyle(element, '').getPropertyValue(property); |
||||
} else { |
||||
ret = element.currentStyle[property]; |
||||
} |
||||
} |
||||
|
||||
if (!ret || ret == 'auto' || ret == 'intrinsic') { |
||||
ret = container.style[property]; |
||||
} |
||||
return ret; |
||||
}; |
||||
|
||||
function applyStyles(elm, styles) { |
||||
for (var style in styles) { |
||||
elm.style[style] = styles[style]; |
||||
} |
||||
} |
||||
|
||||
function setupContainer(element, getValue) { |
||||
if (element.type != 'textarea') { |
||||
throw new Error("Textarea required!"); |
||||
} |
||||
|
||||
var parentNode = element.parentNode; |
||||
var container = document.createElement('div'); |
||||
var resizeEvent = function() { |
||||
var style = 'position:relative;'; |
||||
[ |
||||
'margin-top', 'margin-left', 'margin-right', 'margin-bottom' |
||||
].forEach(function(item) { |
||||
style += item + ':' + |
||||
getCSSProperty(element, container, item) + ';'; |
||||
}); |
||||
var width = getCSSProperty(element, container, 'width') || (element.clientWidth + "px"); |
||||
var height = getCSSProperty(element, container, 'height') || (element.clientHeight + "px"); |
||||
style += 'height:' + height + ';width:' + width + ';'; |
||||
style += 'display:inline-block;'; |
||||
container.setAttribute('style', style); |
||||
}; |
||||
event.addListener(window, 'resize', resizeEvent); |
||||
resizeEvent(); |
||||
parentNode.insertBefore(container, element.nextSibling); |
||||
while (parentNode !== document) { |
||||
if (parentNode.tagName.toUpperCase() === 'FORM') { |
||||
var oldSumit = parentNode.onsubmit; |
||||
parentNode.onsubmit = function(evt) { |
||||
element.value = getValue(); |
||||
if (oldSumit) { |
||||
oldSumit.call(this, evt); |
||||
} |
||||
}; |
||||
break; |
||||
} |
||||
parentNode = parentNode.parentNode; |
||||
} |
||||
return container; |
||||
} |
||||
|
||||
exports.transformTextarea = function(element, options) { |
||||
var session; |
||||
var container = setupContainer(element, function() { |
||||
return session.getValue(); |
||||
}); |
||||
element.style.display = 'none'; |
||||
container.style.background = 'white'; |
||||
var editorDiv = document.createElement("div"); |
||||
applyStyles(editorDiv, { |
||||
top: "0px", |
||||
left: "0px", |
||||
right: "0px", |
||||
bottom: "0px", |
||||
border: "1px solid gray", |
||||
position: "absolute" |
||||
}); |
||||
container.appendChild(editorDiv); |
||||
|
||||
var settingOpener = document.createElement("div"); |
||||
applyStyles(settingOpener, { |
||||
position: "absolute", |
||||
right: "0px", |
||||
bottom: "0px", |
||||
background: "red", |
||||
cursor: "nw-resize", |
||||
borderStyle: "solid", |
||||
borderWidth: "9px 8px 10px 9px", |
||||
width: "2px", |
||||
borderColor: "lightblue gray gray lightblue", |
||||
zIndex: 101 |
||||
}); |
||||
|
||||
var settingDiv = document.createElement("div"); |
||||
var settingDivStyles = { |
||||
top: "0px", |
||||
left: "20%", |
||||
right: "0px", |
||||
bottom: "0px", |
||||
position: "absolute", |
||||
padding: "5px", |
||||
zIndex: 100, |
||||
color: "white", |
||||
display: "none", |
||||
overflow: "auto", |
||||
fontSize: "14px", |
||||
boxShadow: "-5px 2px 3px gray" |
||||
}; |
||||
if (!UA.isOldIE) { |
||||
settingDivStyles.backgroundColor = "rgba(0, 0, 0, 0.6)"; |
||||
} else { |
||||
settingDivStyles.backgroundColor = "#333"; |
||||
} |
||||
|
||||
applyStyles(settingDiv, settingDivStyles); |
||||
container.appendChild(settingDiv); |
||||
|
||||
options = options || exports.defaultOptions; |
||||
var editor = ace.edit(editorDiv); |
||||
session = editor.getSession(); |
||||
|
||||
session.setValue(element.value || element.innerHTML); |
||||
editor.focus(); |
||||
container.appendChild(settingOpener); |
||||
setupApi(editor, editorDiv, settingDiv, ace, options, load); |
||||
setupSettingPanel(settingDiv, settingOpener, editor); |
||||
|
||||
var state = ""; |
||||
event.addListener(settingOpener, "mousemove", function(e) { |
||||
var rect = this.getBoundingClientRect(); |
||||
var x = e.clientX - rect.left, y = e.clientY - rect.top; |
||||
if (x + y < (rect.width + rect.height)/2) { |
||||
this.style.cursor = "pointer"; |
||||
state = "toggle"; |
||||
} else { |
||||
state = "resize"; |
||||
this.style.cursor = "nw-resize"; |
||||
} |
||||
}); |
||||
|
||||
event.addListener(settingOpener, "mousedown", function(e) { |
||||
if (state == "toggle") { |
||||
editor.setDisplaySettings(); |
||||
return; |
||||
} |
||||
container.style.zIndex = 100000; |
||||
var rect = container.getBoundingClientRect(); |
||||
var startX = rect.width + rect.left - e.clientX; |
||||
var startY = rect.height + rect.top - e.clientY; |
||||
event.capture(settingOpener, function(e) { |
||||
container.style.width = e.clientX - rect.left + startX + "px"; |
||||
container.style.height = e.clientY - rect.top + startY + "px"; |
||||
editor.resize(); |
||||
}, function() {}); |
||||
}); |
||||
|
||||
return editor; |
||||
}; |
||||
|
||||
function load(url, module, callback) { |
||||
net.loadScript(url, function() { |
||||
require([module], callback); |
||||
}); |
||||
} |
||||
|
||||
function setupApi(editor, editorDiv, settingDiv, ace, options, loader) { |
||||
var session = editor.getSession(); |
||||
var renderer = editor.renderer; |
||||
loader = loader || load; |
||||
|
||||
function toBool(value) { |
||||
return value === "true" || value == true; |
||||
} |
||||
|
||||
editor.setDisplaySettings = function(display) { |
||||
if (display == null) |
||||
display = settingDiv.style.display == "none"; |
||||
if (display) { |
||||
settingDiv.style.display = "block"; |
||||
settingDiv.hideButton.focus(); |
||||
editor.on("focus", function onFocus() { |
||||
editor.removeListener("focus", onFocus); |
||||
settingDiv.style.display = "none"; |
||||
}); |
||||
} else { |
||||
editor.focus(); |
||||
} |
||||
}; |
||||
|
||||
editor.$setOption = editor.setOption; |
||||
editor.$getOption = editor.getOption; |
||||
editor.setOption = function(key, value) { |
||||
switch (key) { |
||||
case "mode": |
||||
editor.$setOption("mode", "ace/mode/" + value) |
||||
break; |
||||
case "theme": |
||||
editor.$setOption("theme", "ace/theme/" + value) |
||||
break; |
||||
case "keybindings": |
||||
switch (value) { |
||||
case "vim": |
||||
editor.setKeyboardHandler("ace/keyboard/vim"); |
||||
break; |
||||
case "emacs": |
||||
editor.setKeyboardHandler("ace/keyboard/emacs"); |
||||
break; |
||||
default: |
||||
editor.setKeyboardHandler(null); |
||||
} |
||||
break; |
||||
|
||||
case "softWrap": |
||||
case "fontSize": |
||||
editor.$setOption(key, value); |
||||
break; |
||||
|
||||
default: |
||||
editor.$setOption(key, toBool(value)); |
||||
} |
||||
}; |
||||
|
||||
editor.getOption = function(key) { |
||||
switch (key) { |
||||
case "mode": |
||||
return editor.$getOption("mode").substr("ace/mode/".length) |
||||
break; |
||||
|
||||
case "theme": |
||||
return editor.$getOption("theme").substr("ace/theme/".length) |
||||
break; |
||||
|
||||
case "keybindings": |
||||
var value = editor.getKeyboardHandler() |
||||
switch (value && value.$id) { |
||||
case "ace/keyboard/vim": |
||||
return "vim"; |
||||
case "ace/keyboard/emacs": |
||||
return "emacs"; |
||||
default: |
||||
return "ace"; |
||||
} |
||||
break; |
||||
|
||||
default: |
||||
return editor.$getOption(key); |
||||
} |
||||
}; |
||||
|
||||
editor.setOptions(options); |
||||
return editor; |
||||
} |
||||
|
||||
function setupSettingPanel(settingDiv, settingOpener, editor) { |
||||
var BOOL = null; |
||||
|
||||
var desc = { |
||||
mode: "Mode:", |
||||
wrap: "Soft Wrap:", |
||||
theme: "Theme:", |
||||
fontSize: "Font Size:", |
||||
showGutter: "Display Gutter:", |
||||
keybindings: "Keyboard", |
||||
showPrintMargin: "Show Print Margin:", |
||||
useSoftTabs: "Use Soft Tabs:", |
||||
showInvisibles: "Show Invisibles" |
||||
}; |
||||
|
||||
var optionValues = { |
||||
mode: { |
||||
text: "Plain", |
||||
javascript: "JavaScript", |
||||
xml: "XML", |
||||
html: "HTML", |
||||
css: "CSS", |
||||
scss: "SCSS", |
||||
python: "Python", |
||||
php: "PHP", |
||||
java: "Java", |
||||
ruby: "Ruby", |
||||
c_cpp: "C/C++", |
||||
coffee: "CoffeeScript", |
||||
json: "json", |
||||
perl: "Perl", |
||||
clojure: "Clojure", |
||||
ocaml: "OCaml", |
||||
csharp: "C#", |
||||
haxe: "haXe", |
||||
svg: "SVG", |
||||
textile: "Textile", |
||||
groovy: "Groovy", |
||||
liquid: "Liquid", |
||||
Scala: "Scala" |
||||
}, |
||||
theme: { |
||||
clouds: "Clouds", |
||||
clouds_midnight: "Clouds Midnight", |
||||
cobalt: "Cobalt", |
||||
crimson_editor: "Crimson Editor", |
||||
dawn: "Dawn", |
||||
eclipse: "Eclipse", |
||||
idle_fingers: "Idle Fingers", |
||||
kr_theme: "Kr Theme", |
||||
merbivore: "Merbivore", |
||||
merbivore_soft: "Merbivore Soft", |
||||
mono_industrial: "Mono Industrial", |
||||
monokai: "Monokai", |
||||
pastel_on_dark: "Pastel On Dark", |
||||
solarized_dark: "Solarized Dark", |
||||
solarized_light: "Solarized Light", |
||||
textmate: "Textmate", |
||||
twilight: "Twilight", |
||||
vibrant_ink: "Vibrant Ink" |
||||
}, |
||||
showGutter: BOOL, |
||||
fontSize: { |
||||
"10px": "10px", |
||||
"11px": "11px", |
||||
"12px": "12px", |
||||
"14px": "14px", |
||||
"16px": "16px" |
||||
}, |
||||
wrap: { |
||||
off: "Off", |
||||
40: "40", |
||||
80: "80", |
||||
free: "Free" |
||||
}, |
||||
keybindings: { |
||||
ace: "ace", |
||||
vim: "vim", |
||||
emacs: "emacs" |
||||
}, |
||||
showPrintMargin: BOOL, |
||||
useSoftTabs: BOOL, |
||||
showInvisibles: BOOL |
||||
}; |
||||
|
||||
var table = []; |
||||
table.push("<table><tr><th>Setting</th><th>Value</th></tr>"); |
||||
|
||||
function renderOption(builder, option, obj, cValue) { |
||||
if (!obj) { |
||||
builder.push( |
||||
"<input type='checkbox' title='", option, "' ", |
||||
cValue + "" == "true" ? "checked='true'" : "", |
||||
"'></input>" |
||||
); |
||||
return; |
||||
} |
||||
builder.push("<select title='" + option + "'>"); |
||||
for (var value in obj) { |
||||
builder.push("<option value='" + value + "' "); |
||||
|
||||
if (cValue == value) { |
||||
builder.push(" selected "); |
||||
} |
||||
|
||||
builder.push(">", |
||||
obj[value], |
||||
"</option>"); |
||||
} |
||||
builder.push("</select>"); |
||||
} |
||||
|
||||
for (var option in exports.defaultOptions) { |
||||
table.push("<tr><td>", desc[option], "</td>"); |
||||
table.push("<td>"); |
||||
renderOption(table, option, optionValues[option], editor.getOption(option)); |
||||
table.push("</td></tr>"); |
||||
} |
||||
table.push("</table>"); |
||||
settingDiv.innerHTML = table.join(""); |
||||
|
||||
var onChange = function(e) { |
||||
var select = e.currentTarget; |
||||
editor.setOption(select.title, select.value); |
||||
}; |
||||
var onClick = function(e) { |
||||
var cb = e.currentTarget; |
||||
editor.setOption(cb.title, cb.checked); |
||||
}; |
||||
var selects = settingDiv.getElementsByTagName("select"); |
||||
for (var i = 0; i < selects.length; i++) |
||||
selects[i].onchange = onChange; |
||||
var cbs = settingDiv.getElementsByTagName("input"); |
||||
for (var i = 0; i < cbs.length; i++) |
||||
cbs[i].onclick = onClick; |
||||
|
||||
|
||||
var button = document.createElement("input"); |
||||
button.type = "button"; |
||||
button.value = "Hide"; |
||||
event.addListener(button, "click", function() { |
||||
editor.setDisplaySettings(false); |
||||
}); |
||||
settingDiv.appendChild(button); |
||||
settingDiv.hideButton = button; |
||||
} |
||||
exports.defaultOptions = { |
||||
mode: "javascript", |
||||
theme: "textmate", |
||||
wrap: "off", |
||||
fontSize: "12px", |
||||
showGutter: "false", |
||||
keybindings: "ace", |
||||
showPrintMargin: "false", |
||||
useSoftTabs: "true", |
||||
showInvisibles: "false" |
||||
}; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/textarea"], function() {}); |
||||
})(); |
||||
|
@ -1,60 +0,0 @@
|
||||
ace.define("ace/ext/themelist",["require","exports","module","ace/lib/fixoldbrowsers"], function(require, exports, module) { |
||||
"use strict"; |
||||
require("ace/lib/fixoldbrowsers"); |
||||
|
||||
var themeData = [ |
||||
["Chrome" ], |
||||
["Clouds" ], |
||||
["Crimson Editor" ], |
||||
["Dawn" ], |
||||
["Dreamweaver" ], |
||||
["Eclipse" ], |
||||
["GitHub" ], |
||||
["IPlastic" ], |
||||
["Solarized Light"], |
||||
["TextMate" ], |
||||
["Tomorrow" ], |
||||
["XCode" ], |
||||
["Kuroir"], |
||||
["KatzenMilch"], |
||||
["SQL Server" ,"sqlserver" , "light"], |
||||
["Ambiance" ,"ambiance" , "dark"], |
||||
["Chaos" ,"chaos" , "dark"], |
||||
["Clouds Midnight" ,"clouds_midnight" , "dark"], |
||||
["Cobalt" ,"cobalt" , "dark"], |
||||
["idle Fingers" ,"idle_fingers" , "dark"], |
||||
["krTheme" ,"kr_theme" , "dark"], |
||||
["Merbivore" ,"merbivore" , "dark"], |
||||
["Merbivore Soft" ,"merbivore_soft" , "dark"], |
||||
["Mono Industrial" ,"mono_industrial" , "dark"], |
||||
["Monokai" ,"monokai" , "dark"], |
||||
["Pastel on dark" ,"pastel_on_dark" , "dark"], |
||||
["Solarized Dark" ,"solarized_dark" , "dark"], |
||||
["Terminal" ,"terminal" , "dark"], |
||||
["Tomorrow Night" ,"tomorrow_night" , "dark"], |
||||
["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"], |
||||
["Tomorrow Night Bright","tomorrow_night_bright" , "dark"], |
||||
["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"], |
||||
["Twilight" ,"twilight" , "dark"], |
||||
["Vibrant Ink" ,"vibrant_ink" , "dark"] |
||||
]; |
||||
|
||||
|
||||
exports.themesByName = {}; |
||||
exports.themes = themeData.map(function(data) { |
||||
var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); |
||||
var theme = { |
||||
caption: data[0], |
||||
theme: "ace/theme/" + name, |
||||
isDark: data[2] == "dark", |
||||
name: name |
||||
}; |
||||
exports.themesByName[name] = theme; |
||||
return theme; |
||||
}); |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/themelist"], function() {}); |
||||
})(); |
||||
|
@ -1,181 +0,0 @@
|
||||
ace.define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var lang = require("../lib/lang"); |
||||
exports.$detectIndentation = function(lines, fallback) { |
||||
var stats = []; |
||||
var changes = []; |
||||
var tabIndents = 0; |
||||
var prevSpaces = 0; |
||||
var max = Math.min(lines.length, 1000); |
||||
for (var i = 0; i < max; i++) { |
||||
var line = lines[i]; |
||||
if (!/^\s*[^*+\-\s]/.test(line)) |
||||
continue; |
||||
|
||||
if (line[0] == "\t") |
||||
tabIndents++; |
||||
|
||||
var spaces = line.match(/^ */)[0].length; |
||||
if (spaces && line[spaces] != "\t") { |
||||
var diff = spaces - prevSpaces; |
||||
if (diff > 0 && !(prevSpaces%diff) && !(spaces%diff)) |
||||
changes[diff] = (changes[diff] || 0) + 1; |
||||
|
||||
stats[spaces] = (stats[spaces] || 0) + 1; |
||||
} |
||||
prevSpaces = spaces; |
||||
while (i < max && line[line.length - 1] == "\\") |
||||
line = lines[i++]; |
||||
} |
||||
|
||||
function getScore(indent) { |
||||
var score = 0; |
||||
for (var i = indent; i < stats.length; i += indent) |
||||
score += stats[i] || 0; |
||||
return score; |
||||
} |
||||
|
||||
var changesTotal = changes.reduce(function(a,b){return a+b}, 0); |
||||
|
||||
var first = {score: 0, length: 0}; |
||||
var spaceIndents = 0; |
||||
for (var i = 1; i < 12; i++) { |
||||
var score = getScore(i); |
||||
if (i == 1) { |
||||
spaceIndents = score; |
||||
score = stats[1] ? 0.9 : 0.8; |
||||
if (!stats.length) |
||||
score = 0 |
||||
} else |
||||
score /= spaceIndents; |
||||
|
||||
if (changes[i]) |
||||
score += changes[i] / changesTotal; |
||||
|
||||
if (score > first.score) |
||||
first = {score: score, length: i}; |
||||
} |
||||
|
||||
if (first.score && first.score > 1.4) |
||||
var tabLength = first.length; |
||||
|
||||
if (tabIndents > spaceIndents + 1) |
||||
return {ch: "\t", length: tabLength}; |
||||
|
||||
if (spaceIndents > tabIndents + 1) |
||||
return {ch: " ", length: tabLength}; |
||||
}; |
||||
|
||||
exports.detectIndentation = function(session) { |
||||
var lines = session.getLines(0, 1000); |
||||
var indent = exports.$detectIndentation(lines) || {}; |
||||
|
||||
if (indent.ch) |
||||
session.setUseSoftTabs(indent.ch == " "); |
||||
|
||||
if (indent.length) |
||||
session.setTabSize(indent.length); |
||||
return indent; |
||||
}; |
||||
|
||||
exports.trimTrailingSpace = function(session, trimEmpty) { |
||||
var doc = session.getDocument(); |
||||
var lines = doc.getAllLines(); |
||||
|
||||
var min = trimEmpty ? -1 : 0; |
||||
|
||||
for (var i = 0, l=lines.length; i < l; i++) { |
||||
var line = lines[i]; |
||||
var index = line.search(/\s+$/); |
||||
|
||||
if (index > min) |
||||
doc.removeInLine(i, index, line.length); |
||||
} |
||||
}; |
||||
|
||||
exports.convertIndentation = function(session, ch, len) { |
||||
var oldCh = session.getTabString()[0]; |
||||
var oldLen = session.getTabSize(); |
||||
if (!len) len = oldLen; |
||||
if (!ch) ch = oldCh; |
||||
|
||||
var tab = ch == "\t" ? ch: lang.stringRepeat(ch, len); |
||||
|
||||
var doc = session.doc; |
||||
var lines = doc.getAllLines(); |
||||
|
||||
var cache = {}; |
||||
var spaceCache = {}; |
||||
for (var i = 0, l=lines.length; i < l; i++) { |
||||
var line = lines[i]; |
||||
var match = line.match(/^\s*/)[0]; |
||||
if (match) { |
||||
var w = session.$getStringScreenWidth(match)[0]; |
||||
var tabCount = Math.floor(w/oldLen); |
||||
var reminder = w%oldLen; |
||||
var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount)); |
||||
toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder)); |
||||
|
||||
if (toInsert != match) { |
||||
doc.removeInLine(i, 0, match.length); |
||||
doc.insertInLine({row: i, column: 0}, toInsert); |
||||
} |
||||
} |
||||
} |
||||
session.setTabSize(len); |
||||
session.setUseSoftTabs(ch == " "); |
||||
}; |
||||
|
||||
exports.$parseStringArg = function(text) { |
||||
var indent = {}; |
||||
if (/t/.test(text)) |
||||
indent.ch = "\t"; |
||||
else if (/s/.test(text)) |
||||
indent.ch = " "; |
||||
var m = text.match(/\d+/); |
||||
if (m) |
||||
indent.length = parseInt(m[0], 10); |
||||
return indent; |
||||
}; |
||||
|
||||
exports.$parseArg = function(arg) { |
||||
if (!arg) |
||||
return {}; |
||||
if (typeof arg == "string") |
||||
return exports.$parseStringArg(arg); |
||||
if (typeof arg.text == "string") |
||||
return exports.$parseStringArg(arg.text); |
||||
return arg; |
||||
}; |
||||
|
||||
exports.commands = [{ |
||||
name: "detectIndentation", |
||||
exec: function(editor) { |
||||
exports.detectIndentation(editor.session); |
||||
} |
||||
}, { |
||||
name: "trimTrailingSpace", |
||||
exec: function(editor) { |
||||
exports.trimTrailingSpace(editor.session); |
||||
} |
||||
}, { |
||||
name: "convertIndentation", |
||||
exec: function(editor, arg) { |
||||
var indent = exports.$parseArg(arg); |
||||
exports.convertIndentation(editor.session, indent.ch, indent.length); |
||||
} |
||||
}, { |
||||
name: "setIndentation", |
||||
exec: function(editor, arg) { |
||||
var indent = exports.$parseArg(arg); |
||||
indent.length && editor.session.setTabSize(indent.length); |
||||
indent.ch && editor.session.setUseSoftTabs(indent.ch == " "); |
||||
} |
||||
}]; |
||||
|
||||
}); |
||||
(function() { |
||||
ace.require(["ace/ext/whitespace"], function() {}); |
||||
})(); |
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,668 +0,0 @@
|
||||
ace.define("ace/mode/json_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var oop = require("../lib/oop"); |
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
||||
|
||||
var JsonHighlightRules = function() { |
||||
this.$rules = { |
||||
"start" : [ |
||||
{ |
||||
token : "variable", // single line
|
||||
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)' |
||||
}, { |
||||
token : "string", // single line
|
||||
regex : '"', |
||||
next : "string" |
||||
}, { |
||||
token : "constant.numeric", // hex
|
||||
regex : "0[xX][0-9a-fA-F]+\\b" |
||||
}, { |
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" |
||||
}, { |
||||
token : "constant.language.boolean", |
||||
regex : "(?:true|false)\\b" |
||||
}, { |
||||
token : "invalid.illegal", // single quoted strings are not allowed
|
||||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" |
||||
}, { |
||||
token : "invalid.illegal", // comments are not allowed
|
||||
regex : "\\/\\/.*$" |
||||
}, { |
||||
token : "paren.lparen", |
||||
regex : "[[({]" |
||||
}, { |
||||
token : "paren.rparen", |
||||
regex : "[\\])}]" |
||||
}, { |
||||
token : "text", |
||||
regex : "\\s+" |
||||
} |
||||
], |
||||
"string" : [ |
||||
{ |
||||
token : "constant.language.escape", |
||||
regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/ |
||||
}, { |
||||
token : "string", |
||||
regex : '[^"\\\\]+' |
||||
}, { |
||||
token : "string", |
||||
regex : '"', |
||||
next : "start" |
||||
}, { |
||||
token : "string", |
||||
regex : "", |
||||
next : "start" |
||||
} |
||||
] |
||||
}; |
||||
|
||||
}; |
||||
|
||||
oop.inherits(JsonHighlightRules, TextHighlightRules); |
||||
|
||||
exports.JsonHighlightRules = JsonHighlightRules; |
||||
}); |
||||
|
||||
ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var Range = require("../range").Range; |
||||
|
||||
var MatchingBraceOutdent = function() {}; |
||||
|
||||
(function() { |
||||
|
||||
this.checkOutdent = function(line, input) { |
||||
if (! /^\s+$/.test(line)) |
||||
return false; |
||||
|
||||
return /^\s*\}/.test(input); |
||||
}; |
||||
|
||||
this.autoOutdent = function(doc, row) { |
||||
var line = doc.getLine(row); |
||||
var match = line.match(/^(\s*\})/); |
||||
|
||||
if (!match) return 0; |
||||
|
||||
var column = match[1].length; |
||||
var openBracePos = doc.findMatchingBracket({row: row, column: column}); |
||||
|
||||
if (!openBracePos || openBracePos.row == row) return 0; |
||||
|
||||
var indent = this.$getIndent(doc.getLine(openBracePos.row)); |
||||
doc.replace(new Range(row, 0, row, column-1), indent); |
||||
}; |
||||
|
||||
this.$getIndent = function(line) { |
||||
return line.match(/^\s*/)[0]; |
||||
}; |
||||
|
||||
}).call(MatchingBraceOutdent.prototype); |
||||
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent; |
||||
}); |
||||
|
||||
ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var oop = require("../../lib/oop"); |
||||
var Behaviour = require("../behaviour").Behaviour; |
||||
var TokenIterator = require("../../token_iterator").TokenIterator; |
||||
var lang = require("../../lib/lang"); |
||||
|
||||
var SAFE_INSERT_IN_TOKENS = |
||||
["text", "paren.rparen", "punctuation.operator"]; |
||||
var SAFE_INSERT_BEFORE_TOKENS = |
||||
["text", "paren.rparen", "punctuation.operator", "comment"]; |
||||
|
||||
var context; |
||||
var contextCache = {}; |
||||
var initContext = function(editor) { |
||||
var id = -1; |
||||
if (editor.multiSelect) { |
||||
id = editor.selection.index; |
||||
if (contextCache.rangeCount != editor.multiSelect.rangeCount) |
||||
contextCache = {rangeCount: editor.multiSelect.rangeCount}; |
||||
} |
||||
if (contextCache[id]) |
||||
return context = contextCache[id]; |
||||
context = contextCache[id] = { |
||||
autoInsertedBrackets: 0, |
||||
autoInsertedRow: -1, |
||||
autoInsertedLineEnd: "", |
||||
maybeInsertedBrackets: 0, |
||||
maybeInsertedRow: -1, |
||||
maybeInsertedLineStart: "", |
||||
maybeInsertedLineEnd: "" |
||||
}; |
||||
}; |
||||
|
||||
var getWrapped = function(selection, selected, opening, closing) { |
||||
var rowDiff = selection.end.row - selection.start.row; |
||||
return { |
||||
text: opening + selected + closing, |
||||
selection: [ |
||||
0, |
||||
selection.start.column + 1, |
||||
rowDiff, |
||||
selection.end.column + (rowDiff ? 0 : 1) |
||||
] |
||||
}; |
||||
}; |
||||
|
||||
var CstyleBehaviour = function() { |
||||
this.add("braces", "insertion", function(state, action, editor, session, text) { |
||||
var cursor = editor.getCursorPosition(); |
||||
var line = session.doc.getLine(cursor.row); |
||||
if (text == '{') { |
||||
initContext(editor); |
||||
var selection = editor.getSelectionRange(); |
||||
var selected = session.doc.getTextRange(selection); |
||||
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { |
||||
return getWrapped(selection, selected, '{', '}'); |
||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
||||
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) { |
||||
CstyleBehaviour.recordAutoInsert(editor, session, "}"); |
||||
return { |
||||
text: '{}', |
||||
selection: [1, 1] |
||||
}; |
||||
} else { |
||||
CstyleBehaviour.recordMaybeInsert(editor, session, "{"); |
||||
return { |
||||
text: '{', |
||||
selection: [1, 1] |
||||
}; |
||||
} |
||||
} |
||||
} else if (text == '}') { |
||||
initContext(editor); |
||||
var rightChar = line.substring(cursor.column, cursor.column + 1); |
||||
if (rightChar == '}') { |
||||
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); |
||||
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
||||
CstyleBehaviour.popAutoInsertedClosing(); |
||||
return { |
||||
text: '', |
||||
selection: [1, 1] |
||||
}; |
||||
} |
||||
} |
||||
} else if (text == "\n" || text == "\r\n") { |
||||
initContext(editor); |
||||
var closing = ""; |
||||
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) { |
||||
closing = lang.stringRepeat("}", context.maybeInsertedBrackets); |
||||
CstyleBehaviour.clearMaybeInsertedClosing(); |
||||
} |
||||
var rightChar = line.substring(cursor.column, cursor.column + 1); |
||||
if (rightChar === '}') { |
||||
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}'); |
||||
if (!openBracePos) |
||||
return null; |
||||
var next_indent = this.$getIndent(session.getLine(openBracePos.row)); |
||||
} else if (closing) { |
||||
var next_indent = this.$getIndent(line); |
||||
} else { |
||||
CstyleBehaviour.clearMaybeInsertedClosing(); |
||||
return; |
||||
} |
||||
var indent = next_indent + session.getTabString(); |
||||
|
||||
return { |
||||
text: '\n' + indent + '\n' + next_indent + closing, |
||||
selection: [1, indent.length, 1, indent.length] |
||||
}; |
||||
} else { |
||||
CstyleBehaviour.clearMaybeInsertedClosing(); |
||||
} |
||||
}); |
||||
|
||||
this.add("braces", "deletion", function(state, action, editor, session, range) { |
||||
var selected = session.doc.getTextRange(range); |
||||
if (!range.isMultiLine() && selected == '{') { |
||||
initContext(editor); |
||||
var line = session.doc.getLine(range.start.row); |
||||
var rightChar = line.substring(range.end.column, range.end.column + 1); |
||||
if (rightChar == '}') { |
||||
range.end.column++; |
||||
return range; |
||||
} else { |
||||
context.maybeInsertedBrackets--; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
this.add("parens", "insertion", function(state, action, editor, session, text) { |
||||
if (text == '(') { |
||||
initContext(editor); |
||||
var selection = editor.getSelectionRange(); |
||||
var selected = session.doc.getTextRange(selection); |
||||
if (selected !== "" && editor.getWrapBehavioursEnabled()) { |
||||
return getWrapped(selection, selected, '(', ')'); |
||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
||||
CstyleBehaviour.recordAutoInsert(editor, session, ")"); |
||||
return { |
||||
text: '()', |
||||
selection: [1, 1] |
||||
}; |
||||
} |
||||
} else if (text == ')') { |
||||
initContext(editor); |
||||
var cursor = editor.getCursorPosition(); |
||||
var line = session.doc.getLine(cursor.row); |
||||
var rightChar = line.substring(cursor.column, cursor.column + 1); |
||||
if (rightChar == ')') { |
||||
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); |
||||
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
||||
CstyleBehaviour.popAutoInsertedClosing(); |
||||
return { |
||||
text: '', |
||||
selection: [1, 1] |
||||
}; |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
|
||||
this.add("parens", "deletion", function(state, action, editor, session, range) { |
||||
var selected = session.doc.getTextRange(range); |
||||
if (!range.isMultiLine() && selected == '(') { |
||||
initContext(editor); |
||||
var line = session.doc.getLine(range.start.row); |
||||
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
||||
if (rightChar == ')') { |
||||
range.end.column++; |
||||
return range; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
this.add("brackets", "insertion", function(state, action, editor, session, text) { |
||||
if (text == '[') { |
||||
initContext(editor); |
||||
var selection = editor.getSelectionRange(); |
||||
var selected = session.doc.getTextRange(selection); |
||||
if (selected !== "" && editor.getWrapBehavioursEnabled()) { |
||||
return getWrapped(selection, selected, '[', ']'); |
||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
||||
CstyleBehaviour.recordAutoInsert(editor, session, "]"); |
||||
return { |
||||
text: '[]', |
||||
selection: [1, 1] |
||||
}; |
||||
} |
||||
} else if (text == ']') { |
||||
initContext(editor); |
||||
var cursor = editor.getCursorPosition(); |
||||
var line = session.doc.getLine(cursor.row); |
||||
var rightChar = line.substring(cursor.column, cursor.column + 1); |
||||
if (rightChar == ']') { |
||||
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); |
||||
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
||||
CstyleBehaviour.popAutoInsertedClosing(); |
||||
return { |
||||
text: '', |
||||
selection: [1, 1] |
||||
}; |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
|
||||
this.add("brackets", "deletion", function(state, action, editor, session, range) { |
||||
var selected = session.doc.getTextRange(range); |
||||
if (!range.isMultiLine() && selected == '[') { |
||||
initContext(editor); |
||||
var line = session.doc.getLine(range.start.row); |
||||
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
||||
if (rightChar == ']') { |
||||
range.end.column++; |
||||
return range; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
this.add("string_dquotes", "insertion", function(state, action, editor, session, text) { |
||||
if (text == '"' || text == "'") { |
||||
initContext(editor); |
||||
var quote = text; |
||||
var selection = editor.getSelectionRange(); |
||||
var selected = session.doc.getTextRange(selection); |
||||
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { |
||||
return getWrapped(selection, selected, quote, quote); |
||||
} else if (!selected) { |
||||
var cursor = editor.getCursorPosition(); |
||||
var line = session.doc.getLine(cursor.row); |
||||
var leftChar = line.substring(cursor.column-1, cursor.column); |
||||
var rightChar = line.substring(cursor.column, cursor.column + 1); |
||||
|
||||
var token = session.getTokenAt(cursor.row, cursor.column); |
||||
var rightToken = session.getTokenAt(cursor.row, cursor.column + 1); |
||||
if (leftChar == "\\" && token && /escape/.test(token.type)) |
||||
return null; |
||||
|
||||
var stringBefore = token && /string/.test(token.type); |
||||
var stringAfter = !rightToken || /string/.test(rightToken.type); |
||||
|
||||
var pair; |
||||
if (rightChar == quote) { |
||||
pair = stringBefore !== stringAfter; |
||||
} else { |
||||
if (stringBefore && !stringAfter) |
||||
return null; // wrap string with different quote
|
||||
if (stringBefore && stringAfter) |
||||
return null; // do not pair quotes inside strings
|
||||
var wordRe = session.$mode.tokenRe; |
||||
wordRe.lastIndex = 0; |
||||
var isWordBefore = wordRe.test(leftChar); |
||||
wordRe.lastIndex = 0; |
||||
var isWordAfter = wordRe.test(leftChar); |
||||
if (isWordBefore || isWordAfter) |
||||
return null; // before or after alphanumeric
|
||||
if (rightChar && !/[\s;,.})\]\\]/.test(rightChar)) |
||||
return null; // there is rightChar and it isn't closing
|
||||
pair = true; |
||||
} |
||||
return { |
||||
text: pair ? quote + quote : "", |
||||
selection: [1,1] |
||||
}; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { |
||||
var selected = session.doc.getTextRange(range); |
||||
if (!range.isMultiLine() && (selected == '"' || selected == "'")) { |
||||
initContext(editor); |
||||
var line = session.doc.getLine(range.start.row); |
||||
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
||||
if (rightChar == selected) { |
||||
range.end.column++; |
||||
return range; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
}; |
||||
|
||||
|
||||
CstyleBehaviour.isSaneInsertion = function(editor, session) { |
||||
var cursor = editor.getCursorPosition(); |
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column); |
||||
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { |
||||
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); |
||||
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) |
||||
return false; |
||||
} |
||||
iterator.stepForward(); |
||||
return iterator.getCurrentTokenRow() !== cursor.row || |
||||
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); |
||||
}; |
||||
|
||||
CstyleBehaviour.$matchTokenType = function(token, types) { |
||||
return types.indexOf(token.type || token) > -1; |
||||
}; |
||||
|
||||
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { |
||||
var cursor = editor.getCursorPosition(); |
||||
var line = session.doc.getLine(cursor.row); |
||||
if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0])) |
||||
context.autoInsertedBrackets = 0; |
||||
context.autoInsertedRow = cursor.row; |
||||
context.autoInsertedLineEnd = bracket + line.substr(cursor.column); |
||||
context.autoInsertedBrackets++; |
||||
}; |
||||
|
||||
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) { |
||||
var cursor = editor.getCursorPosition(); |
||||
var line = session.doc.getLine(cursor.row); |
||||
if (!this.isMaybeInsertedClosing(cursor, line)) |
||||
context.maybeInsertedBrackets = 0; |
||||
context.maybeInsertedRow = cursor.row; |
||||
context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; |
||||
context.maybeInsertedLineEnd = line.substr(cursor.column); |
||||
context.maybeInsertedBrackets++; |
||||
}; |
||||
|
||||
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { |
||||
return context.autoInsertedBrackets > 0 && |
||||
cursor.row === context.autoInsertedRow && |
||||
bracket === context.autoInsertedLineEnd[0] && |
||||
line.substr(cursor.column) === context.autoInsertedLineEnd; |
||||
}; |
||||
|
||||
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) { |
||||
return context.maybeInsertedBrackets > 0 && |
||||
cursor.row === context.maybeInsertedRow && |
||||
line.substr(cursor.column) === context.maybeInsertedLineEnd && |
||||
line.substr(0, cursor.column) == context.maybeInsertedLineStart; |
||||
}; |
||||
|
||||
CstyleBehaviour.popAutoInsertedClosing = function() { |
||||
context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1); |
||||
context.autoInsertedBrackets--; |
||||
}; |
||||
|
||||
CstyleBehaviour.clearMaybeInsertedClosing = function() { |
||||
if (context) { |
||||
context.maybeInsertedBrackets = 0; |
||||
context.maybeInsertedRow = -1; |
||||
} |
||||
}; |
||||
|
||||
|
||||
|
||||
oop.inherits(CstyleBehaviour, Behaviour); |
||||
|
||||
exports.CstyleBehaviour = CstyleBehaviour; |
||||
}); |
||||
|
||||
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var oop = require("../../lib/oop"); |
||||
var Range = require("../../range").Range; |
||||
var BaseFoldMode = require("./fold_mode").FoldMode; |
||||
|
||||
var FoldMode = exports.FoldMode = function(commentRegex) { |
||||
if (commentRegex) { |
||||
this.foldingStartMarker = new RegExp( |
||||
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) |
||||
); |
||||
this.foldingStopMarker = new RegExp( |
||||
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) |
||||
); |
||||
} |
||||
}; |
||||
oop.inherits(FoldMode, BaseFoldMode); |
||||
|
||||
(function() { |
||||
|
||||
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; |
||||
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; |
||||
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; |
||||
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
||||
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
||||
this._getFoldWidgetBase = this.getFoldWidget; |
||||
this.getFoldWidget = function(session, foldStyle, row) { |
||||
var line = session.getLine(row); |
||||
|
||||
if (this.singleLineBlockCommentRe.test(line)) { |
||||
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
||||
return ""; |
||||
} |
||||
|
||||
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
||||
|
||||
if (!fw && this.startRegionRe.test(line)) |
||||
return "start"; // lineCommentRegionStart
|
||||
|
||||
return fw; |
||||
}; |
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { |
||||
var line = session.getLine(row); |
||||
|
||||
if (this.startRegionRe.test(line)) |
||||
return this.getCommentRegionBlock(session, line, row); |
||||
|
||||
var match = line.match(this.foldingStartMarker); |
||||
if (match) { |
||||
var i = match.index; |
||||
|
||||
if (match[1]) |
||||
return this.openingBracketBlock(session, match[1], row, i); |
||||
|
||||
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
||||
|
||||
if (range && !range.isMultiLine()) { |
||||
if (forceMultiline) { |
||||
range = this.getSectionRange(session, row); |
||||
} else if (foldStyle != "all") |
||||
range = null; |
||||
} |
||||
|
||||
return range; |
||||
} |
||||
|
||||
if (foldStyle === "markbegin") |
||||
return; |
||||
|
||||
var match = line.match(this.foldingStopMarker); |
||||
if (match) { |
||||
var i = match.index + match[0].length; |
||||
|
||||
if (match[1]) |
||||
return this.closingBracketBlock(session, match[1], row, i); |
||||
|
||||
return session.getCommentFoldRange(row, i, -1); |
||||
} |
||||
}; |
||||
|
||||
this.getSectionRange = function(session, row) { |
||||
var line = session.getLine(row); |
||||
var startIndent = line.search(/\S/); |
||||
var startRow = row; |
||||
var startColumn = line.length; |
||||
row = row + 1; |
||||
var endRow = row; |
||||
var maxRow = session.getLength(); |
||||
while (++row < maxRow) { |
||||
line = session.getLine(row); |
||||
var indent = line.search(/\S/); |
||||
if (indent === -1) |
||||
continue; |
||||
if (startIndent > indent) |
||||
break; |
||||
var subRange = this.getFoldWidgetRange(session, "all", row); |
||||
|
||||
if (subRange) { |
||||
if (subRange.start.row <= startRow) { |
||||
break; |
||||
} else if (subRange.isMultiLine()) { |
||||
row = subRange.end.row; |
||||
} else if (startIndent == indent) { |
||||
break; |
||||
} |
||||
} |
||||
endRow = row; |
||||
} |
||||
|
||||
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
||||
}; |
||||
this.getCommentRegionBlock = function(session, line, row) { |
||||
var startColumn = line.search(/\s*$/); |
||||
var maxRow = session.getLength(); |
||||
var startRow = row; |
||||
|
||||
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
||||
var depth = 1; |
||||
while (++row < maxRow) { |
||||
line = session.getLine(row); |
||||
var m = re.exec(line); |
||||
if (!m) continue; |
||||
if (m[1]) depth--; |
||||
else depth++; |
||||
|
||||
if (!depth) break; |
||||
} |
||||
|
||||
var endRow = row; |
||||
if (endRow > startRow) { |
||||
return new Range(startRow, startColumn, endRow, line.length); |
||||
} |
||||
}; |
||||
|
||||
}).call(FoldMode.prototype); |
||||
|
||||
}); |
||||
|
||||
ace.define("ace/mode/json",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle","ace/worker/worker_client"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
var oop = require("../lib/oop"); |
||||
var TextMode = require("./text").Mode; |
||||
var HighlightRules = require("./json_highlight_rules").JsonHighlightRules; |
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; |
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; |
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode; |
||||
var WorkerClient = require("../worker/worker_client").WorkerClient; |
||||
|
||||
var Mode = function() { |
||||
this.HighlightRules = HighlightRules; |
||||
this.$outdent = new MatchingBraceOutdent(); |
||||
this.$behaviour = new CstyleBehaviour(); |
||||
this.foldingRules = new CStyleFoldMode(); |
||||
}; |
||||
oop.inherits(Mode, TextMode); |
||||
|
||||
(function() { |
||||
|
||||
this.getNextLineIndent = function(state, line, tab) { |
||||
var indent = this.$getIndent(line); |
||||
|
||||
if (state == "start") { |
||||
var match = line.match(/^.*[\{\(\[]\s*$/); |
||||
if (match) { |
||||
indent += tab; |
||||
} |
||||
} |
||||
|
||||
return indent; |
||||
}; |
||||
|
||||
this.checkOutdent = function(state, line, input) { |
||||
return this.$outdent.checkOutdent(line, input); |
||||
}; |
||||
|
||||
this.autoOutdent = function(state, doc, row) { |
||||
this.$outdent.autoOutdent(doc, row); |
||||
}; |
||||
|
||||
this.createWorker = function(session) { |
||||
var worker = new WorkerClient(["ace"], "ace/mode/json_worker", "JsonWorker"); |
||||
worker.attachToDocument(session.getDocument()); |
||||
|
||||
worker.on("annotate", function(e) { |
||||
session.setAnnotations(e.data); |
||||
}); |
||||
|
||||
worker.on("terminate", function() { |
||||
session.clearAnnotations(); |
||||
}); |
||||
|
||||
return worker; |
||||
}; |
||||
|
||||
|
||||
this.$id = "ace/mode/json"; |
||||
}).call(Mode.prototype); |
||||
|
||||
exports.Mode = Mode; |
||||
}); |
File diff suppressed because one or more lines are too long
@ -1,189 +0,0 @@
|
||||
ace.define("ace/snippets/javascript",["require","exports","module"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
exports.snippetText = "# Prototype\n\ |
||||
snippet proto\n\ |
||||
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {\n\ |
||||
${4:// body...}\n\
|
||||
};\n\ |
||||
# Function\n\ |
||||
snippet fun\n\ |
||||
function ${1?:function_name}(${2:argument}) {\n\ |
||||
${3:// body...}\n\
|
||||
}\n\ |
||||
# Anonymous Function\n\ |
||||
regex /((=)\\s*|(:)\\s*|(\\()|\\b)/f/(\\))?/\n\ |
||||
snippet f\n\ |
||||
function${M1?: ${1:functionName}}($2) {\n\ |
||||
${0:$TM_SELECTED_TEXT}\n\ |
||||
}${M2?;}${M3?,}${M4?)}\n\ |
||||
# Immediate function\n\ |
||||
trigger \\(?f\\(\n\ |
||||
endTrigger \\)?\n\ |
||||
snippet f(\n\ |
||||
(function(${1}) {\n\ |
||||
${0:${TM_SELECTED_TEXT:/* code */}}\n\ |
||||
}(${1}));\n\ |
||||
# if\n\ |
||||
snippet if\n\ |
||||
if (${1:true}) {\n\ |
||||
${0}\n\ |
||||
}\n\ |
||||
# if ... else\n\ |
||||
snippet ife\n\ |
||||
if (${1:true}) {\n\ |
||||
${2}\n\ |
||||
} else {\n\ |
||||
${0}\n\ |
||||
}\n\ |
||||
# tertiary conditional\n\ |
||||
snippet ter\n\ |
||||
${1:/* condition */} ? ${2:a} : ${3:b}\n\ |
||||
# switch\n\ |
||||
snippet switch\n\ |
||||
switch (${1:expression}) {\n\ |
||||
case '${3:case}':\n\ |
||||
${4:// code}\n\
|
||||
break;\n\ |
||||
${5}\n\ |
||||
default:\n\ |
||||
${2:// code}\n\
|
||||
}\n\ |
||||
# case\n\ |
||||
snippet case\n\ |
||||
case '${1:case}':\n\ |
||||
${2:// code}\n\
|
||||
break;\n\ |
||||
${3}\n\ |
||||
\n\ |
||||
# while (...) {...}\n\ |
||||
snippet wh\n\ |
||||
while (${1:/* condition */}) {\n\ |
||||
${0:/* code */}\n\ |
||||
}\n\ |
||||
# try\n\ |
||||
snippet try\n\ |
||||
try {\n\ |
||||
${0:/* code */}\n\ |
||||
} catch (e) {}\n\ |
||||
# do...while\n\ |
||||
snippet do\n\ |
||||
do {\n\ |
||||
${2:/* code */}\n\ |
||||
} while (${1:/* condition */});\n\ |
||||
# Object Method\n\ |
||||
snippet :f\n\ |
||||
regex /([,{[])|^\\s*/:f/\n\ |
||||
${1:method_name}: function(${2:attribute}) {\n\ |
||||
${0}\n\ |
||||
}${3:,}\n\ |
||||
# setTimeout function\n\ |
||||
snippet setTimeout\n\ |
||||
regex /\\b/st|timeout|setTimeo?u?t?/\n\ |
||||
setTimeout(function() {${3:$TM_SELECTED_TEXT}}, ${1:10});\n\ |
||||
# Get Elements\n\ |
||||
snippet gett\n\ |
||||
getElementsBy${1:TagName}('${2}')${3}\n\ |
||||
# Get Element\n\ |
||||
snippet get\n\ |
||||
getElementBy${1:Id}('${2}')${3}\n\ |
||||
# console.log (Firebug)\n\ |
||||
snippet cl\n\ |
||||
console.log(${1});\n\ |
||||
# return\n\ |
||||
snippet ret\n\ |
||||
return ${1:result}\n\ |
||||
# for (property in object ) { ... }\n\ |
||||
snippet fori\n\ |
||||
for (var ${1:prop} in ${2:Things}) {\n\ |
||||
${0:$2[$1]}\n\ |
||||
}\n\ |
||||
# hasOwnProperty\n\ |
||||
snippet has\n\ |
||||
hasOwnProperty(${1})\n\ |
||||
# docstring\n\ |
||||
snippet /**\n\ |
||||
snippet @par\n\ |
||||
regex /^\\s*\\*\\s*/@(para?m?)?/\n\ |
||||
@param {${1:type}} ${2:name} ${3:description}\n\ |
||||
snippet @ret\n\ |
||||
@return {${1:type}} ${2:description}\n\ |
||||
# JSON.parse\n\ |
||||
snippet jsonp\n\ |
||||
JSON.parse(${1:jstr});\n\ |
||||
# JSON.stringify\n\ |
||||
snippet jsons\n\ |
||||
JSON.stringify(${1:object});\n\ |
||||
# self-defining function\n\ |
||||
snippet sdf\n\ |
||||
var ${1:function_name} = function(${2:argument}) {\n\ |
||||
${3:// initial code ...}\n\
|
||||
\n\ |
||||
$1 = function($2) {\n\ |
||||
${4:// main code}\n\
|
||||
};\n\ |
||||
}\n\ |
||||
# singleton\n\ |
||||
snippet sing\n\ |
||||
function ${1:Singleton} (${2:argument}) {\n\ |
||||
var instance;\n\ |
||||
$1 = function $1($2) {\n\ |
||||
return instance;\n\ |
||||
};\n\ |
||||
$1.prototype = this;\n\ |
||||
instance = new $1();\n\ |
||||
instance.constructor = $1;\n\ |
||||
\n\ |
||||
${3:// code ...}\n\
|
||||
\n\ |
||||
return instance;\n\ |
||||
}\n\ |
||||
# class\n\ |
||||
snippet class\n\ |
||||
regex /^\\s*/clas{0,2}/\n\ |
||||
var ${1:class} = function(${20}) {\n\ |
||||
$40$0\n\ |
||||
};\n\ |
||||
\n\ |
||||
(function() {\n\ |
||||
${60:this.prop = \"\"}\n\ |
||||
}).call(${1:class}.prototype);\n\ |
||||
\n\ |
||||
exports.${1:class} = ${1:class};\n\ |
||||
# \n\ |
||||
snippet for-\n\ |
||||
for (var ${1:i} = ${2:Things}.length; ${1:i}--; ) {\n\ |
||||
${0:${2:Things}[${1:i}];}\n\ |
||||
}\n\ |
||||
# for (...) {...}\n\ |
||||
snippet for\n\ |
||||
for (var ${1:i} = 0; $1 < ${2:Things}.length; $1++) {\n\ |
||||
${3:$2[$1]}$0\n\ |
||||
}\n\ |
||||
# for (...) {...} (Improved Native For-Loop)\n\ |
||||
snippet forr\n\ |
||||
for (var ${1:i} = ${2:Things}.length - 1; $1 >= 0; $1--) {\n\ |
||||
${3:$2[$1]}$0\n\ |
||||
}\n\ |
||||
\n\ |
||||
\n\ |
||||
#modules\n\ |
||||
snippet def\n\ |
||||
ace.define(function(require, exports, module) {\n\ |
||||
\"use strict\";\n\ |
||||
var ${1/.*\\///} = require(\"${1}\");\n\
|
||||
\n\ |
||||
$TM_SELECTED_TEXT\n\ |
||||
});\n\ |
||||
snippet req\n\ |
||||
guard ^\\s*\n\ |
||||
var ${1/.*\\///} = require(\"${1}\");\n\
|
||||
$0\n\ |
||||
snippet requ\n\ |
||||
guard ^\\s*\n\ |
||||
var ${1/.*\\/(.)/\\u$1/} = require(\"${1}\").${1/.*\\/(.)/\\u$1/};\n\ |
||||
$0\n\ |
||||
"; |
||||
exports.scope = "javascript"; |
||||
|
||||
}); |
@ -1,7 +0,0 @@
|
||||
ace.define("ace/snippets/json",["require","exports","module"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
exports.snippetText =undefined; |
||||
exports.scope = "json"; |
||||
|
||||
}); |
@ -1,68 +0,0 @@
|
||||
ace.define("ace/snippets/jsoniq",["require","exports","module"], function(require, exports, module) { |
||||
"use strict"; |
||||
|
||||
exports.snippetText = "snippet for\n\ |
||||
for $${1:item} in ${2:expr}\n\ |
||||
snippet return\n\ |
||||
return ${1:expr}\n\ |
||||
snippet import\n\ |
||||
import module namespace ${1:ns} = \"${2:http://www.example.com/}\";\n\ |
||||
snippet some\n\ |
||||
some $${1:varname} in ${2:expr} satisfies ${3:expr}\n\ |
||||
snippet every\n\ |
||||
every $${1:varname} in ${2:expr} satisfies ${3:expr}\n\ |
||||
snippet if\n\ |
||||
if(${1:true}) then ${2:expr} else ${3:true}\n\ |
||||
snippet switch\n\ |
||||
switch(${1:\"foo\"})\n\ |
||||
case ${2:\"foo\"}\n\ |
||||
return ${3:true}\n\ |
||||
default return ${4:false}\n\ |
||||
snippet try\n\ |
||||
try { ${1:expr} } catch ${2:*} { ${3:expr} }\n\ |
||||
snippet tumbling\n\ |
||||
for tumbling window $${1:varname} in ${2:expr}\n\ |
||||
start at $${3:start} when ${4:expr}\n\ |
||||
end at $${5:end} when ${6:expr}\n\ |
||||
return ${7:expr}\n\ |
||||
snippet sliding\n\ |
||||
for sliding window $${1:varname} in ${2:expr}\n\ |
||||
start at $${3:start} when ${4:expr}\n\ |
||||
end at $${5:end} when ${6:expr}\n\ |
||||
return ${7:expr}\n\ |
||||
snippet let\n\ |
||||
let $${1:varname} := ${2:expr}\n\ |
||||
snippet group\n\ |
||||
group by $${1:varname} := ${2:expr}\n\ |
||||
snippet order\n\ |
||||
order by ${1:expr} ${2:descending}\n\ |
||||
snippet stable\n\ |
||||
stable order by ${1:expr}\n\ |
||||
snippet count\n\ |
||||
count $${1:varname}\n\ |
||||
snippet ordered\n\ |
||||
ordered { ${1:expr} }\n\ |
||||
snippet unordered\n\ |
||||
unordered { ${1:expr} }\n\ |
||||
snippet treat \n\ |
||||
treat as ${1:expr}\n\ |
||||
snippet castable\n\ |
||||
castable as ${1:atomicType}\n\ |
||||
snippet cast\n\ |
||||
cast as ${1:atomicType}\n\ |
||||
snippet typeswitch\n\ |
||||
typeswitch(${1:expr})\n\ |
||||
case ${2:type} return ${3:expr}\n\ |
||||
default return ${4:expr}\n\ |
||||
snippet var\n\ |
||||
declare variable $${1:varname} := ${2:expr};\n\ |
||||
snippet fn\n\ |
||||
declare function ${1:ns}:${2:name}(){\n\ |
||||
${3:expr}\n\ |
||||
};\n\ |
||||
snippet module\n\ |
||||
module namespace ${1:ns} = \"${2:http://www.example.com}\";\n\ |
||||
"; |
||||
exports.scope = "jsoniq"; |
||||
|
||||
}); |
@ -1,110 +0,0 @@
|
||||
ace.define("ace/theme/twilight",["require","exports","module","ace/lib/dom"], function(require, exports, module) { |
||||
|
||||
exports.isDark = true; |
||||
exports.cssClass = "ace-twilight"; |
||||
exports.cssText = ".ace-twilight .ace_gutter {\ |
||||
background: #232323;\ |
||||
color: #E2E2E2\ |
||||
}\ |
||||
.ace-twilight .ace_print-margin {\ |
||||
width: 1px;\ |
||||
background: #232323\ |
||||
}\ |
||||
.ace-twilight {\ |
||||
background-color: #141414;\ |
||||
color: #F8F8F8\ |
||||
}\ |
||||
.ace-twilight .ace_cursor {\ |
||||
color: #A7A7A7\ |
||||
}\ |
||||
.ace-twilight .ace_marker-layer .ace_selection {\ |
||||
background: rgba(221, 240, 255, 0.20)\ |
||||
}\ |
||||
.ace-twilight.ace_multiselect .ace_selection.ace_start {\ |
||||
box-shadow: 0 0 3px 0px #141414;\ |
||||
border-radius: 2px\ |
||||
}\ |
||||
.ace-twilight .ace_marker-layer .ace_step {\ |
||||
background: rgb(102, 82, 0)\ |
||||
}\ |
||||
.ace-twilight .ace_marker-layer .ace_bracket {\ |
||||
margin: -1px 0 0 -1px;\ |
||||
border: 1px solid rgba(255, 255, 255, 0.25)\ |
||||
}\ |
||||
.ace-twilight .ace_marker-layer .ace_active-line {\ |
||||
background: rgba(255, 255, 255, 0.031)\ |
||||
}\ |
||||
.ace-twilight .ace_gutter-active-line {\ |
||||
background-color: rgba(255, 255, 255, 0.031)\ |
||||
}\ |
||||
.ace-twilight .ace_marker-layer .ace_selected-word {\ |
||||
border: 1px solid rgba(221, 240, 255, 0.20)\ |
||||
}\ |
||||
.ace-twilight .ace_invisible {\ |
||||
color: rgba(255, 255, 255, 0.25)\ |
||||
}\ |
||||
.ace-twilight .ace_keyword,\ |
||||
.ace-twilight .ace_meta {\ |
||||
color: #CDA869\ |
||||
}\ |
||||
.ace-twilight .ace_constant,\ |
||||
.ace-twilight .ace_constant.ace_character,\ |
||||
.ace-twilight .ace_constant.ace_character.ace_escape,\ |
||||
.ace-twilight .ace_constant.ace_other,\ |
||||
.ace-twilight .ace_heading,\ |
||||
.ace-twilight .ace_markup.ace_heading,\ |
||||
.ace-twilight .ace_support.ace_constant {\ |
||||
color: #CF6A4C\ |
||||
}\ |
||||
.ace-twilight .ace_invalid.ace_illegal {\ |
||||
color: #F8F8F8;\ |
||||
background-color: rgba(86, 45, 86, 0.75)\ |
||||
}\ |
||||
.ace-twilight .ace_invalid.ace_deprecated {\ |
||||
text-decoration: underline;\ |
||||
font-style: italic;\ |
||||
color: #D2A8A1\ |
||||
}\ |
||||
.ace-twilight .ace_support {\ |
||||
color: #9B859D\ |
||||
}\ |
||||
.ace-twilight .ace_fold {\ |
||||
background-color: #AC885B;\ |
||||
border-color: #F8F8F8\ |
||||
}\ |
||||
.ace-twilight .ace_support.ace_function {\ |
||||
color: #DAD085\ |
||||
}\ |
||||
.ace-twilight .ace_list,\ |
||||
.ace-twilight .ace_markup.ace_list,\ |
||||
.ace-twilight .ace_storage {\ |
||||
color: #F9EE98\ |
||||
}\ |
||||
.ace-twilight .ace_entity.ace_name.ace_function,\ |
||||
.ace-twilight .ace_meta.ace_tag,\ |
||||
.ace-twilight .ace_variable {\ |
||||
color: #AC885B\ |
||||
}\ |
||||
.ace-twilight .ace_string {\ |
||||
color: #8F9D6A\ |
||||
}\ |
||||
.ace-twilight .ace_string.ace_regexp {\ |
||||
color: #E9C062\ |
||||
}\ |
||||
.ace-twilight .ace_comment {\ |
||||
font-style: italic;\ |
||||
color: #5F5A60\ |
||||
}\ |
||||
.ace-twilight .ace_variable {\ |
||||
color: #7587A6\ |
||||
}\ |
||||
.ace-twilight .ace_xml-pe {\ |
||||
color: #494949\ |
||||
}\ |
||||
.ace-twilight .ace_indent-guide {\ |
||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMQERFpYLC1tf0PAAgOAnPnhxyiAAAAAElFTkSuQmCC) right repeat-y\ |
||||
}"; |
||||
|
||||
var dom = require("../lib/dom"); |
||||
dom.importCssString(exports.cssText, exports.cssClass); |
||||
}); |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,26 +0,0 @@
|
||||
Copyright (c) 2013, Michael Bostock |
||||
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. |
||||
|
||||
* The name Michael Bostock may not 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 MICHAEL BOSTOCK 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. |
@ -1,26 +0,0 @@
|
||||
Copyright (c) 2013, Michael Bostock |
||||
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. |
||||
|
||||
* The name Michael Bostock may not 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 MICHAEL BOSTOCK 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. |
@ -1,125 +0,0 @@
|
||||
// ===================================================
|
||||
// =============== SELECTING_NODE =============
|
||||
// ===================================================
|
||||
|
||||
'use strict'; |
||||
|
||||
var graph_actions = { |
||||
create: function create(svg, dvgraph) { |
||||
|
||||
return { |
||||
selectedIdx: -1, |
||||
selectedType: "normal", |
||||
svg: svg, |
||||
selectedObject: {}, |
||||
dvgraph: dvgraph, |
||||
|
||||
deselect_node: function deselect_node(d) { |
||||
delete d.fixed; |
||||
this.selectedIdx = -1; |
||||
this.selectedObject = {}; |
||||
|
||||
this.svg.selectAll('circle').each(function (node) { |
||||
node.filtered = false; |
||||
}).classed('filtered', false).transition(); |
||||
|
||||
this.svg.selectAll('path, text').classed('filtered', false).transition(); |
||||
|
||||
this.svg.selectAll('.link').attr("marker-end", "url(#default)").classed('filtered', false).classed('dependency', false).classed('dependants', false).transition(); |
||||
}, |
||||
|
||||
deselect_selected_node: function deselect_selected_node() { |
||||
this.deselect_node(this.selectedObject); |
||||
}, |
||||
|
||||
_lockNode: function _lockNode(node) { |
||||
node.fixed = true; |
||||
}, |
||||
|
||||
_unlockNode: function _unlockNode(node) { |
||||
delete node.fixed; |
||||
}, |
||||
|
||||
_selectAndLockNode: function _selectAndLockNode(node, type) { |
||||
this._unlockNode(this.selectedObject); |
||||
this.selectedIdx = node.idx; |
||||
this.selectedObject = node; |
||||
this.selectedType = type; |
||||
this._lockNode(this.selectedObject); |
||||
}, |
||||
|
||||
_deselectNodeIfNeeded: function _deselectNodeIfNeeded(node, type) { |
||||
if (node.idx == this.selectedIdx && this.selectedType == type) { |
||||
this.deselect_node(node); |
||||
return true; |
||||
} |
||||
return false; |
||||
}, |
||||
|
||||
_fadeOutAllNodesAndLinks: function _fadeOutAllNodesAndLinks() { |
||||
// Fade out all circles
|
||||
this.svg.selectAll('circle').classed('filtered', true).each(function (node) { |
||||
node.filtered = true; |
||||
node.neighbours = false; |
||||
}).transition(); |
||||
|
||||
this.svg.selectAll('text').classed('filtered', true).transition(); |
||||
|
||||
this.svg.selectAll('.link').classed('dependency', false).classed('dependants', false).transition().attr("marker-end", ""); |
||||
}, |
||||
|
||||
_highlightNodesWithIndexes: function _highlightNodesWithIndexes(indexesArray) { |
||||
this.svg.selectAll('circle, text').filter(function (node) { |
||||
return indexesArray.indexOf(node.index) > -1; |
||||
}).classed('filtered', false).each(function (node) { |
||||
node.filtered = false; |
||||
node.neighbours = true; |
||||
}).transition(); |
||||
}, |
||||
|
||||
_isDependencyLink: function _isDependencyLink(node, link) { |
||||
return link.source.index === node.index; |
||||
}, |
||||
_nodeExistsInLink: function _nodeExistsInLink(node, link) { |
||||
return link.source.index === node.index || link.target.index == node.index; |
||||
}, |
||||
_oppositeNodeOfLink: function _oppositeNodeOfLink(node, link) { |
||||
return link.source.index == node.index ? link.target : link.target.index == node.index ? link.source : null; |
||||
}, |
||||
|
||||
_highlightLinksFromRootWithNodesIndexes: function _highlightLinksFromRootWithNodesIndexes(root, nodeNeighbors, maxLevel) { |
||||
var _this = this; |
||||
|
||||
this.svg.selectAll('.link').filter(function (link) { |
||||
return nodeNeighbors.indexOf(link.source.index) > -1; |
||||
}).classed('filtered', false).classed('dependency', function (l) { |
||||
return _this._nodeExistsInLink(root, l) && _this._isDependencyLink(root, l); |
||||
}).classed('dependants', function (l) { |
||||
return _this._nodeExistsInLink(root, l) && !_this._isDependencyLink(root, l); |
||||
}).attr("marker-end", function (l) { |
||||
return _this._nodeExistsInLink(root, l) ? _this._isDependencyLink(root, l) ? "url(#dependency)" : "url(#dependants)" : maxLevel == 1 ? "" : "url(#default)"; |
||||
}).transition(); |
||||
}, |
||||
|
||||
selectNodesStartingFromNode: function selectNodesStartingFromNode(node) { |
||||
var maxLevel = arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1]; |
||||
|
||||
if (this._deselectNodeIfNeeded(node, "level" + maxLevel)) { |
||||
return; |
||||
} |
||||
this._selectAndLockNode(node, "level" + maxLevel); |
||||
|
||||
var neighborIndexes = this.dvgraph.nodesStartingFromNode(node, { max_level: maxLevel, use_backward_search: maxLevel == 1 }).map(function (n) { |
||||
return n.index; |
||||
}); |
||||
|
||||
this._fadeOutAllNodesAndLinks(); |
||||
this._highlightNodesWithIndexes(neighborIndexes); |
||||
this._highlightLinksFromRootWithNodesIndexes(node, neighborIndexes, maxLevel); |
||||
} |
||||
|
||||
}; |
||||
} |
||||
}; |
||||
|
||||
//# sourceMappingURL=graph-actions-select-compiled.js.map
|
@ -1,132 +0,0 @@
|
||||
// ===================================================
|
||||
// =============== SELECTING_NODE =============
|
||||
// ===================================================
|
||||
|
||||
let graph_actions = { |
||||
create: function (svg, dvgraph) { |
||||
|
||||
return { |
||||
selectedIdx: -1, |
||||
selectedType: "normal", |
||||
svg: svg, |
||||
selectedObject: {}, |
||||
dvgraph: dvgraph, |
||||
|
||||
deselect_node: function (d) { |
||||
delete d.fixed; |
||||
this.selectedIdx = -1; |
||||
this.selectedObject = {}; |
||||
|
||||
this.svg.selectAll('circle') |
||||
.each(function (node) { |
||||
node.filtered = false |
||||
}) |
||||
.classed('filtered', false) |
||||
.transition(); |
||||
|
||||
this.svg.selectAll('path, text') |
||||
.classed('filtered', false) |
||||
.transition(); |
||||
|
||||
|
||||
this.svg.selectAll('.link') |
||||
.attr("marker-end", "url(#default)") |
||||
.classed('filtered', false) |
||||
.classed('dependency', false) |
||||
.classed('dependants', false) |
||||
.transition(); |
||||
}, |
||||
|
||||
deselect_selected_node: function () { |
||||
this.deselect_node(this.selectedObject) |
||||
}, |
||||
|
||||
_lockNode: function (node) { |
||||
node.fixed = true; |
||||
}, |
||||
|
||||
_unlockNode: function (node) { |
||||
delete node.fixed; |
||||
}, |
||||
|
||||
_selectAndLockNode: function (node, type) { |
||||
this._unlockNode(this.selectedObject); |
||||
this.selectedIdx = node.idx; |
||||
this.selectedObject = node; |
||||
this.selectedType = type; |
||||
this._lockNode(this.selectedObject); |
||||
}, |
||||
|
||||
_deselectNodeIfNeeded: function (node, type) { |
||||
if (node.idx == this.selectedIdx && this.selectedType == type) { |
||||
this.deselect_node(node); |
||||
return true; |
||||
} |
||||
return false; |
||||
}, |
||||
|
||||
_fadeOutAllNodesAndLinks: function () { |
||||
// Fade out all circles
|
||||
this.svg.selectAll('circle') |
||||
.classed('filtered', true) |
||||
.each(function (node) { |
||||
node.filtered = true; |
||||
node.neighbours = false; |
||||
}).transition(); |
||||
|
||||
this.svg.selectAll('text') |
||||
.classed('filtered', true) |
||||
.transition(); |
||||
|
||||
this.svg.selectAll('.link') |
||||
.classed('dependency', false) |
||||
.classed('dependants', false) |
||||
.transition() |
||||
.attr("marker-end", ""); |
||||
|
||||
}, |
||||
|
||||
_highlightNodesWithIndexes: function (indexesArray) { |
||||
this.svg.selectAll('circle, text') |
||||
.filter((node) => indexesArray.indexOf(node.index) > -1) |
||||
.classed('filtered', false) |
||||
.each((node) => { |
||||
node.filtered = false; |
||||
node.neighbours = true; |
||||
}) |
||||
.transition(); |
||||
}, |
||||
|
||||
_isDependencyLink: (node, link) => (link.source.index === node.index), |
||||
_nodeExistsInLink: (node, link) => (link.source.index === node.index || link.target.index == node.index), |
||||
_oppositeNodeOfLink: (node, link) => (link.source.index == node.index ? link.target : link.target.index == node.index ? link.source : null), |
||||
|
||||
_highlightLinksFromRootWithNodesIndexes: function (root, nodeNeighbors, maxLevel) { |
||||
this.svg.selectAll('.link') |
||||
.filter((link) => nodeNeighbors.indexOf(link.source.index) > -1) |
||||
.classed('filtered', false) |
||||
.classed('dependency', (l) => this._nodeExistsInLink(root,l) && this._isDependencyLink(root, l)) |
||||
.classed('dependants', (l) => this._nodeExistsInLink(root,l) && !this._isDependencyLink(root, l)) |
||||
.attr("marker-end", (l) => this._nodeExistsInLink(root,l) ? (this._isDependencyLink(root, l) ? "url(#dependency)" : "url(#dependants)") : (maxLevel == 1 ? "" : "url(#default)")) |
||||
.transition(); |
||||
}, |
||||
|
||||
selectNodesStartingFromNode: function (node, maxLevel = 100) { |
||||
if (this._deselectNodeIfNeeded(node, "level" + maxLevel)) { |
||||
return |
||||
} |
||||
this._selectAndLockNode(node, "level" + maxLevel); |
||||
|
||||
let neighborIndexes = |
||||
this.dvgraph.nodesStartingFromNode(node, {max_level: maxLevel, use_backward_search: maxLevel == 1}) |
||||
.map((n) => n.index); |
||||
|
||||
this._fadeOutAllNodesAndLinks(); |
||||
this._highlightNodesWithIndexes(neighborIndexes); |
||||
this._highlightLinksFromRootWithNodesIndexes(node, neighborIndexes, maxLevel); |
||||
} |
||||
|
||||
}; |
||||
} |
||||
}; |
||||
|
File diff suppressed because one or more lines are too long
@ -1,190 +0,0 @@
|
||||
// ===================================================
|
||||
// =============== PARSING ===========================
|
||||
// ===================================================
|
||||
// Input
|
||||
// { links : [ {source: sourceName, dest : destName} * ] }
|
||||
// Output:
|
||||
"use strict"; |
||||
|
||||
var objcdv = { |
||||
version: "0.0.1", |
||||
_createGraph: function _createGraph() { |
||||
return { |
||||
nodes: [], |
||||
links: [], |
||||
nodesSet: {}, |
||||
node_index: 0, |
||||
|
||||
addLink: function addLink(link) { |
||||
|
||||
var source_node = this.getNode(link.source); |
||||
source_node.source++; |
||||
|
||||
var dest_node = this.getNode(link.dest); |
||||
dest_node.dest++; |
||||
|
||||
this.links.push({ |
||||
// d3 js properties
|
||||
source: source_node.idx, |
||||
target: dest_node.idx, |
||||
|
||||
// Additional link information
|
||||
sourceNode: source_node, |
||||
targetNode: dest_node |
||||
}); |
||||
}, |
||||
|
||||
getNode: function getNode(nodeName) { |
||||
var node = this.nodesSet[nodeName]; |
||||
if (node == null) { |
||||
var idx = this.node_index; |
||||
this.nodesSet[nodeName] = node = { idx: idx, name: nodeName, source: 1, dest: 0 }; |
||||
this.node_index++; |
||||
} |
||||
return node; |
||||
}, |
||||
|
||||
updateNodes: function updateNodes(f) { |
||||
_.values(this.nodesSet).forEach(f); |
||||
}, |
||||
|
||||
d3jsGraph: function d3jsGraph() { |
||||
// Sorting up nodes, since, in some cases they aren't returned in correct number
|
||||
var nodes = _.values(this.nodesSet).slice(0).sort(function (a, b) { |
||||
return a.idx - b.idx; |
||||
}); |
||||
return { nodes: nodes, links: this.links }; |
||||
}, |
||||
|
||||
nodesStartingFromNode: function nodesStartingFromNode(node) { |
||||
var _this = this; |
||||
|
||||
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; |
||||
|
||||
var _ref$max_level = _ref.max_level; |
||||
var max_level = _ref$max_level === undefined ? 100 : _ref$max_level; |
||||
var _ref$use_backward_search = _ref.use_backward_search; |
||||
var use_backward_search = _ref$use_backward_search === undefined ? false : _ref$use_backward_search; |
||||
var _ref$use_forward_search = _ref.use_forward_search; |
||||
var use_forward_search = _ref$use_forward_search === undefined ? true : _ref$use_forward_search; |
||||
|
||||
// Figure out the neighboring node id's with brute strength because the graph is small
|
||||
var neighbours = {}; |
||||
neighbours[node.index] = node; |
||||
|
||||
var nodesToCheck = [node.index]; |
||||
var current_level = 0; |
||||
|
||||
var _loop = function () { |
||||
forwardNeighbours = []; |
||||
backwardNeighbours = []; |
||||
|
||||
var tmpNeighbours = {}; |
||||
if (use_forward_search) { |
||||
forwardNeighbours = _this.links.filter(function (link) { |
||||
return link.source.index in neighbours; |
||||
}).filter(function (link) { |
||||
return !(link.target.index in neighbours); |
||||
}).map(function (link) { |
||||
tmpNeighbours[link.target.index] = link.target; |
||||
return link.target.index; |
||||
}); |
||||
} |
||||
if (use_backward_search) { |
||||
backwardNeighbours = _this.links.filter(function (link) { |
||||
return link.target.index in neighbours; |
||||
}).filter(function (link) { |
||||
return !(link.source.index in neighbours); |
||||
}).map(function (link) { |
||||
tmpNeighbours[link.source.index] = link.source; |
||||
return link.source.index; |
||||
}); |
||||
} |
||||
|
||||
_.extend(neighbours, tmpNeighbours); |
||||
|
||||
nodesToCheck = forwardNeighbours.concat(backwardNeighbours); |
||||
console.log("Nodes to check" + nodesToCheck); |
||||
|
||||
// Skip if we reached max level
|
||||
current_level++; |
||||
if (current_level == max_level) { |
||||
console.log("Reached max at level" + current_level); |
||||
return "break"; |
||||
} |
||||
}; |
||||
|
||||
while (Object.keys(nodesToCheck).length != 0) { |
||||
var forwardNeighbours; |
||||
var backwardNeighbours; |
||||
|
||||
var _ret = _loop(); |
||||
|
||||
if (_ret === "break") break; |
||||
} |
||||
return _.values(neighbours); |
||||
} |
||||
|
||||
}; |
||||
}, |
||||
_createPrefixes: function _createPrefixes() { |
||||
return { |
||||
_prefixesDistr: {}, |
||||
|
||||
_sortedPrefixes: null, |
||||
|
||||
addName: function addName(name) { |
||||
this._sortedPrefixes = null; |
||||
|
||||
var prefix = name.substring(0, 2); |
||||
if (!(prefix in this._prefixesDistr)) { |
||||
this._prefixesDistr[prefix] = 1; |
||||
} else { |
||||
this._prefixesDistr[prefix]++; |
||||
} |
||||
}, |
||||
|
||||
prefixIndexForName: function prefixIndexForName(name) { |
||||
var sortedPrefixes = this._getSortedPrefixes(); |
||||
var prefix = name.substring(0, 2); |
||||
return _.indexOf(sortedPrefixes, prefix); |
||||
}, |
||||
|
||||
_getSortedPrefixes: function _getSortedPrefixes() { |
||||
if (this._sortedPrefixes == null) { |
||||
this._sortedPrefixes = _.map(this._prefixesDistr, function (v, k) { |
||||
return { "key": k, "value": v }; |
||||
}).sort(function (a, b) { |
||||
return b.value - a.value; |
||||
}).map(function (o) { |
||||
return o.key; |
||||
}); |
||||
} |
||||
return this._sortedPrefixes; |
||||
} |
||||
}; |
||||
}, |
||||
|
||||
parse_dependencies_graph: function parse_dependencies_graph(dependencies) { |
||||
|
||||
var graph = this._createGraph(); |
||||
var prefixes = this._createPrefixes(); |
||||
|
||||
dependencies.links.forEach(function (link) { |
||||
graph.addLink(link); |
||||
|
||||
prefixes.addName(link.source); |
||||
prefixes.addName(link.dest); |
||||
}); |
||||
|
||||
graph.updateNodes(function (node) { |
||||
node.weight = node.source; |
||||
node.group = prefixes.prefixIndexForName(node.name) + 1; |
||||
}); |
||||
|
||||
return graph; |
||||
} |
||||
|
||||
}; |
||||
|
||||
//# sourceMappingURL=parse-compiled.js.map
|
@ -1,168 +0,0 @@
|
||||
// ===================================================
|
||||
// =============== PARSING ===========================
|
||||
// ===================================================
|
||||
// Input
|
||||
// { links : [ {source: sourceName, dest : destName} * ] }
|
||||
// Output:
|
||||
let objcdv = { |
||||
version: "0.0.1", |
||||
_createGraph: function () { |
||||
return { |
||||
nodes: [], |
||||
links: [], |
||||
nodesSet: {}, |
||||
node_index: 0, |
||||
|
||||
addLink: function (link) { |
||||
|
||||
var source_node = this.getNode(link.source); |
||||
source_node.source++; |
||||
|
||||
var dest_node = this.getNode(link.dest); |
||||
dest_node.dest++; |
||||
|
||||
this.links.push({ |
||||
// d3 js properties
|
||||
source: source_node.idx, |
||||
target: dest_node.idx, |
||||
|
||||
// Additional link information
|
||||
sourceNode: source_node, |
||||
targetNode: dest_node |
||||
}) |
||||
}, |
||||
|
||||
getNode: function (nodeName) { |
||||
var node = this.nodesSet[nodeName]; |
||||
if (node == null) { |
||||
var idx = this.node_index; |
||||
this.nodesSet[nodeName] = node = {idx: idx, name: nodeName, source: 1, dest: 0}; |
||||
this.node_index++; |
||||
} |
||||
return node |
||||
}, |
||||
|
||||
updateNodes: function (f) { |
||||
_.values(this.nodesSet).forEach(f) |
||||
}, |
||||
|
||||
d3jsGraph: function () { |
||||
// Sorting up nodes, since, in some cases they aren't returned in correct number
|
||||
var nodes = _.values(this.nodesSet).slice(0).sort((a, b) => a.idx - b.idx); |
||||
return {nodes: nodes, links: this.links}; |
||||
}, |
||||
|
||||
nodesStartingFromNode: function (node, {max_level = 100, use_backward_search = false, use_forward_search = true } = {} ) { |
||||
// Figure out the neighboring node id's with brute strength because the graph is small
|
||||
var neighbours = {}; |
||||
neighbours[node.index] = node; |
||||
|
||||
var nodesToCheck = [node.index]; |
||||
let current_level = 0; |
||||
while (Object.keys(nodesToCheck).length != 0) { |
||||
var forwardNeighbours = []; |
||||
var backwardNeighbours = []; |
||||
|
||||
let tmpNeighbours = {}; |
||||
if (use_forward_search) { |
||||
forwardNeighbours = this.links |
||||
.filter((link) => link.source.index in neighbours) |
||||
.filter((link) => !(link.target.index in neighbours)) |
||||
.map((link) => { |
||||
tmpNeighbours[link.target.index] = link.target; |
||||
return link.target.index; |
||||
}); |
||||
} |
||||
if (use_backward_search) { |
||||
backwardNeighbours = this.links |
||||
.filter((link) => link.target.index in neighbours) |
||||
.filter((link) => !(link.source.index in neighbours)) |
||||
.map((link) => { |
||||
tmpNeighbours[link.source.index] = link.source; |
||||
return link.source.index; |
||||
}); |
||||
} |
||||
|
||||
_.extend(neighbours, tmpNeighbours); |
||||
|
||||
|
||||
nodesToCheck = forwardNeighbours.concat(backwardNeighbours); |
||||
console.log("Nodes to check" + nodesToCheck); |
||||
|
||||
// Skip if we reached max level
|
||||
current_level++; |
||||
if (current_level == max_level) { |
||||
console.log("Reached max at level" + current_level); |
||||
break; |
||||
} |
||||
} |
||||
return _.values(neighbours); |
||||
|
||||
} |
||||
|
||||
}; |
||||
|
||||
}, |
||||
_createPrefixes: function () { |
||||
return { |
||||
_prefixesDistr: {}, |
||||
|
||||
_sortedPrefixes: null, |
||||
|
||||
addName: function (name) { |
||||
this._sortedPrefixes = null; |
||||
|
||||
var prefix = name.substring(0, 2); |
||||
if (!(prefix in this._prefixesDistr)) { |
||||
this._prefixesDistr[prefix] = 1; |
||||
} else { |
||||
this._prefixesDistr[prefix]++; |
||||
} |
||||
}, |
||||
|
||||
prefixIndexForName: function (name) { |
||||
var sortedPrefixes = this._getSortedPrefixes(); |
||||
var prefix = name.substring(0, 2); |
||||
return _.indexOf(sortedPrefixes, prefix) |
||||
}, |
||||
|
||||
_getSortedPrefixes: function () { |
||||
if (this._sortedPrefixes == null) { |
||||
this._sortedPrefixes = _.map(this._prefixesDistr, (v, k) => ({"key": k, "value": v})) |
||||
.sort((a, b) => b.value - a.value) |
||||
.map(o => o.key) |
||||
} |
||||
return this._sortedPrefixes |
||||
} |
||||
}; |
||||
}, |
||||
|
||||
|
||||
parse_dependencies_graph: function (dependencies) { |
||||
|
||||
var graph = this._createGraph(); |
||||
var prefixes = this._createPrefixes(); |
||||
|
||||
dependencies.links.forEach((link) => { |
||||
graph.addLink(link); |
||||
|
||||
prefixes.addName(link.source); |
||||
prefixes.addName(link.dest); |
||||
|
||||
}); |
||||
|
||||
graph.updateNodes((node) => { |
||||
node.weight = node.source; |
||||
node.group = prefixes.prefixIndexForName(node.name) + 1 |
||||
}); |
||||
|
||||
return graph |
||||
|
||||
} |
||||
|
||||
}; |
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,312 +0,0 @@
|
||||
/* |
||||
* Sidr |
||||
* https://github.com/artberri/sidr
|
||||
* |
||||
* Copyright (c) 2013 Alberto Varela |
||||
* Licensed under the MIT license. |
||||
*/ |
||||
|
||||
;(function( $ ){ |
||||
|
||||
var sidrMoving = false, |
||||
sidrOpened = false; |
||||
|
||||
// Private methods
|
||||
var privateMethods = { |
||||
// Check for valids urls
|
||||
// From : http://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-an-url
|
||||
isUrl: function (str) { |
||||
var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
|
||||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
|
||||
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
|
||||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
|
||||
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
|
||||
'(\\#[-a-z\\d_]*)?$','i'); // fragment locator
|
||||
if(!pattern.test(str)) { |
||||
return false; |
||||
} else { |
||||
return true; |
||||
} |
||||
}, |
||||
// Loads the content into the menu bar
|
||||
loadContent: function($menu, content) { |
||||
$menu.html(content); |
||||
}, |
||||
// Add sidr prefixes
|
||||
addPrefix: function($element) { |
||||
var elementId = $element.attr('id'), |
||||
elementClass = $element.attr('class'); |
||||
|
||||
if(typeof elementId === 'string' && '' !== elementId) { |
||||
$element.attr('id', elementId.replace(/([A-Za-z0-9_.\-]+)/g, 'sidr-id-$1')); |
||||
} |
||||
if(typeof elementClass === 'string' && '' !== elementClass && 'sidr-inner' !== elementClass) { |
||||
$element.attr('class', elementClass.replace(/([A-Za-z0-9_.\-]+)/g, 'sidr-class-$1')); |
||||
} |
||||
$element.removeAttr('style'); |
||||
}, |
||||
execute: function(action, name, callback) { |
||||
// Check arguments
|
||||
if(typeof name === 'function') { |
||||
callback = name; |
||||
name = 'sidr'; |
||||
} |
||||
else if(!name) { |
||||
name = 'sidr'; |
||||
} |
||||
|
||||
// Declaring
|
||||
var $menu = $('#' + name), |
||||
$body = $($menu.data('body')), |
||||
$html = $('html'), |
||||
menuWidth = $menu.outerWidth(true), |
||||
speed = $menu.data('speed'), |
||||
side = $menu.data('side'), |
||||
displace = $menu.data('displace'), |
||||
onOpen = $menu.data('onOpen'), |
||||
onClose = $menu.data('onClose'), |
||||
bodyAnimation, |
||||
menuAnimation, |
||||
scrollTop, |
||||
bodyClass = (name === 'sidr' ? 'sidr-open' : 'sidr-open ' + name + '-open'); |
||||
|
||||
// Open Sidr
|
||||
if('open' === action || ('toggle' === action && !$menu.is(':visible'))) { |
||||
// Check if we can open it
|
||||
if( $menu.is(':visible') || sidrMoving ) { |
||||
return; |
||||
} |
||||
|
||||
// If another menu opened close first
|
||||
if(sidrOpened !== false) { |
||||
methods.close(sidrOpened, function() { |
||||
methods.open(name); |
||||
}); |
||||
|
||||
return; |
||||
} |
||||
|
||||
// Lock sidr
|
||||
sidrMoving = true; |
||||
|
||||
// Left or right?
|
||||
if(side === 'left') { |
||||
bodyAnimation = {left: menuWidth + 'px'}; |
||||
menuAnimation = {left: '0px'}; |
||||
} |
||||
else { |
||||
bodyAnimation = {right: menuWidth + 'px'}; |
||||
menuAnimation = {right: '0px'}; |
||||
} |
||||
|
||||
// Prepare page if container is body
|
||||
if($body.is('body')){ |
||||
scrollTop = $html.scrollTop(); |
||||
$html.css('overflow-x', 'hidden').scrollTop(scrollTop); |
||||
} |
||||
|
||||
// Open menu
|
||||
if(displace){ |
||||
$body.addClass('sidr-animating').css({ |
||||
width: $body.width(), |
||||
position: 'absolute' |
||||
}).animate(bodyAnimation, speed, function() { |
||||
$(this).addClass(bodyClass); |
||||
}); |
||||
} |
||||
else { |
||||
setTimeout(function() { |
||||
$(this).addClass(bodyClass); |
||||
}, speed); |
||||
} |
||||
$menu.css('display', 'block').animate(menuAnimation, speed, function() { |
||||
sidrMoving = false; |
||||
sidrOpened = name; |
||||
// Callback
|
||||
if(typeof callback === 'function') { |
||||
callback(name); |
||||
} |
||||
$body.removeClass('sidr-animating'); |
||||
}); |
||||
|
||||
// onOpen callback
|
||||
onOpen(); |
||||
} |
||||
// Close Sidr
|
||||
else { |
||||
// Check if we can close it
|
||||
if( !$menu.is(':visible') || sidrMoving ) { |
||||
return; |
||||
} |
||||
|
||||
// Lock sidr
|
||||
sidrMoving = true; |
||||
|
||||
// Right or left menu?
|
||||
if(side === 'left') { |
||||
bodyAnimation = {left: 0}; |
||||
menuAnimation = {left: '-' + menuWidth + 'px'}; |
||||
} |
||||
else { |
||||
bodyAnimation = {right: 0}; |
||||
menuAnimation = {right: '-' + menuWidth + 'px'}; |
||||
} |
||||
|
||||
// Close menu
|
||||
if($body.is('body')){ |
||||
scrollTop = $html.scrollTop(); |
||||
$html.removeAttr('style').scrollTop(scrollTop); |
||||
} |
||||
$body.addClass('sidr-animating').animate(bodyAnimation, speed).removeClass(bodyClass); |
||||
$menu.animate(menuAnimation, speed, function() { |
||||
$menu.removeAttr('style').hide(); |
||||
$body.removeAttr('style'); |
||||
$('html').removeAttr('style'); |
||||
sidrMoving = false; |
||||
sidrOpened = false; |
||||
// Callback
|
||||
if(typeof callback === 'function') { |
||||
callback(name); |
||||
} |
||||
$body.removeClass('sidr-animating'); |
||||
}); |
||||
|
||||
// onClose callback
|
||||
onClose(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
// Sidr public methods
|
||||
var methods = { |
||||
open: function(name, callback) { |
||||
privateMethods.execute('open', name, callback); |
||||
}, |
||||
close: function(name, callback) { |
||||
privateMethods.execute('close', name, callback); |
||||
}, |
||||
toggle: function(name, callback) { |
||||
privateMethods.execute('toggle', name, callback); |
||||
}, |
||||
// I made a typo, so I mantain this method to keep backward compatibilty with 1.1.1v and previous
|
||||
toogle: function(name, callback) { |
||||
privateMethods.execute('toggle', name, callback); |
||||
} |
||||
}; |
||||
|
||||
$.sidr = function( method ) { |
||||
|
||||
if ( methods[method] ) { |
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); |
||||
} |
||||
else if ( typeof method === 'function' || typeof method === 'string' || ! method ) { |
||||
return methods.toggle.apply( this, arguments ); |
||||
} |
||||
else { |
||||
$.error( 'Method ' + method + ' does not exist on jQuery.sidr' ); |
||||
} |
||||
|
||||
}; |
||||
|
||||
$.fn.sidr = function( options ) { |
||||
|
||||
var settings = $.extend( { |
||||
name : 'sidr', // Name for the 'sidr'
|
||||
speed : 200, // Accepts standard jQuery effects speeds (i.e. fast, normal or milliseconds)
|
||||
side : 'left', // Accepts 'left' or 'right'
|
||||
source : null, // Override the source of the content.
|
||||
renaming : true, // The ids and classes will be prepended with a prefix when loading existent content
|
||||
body : 'body', // Page container selector,
|
||||
displace: true, // Displace the body content or not
|
||||
onOpen : function() {}, // Callback when sidr opened
|
||||
onClose : function() {} // Callback when sidr closed
|
||||
}, options); |
||||
|
||||
var name = settings.name, |
||||
$sideMenu = $('#' + name); |
||||
|
||||
// If the side menu do not exist create it
|
||||
if( $sideMenu.length === 0 ) { |
||||
$sideMenu = $('<div />') |
||||
.attr('id', name) |
||||
.appendTo($('body')); |
||||
} |
||||
|
||||
// Adding styles and options
|
||||
$sideMenu |
||||
.addClass('sidr') |
||||
.addClass(settings.side) |
||||
.data({ |
||||
speed : settings.speed, |
||||
side : settings.side, |
||||
body : settings.body, |
||||
displace : settings.displace, |
||||
onOpen : settings.onOpen, |
||||
onClose : settings.onClose |
||||
}); |
||||
|
||||
// The menu content
|
||||
if(typeof settings.source === 'function') { |
||||
var newContent = settings.source(name); |
||||
privateMethods.loadContent($sideMenu, newContent); |
||||
} |
||||
else if(typeof settings.source === 'string' && privateMethods.isUrl(settings.source)) { |
||||
$.get(settings.source, function(data) { |
||||
privateMethods.loadContent($sideMenu, data); |
||||
}); |
||||
} |
||||
else if(typeof settings.source === 'string') { |
||||
var htmlContent = '', |
||||
selectors = settings.source.split(','); |
||||
|
||||
$.each(selectors, function(index, element) { |
||||
htmlContent += '<div class="sidr-inner">' + $(element).html() + '</div>'; |
||||
}); |
||||
|
||||
// Renaming ids and classes
|
||||
if(settings.renaming) { |
||||
var $htmlContent = $('<div />').html(htmlContent); |
||||
$htmlContent.find('*').each(function(index, element) { |
||||
var $element = $(element); |
||||
privateMethods.addPrefix($element); |
||||
}); |
||||
htmlContent = $htmlContent.html(); |
||||
} |
||||
privateMethods.loadContent($sideMenu, htmlContent); |
||||
} |
||||
else if(settings.source !== null) { |
||||
$.error('Invalid Sidr Source'); |
||||
} |
||||
|
||||
return this.each(function(){ |
||||
var $this = $(this), |
||||
data = $this.data('sidr'); |
||||
|
||||
// If the plugin hasn't been initialized yet
|
||||
if ( ! data ) { |
||||
|
||||
$this.data('sidr', name); |
||||
if('ontouchstart' in document.documentElement) { |
||||
$this.bind('touchstart', function(e) { |
||||
var theEvent = e.originalEvent.touches[0]; |
||||
this.touched = e.timeStamp; |
||||
}); |
||||
$this.bind('touchend', function(e) { |
||||
var delta = Math.abs(e.timeStamp - this.touched); |
||||
if(delta < 200) { |
||||
e.preventDefault(); |
||||
methods.toggle(name); |
||||
} |
||||
}); |
||||
} |
||||
else { |
||||
$this.click(function(e) { |
||||
e.preventDefault(); |
||||
methods.toggle(name); |
||||
}); |
||||
} |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
})( jQuery ); |
@ -1,190 +0,0 @@
|
||||
/* line 3, ../../src/scss/sidr/_base.scss */ |
||||
.sidr { |
||||
/* Default Settings */ |
||||
display: none; |
||||
position: absolute; |
||||
position: fixed; |
||||
top: 0; |
||||
height: 100%; |
||||
z-index: 999999; |
||||
width: 260px; |
||||
overflow-x: none; |
||||
overflow-y: auto; |
||||
/* Theme Settings */ |
||||
font-family: "lucida grande", tahoma, verdana, arial, sans-serif; |
||||
font-size: 15px; |
||||
background: #333333; |
||||
color: white; |
||||
-webkit-box-shadow: inset 0 0 5px 5px #222222; |
||||
-moz-box-shadow: inset 0 0 5px 5px #222222; |
||||
box-shadow: inset 0 0 5px 5px #222222; |
||||
} |
||||
/* line 15, ../../src/scss/sidr/_base.scss */ |
||||
.sidr .sidr-inner { |
||||
padding: 0 0 15px; |
||||
} |
||||
/* line 18, ../../src/scss/sidr/_base.scss */ |
||||
.sidr .sidr-inner > p { |
||||
margin-left: 15px; |
||||
margin-right: 15px; |
||||
} |
||||
/* line 24, ../../src/scss/sidr/_base.scss */ |
||||
.sidr.right { |
||||
left: auto; |
||||
right: -260px; |
||||
} |
||||
/* line 29, ../../src/scss/sidr/_base.scss */ |
||||
.sidr.left { |
||||
left: -260px; |
||||
right: auto; |
||||
} |
||||
/* line 41, ../../src/scss/sidr/_base.scss */ |
||||
.sidr h1, .sidr h2, .sidr h3, .sidr h4, .sidr h5, .sidr h6 { |
||||
font-size: 11px; |
||||
font-weight: normal; |
||||
padding: 0 15px; |
||||
margin: 0 0 5px; |
||||
color: white; |
||||
line-height: 24px; |
||||
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #4d4d4d), color-stop(100%, #1a1a1a)); |
||||
background-image: -webkit-linear-gradient(#4d4d4d, #1a1a1a); |
||||
background-image: -moz-linear-gradient(#4d4d4d, #1a1a1a); |
||||
background-image: -o-linear-gradient(#4d4d4d, #1a1a1a); |
||||
background-image: linear-gradient(#4d4d4d, #1a1a1a); |
||||
-webkit-box-shadow: 0 5px 5px 3px rgba(0, 0, 0, 0.2); |
||||
-moz-box-shadow: 0 5px 5px 3px rgba(0, 0, 0, 0.2); |
||||
box-shadow: 0 5px 5px 3px rgba(0, 0, 0, 0.2); |
||||
} |
||||
/* line 52, ../../src/scss/sidr/_base.scss */ |
||||
.sidr p { |
||||
font-size: 13px; |
||||
margin: 0 0 12px; |
||||
} |
||||
/* line 55, ../../src/scss/sidr/_base.scss */ |
||||
.sidr p a { |
||||
color: rgba(255, 255, 255, 0.9); |
||||
} |
||||
/* line 60, ../../src/scss/sidr/_base.scss */ |
||||
.sidr > p { |
||||
margin-left: 15px; |
||||
margin-right: 15px; |
||||
} |
||||
/* line 65, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul { |
||||
display: block; |
||||
margin: 0 0 15px; |
||||
padding: 0; |
||||
border-top: 1px solid #1a1a1a; |
||||
border-bottom: 1px solid #4d4d4d; |
||||
} |
||||
/* line 72, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li { |
||||
display: block; |
||||
margin: 0; |
||||
line-height: 48px; |
||||
border-top: 1px solid #4d4d4d; |
||||
border-bottom: 1px solid #1a1a1a; |
||||
} |
||||
/* line 81, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li:hover, .sidr ul li.active, .sidr ul li.sidr-class-active { |
||||
border-top: none; |
||||
line-height: 49px; |
||||
} |
||||
/* line 85, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li:hover > a, .sidr ul li:hover > span, .sidr ul li.active > a, .sidr ul li.active > span, .sidr ul li.sidr-class-active > a, .sidr ul li.sidr-class-active > span { |
||||
-webkit-box-shadow: inset 0 0 15px 3px #222222; |
||||
-moz-box-shadow: inset 0 0 15px 3px #222222; |
||||
box-shadow: inset 0 0 15px 3px #222222; |
||||
} |
||||
/* line 90, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li a, .sidr ul li span { |
||||
padding: 0 15px; |
||||
display: block; |
||||
text-decoration: none; |
||||
color: white; |
||||
} |
||||
/* line 97, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul { |
||||
border-bottom: none; |
||||
margin: 0; |
||||
} |
||||
/* line 100, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li { |
||||
line-height: 40px; |
||||
font-size: 13px; |
||||
} |
||||
/* line 104, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li:last-child { |
||||
border-bottom: none; |
||||
} |
||||
/* line 110, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li:hover, .sidr ul li ul li.active, .sidr ul li ul li.sidr-class-active { |
||||
border-top: none; |
||||
line-height: 41px; |
||||
} |
||||
/* line 114, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li:hover > a, .sidr ul li ul li:hover > span, .sidr ul li ul li.active > a, .sidr ul li ul li.active > span, .sidr ul li ul li.sidr-class-active > a, .sidr ul li ul li.sidr-class-active > span { |
||||
-webkit-box-shadow: inset 0 0 15px 3px #222222; |
||||
-moz-box-shadow: inset 0 0 15px 3px #222222; |
||||
box-shadow: inset 0 0 15px 3px #222222; |
||||
} |
||||
/* line 119, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li a, .sidr ul li ul li span { |
||||
color: rgba(255, 255, 255, 0.8); |
||||
padding-left: 30px; |
||||
} |
||||
/* line 128, ../../src/scss/sidr/_base.scss */ |
||||
.sidr form { |
||||
margin: 0 15px; |
||||
} |
||||
/* line 132, ../../src/scss/sidr/_base.scss */ |
||||
.sidr label { |
||||
font-size: 13px; |
||||
} |
||||
/* line 146, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type="text"], |
||||
.sidr input[type="password"], |
||||
.sidr input[type="date"], |
||||
.sidr input[type="datetime"], |
||||
.sidr input[type="email"], |
||||
.sidr input[type="number"], |
||||
.sidr input[type="search"], |
||||
.sidr input[type="tel"], |
||||
.sidr input[type="time"], |
||||
.sidr input[type="url"], |
||||
.sidr textarea, .sidr select { |
||||
width: 100%; |
||||
font-size: 13px; |
||||
padding: 5px; |
||||
-webkit-box-sizing: border-box; |
||||
-moz-box-sizing: border-box; |
||||
box-sizing: border-box; |
||||
margin: 0 0 10px; |
||||
-webkit-border-radius: 2px; |
||||
-moz-border-radius: 2px; |
||||
-ms-border-radius: 2px; |
||||
-o-border-radius: 2px; |
||||
border-radius: 2px; |
||||
border: none; |
||||
background: rgba(0, 0, 0, 0.1); |
||||
color: rgba(255, 255, 255, 0.6); |
||||
display: block; |
||||
clear: both; |
||||
} |
||||
/* line 160, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type=checkbox] { |
||||
width: auto; |
||||
display: inline; |
||||
clear: none; |
||||
} |
||||
/* line 167, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type=button], |
||||
.sidr input[type=submit] { |
||||
color: #333333; |
||||
background: white; |
||||
} |
||||
/* line 171, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type=button]:hover, |
||||
.sidr input[type=submit]:hover { |
||||
background: rgba(255, 255, 255, 0.9); |
||||
} |
@ -1,190 +0,0 @@
|
||||
/* line 3, ../../src/scss/sidr/_base.scss */ |
||||
.sidr { |
||||
/* Default Settings */ |
||||
display: none; |
||||
position: absolute; |
||||
position: fixed; |
||||
top: 0; |
||||
height: 100%; |
||||
z-index: 999999; |
||||
width: 260px; |
||||
overflow-x: none; |
||||
overflow-y: auto; |
||||
/* Theme Settings */ |
||||
font-family: "lucida grande", tahoma, verdana, arial, sans-serif; |
||||
font-size: 15px; |
||||
background: #f8f8f8; |
||||
color: #333333; |
||||
-webkit-box-shadow: inset 0 0 5px 5px #ebebeb; |
||||
-moz-box-shadow: inset 0 0 5px 5px #ebebeb; |
||||
box-shadow: inset 0 0 5px 5px #ebebeb; |
||||
} |
||||
/* line 15, ../../src/scss/sidr/_base.scss */ |
||||
.sidr .sidr-inner { |
||||
padding: 0 0 15px; |
||||
} |
||||
/* line 18, ../../src/scss/sidr/_base.scss */ |
||||
.sidr .sidr-inner > p { |
||||
margin-left: 15px; |
||||
margin-right: 15px; |
||||
} |
||||
/* line 24, ../../src/scss/sidr/_base.scss */ |
||||
.sidr.right { |
||||
left: auto; |
||||
right: -260px; |
||||
} |
||||
/* line 29, ../../src/scss/sidr/_base.scss */ |
||||
.sidr.left { |
||||
left: -260px; |
||||
right: auto; |
||||
} |
||||
/* line 41, ../../src/scss/sidr/_base.scss */ |
||||
.sidr h1, .sidr h2, .sidr h3, .sidr h4, .sidr h5, .sidr h6 { |
||||
font-size: 11px; |
||||
font-weight: normal; |
||||
padding: 0 15px; |
||||
margin: 0 0 5px; |
||||
color: #333333; |
||||
line-height: 24px; |
||||
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #dfdfdf)); |
||||
background-image: -webkit-linear-gradient(#ffffff, #dfdfdf); |
||||
background-image: -moz-linear-gradient(#ffffff, #dfdfdf); |
||||
background-image: -o-linear-gradient(#ffffff, #dfdfdf); |
||||
background-image: linear-gradient(#ffffff, #dfdfdf); |
||||
-webkit-box-shadow: 0 5px 5px 3px rgba(0, 0, 0, 0.2); |
||||
-moz-box-shadow: 0 5px 5px 3px rgba(0, 0, 0, 0.2); |
||||
box-shadow: 0 5px 5px 3px rgba(0, 0, 0, 0.2); |
||||
} |
||||
/* line 52, ../../src/scss/sidr/_base.scss */ |
||||
.sidr p { |
||||
font-size: 13px; |
||||
margin: 0 0 12px; |
||||
} |
||||
/* line 55, ../../src/scss/sidr/_base.scss */ |
||||
.sidr p a { |
||||
color: rgba(51, 51, 51, 0.9); |
||||
} |
||||
/* line 60, ../../src/scss/sidr/_base.scss */ |
||||
.sidr > p { |
||||
margin-left: 15px; |
||||
margin-right: 15px; |
||||
} |
||||
/* line 65, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul { |
||||
display: block; |
||||
margin: 0 0 15px; |
||||
padding: 0; |
||||
border-top: 1px solid #dfdfdf; |
||||
border-bottom: 1px solid white; |
||||
} |
||||
/* line 72, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li { |
||||
display: block; |
||||
margin: 0; |
||||
line-height: 48px; |
||||
border-top: 1px solid white; |
||||
border-bottom: 1px solid #dfdfdf; |
||||
} |
||||
/* line 81, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li:hover, .sidr ul li.active, .sidr ul li.sidr-class-active { |
||||
border-top: none; |
||||
line-height: 49px; |
||||
} |
||||
/* line 85, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li:hover > a, .sidr ul li:hover > span, .sidr ul li.active > a, .sidr ul li.active > span, .sidr ul li.sidr-class-active > a, .sidr ul li.sidr-class-active > span { |
||||
-webkit-box-shadow: inset 0 0 15px 3px #ebebeb; |
||||
-moz-box-shadow: inset 0 0 15px 3px #ebebeb; |
||||
box-shadow: inset 0 0 15px 3px #ebebeb; |
||||
} |
||||
/* line 90, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li a, .sidr ul li span { |
||||
padding: 0 15px; |
||||
display: block; |
||||
text-decoration: none; |
||||
color: #333333; |
||||
} |
||||
/* line 97, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul { |
||||
border-bottom: none; |
||||
margin: 0; |
||||
} |
||||
/* line 100, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li { |
||||
line-height: 40px; |
||||
font-size: 13px; |
||||
} |
||||
/* line 104, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li:last-child { |
||||
border-bottom: none; |
||||
} |
||||
/* line 110, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li:hover, .sidr ul li ul li.active, .sidr ul li ul li.sidr-class-active { |
||||
border-top: none; |
||||
line-height: 41px; |
||||
} |
||||
/* line 114, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li:hover > a, .sidr ul li ul li:hover > span, .sidr ul li ul li.active > a, .sidr ul li ul li.active > span, .sidr ul li ul li.sidr-class-active > a, .sidr ul li ul li.sidr-class-active > span { |
||||
-webkit-box-shadow: inset 0 0 15px 3px #ebebeb; |
||||
-moz-box-shadow: inset 0 0 15px 3px #ebebeb; |
||||
box-shadow: inset 0 0 15px 3px #ebebeb; |
||||
} |
||||
/* line 119, ../../src/scss/sidr/_base.scss */ |
||||
.sidr ul li ul li a, .sidr ul li ul li span { |
||||
color: rgba(51, 51, 51, 0.8); |
||||
padding-left: 30px; |
||||
} |
||||
/* line 128, ../../src/scss/sidr/_base.scss */ |
||||
.sidr form { |
||||
margin: 0 15px; |
||||
} |
||||
/* line 132, ../../src/scss/sidr/_base.scss */ |
||||
.sidr label { |
||||
font-size: 13px; |
||||
} |
||||
/* line 146, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type="text"], |
||||
.sidr input[type="password"], |
||||
.sidr input[type="date"], |
||||
.sidr input[type="datetime"], |
||||
.sidr input[type="email"], |
||||
.sidr input[type="number"], |
||||
.sidr input[type="search"], |
||||
.sidr input[type="tel"], |
||||
.sidr input[type="time"], |
||||
.sidr input[type="url"], |
||||
.sidr textarea, .sidr select { |
||||
width: 100%; |
||||
font-size: 13px; |
||||
padding: 5px; |
||||
-webkit-box-sizing: border-box; |
||||
-moz-box-sizing: border-box; |
||||
box-sizing: border-box; |
||||
margin: 0 0 10px; |
||||
-webkit-border-radius: 2px; |
||||
-moz-border-radius: 2px; |
||||
-ms-border-radius: 2px; |
||||
-o-border-radius: 2px; |
||||
border-radius: 2px; |
||||
border: none; |
||||
background: rgba(0, 0, 0, 0.1); |
||||
color: rgba(51, 51, 51, 0.6); |
||||
display: block; |
||||
clear: both; |
||||
} |
||||
/* line 160, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type=checkbox] { |
||||
width: auto; |
||||
display: inline; |
||||
clear: none; |
||||
} |
||||
/* line 167, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type=button], |
||||
.sidr input[type=submit] { |
||||
color: #f8f8f8; |
||||
background: #333333; |
||||
} |
||||
/* line 171, ../../src/scss/sidr/_base.scss */ |
||||
.sidr input[type=button]:hover, |
||||
.sidr input[type=submit]:hover { |
||||
background: rgba(51, 51, 51, 0.9); |
||||
} |
File diff suppressed because one or more lines are too long
@ -1,138 +0,0 @@
|
||||
|
||||
|
||||
.node.filtered { |
||||
fill-opacity:0.3; |
||||
stroke-opacity:0.3; |
||||
} |
||||
|
||||
text.filtered { |
||||
fill-opacity:0; |
||||
stroke-opacity:0; |
||||
} |
||||
|
||||
.link.filtered { |
||||
stroke: #ddd; |
||||
fill-opacity:0.1; |
||||
stroke-opacity:0.1; |
||||
} |
||||
|
||||
.link.dependency { |
||||
stroke: #900; |
||||
fill:#900; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
.link.dependants { |
||||
stroke: #090; |
||||
fill:#090; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
|
||||
.node.skipped { |
||||
fill-opacity:0.0; |
||||
stroke-opacity:0.0; |
||||
} |
||||
|
||||
text.skipped { |
||||
fill-opacity:0; |
||||
stroke-opacity:0; |
||||
} |
||||
|
||||
.link.skipped { |
||||
stroke: #ddd; |
||||
fill-opacity:0.0; |
||||
stroke-opacity:0.0; |
||||
} |
||||
|
||||
.node { |
||||
stroke: #000; |
||||
stroke-width: 0.5px; |
||||
} |
||||
|
||||
.link { |
||||
stroke: #999; |
||||
stroke-opacity: .6; |
||||
fill: none; |
||||
stroke-width: 1.5px; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
.marker#default { |
||||
stroke: #999; |
||||
fill:#999; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
.marker#dependency { |
||||
stroke: #900; |
||||
fill:#900; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
.marker#dependants { |
||||
stroke: #090; |
||||
fill:#090; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
body { |
||||
margin: 0px; |
||||
padding: 0px; |
||||
} |
||||
|
||||
html { |
||||
overflow: hidden; |
||||
} |
||||
|
||||
text { |
||||
stroke: #000; |
||||
stroke-width: 0.5px; |
||||
text-anchor:middle; |
||||
font: 10px sans-serif; |
||||
font-weight: normal; |
||||
font-style: normal; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
form { |
||||
position: absolute; |
||||
right: 10px; |
||||
top: 60px; |
||||
} |
||||
|
||||
#simple-menu { |
||||
position: absolute; |
||||
right: 10px; |
||||
top: 10px; |
||||
|
||||
} |
||||
.editor-button { |
||||
background: #000000; |
||||
background-image: -webkit-linear-gradient(top, #000000, #6a7175); |
||||
background-image: -moz-linear-gradient(top, #000000, #6a7175); |
||||
background-image: -ms-linear-gradient(top, #000000, #6a7175); |
||||
background-image: -o-linear-gradient(top, #000000, #6a7175); |
||||
background-image: linear-gradient(to bottom, #000000, #6a7175); |
||||
-webkit-border-radius: 28; |
||||
-moz-border-radius: 28; |
||||
border-radius: 28px; |
||||
text-shadow: 2px 1px 5px #000000; |
||||
font-family: Menlo; |
||||
color: #ffffff; |
||||
font-size: 20px; |
||||
padding: 10px 20px 10px 20px; |
||||
text-decoration: none; |
||||
|
||||
|
||||
} |
||||
|
||||
.editor-button:hover { |
||||
background: #545f66; |
||||
background-image: -webkit-linear-gradient(top, #545f66, #111112); |
||||
background-image: -moz-linear-gradient(top, #545f66, #111112); |
||||
background-image: -ms-linear-gradient(top, #545f66, #111112); |
||||
background-image: -o-linear-gradient(top, #545f66, #111112); |
||||
background-image: linear-gradient(to bottom, #545f66, #111112); |
||||
text-decoration: none; |
||||
} |
@ -1,414 +0,0 @@
|
||||
<!DOCTYPE html> |
||||
<meta charset="utf-8"> |
||||
<head> |
||||
<link rel="stylesheet" type="text/css" href="dependency.css"> |
||||
<link rel="stylesheet" href="Scripts/sidr/stylesheets/jquery.sidr.dark.css"> |
||||
<style type="text/css" media="screen"> |
||||
body { |
||||
overflow: hidden; |
||||
} |
||||
|
||||
#editor { |
||||
margin: 0; |
||||
position: absolute; |
||||
top: 0; |
||||
width: 700px; |
||||
left: 0; |
||||
height: 100%; |
||||
} |
||||
|
||||
#sidr { |
||||
width: 700px; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<script type="text/javascript" src="Scripts/jquery/jquery-2.1.4.min.js"></script> |
||||
<script type="text/javascript" src="Scripts/sidr/jquery.sidr.js"></script> |
||||
<script type="text/javascript" src="Scripts/underscore/underscore-min.js"></script> |
||||
<script type="text/javascript" src="Scripts/d3/d3.v3.js"></script> |
||||
|
||||
<script type="text/javascript" src="origin.js"></script> |
||||
|
||||
<!-- ================================================= --> |
||||
<!-- ===========ACTUAL HTML ================ --> |
||||
<!-- ================================================= --> |
||||
|
||||
<form id="form"> |
||||
<label><input type="range" name="circle_size" min="1" max="50" value="15"/> Circle size</label><br> |
||||
<label><input type="range" name="charge_multiplier" min="1" max="500" value="100"/> Charge multiplier</label><br> |
||||
<label><input type="range" name="link_strength" min="0.1" max="100" value="7"/> Link strength</label><br> |
||||
<label><input type="checkbox" name="show_texts_near_circles"/> Show names</label><br> |
||||
<input id="search_input" placeholder="Type regexp to filter nodes" style="width:100%;"><br> |
||||
|
||||
</form> |
||||
|
||||
<a id="simple-menu" class="editor-button" href="#sidr">Live editor</a> |
||||
|
||||
<div id="chart"> |
||||
<!-- Here the SVG will be placed--> |
||||
</div> |
||||
|
||||
<div id="sidr"> |
||||
<pre id="editor"> |
||||
// This one is used by default |
||||
// Groups are set based on the Prefixes |
||||
function default_coloring(d) { |
||||
return color(d.group); |
||||
} |
||||
|
||||
// This function will group nodes based on the |
||||
// Rgular expressions you've provided |
||||
function regex_based_coloring(d) { |
||||
var className = d.name |
||||
|
||||
var rules = ["Magical", "Mapp", "^NS", "^UI", "^NI", "AF", ""]; |
||||
// var rules = ["ViewController", "View"] |
||||
|
||||
for (var i = 0; i < rules.length; i++) { |
||||
var re = new RegExp(rules[i], ""); |
||||
if (className.match(re)) { |
||||
return color(i + 1) |
||||
} |
||||
} |
||||
return "black"; |
||||
} |
||||
|
||||
// Filling out with default coloring |
||||
node.style("fill", default_coloring) |
||||
// node.style("fill", regex_based_coloring) |
||||
|
||||
force.start() |
||||
</pre> |
||||
</div> |
||||
|
||||
<script src="Scripts/ace/ace.js" type="text/javascript" charset="utf-8"></script> |
||||
<script> |
||||
var editor = ace.edit("editor"); |
||||
editor.setTheme("ace/theme/twilight"); |
||||
editor.getSession().setMode("ace/mode/javascript"); |
||||
|
||||
editor.getSession().on('change', function (e) { |
||||
try { |
||||
eval(editor.getSession().getValue()) |
||||
} catch (err) { |
||||
console.log(err) |
||||
} |
||||
}); |
||||
</script> |
||||
|
||||
<script> |
||||
$(document).ready(function () { |
||||
$('#simple-menu').sidr( |
||||
{ |
||||
displace: false, |
||||
onOpen: function () { |
||||
editor.resize() |
||||
} |
||||
} |
||||
); |
||||
$("#chart").css("overflow", "hidden"); |
||||
|
||||
}); |
||||
</script> |
||||
|
||||
<script src="Scripts/graph-actions-select-compiled.js"></script> |
||||
<script src="Scripts/parse-compiled.js"></script> |
||||
<script> |
||||
|
||||
// =================================================== |
||||
// =============== CONFIGURABLE PARAMS ============== |
||||
// =================================================== |
||||
|
||||
var default_link_distance = 10; |
||||
|
||||
// How far can we change default_link_distance? |
||||
// 0 - I don't care |
||||
// 0.5 - Change it as you want, but it's preferrable to have default_link_distance |
||||
// 1 - One does not change default_link_distance |
||||
var default_link_strength = 0.7; |
||||
|
||||
// Should I comment this? |
||||
var default_circle_radius = 15; |
||||
|
||||
// you can set it to true, but this will not help to understanf what's going on |
||||
var show_texts_near_circles = false; |
||||
var default_max_texts_length = 100; |
||||
|
||||
var charge_multiplier = 200; |
||||
|
||||
var dvgraph = objcdv.parse_dependencies_graph(dependencies); |
||||
var d3graph = dvgraph.d3jsGraph(); |
||||
|
||||
var w = window, |
||||
d = document, |
||||
e = d.documentElement, |
||||
g = d.getElementsByTagName('body')[0], |
||||
x = w.innerWidth || e.clientWidth || g.clientWidth, |
||||
y = w.innerHeight || e.clientHeight || g.clientHeight; |
||||
|
||||
// =================================================== |
||||
// =============== http://d3js.org/ Magic =========== |
||||
// =================================================== |
||||
|
||||
// https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors |
||||
var color = d3.scale.category10(); |
||||
|
||||
var container = d3.select("#chart").append("svg") |
||||
.attr("width", x) |
||||
.attr("height", y) |
||||
.style("overflow", "hidden"); |
||||
|
||||
// =================================================== |
||||
// =============== ZOOM LOGIC ======================== |
||||
// =================================================== |
||||
|
||||
container.append("rect") |
||||
.attr("width", x) |
||||
.attr("height", y) |
||||
.style("fill", "none") |
||||
.style("pointer-events", "all") |
||||
.call(d3.behavior.zoom().on("zoom", function () { |
||||
svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); |
||||
})); |
||||
|
||||
|
||||
// =================================================== |
||||
// =============== FORCE LAYOUT ====================== |
||||
// =================================================== |
||||
|
||||
var force = d3.layout.force() |
||||
.charge(function (d) { |
||||
return d.filtered ? 0 : -d.weight * charge_multiplier |
||||
}) |
||||
.linkDistance(function (l) { |
||||
return l.source.filtered || l.target.filtered ? 500 : radius(l.source) + radius(l.target) + default_link_distance |
||||
}) |
||||
.size([x, y]) |
||||
.nodes(d3.values(d3graph.nodes)) |
||||
.links(d3graph.links) |
||||
.linkStrength(function (l) { |
||||
return l.source.filtered || l.target.filtered ? 0 : default_link_strength |
||||
}) |
||||
.start(); |
||||
|
||||
var svg = container.append('g'); |
||||
var actions = graph_actions.create(svg, dvgraph); |
||||
|
||||
// =================================================== |
||||
// =============== MARKERS SETUP ================== |
||||
// =================================================== |
||||
|
||||
svg.append("defs").selectAll("marker") |
||||
.data(["default", "dependency", "dependants"]) |
||||
.enter().append("marker") |
||||
.attr("id", function (d) { |
||||
return d; |
||||
}) |
||||
.attr("viewBox", "0 -5 10 10") |
||||
.attr("refX", 10) |
||||
.attr("refY", 0) |
||||
.attr("markerWidth", 10) |
||||
.attr("markerHeight", 10) |
||||
.attr("orient", "auto") |
||||
.attr("class", "marker") |
||||
.append("path") |
||||
.attr("d", "M0,-5L10,0L0,5"); |
||||
|
||||
|
||||
// =================================================== |
||||
// =============== LINKS SETUP ================== |
||||
// =================================================== |
||||
|
||||
var link = svg.append("g").selectAll("path") |
||||
.data(d3graph.links) |
||||
.enter().append("path") |
||||
.attr("class", "link") |
||||
.attr("marker-end", "url(#default)") |
||||
.style("stroke-width", function (d) { |
||||
return 1; |
||||
}); |
||||
|
||||
// =================================================== |
||||
// =============== NODES SETUP ================== |
||||
// =================================================== |
||||
|
||||
var node = svg.append("g").selectAll("circle.node") |
||||
.data(d3graph.nodes) |
||||
.enter().append("circle") |
||||
.attr("r", radius) |
||||
.style("fill", function (d) { |
||||
return color(d.group) |
||||
}) |
||||
.attr("class", "node") |
||||
.attr("source", function (d) { |
||||
return d.source |
||||
}) |
||||
.attr("dest", function (d) { |
||||
return d.dest |
||||
}) |
||||
.call(force.drag) |
||||
.on("click", function (d) { |
||||
if (d3.event.defaultPrevented) { |
||||
return |
||||
} |
||||
actions.selectNodesStartingFromNode(d, 1); |
||||
force.start(); |
||||
}) |
||||
.on("contextmenu", function (d) { |
||||
if (d3.event.defaultPrevented) { |
||||
return |
||||
} |
||||
// Don't actually show context menu |
||||
d3.event.preventDefault(); |
||||
|
||||
actions.selectNodesStartingFromNode(d); |
||||
force.start(); |
||||
}); |
||||
|
||||
// =================================================== |
||||
// =============== TEXT NODES SETUP ============= |
||||
// =================================================== |
||||
|
||||
var text = svg.append("g").selectAll("text") |
||||
.data(force.nodes()) |
||||
.enter().append("text") |
||||
.attr("visibility", "hidden") |
||||
.text(function (d) { |
||||
return d.name.substring(0, default_max_texts_length) |
||||
}); |
||||
|
||||
// =================================================== |
||||
// =============== FORCE UPDATE ============= |
||||
// =================================================== |
||||
|
||||
force.on("tick", function (e) { |
||||
svg.selectAll(".node").attr("r", radius); |
||||
link.attr("d", link_line); |
||||
node.attr("transform", transform); |
||||
if (show_texts_near_circles) { |
||||
text.attr("transform", transform); |
||||
} |
||||
}); |
||||
|
||||
// =================================================== |
||||
// =============== HELPER FUNCTIONS ============= |
||||
// =================================================== |
||||
function link_line(d) { |
||||
var dx = d.target.x - d.source.x, |
||||
dy = d.target.y - d.source.y, |
||||
dr = Math.sqrt(dx * dx + dy * dy); |
||||
|
||||
var rsource = radius(d.sourceNode) / dr; |
||||
var rdest = radius(d.targetNode) / dr; |
||||
var startX = d.source.x + dx * rsource; |
||||
var startY = d.source.y + dy * rsource; |
||||
|
||||
var endX = d.target.x - dx * rdest; |
||||
var endY = d.target.y - dy * rdest; |
||||
return "M" + startX + "," + startY + "L" + endX + "," + endY; |
||||
} |
||||
|
||||
function transform(d) { |
||||
return "translate(" + d.x + "," + d.y + ")"; |
||||
} |
||||
|
||||
function radius(d) { |
||||
return default_circle_radius + default_circle_radius * d.source / 10; |
||||
} |
||||
|
||||
/* |
||||
Window resize update |
||||
*/ |
||||
w.onresize = function () { |
||||
x = w.innerWidth || e.clientWidth || g.clientWidth; |
||||
y = w.innerHeight || e.clientHeight || g.clientHeight; |
||||
|
||||
container.attr("width", Math.ceil(x)).attr("height", Math.ceil(y)); |
||||
force.size([Math.ceil(x), Math.ceil(y)]).start(); |
||||
}; |
||||
|
||||
|
||||
</script> |
||||
|
||||
<script> |
||||
// =================================================== |
||||
// =============== INPUTS HANDLING ============== |
||||
// =================================================== |
||||
d3.selectAll("input").on("change", function change() { |
||||
|
||||
if (this.name == "circle_size") { |
||||
default_circle_radius = parseInt(this.value); |
||||
force.linkDistance(function (l) { |
||||
return radius(l.source) + radius(l.target) + default_link_distance; |
||||
}); |
||||
force.start(); |
||||
} |
||||
|
||||
if (this.name == "charge_multiplier") { |
||||
charge_multiplier = parseInt(this.value); |
||||
force.start(); |
||||
} |
||||
|
||||
if (this.name == "link_strength") { |
||||
default_link_strength = parseInt(this.value) / 10; |
||||
force.linkStrength(default_link_strength); |
||||
force.start(); |
||||
} |
||||
|
||||
if (this.name == "show_texts_near_circles") { |
||||
text.attr("visibility", this.checked ? "visible" : "hidden"); |
||||
show_texts_near_circles = this.checked; |
||||
force.start(); |
||||
} |
||||
|
||||
}); |
||||
</script> |
||||
|
||||
|
||||
<script> |
||||
// =================================================== |
||||
// =============== LIVE FILTERING ============== |
||||
// =================================================== |
||||
|
||||
function live_filter_graph(regexp, classname, invert) { |
||||
classname = typeof classname !== 'undefined' ? classname : "filtered"; |
||||
invert = typeof invert !== 'undefined' ? invert : false; |
||||
|
||||
var re = new RegExp(regexp, "i"); |
||||
svg.selectAll('circle, text') |
||||
.classed(classname, function (node) { |
||||
var filtered = !node.name.match(re); |
||||
filtered = invert ? !filtered : filtered; |
||||
node.filtered = filtered; |
||||
node.neighbours = !filtered; |
||||
return filtered; |
||||
}) |
||||
.transition(); |
||||
|
||||
svg.selectAll('.link') |
||||
.classed(classname, function (l) { |
||||
var filtered = !(l.sourceNode.name.match(re) && l.targetNode.name.match(re)); |
||||
filtered = invert ? !filtered : filtered; |
||||
return filtered; |
||||
}) |
||||
.attr("marker-end", function (l) { |
||||
var filtered = !(l.sourceNode.name.match(re) && l.targetNode.name.match(re)); |
||||
filtered = invert ? !filtered : filtered; |
||||
return filtered ? "" : "url(#default)" |
||||
}) |
||||
.transition() |
||||
} |
||||
|
||||
|
||||
d3.select("#search_input").on("input", function () { |
||||
// Filter all items |
||||
console.log("Input changed to" + this.value); |
||||
actions.deselect_selected_node(); |
||||
|
||||
if (this.value && this.value.length) { |
||||
live_filter_graph(this.value, "filtered"); |
||||
force.start(); |
||||
} |
||||
}); |
||||
</script> |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue