Skip to content

Instantly share code, notes, and snippets.

View AlexandreBonneau's full-sized avatar

Alexandre AlexandreBonneau

  • Earth
View GitHub Profile
/**
* Return an array containing only the element 'key => value' that are duplicated in the original $array.
* Warning : the generated array DOES NOT respect the order of the original array.
* @param $array
*
* @return array
* @licence Copyright (C) 2015 Alexandre Bonneau
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@AlexandreBonneau
AlexandreBonneau / cdz-cancellable.js
Created October 18, 2016 02:24
Angular 1 directive that allows the user to cancel a text input change with 'Escape'
/**
* This directive allow the user to 'cancel' an input with the 'Esc' key.
* Basically this saves the input value on focus, and set it back to this 'old' value whenever the user hit 'Esc'.
* Additionally, if the input value did not change when the user hits 'Esc', then the whole input value is selected.
*
* @usage <element data-cdz-cancellable contenteditable></element>
*/
app.directive('cdzCancellable', function() {
return {
restrict: 'A',
@AlexandreBonneau
AlexandreBonneau / cdz-cancellable-vue.js
Created October 18, 2016 08:50
Vue 2 directive that allows the user to cancel a text input change with 'Escape' - Work in progress
directives: {
cdzCancellable: { //FIXME finish this
bind(el, bindings, vnode, oldVnode) {
console.log(`cdzCancellable attached!`, el, el.type, bindings, vnode, oldVnode); //DEBUG
if (el.type === 'radio' || el.type === 'checkbox') {
return;
}
let oldValue;
let isAutoNumericInput = false;
@AlexandreBonneau
AlexandreBonneau / CdzAutoNumeric.js
Created November 8, 2016 00:03
Directive cdz-auto-numeric : wrap an autoNumeric-managed input with Vue.js 2.0
//AutoNumeric 2 : https://rawgithub.com/BobKnothe/autoNumeric/master/autoNumeric-2.0/autoNumeric-2.0-BETA.js //FAIL
//AutoNumeric 1.9.46 : https://cdnjs.cloudflare.com/ajax/libs/autonumeric/1.9.46/autoNumeric.min.js //WORK
//Live example on http://codepen.io/AnotherLinuxUser/pen/VmwvOK
let cdzNumericDirective = {
//Known problems :
//Using __autoNumercic 2.0 BETA__, when using 2 inputs with the same v-model (or when one input updates the value of another, even with different v-models), when you enter a value in one input, both updates well, but when you focus on the second input, the initial value is shown (since the current autoNumeric 2.0 BETA keeps its own `rawValue`). You can solve this by using 1.9.46 for the time being.
bind(el, bindings, vnode, oldVnode) {
let jQueryElement = $(el);
@AlexandreBonneau
AlexandreBonneau / TODO.md
Last active April 20, 2017 20:24
This is the live TODO list for feature that could be part of autoNumeric v4. Any ideas? Contribute!

TODO list for autoNumeric v4

ES6 Conversion

  • Finish converting autoNumeric to an ES6 module :
/* 
 * The idea is to use the AutoNumeric :
 * - static methods to access default options and static functions,
 * - class to instantiate `AutoNumeric` elements.
@AlexandreBonneau
AlexandreBonneau / .npmignore
Created January 30, 2017 04:08
Proposed autoNumeric .npmignore
.DS_Store
node_modules/
# Logs
*.log
# Test files
test/e2e/reports
test/e2e/screenshots
@AlexandreBonneau
AlexandreBonneau / autoNumeric.min.js
Created October 21, 2017 18:59
Potential fix for autoNumeric issue #518
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AutoNumeric=t():e.AutoNumeric=t()}(this,function(){return function(e){function t(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",
@AlexandreBonneau
AlexandreBonneau / autoNumeric.min.js
Created October 22, 2017 11:30
Fixing autoNumeric issue #516
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AutoNumeric=t():e.AutoNumeric=t()}(this,function(){return function(e){function t(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,i){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}return Array.from(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",
@AlexandreBonneau
AlexandreBonneau / VAutonumeric.vue
Created February 15, 2018 00:51
A Vue.js component that 'vuetify' the vue-autonumeric one
<!--
v-autonumeric
@version 0.2.0
@date 2018-01-31 UTC 22:00
@author Alexandre Bonneau
@copyright 2018 © Alexandre Bonneau <[email protected]>
@summary A Vue.js component that 'vuetify' the vue-autonumeric one
@AlexandreBonneau
AlexandreBonneau / vueAutonum_package.json
Last active February 20, 2018 10:16
vue-autonumeric with webpack 2cf. pr #6
{
"name": "tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"es6-karma-jasmine-webpack-boilerplate": "^0.2.0",
"vue": "^2.5.4",
"vue-autonumeric": "^1.0.2"
},