6     function SearchPerspective(options){
 
   7         var old_callback = options.callback || function() { };
 
   9         this.noupdate_hash_onenter = true;
 
  11         options.callback = function(){
 
  15             this.$element = $("#side-search");
 
  16             this.$searchInput = $('#search-input', this.$element);
 
  17             this.$replaceInput = $('#replace-input', this.$element);
 
  18             this.$searchButton = $('#search-button', this.$element);
 
  19             this.$replaceButton = $('#replace-button', this.$element);
 
  21             this.$replaceButton.attr("disabled","disabled");
 
  22             this.options = Array();
 
  25             this.$searchInput.change(function(event){
 
  26                 self.searchCursor = null;
 
  28             this.$replaceInput.change(function(event){
 
  29                 self.searchCursor = null;
 
  32             $("#side-search input:checkbox").each(function() {
 
  33                 self.options[this.id] = this.checked;
 
  35                 self.options[this.id] = this.checked;
 
  36                 self.searchCursor = null;
 
  39             this.$searchButton.click(function(){
 
  41                     alert('Brak wyników.');
 
  44             this.$replaceButton.click(function(){
 
  48             old_callback.call(this);
 
  51         $.wiki.Perspective.call(this, options);
 
  54     SearchPerspective.prototype = new $.wiki.Perspective();
 
  56     SearchPerspective.prototype.search = function(){
 
  58         var query = self.$searchInput.val();
 
  61             self.editor = $.wiki.perspectiveForTab('#CodeMirrorPerspective').codemirror
 
  63         if (!self.searchCursor) {
 
  64             self.searchCursor = self.editor.getSearchCursor(
 
  65                 self.$searchInput.val(), 
 
  66                 self.options['search-from-cursor'], 
 
  67                 !self.options['search-case-sensitive']
 
  70         if (self.searchCursor.findNext()) {
 
  71             self.searchCursor.select();
 
  72             self.$replaceButton.removeAttr("disabled");
 
  76             self.searchCursor = null;
 
  77             this.$replaceButton.attr("disabled","disabled");
 
  82     SearchPerspective.prototype.replace = function(){
 
  84         var query = self.$replaceInput.val();
 
  86         if (!self.searchCursor) {
 
  90         self.searchCursor.select();
 
  91         self.searchCursor.replace(query);
 
  95     SearchPerspective.prototype.onEnter = function(success, failure){
 
  98         $.wiki.Perspective.prototype.onEnter.call(this);
 
  99         self.$searchCursor = null;
 
 101         $('.vsplitbar').not('.active').trigger('click');
 
 102         $(".vsplitbar-title").html("↓ SEARCH AND REPLACE ↓");        
 
 104         if ($.wiki.activePerspective() != 'CodeMirrorPerspective')
 
 105             $.wiki.switchToTab('#CodeMirrorPerspective');
 
 108     SearchPerspective.prototype.onExit = function(success, failure) {
 
 112     $.wiki.SearchPerspective = SearchPerspective;