[refs #195] Fix radio and checkboxes script. Fix project edit and new form

This commit is contained in:
konstantin.grabar 2012-02-28 23:11:08 +04:00
parent e9ae923b60
commit fa69cd8ee4
4 changed files with 113 additions and 147 deletions

View File

@ -1,38 +1,32 @@
function changeCheck(el)
function changeCheck(el) {
var el = el, input = el.find('input[type="checkbox"]');
{
var el = el,
input = el.getElementsByTagName("input")[0];
if(input.checked)
{
el.style.backgroundPosition="0 0";
input.checked=false;
}
else
{
el.style.backgroundPosition="0 -18px";
input.checked=true;
}
return true;
}
function startChangeCheck(el)
if(input.attr("checked")) {
el.css('backgroundPosition', '0 0');
input.removeAttr('checked');
} else {
el.css('backgroundPosition', '0 -18px');
input.attr('checked', true);
}
{
var el = el,
input = el.getElementsByTagName("input")[0];
if(input.checked)
{
el.style.backgroundPosition="0 -18px";
}
return true;
return true;
}
function startCheck()
{
function startChangeCheck(el) {
var el = el, input = el.find('input[type="checkbox"]');
startChangeCheck(document.getElementById("niceCheckbox1"));
startChangeCheck(document.getElementById("niceCheckbox2"));
startChangeCheck(document.getElementById("niceCheckbox3"));
startChangeCheck(document.getElementById("niceCheckbox4"));
}
if(input.attr('checked')) {
el.css('backgroundPosition', '0 -18px');
}
return true;
}
$(document).ready(function(){
$('.niceCheck-main').each(function(i,el) {
startChangeCheck($(el));
});
$('.niceCheck-main').click(function() {
changeCheck($(this));
});
});

View File

@ -1,4 +1,6 @@
function changeCheck(el)
/*function changeCheck(el)
{
var el = el,
@ -32,4 +34,4 @@ function startCheck()
{
startChangeCheck(document.getElementById("niceCheckbox1"));
}
}*/

View File

@ -1,116 +1,96 @@
jQuery(document).ready(function(){
jQuery(".niceRadio").each(
function() {
changeRadioStart(jQuery(this));
$(document).ready(function(){
$(".niceRadio").each(function() {
changeRadioStart($(this));
});
});
function changeRadio(el) {
var el = el, input = el.find("input").eq(0);
var nm = input.attr("name");
});
$(".niceRadio input").each(
function() {
if($(this).attr("name")==nm) {
$(this).parent().removeClass("radioChecked");
}
});
function changeRadio(el)
if(el.attr("class").indexOf("niceRadioDisabled")==-1) {
el.addClass("radioChecked");
input.attr("checked", true);
}
{
var el = el,
input = el.find("input").eq(0);
var nm=input.attr("name");
jQuery(".niceRadio input").each(
function() {
if(jQuery(this).attr("name")==nm)
{
jQuery(this).parent().removeClass("radioChecked");
}
});
if(el.attr("class").indexOf("niceRadioDisabled")==-1)
{
el.addClass("radioChecked");
input.attr("checked", true);
}
return true;
return true;
}
function changeVisualRadio(input)
{
function changeVisualRadio(input) {
var wrapInput = input.parent();
var nm=input.attr("name");
jQuery(".niceRadio input").each(
function() {
if(jQuery(this).attr("name")==nm)
{
jQuery(this).parent().removeClass("radioChecked");
}
});
var wrapInput = input.parent();
var nm=input.attr("name");
if(input.attr("checked"))
{
wrapInput.addClass("radioChecked");
}
$(".niceRadio input").each(function() {
if($(this).attr("name")==nm)
{
$(this).parent().removeClass("radioChecked");
}
});
if(input.attr("checked"))
{
wrapInput.addClass("radioChecked");
}
}
function changeRadioStart(el)
function changeRadioStart(el) {
{
try {
var el = el,
radioName = el.attr("name"),
radioId = el.attr("id"),
radioChecked = el.attr("checked"),
radioDisabled = el.attr("disabled"),
radioTab = el.attr("tabindex"),
radioValue = el.attr("value");
try
{
var el = el,
radioName = el.attr("name"),
radioId = el.attr("id"),
radioChecked = el.attr("checked"),
radioDisabled = el.attr("disabled"),
radioTab = el.attr("tabindex"),
radioValue = el.attr("value");
if(radioChecked)
el.after("<span class='niceRadio radioChecked'>"+
"<input type='radio'"+
"name='"+radioName+"'"+
"id='"+radioId+"'"+
"checked='"+radioChecked+"'"+
"tabindex='"+radioTab+"'"+
"value='"+radioValue+"' /></span>");
else
el.after("<span class='niceRadio'>"+
"<input type='radio'"+
"name='"+radioName+"'"+
"id='"+radioId+"'"+
"tabindex='"+radioTab+"'"+
"value='"+radioValue+"' /></span>");
if(radioChecked) {
el.after("<span class='niceRadio radioChecked'>"+
"<input type='radio'"+
"name='"+radioName+"'"+
"id='"+radioId+"'"+
"checked='"+radioChecked+"'"+
"tabindex='"+radioTab+"'"+
"value='"+radioValue+"' /></span>");
} else {
el.after("<span class='niceRadio'>"+
"<input type='radio'"+
"name='"+radioName+"'"+
"id='"+radioId+"'"+
"tabindex='"+radioTab+"'"+
"value='"+radioValue+"' /></span>");
}
if(radioDisabled)
{
el.next().addClass("niceRadioDisabled");
el.next().find("input").eq(0).attr("disabled","disabled");
}
if(radioDisabled) {
el.next().addClass("niceRadioDisabled");
el.next().find("input").eq(0).attr("disabled","disabled");
}
el.next().bind("mousedown", function(e) { changeRadio(jQuery(this)) });
if(jQuery.browser.msie) el.next().find("input").eq(0).bind("click", function(e) { changeVisualRadio(jQuery(this)) });
else el.next().find("input").eq(0).bind("change", function(e) { changeVisualRadio(jQuery(this)) });
el.remove();
}
catch(e)
{
}
return true;
el.next().bind("mousedown", function(e) {
changeRadio($(this))
});
if($.browser.msie) {
el.next().find("input").eq(0).bind("click", function(e) {
changeVisualRadio($(this))
});
} else {
el.next().find("input").eq(0).bind("change", function(e) {
changeVisualRadio($(this))
});
}
el.remove();
}
catch(e) { }
return true;
}

View File

@ -32,8 +32,7 @@
.rightlist
=# f.select :visibility, Project::VISIBILITIES
- Project::VISIBILITIES.each do |visibility|
%span.niceRadio.radioChecked
= f.radio_button :visibility, visibility, :class => 'niceRadio'
= f.radio_button :visibility, visibility, :class => 'niceRadio'
- if visibility == 'open'
= image_tag("unlock.png")
- else
@ -45,16 +44,6 @@
Ветка по умолчанию:
.rightlist
= f.select :default_branch, options_from_collection_for_select(@project.branches, :name, :name, @project.default_branch), :class => 'sel80', :id => 'branch_selector'
-#.lineForm
-# #cuselFrame-ext.cusel.sel80{:style => "width:200px", :tabindex => "2"}
-# .cuselFrameRight
-# .cuselText Master
-# .cusel-scroll-wrap{:style => "display: none; visibility: visible; "}
-# #cusel-scroll-ext.cusel-scroll-pane
-# %span.cuselActive{:selected => "selected", :val => "1000"} Master
-# %span{:val => "1"} Extend
-# %span{:val => "2"} Fork4Driver
-# %input#ext{:name => "ext", :type => "hidden", :value => "1000"}/
.both
- if [:edit, :update].include? act
.leftlist
@ -63,7 +52,8 @@
.check
-#%span#niceCheckbox1.niceCheck-main{:onclick => "changeCheck(this)"}
-# %input{:name => "ch1", :type => "checkbox"}/
= f.check_box :is_rpm, :class => 'niceCheck-main'
%span#niceCheckbox1.niceCheck-main
= f.check_box :is_rpm#, :class => 'niceCheckbox1'
.forcheck
Проект является пакетом
.both