Module: Opale::ScriptInserter

Defined in:
lib/opale/script_inserter.rb

Constant Summary collapse

BODY_TAG =
%r{</body>}
JS_SCRIPT =
%q(
  <script>
  function sortable(event, column) {
    console.log("sortable");
    var direction = $("#direction").val();

    $("#sort").val(column);
    $("#direction").val(direction == "desc" ? "asc" : "desc");

    $('#direction').parent().submit();

    //event.preventDefault();
  }
  </script>
)

Instance Method Summary collapse

Instance Method Details

#insert_opalejsObject



21
22
23
24
25
26
27
28
# File 'lib/opale/script_inserter.rb', line 21

def insert_opalejs
  if (
    response.content_type == 'text/html' &&
    response.body.match(BODY_TAG)
  )
    response.body = response.body.gsub(BODY_TAG, JS_SCRIPT + '\\0')
  end
end