Skip to content

Instantly share code, notes, and snippets.

View AbraaoAlves's full-sized avatar
☀️
stay positive

AbraaoAlves AbraaoAlves

☀️
stay positive
View GitHub Profile
@AbraaoAlves
AbraaoAlves / loadOptions and clearOptions
Created May 16, 2011 20:08
Method to insert options in select tag from json object.[update performance]
///<summary> Sample: </summary>
///<code>
/// $.getJson("url", function(data){
/// //data : [{Value:1, Text: 'value 1', Selected:false},{Value:2, Text: 'value 2', Selected: true}]
/// $("#mySelect").loadOptions(data);
/// });
/// or
/// $.getJson("url", function(data){
/// //data : [{id:1, name: 'value 1'},{id:2, name: 'value 2'}]
/// $("#mySelect").loadOptions(data, {value: 'id', text: 'name'});
@AbraaoAlves
AbraaoAlves / labelFadeInput
Created September 24, 2011 21:00
labelFadeInput is a plugin to show/hide message in input:text with title attribute. Message is set tough of title attribute
//demo: http://jsfiddle.net/uPvTm/8/
;(function($) {
$.labelFadeInput = function () {
///use to set labelFadeInput in All input's with title
///ex: <input type='text' title='Any text here' />, use $.labelFadeinput();
$('input:text[title]').each(function() {
setEvents.call(this);
});
@AbraaoAlves
AbraaoAlves / tip.js
Created September 26, 2011 00:40
Create tip message through title attribute, custom data atribute or none of these(cache message).
//demo: http://jsfiddle.net/AbraaoAlves/W7j4z/18/
//use this:
//$("input:first").tip();
//$("[data-tip]").tip({tipMsgAttr: 'data-tip'});
//$("p").tip('custom message');
(function($){
var $defaults = {
@AbraaoAlves
AbraaoAlves / contains-IgnoreAceents
Created October 7, 2011 15:24
Custom jQuery Selector to tag that contains text(ignore accents). It works equals :contains selector, but select all tags inpedendent of accents
(function($) {
var accent_map = {
'á':'a',
'à':'a',
'â':'a',
'å':'a',
'ä':'a',
@AbraaoAlves
AbraaoAlves / jqueryplugin
Created October 18, 2011 13:36 — forked from hvitorino/jqueryplugin
jquery plugin carregaSelects
(function ($) {
$.fn.carregaOptions = function(configs) {
var defaults = {
options : [],
template: function(val) {
return '<option value="{0}">{1}</option>'.format(val[0], val[1]);
}
};
return this.each(function(val) {
@AbraaoAlves
AbraaoAlves / example.JS
Created November 8, 2011 17:43
Simple example of inheritance, overwrite and override with only native javascript resources. Obs: This example use javascript 1.8.5 especification.
function A(){} /* constructor */
A.prototype = { /* especification of prop and methods of the class A */
num : 5,
name : 'test',
action : function(){ /*base implementation*/},
alert
};
function B(){ /* constructor */
@AbraaoAlves
AbraaoAlves / RequestJson.as
Created November 11, 2011 16:54
Class to work with RequestJson in actionScript
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class RequestJson extends Sprite {
private var loader:URLLoader;
private var request:URLRequest;
private var _completeHandler:Function;
@AbraaoAlves
AbraaoAlves / gist:1529492
Created December 28, 2011 20:10
jQuery parentN
$.fn.parentN = function(n){
var result = this;
for(var i = 0; i< n; i++)
result = result.parent();
return result;
};
@AbraaoAlves
AbraaoAlves / GitForPS1.ps1
Created February 9, 2012 12:52
Git for power shell
#Com git instalado, via powershell:
#antes de executar o ps1: Set-ExecutionPolicy Unrestricted | responder S
if(!$env:path.Contains("C:\Program Files (x86)\Git\bin"))
{
$env:path += ";C:\Program Files (x86)\Git\bin";
}
if(!$env:path.Contains("C:\Program Files (x86)\Git\cmd"))
{
@AbraaoAlves
AbraaoAlves / gist:2398698
Created April 16, 2012 13:15
bind convention to textarea
'.field[data-col]:not(.dlk-field) textarea': function(data, el) {
return { text: data[el.parentNode.getAttribute('data-col')] };
}