- old_callback.call(this);
- };
-
- $.wiki.SidebarPerspective.call(this, options);
- };
-
- SearchPerspective.prototype = new $.wiki.SidebarPerspective();
-
- SearchPerspective.prototype.search = function(forward=true){
- var self = this;
- var query = self.$searchInput.val();
-
- if (!self.editor)
- self.editor = $.wiki.perspectiveForTab('#CodeMirrorPerspective').codemirror
-
- if (!self.searchCursor) {
- var options = {};
- options.caseFold = !self.options['search-case-sensitive'];
- var start = 0;
- if (self.options['search-from-cursor']) {
- start = self.editor.getCursor();
+ search(forward=true) {
+ var self = this;
+ var query = self.$searchInput.val();
+
+ if (!self.editor)
+ self.editor = $.wiki.perspectiveForTab('#CodeMirrorPerspective').codemirror
+
+ if (!self.searchCursor) {
+ var options = {};
+ options.caseFold = !self.options['search-case-sensitive'];
+ var start = 0;
+ if (self.options['search-from-cursor']) {
+ start = self.editor.getCursor();
+ }
+ self.searchCursor = self.editor.getSearchCursor(
+ self.$searchInput.val(),
+ start,
+ options
+ );
+ }
+ if (forward ? self.searchCursor.findNext() : self.searchCursor.findPrevious()) {
+ self.editor.setSelection(self.searchCursor.from(), self.searchCursor.to());
+ self.editor.scrollIntoView({from: self.searchCursor.from(), to: self.searchCursor.to()}, 20);
+ self.$replaceButton.removeAttr("disabled");
+ return true;
+ }
+ else {
+ self.searchCursor = null;
+ this.$replaceButton.attr("disabled","disabled");
+ return false;