Skip to content

Instantly share code, notes, and snippets.

@melihbuyuk
Created April 8, 2011 15:07
Show Gist options
  • Save melihbuyuk/910056 to your computer and use it in GitHub Desktop.
Save melihbuyuk/910056 to your computer and use it in GitHub Desktop.
Kendine Gore Duzenlersin
(function ($)
{
$.fn.select_skins = function (w)
{
return $(this).each(function (i) {
s = $(this);
if (!s.attr('multiple'))
{
s.wrap('<div class="cmf-skinned-selects"></div>');
c = s.parent();
c.children().before('<div class="cmf-skinned-texts"> </div>').each(function ()
{
if (this.selectedIndex >= 0) {
$(this).prev().text(this.options[this.selectedIndex].innerHTML);
}
});
c.width(s.outerWidth() - 2);
c.height(s.outerHeight() - 2);
c.css('background-color', s.css('background-color'));
c.css('color', s.css('color'));
c.css('font-size', s.css('font-size'));
c.css('font-family', s.css('font-family'));
c.css('font-style', s.css('font-style'));
c.css('position', 'relative');
s.css({
'opacity' : 0, 'position' : 'relative', 'z-index' : 1001
});
var t = c.children().prev();
t.height(c.outerHeight() - s.css('padding-top').replace(/px,*\)*/g, "") - s.css('padding-bottom').replace(/px,*\)*/g,
"") - t.css('padding-top').replace(/px,*\)*/g, "") - t.css('padding-bottom').replace(/px,*\)*/g,
"") - 2);
t.width(c.innerWidth() - s.css('padding-right').replace(/px,*\)*/g, "") - s.css('padding-left').replace(/px,*\)*/g,
"") - t.css('padding-right').replace(/px,*\)*/g, "") - t.css('padding-left').replace(/px,*\)*/g,
"") - c.innerHeight());
t.css(
{
'opacity' : 100, 'overflow' : 'hidden', 'position' : 'absolute', 'text-indent' : '0px',
'z-index' : 1, 'top' : 0, 'left' : 0
});
c.children().click(function ()
{
t.text((this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : ''));
});
c.children().change(function ()
{
t.text((this.options.length > 0 && this.selectedIndex >= 0 ? this.options[this.selectedIndex].innerHTML : ''));
});
}
});
}
$.fn.select_unskins = function (w)
{
return $(this).each(function (i) {
s = $(this);
if (!s.attr('multiple') && s.parent().hasClass('cmf-skinned-selects'))
{
s.siblings('.cmf-skinned-texts').remove();
s.css({
'opacity' : 100, 'z-index' : 0
}).unwrap();
}
});
}
}
(jQuery));
//////////Kullanimi....../////////
function melih_forms_select(){jQuery(".select-1, .select-2, .search-select").select_skin();}
///////////////css
select.select-1{ width:193px; height:23px; float:left; padding:0 0 0 6px; padding:6px 0 0 6px\9; border:1px solid #2e2e2e; background:#2e2e2e; margin:10px 0px 0px 0; *margin:11px 0 0 0; cursor:pointer; }
select.select-2{ width:165px; height:23px; float:left; /*padding:0 0 0 6px; padding:6px 0 0 6px\9;*/ border:1px solid #2e2e2e; background:#2e2e2e; /*margin:10px 0px 0px 0px; *margin:11px 0 0 0;*/ cursor:pointer; color: #9b9b9b;}
div.cmf-skinned-select{ background: url(../images/author_search_bg.png) no-repeat; border:1px solid #2e2e2e; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius:5px; float:left; }
div.cmf-skinned-select:hover{ }
div.cmf-skinned-text{ line-height: 23px; padding: 0 0 0 20px; font-size: 10px; color: #9b9b9b; font-family:Arial, Helvetica, sans-serif; font-style: normal; float:left; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment