Skip to content

Instantly share code, notes, and snippets.

View orhanveli's full-sized avatar

orhan orhanveli

  • Finbyte GmbH
  • Turkiye
  • 02:53 (UTC +03:00)
View GitHub Profile
@orhanveli
orhanveli / asp-net-check-all.js
Created November 14, 2011 20:43
asp:checkbox check all checkboxes using jQuery
// Checks all individual checkboxes
$(".checkAreaAll").children("input").click(function () {
$(".checkArea").children("input").attr('checked', $(".checkAreaAll").children("input").is(':checked'));
});
// unchecks the check all checkbox when one individual checkbox is unchecked
$(".checkArea").children("input").click(function () {
@orhanveli
orhanveli / jquery-checkall.js
Created November 14, 2011 20:47
check/uncheck all checkboxes with jquery
$('.checkall').click(function () {
$(this).parents('fieldset:eq(0)').find('.check:checkbox').attr('checked', this.checked);
});
@orhanveli
orhanveli / string-format.js
Created November 14, 2011 20:50
c# like string.format() function for JavaScript
String.prototype.format = function () {
var s = this,
i = arguments.length;
while (i--) {
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
}
return s;
};
//useage
@orhanveli
orhanveli / jquery-smooth-scroll.js
Created November 14, 2011 20:52
Smooth Scrolling with jQuery and internal page links
$(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
@orhanveli
orhanveli / asp-net-js-date-formater.js
Created November 14, 2011 20:56
Formatting ASP.NET [Webmethods] seriliazed DateTime objects on javascript side
(function ($) {
$.dateNet = function (date) {
if (date === null || date === undefined) return null;
if (/\/Date\([0-9\+]*\)\//.test(date))
return eval('new ' + date.split('/')[1]);
return '/Date(' + date.getTime() + ')/';
};
})(jQuery);
@orhanveli
orhanveli / jquery.formHints.js
Created November 14, 2011 20:58
jQuery info hints for text inputs (clear on focus, restore on blur if not changed)
(function ($) {
// HINTS FOR FORM INPUTS PLUG IN
$.fn.clearDefault = function () {
return this.each(function () {
var $this = $(this);
var default_value = $this.attr('title');
$this.val(default_value);
var id = $this.attr('id');
@orhanveli
orhanveli / jquery-opac-links.js
Created November 14, 2011 21:00
opac link elements and hover efect
@orhanveli
orhanveli / guid.cs
Created November 20, 2011 09:12
fluent nhiberante guid mapping
public TagMap()
{
Table("general_tags");
#region EntityBase
//Id(x => x.Id, "tagId").GeneratedBy.HiLo("nhibernate_hilo", "tag_NextHi", "5");
Id(x => x.Id, "tagId").GeneratedBy.Guid();
Map(x => x.IsDeleted, "isDeleted").CustomType(typeof(bool));
#endregion
@orhanveli
orhanveli / helpers.cs
Created November 20, 2011 09:55
ASP.NET MVC custom html helpers
namespace MyCMS.Helpers
{
public static class Html
{
public static MvcHtmlString DescriptionFor<TModel, TValue>(
this HtmlHelper<TModel> self,
Expression<Func<TModel, TValue>> expression)
{
var metadata = ModelMetadata.FromLambdaExpression(expression, self.ViewData);
var description = Localizer.Translate(metadata.Description);
@orhanveli
orhanveli / join.cs
Created November 20, 2011 12:52
c# joining array with comma
string[] ids = {"2343","2344","2345"};
string idString = String.Join(",",ids);