提交 5f12ea2e 编写于 作者: S Sercan

cursor options

上级 8170a1e7
......@@ -12,6 +12,17 @@ clearSessions = function () {
Session.set(strSessionSelectedCollection, undefined);
};
Array.prototype.remove = function () {
var what, a = arguments, L = a.length, ax;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
this.splice(ax, 1);
}
}
return this;
};
Template.registerHelper('getConnection', function () {
if (Session.get(strSessionConnection)) {
return Connections.findOne({_id: Session.get(strSessionConnection)});
......
......@@ -7,4 +7,15 @@
HH:mm:ss</strong></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-1 control-label">Options</label>
<div class="col-lg-11">
<select id="cmbCursorOptions"
data-placeholder="Choose one or more options.."
multiple="true"
class="chosen-select form-control"
tabindex="-1">
</select>
</div>
</div>
</template>
\ No newline at end of file
/**
* Created by sercan on 30.12.2015.
*/
var strSessionSelectedOptions = "selectedCursorOptions";
Template.find.onRendered(function () {
// set ace editor
AceEditor.instance("preSelector", {
mode: "javascript",
theme: 'dawn'
}, function (editor) {
editor.$blockScrolling = Infinity;
editor.setOptions({
fontSize: "11pt",
showPrintMargin: false,
});
// remove newlines in pasted text
editor.on("paste", function (e) {
e.text = e.text.replace(/[\r\n]+/g, " ");
});
// make mouse position clipping nicer
editor.renderer.screenToTextCoordinates = function (x, y) {
var pos = this.pixelToScreenCoordinates(x, y);
return this.session.screenToDocumentPosition(
Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
Math.max(pos.column, 0)
);
};
// disable Enter Shift-Enter keys
editor.commands.bindKey("Enter|Shift-Enter", executeQuery);
});
initializeAceEditor();
initializeOptions();
initializeSessionVariable();
});
Template.browseCollection.events({
......@@ -107,4 +87,57 @@ executeQuery = function () {
// stop loading animation
l.ladda('stop');
});
}
initializeAceEditor = function () {
AceEditor.instance("preSelector", {
mode: "javascript",
theme: 'dawn'
}, function (editor) {
editor.$blockScrolling = Infinity;
editor.setOptions({
fontSize: "11pt",
showPrintMargin: false,
});
// remove newlines in pasted text
editor.on("paste", function (e) {
e.text = e.text.replace(/[\r\n]+/g, " ");
});
// make mouse position clipping nicer
editor.renderer.screenToTextCoordinates = function (x, y) {
var pos = this.pixelToScreenCoordinates(x, y);
return this.session.screenToDocumentPosition(
Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
Math.max(pos.column, 0)
);
};
// disable Enter Shift-Enter keys
editor.commands.bindKey("Enter|Shift-Enter", executeQuery);
});
}
initializeOptions = function () {
var cmb = $('#cmbCursorOptions');
$.each(CURSOR_OPTIONS, function (key, value) {
cmb.append($("<option></option>")
.attr("value", key)
.text(value));
});
cmb.chosen();
cmb.on('change', function (evt, params) {
var array = Session.get(strSessionSelectedOptions);
if (params.deselected) {
array.remove(params.deselected);
}
else {
array.push(params.selected);
}
Session.set(strSessionSelectedOptions, array);
});
}
initializeSessionVariable = function () {
Session.set(strSessionSelectedOptions, []);
}
\ No newline at end of file
......@@ -10,4 +10,13 @@ QUERY_TYPES = {
FINDONE_AND_REPLACE: "findOneAndReplace",
FINDONE_AND_UPDATE: "findOneAndUpdate"
}
CURSOR_OPTIONS = {
PROJECT: "project",
SKIP: "skip",
LIMIT: "limit",
MAX: "max",
MIN: "min",
SORT: "sort"
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册