- 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.| //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); |
| 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; |
| /** | |
| * 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', |
| /** | |
| * 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 |