Skip to content

Instantly share code, notes, and snippets.

View EpokK's full-sized avatar

Richard EpokK

View GitHub Profile
@EpokK
EpokK / example.html
Created June 14, 2013 07:24
Subliminal JS
<html>
<head>
<script src="subliminal.js"></script>
<script type="application/javascript">
function init() {
addSubliminal(
[ 'subliminal', 'message', 'affecting', 'web', 'perception', 'subconscious',':)', '$' ],
defaultSubliminalParameters
@EpokK
EpokK / ngBlur.js
Last active December 18, 2015 13:09
Directives AngularJS : ngBlur
myApp.directive('ngBlur', function() {
return function( scope, elem, attrs ) {
elem.bind('blur', function() {
scope.$apply(attrs.ngBlur);
});
};
});
@EpokK
EpokK / ngInitFocus.js
Last active December 18, 2015 22:49
init focus directive angular js
angular.module('app', []).directive('ngInitFocus', function() {
var timer;
return function(scope, elm, attr) {
if (timer) clearTimeout(timer);
timer = setTimeout(function() {
elm.focus();
}, 0);
};
@EpokK
EpokK / ngPlaceholder.js
Last active December 19, 2015 02:38
Placeholder directive : ngPlaceholder (https://twitter.com/ririlepanda)
app.directive('ngPlaceholder', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attr, ctrl) {
var value;
var placehold = function () {
element.val(attr.placehold)
@EpokK
EpokK / ngEnter.js
Last active January 7, 2022 13:57
ngEnter directive if you can use submit form(https://twitter.com/ririlepanda)
app.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
@EpokK
EpokK / tooltip.js
Created July 3, 2013 07:05
A lightweight javascript tooltip
//
// ToolTip
//
// source: http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/
var tooltip = function () {
var id = 'tt';
var top = 3;
var left = 3;
var maxw = 300;
@EpokK
EpokK / example.html
Created July 8, 2013 09:35
focus-me directive
<button class="btn" ng-click="showForm=true; focusInput=true">show form and focus input</button>
<div ng-show="showForm">
<input type="text" focus-me="focusInput">
<button class="btn" ng-click="showForm=false">hide form</button>
</div>
@EpokK
EpokK / nav.html
Created July 16, 2013 10:54
Page navigation bar in AngularJS
<div class="well sidebar-nav" ng-app="navList">
<ul class="nav nav-list" ng-controller="navCtrl">
<li ng-class="navClass('home')"><a href='#/home'>Home</a></li>
<li ng-class="navClass('about')"><a href='#/about'>About Us</a></li>
<li ng-class="navClass('contact')"><a href='#/contact'>Contact Us</a></li>
</ul>
</div>
@EpokK
EpokK / ngRightClick.js
Created July 18, 2013 13:26
ngRightClick
app.directive('ngRightClick', function($parse) {
return function(scope, element, attrs) {
var fn = $parse(attrs.ngRightClick);
element.bind('contextmenu', function(event) {
scope.$apply(function() {
event.preventDefault();
fn(scope, {$event:event});
});
});
};
@EpokK
EpokK / ngDatePicker.js
Last active December 19, 2015 23:59
ng-datePicker
angular.module('myApp', []).directive('ngDatePicker', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, ctrl) {
element.datepicker({
changeYear: true,
changeMonth: true,
appendText: '(yyyy-mm-dd)',
dateFormat: 'yy-mm-dd',
onSelect: function(dateText, inst) {