Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails HTML escaping fixes + Support for editoptions #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/2dc_jqgrid.rb
Expand Up @@ -169,7 +169,7 @@ def jqgrid(title, id, action, columns = [], options = {})
search = ""
filter_toolbar = ""
if options[:search] == 'true'
search = %Q/.navButtonAdd("##{id}_pager",{caption:"",title:$.jgrid.nav.searchtitle, buttonicon :'ui-icon-search', onClickButton:function(){ mygrid[0].toggleToolbar() } })/
search = %Q/.navButtonAdd("##{id}_pager",{caption:"",title:jQuery.jgrid.nav.searchtitle, buttonicon :'ui-icon-search', onClickButton:function(){ mygrid[0].toggleToolbar() } })/
filter_toolbar = "mygrid.filterToolbar();"
filter_toolbar << "mygrid[0].toggleToolbar()"
end
Expand Down Expand Up @@ -229,7 +229,7 @@ def jqgrid(title, id, action, columns = [], options = {})
// When the cookie is saved the items will be a comma separated string
// so we will split the cookie by comma to get the original array
// Get the cookie if it exists
var cookie = $.cookie(cookieName);
var cookie = jQuery.cookie(cookieName);
// Load the items or a new array if null.
var items = cookie ? cookie.split(/,/) : new Array();

Expand All @@ -241,19 +241,19 @@ def jqgrid(title, id, action, columns = [], options = {})
},
"del": function(val) {
// Remove value from the items.
if($.inArray(val, items) > -1) items.splice($.inArray(val, items), 1);
if(jQuery.inArray(val, items) > -1) items.splice(jQuery.inArray(val, items), 1);
},
"clear": function() {
//clear the cookie.
$.cookie(cookieName, null);
jQuery.cookie(cookieName, null);
},
"save": function() {
// Save the items to a cookie.
$.cookie(cookieName, items.join(','));
jQuery.cookie(cookieName, items.join(','));
},
"exists": function(val) {
// Check if value exists in array
return ($.inArray(val, items) > -1);
return (jQuery.inArray(val, items) > -1);
},
"items": function() {
// Get all the items.
Expand Down Expand Up @@ -293,7 +293,7 @@ def jqgrid(title, id, action, columns = [], options = {})
var unselected_records = new cookieArray("#{id}_unselected_records");
// Process the ids
//alert(selected_records.items());
$.each(ids, function (i, id) {
jQuery.each(ids, function (i, id) {
if (selected) {
selected_records.add(id);
unselected_records.del(id);
Expand All @@ -317,7 +317,7 @@ def jqgrid(title, id, action, columns = [], options = {})
var grid = jQuery("##{id}");
// Process and apply selections
grid_ids = grid.getDataIDs();
$.each(grid.getDataIDs(), function (i, id) {
jQuery.each(grid.getDataIDs(), function (i, id) {
if (selected_records.exists(id)) {
grid.setSelection(id, false);
}
Expand Down Expand Up @@ -551,7 +551,7 @@ def jqgrid(title, id, action, columns = [], options = {})
height: '100%'
})
.navGrid("#"+pager_id,{edit:#{options[:subgrid][:edit]},add:#{options[:subgrid][:add]},del:#{options[:subgrid][:delete]},search:false})
.navButtonAdd("#"+pager_id,{caption:"",title:$.jgrid.nav.searchtitle, buttonicon :'ui-icon-search', onClickButton:function(){ subgrd[0].toggleToolbar() } })
.navButtonAdd("#"+pager_id,{caption:"",title:jQuery.jgrid.nav.searchtitle, buttonicon :'ui-icon-search', onClickButton:function(){ subgrd[0].toggleToolbar() } })
subgrd.filterToolbar();
subgrd[0].toggleToolbar();
},
Expand Down Expand Up @@ -628,7 +628,7 @@ def jqgrid(title, id, action, columns = [], options = {})
<div id="flash_alert" style="display:none;padding:0.7em;" class="ui-state-highlight ui-corner-all"></div>
<table id="#{id}" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="#{id}_pager" class="scroll" style="text-align:center;"></div>
)
).html_safe
end

private
Expand Down Expand Up @@ -692,7 +692,7 @@ def get_sub_options(editoptions)
elsif couple[0] == :elmsuffix || couple[0] == :elmpreffix # :elmsuffix => %Q~<a id="companysearch" href="javascript:void(0)"><span id="companysearchicon" class="ui-icon ui-icon-plus" style="position:absolute; top:2px; right:25px;"></span></a>~
options << %Q~#{couple[0]}:'#{couple[1]}',~
else # :size => 30, :rows => 5, :maxlength => 20, ...
if couple[0] == :elmsuffix || couple[1].instance_of?(Fixnum) || couple[1] == 'true' || couple[1] == 'false' || couple[1] == true || couple[1] == false || couple[1] =~ /function/
if couple[0] == :elmsuffix || couple[1].instance_of?(Symbol) || couple[1].instance_of?(Fixnum) || couple[1] == 'true' || couple[1] == 'false' || couple[1] == true || couple[1] == false || couple[1] =~ /function/
options << %Q/#{couple[0]}:#{couple[1]},/
else
options << %Q/#{couple[0]}:"#{couple[1]}",/
Expand Down