Method: ReactiveRecord::WhileLoading.add_style_sheet

Defined in:
lib/reactive_record/active_record/reactive_record/while_loading.rb

.add_style_sheetObject



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/reactive_record/active_record/reactive_record/while_loading.rb', line 150

def add_style_sheet
  # directly assigning the code to the variable triggers a opal 0.10.5 compiler bug.
  unless @style_sheet_added
    %x{
      var style_el = document.createElement("style");
      style_el.setAttribute("type", "text/css");
      style_el.innerHTML = ".reactive_record_is_loading > .reactive_record_show_when_loaded { display: none; }\n" +
                           ".reactive_record_is_loaded > .reactive_record_show_while_loading { display: none; }";
      document.head.append(style_el);
    }
    @style_sheet_added = true
  end
end