Module: Admin::SnippetsHelper

Defined in:
app/helpers/admin/snippets_helper.rb

Instance Method Summary collapse

Instance Method Details

#snippet_edit_javascriptsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/admin/snippets_helper.rb', line 2

def snippet_edit_javascripts
  (<<-CODE).html_safe
  var tagReferenceWindows = {};
  function loadTagReference() {
    var pageType = 'Page';
    if (!tagReferenceWindows[pageType])
      tagReferenceWindows[pageType] = new Popup.AjaxWindow("#{admin_reference_path('tags')}?class_name=" + encodeURIComponent(pageType), {reload: false});
    var window = tagReferenceWindows[pageType];
    if('Page' != pageType) {
      $('tag_reference_link').highlight();
      window.show();
    } else {
      window.toggle();
    }
    lastPageType = pageType;
    return false;
  }

  var lastFilter = '#{@snippet.filter_id}';
  var filterWindows = {};
  function loadFilterReference() {
    var filter = $F("snippet_filter_id");
    if (filter != "") {
      if (!filterWindows[filter]) filterWindows[filter] = new Popup.AjaxWindow("#{admin_reference_path('filters')}?filter_name="+encodeURIComponent(filter), {reload: false});
      var window = filterWindows[filter];
      if(lastFilter != filter) {
        window.show();
      } else {
        window.toggle();
      }
      lastFilter = filter;
    } else {
      alert('No documentation for filter.');
    }
    return false;
  }
  CODE
end