ende 0.3.13 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/component.json +7 -0
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +2 -2
- data/lib/assets/javascripts/aura/extensions/loader.js.coffee +13 -11
- data/lib/assets/javascripts/aura/extensions/mask.js.coffee +54 -40
- data/lib/assets/javascripts/aura/extensions/mediator.js +5 -3
- data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +2 -2
- data/lib/assets/javascripts/aura/extensions/rivets/accounting.js.coffee +7 -1
- data/lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee +5 -1
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +47 -29
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +10 -5
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +2 -2
- data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +18 -19
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +15 -10
- data/lib/assets/javascripts/config/initializers/jquery.js.coffee +2 -1
- data/lib/assets/javascripts/config/initializers/requirejs.js.coffee +3 -4
- data/lib/assets/javascripts/config/initializers.js.coffee +3 -0
- data/lib/assets/javascripts/config/load_components.js.coffee +106 -83
- data/lib/assets/javascripts/ende.js.coffee +13 -4
- data/lib/assets/javascripts/widgets/authenticator/presenter.js.coffee +3 -2
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +7 -3
- data/lib/assets/javascripts/widgets/support/main.js.coffee +3 -4
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +35 -103
- data/lib/assets/javascripts/widgets/viewer/presenters/default.js.coffee +2 -4
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/build.js +30877 -0
- data/vendor/assets/components/ende_build.js +2487 -148
- data/vendor/assets/components/indemma_with_none.js +30553 -0
- data/vendor/assets/javascripts/spin/spin.js +349 -0
- data/vendor/components/indefinido-indemma/.gitignore +3 -0
- data/vendor/components/indefinido-indemma/.ruby-gemset +1 -1
- data/vendor/components/indefinido-indemma/.ruby-version +1 -1
- data/vendor/components/indefinido-indemma/build/development.js +17 -14
- data/vendor/components/indefinido-indemma/build/release.js +213 -148
- data/vendor/components/indefinido-indemma/build/test.js +213 -148
- data/vendor/components/indefinido-indemma/component.json +3 -1
- data/vendor/components/indefinido-indemma/karma.conf.js +50 -60
- data/vendor/components/indefinido-indemma/lib/record/associable.js +17 -17
- data/vendor/components/indefinido-indemma/lib/record/persistable.js +8 -1
- data/vendor/components/indefinido-indemma/lib/record/queryable.js +3 -0
- data/vendor/components/indefinido-indemma/lib/record/resource.js +25 -45
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +82 -28
- data/vendor/components/indefinido-indemma/lib/record/scopable.js +28 -2
- data/vendor/components/indefinido-indemma/lib/record/storable.js +1 -1
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +15 -23
- data/vendor/components/indefinido-indemma/lib/record/validations/associated.js +3 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/confirmation.js +3 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/cpf.js +5 -7
- data/vendor/components/indefinido-indemma/lib/record/validations/presence.js +3 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/remote.js +3 -7
- data/vendor/components/indefinido-indemma/lib/record/validations/type.js +2 -2
- data/vendor/components/indefinido-indemma/lib/record/validations/validatorable.js +12 -0
- data/vendor/components/indefinido-indemma/package.json +9 -0
- data/vendor/components/indefinido-indemma/spec/record/restfulable_spec.js +12 -0
- data/vendor/components/indefinido-indemma/spec/record/validatable_spec.js +4 -4
- data/vendor/components/indefinido-indemma/spec/record/validations/associated_spec.js +2 -2
- data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +44 -20
- data/vendor/components/indefinido-indemma/src/lib/record/persistable.coffee +7 -2
- data/vendor/components/indefinido-indemma/src/lib/record/queryable.coffee +1 -0
- data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +32 -32
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +79 -22
- data/vendor/components/indefinido-indemma/src/lib/record/scopable.coffee +27 -8
- data/vendor/components/indefinido-indemma/src/lib/record/storable.coffee +1 -1
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +20 -19
- data/vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee +3 -5
- data/vendor/components/indefinido-indemma/src/lib/record/validations/confirmation.coffee +2 -4
- data/vendor/components/indefinido-indemma/src/lib/record/validations/cpf.coffee +4 -5
- data/vendor/components/indefinido-indemma/src/lib/record/validations/presence.coffee +2 -5
- data/vendor/components/indefinido-indemma/src/lib/record/validations/remote.coffee +3 -7
- data/vendor/components/indefinido-indemma/src/lib/record/validations/type.coffee +2 -3
- data/vendor/components/indefinido-indemma/src/lib/record/validations/validatorable.coffee +5 -0
- data/vendor/components/indefinido-indemma/src/spec/record/restfulable_spec.coffee +8 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validatable_spec.coffee +4 -4
- data/vendor/components/indefinido-indemma/src/spec/record/validations/associated_spec.coffee +2 -2
- metadata +9 -3
- data/lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee~ +0 -0
@@ -18625,26 +18625,22 @@ singular = {
|
|
18625
18625
|
subscribers = {
|
18626
18626
|
belongs_to: {
|
18627
18627
|
foreign_key: function(resource_id) {
|
18628
|
-
var
|
18628
|
+
var association_name, current_resource_id, resource, _ref;
|
18629
18629
|
|
18630
18630
|
association_name = this.resource.toString();
|
18631
|
-
if (resource_id
|
18631
|
+
if (!resource_id) {
|
18632
18632
|
this.dirty = true;
|
18633
18633
|
this.owner[association_name] = resource_id;
|
18634
18634
|
return resource_id;
|
18635
18635
|
}
|
18636
|
-
current_resource_id = (_ref = this.owner[association_name]) != null ? _ref._id : void 0;
|
18636
|
+
current_resource_id = (_ref = this.owner.observed[association_name]) != null ? _ref._id : void 0;
|
18637
18637
|
if (resource_id !== current_resource_id) {
|
18638
18638
|
resource = model[association_name];
|
18639
18639
|
if (!resource) {
|
18640
18640
|
console.warn("subscribers.belongs_to.foreign_key: associated factory not found for model: " + association_name);
|
18641
18641
|
return resource_id;
|
18642
18642
|
}
|
18643
|
-
|
18644
|
-
associated || (associated = resource({
|
18645
|
-
_id: resource_id
|
18646
|
-
}));
|
18647
|
-
this.owner.observed[association_name] = associated;
|
18643
|
+
this.owner.observed[association_name] = null;
|
18648
18644
|
}
|
18649
18645
|
return resource_id;
|
18650
18646
|
},
|
@@ -18682,10 +18678,12 @@ modifiers = {
|
|
18682
18678
|
return associated;
|
18683
18679
|
}
|
18684
18680
|
associated = resource.find(associated_id || associated._id);
|
18681
|
+
if (associated) {
|
18682
|
+
return _this.owner.observed[association_name] = associated;
|
18683
|
+
}
|
18685
18684
|
associated || (associated = resource({
|
18686
18685
|
_id: associated_id
|
18687
18686
|
}));
|
18688
|
-
resource.storage.store(associated._id, associated);
|
18689
18687
|
associated.reload();
|
18690
18688
|
return _this.owner.observed[association_name] = associated;
|
18691
18689
|
},
|
@@ -18707,8 +18705,8 @@ callbacks = {
|
|
18707
18705
|
for (_i = 0, _len = association_names.length; _i < _len; _i++) {
|
18708
18706
|
association_name = association_names[_i];
|
18709
18707
|
associations_attributes = this["" + association_name + "_attributes"];
|
18708
|
+
association = this[model.pluralize(association_name)];
|
18710
18709
|
if (associations_attributes && associations_attributes.length) {
|
18711
|
-
association = this[model.pluralize(association_name)];
|
18712
18710
|
if (!association) {
|
18713
18711
|
message = "has_many.nest_attributes: Association not found for " + association_name + ". \n";
|
18714
18712
|
message += "did you set it on model declaration? \n has_many: " + association_name + " ";
|
@@ -18798,7 +18796,7 @@ associable = {
|
|
18798
18796
|
return true;
|
18799
18797
|
},
|
18800
18798
|
create_after_hooks: function(definition) {
|
18801
|
-
var association_name, association_proxy, old_resource_id, options, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
|
18799
|
+
var association_attributes, association_name, association_proxy, old_dirty, old_resource_id, options, resource, _i, _j, _k, _len, _len1, _len2, _name, _ref, _ref1, _ref2, _results;
|
18802
18800
|
|
18803
18801
|
options = model[this.resource.name || this.resource.toString()];
|
18804
18802
|
if (options.has_many) {
|
@@ -18811,6 +18809,11 @@ associable = {
|
|
18811
18809
|
parent: this
|
18812
18810
|
};
|
18813
18811
|
association_name = model.pluralize(resource);
|
18812
|
+
association_attributes = this[association_name] || [];
|
18813
|
+
this[_name = "" + association_name + "_attributes"] || (this[_name] = []);
|
18814
|
+
if (association_attributes.length) {
|
18815
|
+
this["" + association_name + "_attributes"] = this["" + association_name + "_attributes"].concat(association_attributes);
|
18816
|
+
}
|
18814
18817
|
this[association_name] = $.extend(association_proxy, plural);
|
18815
18818
|
}
|
18816
18819
|
this.after('saved', callbacks.has_many.update_association);
|
@@ -18846,15 +18849,12 @@ associable = {
|
|
18846
18849
|
this["build_" + resource] = $.proxy(singular.build, association_proxy);
|
18847
18850
|
this["create_" + resource] = $.proxy(singular.create, association_proxy);
|
18848
18851
|
old_resource_id = this["" + resource + "_id"];
|
18852
|
+
old_dirty = this.dirty;
|
18849
18853
|
this["" + resource + "_id"] = null;
|
18850
18854
|
this.subscribe("" + resource + "_id", $.proxy(subscribers.belongs_to.foreign_key, association_proxy));
|
18851
18855
|
this.subscribe(resource.toString(), $.proxy(subscribers.belongs_to.associated_changed, association_proxy));
|
18852
|
-
this
|
18853
|
-
|
18854
|
-
_results.push(this.publish("" + resource + "_id", this["" + resource + "_id"]));
|
18855
|
-
} else {
|
18856
|
-
_results.push(void 0);
|
18857
|
-
}
|
18856
|
+
this["" + resource + "_id"] = old_resource_id;
|
18857
|
+
_results.push(this.dirty = old_dirty);
|
18858
18858
|
}
|
18859
18859
|
return _results;
|
18860
18860
|
}
|
@@ -18929,7 +18929,14 @@ handlers = {
|
|
18929
18929
|
persistable = {
|
18930
18930
|
record: {
|
18931
18931
|
after_initialize: function() {
|
18932
|
-
|
18932
|
+
var storage;
|
18933
|
+
|
18934
|
+
if (this._id) {
|
18935
|
+
storage = model[this.resource.toString()].storage;
|
18936
|
+
return storage.store(this._id, this);
|
18937
|
+
} else {
|
18938
|
+
return this.after('saved', handlers.store_after_saved);
|
18939
|
+
}
|
18933
18940
|
}
|
18934
18941
|
}
|
18935
18942
|
};
|
@@ -18971,7 +18978,7 @@ storable = stampit({
|
|
18971
18978
|
return collection[key];
|
18972
18979
|
} else {
|
18973
18980
|
this.writes++;
|
18974
|
-
value.sustained = true;
|
18981
|
+
value.sustained || (value.sustained = true);
|
18975
18982
|
return collection[key] = value;
|
18976
18983
|
}
|
18977
18984
|
},
|
@@ -19008,6 +19015,9 @@ stampit = require('../../vendor/stampit');
|
|
19008
19015
|
queryable = {
|
19009
19016
|
storage: storable(),
|
19010
19017
|
find: function(key) {
|
19018
|
+
if (!key) {
|
19019
|
+
throw new TypeError("InvalidFind: resource.find was called with a falsey value");
|
19020
|
+
}
|
19011
19021
|
return this.storage.store(key);
|
19012
19022
|
},
|
19013
19023
|
all: function() {
|
@@ -19032,7 +19042,7 @@ model.mix(function(modelable) {
|
|
19032
19042
|
|
19033
19043
|
});
|
19034
19044
|
require.register("indefinido-indemma/lib/record/resource.js", function(exports, require, module){
|
19035
|
-
var model, resource, resourceable, stampit;
|
19045
|
+
var descriptors, model, resource, resourceable, stampit;
|
19036
19046
|
|
19037
19047
|
stampit = require('../../vendor/stampit');
|
19038
19048
|
|
@@ -19059,34 +19069,11 @@ resource = stampit({
|
|
19059
19069
|
return this;
|
19060
19070
|
});
|
19061
19071
|
|
19062
|
-
|
19063
|
-
pluralize: function(word, count, plural) {
|
19064
|
-
if (!(word && word.length)) {
|
19065
|
-
throw new TypeError("Invalid string passed to pluralize '" + word + "'");
|
19066
|
-
}
|
19067
|
-
if (word.indexOf('s') !== word.length - 1) {
|
19068
|
-
return owl.pluralize(word, count, plural);
|
19069
|
-
} else {
|
19070
|
-
return word;
|
19071
|
-
}
|
19072
|
-
},
|
19073
|
-
singularize: function(word) {
|
19074
|
-
if (!(word && word.length)) {
|
19075
|
-
throw new TypeError("Invalid string passed to singularize '" + word + "'");
|
19076
|
-
}
|
19077
|
-
if (word.lastIndexOf('s') === word.length - 1) {
|
19078
|
-
return word.substring(0, word.length - 1);
|
19079
|
-
} else {
|
19080
|
-
return word;
|
19081
|
-
}
|
19082
|
-
},
|
19072
|
+
descriptors = {
|
19083
19073
|
route: {
|
19084
19074
|
get: function() {
|
19085
19075
|
var route;
|
19086
19076
|
|
19087
|
-
if (this.initial_route != null) {
|
19088
|
-
return this.initial_route;
|
19089
|
-
}
|
19090
19077
|
if (typeof this.resource === 'string') {
|
19091
19078
|
this.resource = {
|
19092
19079
|
name: this.resource
|
@@ -19100,33 +19087,36 @@ resourceable = {
|
|
19100
19087
|
route += this.resource.scope + '/';
|
19101
19088
|
}
|
19102
19089
|
route += this.resource.singular ? this.resource.name : model.pluralize(this.resource.name);
|
19103
|
-
this.
|
19104
|
-
return route;
|
19090
|
+
return this.route = route;
|
19105
19091
|
},
|
19106
|
-
|
19107
|
-
|
19092
|
+
configurable: true
|
19093
|
+
}
|
19094
|
+
};
|
19095
|
+
|
19096
|
+
resourceable = {
|
19097
|
+
pluralize: function(word, count, plural) {
|
19098
|
+
if (!(word && word.length)) {
|
19099
|
+
throw new TypeError("Invalid string passed to pluralize '" + word + "'");
|
19100
|
+
}
|
19101
|
+
if (word.indexOf('s') !== word.length - 1) {
|
19102
|
+
return owl.pluralize(word, count, plural);
|
19103
|
+
} else {
|
19104
|
+
return word;
|
19108
19105
|
}
|
19109
19106
|
},
|
19110
|
-
|
19111
|
-
|
19112
|
-
|
19113
|
-
|
19114
|
-
|
19115
|
-
|
19116
|
-
|
19117
|
-
return
|
19107
|
+
singularize: function(word) {
|
19108
|
+
if (!(word && word.length)) {
|
19109
|
+
throw new TypeError("Invalid string passed to singularize '" + word + "'");
|
19110
|
+
}
|
19111
|
+
if (word.lastIndexOf('s') === word.length - 1) {
|
19112
|
+
return word.substring(0, word.length - 1);
|
19113
|
+
} else {
|
19114
|
+
return word;
|
19118
19115
|
}
|
19119
19116
|
},
|
19120
19117
|
initialize: function() {
|
19121
19118
|
var resource_definition, _ref;
|
19122
19119
|
|
19123
|
-
if (this.parent_resource) {
|
19124
|
-
Object.defineProperty(this, "" + this.parent_resource + "_id", {
|
19125
|
-
value: resourceable.parent_id,
|
19126
|
-
configurable: true,
|
19127
|
-
enumerable: true
|
19128
|
-
});
|
19129
|
-
}
|
19130
19120
|
resource_definition = {};
|
19131
19121
|
if (typeof this.resource === 'string') {
|
19132
19122
|
resource_definition = {
|
@@ -19139,7 +19129,7 @@ resourceable = {
|
|
19139
19129
|
}
|
19140
19130
|
resource_definition.parent = this.parent_resource;
|
19141
19131
|
this.resource = resource(resource_definition);
|
19142
|
-
return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route',
|
19132
|
+
return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route', descriptors.route);
|
19143
19133
|
}
|
19144
19134
|
};
|
19145
19135
|
|
@@ -19198,7 +19188,7 @@ request = function(method, url, data) {
|
|
19198
19188
|
|
19199
19189
|
});
|
19200
19190
|
require.register("indefinido-indemma/lib/record/restfulable.js", function(exports, require, module){
|
19201
|
-
var $, merge, model, observable, record, rest, restful, type, util,
|
19191
|
+
var $, merge, model, observable, record, rest, restful, root, type, util,
|
19202
19192
|
__slice = [].slice;
|
19203
19193
|
|
19204
19194
|
merge = require('assimilate').withStrategy('deep');
|
@@ -19211,15 +19201,17 @@ $ = require('jquery');
|
|
19211
19201
|
|
19212
19202
|
rest = require('./rest.js');
|
19213
19203
|
|
19204
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
19205
|
+
|
19214
19206
|
util = {
|
19215
19207
|
model: {
|
19216
|
-
map: function(
|
19217
|
-
var
|
19208
|
+
map: function(records) {
|
19209
|
+
var record, _i, _len, _results;
|
19218
19210
|
|
19219
19211
|
_results = [];
|
19220
|
-
for (_i = 0, _len =
|
19221
|
-
|
19222
|
-
_results.push(this(
|
19212
|
+
for (_i = 0, _len = records.length; _i < _len; _i++) {
|
19213
|
+
record = records[_i];
|
19214
|
+
_results.push(this(record));
|
19223
19215
|
}
|
19224
19216
|
return _results;
|
19225
19217
|
}
|
@@ -19251,15 +19243,15 @@ restful = {
|
|
19251
19243
|
}
|
19252
19244
|
return $.when.apply($, savings);
|
19253
19245
|
},
|
19254
|
-
all: function(conditions,
|
19246
|
+
all: function(conditions, doned, failed) {
|
19255
19247
|
if (conditions == null) {
|
19256
19248
|
conditions = {};
|
19257
19249
|
}
|
19258
19250
|
if (typeof conditions === 'function') {
|
19259
|
-
|
19251
|
+
doned = conditions;
|
19260
19252
|
conditions = {};
|
19261
19253
|
}
|
19262
|
-
return $.when(rest.get.call(this, conditions)).then(util.model.map).done(
|
19254
|
+
return $.when(rest.get.call(this, conditions)).then(util.model.map).done(doned).fail(failed);
|
19263
19255
|
},
|
19264
19256
|
first: function(conditions, callback) {
|
19265
19257
|
var namespaced;
|
@@ -19277,15 +19269,21 @@ restful = {
|
|
19277
19269
|
return this.all(conditions, callback);
|
19278
19270
|
},
|
19279
19271
|
get: function(action, data) {
|
19280
|
-
var old_route, payload, promise, resource
|
19272
|
+
var default_route, old_route, payload, promise, resource;
|
19281
19273
|
|
19282
19274
|
if (data == null) {
|
19283
19275
|
data = {};
|
19284
19276
|
}
|
19285
19277
|
old_route = this.route;
|
19286
|
-
|
19278
|
+
default_route = "/" + (model.pluralize(this.resource.name));
|
19279
|
+
if (default_route !== this.route) {
|
19280
|
+
this.route = default_route;
|
19281
|
+
}
|
19287
19282
|
if (action) {
|
19288
|
-
this
|
19283
|
+
Object.defineProperty(this, 'route', {
|
19284
|
+
value: "" + default_route + "/" + action,
|
19285
|
+
configurable: true
|
19286
|
+
});
|
19289
19287
|
}
|
19290
19288
|
resource = data.resource;
|
19291
19289
|
if (data && data.json) {
|
@@ -19297,13 +19295,19 @@ restful = {
|
|
19297
19295
|
data[resource] = payload;
|
19298
19296
|
}
|
19299
19297
|
promise = rest.get.call(this, data);
|
19300
|
-
route
|
19298
|
+
Object.defineProperty(this, 'route', {
|
19299
|
+
value: old_route,
|
19300
|
+
configurable: true
|
19301
|
+
});
|
19301
19302
|
return promise;
|
19302
19303
|
},
|
19303
19304
|
put: rest.put,
|
19304
19305
|
"delete": rest["delete"]
|
19305
19306
|
},
|
19306
19307
|
record: {
|
19308
|
+
ready: function(callback) {
|
19309
|
+
return callback.call(this);
|
19310
|
+
},
|
19307
19311
|
reload: function() {
|
19308
19312
|
var data, param, params, promise, _i, _len;
|
19309
19313
|
|
@@ -19315,6 +19319,11 @@ restful = {
|
|
19315
19319
|
promise = rest.get.call(this, data || {});
|
19316
19320
|
promise.done(this.assign_attributes);
|
19317
19321
|
promise.fail(this.failed);
|
19322
|
+
this.reloading = promise;
|
19323
|
+
this.ready = function() {
|
19324
|
+
console.warn("resource.ready was deprecated, please use resource.reloading.done");
|
19325
|
+
return promise.done.apply(promise, arguments);
|
19326
|
+
};
|
19318
19327
|
for (_i = 0, _len = params.length; _i < _len; _i++) {
|
19319
19328
|
param = params[_i];
|
19320
19329
|
promise.done(param);
|
@@ -19322,7 +19331,7 @@ restful = {
|
|
19322
19331
|
return promise;
|
19323
19332
|
},
|
19324
19333
|
assign_attributes: function(attributes) {
|
19325
|
-
var association, association_attributes, association_name, associations_attributes, attribute, message, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
|
19334
|
+
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
|
19326
19335
|
|
19327
19336
|
_ref = model[this.resource.toString()].has_many;
|
19328
19337
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
@@ -19367,9 +19376,18 @@ restful = {
|
|
19367
19376
|
}
|
19368
19377
|
}
|
19369
19378
|
_results = [];
|
19370
|
-
for (
|
19371
|
-
|
19372
|
-
|
19379
|
+
for (name in attributes) {
|
19380
|
+
attribute = attributes[name];
|
19381
|
+
if (attribute !== this[name]) {
|
19382
|
+
if (type(attribute) === 'object') {
|
19383
|
+
if (JSON.stringify(attribute) !== JSON.stringify(this[name])) {
|
19384
|
+
_results.push(this[name] = attributes[name]);
|
19385
|
+
} else {
|
19386
|
+
_results.push(void 0);
|
19387
|
+
}
|
19388
|
+
} else {
|
19389
|
+
_results.push(this[name] = attributes[name]);
|
19390
|
+
}
|
19373
19391
|
}
|
19374
19392
|
}
|
19375
19393
|
return _results;
|
@@ -19390,18 +19408,23 @@ restful = {
|
|
19390
19408
|
saving: false,
|
19391
19409
|
salvation: null,
|
19392
19410
|
save: function(doned, failed, data) {
|
19393
|
-
var salvation;
|
19411
|
+
var lock, salvation;
|
19394
19412
|
|
19413
|
+
lock = JSON.stringify(this.json());
|
19395
19414
|
if (this.saving) {
|
19396
|
-
|
19415
|
+
if (this.lock === lock) {
|
19416
|
+
return this.salvation;
|
19417
|
+
} else {
|
19418
|
+
this.salvation.abort();
|
19419
|
+
}
|
19397
19420
|
}
|
19398
|
-
this.lock =
|
19421
|
+
this.lock = lock;
|
19399
19422
|
if (!this.dirty) {
|
19400
19423
|
salvation = $.Deferred().resolveWith(this, null);
|
19401
19424
|
}
|
19425
|
+
this.saving = true;
|
19402
19426
|
salvation || (salvation = rest[this._id ? 'put' : 'post'].call(this, data));
|
19403
19427
|
this.salvation = salvation;
|
19404
|
-
this.saving = true;
|
19405
19428
|
salvation.done(this.saved);
|
19406
19429
|
salvation.fail(this.failed);
|
19407
19430
|
salvation.always(function() {
|
@@ -19417,8 +19440,6 @@ restful = {
|
|
19417
19440
|
if (this.lock === JSON.stringify(this.json())) {
|
19418
19441
|
this.dirty = false;
|
19419
19442
|
delete this.lock;
|
19420
|
-
} else {
|
19421
|
-
return this.save();
|
19422
19443
|
}
|
19423
19444
|
if (data != null) {
|
19424
19445
|
this.assign_attributes(data);
|
@@ -19444,8 +19465,21 @@ restful = {
|
|
19444
19465
|
}
|
19445
19466
|
payload || (payload = xhr.responseText);
|
19446
19467
|
switch (xhr.status) {
|
19468
|
+
case 0:
|
19469
|
+
message = status || xhr.statusText;
|
19470
|
+
switch (message) {
|
19471
|
+
case 'abort':
|
19472
|
+
console.info("salvation probably aborted");
|
19473
|
+
break;
|
19474
|
+
case 'error':
|
19475
|
+
console.info("server probably unreachable");
|
19476
|
+
break;
|
19477
|
+
default:
|
19478
|
+
throw new Error('Unhandled status code for xhr');
|
19479
|
+
}
|
19480
|
+
break;
|
19447
19481
|
case 422:
|
19448
|
-
definition = model[this.resource];
|
19482
|
+
definition = model[this.resource.toString()];
|
19449
19483
|
_ref = payload.errors;
|
19450
19484
|
for (attribute_name in _ref) {
|
19451
19485
|
messages = _ref[attribute_name];
|
@@ -19470,8 +19504,9 @@ restful = {
|
|
19470
19504
|
default:
|
19471
19505
|
message = "Fail in " + this.resource + ".save:\n";
|
19472
19506
|
message += "Record: " + this + "\n";
|
19473
|
-
message += "Status: " + status + " (" + (payload
|
19507
|
+
message += "Status: " + status + " (" + (payload || xhr).status + ")\n";
|
19474
19508
|
message += "Error : " + (payload.error || payload.message || payload);
|
19509
|
+
console.log(message);
|
19475
19510
|
}
|
19476
19511
|
return this.saving = false;
|
19477
19512
|
},
|
@@ -19483,20 +19518,27 @@ restful = {
|
|
19483
19518
|
return JSON.stringify(serialized);
|
19484
19519
|
},
|
19485
19520
|
json: function(methods) {
|
19486
|
-
var attribute, json, name, value, _i, _len, _ref;
|
19521
|
+
var attribute, definition, json, name, value, _i, _len, _ref;
|
19487
19522
|
|
19488
19523
|
if (methods == null) {
|
19489
19524
|
methods = {};
|
19490
19525
|
}
|
19491
19526
|
json = {};
|
19527
|
+
definition = model[this.resource.toString()];
|
19492
19528
|
for (name in this) {
|
19493
|
-
value
|
19494
|
-
|
19529
|
+
if (!(type(value))) {
|
19530
|
+
continue;
|
19531
|
+
}
|
19532
|
+
if (definition.belongs_to.indexOf(name) !== -1 && this.nested_attributes.indexOf(name) === -1) {
|
19495
19533
|
continue;
|
19496
19534
|
}
|
19535
|
+
value = this[name];
|
19497
19536
|
if (value == null) {
|
19498
19537
|
continue;
|
19499
19538
|
}
|
19539
|
+
if (type(value) === 'function') {
|
19540
|
+
continue;
|
19541
|
+
}
|
19500
19542
|
if (type(value) === 'object') {
|
19501
19543
|
if (value.toJSON != null) {
|
19502
19544
|
json[name] = value.toJSON(methods[name]);
|
@@ -19522,6 +19564,8 @@ restful = {
|
|
19522
19564
|
delete json.before_initialize;
|
19523
19565
|
delete json.parent_resource;
|
19524
19566
|
delete json.nested_attributes;
|
19567
|
+
delete json.reloading;
|
19568
|
+
delete json.ready;
|
19525
19569
|
delete json.saving;
|
19526
19570
|
delete json.salvation;
|
19527
19571
|
delete json.sustained;
|
@@ -19568,7 +19612,7 @@ model.associable && model.associable.mix(function(singular_association, plural_a
|
|
19568
19612
|
|
19569
19613
|
});
|
19570
19614
|
require.register("indefinido-indemma/lib/record/scopable.js", function(exports, require, module){
|
19571
|
-
var $, builders, defaults, extend, merge, model, record, rest, scopable, stampit,
|
19615
|
+
var $, builders, defaults, extend, merge, model, observable, record, rest, scopable, stampit, util,
|
19572
19616
|
__slice = [].slice;
|
19573
19617
|
|
19574
19618
|
require('./restfulable');
|
@@ -19579,12 +19623,29 @@ stampit = require('../../vendor/stampit');
|
|
19579
19623
|
|
19580
19624
|
extend = require('assimilate');
|
19581
19625
|
|
19626
|
+
observable = require('observable').mixin;
|
19627
|
+
|
19582
19628
|
merge = extend.withStrategy('deep');
|
19583
19629
|
|
19584
19630
|
$ = require('jquery');
|
19585
19631
|
|
19586
19632
|
rest = require('./rest');
|
19587
19633
|
|
19634
|
+
util = {
|
19635
|
+
model: {
|
19636
|
+
map: function(records) {
|
19637
|
+
var index, record, _i, _len, _results;
|
19638
|
+
|
19639
|
+
_results = [];
|
19640
|
+
for (index = _i = 0, _len = records.length; _i < _len; index = ++_i) {
|
19641
|
+
record = records[index];
|
19642
|
+
_results.push((this.build || this).call(this, record));
|
19643
|
+
}
|
19644
|
+
return _results;
|
19645
|
+
}
|
19646
|
+
}
|
19647
|
+
};
|
19648
|
+
|
19588
19649
|
scopable = {
|
19589
19650
|
builder: stampit().enclose(function() {
|
19590
19651
|
return stampit.mixIn(function(name, type) {
|
@@ -19615,14 +19676,19 @@ scopable = {
|
|
19615
19676
|
fetch: function(data, done, fail) {
|
19616
19677
|
var deferred, scope;
|
19617
19678
|
|
19679
|
+
if (typeof data === 'function') {
|
19680
|
+
done = data;
|
19681
|
+
data = {};
|
19682
|
+
}
|
19618
19683
|
scope = extend({}, this.scope.data);
|
19684
|
+
observable.unobserve(scope);
|
19619
19685
|
if (scope.noned != null) {
|
19620
19686
|
deferred = $.Deferred();
|
19621
19687
|
deferred.resolveWith(this, [[]]);
|
19622
19688
|
} else {
|
19623
19689
|
deferred = rest.get.call(this, extend(scope, data));
|
19624
19690
|
}
|
19625
|
-
deferred.done(this.scope.then.concat(done)).fail(
|
19691
|
+
deferred.then(util.model.map).done(this.scope.then.concat([done])).fail(this.scope.fail.concat([fail]));
|
19626
19692
|
this.scope.clear();
|
19627
19693
|
return deferred;
|
19628
19694
|
},
|
@@ -19665,6 +19731,10 @@ scopable = {
|
|
19665
19731
|
return this;
|
19666
19732
|
},
|
19667
19733
|
fetch: function(data, done, fail) {
|
19734
|
+
if (typeof data === 'function') {
|
19735
|
+
done = data;
|
19736
|
+
data = null;
|
19737
|
+
}
|
19668
19738
|
return this.scope.fetch.call(this, data, done, fail);
|
19669
19739
|
},
|
19670
19740
|
forward_scopes_to_associations: function() {
|
@@ -19921,10 +19991,23 @@ model.mix(function(modelable) {
|
|
19921
19991
|
});
|
19922
19992
|
|
19923
19993
|
});
|
19924
|
-
require.register("indefinido-indemma/lib/record/validations/
|
19925
|
-
var
|
19994
|
+
require.register("indefinido-indemma/lib/record/validations/validatorable.js", function(exports, require, module){
|
19995
|
+
var stampit;
|
19926
19996
|
|
19927
|
-
|
19997
|
+
stampit = require('../../../vendor/stampit');
|
19998
|
+
|
19999
|
+
module.exports = stampit({
|
20000
|
+
validate: function() {
|
20001
|
+
throw new Error('Composed factory must override the validate method');
|
20002
|
+
},
|
20003
|
+
validate_each: function() {
|
20004
|
+
throw new Error('Composed factory must override the validate each method');
|
20005
|
+
}
|
20006
|
+
});
|
20007
|
+
|
20008
|
+
});
|
20009
|
+
require.register("indefinido-indemma/lib/record/validations/confirmation.js", function(exports, require, module){
|
20010
|
+
var composed, confirmationable, stampit;
|
19928
20011
|
|
19929
20012
|
stampit = require('../../../vendor/stampit');
|
19930
20013
|
|
@@ -19936,17 +20019,15 @@ confirmationable = stampit({
|
|
19936
20019
|
}
|
19937
20020
|
});
|
19938
20021
|
|
19939
|
-
composed = stampit.compose(
|
20022
|
+
composed = stampit.compose(require('./validatorable'), confirmationable);
|
19940
20023
|
|
19941
20024
|
composed.definition_key = 'validates_confirmation_of';
|
19942
20025
|
|
19943
|
-
|
20026
|
+
module.exports = composed;
|
19944
20027
|
|
19945
20028
|
});
|
19946
20029
|
require.register("indefinido-indemma/lib/record/validations/associated.js", function(exports, require, module){
|
19947
|
-
var associationable, composed, stampit
|
19948
|
-
|
19949
|
-
validations = require('../validatable');
|
20030
|
+
var associationable, composed, stampit;
|
19950
20031
|
|
19951
20032
|
stampit = require('../../../vendor/stampit');
|
19952
20033
|
|
@@ -19969,17 +20050,15 @@ associationable = stampit({
|
|
19969
20050
|
}
|
19970
20051
|
});
|
19971
20052
|
|
19972
|
-
composed = stampit.compose(
|
20053
|
+
composed = stampit.compose(require('./validatorable'), associationable);
|
19973
20054
|
|
19974
20055
|
composed.definition_key = 'validates_associated';
|
19975
20056
|
|
19976
|
-
|
20057
|
+
module.exports = composed;
|
19977
20058
|
|
19978
20059
|
});
|
19979
20060
|
require.register("indefinido-indemma/lib/record/validations/presence.js", function(exports, require, module){
|
19980
|
-
var composed, presenceable, stampit
|
19981
|
-
|
19982
|
-
validations = require('../validatable');
|
20061
|
+
var composed, presenceable, stampit;
|
19983
20062
|
|
19984
20063
|
stampit = require('../../../vendor/stampit');
|
19985
20064
|
|
@@ -19991,19 +20070,15 @@ presenceable = stampit({
|
|
19991
20070
|
}
|
19992
20071
|
});
|
19993
20072
|
|
19994
|
-
composed = stampit.compose(
|
20073
|
+
composed = stampit.compose(require('./validatorable'), presenceable);
|
19995
20074
|
|
19996
20075
|
composed.definition_key = 'validates_presence_of';
|
19997
20076
|
|
19998
|
-
|
20077
|
+
module.exports = composed;
|
19999
20078
|
|
20000
20079
|
});
|
20001
20080
|
require.register("indefinido-indemma/lib/record/validations/remote.js", function(exports, require, module){
|
20002
|
-
var composed, remoteable, rest,
|
20003
|
-
|
20004
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
20005
|
-
|
20006
|
-
validations = require('../validatable');
|
20081
|
+
var composed, remoteable, rest, stampit;
|
20007
20082
|
|
20008
20083
|
rest = require('../rest');
|
20009
20084
|
|
@@ -20066,11 +20141,11 @@ remoteable = stampit({
|
|
20066
20141
|
return this;
|
20067
20142
|
});
|
20068
20143
|
|
20069
|
-
composed = stampit.compose(
|
20144
|
+
composed = stampit.compose(require('./validatorable'), remoteable);
|
20070
20145
|
|
20071
20146
|
composed.definition_key = 'validates_remotely';
|
20072
20147
|
|
20073
|
-
|
20148
|
+
module.exports = composed;
|
20074
20149
|
|
20075
20150
|
});
|
20076
20151
|
require.register("indefinido-indemma/lib/record/validations/type.js", function(exports, require, module){
|
@@ -20098,17 +20173,15 @@ typeable = stampit({
|
|
20098
20173
|
}
|
20099
20174
|
});
|
20100
20175
|
|
20101
|
-
composed = stampit.compose(
|
20176
|
+
composed = stampit.compose(require('./validatorable'), typeable);
|
20102
20177
|
|
20103
20178
|
composed.definition_key = 'validates_type_of';
|
20104
20179
|
|
20105
|
-
|
20180
|
+
module.exports = composed;
|
20106
20181
|
|
20107
20182
|
});
|
20108
20183
|
require.register("indefinido-indemma/lib/record/validations/cpf.js", function(exports, require, module){
|
20109
|
-
var composed, cpfable, stampit
|
20110
|
-
|
20111
|
-
validations = require('../validatable');
|
20184
|
+
var composed, cpfable, stampit;
|
20112
20185
|
|
20113
20186
|
stampit = require('../../../vendor/stampit');
|
20114
20187
|
|
@@ -20128,7 +20201,7 @@ cpfable = stampit({
|
|
20128
20201
|
d1 = 0;
|
20129
20202
|
v = false;
|
20130
20203
|
i = 0;
|
20131
|
-
for (i = _i =
|
20204
|
+
for (i = _i = 0; _i <= 9; i = ++_i) {
|
20132
20205
|
d1 += c.charAt(i) * (10 - i);
|
20133
20206
|
}
|
20134
20207
|
if (d1 === 0) {
|
@@ -20142,7 +20215,7 @@ cpfable = stampit({
|
|
20142
20215
|
return false;
|
20143
20216
|
}
|
20144
20217
|
d1 *= 2;
|
20145
|
-
for (i = _j =
|
20218
|
+
for (i = _j = 0; _j <= 9; i = ++_j) {
|
20146
20219
|
d1 += c.charAt(i) * (11 - i);
|
20147
20220
|
}
|
20148
20221
|
d1 = 11 - (d1 % 11);
|
@@ -20161,19 +20234,19 @@ cpfable = stampit({
|
|
20161
20234
|
}
|
20162
20235
|
});
|
20163
20236
|
|
20164
|
-
composed = stampit.compose(
|
20237
|
+
composed = stampit.compose(require('./validatorable'), cpfable);
|
20165
20238
|
|
20166
20239
|
composed.definition_key = 'validates_cpf_format';
|
20167
20240
|
|
20168
|
-
|
20241
|
+
module.exports = composed;
|
20169
20242
|
|
20170
20243
|
});
|
20171
20244
|
require.register("indefinido-indemma/lib/record/validatable.js", function(exports, require, module){
|
20172
|
-
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type
|
20245
|
+
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
20173
20246
|
|
20174
20247
|
require('./translationable');
|
20175
20248
|
|
20176
|
-
root = typeof exports !== "undefined" && exports !== null ? exports :
|
20249
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
20177
20250
|
|
20178
20251
|
stampit = require('../../vendor/stampit');
|
20179
20252
|
|
@@ -20264,7 +20337,7 @@ initializers = {
|
|
20264
20337
|
});
|
20265
20338
|
this.validated = false;
|
20266
20339
|
this.subscribe('dirty', function(value) {
|
20267
|
-
return this.validated = false;
|
20340
|
+
return value && (this.validated = false);
|
20268
20341
|
});
|
20269
20342
|
return Object.defineProperty(this, 'valid', {
|
20270
20343
|
get: function() {
|
@@ -20358,7 +20431,12 @@ extensions = {
|
|
20358
20431
|
this.validation.done(doned);
|
20359
20432
|
this.validation.fail(failed);
|
20360
20433
|
this.validation.then(function(record) {
|
20361
|
-
|
20434
|
+
var old_dirty;
|
20435
|
+
|
20436
|
+
old_dirty = record.dirty;
|
20437
|
+
record.dirty = null;
|
20438
|
+
record.validated || (record.validated = true);
|
20439
|
+
return record.dirty = old_dirty;
|
20362
20440
|
});
|
20363
20441
|
return this.validation;
|
20364
20442
|
}
|
@@ -20369,15 +20447,6 @@ manager = {
|
|
20369
20447
|
validators: {}
|
20370
20448
|
};
|
20371
20449
|
|
20372
|
-
validatable = stampit({
|
20373
|
-
validate: function() {
|
20374
|
-
throw new Error('Composed factory must override the validate method');
|
20375
|
-
},
|
20376
|
-
validate_each: function() {
|
20377
|
-
throw new Error('Composed factory must override the validate each method');
|
20378
|
-
}
|
20379
|
-
});
|
20380
|
-
|
20381
20450
|
model.mix(function(modelable) {
|
20382
20451
|
jQuery.extend(modelable, extensions.model);
|
20383
20452
|
jQuery.extend(modelable.record, extensions.record);
|
@@ -20386,21 +20455,17 @@ model.mix(function(modelable) {
|
|
20386
20455
|
return model.validators = manager.validators;
|
20387
20456
|
});
|
20388
20457
|
|
20389
|
-
|
20458
|
+
manager.validators.confirmation = require('./validations/confirmation');
|
20390
20459
|
|
20391
|
-
|
20460
|
+
manager.validators.associated = require('./validations/associated');
|
20392
20461
|
|
20393
|
-
require('./validations/
|
20462
|
+
manager.validators.presence = require('./validations/presence');
|
20394
20463
|
|
20395
|
-
require('./validations/
|
20464
|
+
manager.validators.remote = require('./validations/remote');
|
20396
20465
|
|
20397
|
-
require('./validations/
|
20466
|
+
manager.validators.type = require('./validations/type');
|
20398
20467
|
|
20399
|
-
require('./validations/
|
20400
|
-
|
20401
|
-
require('./validations/type');
|
20402
|
-
|
20403
|
-
require('./validations/cpf');
|
20468
|
+
manager.validators.cpf = require('./validations/cpf');
|
20404
20469
|
|
20405
20470
|
});
|
20406
20471
|
require.register("indefinido-indemma/lib/extensions/rivets.js", function(exports, require, module){
|
@@ -28011,6 +28076,358 @@ var forIn = require('./forIn');
|
|
28011
28076
|
});
|
28012
28077
|
;
|
28013
28078
|
|
28079
|
+
});
|
28080
|
+
require.register("ened/vendor/assets/javascripts/spin/spin.js", function(exports, require, module){
|
28081
|
+
//fgnass.github.com/spin.js#v1.3
|
28082
|
+
|
28083
|
+
/**
|
28084
|
+
* Copyright (c) 2011-2013 Felix Gnass
|
28085
|
+
* Licensed under the MIT license
|
28086
|
+
*/
|
28087
|
+
(function(root, factory) {
|
28088
|
+
|
28089
|
+
/* CommonJS */
|
28090
|
+
if (typeof exports == 'object') module.exports = factory()
|
28091
|
+
|
28092
|
+
/* AMD module */
|
28093
|
+
else if (typeof define == 'function' && define.amd) define(factory)
|
28094
|
+
|
28095
|
+
/* Browser global */
|
28096
|
+
else root.Spinner = factory()
|
28097
|
+
}
|
28098
|
+
(this, function() {
|
28099
|
+
"use strict";
|
28100
|
+
|
28101
|
+
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
|
28102
|
+
, animations = {} /* Animation rules keyed by their name */
|
28103
|
+
, useCssAnimations /* Whether to use CSS animations or setTimeout */
|
28104
|
+
|
28105
|
+
/**
|
28106
|
+
* Utility function to create elements. If no tag name is given,
|
28107
|
+
* a DIV is created. Optionally properties can be passed.
|
28108
|
+
*/
|
28109
|
+
function createEl(tag, prop) {
|
28110
|
+
var el = document.createElement(tag || 'div')
|
28111
|
+
, n
|
28112
|
+
|
28113
|
+
for(n in prop) el[n] = prop[n]
|
28114
|
+
return el
|
28115
|
+
}
|
28116
|
+
|
28117
|
+
/**
|
28118
|
+
* Appends children and returns the parent.
|
28119
|
+
*/
|
28120
|
+
function ins(parent /* child1, child2, ...*/) {
|
28121
|
+
for (var i=1, n=arguments.length; i<n; i++)
|
28122
|
+
parent.appendChild(arguments[i])
|
28123
|
+
|
28124
|
+
return parent
|
28125
|
+
}
|
28126
|
+
|
28127
|
+
/**
|
28128
|
+
* Insert a new stylesheet to hold the @keyframe or VML rules.
|
28129
|
+
*/
|
28130
|
+
var sheet = (function() {
|
28131
|
+
var el = createEl('style', {type : 'text/css'})
|
28132
|
+
ins(document.getElementsByTagName('head')[0], el)
|
28133
|
+
return el.sheet || el.styleSheet
|
28134
|
+
}())
|
28135
|
+
|
28136
|
+
/**
|
28137
|
+
* Creates an opacity keyframe animation rule and returns its name.
|
28138
|
+
* Since most mobile Webkits have timing issues with animation-delay,
|
28139
|
+
* we create separate rules for each line/segment.
|
28140
|
+
*/
|
28141
|
+
function addAnimation(alpha, trail, i, lines) {
|
28142
|
+
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
|
28143
|
+
, start = 0.01 + i/lines * 100
|
28144
|
+
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
|
28145
|
+
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
|
28146
|
+
, pre = prefix && '-' + prefix + '-' || ''
|
28147
|
+
|
28148
|
+
if (!animations[name]) {
|
28149
|
+
sheet.insertRule(
|
28150
|
+
'@' + pre + 'keyframes ' + name + '{' +
|
28151
|
+
'0%{opacity:' + z + '}' +
|
28152
|
+
start + '%{opacity:' + alpha + '}' +
|
28153
|
+
(start+0.01) + '%{opacity:1}' +
|
28154
|
+
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
|
28155
|
+
'100%{opacity:' + z + '}' +
|
28156
|
+
'}', sheet.cssRules.length)
|
28157
|
+
|
28158
|
+
animations[name] = 1
|
28159
|
+
}
|
28160
|
+
|
28161
|
+
return name
|
28162
|
+
}
|
28163
|
+
|
28164
|
+
/**
|
28165
|
+
* Tries various vendor prefixes and returns the first supported property.
|
28166
|
+
*/
|
28167
|
+
function vendor(el, prop) {
|
28168
|
+
var s = el.style
|
28169
|
+
, pp
|
28170
|
+
, i
|
28171
|
+
|
28172
|
+
if(s[prop] !== undefined) return prop
|
28173
|
+
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
|
28174
|
+
for(i=0; i<prefixes.length; i++) {
|
28175
|
+
pp = prefixes[i]+prop
|
28176
|
+
if(s[pp] !== undefined) return pp
|
28177
|
+
}
|
28178
|
+
}
|
28179
|
+
|
28180
|
+
/**
|
28181
|
+
* Sets multiple style properties at once.
|
28182
|
+
*/
|
28183
|
+
function css(el, prop) {
|
28184
|
+
for (var n in prop)
|
28185
|
+
el.style[vendor(el, n)||n] = prop[n]
|
28186
|
+
|
28187
|
+
return el
|
28188
|
+
}
|
28189
|
+
|
28190
|
+
/**
|
28191
|
+
* Fills in default values.
|
28192
|
+
*/
|
28193
|
+
function merge(obj) {
|
28194
|
+
for (var i=1; i < arguments.length; i++) {
|
28195
|
+
var def = arguments[i]
|
28196
|
+
for (var n in def)
|
28197
|
+
if (obj[n] === undefined) obj[n] = def[n]
|
28198
|
+
}
|
28199
|
+
return obj
|
28200
|
+
}
|
28201
|
+
|
28202
|
+
/**
|
28203
|
+
* Returns the absolute page-offset of the given element.
|
28204
|
+
*/
|
28205
|
+
function pos(el) {
|
28206
|
+
var o = { x:el.offsetLeft, y:el.offsetTop }
|
28207
|
+
while((el = el.offsetParent))
|
28208
|
+
o.x+=el.offsetLeft, o.y+=el.offsetTop
|
28209
|
+
|
28210
|
+
return o
|
28211
|
+
}
|
28212
|
+
|
28213
|
+
// Built-in defaults
|
28214
|
+
|
28215
|
+
var defaults = {
|
28216
|
+
lines: 12, // The number of lines to draw
|
28217
|
+
length: 7, // The length of each line
|
28218
|
+
width: 5, // The line thickness
|
28219
|
+
radius: 10, // The radius of the inner circle
|
28220
|
+
rotate: 0, // Rotation offset
|
28221
|
+
corners: 1, // Roundness (0..1)
|
28222
|
+
color: '#000', // #rgb or #rrggbb
|
28223
|
+
direction: 1, // 1: clockwise, -1: counterclockwise
|
28224
|
+
speed: 1, // Rounds per second
|
28225
|
+
trail: 100, // Afterglow percentage
|
28226
|
+
opacity: 1/4, // Opacity of the lines
|
28227
|
+
fps: 20, // Frames per second when using setTimeout()
|
28228
|
+
zIndex: 2e9, // Use a high z-index by default
|
28229
|
+
className: 'spinner', // CSS class to assign to the element
|
28230
|
+
top: 'auto', // center vertically
|
28231
|
+
left: 'auto', // center horizontally
|
28232
|
+
position: 'relative' // element position
|
28233
|
+
}
|
28234
|
+
|
28235
|
+
/** The constructor */
|
28236
|
+
function Spinner(o) {
|
28237
|
+
if (typeof this == 'undefined') return new Spinner(o)
|
28238
|
+
this.opts = merge(o || {}, Spinner.defaults, defaults)
|
28239
|
+
}
|
28240
|
+
|
28241
|
+
// Global defaults that override the built-ins:
|
28242
|
+
Spinner.defaults = {}
|
28243
|
+
|
28244
|
+
merge(Spinner.prototype, {
|
28245
|
+
|
28246
|
+
/**
|
28247
|
+
* Adds the spinner to the given target element. If this instance is already
|
28248
|
+
* spinning, it is automatically removed from its previous target b calling
|
28249
|
+
* stop() internally.
|
28250
|
+
*/
|
28251
|
+
spin: function(target) {
|
28252
|
+
this.stop()
|
28253
|
+
|
28254
|
+
var self = this
|
28255
|
+
, o = self.opts
|
28256
|
+
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
|
28257
|
+
, mid = o.radius+o.length+o.width
|
28258
|
+
, ep // element position
|
28259
|
+
, tp // target position
|
28260
|
+
|
28261
|
+
if (target) {
|
28262
|
+
target.insertBefore(el, target.firstChild||null)
|
28263
|
+
tp = pos(target)
|
28264
|
+
ep = pos(el)
|
28265
|
+
css(el, {
|
28266
|
+
left: (o.left == 'auto' ? tp.x-ep.x + (target.offsetWidth >> 1) : parseInt(o.left, 10) + mid) + 'px',
|
28267
|
+
top: (o.top == 'auto' ? tp.y-ep.y + (target.offsetHeight >> 1) : parseInt(o.top, 10) + mid) + 'px'
|
28268
|
+
})
|
28269
|
+
}
|
28270
|
+
|
28271
|
+
el.setAttribute('role', 'progressbar')
|
28272
|
+
self.lines(el, self.opts)
|
28273
|
+
|
28274
|
+
if (!useCssAnimations) {
|
28275
|
+
// No CSS animation support, use setTimeout() instead
|
28276
|
+
var i = 0
|
28277
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
28278
|
+
, alpha
|
28279
|
+
, fps = o.fps
|
28280
|
+
, f = fps/o.speed
|
28281
|
+
, ostep = (1-o.opacity) / (f*o.trail / 100)
|
28282
|
+
, astep = f/o.lines
|
28283
|
+
|
28284
|
+
;(function anim() {
|
28285
|
+
i++;
|
28286
|
+
for (var j = 0; j < o.lines; j++) {
|
28287
|
+
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
|
28288
|
+
|
28289
|
+
self.opacity(el, j * o.direction + start, alpha, o)
|
28290
|
+
}
|
28291
|
+
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
|
28292
|
+
})()
|
28293
|
+
}
|
28294
|
+
return self
|
28295
|
+
},
|
28296
|
+
|
28297
|
+
/**
|
28298
|
+
* Stops and removes the Spinner.
|
28299
|
+
*/
|
28300
|
+
stop: function() {
|
28301
|
+
var el = this.el
|
28302
|
+
if (el) {
|
28303
|
+
clearTimeout(this.timeout)
|
28304
|
+
if (el.parentNode) el.parentNode.removeChild(el)
|
28305
|
+
this.el = undefined
|
28306
|
+
}
|
28307
|
+
return this
|
28308
|
+
},
|
28309
|
+
|
28310
|
+
/**
|
28311
|
+
* Internal method that draws the individual lines. Will be overwritten
|
28312
|
+
* in VML fallback mode below.
|
28313
|
+
*/
|
28314
|
+
lines: function(el, o) {
|
28315
|
+
var i = 0
|
28316
|
+
, start = (o.lines - 1) * (1 - o.direction) / 2
|
28317
|
+
, seg
|
28318
|
+
|
28319
|
+
function fill(color, shadow) {
|
28320
|
+
return css(createEl(), {
|
28321
|
+
position: 'absolute',
|
28322
|
+
width: (o.length+o.width) + 'px',
|
28323
|
+
height: o.width + 'px',
|
28324
|
+
background: color,
|
28325
|
+
boxShadow: shadow,
|
28326
|
+
transformOrigin: 'left',
|
28327
|
+
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
|
28328
|
+
borderRadius: (o.corners * o.width>>1) + 'px'
|
28329
|
+
})
|
28330
|
+
}
|
28331
|
+
|
28332
|
+
for (; i < o.lines; i++) {
|
28333
|
+
seg = css(createEl(), {
|
28334
|
+
position: 'absolute',
|
28335
|
+
top: 1+~(o.width/2) + 'px',
|
28336
|
+
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
|
28337
|
+
opacity: o.opacity,
|
28338
|
+
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
|
28339
|
+
})
|
28340
|
+
|
28341
|
+
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
|
28342
|
+
|
28343
|
+
ins(el, ins(seg, fill(o.color, '0 0 1px rgba(0,0,0,.1)')))
|
28344
|
+
}
|
28345
|
+
return el
|
28346
|
+
},
|
28347
|
+
|
28348
|
+
/**
|
28349
|
+
* Internal method that adjusts the opacity of a single line.
|
28350
|
+
* Will be overwritten in VML fallback mode below.
|
28351
|
+
*/
|
28352
|
+
opacity: function(el, i, val) {
|
28353
|
+
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
|
28354
|
+
}
|
28355
|
+
|
28356
|
+
})
|
28357
|
+
|
28358
|
+
|
28359
|
+
function initVML() {
|
28360
|
+
|
28361
|
+
/* Utility function to create a VML tag */
|
28362
|
+
function vml(tag, attr) {
|
28363
|
+
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
|
28364
|
+
}
|
28365
|
+
|
28366
|
+
// No CSS transforms but VML support, add a CSS rule for VML elements:
|
28367
|
+
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
|
28368
|
+
|
28369
|
+
Spinner.prototype.lines = function(el, o) {
|
28370
|
+
var r = o.length+o.width
|
28371
|
+
, s = 2*r
|
28372
|
+
|
28373
|
+
function grp() {
|
28374
|
+
return css(
|
28375
|
+
vml('group', {
|
28376
|
+
coordsize: s + ' ' + s,
|
28377
|
+
coordorigin: -r + ' ' + -r
|
28378
|
+
}),
|
28379
|
+
{ width: s, height: s }
|
28380
|
+
)
|
28381
|
+
}
|
28382
|
+
|
28383
|
+
var margin = -(o.width+o.length)*2 + 'px'
|
28384
|
+
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
|
28385
|
+
, i
|
28386
|
+
|
28387
|
+
function seg(i, dx, filter) {
|
28388
|
+
ins(g,
|
28389
|
+
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
|
28390
|
+
ins(css(vml('roundrect', {arcsize: o.corners}), {
|
28391
|
+
width: r,
|
28392
|
+
height: o.width,
|
28393
|
+
left: o.radius,
|
28394
|
+
top: -o.width>>1,
|
28395
|
+
filter: filter
|
28396
|
+
}),
|
28397
|
+
vml('fill', {color: o.color, opacity: o.opacity}),
|
28398
|
+
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
|
28399
|
+
)
|
28400
|
+
)
|
28401
|
+
)
|
28402
|
+
}
|
28403
|
+
|
28404
|
+
if (o.shadow)
|
28405
|
+
for (i = 1; i <= o.lines; i++)
|
28406
|
+
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
|
28407
|
+
|
28408
|
+
for (i = 1; i <= o.lines; i++) seg(i)
|
28409
|
+
return ins(el, g)
|
28410
|
+
}
|
28411
|
+
|
28412
|
+
Spinner.prototype.opacity = function(el, i, val, o) {
|
28413
|
+
var c = el.firstChild
|
28414
|
+
o = o.shadow && o.lines || 0
|
28415
|
+
if (c && i+o < c.childNodes.length) {
|
28416
|
+
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
|
28417
|
+
if (c) c.opacity = val
|
28418
|
+
}
|
28419
|
+
}
|
28420
|
+
}
|
28421
|
+
|
28422
|
+
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
|
28423
|
+
|
28424
|
+
if (!vendor(probe, 'transform') && probe.adj) initVML()
|
28425
|
+
else useCssAnimations = vendor(probe, 'animation')
|
28426
|
+
|
28427
|
+
return Spinner
|
28428
|
+
|
28429
|
+
}));
|
28430
|
+
|
28014
28431
|
});
|
28015
28432
|
require.register("ened/vendor/assets/javascripts/jquery/inview.js", function(exports, require, module){
|
28016
28433
|
/**
|
@@ -28139,6 +28556,1926 @@ require.register("ened/vendor/assets/javascripts/jquery/inview.js", function(exp
|
|
28139
28556
|
setInterval(checkInView, 250);
|
28140
28557
|
})(jQuery);
|
28141
28558
|
});
|
28559
|
+
<<<<<<< HEAD
|
28560
|
+
require.register("ened/vendor/assets/javascripts/jquery/inputmask.js", function(exports, require, module){
|
28561
|
+
/**
|
28562
|
+
* @license Input Mask plugin for jquery
|
28563
|
+
* http://github.com/RobinHerbots/jquery.inputmask
|
28564
|
+
* Copyright (c) 2010 - 2014 Robin Herbots
|
28565
|
+
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
28566
|
+
* Version: 0.0.0
|
28567
|
+
*/
|
28568
|
+
|
28569
|
+
(function ($) {
|
28570
|
+
if ($.fn.inputmask === undefined) {
|
28571
|
+
//helper functions
|
28572
|
+
function isInputEventSupported(eventName) {
|
28573
|
+
var el = document.createElement('input'),
|
28574
|
+
eventName = 'on' + eventName,
|
28575
|
+
isSupported = (eventName in el);
|
28576
|
+
if (!isSupported) {
|
28577
|
+
el.setAttribute(eventName, 'return;');
|
28578
|
+
isSupported = typeof el[eventName] == 'function';
|
28579
|
+
}
|
28580
|
+
el = null;
|
28581
|
+
return isSupported;
|
28582
|
+
}
|
28583
|
+
|
28584
|
+
function resolveAlias(aliasStr, options, opts) {
|
28585
|
+
var aliasDefinition = opts.aliases[aliasStr];
|
28586
|
+
if (aliasDefinition) {
|
28587
|
+
if (aliasDefinition.alias) resolveAlias(aliasDefinition.alias, undefined, opts); //alias is another alias
|
28588
|
+
$.extend(true, opts, aliasDefinition); //merge alias definition in the options
|
28589
|
+
$.extend(true, opts, options); //reapply extra given options
|
28590
|
+
return true;
|
28591
|
+
}
|
28592
|
+
return false;
|
28593
|
+
}
|
28594
|
+
|
28595
|
+
|
28596
|
+
function generateMaskSets(opts) {
|
28597
|
+
var ms = [];
|
28598
|
+
var genmasks = []; //used to keep track of the masks that where processed, to avoid duplicates
|
28599
|
+
function getMaskTemplate(mask) {
|
28600
|
+
if (opts.numericInput) {
|
28601
|
+
mask = mask.split('').reverse().join('');
|
28602
|
+
}
|
28603
|
+
var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
|
28604
|
+
if (repeat == "*") greedy = false;
|
28605
|
+
//if (greedy == true && opts.placeholder == "") opts.placeholder = " ";
|
28606
|
+
if (mask.length == 1 && greedy == false && repeat != 0) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
|
28607
|
+
var singleMask = $.map(mask.split(""), function (element, index) {
|
28608
|
+
var outElem = [];
|
28609
|
+
if (element == opts.escapeChar) {
|
28610
|
+
escaped = true;
|
28611
|
+
}
|
28612
|
+
else if ((element != opts.optionalmarker.start && element != opts.optionalmarker.end) || escaped) {
|
28613
|
+
var maskdef = opts.definitions[element];
|
28614
|
+
if (maskdef && !escaped) {
|
28615
|
+
for (var i = 0; i < maskdef.cardinality; i++) {
|
28616
|
+
outElem.push(opts.placeholder.charAt((outCount + i) % opts.placeholder.length));
|
28617
|
+
}
|
28618
|
+
} else {
|
28619
|
+
outElem.push(element);
|
28620
|
+
escaped = false;
|
28621
|
+
}
|
28622
|
+
outCount += outElem.length;
|
28623
|
+
return outElem;
|
28624
|
+
}
|
28625
|
+
});
|
28626
|
+
|
28627
|
+
//allocate repetitions
|
28628
|
+
var repeatedMask = singleMask.slice();
|
28629
|
+
for (var i = 1; i < repeat && greedy; i++) {
|
28630
|
+
repeatedMask = repeatedMask.concat(singleMask.slice());
|
28631
|
+
}
|
28632
|
+
|
28633
|
+
return { "mask": repeatedMask, "repeat": repeat, "greedy": greedy };
|
28634
|
+
}
|
28635
|
+
//test definition => {fn: RegExp/function, cardinality: int, optionality: bool, newBlockMarker: bool, offset: int, casing: null/upper/lower, def: definitionSymbol}
|
28636
|
+
function getTestingChain(mask) {
|
28637
|
+
if (opts.numericInput) {
|
28638
|
+
mask = mask.split('').reverse().join('');
|
28639
|
+
}
|
28640
|
+
var isOptional = false, escaped = false;
|
28641
|
+
var newBlockMarker = false; //indicates wheter the begin/ending of a block should be indicated
|
28642
|
+
|
28643
|
+
return $.map(mask.split(""), function (element, index) {
|
28644
|
+
var outElem = [];
|
28645
|
+
|
28646
|
+
if (element == opts.escapeChar) {
|
28647
|
+
escaped = true;
|
28648
|
+
} else if (element == opts.optionalmarker.start && !escaped) {
|
28649
|
+
isOptional = true;
|
28650
|
+
newBlockMarker = true;
|
28651
|
+
}
|
28652
|
+
else if (element == opts.optionalmarker.end && !escaped) {
|
28653
|
+
isOptional = false;
|
28654
|
+
newBlockMarker = true;
|
28655
|
+
}
|
28656
|
+
else {
|
28657
|
+
var maskdef = opts.definitions[element];
|
28658
|
+
if (maskdef && !escaped) {
|
28659
|
+
var prevalidators = maskdef["prevalidator"], prevalidatorsL = prevalidators ? prevalidators.length : 0;
|
28660
|
+
for (var i = 1; i < maskdef.cardinality; i++) {
|
28661
|
+
var prevalidator = prevalidatorsL >= i ? prevalidators[i - 1] : [], validator = prevalidator["validator"], cardinality = prevalidator["cardinality"];
|
28662
|
+
outElem.push({ fn: validator ? typeof validator == 'string' ? new RegExp(validator) : new function () { this.test = validator; } : new RegExp("."), cardinality: cardinality ? cardinality : 1, optionality: isOptional, newBlockMarker: isOptional == true ? newBlockMarker : false, offset: 0, casing: maskdef["casing"], def: maskdef["definitionSymbol"] || element });
|
28663
|
+
if (isOptional == true) //reset newBlockMarker
|
28664
|
+
newBlockMarker = false;
|
28665
|
+
}
|
28666
|
+
outElem.push({ fn: maskdef.validator ? typeof maskdef.validator == 'string' ? new RegExp(maskdef.validator) : new function () { this.test = maskdef.validator; } : new RegExp("."), cardinality: maskdef.cardinality, optionality: isOptional, newBlockMarker: newBlockMarker, offset: 0, casing: maskdef["casing"], def: maskdef["definitionSymbol"] || element });
|
28667
|
+
} else {
|
28668
|
+
outElem.push({ fn: null, cardinality: 0, optionality: isOptional, newBlockMarker: newBlockMarker, offset: 0, casing: null, def: element });
|
28669
|
+
escaped = false;
|
28670
|
+
}
|
28671
|
+
//reset newBlockMarker
|
28672
|
+
newBlockMarker = false;
|
28673
|
+
return outElem;
|
28674
|
+
}
|
28675
|
+
});
|
28676
|
+
}
|
28677
|
+
function markOptional(maskPart) { //needed for the clearOptionalTail functionality
|
28678
|
+
return opts.optionalmarker.start + maskPart + opts.optionalmarker.end;
|
28679
|
+
}
|
28680
|
+
function splitFirstOptionalEndPart(maskPart) {
|
28681
|
+
var optionalStartMarkers = 0, optionalEndMarkers = 0, mpl = maskPart.length;
|
28682
|
+
for (var i = 0; i < mpl; i++) {
|
28683
|
+
if (maskPart.charAt(i) == opts.optionalmarker.start) {
|
28684
|
+
optionalStartMarkers++;
|
28685
|
+
}
|
28686
|
+
if (maskPart.charAt(i) == opts.optionalmarker.end) {
|
28687
|
+
optionalEndMarkers++;
|
28688
|
+
}
|
28689
|
+
if (optionalStartMarkers > 0 && optionalStartMarkers == optionalEndMarkers)
|
28690
|
+
break;
|
28691
|
+
}
|
28692
|
+
var maskParts = [maskPart.substring(0, i)];
|
28693
|
+
if (i < mpl) {
|
28694
|
+
maskParts.push(maskPart.substring(i + 1, mpl));
|
28695
|
+
}
|
28696
|
+
return maskParts;
|
28697
|
+
}
|
28698
|
+
function splitFirstOptionalStartPart(maskPart) {
|
28699
|
+
var mpl = maskPart.length;
|
28700
|
+
for (var i = 0; i < mpl; i++) {
|
28701
|
+
if (maskPart.charAt(i) == opts.optionalmarker.start) {
|
28702
|
+
break;
|
28703
|
+
}
|
28704
|
+
}
|
28705
|
+
var maskParts = [maskPart.substring(0, i)];
|
28706
|
+
if (i < mpl) {
|
28707
|
+
maskParts.push(maskPart.substring(i + 1, mpl));
|
28708
|
+
}
|
28709
|
+
return maskParts;
|
28710
|
+
}
|
28711
|
+
function generateMask(maskPrefix, maskPart, metadata) {
|
28712
|
+
var maskParts = splitFirstOptionalEndPart(maskPart);
|
28713
|
+
var newMask, maskTemplate;
|
28714
|
+
|
28715
|
+
var masks = splitFirstOptionalStartPart(maskParts[0]);
|
28716
|
+
if (masks.length > 1) {
|
28717
|
+
newMask = maskPrefix + masks[0] + markOptional(masks[1]) + (maskParts.length > 1 ? maskParts[1] : "");
|
28718
|
+
if ($.inArray(newMask, genmasks) == -1 && newMask != "") {
|
28719
|
+
genmasks.push(newMask);
|
28720
|
+
maskTemplate = getMaskTemplate(newMask);
|
28721
|
+
ms.push({
|
28722
|
+
"mask": newMask,
|
28723
|
+
"_buffer": maskTemplate["mask"],
|
28724
|
+
"buffer": maskTemplate["mask"].slice(),
|
28725
|
+
"tests": getTestingChain(newMask),
|
28726
|
+
"lastValidPosition": -1,
|
28727
|
+
"greedy": maskTemplate["greedy"],
|
28728
|
+
"repeat": maskTemplate["repeat"],
|
28729
|
+
"metadata": metadata
|
28730
|
+
});
|
28731
|
+
}
|
28732
|
+
newMask = maskPrefix + masks[0] + (maskParts.length > 1 ? maskParts[1] : "");
|
28733
|
+
if ($.inArray(newMask, genmasks) == -1 && newMask != "") {
|
28734
|
+
genmasks.push(newMask);
|
28735
|
+
maskTemplate = getMaskTemplate(newMask);
|
28736
|
+
ms.push({
|
28737
|
+
"mask": newMask,
|
28738
|
+
"_buffer": maskTemplate["mask"],
|
28739
|
+
"buffer": maskTemplate["mask"].slice(),
|
28740
|
+
"tests": getTestingChain(newMask),
|
28741
|
+
"lastValidPosition": -1,
|
28742
|
+
"greedy": maskTemplate["greedy"],
|
28743
|
+
"repeat": maskTemplate["repeat"],
|
28744
|
+
"metadata": metadata
|
28745
|
+
});
|
28746
|
+
}
|
28747
|
+
if (splitFirstOptionalStartPart(masks[1]).length > 1) { //optional contains another optional
|
28748
|
+
generateMask(maskPrefix + masks[0], masks[1] + maskParts[1], metadata);
|
28749
|
+
}
|
28750
|
+
if (maskParts.length > 1 && splitFirstOptionalStartPart(maskParts[1]).length > 1) {
|
28751
|
+
generateMask(maskPrefix + masks[0] + markOptional(masks[1]), maskParts[1], metadata);
|
28752
|
+
generateMask(maskPrefix + masks[0], maskParts[1], metadata);
|
28753
|
+
}
|
28754
|
+
}
|
28755
|
+
else {
|
28756
|
+
newMask = maskPrefix + maskParts;
|
28757
|
+
if ($.inArray(newMask, genmasks) == -1 && newMask != "") {
|
28758
|
+
genmasks.push(newMask);
|
28759
|
+
maskTemplate = getMaskTemplate(newMask);
|
28760
|
+
ms.push({
|
28761
|
+
"mask": newMask,
|
28762
|
+
"_buffer": maskTemplate["mask"],
|
28763
|
+
"buffer": maskTemplate["mask"].slice(),
|
28764
|
+
"tests": getTestingChain(newMask),
|
28765
|
+
"lastValidPosition": -1,
|
28766
|
+
"greedy": maskTemplate["greedy"],
|
28767
|
+
"repeat": maskTemplate["repeat"],
|
28768
|
+
"metadata": metadata
|
28769
|
+
});
|
28770
|
+
}
|
28771
|
+
}
|
28772
|
+
|
28773
|
+
}
|
28774
|
+
|
28775
|
+
if ($.isFunction(opts.mask)) { //allow mask to be a preprocessing fn - should return a valid mask
|
28776
|
+
opts.mask = opts.mask.call(this, opts);
|
28777
|
+
}
|
28778
|
+
if ($.isArray(opts.mask)) {
|
28779
|
+
$.each(opts.mask, function (ndx, msk) {
|
28780
|
+
if (msk["mask"] != undefined) {
|
28781
|
+
generateMask("", msk["mask"].toString(), msk);
|
28782
|
+
} else
|
28783
|
+
generateMask("", msk.toString());
|
28784
|
+
});
|
28785
|
+
} else generateMask("", opts.mask.toString());
|
28786
|
+
|
28787
|
+
return opts.greedy ? ms : ms.sort(function (a, b) { return a["mask"].length - b["mask"].length; });
|
28788
|
+
}
|
28789
|
+
|
28790
|
+
|
28791
|
+
var msie10 = navigator.userAgent.match(new RegExp("msie 10", "i")) !== null,
|
28792
|
+
iphone = navigator.userAgent.match(new RegExp("iphone", "i")) !== null,
|
28793
|
+
android = navigator.userAgent.match(new RegExp("android.*safari.*", "i")) !== null,
|
28794
|
+
androidchrome = navigator.userAgent.match(new RegExp("android.*chrome.*", "i")) !== null,
|
28795
|
+
pasteEvent = isInputEventSupported('paste') && !msie10 ? 'paste' : isInputEventSupported('input') ? 'input' : "propertychange";
|
28796
|
+
|
28797
|
+
|
28798
|
+
//masking scope
|
28799
|
+
|
28800
|
+
function maskScope(masksets, activeMasksetIndex, opts) {
|
28801
|
+
var isRTL = false,
|
28802
|
+
valueOnFocus = getActiveBuffer().join(''),
|
28803
|
+
$el, chromeValueOnInput;
|
28804
|
+
|
28805
|
+
//maskset helperfunctions
|
28806
|
+
|
28807
|
+
function getActiveMaskSet() {
|
28808
|
+
return masksets[activeMasksetIndex];
|
28809
|
+
}
|
28810
|
+
|
28811
|
+
function getActiveTests() {
|
28812
|
+
return getActiveMaskSet()['tests'];
|
28813
|
+
}
|
28814
|
+
|
28815
|
+
function getActiveBufferTemplate() {
|
28816
|
+
return getActiveMaskSet()['_buffer'];
|
28817
|
+
}
|
28818
|
+
|
28819
|
+
function getActiveBuffer() {
|
28820
|
+
return getActiveMaskSet()['buffer'];
|
28821
|
+
}
|
28822
|
+
|
28823
|
+
function isValid(pos, c, strict) { //strict true ~ no correction or autofill
|
28824
|
+
strict = strict === true; //always set a value to strict to prevent possible strange behavior in the extensions
|
28825
|
+
|
28826
|
+
function _isValid(position, activeMaskset, c, strict) {
|
28827
|
+
var testPos = determineTestPosition(position), loopend = c ? 1 : 0, chrs = '', buffer = activeMaskset["buffer"];
|
28828
|
+
for (var i = activeMaskset['tests'][testPos].cardinality; i > loopend; i--) {
|
28829
|
+
chrs += getBufferElement(buffer, testPos - (i - 1));
|
28830
|
+
}
|
28831
|
+
|
28832
|
+
if (c) {
|
28833
|
+
chrs += c;
|
28834
|
+
}
|
28835
|
+
|
28836
|
+
//return is false or a json object => { pos: ??, c: ??} or true
|
28837
|
+
return activeMaskset['tests'][testPos].fn != null ?
|
28838
|
+
activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
|
28839
|
+
: (c == getBufferElement(activeMaskset['_buffer'], position, true) || c == opts.skipOptionalPartCharacter) ?
|
28840
|
+
{ "refresh": true, c: getBufferElement(activeMaskset['_buffer'], position, true), pos: position }
|
28841
|
+
: false;
|
28842
|
+
}
|
28843
|
+
|
28844
|
+
function PostProcessResults(maskForwards, results) {
|
28845
|
+
var hasValidActual = false;
|
28846
|
+
$.each(results, function (ndx, rslt) {
|
28847
|
+
hasValidActual = $.inArray(rslt["activeMasksetIndex"], maskForwards) == -1 && rslt["result"] !== false;
|
28848
|
+
if (hasValidActual) return false;
|
28849
|
+
});
|
28850
|
+
if (hasValidActual) { //strip maskforwards
|
28851
|
+
results = $.map(results, function (rslt, ndx) {
|
28852
|
+
if ($.inArray(rslt["activeMasksetIndex"], maskForwards) == -1) {
|
28853
|
+
return rslt;
|
28854
|
+
} else {
|
28855
|
+
masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = actualLVP;
|
28856
|
+
}
|
28857
|
+
});
|
28858
|
+
} else { //keep maskforwards with the least forward
|
28859
|
+
var lowestPos = -1, lowestIndex = -1, rsltValid;
|
28860
|
+
$.each(results, function (ndx, rslt) {
|
28861
|
+
if ($.inArray(rslt["activeMasksetIndex"], maskForwards) != -1 && rslt["result"] !== false & (lowestPos == -1 || lowestPos > rslt["result"]["pos"])) {
|
28862
|
+
lowestPos = rslt["result"]["pos"];
|
28863
|
+
lowestIndex = rslt["activeMasksetIndex"];
|
28864
|
+
}
|
28865
|
+
});
|
28866
|
+
results = $.map(results, function (rslt, ndx) {
|
28867
|
+
if ($.inArray(rslt["activeMasksetIndex"], maskForwards) != -1) {
|
28868
|
+
if (rslt["result"]["pos"] == lowestPos) {
|
28869
|
+
return rslt;
|
28870
|
+
} else if (rslt["result"] !== false) {
|
28871
|
+
for (var i = pos; i < lowestPos; i++) {
|
28872
|
+
rsltValid = _isValid(i, masksets[rslt["activeMasksetIndex"]], masksets[lowestIndex]["buffer"][i], true);
|
28873
|
+
if (rsltValid === false) {
|
28874
|
+
masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = lowestPos - 1;
|
28875
|
+
break;
|
28876
|
+
} else {
|
28877
|
+
setBufferElement(masksets[rslt["activeMasksetIndex"]]["buffer"], i, masksets[lowestIndex]["buffer"][i], true);
|
28878
|
+
masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = i;
|
28879
|
+
}
|
28880
|
+
}
|
28881
|
+
//also check check for the lowestpos with the new input
|
28882
|
+
rsltValid = _isValid(lowestPos, masksets[rslt["activeMasksetIndex"]], c, true);
|
28883
|
+
if (rsltValid !== false) {
|
28884
|
+
setBufferElement(masksets[rslt["activeMasksetIndex"]]["buffer"], lowestPos, c, true);
|
28885
|
+
masksets[rslt["activeMasksetIndex"]]["lastValidPosition"] = lowestPos;
|
28886
|
+
}
|
28887
|
+
//console.log("ndx " + rslt["activeMasksetIndex"] + " validate " + masksets[rslt["activeMasksetIndex"]]["buffer"].join('') + " lv " + masksets[rslt["activeMasksetIndex"]]['lastValidPosition']);
|
28888
|
+
return rslt;
|
28889
|
+
}
|
28890
|
+
}
|
28891
|
+
});
|
28892
|
+
}
|
28893
|
+
return results;
|
28894
|
+
}
|
28895
|
+
|
28896
|
+
if (strict) {
|
28897
|
+
var result = _isValid(pos, getActiveMaskSet(), c, strict); //only check validity in current mask when validating strict
|
28898
|
+
if (result === true) {
|
28899
|
+
result = { "pos": pos }; //always take a possible corrected maskposition into account
|
28900
|
+
}
|
28901
|
+
return result;
|
28902
|
+
}
|
28903
|
+
|
28904
|
+
var results = [], result = false, currentActiveMasksetIndex = activeMasksetIndex,
|
28905
|
+
actualBuffer = getActiveBuffer().slice(), actualLVP = getActiveMaskSet()["lastValidPosition"],
|
28906
|
+
actualPrevious = seekPrevious(pos),
|
28907
|
+
maskForwards = [];
|
28908
|
+
$.each(masksets, function (index, value) {
|
28909
|
+
if (typeof (value) == "object") {
|
28910
|
+
activeMasksetIndex = index;
|
28911
|
+
|
28912
|
+
var maskPos = pos;
|
28913
|
+
var lvp = getActiveMaskSet()['lastValidPosition'],
|
28914
|
+
rsltValid;
|
28915
|
+
if (lvp == actualLVP) {
|
28916
|
+
if ((maskPos - actualLVP) > 1) {
|
28917
|
+
for (var i = lvp == -1 ? 0 : lvp; i < maskPos; i++) {
|
28918
|
+
rsltValid = _isValid(i, getActiveMaskSet(), actualBuffer[i], true);
|
28919
|
+
if (rsltValid === false) {
|
28920
|
+
break;
|
28921
|
+
} else {
|
28922
|
+
setBufferElement(getActiveBuffer(), i, actualBuffer[i], true);
|
28923
|
+
if (rsltValid === true) {
|
28924
|
+
rsltValid = { "pos": i }; //always take a possible corrected maskposition into account
|
28925
|
+
}
|
28926
|
+
var newValidPosition = rsltValid.pos || i;
|
28927
|
+
if (getActiveMaskSet()['lastValidPosition'] < newValidPosition)
|
28928
|
+
getActiveMaskSet()['lastValidPosition'] = newValidPosition; //set new position from isValid
|
28929
|
+
}
|
28930
|
+
}
|
28931
|
+
}
|
28932
|
+
//does the input match on a further position?
|
28933
|
+
if (!isMask(maskPos) && !_isValid(maskPos, getActiveMaskSet(), c, strict)) {
|
28934
|
+
var maxForward = seekNext(maskPos) - maskPos;
|
28935
|
+
for (var fw = 0; fw < maxForward; fw++) {
|
28936
|
+
if (_isValid(++maskPos, getActiveMaskSet(), c, strict) !== false)
|
28937
|
+
break;
|
28938
|
+
}
|
28939
|
+
maskForwards.push(activeMasksetIndex);
|
28940
|
+
//console.log('maskforward ' + activeMasksetIndex + " pos " + pos + " maskPos " + maskPos);
|
28941
|
+
}
|
28942
|
+
}
|
28943
|
+
|
28944
|
+
if (getActiveMaskSet()['lastValidPosition'] >= actualLVP || activeMasksetIndex == currentActiveMasksetIndex) {
|
28945
|
+
if (maskPos >= 0 && maskPos < getMaskLength()) {
|
28946
|
+
result = _isValid(maskPos, getActiveMaskSet(), c, strict);
|
28947
|
+
if (result !== false) {
|
28948
|
+
if (result === true) {
|
28949
|
+
result = { "pos": maskPos }; //always take a possible corrected maskposition into account
|
28950
|
+
}
|
28951
|
+
var newValidPosition = result.pos || maskPos;
|
28952
|
+
if (getActiveMaskSet()['lastValidPosition'] < newValidPosition)
|
28953
|
+
getActiveMaskSet()['lastValidPosition'] = newValidPosition; //set new position from isValid
|
28954
|
+
}
|
28955
|
+
//console.log("pos " + pos + " ndx " + activeMasksetIndex + " validate " + getActiveBuffer().join('') + " lv " + getActiveMaskSet()['lastValidPosition']);
|
28956
|
+
results.push({ "activeMasksetIndex": index, "result": result });
|
28957
|
+
}
|
28958
|
+
}
|
28959
|
+
}
|
28960
|
+
});
|
28961
|
+
activeMasksetIndex = currentActiveMasksetIndex; //reset activeMasksetIndex
|
28962
|
+
|
28963
|
+
return PostProcessResults(maskForwards, results); //return results of the multiple mask validations
|
28964
|
+
}
|
28965
|
+
|
28966
|
+
function determineActiveMasksetIndex() {
|
28967
|
+
var currentMasksetIndex = activeMasksetIndex,
|
28968
|
+
highestValid = { "activeMasksetIndex": 0, "lastValidPosition": -1, "next": -1 };
|
28969
|
+
$.each(masksets, function (index, value) {
|
28970
|
+
if (typeof (value) == "object") {
|
28971
|
+
activeMasksetIndex = index;
|
28972
|
+
if (getActiveMaskSet()['lastValidPosition'] > highestValid['lastValidPosition']) {
|
28973
|
+
highestValid["activeMasksetIndex"] = index;
|
28974
|
+
highestValid["lastValidPosition"] = getActiveMaskSet()['lastValidPosition'];
|
28975
|
+
highestValid["next"] = seekNext(getActiveMaskSet()['lastValidPosition']);
|
28976
|
+
} else if (getActiveMaskSet()['lastValidPosition'] == highestValid['lastValidPosition'] &&
|
28977
|
+
(highestValid['next'] == -1 || highestValid['next'] > seekNext(getActiveMaskSet()['lastValidPosition']))) {
|
28978
|
+
highestValid["activeMasksetIndex"] = index;
|
28979
|
+
highestValid["lastValidPosition"] = getActiveMaskSet()['lastValidPosition'];
|
28980
|
+
highestValid["next"] = seekNext(getActiveMaskSet()['lastValidPosition']);
|
28981
|
+
}
|
28982
|
+
}
|
28983
|
+
});
|
28984
|
+
|
28985
|
+
activeMasksetIndex = highestValid["lastValidPosition"] != -1 && masksets[currentMasksetIndex]["lastValidPosition"] == highestValid["lastValidPosition"] ? currentMasksetIndex : highestValid["activeMasksetIndex"];
|
28986
|
+
if (currentMasksetIndex != activeMasksetIndex) {
|
28987
|
+
clearBuffer(getActiveBuffer(), seekNext(highestValid["lastValidPosition"]), getMaskLength());
|
28988
|
+
getActiveMaskSet()["writeOutBuffer"] = true;
|
28989
|
+
}
|
28990
|
+
$el.data('_inputmask')['activeMasksetIndex'] = activeMasksetIndex; //store the activeMasksetIndex
|
28991
|
+
}
|
28992
|
+
|
28993
|
+
function isMask(pos) {
|
28994
|
+
var testPos = determineTestPosition(pos);
|
28995
|
+
var test = getActiveTests()[testPos];
|
28996
|
+
|
28997
|
+
return test != undefined ? test.fn : false;
|
28998
|
+
}
|
28999
|
+
|
29000
|
+
function determineTestPosition(pos) {
|
29001
|
+
return pos % getActiveTests().length;
|
29002
|
+
}
|
29003
|
+
|
29004
|
+
function getMaskLength() {
|
29005
|
+
return opts.getMaskLength(getActiveBufferTemplate(), getActiveMaskSet()['greedy'], getActiveMaskSet()['repeat'], getActiveBuffer(), opts);
|
29006
|
+
}
|
29007
|
+
|
29008
|
+
//pos: from position
|
29009
|
+
|
29010
|
+
function seekNext(pos) {
|
29011
|
+
var maskL = getMaskLength();
|
29012
|
+
if (pos >= maskL) return maskL;
|
29013
|
+
var position = pos;
|
29014
|
+
while (++position < maskL && !isMask(position)) {
|
29015
|
+
}
|
29016
|
+
return position;
|
29017
|
+
}
|
29018
|
+
|
29019
|
+
//pos: from position
|
29020
|
+
|
29021
|
+
function seekPrevious(pos) {
|
29022
|
+
var position = pos;
|
29023
|
+
if (position <= 0) return 0;
|
29024
|
+
|
29025
|
+
while (--position > 0 && !isMask(position)) {
|
29026
|
+
}
|
29027
|
+
;
|
29028
|
+
return position;
|
29029
|
+
}
|
29030
|
+
|
29031
|
+
function setBufferElement(buffer, position, element, autoPrepare) {
|
29032
|
+
if (autoPrepare) position = prepareBuffer(buffer, position);
|
29033
|
+
|
29034
|
+
var test = getActiveTests()[determineTestPosition(position)];
|
29035
|
+
var elem = element;
|
29036
|
+
if (elem != undefined && test != undefined) {
|
29037
|
+
switch (test.casing) {
|
29038
|
+
case "upper":
|
29039
|
+
elem = element.toUpperCase();
|
29040
|
+
break;
|
29041
|
+
case "lower":
|
29042
|
+
elem = element.toLowerCase();
|
29043
|
+
break;
|
29044
|
+
}
|
29045
|
+
}
|
29046
|
+
|
29047
|
+
buffer[position] = elem;
|
29048
|
+
}
|
29049
|
+
|
29050
|
+
function getBufferElement(buffer, position, autoPrepare) {
|
29051
|
+
if (autoPrepare) position = prepareBuffer(buffer, position);
|
29052
|
+
return buffer[position];
|
29053
|
+
}
|
29054
|
+
|
29055
|
+
//needed to handle the non-greedy mask repetitions
|
29056
|
+
|
29057
|
+
function prepareBuffer(buffer, position) {
|
29058
|
+
var j;
|
29059
|
+
while (buffer[position] == undefined && buffer.length < getMaskLength()) {
|
29060
|
+
j = 0;
|
29061
|
+
while (getActiveBufferTemplate()[j] !== undefined) { //add a new buffer
|
29062
|
+
buffer.push(getActiveBufferTemplate()[j++]);
|
29063
|
+
}
|
29064
|
+
}
|
29065
|
+
|
29066
|
+
return position;
|
29067
|
+
}
|
29068
|
+
|
29069
|
+
function writeBuffer(input, buffer, caretPos) {
|
29070
|
+
input._valueSet(buffer.join(''));
|
29071
|
+
if (caretPos != undefined) {
|
29072
|
+
caret(input, caretPos);
|
29073
|
+
}
|
29074
|
+
}
|
29075
|
+
|
29076
|
+
function clearBuffer(buffer, start, end, stripNomasks) {
|
29077
|
+
for (var i = start, maskL = getMaskLength() ; i < end && i < maskL; i++) {
|
29078
|
+
if (stripNomasks === true) {
|
29079
|
+
if (!isMask(i))
|
29080
|
+
setBufferElement(buffer, i, "");
|
29081
|
+
} else
|
29082
|
+
setBufferElement(buffer, i, getBufferElement(getActiveBufferTemplate().slice(), i, true));
|
29083
|
+
}
|
29084
|
+
}
|
29085
|
+
|
29086
|
+
function setReTargetPlaceHolder(buffer, pos) {
|
29087
|
+
var testPos = determineTestPosition(pos);
|
29088
|
+
setBufferElement(buffer, pos, getBufferElement(getActiveBufferTemplate(), testPos));
|
29089
|
+
}
|
29090
|
+
|
29091
|
+
function getPlaceHolder(pos) {
|
29092
|
+
return opts.placeholder.charAt(pos % opts.placeholder.length);
|
29093
|
+
}
|
29094
|
+
|
29095
|
+
function checkVal(input, writeOut, strict, nptvl, intelliCheck) {
|
29096
|
+
var inputValue = nptvl != undefined ? nptvl.slice() : truncateInput(input._valueGet()).split('');
|
29097
|
+
|
29098
|
+
$.each(masksets, function (ndx, ms) {
|
29099
|
+
if (typeof (ms) == "object") {
|
29100
|
+
ms["buffer"] = ms["_buffer"].slice();
|
29101
|
+
ms["lastValidPosition"] = -1;
|
29102
|
+
ms["p"] = -1;
|
29103
|
+
}
|
29104
|
+
});
|
29105
|
+
if (strict !== true) activeMasksetIndex = 0;
|
29106
|
+
if (writeOut) input._valueSet(""); //initial clear
|
29107
|
+
var ml = getMaskLength();
|
29108
|
+
$.each(inputValue, function (ndx, charCode) {
|
29109
|
+
if (intelliCheck === true) {
|
29110
|
+
var p = getActiveMaskSet()["p"], lvp = p == -1 ? p : seekPrevious(p),
|
29111
|
+
pos = lvp == -1 ? ndx : seekNext(lvp);
|
29112
|
+
if ($.inArray(charCode, getActiveBufferTemplate().slice(lvp + 1, pos)) == -1) {
|
29113
|
+
$(input).trigger("_keypress", [true, charCode.charCodeAt(0), writeOut, strict, ndx]);
|
29114
|
+
}
|
29115
|
+
} else {
|
29116
|
+
$(input).trigger("_keypress", [true, charCode.charCodeAt(0), writeOut, strict, ndx]);
|
29117
|
+
}
|
29118
|
+
});
|
29119
|
+
|
29120
|
+
if (strict === true && getActiveMaskSet()["p"] != -1) {
|
29121
|
+
getActiveMaskSet()["lastValidPosition"] = seekPrevious(getActiveMaskSet()["p"]);
|
29122
|
+
}
|
29123
|
+
}
|
29124
|
+
|
29125
|
+
function escapeRegex(str) {
|
29126
|
+
return $.inputmask.escapeRegex.call(this, str);
|
29127
|
+
}
|
29128
|
+
|
29129
|
+
function truncateInput(inputValue) {
|
29130
|
+
return inputValue.replace(new RegExp("(" + escapeRegex(getActiveBufferTemplate().join('')) + ")*$"), "");
|
29131
|
+
}
|
29132
|
+
|
29133
|
+
function clearOptionalTail(input) {
|
29134
|
+
var buffer = getActiveBuffer(), tmpBuffer = buffer.slice(), testPos, pos;
|
29135
|
+
for (var pos = tmpBuffer.length - 1; pos >= 0; pos--) {
|
29136
|
+
var testPos = determineTestPosition(pos);
|
29137
|
+
if (getActiveTests()[testPos].optionality) {
|
29138
|
+
if (!isMask(pos) || !isValid(pos, buffer[pos], true))
|
29139
|
+
tmpBuffer.pop();
|
29140
|
+
else break;
|
29141
|
+
} else break;
|
29142
|
+
}
|
29143
|
+
writeBuffer(input, tmpBuffer);
|
29144
|
+
}
|
29145
|
+
|
29146
|
+
function unmaskedvalue($input, skipDatepickerCheck) {
|
29147
|
+
if (getActiveTests() && (skipDatepickerCheck === true || !$input.hasClass('hasDatepicker'))) {
|
29148
|
+
//checkVal(input, false, true);
|
29149
|
+
var umValue = $.map(getActiveBuffer(), function (element, index) {
|
29150
|
+
return isMask(index) && isValid(index, element, true) ? element : null;
|
29151
|
+
});
|
29152
|
+
var unmaskedValue = (isRTL ? umValue.reverse() : umValue).join('');
|
29153
|
+
return opts.onUnMask != undefined ? opts.onUnMask.call(this, getActiveBuffer().join(''), unmaskedValue) : unmaskedValue;
|
29154
|
+
} else {
|
29155
|
+
return $input[0]._valueGet();
|
29156
|
+
}
|
29157
|
+
}
|
29158
|
+
|
29159
|
+
function TranslatePosition(pos) {
|
29160
|
+
if (isRTL && typeof pos == 'number' && (!opts.greedy || opts.placeholder != "")) {
|
29161
|
+
var bffrLght = getActiveBuffer().length;
|
29162
|
+
pos = bffrLght - pos;
|
29163
|
+
}
|
29164
|
+
return pos;
|
29165
|
+
}
|
29166
|
+
|
29167
|
+
function caret(input, begin, end) {
|
29168
|
+
var npt = input.jquery && input.length > 0 ? input[0] : input, range;
|
29169
|
+
if (typeof begin == 'number') {
|
29170
|
+
begin = TranslatePosition(begin);
|
29171
|
+
end = TranslatePosition(end);
|
29172
|
+
if (!$(input).is(':visible')) {
|
29173
|
+
return;
|
29174
|
+
}
|
29175
|
+
end = (typeof end == 'number') ? end : begin;
|
29176
|
+
npt.scrollLeft = npt.scrollWidth;
|
29177
|
+
if (opts.insertMode == false && begin == end) end++; //set visualization for insert/overwrite mode
|
29178
|
+
if (npt.setSelectionRange) {
|
29179
|
+
npt.selectionStart = begin;
|
29180
|
+
npt.selectionEnd = android ? begin : end;
|
29181
|
+
|
29182
|
+
} else if (npt.createTextRange) {
|
29183
|
+
range = npt.createTextRange();
|
29184
|
+
range.collapse(true);
|
29185
|
+
range.moveEnd('character', end);
|
29186
|
+
range.moveStart('character', begin);
|
29187
|
+
range.select();
|
29188
|
+
}
|
29189
|
+
} else {
|
29190
|
+
if (!$(input).is(':visible')) {
|
29191
|
+
return { "begin": 0, "end": 0 };
|
29192
|
+
}
|
29193
|
+
if (npt.setSelectionRange) {
|
29194
|
+
begin = npt.selectionStart;
|
29195
|
+
end = npt.selectionEnd;
|
29196
|
+
} else if (document.selection && document.selection.createRange) {
|
29197
|
+
range = document.selection.createRange();
|
29198
|
+
begin = 0 - range.duplicate().moveStart('character', -100000);
|
29199
|
+
end = begin + range.text.length;
|
29200
|
+
}
|
29201
|
+
begin = TranslatePosition(begin);
|
29202
|
+
end = TranslatePosition(end);
|
29203
|
+
return { "begin": begin, "end": end };
|
29204
|
+
}
|
29205
|
+
}
|
29206
|
+
|
29207
|
+
function isComplete(buffer) { //return true / false / undefined (repeat *)
|
29208
|
+
if (opts.repeat == "*") return undefined;
|
29209
|
+
var complete = false, highestValidPosition = 0, currentActiveMasksetIndex = activeMasksetIndex;
|
29210
|
+
$.each(masksets, function (ndx, ms) {
|
29211
|
+
if (typeof (ms) == "object") {
|
29212
|
+
activeMasksetIndex = ndx;
|
29213
|
+
var aml = seekPrevious(getMaskLength());
|
29214
|
+
if (ms["lastValidPosition"] >= highestValidPosition && ms["lastValidPosition"] == aml) {
|
29215
|
+
var msComplete = true;
|
29216
|
+
for (var i = 0; i <= aml; i++) {
|
29217
|
+
var mask = isMask(i), testPos = determineTestPosition(i);
|
29218
|
+
if ((mask && (buffer[i] == undefined || buffer[i] == getPlaceHolder(i))) || (!mask && buffer[i] != getActiveBufferTemplate()[testPos])) {
|
29219
|
+
msComplete = false;
|
29220
|
+
break;
|
29221
|
+
}
|
29222
|
+
}
|
29223
|
+
complete = complete || msComplete;
|
29224
|
+
if (complete) //break loop
|
29225
|
+
return false;
|
29226
|
+
}
|
29227
|
+
highestValidPosition = ms["lastValidPosition"];
|
29228
|
+
}
|
29229
|
+
});
|
29230
|
+
activeMasksetIndex = currentActiveMasksetIndex; //reset activeMaskset
|
29231
|
+
return complete;
|
29232
|
+
}
|
29233
|
+
|
29234
|
+
function isSelection(begin, end) {
|
29235
|
+
return isRTL ? (begin - end) > 1 || ((begin - end) == 1 && opts.insertMode) :
|
29236
|
+
(end - begin) > 1 || ((end - begin) == 1 && opts.insertMode);
|
29237
|
+
}
|
29238
|
+
|
29239
|
+
function mask(el) {
|
29240
|
+
$el = $(el);
|
29241
|
+
if (!$el.is(":input")) return;
|
29242
|
+
|
29243
|
+
//store tests & original buffer in the input element - used to get the unmasked value
|
29244
|
+
$el.data('_inputmask', {
|
29245
|
+
'masksets': masksets,
|
29246
|
+
'activeMasksetIndex': activeMasksetIndex,
|
29247
|
+
'opts': opts,
|
29248
|
+
'isRTL': false
|
29249
|
+
});
|
29250
|
+
|
29251
|
+
//show tooltip
|
29252
|
+
if (opts.showTooltip) {
|
29253
|
+
$el.prop("title", getActiveMaskSet()["mask"]);
|
29254
|
+
}
|
29255
|
+
|
29256
|
+
//correct greedy setting if needed
|
29257
|
+
getActiveMaskSet()['greedy'] = getActiveMaskSet()['greedy'] ? getActiveMaskSet()['greedy'] : getActiveMaskSet()['repeat'] == 0;
|
29258
|
+
|
29259
|
+
//handle maxlength attribute
|
29260
|
+
if ($el.attr("maxLength") != null) //only when the attribute is set
|
29261
|
+
{
|
29262
|
+
var maxLength = $el.prop('maxLength');
|
29263
|
+
if (maxLength > -1) { //handle *-repeat
|
29264
|
+
$.each(masksets, function (ndx, ms) {
|
29265
|
+
if (typeof (ms) == "object") {
|
29266
|
+
if (ms["repeat"] == "*") {
|
29267
|
+
ms["repeat"] = maxLength;
|
29268
|
+
}
|
29269
|
+
}
|
29270
|
+
});
|
29271
|
+
}
|
29272
|
+
if (getMaskLength() >= maxLength && maxLength > -1) { //FF sets no defined max length to -1
|
29273
|
+
if (maxLength < getActiveBufferTemplate().length) getActiveBufferTemplate().length = maxLength;
|
29274
|
+
if (getActiveMaskSet()['greedy'] == false) {
|
29275
|
+
getActiveMaskSet()['repeat'] = Math.round(maxLength / getActiveBufferTemplate().length);
|
29276
|
+
}
|
29277
|
+
$el.prop('maxLength', getMaskLength() * 2);
|
29278
|
+
}
|
29279
|
+
}
|
29280
|
+
|
29281
|
+
patchValueProperty(el);
|
29282
|
+
|
29283
|
+
//init vars
|
29284
|
+
var skipKeyPressEvent = false, //Safari 5.1.x - modal dialog fires keypress twice workaround
|
29285
|
+
skipInputEvent = false, //skip when triggered from within inputmask
|
29286
|
+
ignorable = false;
|
29287
|
+
|
29288
|
+
if (opts.numericInput) opts.isNumeric = opts.numericInput;
|
29289
|
+
if (el.dir == "rtl" || (opts.numericInput && opts.rightAlignNumerics) || (opts.isNumeric && opts.rightAlignNumerics))
|
29290
|
+
$el.css("text-align", "right");
|
29291
|
+
|
29292
|
+
if (el.dir == "rtl" || opts.numericInput) {
|
29293
|
+
el.dir = "ltr";
|
29294
|
+
$el.removeAttr("dir");
|
29295
|
+
var inputData = $el.data('_inputmask');
|
29296
|
+
inputData['isRTL'] = true;
|
29297
|
+
$el.data('_inputmask', inputData);
|
29298
|
+
isRTL = true;
|
29299
|
+
}
|
29300
|
+
|
29301
|
+
//unbind all events - to make sure that no other mask will interfere when re-masking
|
29302
|
+
$el.unbind(".inputmask");
|
29303
|
+
$el.removeClass('focus.inputmask');
|
29304
|
+
//bind events
|
29305
|
+
$el.closest('form').bind("submit", function () { //trigger change on submit if any
|
29306
|
+
if (valueOnFocus != getActiveBuffer().join('')) {
|
29307
|
+
$el.change();
|
29308
|
+
}
|
29309
|
+
}).bind('reset', function () {
|
29310
|
+
setTimeout(function () {
|
29311
|
+
$el.trigger("setvalue");
|
29312
|
+
}, 0);
|
29313
|
+
});
|
29314
|
+
$el.bind("mouseenter.inputmask", function () {
|
29315
|
+
var $input = $(this), input = this;
|
29316
|
+
if (!$input.hasClass('focus.inputmask') && opts.showMaskOnHover) {
|
29317
|
+
if (input._valueGet() != getActiveBuffer().join('')) {
|
29318
|
+
writeBuffer(input, getActiveBuffer());
|
29319
|
+
}
|
29320
|
+
}
|
29321
|
+
}).bind("blur.inputmask", function () {
|
29322
|
+
var $input = $(this), input = this, nptValue = input._valueGet(), buffer = getActiveBuffer();
|
29323
|
+
$input.removeClass('focus.inputmask');
|
29324
|
+
if (valueOnFocus != getActiveBuffer().join('')) {
|
29325
|
+
$input.change();
|
29326
|
+
}
|
29327
|
+
if (opts.clearMaskOnLostFocus && nptValue != '') {
|
29328
|
+
if (nptValue == getActiveBufferTemplate().join(''))
|
29329
|
+
input._valueSet('');
|
29330
|
+
else { //clearout optional tail of the mask
|
29331
|
+
clearOptionalTail(input);
|
29332
|
+
}
|
29333
|
+
}
|
29334
|
+
if (isComplete(buffer) === false) {
|
29335
|
+
$input.trigger("incomplete");
|
29336
|
+
if (opts.clearIncomplete) {
|
29337
|
+
$.each(masksets, function (ndx, ms) {
|
29338
|
+
if (typeof (ms) == "object") {
|
29339
|
+
ms["buffer"] = ms["_buffer"].slice();
|
29340
|
+
ms["lastValidPosition"] = -1;
|
29341
|
+
}
|
29342
|
+
});
|
29343
|
+
activeMasksetIndex = 0;
|
29344
|
+
if (opts.clearMaskOnLostFocus)
|
29345
|
+
input._valueSet('');
|
29346
|
+
else {
|
29347
|
+
buffer = getActiveBufferTemplate().slice();
|
29348
|
+
writeBuffer(input, buffer);
|
29349
|
+
}
|
29350
|
+
}
|
29351
|
+
}
|
29352
|
+
}).bind("focus.inputmask", function () {
|
29353
|
+
var $input = $(this), input = this, nptValue = input._valueGet();
|
29354
|
+
if (opts.showMaskOnFocus && !$input.hasClass('focus.inputmask') && (!opts.showMaskOnHover || (opts.showMaskOnHover && nptValue == ''))) {
|
29355
|
+
if (input._valueGet() != getActiveBuffer().join('')) {
|
29356
|
+
writeBuffer(input, getActiveBuffer(), seekNext(getActiveMaskSet()["lastValidPosition"]));
|
29357
|
+
}
|
29358
|
+
}
|
29359
|
+
$input.addClass('focus.inputmask');
|
29360
|
+
valueOnFocus = getActiveBuffer().join('');
|
29361
|
+
}).bind("mouseleave.inputmask", function () {
|
29362
|
+
var $input = $(this), input = this;
|
29363
|
+
if (opts.clearMaskOnLostFocus) {
|
29364
|
+
if (!$input.hasClass('focus.inputmask') && input._valueGet() != $input.attr("placeholder")) {
|
29365
|
+
if (input._valueGet() == getActiveBufferTemplate().join('') || input._valueGet() == '')
|
29366
|
+
input._valueSet('');
|
29367
|
+
else { //clearout optional tail of the mask
|
29368
|
+
clearOptionalTail(input);
|
29369
|
+
}
|
29370
|
+
}
|
29371
|
+
}
|
29372
|
+
}).bind("click.inputmask", function () {
|
29373
|
+
var input = this;
|
29374
|
+
setTimeout(function () {
|
29375
|
+
var selectedCaret = caret(input), buffer = getActiveBuffer();
|
29376
|
+
if (selectedCaret.begin == selectedCaret.end) {
|
29377
|
+
var clickPosition = opts.isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin,
|
29378
|
+
lvp = getActiveMaskSet()["lastValidPosition"],
|
29379
|
+
lastPosition;
|
29380
|
+
if (opts.isNumeric) {
|
29381
|
+
lastPosition = opts.skipRadixDance === false && opts.radixPoint != "" && $.inArray(opts.radixPoint, buffer) != -1 ?
|
29382
|
+
(opts.numericInput ? seekNext($.inArray(opts.radixPoint, buffer)) : $.inArray(opts.radixPoint, buffer)) :
|
29383
|
+
seekNext(lvp);
|
29384
|
+
} else {
|
29385
|
+
lastPosition = seekNext(lvp);
|
29386
|
+
}
|
29387
|
+
if (clickPosition < lastPosition) {
|
29388
|
+
if (isMask(clickPosition))
|
29389
|
+
caret(input, clickPosition);
|
29390
|
+
else caret(input, seekNext(clickPosition));
|
29391
|
+
} else
|
29392
|
+
caret(input, lastPosition);
|
29393
|
+
}
|
29394
|
+
}, 0);
|
29395
|
+
}).bind('dblclick.inputmask', function () {
|
29396
|
+
var input = this;
|
29397
|
+
setTimeout(function () {
|
29398
|
+
caret(input, 0, seekNext(getActiveMaskSet()["lastValidPosition"]));
|
29399
|
+
}, 0);
|
29400
|
+
}).bind(pasteEvent + ".inputmask dragdrop.inputmask drop.inputmask", function (e) {
|
29401
|
+
if (skipInputEvent === true) {
|
29402
|
+
skipInputEvent = false;
|
29403
|
+
return true;
|
29404
|
+
}
|
29405
|
+
var input = this, $input = $(input);
|
29406
|
+
|
29407
|
+
//paste event for IE8 and lower I guess ;-)
|
29408
|
+
if (e.type == "propertychange" && input._valueGet().length <= getMaskLength()) {
|
29409
|
+
return true;
|
29410
|
+
}
|
29411
|
+
setTimeout(function () {
|
29412
|
+
var pasteValue = opts.onBeforePaste != undefined ? opts.onBeforePaste.call(this, input._valueGet()) : input._valueGet();
|
29413
|
+
checkVal(input, true, false, pasteValue.split(''), true);
|
29414
|
+
if (isComplete(getActiveBuffer()) === true)
|
29415
|
+
$input.trigger("complete");
|
29416
|
+
$input.click();
|
29417
|
+
}, 0);
|
29418
|
+
}).bind('setvalue.inputmask', function () {
|
29419
|
+
var input = this;
|
29420
|
+
checkVal(input, true);
|
29421
|
+
valueOnFocus = getActiveBuffer().join('');
|
29422
|
+
if (input._valueGet() == getActiveBufferTemplate().join(''))
|
29423
|
+
input._valueSet('');
|
29424
|
+
}).bind("_keypress.inputmask", keypressEvent //will be skipped be the eventruler
|
29425
|
+
).bind('complete.inputmask', opts.oncomplete
|
29426
|
+
).bind('incomplete.inputmask', opts.onincomplete
|
29427
|
+
).bind('cleared.inputmask', opts.oncleared
|
29428
|
+
).bind("keyup.inputmask", keyupEvent);
|
29429
|
+
|
29430
|
+
if (androidchrome) {
|
29431
|
+
$el.bind("input.inputmask", function (e) {
|
29432
|
+
if (skipInputEvent === true) {
|
29433
|
+
skipInputEvent = false;
|
29434
|
+
return true;
|
29435
|
+
}
|
29436
|
+
var input = this, $input = $(input);
|
29437
|
+
|
29438
|
+
chromeValueOnInput = getActiveBuffer().join('');
|
29439
|
+
checkVal(input, false, false);
|
29440
|
+
writeBuffer(input, getActiveBuffer());
|
29441
|
+
if (isComplete(getActiveBuffer()) === true)
|
29442
|
+
$input.trigger("complete");
|
29443
|
+
$input.click();
|
29444
|
+
});
|
29445
|
+
} else {
|
29446
|
+
$el.bind("keydown.inputmask", keydownEvent
|
29447
|
+
).bind("keypress.inputmask", keypressEvent);
|
29448
|
+
}
|
29449
|
+
|
29450
|
+
//apply mask
|
29451
|
+
checkVal(el, true, false);
|
29452
|
+
valueOnFocus = getActiveBuffer().join('');
|
29453
|
+
// Wrap document.activeElement in a try/catch block since IE9 throw "Unspecified error" if document.activeElement is undefined when we are in an IFrame.
|
29454
|
+
var activeElement;
|
29455
|
+
try {
|
29456
|
+
activeElement = document.activeElement;
|
29457
|
+
} catch (e) {
|
29458
|
+
}
|
29459
|
+
if (activeElement === el) { //position the caret when in focus
|
29460
|
+
$el.addClass('focus.inputmask');
|
29461
|
+
caret(el, seekNext(getActiveMaskSet()["lastValidPosition"]));
|
29462
|
+
} else if (opts.clearMaskOnLostFocus) {
|
29463
|
+
if (getActiveBuffer().join('') == getActiveBufferTemplate().join('')) {
|
29464
|
+
el._valueSet('');
|
29465
|
+
} else {
|
29466
|
+
clearOptionalTail(el);
|
29467
|
+
}
|
29468
|
+
} else {
|
29469
|
+
writeBuffer(el, getActiveBuffer());
|
29470
|
+
}
|
29471
|
+
|
29472
|
+
installEventRuler(el);
|
29473
|
+
|
29474
|
+
//private functions
|
29475
|
+
|
29476
|
+
function installEventRuler(npt) {
|
29477
|
+
var events = $._data(npt).events;
|
29478
|
+
|
29479
|
+
$.each(events, function (eventType, eventHandlers) {
|
29480
|
+
$.each(eventHandlers, function (ndx, eventHandler) {
|
29481
|
+
if (eventHandler.namespace == "inputmask") {
|
29482
|
+
if (eventHandler.type != "setvalue" && eventHandler.type != "_keypress") {
|
29483
|
+
var handler = eventHandler.handler;
|
29484
|
+
eventHandler.handler = function (e) {
|
29485
|
+
if (this.readOnly || this.disabled)
|
29486
|
+
e.preventDefault;
|
29487
|
+
else
|
29488
|
+
return handler.apply(this, arguments);
|
29489
|
+
};
|
29490
|
+
}
|
29491
|
+
}
|
29492
|
+
});
|
29493
|
+
});
|
29494
|
+
}
|
29495
|
+
|
29496
|
+
function patchValueProperty(npt) {
|
29497
|
+
var valueProperty;
|
29498
|
+
if (Object.getOwnPropertyDescriptor)
|
29499
|
+
valueProperty = Object.getOwnPropertyDescriptor(npt, "value");
|
29500
|
+
if (valueProperty && valueProperty.get) {
|
29501
|
+
if (!npt._valueGet) {
|
29502
|
+
var valueGet = valueProperty.get;
|
29503
|
+
var valueSet = valueProperty.set;
|
29504
|
+
npt._valueGet = function () {
|
29505
|
+
return isRTL ? valueGet.call(this).split('').reverse().join('') : valueGet.call(this);
|
29506
|
+
};
|
29507
|
+
npt._valueSet = function (value) {
|
29508
|
+
valueSet.call(this, isRTL ? value.split('').reverse().join('') : value);
|
29509
|
+
};
|
29510
|
+
|
29511
|
+
Object.defineProperty(npt, "value", {
|
29512
|
+
get: function () {
|
29513
|
+
var $self = $(this), inputData = $(this).data('_inputmask'), masksets = inputData['masksets'],
|
29514
|
+
activeMasksetIndex = inputData['activeMasksetIndex'];
|
29515
|
+
return inputData && inputData['opts'].autoUnmask ? $self.inputmask('unmaskedvalue') : valueGet.call(this) != masksets[activeMasksetIndex]['_buffer'].join('') ? valueGet.call(this) : '';
|
29516
|
+
},
|
29517
|
+
set: function (value) {
|
29518
|
+
valueSet.call(this, value);
|
29519
|
+
$(this).triggerHandler('setvalue.inputmask');
|
29520
|
+
}
|
29521
|
+
});
|
29522
|
+
}
|
29523
|
+
} else if (document.__lookupGetter__ && npt.__lookupGetter__("value")) {
|
29524
|
+
if (!npt._valueGet) {
|
29525
|
+
var valueGet = npt.__lookupGetter__("value");
|
29526
|
+
var valueSet = npt.__lookupSetter__("value");
|
29527
|
+
npt._valueGet = function () {
|
29528
|
+
return isRTL ? valueGet.call(this).split('').reverse().join('') : valueGet.call(this);
|
29529
|
+
};
|
29530
|
+
npt._valueSet = function (value) {
|
29531
|
+
valueSet.call(this, isRTL ? value.split('').reverse().join('') : value);
|
29532
|
+
};
|
29533
|
+
|
29534
|
+
npt.__defineGetter__("value", function () {
|
29535
|
+
var $self = $(this), inputData = $(this).data('_inputmask'), masksets = inputData['masksets'],
|
29536
|
+
activeMasksetIndex = inputData['activeMasksetIndex'];
|
29537
|
+
return inputData && inputData['opts'].autoUnmask ? $self.inputmask('unmaskedvalue') : valueGet.call(this) != masksets[activeMasksetIndex]['_buffer'].join('') ? valueGet.call(this) : '';
|
29538
|
+
});
|
29539
|
+
npt.__defineSetter__("value", function (value) {
|
29540
|
+
valueSet.call(this, value);
|
29541
|
+
$(this).triggerHandler('setvalue.inputmask');
|
29542
|
+
});
|
29543
|
+
}
|
29544
|
+
} else {
|
29545
|
+
if (!npt._valueGet) {
|
29546
|
+
npt._valueGet = function () { return isRTL ? this.value.split('').reverse().join('') : this.value; };
|
29547
|
+
npt._valueSet = function (value) { this.value = isRTL ? value.split('').reverse().join('') : value; };
|
29548
|
+
}
|
29549
|
+
if ($.valHooks.text == undefined || $.valHooks.text.inputmaskpatch != true) {
|
29550
|
+
var valueGet = $.valHooks.text && $.valHooks.text.get ? $.valHooks.text.get : function (elem) { return elem.value; };
|
29551
|
+
var valueSet = $.valHooks.text && $.valHooks.text.set ? $.valHooks.text.set : function (elem, value) {
|
29552
|
+
elem.value = value;
|
29553
|
+
return elem;
|
29554
|
+
};
|
29555
|
+
|
29556
|
+
jQuery.extend($.valHooks, {
|
29557
|
+
text: {
|
29558
|
+
get: function (elem) {
|
29559
|
+
var $elem = $(elem);
|
29560
|
+
if ($elem.data('_inputmask')) {
|
29561
|
+
if ($elem.data('_inputmask')['opts'].autoUnmask)
|
29562
|
+
return $elem.inputmask('unmaskedvalue');
|
29563
|
+
else {
|
29564
|
+
var result = valueGet(elem),
|
29565
|
+
inputData = $elem.data('_inputmask'), masksets = inputData['masksets'],
|
29566
|
+
activeMasksetIndex = inputData['activeMasksetIndex'];
|
29567
|
+
return result != masksets[activeMasksetIndex]['_buffer'].join('') ? result : '';
|
29568
|
+
}
|
29569
|
+
} else return valueGet(elem);
|
29570
|
+
},
|
29571
|
+
set: function (elem, value) {
|
29572
|
+
var $elem = $(elem);
|
29573
|
+
var result = valueSet(elem, value);
|
29574
|
+
if ($elem.data('_inputmask')) $elem.triggerHandler('setvalue.inputmask');
|
29575
|
+
return result;
|
29576
|
+
},
|
29577
|
+
inputmaskpatch: true
|
29578
|
+
}
|
29579
|
+
});
|
29580
|
+
}
|
29581
|
+
}
|
29582
|
+
}
|
29583
|
+
|
29584
|
+
//shift chars to left from start to end and put c at end position if defined
|
29585
|
+
|
29586
|
+
function shiftL(start, end, c, maskJumps) {
|
29587
|
+
var buffer = getActiveBuffer();
|
29588
|
+
if (maskJumps !== false) //jumping over nonmask position
|
29589
|
+
while (!isMask(start) && start - 1 >= 0) start--;
|
29590
|
+
for (var i = start; i < end && i < getMaskLength() ; i++) {
|
29591
|
+
if (isMask(i)) {
|
29592
|
+
setReTargetPlaceHolder(buffer, i);
|
29593
|
+
var j = seekNext(i);
|
29594
|
+
var p = getBufferElement(buffer, j);
|
29595
|
+
if (p != getPlaceHolder(j)) {
|
29596
|
+
if (j < getMaskLength() && isValid(i, p, true) !== false && getActiveTests()[determineTestPosition(i)].def == getActiveTests()[determineTestPosition(j)].def) {
|
29597
|
+
setBufferElement(buffer, i, p, true);
|
29598
|
+
} else {
|
29599
|
+
if (isMask(i))
|
29600
|
+
break;
|
29601
|
+
}
|
29602
|
+
}
|
29603
|
+
} else {
|
29604
|
+
setReTargetPlaceHolder(buffer, i);
|
29605
|
+
}
|
29606
|
+
}
|
29607
|
+
if (c != undefined)
|
29608
|
+
setBufferElement(buffer, seekPrevious(end), c);
|
29609
|
+
|
29610
|
+
if (getActiveMaskSet()["greedy"] == false) {
|
29611
|
+
var trbuffer = truncateInput(buffer.join('')).split('');
|
29612
|
+
buffer.length = trbuffer.length;
|
29613
|
+
for (var i = 0, bl = buffer.length; i < bl; i++) {
|
29614
|
+
buffer[i] = trbuffer[i];
|
29615
|
+
}
|
29616
|
+
if (buffer.length == 0) getActiveMaskSet()["buffer"] = getActiveBufferTemplate().slice();
|
29617
|
+
}
|
29618
|
+
return start; //return the used start position
|
29619
|
+
}
|
29620
|
+
|
29621
|
+
function shiftR(start, end, c) {
|
29622
|
+
var buffer = getActiveBuffer();
|
29623
|
+
if (getBufferElement(buffer, start, true) != getPlaceHolder(start)) {
|
29624
|
+
for (var i = seekPrevious(end) ; i > start && i >= 0; i--) {
|
29625
|
+
if (isMask(i)) {
|
29626
|
+
var j = seekPrevious(i);
|
29627
|
+
var t = getBufferElement(buffer, j);
|
29628
|
+
if (t != getPlaceHolder(j)) {
|
29629
|
+
if (isValid(j, t, true) !== false && getActiveTests()[determineTestPosition(i)].def == getActiveTests()[determineTestPosition(j)].def) {
|
29630
|
+
setBufferElement(buffer, i, t, true);
|
29631
|
+
setReTargetPlaceHolder(buffer, j);
|
29632
|
+
} //else break;
|
29633
|
+
}
|
29634
|
+
} else
|
29635
|
+
setReTargetPlaceHolder(buffer, i);
|
29636
|
+
}
|
29637
|
+
}
|
29638
|
+
if (c != undefined && getBufferElement(buffer, start) == getPlaceHolder(start))
|
29639
|
+
setBufferElement(buffer, start, c);
|
29640
|
+
var lengthBefore = buffer.length;
|
29641
|
+
if (getActiveMaskSet()["greedy"] == false) {
|
29642
|
+
var trbuffer = truncateInput(buffer.join('')).split('');
|
29643
|
+
buffer.length = trbuffer.length;
|
29644
|
+
for (var i = 0, bl = buffer.length; i < bl; i++) {
|
29645
|
+
buffer[i] = trbuffer[i];
|
29646
|
+
}
|
29647
|
+
if (buffer.length == 0) getActiveMaskSet()["buffer"] = getActiveBufferTemplate().slice();
|
29648
|
+
}
|
29649
|
+
return end - (lengthBefore - buffer.length); //return new start position
|
29650
|
+
}
|
29651
|
+
|
29652
|
+
;
|
29653
|
+
|
29654
|
+
|
29655
|
+
function HandleRemove(input, k, pos) {
|
29656
|
+
if (opts.numericInput || isRTL) {
|
29657
|
+
switch (k) {
|
29658
|
+
case opts.keyCode.BACKSPACE:
|
29659
|
+
k = opts.keyCode.DELETE;
|
29660
|
+
break;
|
29661
|
+
case opts.keyCode.DELETE:
|
29662
|
+
k = opts.keyCode.BACKSPACE;
|
29663
|
+
break;
|
29664
|
+
}
|
29665
|
+
if (isRTL) {
|
29666
|
+
var pend = pos.end;
|
29667
|
+
pos.end = pos.begin;
|
29668
|
+
pos.begin = pend;
|
29669
|
+
}
|
29670
|
+
}
|
29671
|
+
|
29672
|
+
var isSelection = true;
|
29673
|
+
if (pos.begin == pos.end) {
|
29674
|
+
var posBegin = k == opts.keyCode.BACKSPACE ? pos.begin - 1 : pos.begin;
|
29675
|
+
if (opts.isNumeric && opts.radixPoint != "" && getActiveBuffer()[posBegin] == opts.radixPoint) {
|
29676
|
+
pos.begin = (getActiveBuffer().length - 1 == posBegin) /* radixPoint is latest? delete it */ ? pos.begin : k == opts.keyCode.BACKSPACE ? posBegin : seekNext(posBegin);
|
29677
|
+
pos.end = pos.begin;
|
29678
|
+
}
|
29679
|
+
isSelection = false;
|
29680
|
+
if (k == opts.keyCode.BACKSPACE)
|
29681
|
+
pos.begin--;
|
29682
|
+
else if (k == opts.keyCode.DELETE)
|
29683
|
+
pos.end++;
|
29684
|
+
} else if (pos.end - pos.begin == 1 && !opts.insertMode) {
|
29685
|
+
isSelection = false;
|
29686
|
+
if (k == opts.keyCode.BACKSPACE)
|
29687
|
+
pos.begin--;
|
29688
|
+
}
|
29689
|
+
|
29690
|
+
clearBuffer(getActiveBuffer(), pos.begin, pos.end);
|
29691
|
+
|
29692
|
+
var ml = getMaskLength();
|
29693
|
+
if (opts.greedy == false) {
|
29694
|
+
shiftL(pos.begin, ml, undefined, !isRTL && (k == opts.keyCode.BACKSPACE && !isSelection));
|
29695
|
+
} else {
|
29696
|
+
var newpos = pos.begin;
|
29697
|
+
for (var i = pos.begin; i < pos.end; i++) { //seeknext to skip placeholders at start in selection
|
29698
|
+
if (isMask(i) || !isSelection)
|
29699
|
+
newpos = shiftL(pos.begin, ml, undefined, !isRTL && (k == opts.keyCode.BACKSPACE && !isSelection));
|
29700
|
+
}
|
29701
|
+
if (!isSelection) pos.begin = newpos;
|
29702
|
+
}
|
29703
|
+
var firstMaskPos = seekNext(-1);
|
29704
|
+
clearBuffer(getActiveBuffer(), pos.begin, pos.end, true);
|
29705
|
+
checkVal(input, false, masksets[1] == undefined || firstMaskPos >= pos.end, getActiveBuffer());
|
29706
|
+
if (getActiveMaskSet()['lastValidPosition'] < firstMaskPos) {
|
29707
|
+
getActiveMaskSet()["lastValidPosition"] = -1;
|
29708
|
+
getActiveMaskSet()["p"] = firstMaskPos;
|
29709
|
+
} else {
|
29710
|
+
getActiveMaskSet()["p"] = pos.begin;
|
29711
|
+
}
|
29712
|
+
}
|
29713
|
+
|
29714
|
+
function keydownEvent(e) {
|
29715
|
+
//Safari 5.1.x - modal dialog fires keypress twice workaround
|
29716
|
+
skipKeyPressEvent = false;
|
29717
|
+
var input = this, $input = $(input), k = e.keyCode, pos = caret(input);
|
29718
|
+
|
29719
|
+
//backspace, delete, and escape get special treatment
|
29720
|
+
if (k == opts.keyCode.BACKSPACE || k == opts.keyCode.DELETE || (iphone && k == 127) || e.ctrlKey && k == 88) { //backspace/delete
|
29721
|
+
e.preventDefault(); //stop default action but allow propagation
|
29722
|
+
if (k == 88) valueOnFocus = getActiveBuffer().join('');
|
29723
|
+
HandleRemove(input, k, pos);
|
29724
|
+
determineActiveMasksetIndex();
|
29725
|
+
writeBuffer(input, getActiveBuffer(), getActiveMaskSet()["p"]);
|
29726
|
+
if (input._valueGet() == getActiveBufferTemplate().join(''))
|
29727
|
+
$input.trigger('cleared');
|
29728
|
+
|
29729
|
+
if (opts.showTooltip) { //update tooltip
|
29730
|
+
$input.prop("title", getActiveMaskSet()["mask"]);
|
29731
|
+
}
|
29732
|
+
} else if (k == opts.keyCode.END || k == opts.keyCode.PAGE_DOWN) { //when END or PAGE_DOWN pressed set position at lastmatch
|
29733
|
+
setTimeout(function () {
|
29734
|
+
var caretPos = seekNext(getActiveMaskSet()["lastValidPosition"]);
|
29735
|
+
if (!opts.insertMode && caretPos == getMaskLength() && !e.shiftKey) caretPos--;
|
29736
|
+
caret(input, e.shiftKey ? pos.begin : caretPos, caretPos);
|
29737
|
+
}, 0);
|
29738
|
+
} else if ((k == opts.keyCode.HOME && !e.shiftKey) || k == opts.keyCode.PAGE_UP) { //Home or page_up
|
29739
|
+
caret(input, 0, e.shiftKey ? pos.begin : 0);
|
29740
|
+
} else if (k == opts.keyCode.ESCAPE || (k == 90 && e.ctrlKey)) { //escape && undo
|
29741
|
+
checkVal(input, true, false, valueOnFocus.split(''));
|
29742
|
+
$input.click();
|
29743
|
+
} else if (k == opts.keyCode.INSERT && !(e.shiftKey || e.ctrlKey)) { //insert
|
29744
|
+
opts.insertMode = !opts.insertMode;
|
29745
|
+
caret(input, !opts.insertMode && pos.begin == getMaskLength() ? pos.begin - 1 : pos.begin);
|
29746
|
+
} else if (opts.insertMode == false && !e.shiftKey) {
|
29747
|
+
if (k == opts.keyCode.RIGHT) {
|
29748
|
+
setTimeout(function () {
|
29749
|
+
var caretPos = caret(input);
|
29750
|
+
caret(input, caretPos.begin);
|
29751
|
+
}, 0);
|
29752
|
+
} else if (k == opts.keyCode.LEFT) {
|
29753
|
+
setTimeout(function () {
|
29754
|
+
var caretPos = caret(input);
|
29755
|
+
caret(input, caretPos.begin - 1);
|
29756
|
+
}, 0);
|
29757
|
+
}
|
29758
|
+
}
|
29759
|
+
|
29760
|
+
var currentCaretPos = caret(input);
|
29761
|
+
if (opts.onKeyDown.call(this, e, getActiveBuffer(), opts) === true) //extra stuff to execute on keydown
|
29762
|
+
caret(input, currentCaretPos.begin, currentCaretPos.end);
|
29763
|
+
ignorable = $.inArray(k, opts.ignorables) != -1;
|
29764
|
+
}
|
29765
|
+
|
29766
|
+
|
29767
|
+
function keypressEvent(e, checkval, k, writeOut, strict, ndx) {
|
29768
|
+
//Safari 5.1.x - modal dialog fires keypress twice workaround
|
29769
|
+
if (k == undefined && skipKeyPressEvent) return false;
|
29770
|
+
skipKeyPressEvent = true;
|
29771
|
+
|
29772
|
+
var input = this, $input = $(input);
|
29773
|
+
|
29774
|
+
e = e || window.event;
|
29775
|
+
var k = k || e.which || e.charCode || e.keyCode;
|
29776
|
+
|
29777
|
+
if ((!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || ignorable)) && checkval !== true) {
|
29778
|
+
return true;
|
29779
|
+
} else {
|
29780
|
+
if (k) {
|
29781
|
+
//special treat the decimal separator
|
29782
|
+
if (checkval !== true && k == 46 && e.shiftKey == false && opts.radixPoint == ",") k = 44;
|
29783
|
+
|
29784
|
+
var pos, results, result, c = String.fromCharCode(k);
|
29785
|
+
if (checkval) {
|
29786
|
+
var pcaret = strict ? ndx : getActiveMaskSet()["lastValidPosition"] + 1;
|
29787
|
+
pos = { begin: pcaret, end: pcaret };
|
29788
|
+
} else {
|
29789
|
+
pos = caret(input);
|
29790
|
+
}
|
29791
|
+
|
29792
|
+
//should we clear a possible selection??
|
29793
|
+
var isSlctn = isSelection(pos.begin, pos.end), redetermineLVP = false,
|
29794
|
+
initialIndex = activeMasksetIndex;
|
29795
|
+
if (isSlctn) {
|
29796
|
+
activeMasksetIndex = initialIndex;
|
29797
|
+
$.each(masksets, function (ndx, lmnt) { //init undobuffer for recovery when not valid
|
29798
|
+
if (typeof (lmnt) == "object") {
|
29799
|
+
activeMasksetIndex = ndx;
|
29800
|
+
getActiveMaskSet()["undoBuffer"] = getActiveBuffer().join('');
|
29801
|
+
}
|
29802
|
+
});
|
29803
|
+
HandleRemove(input, opts.keyCode.DELETE, pos);
|
29804
|
+
if (!opts.insertMode) { //preserve some space
|
29805
|
+
$.each(masksets, function (ndx, lmnt) {
|
29806
|
+
if (typeof (lmnt) == "object") {
|
29807
|
+
activeMasksetIndex = ndx;
|
29808
|
+
shiftR(pos.begin, getMaskLength());
|
29809
|
+
getActiveMaskSet()["lastValidPosition"] = seekNext(getActiveMaskSet()["lastValidPosition"]);
|
29810
|
+
}
|
29811
|
+
});
|
29812
|
+
}
|
29813
|
+
activeMasksetIndex = initialIndex; //restore index
|
29814
|
+
}
|
29815
|
+
|
29816
|
+
var radixPosition = getActiveBuffer().join('').indexOf(opts.radixPoint);
|
29817
|
+
if (opts.isNumeric && checkval !== true && radixPosition != -1) {
|
29818
|
+
if (opts.greedy && pos.begin <= radixPosition) {
|
29819
|
+
pos.begin = seekPrevious(pos.begin);
|
29820
|
+
pos.end = pos.begin;
|
29821
|
+
} else if (c == opts.radixPoint) {
|
29822
|
+
pos.begin = radixPosition;
|
29823
|
+
pos.end = pos.begin;
|
29824
|
+
}
|
29825
|
+
}
|
29826
|
+
|
29827
|
+
|
29828
|
+
var p = pos.begin;
|
29829
|
+
results = isValid(p, c, strict);
|
29830
|
+
if (strict === true) results = [{ "activeMasksetIndex": activeMasksetIndex, "result": results }];
|
29831
|
+
var minimalForwardPosition = -1;
|
29832
|
+
$.each(results, function (index, result) {
|
29833
|
+
activeMasksetIndex = result["activeMasksetIndex"];
|
29834
|
+
getActiveMaskSet()["writeOutBuffer"] = true;
|
29835
|
+
var np = result["result"];
|
29836
|
+
if (np !== false) {
|
29837
|
+
var refresh = false, buffer = getActiveBuffer();
|
29838
|
+
if (np !== true) {
|
29839
|
+
refresh = np["refresh"]; //only rewrite buffer from isValid
|
29840
|
+
p = np.pos != undefined ? np.pos : p; //set new position from isValid
|
29841
|
+
c = np.c != undefined ? np.c : c; //set new char from isValid
|
29842
|
+
}
|
29843
|
+
if (refresh !== true) {
|
29844
|
+
if (opts.insertMode == true) {
|
29845
|
+
var lastUnmaskedPosition = getMaskLength();
|
29846
|
+
var bfrClone = buffer.slice();
|
29847
|
+
while (getBufferElement(bfrClone, lastUnmaskedPosition, true) != getPlaceHolder(lastUnmaskedPosition) && lastUnmaskedPosition >= p) {
|
29848
|
+
lastUnmaskedPosition = lastUnmaskedPosition == 0 ? -1 : seekPrevious(lastUnmaskedPosition);
|
29849
|
+
}
|
29850
|
+
if (lastUnmaskedPosition >= p) {
|
29851
|
+
shiftR(p, getMaskLength(), c);
|
29852
|
+
//shift the lvp if needed
|
29853
|
+
var lvp = getActiveMaskSet()["lastValidPosition"], nlvp = seekNext(lvp);
|
29854
|
+
if (nlvp != getMaskLength() && lvp >= p && (getBufferElement(getActiveBuffer(), nlvp, true) != getPlaceHolder(nlvp))) {
|
29855
|
+
getActiveMaskSet()["lastValidPosition"] = nlvp;
|
29856
|
+
}
|
29857
|
+
} else getActiveMaskSet()["writeOutBuffer"] = false;
|
29858
|
+
} else setBufferElement(buffer, p, c, true);
|
29859
|
+
if (minimalForwardPosition == -1 || minimalForwardPosition > seekNext(p)) {
|
29860
|
+
minimalForwardPosition = seekNext(p);
|
29861
|
+
}
|
29862
|
+
} else if (!strict) {
|
29863
|
+
var nextPos = p < getMaskLength() ? p + 1 : p;
|
29864
|
+
if (minimalForwardPosition == -1 || minimalForwardPosition > nextPos) {
|
29865
|
+
minimalForwardPosition = nextPos;
|
29866
|
+
}
|
29867
|
+
}
|
29868
|
+
if (minimalForwardPosition > getActiveMaskSet()["p"])
|
29869
|
+
getActiveMaskSet()["p"] = minimalForwardPosition; //needed for checkval strict
|
29870
|
+
}
|
29871
|
+
});
|
29872
|
+
|
29873
|
+
if (strict !== true) {
|
29874
|
+
activeMasksetIndex = initialIndex;
|
29875
|
+
determineActiveMasksetIndex();
|
29876
|
+
}
|
29877
|
+
if (writeOut !== false) {
|
29878
|
+
$.each(results, function (ndx, rslt) {
|
29879
|
+
if (rslt["activeMasksetIndex"] == activeMasksetIndex) {
|
29880
|
+
result = rslt;
|
29881
|
+
return false;
|
29882
|
+
}
|
29883
|
+
});
|
29884
|
+
if (result != undefined) {
|
29885
|
+
var self = this;
|
29886
|
+
setTimeout(function () { opts.onKeyValidation.call(self, result["result"], opts); }, 0);
|
29887
|
+
if (getActiveMaskSet()["writeOutBuffer"] && result["result"] !== false) {
|
29888
|
+
var buffer = getActiveBuffer();
|
29889
|
+
|
29890
|
+
var newCaretPosition;
|
29891
|
+
if (checkval) {
|
29892
|
+
newCaretPosition = undefined;
|
29893
|
+
} else if (opts.numericInput) {
|
29894
|
+
if (p > radixPosition) {
|
29895
|
+
newCaretPosition = seekPrevious(minimalForwardPosition);
|
29896
|
+
} else if (c == opts.radixPoint) {
|
29897
|
+
newCaretPosition = minimalForwardPosition - 1;
|
29898
|
+
} else newCaretPosition = seekPrevious(minimalForwardPosition - 1);
|
29899
|
+
} else {
|
29900
|
+
newCaretPosition = minimalForwardPosition;
|
29901
|
+
}
|
29902
|
+
|
29903
|
+
writeBuffer(input, buffer, newCaretPosition);
|
29904
|
+
if (checkval !== true) {
|
29905
|
+
setTimeout(function () { //timeout needed for IE
|
29906
|
+
if (isComplete(buffer) === true)
|
29907
|
+
$input.trigger("complete");
|
29908
|
+
skipInputEvent = true;
|
29909
|
+
$input.trigger("input");
|
29910
|
+
}, 0);
|
29911
|
+
}
|
29912
|
+
} else if (isSlctn) {
|
29913
|
+
getActiveMaskSet()["buffer"] = getActiveMaskSet()["undoBuffer"].split('');
|
29914
|
+
}
|
29915
|
+
}
|
29916
|
+
}
|
29917
|
+
|
29918
|
+
if (opts.showTooltip) { //update tooltip
|
29919
|
+
$input.prop("title", getActiveMaskSet()["mask"]);
|
29920
|
+
}
|
29921
|
+
e.preventDefault();
|
29922
|
+
}
|
29923
|
+
}
|
29924
|
+
}
|
29925
|
+
|
29926
|
+
function keyupEvent(e) {
|
29927
|
+
var $input = $(this), input = this, k = e.keyCode, buffer = getActiveBuffer();
|
29928
|
+
|
29929
|
+
if (androidchrome && k == opts.keyCode.BACKSPACE) {
|
29930
|
+
if (chromeValueOnInput == input._valueGet())
|
29931
|
+
keydownEvent.call(this, e);
|
29932
|
+
}
|
29933
|
+
|
29934
|
+
opts.onKeyUp.call(this, e, buffer, opts); //extra stuff to execute on keyup
|
29935
|
+
if (k == opts.keyCode.TAB && opts.showMaskOnFocus) {
|
29936
|
+
if ($input.hasClass('focus.inputmask') && input._valueGet().length == 0) {
|
29937
|
+
buffer = getActiveBufferTemplate().slice();
|
29938
|
+
writeBuffer(input, buffer);
|
29939
|
+
caret(input, 0);
|
29940
|
+
valueOnFocus = getActiveBuffer().join('');
|
29941
|
+
} else {
|
29942
|
+
writeBuffer(input, buffer);
|
29943
|
+
if (buffer.join('') == getActiveBufferTemplate().join('') && $.inArray(opts.radixPoint, buffer) != -1) {
|
29944
|
+
caret(input, TranslatePosition(0));
|
29945
|
+
$input.click();
|
29946
|
+
} else
|
29947
|
+
caret(input, TranslatePosition(0), TranslatePosition(getMaskLength()));
|
29948
|
+
}
|
29949
|
+
}
|
29950
|
+
}
|
29951
|
+
}
|
29952
|
+
|
29953
|
+
return {
|
29954
|
+
isComplete: function (buffer) {
|
29955
|
+
return isComplete(buffer);
|
29956
|
+
},
|
29957
|
+
unmaskedvalue: function ($input, skipDatepickerCheck) {
|
29958
|
+
isRTL = $input.data('_inputmask')['isRTL'];
|
29959
|
+
return unmaskedvalue($input, skipDatepickerCheck);
|
29960
|
+
},
|
29961
|
+
mask: function (el) {
|
29962
|
+
mask(el);
|
29963
|
+
}
|
29964
|
+
};
|
29965
|
+
};
|
29966
|
+
|
29967
|
+
$.inputmask = {
|
29968
|
+
//options default
|
29969
|
+
defaults: {
|
29970
|
+
placeholder: "_",
|
29971
|
+
optionalmarker: { start: "[", end: "]" },
|
29972
|
+
quantifiermarker: { start: "{", end: "}" },
|
29973
|
+
groupmarker: { start: "(", end: ")" },
|
29974
|
+
escapeChar: "\\",
|
29975
|
+
mask: null,
|
29976
|
+
oncomplete: $.noop, //executes when the mask is complete
|
29977
|
+
onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
|
29978
|
+
oncleared: $.noop, //executes when the mask is cleared
|
29979
|
+
repeat: 0, //repetitions of the mask: * ~ forever, otherwise specify an integer
|
29980
|
+
greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
|
29981
|
+
autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
|
29982
|
+
clearMaskOnLostFocus: true,
|
29983
|
+
insertMode: true, //insert the input or overwrite the input
|
29984
|
+
clearIncomplete: false, //clear the incomplete input on blur
|
29985
|
+
aliases: {}, //aliases definitions => see jquery.inputmask.extensions.js
|
29986
|
+
onKeyUp: $.noop, //override to implement autocomplete on certain keys for example
|
29987
|
+
onKeyDown: $.noop, //override to implement autocomplete on certain keys for example
|
29988
|
+
onBeforePaste: undefined, //executes before masking the pasted value to allow preprocessing of the pasted value. args => pastedValue => return processedValue
|
29989
|
+
onUnMask: undefined, //executes after unmasking to allow postprocessing of the unmaskedvalue. args => maskedValue, unmaskedValue
|
29990
|
+
showMaskOnFocus: true, //show the mask-placeholder when the input has focus
|
29991
|
+
showMaskOnHover: true, //show the mask-placeholder when hovering the empty input
|
29992
|
+
onKeyValidation: $.noop, //executes on every key-press with the result of isValid. Params: result, opts
|
29993
|
+
skipOptionalPartCharacter: " ", //a character which can be used to skip an optional part of a mask
|
29994
|
+
showTooltip: false, //show the activemask as tooltip
|
29995
|
+
numericInput: false, //numericInput input direction style (input shifts to the left while holding the caret position)
|
29996
|
+
//numeric basic properties
|
29997
|
+
isNumeric: false, //enable numeric features
|
29998
|
+
radixPoint: "", //".", // | ","
|
29999
|
+
skipRadixDance: false, //disable radixpoint caret positioning
|
30000
|
+
rightAlignNumerics: true, //align numerics to the right
|
30001
|
+
//numeric basic properties
|
30002
|
+
definitions: {
|
30003
|
+
'9': {
|
30004
|
+
validator: "[0-9]",
|
30005
|
+
cardinality: 1
|
30006
|
+
},
|
30007
|
+
'a': {
|
30008
|
+
validator: "[A-Za-z\u0410-\u044F\u0401\u0451]",
|
30009
|
+
cardinality: 1
|
30010
|
+
},
|
30011
|
+
'*': {
|
30012
|
+
validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
|
30013
|
+
cardinality: 1
|
30014
|
+
}
|
30015
|
+
},
|
30016
|
+
keyCode: {
|
30017
|
+
ALT: 18, BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, COMMAND: 91, COMMAND_LEFT: 91, COMMAND_RIGHT: 93, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, MENU: 93, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108,
|
30018
|
+
NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38, WINDOWS: 91
|
30019
|
+
},
|
30020
|
+
//specify keycodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
|
30021
|
+
ignorables: [8, 9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
|
30022
|
+
getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) {
|
30023
|
+
var calculatedLength = buffer.length;
|
30024
|
+
if (!greedy) {
|
30025
|
+
if (repeat == "*") {
|
30026
|
+
calculatedLength = currentBuffer.length + 1;
|
30027
|
+
} else if (repeat > 1) {
|
30028
|
+
calculatedLength += (buffer.length * (repeat - 1));
|
30029
|
+
}
|
30030
|
+
}
|
30031
|
+
return calculatedLength;
|
30032
|
+
}
|
30033
|
+
},
|
30034
|
+
escapeRegex: function (str) {
|
30035
|
+
var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'];
|
30036
|
+
return str.replace(new RegExp('(\\' + specials.join('|\\') + ')', 'gim'), '\\$1');
|
30037
|
+
},
|
30038
|
+
format: function (value, opts) {
|
30039
|
+
|
30040
|
+
}
|
30041
|
+
};
|
30042
|
+
|
30043
|
+
$.fn.inputmask = function (fn, options) {
|
30044
|
+
var opts = $.extend(true, {}, $.inputmask.defaults, options),
|
30045
|
+
masksets,
|
30046
|
+
activeMasksetIndex = 0;
|
30047
|
+
|
30048
|
+
if (typeof fn === "string") {
|
30049
|
+
switch (fn) {
|
30050
|
+
case "mask":
|
30051
|
+
//resolve possible aliases given by options
|
30052
|
+
resolveAlias(opts.alias, options, opts);
|
30053
|
+
masksets = generateMaskSets(opts);
|
30054
|
+
if (masksets.length == 0) { return this; }
|
30055
|
+
|
30056
|
+
return this.each(function () {
|
30057
|
+
maskScope($.extend(true, {}, masksets), 0, opts).mask(this);
|
30058
|
+
});
|
30059
|
+
case "unmaskedvalue":
|
30060
|
+
var $input = $(this), input = this;
|
30061
|
+
if ($input.data('_inputmask')) {
|
30062
|
+
masksets = $input.data('_inputmask')['masksets'];
|
30063
|
+
activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
|
30064
|
+
opts = $input.data('_inputmask')['opts'];
|
30065
|
+
return maskScope(masksets, activeMasksetIndex, opts).unmaskedvalue($input);
|
30066
|
+
} else return $input.val();
|
30067
|
+
case "remove":
|
30068
|
+
return this.each(function () {
|
30069
|
+
var $input = $(this), input = this;
|
30070
|
+
if ($input.data('_inputmask')) {
|
30071
|
+
masksets = $input.data('_inputmask')['masksets'];
|
30072
|
+
activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
|
30073
|
+
opts = $input.data('_inputmask')['opts'];
|
30074
|
+
//writeout the unmaskedvalue
|
30075
|
+
input._valueSet(maskScope(masksets, activeMasksetIndex, opts).unmaskedvalue($input, true));
|
30076
|
+
//clear data
|
30077
|
+
$input.removeData('_inputmask');
|
30078
|
+
//unbind all events
|
30079
|
+
$input.unbind(".inputmask");
|
30080
|
+
$input.removeClass('focus.inputmask');
|
30081
|
+
//restore the value property
|
30082
|
+
var valueProperty;
|
30083
|
+
if (Object.getOwnPropertyDescriptor)
|
30084
|
+
valueProperty = Object.getOwnPropertyDescriptor(input, "value");
|
30085
|
+
if (valueProperty && valueProperty.get) {
|
30086
|
+
if (input._valueGet) {
|
30087
|
+
Object.defineProperty(input, "value", {
|
30088
|
+
get: input._valueGet,
|
30089
|
+
set: input._valueSet
|
30090
|
+
});
|
30091
|
+
}
|
30092
|
+
} else if (document.__lookupGetter__ && input.__lookupGetter__("value")) {
|
30093
|
+
if (input._valueGet) {
|
30094
|
+
input.__defineGetter__("value", input._valueGet);
|
30095
|
+
input.__defineSetter__("value", input._valueSet);
|
30096
|
+
}
|
30097
|
+
}
|
30098
|
+
try { //try catch needed for IE7 as it does not supports deleting fns
|
30099
|
+
delete input._valueGet;
|
30100
|
+
delete input._valueSet;
|
30101
|
+
} catch (e) {
|
30102
|
+
input._valueGet = undefined;
|
30103
|
+
input._valueSet = undefined;
|
30104
|
+
|
30105
|
+
}
|
30106
|
+
}
|
30107
|
+
});
|
30108
|
+
break;
|
30109
|
+
case "getemptymask": //return the default (empty) mask value, usefull for setting the default value in validation
|
30110
|
+
if (this.data('_inputmask')) {
|
30111
|
+
masksets = this.data('_inputmask')['masksets'];
|
30112
|
+
activeMasksetIndex = this.data('_inputmask')['activeMasksetIndex'];
|
30113
|
+
return masksets[activeMasksetIndex]['_buffer'].join('');
|
30114
|
+
}
|
30115
|
+
else return "";
|
30116
|
+
case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
|
30117
|
+
return this.data('_inputmask') ? !this.data('_inputmask')['opts'].autoUnmask : false;
|
30118
|
+
case "isComplete":
|
30119
|
+
masksets = this.data('_inputmask')['masksets'];
|
30120
|
+
activeMasksetIndex = this.data('_inputmask')['activeMasksetIndex'];
|
30121
|
+
opts = this.data('_inputmask')['opts'];
|
30122
|
+
return maskScope(masksets, activeMasksetIndex, opts).isComplete(this[0]._valueGet().split(''));
|
30123
|
+
case "getmetadata": //return mask metadata if exists
|
30124
|
+
if (this.data('_inputmask')) {
|
30125
|
+
masksets = this.data('_inputmask')['masksets'];
|
30126
|
+
activeMasksetIndex = this.data('_inputmask')['activeMasksetIndex'];
|
30127
|
+
return masksets[activeMasksetIndex]['metadata'];
|
30128
|
+
}
|
30129
|
+
else return undefined;
|
30130
|
+
default:
|
30131
|
+
//check if the fn is an alias
|
30132
|
+
if (!resolveAlias(fn, options, opts)) {
|
30133
|
+
//maybe fn is a mask so we try
|
30134
|
+
//set mask
|
30135
|
+
opts.mask = fn;
|
30136
|
+
}
|
30137
|
+
masksets = generateMaskSets(opts);
|
30138
|
+
if (masksets.length == 0) { return this; }
|
30139
|
+
return this.each(function () {
|
30140
|
+
maskScope($.extend(true, {}, masksets), activeMasksetIndex, opts).mask(this);
|
30141
|
+
});
|
30142
|
+
|
30143
|
+
break;
|
30144
|
+
}
|
30145
|
+
} else if (typeof fn == "object") {
|
30146
|
+
opts = $.extend(true, {}, $.inputmask.defaults, fn);
|
30147
|
+
|
30148
|
+
resolveAlias(opts.alias, fn, opts); //resolve aliases
|
30149
|
+
masksets = generateMaskSets(opts);
|
30150
|
+
if (masksets.length == 0) { return this; }
|
30151
|
+
return this.each(function () {
|
30152
|
+
maskScope($.extend(true, {}, masksets), activeMasksetIndex, opts).mask(this);
|
30153
|
+
});
|
30154
|
+
} else if (fn == undefined) {
|
30155
|
+
//look for data-inputmask atribute - the attribute should only contain optipns
|
30156
|
+
return this.each(function () {
|
30157
|
+
var attrOptions = $(this).attr("data-inputmask");
|
30158
|
+
if (attrOptions && attrOptions != "") {
|
30159
|
+
try {
|
30160
|
+
attrOptions = attrOptions.replace(new RegExp("'", "g"), '"');
|
30161
|
+
var dataoptions = $.parseJSON("{" + attrOptions + "}");
|
30162
|
+
$.extend(true, dataoptions, options);
|
30163
|
+
opts = $.extend(true, {}, $.inputmask.defaults, dataoptions);
|
30164
|
+
resolveAlias(opts.alias, dataoptions, opts);
|
30165
|
+
opts.alias = undefined;
|
30166
|
+
$(this).inputmask(opts);
|
30167
|
+
} catch (ex) { } //need a more relax parseJSON
|
30168
|
+
}
|
30169
|
+
});
|
30170
|
+
}
|
30171
|
+
};
|
30172
|
+
}
|
30173
|
+
})(jQuery);
|
30174
|
+
|
30175
|
+
});
|
30176
|
+
require.register("ened/vendor/assets/javascripts/jquery/inputmask.extensions.js", function(exports, require, module){
|
30177
|
+
/*
|
30178
|
+
Input Mask plugin extensions
|
30179
|
+
http://github.com/RobinHerbots/jquery.inputmask
|
30180
|
+
Copyright (c) 2010 - 2014 Robin Herbots
|
30181
|
+
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
30182
|
+
Version: 0.0.0
|
30183
|
+
|
30184
|
+
Optional extensions on the jquery.inputmask base
|
30185
|
+
*/
|
30186
|
+
(function ($) {
|
30187
|
+
//extra definitions
|
30188
|
+
$.extend($.inputmask.defaults.definitions, {
|
30189
|
+
'A': {
|
30190
|
+
validator: "[A-Za-z]",
|
30191
|
+
cardinality: 1,
|
30192
|
+
casing: "upper" //auto uppercasing
|
30193
|
+
},
|
30194
|
+
'#': {
|
30195
|
+
validator: "[A-Za-z\u0410-\u044F\u0401\u04510-9]",
|
30196
|
+
cardinality: 1,
|
30197
|
+
casing: "upper"
|
30198
|
+
}
|
30199
|
+
});
|
30200
|
+
$.extend($.inputmask.defaults.aliases, {
|
30201
|
+
'url': {
|
30202
|
+
mask: "ir",
|
30203
|
+
placeholder: "",
|
30204
|
+
separator: "",
|
30205
|
+
defaultPrefix: "http://",
|
30206
|
+
regex: {
|
30207
|
+
urlpre1: new RegExp("[fh]"),
|
30208
|
+
urlpre2: new RegExp("(ft|ht)"),
|
30209
|
+
urlpre3: new RegExp("(ftp|htt)"),
|
30210
|
+
urlpre4: new RegExp("(ftp:|http|ftps)"),
|
30211
|
+
urlpre5: new RegExp("(ftp:/|ftps:|http:|https)"),
|
30212
|
+
urlpre6: new RegExp("(ftp://|ftps:/|http:/|https:)"),
|
30213
|
+
urlpre7: new RegExp("(ftp://|ftps://|http://|https:/)"),
|
30214
|
+
urlpre8: new RegExp("(ftp://|ftps://|http://|https://)")
|
30215
|
+
},
|
30216
|
+
definitions: {
|
30217
|
+
'i': {
|
30218
|
+
validator: function (chrs, buffer, pos, strict, opts) {
|
30219
|
+
return true;
|
30220
|
+
},
|
30221
|
+
cardinality: 8,
|
30222
|
+
prevalidator: (function () {
|
30223
|
+
var result = [], prefixLimit = 8;
|
30224
|
+
for (var i = 0; i < prefixLimit; i++) {
|
30225
|
+
result[i] = (function () {
|
30226
|
+
var j = i;
|
30227
|
+
return {
|
30228
|
+
validator: function (chrs, buffer, pos, strict, opts) {
|
30229
|
+
if (opts.regex["urlpre" + (j + 1)]) {
|
30230
|
+
var tmp = chrs, k;
|
30231
|
+
if (((j + 1) - chrs.length) > 0) {
|
30232
|
+
tmp = buffer.join('').substring(0, ((j + 1) - chrs.length)) + "" + tmp;
|
30233
|
+
}
|
30234
|
+
var isValid = opts.regex["urlpre" + (j + 1)].test(tmp);
|
30235
|
+
if (!strict && !isValid) {
|
30236
|
+
pos = pos - j;
|
30237
|
+
for (k = 0; k < opts.defaultPrefix.length; k++) {
|
30238
|
+
buffer[pos] = opts.defaultPrefix[k]; pos++;
|
30239
|
+
}
|
30240
|
+
for (k = 0; k < tmp.length - 1; k++) {
|
30241
|
+
buffer[pos] = tmp[k]; pos++;
|
30242
|
+
}
|
30243
|
+
return { "pos": pos };
|
30244
|
+
}
|
30245
|
+
return isValid;
|
30246
|
+
} else {
|
30247
|
+
return false;
|
30248
|
+
}
|
30249
|
+
}, cardinality: j
|
30250
|
+
};
|
30251
|
+
})();
|
30252
|
+
}
|
30253
|
+
return result;
|
30254
|
+
})()
|
30255
|
+
},
|
30256
|
+
"r": {
|
30257
|
+
validator: ".",
|
30258
|
+
cardinality: 50
|
30259
|
+
}
|
30260
|
+
},
|
30261
|
+
insertMode: false,
|
30262
|
+
autoUnmask: false
|
30263
|
+
},
|
30264
|
+
"ip": { //ip-address mask
|
30265
|
+
mask: ["[[x]y]z.[[x]y]z.[[x]y]z.x[yz]", "[[x]y]z.[[x]y]z.[[x]y]z.[[x]y][z]"],
|
30266
|
+
definitions: {
|
30267
|
+
'x': {
|
30268
|
+
validator: "[012]",
|
30269
|
+
cardinality: 1,
|
30270
|
+
definitionSymbol: "i"
|
30271
|
+
},
|
30272
|
+
'y': {
|
30273
|
+
validator: function (chrs, buffer, pos, strict, opts) {
|
30274
|
+
if (pos - 1 > -1 && buffer[pos - 1] != ".")
|
30275
|
+
chrs = buffer[pos - 1] + chrs;
|
30276
|
+
else chrs = "0" + chrs;
|
30277
|
+
return new RegExp("2[0-5]|[01][0-9]").test(chrs);
|
30278
|
+
},
|
30279
|
+
cardinality: 1,
|
30280
|
+
definitionSymbol: "i"
|
30281
|
+
},
|
30282
|
+
'z': {
|
30283
|
+
validator: function (chrs, buffer, pos, strict, opts) {
|
30284
|
+
if (pos - 1 > -1 && buffer[pos - 1] != ".") {
|
30285
|
+
chrs = buffer[pos - 1] + chrs;
|
30286
|
+
if (pos - 2 > -1 && buffer[pos - 2] != ".") {
|
30287
|
+
chrs = buffer[pos - 2] + chrs;
|
30288
|
+
} else chrs = "0" + chrs;
|
30289
|
+
} else chrs = "00" + chrs;
|
30290
|
+
return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
|
30291
|
+
},
|
30292
|
+
cardinality: 1,
|
30293
|
+
definitionSymbol: "i"
|
30294
|
+
}
|
30295
|
+
}
|
30296
|
+
}
|
30297
|
+
});
|
30298
|
+
})(jQuery);
|
30299
|
+
});
|
30300
|
+
require.register("ened/vendor/assets/javascripts/jquery/inputmask.numeric.extensions.js", function(exports, require, module){
|
30301
|
+
/*
|
30302
|
+
Input Mask plugin extensions
|
30303
|
+
http://github.com/RobinHerbots/jquery.inputmask
|
30304
|
+
Copyright (c) 2010 - 2014 Robin Herbots
|
30305
|
+
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
30306
|
+
Version: 0.0.0
|
30307
|
+
|
30308
|
+
Optional extensions on the jquery.inputmask base
|
30309
|
+
*/
|
30310
|
+
(function ($) {
|
30311
|
+
//number aliases
|
30312
|
+
$.extend($.inputmask.defaults.aliases, {
|
30313
|
+
'decimal': {
|
30314
|
+
mask: "~",
|
30315
|
+
placeholder: "",
|
30316
|
+
repeat: "*",
|
30317
|
+
greedy: false,
|
30318
|
+
numericInput: false,
|
30319
|
+
isNumeric: true,
|
30320
|
+
digits: "*", //number of fractionalDigits
|
30321
|
+
groupSeparator: "",//",", // | "."
|
30322
|
+
radixPoint: ".",
|
30323
|
+
groupSize: 3,
|
30324
|
+
autoGroup: false,
|
30325
|
+
allowPlus: true,
|
30326
|
+
allowMinus: true,
|
30327
|
+
//todo
|
30328
|
+
integerDigits: "*", //number of integerDigits
|
30329
|
+
defaultValue: "",
|
30330
|
+
prefix: "",
|
30331
|
+
suffix: "",
|
30332
|
+
|
30333
|
+
//todo
|
30334
|
+
getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) { //custom getMaskLength to take the groupSeparator into account
|
30335
|
+
var calculatedLength = buffer.length;
|
30336
|
+
|
30337
|
+
if (!greedy) {
|
30338
|
+
if (repeat == "*") {
|
30339
|
+
calculatedLength = currentBuffer.length + 1;
|
30340
|
+
} else if (repeat > 1) {
|
30341
|
+
calculatedLength += (buffer.length * (repeat - 1));
|
30342
|
+
}
|
30343
|
+
}
|
30344
|
+
|
30345
|
+
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
|
30346
|
+
var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
|
30347
|
+
var currentBufferStr = currentBuffer.join(''), strippedBufferStr = currentBufferStr.replace(new RegExp(escapedGroupSeparator, "g"), "").replace(new RegExp(escapedRadixPoint), ""),
|
30348
|
+
groupOffset = currentBufferStr.length - strippedBufferStr.length;
|
30349
|
+
return calculatedLength + groupOffset;
|
30350
|
+
},
|
30351
|
+
postFormat: function (buffer, pos, reformatOnly, opts) {
|
30352
|
+
if (opts.groupSeparator == "") return pos;
|
30353
|
+
var cbuf = buffer.slice(),
|
30354
|
+
radixPos = $.inArray(opts.radixPoint, buffer);
|
30355
|
+
if (!reformatOnly) {
|
30356
|
+
cbuf.splice(pos, 0, "?"); //set position indicator
|
30357
|
+
}
|
30358
|
+
var bufVal = cbuf.join('');
|
30359
|
+
if (opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
|
30360
|
+
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
|
30361
|
+
bufVal = bufVal.replace(new RegExp(escapedGroupSeparator, "g"), '');
|
30362
|
+
var radixSplit = bufVal.split(opts.radixPoint);
|
30363
|
+
bufVal = radixSplit[0];
|
30364
|
+
var reg = new RegExp('([-\+]?[\\d\?]+)([\\d\?]{' + opts.groupSize + '})');
|
30365
|
+
while (reg.test(bufVal)) {
|
30366
|
+
bufVal = bufVal.replace(reg, '$1' + opts.groupSeparator + '$2');
|
30367
|
+
bufVal = bufVal.replace(opts.groupSeparator + opts.groupSeparator, opts.groupSeparator);
|
30368
|
+
}
|
30369
|
+
if (radixSplit.length > 1)
|
30370
|
+
bufVal += opts.radixPoint + radixSplit[1];
|
30371
|
+
}
|
30372
|
+
buffer.length = bufVal.length; //align the length
|
30373
|
+
for (var i = 0, l = bufVal.length; i < l; i++) {
|
30374
|
+
buffer[i] = bufVal.charAt(i);
|
30375
|
+
}
|
30376
|
+
var newPos = $.inArray("?", buffer);
|
30377
|
+
if (!reformatOnly) buffer.splice(newPos, 1);
|
30378
|
+
|
30379
|
+
return reformatOnly ? pos : newPos;
|
30380
|
+
},
|
30381
|
+
regex: {
|
30382
|
+
number: function (opts) {
|
30383
|
+
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
|
30384
|
+
var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
|
30385
|
+
var digitExpression = isNaN(opts.digits) ? opts.digits : '{0,' + opts.digits + '}';
|
30386
|
+
var signedExpression = opts.allowPlus || opts.allowMinus ? "[" + (opts.allowPlus ? "\+" : "") + (opts.allowMinus ? "-" : "") + "]?" : "";
|
30387
|
+
return new RegExp("^" + signedExpression + "(\\d+|\\d{1," + opts.groupSize + "}((" + escapedGroupSeparator + "\\d{" + opts.groupSize + "})?)+)(" + escapedRadixPoint + "\\d" + digitExpression + ")?$");
|
30388
|
+
}
|
30389
|
+
},
|
30390
|
+
onKeyDown: function (e, buffer, opts) {
|
30391
|
+
var $input = $(this), input = this;
|
30392
|
+
if (e.keyCode == opts.keyCode.TAB) {
|
30393
|
+
var radixPosition = $.inArray(opts.radixPoint, buffer);
|
30394
|
+
if (radixPosition != -1) {
|
30395
|
+
var masksets = $input.data('_inputmask')['masksets'];
|
30396
|
+
var activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
|
30397
|
+
for (var i = 1; i <= opts.digits && i < opts.getMaskLength(masksets[activeMasksetIndex]["_buffer"], masksets[activeMasksetIndex]["greedy"], masksets[activeMasksetIndex]["repeat"], buffer, opts) ; i++) {
|
30398
|
+
if (buffer[radixPosition + i] == undefined || buffer[radixPosition + i] == "") buffer[radixPosition + i] = "0";
|
30399
|
+
}
|
30400
|
+
input._valueSet(buffer.join(''));
|
30401
|
+
}
|
30402
|
+
} else if (e.keyCode == opts.keyCode.DELETE || e.keyCode == opts.keyCode.BACKSPACE) {
|
30403
|
+
opts.postFormat(buffer, 0, true, opts);
|
30404
|
+
input._valueSet(buffer.join(''));
|
30405
|
+
return true;
|
30406
|
+
}
|
30407
|
+
},
|
30408
|
+
definitions: {
|
30409
|
+
'~': { //real number
|
30410
|
+
validator: function (chrs, buffer, pos, strict, opts) {
|
30411
|
+
if (chrs == "") return false;
|
30412
|
+
if (!strict && pos <= 1 && buffer[0] === '0' && new RegExp("[\\d-]").test(chrs) && buffer.join('').length == 1) { //handle first char
|
30413
|
+
buffer[0] = "";
|
30414
|
+
return { "pos": 0 };
|
30415
|
+
}
|
30416
|
+
|
30417
|
+
var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
|
30418
|
+
|
30419
|
+
cbuf.splice(pos, 0, chrs);
|
30420
|
+
var bufferStr = cbuf.join('');
|
30421
|
+
|
30422
|
+
//strip groupseparator
|
30423
|
+
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
|
30424
|
+
bufferStr = bufferStr.replace(new RegExp(escapedGroupSeparator, "g"), '');
|
30425
|
+
|
30426
|
+
var isValid = opts.regex.number(opts).test(bufferStr);
|
30427
|
+
if (!isValid) {
|
30428
|
+
//let's help the regex a bit
|
30429
|
+
bufferStr += "0";
|
30430
|
+
isValid = opts.regex.number(opts).test(bufferStr);
|
30431
|
+
if (!isValid) {
|
30432
|
+
//make a valid group
|
30433
|
+
var lastGroupSeparator = bufferStr.lastIndexOf(opts.groupSeparator);
|
30434
|
+
for (var i = bufferStr.length - lastGroupSeparator; i <= 3; i++) {
|
30435
|
+
bufferStr += "0";
|
30436
|
+
}
|
30437
|
+
|
30438
|
+
isValid = opts.regex.number(opts).test(bufferStr);
|
30439
|
+
if (!isValid && !strict) {
|
30440
|
+
if (chrs == opts.radixPoint) {
|
30441
|
+
isValid = opts.regex.number(opts).test("0" + bufferStr + "0");
|
30442
|
+
if (isValid) {
|
30443
|
+
buffer[pos] = "0";
|
30444
|
+
pos++;
|
30445
|
+
return { "pos": pos };
|
30446
|
+
}
|
30447
|
+
}
|
30448
|
+
}
|
30449
|
+
}
|
30450
|
+
}
|
30451
|
+
|
30452
|
+
if (isValid != false && !strict && chrs != opts.radixPoint) {
|
30453
|
+
var newPos = opts.postFormat(buffer, pos, false, opts);
|
30454
|
+
return { "pos": newPos };
|
30455
|
+
}
|
30456
|
+
|
30457
|
+
return isValid;
|
30458
|
+
},
|
30459
|
+
cardinality: 1,
|
30460
|
+
prevalidator: null
|
30461
|
+
}
|
30462
|
+
},
|
30463
|
+
insertMode: true,
|
30464
|
+
autoUnmask: false
|
30465
|
+
},
|
30466
|
+
'integer': {
|
30467
|
+
regex: {
|
30468
|
+
number: function (opts) {
|
30469
|
+
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
|
30470
|
+
var signedExpression = opts.allowPlus || opts.allowMinus ? "[" + (opts.allowPlus ? "\+" : "") + (opts.allowMinus ? "-" : "") + "]?" : "";
|
30471
|
+
return new RegExp("^" + signedExpression + "(\\d+|\\d{1," + opts.groupSize + "}((" + escapedGroupSeparator + "\\d{" + opts.groupSize + "})?)+)$");
|
30472
|
+
}
|
30473
|
+
},
|
30474
|
+
alias: "decimal"
|
30475
|
+
}
|
30476
|
+
});
|
30477
|
+
})(jQuery);
|
30478
|
+
=======
|
28142
30479
|
require.register("ened/vendor/assets/javascripts/shims/es6-map-shim.js", function(exports, require, module){
|
28143
30480
|
/**
|
28144
30481
|
* Copyright 2012 Eric Wendelin - MIT License
|
@@ -28396,6 +30733,7 @@ require.register("ened/vendor/assets/javascripts/shims/es6-map-shim.js", functio
|
|
28396
30733
|
window.Map = module.Map = window.Map || Map;
|
28397
30734
|
}.call(this, window));
|
28398
30735
|
|
30736
|
+
>>>>>>> master
|
28399
30737
|
});
|
28400
30738
|
require.alias("mikeric-rivets/dist/rivets.js", "ened/deps/rivets/dist/rivets.js");
|
28401
30739
|
require.alias("mikeric-rivets/dist/rivets.js", "ened/deps/rivets/index.js");
|
@@ -28448,6 +30786,7 @@ require.alias("indefinido-indemma/lib/record/restfulable.js", "ened/deps/indemma
|
|
28448
30786
|
require.alias("indefinido-indemma/lib/record/scopable.js", "ened/deps/indemma/lib/record/scopable.js");
|
28449
30787
|
require.alias("indefinido-indemma/lib/record/maid.js", "ened/deps/indemma/lib/record/maid.js");
|
28450
30788
|
require.alias("indefinido-indemma/lib/record/translationable.js", "ened/deps/indemma/lib/record/translationable.js");
|
30789
|
+
require.alias("indefinido-indemma/lib/record/validations/validatorable.js", "ened/deps/indemma/lib/record/validations/validatorable.js");
|
28451
30790
|
require.alias("indefinido-indemma/lib/record/validations/confirmation.js", "ened/deps/indemma/lib/record/validations/confirmation.js");
|
28452
30791
|
require.alias("indefinido-indemma/lib/record/validations/associated.js", "ened/deps/indemma/lib/record/validations/associated.js");
|
28453
30792
|
require.alias("indefinido-indemma/lib/record/validations/presence.js", "ened/deps/indemma/lib/record/validations/presence.js");
|