From: Jan Provaznik jprovazn@redhat.com
Removed code for rendering JS tables which we don't user anymore. --- src/app/helpers/application_helper.rb | 107 --------------------------------- src/public/javascripts/application.js | 48 --------------- 2 files changed, 0 insertions(+), 155 deletions(-)
diff --git a/src/app/helpers/application_helper.rb b/src/app/helpers/application_helper.rb index c3cf0cc..a2e74b5 100644 --- a/src/app/helpers/application_helper.rb +++ b/src/app/helpers/application_helper.rb @@ -20,31 +20,6 @@ # Likewise, all the methods added will be available for all controllers.
module ApplicationHelper - - def confirmation_dialog(div_id, text, action) - %{ - <div id="#{div_id}" style="display:none;"> - <div class="confirm_dialog_title"> - <div class="confirm_dialog_header">#{text}</div> - <div style="clear:both;"></div> - </div> - - <div class="confirm_dialog_footer"> - <div class="button"> - <div class="button_left_grey"></div> - <div class="button_middle_grey"><a href="#" onclick="$(document).trigger('close.facebox')">Cancel</a></div> - <div class="button_right_grey"></div> - </div> - <div class="button"> - <div class="button_left_blue"></div> - <div class="button_middle_blue"><a href="#" onclick="#{action}">OK</a></div> - <div class="button_right_blue"></div> - </div> - </div> - </div> - } - end - def number_to_duration(input_num) input_int = input_num.to_i hours_to_seconds = [input_int/3600 % 24, @@ -59,29 +34,6 @@ module ApplicationHelper day_str + hours_to_seconds end
- def column_header(column, order, order_dir, check_all) - next_dir = order_dir.to_s == 'asc' ? 'desc' : 'asc' - if order and column[:id] == order - dir = order_dir.to_s == 'desc' ? 'desc' : 'asc' - cls = "ordercol #{dir}" - else - cls = nil - end - - if column[:sortable] - label = link_to( - column[:header], - {:action => controller.action_name, :partial => true, :order => column[:id], :order_dir => next_dir, :search => params[:search]}, - :class => cls) - elsif check_all.to_s == column[:id] - label = check_box_tag 'check_all' - else - label = column[:header] - end - - content_tag 'th', label - end - # Fields example: # [ # { :name => 'Pool name', :sort_attr => 'name'}, @@ -135,65 +87,6 @@ module ApplicationHelper } end
- def paginated_table(html_id, columns, data, opts = {}) - search_url = url_for(:partial => true, :order => opts[:order], :order_dir => opts[:order_dir]) - - # for now submit url for base table form can be same as search url - # it's possible to change it in a future - submit_url = search_url - - extend_table_js = "<script type="text/javascript">Conductor.extendTable({id: '##{html_id}',single_select:#{opts[:single_select] ? true : false}});#{opts[:load_callback]};</script>" - extend_sfield_js = "<script type="text/javascript">Conductor.extendTableSearchField({id: '##{html_id}'})</script>" - - rows = data.map do |rec| - if block_given? - capture_haml{yield rec} - else - content_tag 'tr', :class => cycle('even', 'odd') do - columns.map { |c| content_tag 'td', rec[c[:id]] } - end - end - end - - header_cols = columns.map {|c| column_header(c, opts[:order], opts[:order_dir], opts[:check_all])} - - table = content_tag 'table' do - content_tag('thead', content_tag('tr', header_cols)) + content_tag('tbody', rows) - end - - internal_header = content_tag 'div', :class => 'header' do - content_tag('div', opts[:title], :class => 'title') - end - - internal_footer = content_tag 'div', :class => 'footer' do - will_paginate(data, :params => {:partial => true}).to_s + - page_entries_info(data).to_s - end - - ajax_content = table + internal_footer + extend_table_js - - if params[:partial] and request.xhr? - ajax_content - else - wrapped_table = content_tag 'div', :class => 'wrapped_table' do - internal_header + - content_tag('div', ajax_content, :class => 'wrapper') - end - base_form = content_tag 'form', :action => submit_url, :class => 'dtable_form' do - opts[:header].to_s + wrapped_table + opts[:footer].to_s - end - - # search field is in separate form because of submitting on enter key - search_field = content_tag 'form', :action => search_url, :class => 'search_field' do - 'Search ' + text_field_tag('search', params[:search], :size => 10, :value => params[:search]) + extend_sfield_js - end - - content_tag 'div', :id => html_id, :class => "dtable #{opts[:class]}" do - base_form + search_field - end - end - end - # Integration of rack-restful_submit convention to be able to call # RESTful resources defined by Rails conventions without Javascript. # diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js index bb23e4e..cd4a0dc 100644 --- a/src/public/javascripts/application.js +++ b/src/public/javascripts/application.js @@ -3,54 +3,6 @@
$.extend(Conductor, { - extendTable: function(options) { - var table = $(options.id); - var wrapper = $(".wrapper", table); - - // show searchfield (it's disabled by default because with JS off, - // when enter is pressed in search field, form is submited) - $(".search_field", table).css('display', 'block'); - - // make column head links ajax - $("table thead tr th a", table).click(function() {wrapper.load($(this).attr('href'));return false;}); - - // pagination links should be ajax too - $(".pagination a", table).click(function() {wrapper.load($(this).attr('href'));return false;}); - - // check all checkboxes when checking "check all" - $("input[name='check_all']", table).click(function() {$("input[name='ids[]']", table).attr('checked', $(this).attr('checked'))}); - - // check checkbox if row is clicked - $("table tbody tr", table).click(function(ev) { - var on_checkbox = $(ev.target).attr('name') == 'ids[]'; - var box = $("input[name='ids[]']", this); - var old_val = box.attr('checked'); - if (options.single_select || !on_checkbox) $("input[name='ids[]']", table).attr('checked', false); - // when click is on checkbox, value is already toggled - box.attr('checked', on_checkbox ? old_val : !old_val); - }); - }, - - extendTableSearchField: function(options) { - var table = $(options.id); - var wrapper = $(".wrapper", table); - $(".search_field input", table).keypress(function(ev) { - var delay = 1000; - if (ev.keyCode == 13) { - delay = 0; - ev.preventDefault(); - } - if (table.searching) clearTimeout(table.searching); - table.searching = setTimeout(function() { - $(".wrapper", table).mask('Searching...'); - table.search_lock = false; - var search = $(".search_field input", table).val(); - var url = $("form", table).attr('action') + '&search=' + search; - wrapper.load(url, function() {$(".wrapper", table).unmask()}); - }, delay); - }); - }, - positionFooter: function () { var $footer = $('footer'); if ($(document.body).height() < $(window).height()) {
On Monday 19 September 2011 13:16:53 jprovazn@redhat.com wrote:
From: Jan Provaznik jprovazn@redhat.com
Removed code for rendering JS tables which we don't user anymore.
src/app/helpers/application_helper.rb | 107 --------------------------------- src/public/javascripts/application.js | 48 --------------- 2 files changed, 0 insertions(+), 155 deletions(-)
diff --git a/src/app/helpers/application_helper.rb b/src/app/helpers/application_helper.rb index c3cf0cc..a2e74b5 100644 --- a/src/app/helpers/application_helper.rb +++ b/src/app/helpers/application_helper.rb @@ -20,31 +20,6 @@ # Likewise, all the methods added will be available for all controllers.
module ApplicationHelper
- def confirmation_dialog(div_id, text, action)
- %{
<div id="#{div_id}" style="display:none;">
<div class="confirm_dialog_title">
<div class="confirm_dialog_header">#{text}</div>
<div style="clear:both;"></div>
</div>
<div class="confirm_dialog_footer">
<div class="button">
<div class="button_left_grey"></div>
<div class="button_middle_grey"><a href="#"
onclick="$(document).trigger('close.facebox')">Cancel</a></div> -
<div class="button_right_grey"></div> - </div> - <div class="button"> - <div class="button_left_blue"></div> - <div class="button_middle_blue"><a href="#" onclick="#{action}">OK</a></div> - <div class="button_right_blue"></div> - </div> - </div> - </div> - } - end - def number_to_duration(input_num) input_int = input_num.to_i hours_to_seconds = [input_int/3600 % 24, @@ -59,29 +34,6 @@ module ApplicationHelper day_str + hours_to_seconds end
- def column_header(column, order, order_dir, check_all)
- next_dir = order_dir.to_s == 'asc' ? 'desc' : 'asc'
- if order and column[:id] == order
dir = order_dir.to_s == 'desc' ? 'desc' : 'asc'
cls = "ordercol #{dir}"
- else
cls = nil
- end
- if column[:sortable]
label = link_to(
column[:header],
{:action => controller.action_name, :partial => true, :order =>
column[:id], :order_dir => next_dir, :search => params[:search]}, - :class => cls)
- elsif check_all.to_s == column[:id]
label = check_box_tag 'check_all'
- else
label = column[:header]
- end
- content_tag 'th', label
- end
- # Fields example: # [ # { :name => 'Pool name', :sort_attr => 'name'},
@@ -135,65 +87,6 @@ module ApplicationHelper } end
- def paginated_table(html_id, columns, data, opts = {})
- search_url = url_for(:partial => true, :order => opts[:order],
:order_dir => opts[:order_dir]) -
- # for now submit url for base table form can be same as search url
- # it's possible to change it in a future
- submit_url = search_url
- extend_table_js = "<script
type="text/javascript">Conductor.extendTable({id: '##{html_id}',single_select:#{opts[:single_select] ? true : false}});#{opts[:load_callback]};</script>" - extend_sfield_js = "<script type="text/javascript">Conductor.extendTableSearchField({id: '##{html_id}'})</script>" -
- rows = data.map do |rec|
if block_given?
capture_haml{yield rec}
else
content_tag 'tr', :class => cycle('even', 'odd') do
columns.map { |c| content_tag 'td', rec[c[:id]] }
end
end
- end
- header_cols = columns.map {|c| column_header(c, opts[:order],
opts[:order_dir], opts[:check_all])} -
- table = content_tag 'table' do
content_tag('thead', content_tag('tr', header_cols)) +
content_tag('tbody', rows) - end
- internal_header = content_tag 'div', :class => 'header' do
content_tag('div', opts[:title], :class => 'title')
- end
- internal_footer = content_tag 'div', :class => 'footer' do
will_paginate(data, :params => {:partial => true}).to_s +
page_entries_info(data).to_s
- end
- ajax_content = table + internal_footer + extend_table_js
- if params[:partial] and request.xhr?
ajax_content
- else
wrapped_table = content_tag 'div', :class => 'wrapped_table' do
internal_header +
content_tag('div', ajax_content, :class => 'wrapper')
end
base_form = content_tag 'form', :action => submit_url, :class =>
'dtable_form' do - opts[:header].to_s + wrapped_table + opts[:footer].to_s
end
# search field is in separate form because of submitting on enter
key - search_field = content_tag 'form', :action => search_url, :class => 'search_field' do - 'Search ' + text_field_tag('search', params[:search], :size => 10, :value => params[:search]) + extend_sfield_js - end
content_tag 'div', :id => html_id, :class => "dtable
#{opts[:class]}" do - base_form + search_field
end
- end
- end
- # Integration of rack-restful_submit convention to be able to call # RESTful resources defined by Rails conventions without Javascript. #
diff --git a/src/public/javascripts/application.js b/src/public/javascripts/application.js index bb23e4e..cd4a0dc 100644 --- a/src/public/javascripts/application.js +++ b/src/public/javascripts/application.js @@ -3,54 +3,6 @@
$.extend(Conductor, {
- extendTable: function(options) {
- var table = $(options.id);
- var wrapper = $(".wrapper", table);
- // show searchfield (it's disabled by default because with JS off,
- // when enter is pressed in search field, form is submited)
- $(".search_field", table).css('display', 'block');
- // make column head links ajax
- $("table thead tr th a", table).click(function()
{wrapper.load($(this).attr('href'));return false;}); -
- // pagination links should be ajax too
- $(".pagination a", table).click(function()
{wrapper.load($(this).attr('href'));return false;}); -
- // check all checkboxes when checking "check all"
- $("input[name='check_all']", table).click(function()
{$("input[name='ids[]']", table).attr('checked', $(this).attr('checked'))}); -
- // check checkbox if row is clicked
- $("table tbody tr", table).click(function(ev) {
var on_checkbox = $(ev.target).attr('name') == 'ids[]';
var box = $("input[name='ids[]']", this);
var old_val = box.attr('checked');
if (options.single_select || !on_checkbox) $("input[name='ids[]']",
table).attr('checked', false); - // when click is on checkbox, value is already toggled
box.attr('checked', on_checkbox ? old_val : !old_val);
- });
- },
- extendTableSearchField: function(options) {
- var table = $(options.id);
- var wrapper = $(".wrapper", table);
- $(".search_field input", table).keypress(function(ev) {
var delay = 1000;
if (ev.keyCode == 13) {
delay = 0;
ev.preventDefault();
}
if (table.searching) clearTimeout(table.searching);
table.searching = setTimeout(function() {
$(".wrapper", table).mask('Searching...');
table.search_lock = false;
var search = $(".search_field input", table).val();
var url = $("form", table).attr('action') + '&search=' + search;
wrapper.load(url, function() {$(".wrapper", table).unmask()});
}, delay);
- });
- },
- positionFooter: function () { var $footer = $('footer'); if ($(document.body).height() < $(window).height()) {
ACK
aeolus-devel@lists.fedorahosted.org