Module: JscaffoldHelper
- Defined in:
- lib/generators/jscaffold/templates/helpers/jscaffold_helper.rb
Instance Method Summary collapse
- #hide_more_button(model) ⇒ Object
- #jq_load_more_btn(model) ⇒ Object
- #jqscript(model, data_a, searchf) ⇒ Object
- #search_data(data, category) ⇒ Object
- #search_field(model, search) ⇒ Object
Instance Method Details
#hide_more_button(model) ⇒ Object
2 3 4 |
# File 'lib/generators/jscaffold/templates/helpers/jscaffold_helper.rb', line 2 def (model) "<script>document.getElementById('#{model.table_name}_next_link').innerHTML = '';</script>".html_safe if model.last_page? end |
#jq_load_more_btn(model) ⇒ Object
18 19 20 21 22 |
# File 'lib/generators/jscaffold/templates/helpers/jscaffold_helper.rb', line 18 def jq_load_more_btn(model) if !model.last_page? ("<div id=\""+model.table_name+"_next_link\"><br/><center><button class=\""+model.table_name+"_next\" type=\"submit\" style=\"width:300px;\" name=\"button\">Load more</button></center></div>").html_safe end end |
#jqscript(model, data_a, searchf) ⇒ Object
10 11 12 |
# File 'lib/generators/jscaffold/templates/helpers/jscaffold_helper.rb', line 10 def jqscript(model,data_a,searchf) ("<script>$(function() { var data = [ "+data_a.map{ |x| x.reverse.take(1).map { |y| search_data(x,y) } }.to_s+"]; $(\"#"+model.table_name+"_search_field\").catcomplete({ delay: 0, source: data }); }); $(document).ready(function() { var currPage = 1; $(\"button."+model.table_name+"_next\").click(function() { loadMore(++currPage,'"+model.table_name+"','"+ searchf + "'); }); });</script>").html_safe end |
#search_data(data, category) ⇒ Object
6 7 8 |
# File 'lib/generators/jscaffold/templates/helpers/jscaffold_helper.rb', line 6 def search_data(data,category) data.map{ |x| "{ label: '"+x+"', category: '"+category.capitalize+"' }," if x != category }.to_s.html_safe end |
#search_field(model, search) ⇒ Object
14 15 16 |
# File 'lib/generators/jscaffold/templates/helpers/jscaffold_helper.rb', line 14 def search_field(model,search) ("<form accept-charset=\"UTF-8\" action=\"/"+model.table_name+"/\" autocomplete=\"off\" method=\"get\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /></div><input id=\""+model.table_name+"_search_field\" name=\"q\" type=\"text\" value=\""+search+"\" /><input type=\"submit\" value=\"Search\" /></form>").html_safe end |