[MERGE] forward port of branch saas-3 up to revid 3975 chs@openerp.com-20140318115516-sn3laxqseam1oz3f
bzr revid: chs@openerp.com-20140318124050-ul3reev0vvmgqxz8
This commit is contained in:
commit
a2f9619e26
|
@ -13,7 +13,7 @@
|
||||||
}
|
}
|
||||||
.fa {
|
.fa {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-family: FontAwesome;
|
font-family: FontAwesome !important;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Underscore.js 1.5.2
|
// Underscore.js 1.6.0
|
||||||
// http://underscorejs.org
|
// http://underscorejs.org
|
||||||
// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||||
// Underscore may be freely distributed under the MIT license.
|
// Underscore may be freely distributed under the MIT license.
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Current version.
|
// Current version.
|
||||||
_.VERSION = '1.5.2';
|
_.VERSION = '1.6.0';
|
||||||
|
|
||||||
// Collection Functions
|
// Collection Functions
|
||||||
// --------------------
|
// --------------------
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
// Handles objects with the built-in `forEach`, arrays, and raw objects.
|
// Handles objects with the built-in `forEach`, arrays, and raw objects.
|
||||||
// Delegates to **ECMAScript 5**'s native `forEach` if available.
|
// Delegates to **ECMAScript 5**'s native `forEach` if available.
|
||||||
var each = _.each = _.forEach = function(obj, iterator, context) {
|
var each = _.each = _.forEach = function(obj, iterator, context) {
|
||||||
if (obj == null) return;
|
if (obj == null) return obj;
|
||||||
if (nativeForEach && obj.forEach === nativeForEach) {
|
if (nativeForEach && obj.forEach === nativeForEach) {
|
||||||
obj.forEach(iterator, context);
|
obj.forEach(iterator, context);
|
||||||
} else if (obj.length === +obj.length) {
|
} else if (obj.length === +obj.length) {
|
||||||
|
@ -87,6 +87,7 @@
|
||||||
if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;
|
if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the results of applying the iterator to each element.
|
// Return the results of applying the iterator to each element.
|
||||||
|
@ -152,10 +153,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the first value which passes a truth test. Aliased as `detect`.
|
// Return the first value which passes a truth test. Aliased as `detect`.
|
||||||
_.find = _.detect = function(obj, iterator, context) {
|
_.find = _.detect = function(obj, predicate, context) {
|
||||||
var result;
|
var result;
|
||||||
any(obj, function(value, index, list) {
|
any(obj, function(value, index, list) {
|
||||||
if (iterator.call(context, value, index, list)) {
|
if (predicate.call(context, value, index, list)) {
|
||||||
result = value;
|
result = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -166,33 +167,33 @@
|
||||||
// Return all the elements that pass a truth test.
|
// Return all the elements that pass a truth test.
|
||||||
// Delegates to **ECMAScript 5**'s native `filter` if available.
|
// Delegates to **ECMAScript 5**'s native `filter` if available.
|
||||||
// Aliased as `select`.
|
// Aliased as `select`.
|
||||||
_.filter = _.select = function(obj, iterator, context) {
|
_.filter = _.select = function(obj, predicate, context) {
|
||||||
var results = [];
|
var results = [];
|
||||||
if (obj == null) return results;
|
if (obj == null) return results;
|
||||||
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
|
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context);
|
||||||
each(obj, function(value, index, list) {
|
each(obj, function(value, index, list) {
|
||||||
if (iterator.call(context, value, index, list)) results.push(value);
|
if (predicate.call(context, value, index, list)) results.push(value);
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return all the elements for which a truth test fails.
|
// Return all the elements for which a truth test fails.
|
||||||
_.reject = function(obj, iterator, context) {
|
_.reject = function(obj, predicate, context) {
|
||||||
return _.filter(obj, function(value, index, list) {
|
return _.filter(obj, function(value, index, list) {
|
||||||
return !iterator.call(context, value, index, list);
|
return !predicate.call(context, value, index, list);
|
||||||
}, context);
|
}, context);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Determine whether all of the elements match a truth test.
|
// Determine whether all of the elements match a truth test.
|
||||||
// Delegates to **ECMAScript 5**'s native `every` if available.
|
// Delegates to **ECMAScript 5**'s native `every` if available.
|
||||||
// Aliased as `all`.
|
// Aliased as `all`.
|
||||||
_.every = _.all = function(obj, iterator, context) {
|
_.every = _.all = function(obj, predicate, context) {
|
||||||
iterator || (iterator = _.identity);
|
predicate || (predicate = _.identity);
|
||||||
var result = true;
|
var result = true;
|
||||||
if (obj == null) return result;
|
if (obj == null) return result;
|
||||||
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
|
if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context);
|
||||||
each(obj, function(value, index, list) {
|
each(obj, function(value, index, list) {
|
||||||
if (!(result = result && iterator.call(context, value, index, list))) return breaker;
|
if (!(result = result && predicate.call(context, value, index, list))) return breaker;
|
||||||
});
|
});
|
||||||
return !!result;
|
return !!result;
|
||||||
};
|
};
|
||||||
|
@ -200,13 +201,13 @@
|
||||||
// Determine if at least one element in the object matches a truth test.
|
// Determine if at least one element in the object matches a truth test.
|
||||||
// Delegates to **ECMAScript 5**'s native `some` if available.
|
// Delegates to **ECMAScript 5**'s native `some` if available.
|
||||||
// Aliased as `any`.
|
// Aliased as `any`.
|
||||||
var any = _.some = _.any = function(obj, iterator, context) {
|
var any = _.some = _.any = function(obj, predicate, context) {
|
||||||
iterator || (iterator = _.identity);
|
predicate || (predicate = _.identity);
|
||||||
var result = false;
|
var result = false;
|
||||||
if (obj == null) return result;
|
if (obj == null) return result;
|
||||||
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
|
if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context);
|
||||||
each(obj, function(value, index, list) {
|
each(obj, function(value, index, list) {
|
||||||
if (result || (result = iterator.call(context, value, index, list))) return breaker;
|
if (result || (result = predicate.call(context, value, index, list))) return breaker;
|
||||||
});
|
});
|
||||||
return !!result;
|
return !!result;
|
||||||
};
|
};
|
||||||
|
@ -232,25 +233,19 @@
|
||||||
|
|
||||||
// Convenience version of a common use case of `map`: fetching a property.
|
// Convenience version of a common use case of `map`: fetching a property.
|
||||||
_.pluck = function(obj, key) {
|
_.pluck = function(obj, key) {
|
||||||
return _.map(obj, function(value){ return value[key]; });
|
return _.map(obj, _.property(key));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convenience version of a common use case of `filter`: selecting only objects
|
// Convenience version of a common use case of `filter`: selecting only objects
|
||||||
// containing specific `key:value` pairs.
|
// containing specific `key:value` pairs.
|
||||||
_.where = function(obj, attrs, first) {
|
_.where = function(obj, attrs) {
|
||||||
if (_.isEmpty(attrs)) return first ? void 0 : [];
|
return _.filter(obj, _.matches(attrs));
|
||||||
return _[first ? 'find' : 'filter'](obj, function(value) {
|
|
||||||
for (var key in attrs) {
|
|
||||||
if (attrs[key] !== value[key]) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convenience version of a common use case of `find`: getting the first object
|
// Convenience version of a common use case of `find`: getting the first object
|
||||||
// containing specific `key:value` pairs.
|
// containing specific `key:value` pairs.
|
||||||
_.findWhere = function(obj, attrs) {
|
_.findWhere = function(obj, attrs) {
|
||||||
return _.where(obj, attrs, true);
|
return _.find(obj, _.matches(attrs));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the maximum element or (element-based computation).
|
// Return the maximum element or (element-based computation).
|
||||||
|
@ -260,13 +255,15 @@
|
||||||
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
||||||
return Math.max.apply(Math, obj);
|
return Math.max.apply(Math, obj);
|
||||||
}
|
}
|
||||||
if (!iterator && _.isEmpty(obj)) return -Infinity;
|
var result = -Infinity, lastComputed = -Infinity;
|
||||||
var result = {computed : -Infinity, value: -Infinity};
|
|
||||||
each(obj, function(value, index, list) {
|
each(obj, function(value, index, list) {
|
||||||
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
||||||
computed > result.computed && (result = {value : value, computed : computed});
|
if (computed > lastComputed) {
|
||||||
|
result = value;
|
||||||
|
lastComputed = computed;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return result.value;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the minimum element (or element-based computation).
|
// Return the minimum element (or element-based computation).
|
||||||
|
@ -274,16 +271,18 @@
|
||||||
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
|
||||||
return Math.min.apply(Math, obj);
|
return Math.min.apply(Math, obj);
|
||||||
}
|
}
|
||||||
if (!iterator && _.isEmpty(obj)) return Infinity;
|
var result = Infinity, lastComputed = Infinity;
|
||||||
var result = {computed : Infinity, value: Infinity};
|
|
||||||
each(obj, function(value, index, list) {
|
each(obj, function(value, index, list) {
|
||||||
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
||||||
computed < result.computed && (result = {value : value, computed : computed});
|
if (computed < lastComputed) {
|
||||||
|
result = value;
|
||||||
|
lastComputed = computed;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return result.value;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Shuffle an array, using the modern version of the
|
// Shuffle an array, using the modern version of the
|
||||||
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
|
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
|
||||||
_.shuffle = function(obj) {
|
_.shuffle = function(obj) {
|
||||||
var rand;
|
var rand;
|
||||||
|
@ -297,11 +296,12 @@
|
||||||
return shuffled;
|
return shuffled;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sample **n** random values from an array.
|
// Sample **n** random values from a collection.
|
||||||
// If **n** is not specified, returns a single random element from the array.
|
// If **n** is not specified, returns a single random element.
|
||||||
// The internal `guard` argument allows it to work with `map`.
|
// The internal `guard` argument allows it to work with `map`.
|
||||||
_.sample = function(obj, n, guard) {
|
_.sample = function(obj, n, guard) {
|
||||||
if (arguments.length < 2 || guard) {
|
if (n == null || guard) {
|
||||||
|
if (obj.length !== +obj.length) obj = _.values(obj);
|
||||||
return obj[_.random(obj.length - 1)];
|
return obj[_.random(obj.length - 1)];
|
||||||
}
|
}
|
||||||
return _.shuffle(obj).slice(0, Math.max(0, n));
|
return _.shuffle(obj).slice(0, Math.max(0, n));
|
||||||
|
@ -309,12 +309,14 @@
|
||||||
|
|
||||||
// An internal function to generate lookup iterators.
|
// An internal function to generate lookup iterators.
|
||||||
var lookupIterator = function(value) {
|
var lookupIterator = function(value) {
|
||||||
return _.isFunction(value) ? value : function(obj){ return obj[value]; };
|
if (value == null) return _.identity;
|
||||||
|
if (_.isFunction(value)) return value;
|
||||||
|
return _.property(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sort the object's values by a criterion produced by an iterator.
|
// Sort the object's values by a criterion produced by an iterator.
|
||||||
_.sortBy = function(obj, value, context) {
|
_.sortBy = function(obj, iterator, context) {
|
||||||
var iterator = lookupIterator(value);
|
iterator = lookupIterator(iterator);
|
||||||
return _.pluck(_.map(obj, function(value, index, list) {
|
return _.pluck(_.map(obj, function(value, index, list) {
|
||||||
return {
|
return {
|
||||||
value: value,
|
value: value,
|
||||||
|
@ -334,9 +336,9 @@
|
||||||
|
|
||||||
// An internal function used for aggregate "group by" operations.
|
// An internal function used for aggregate "group by" operations.
|
||||||
var group = function(behavior) {
|
var group = function(behavior) {
|
||||||
return function(obj, value, context) {
|
return function(obj, iterator, context) {
|
||||||
var result = {};
|
var result = {};
|
||||||
var iterator = value == null ? _.identity : lookupIterator(value);
|
iterator = lookupIterator(iterator);
|
||||||
each(obj, function(value, index) {
|
each(obj, function(value, index) {
|
||||||
var key = iterator.call(context, value, index, obj);
|
var key = iterator.call(context, value, index, obj);
|
||||||
behavior(result, key, value);
|
behavior(result, key, value);
|
||||||
|
@ -348,7 +350,7 @@
|
||||||
// Groups the object's values by a criterion. Pass either a string attribute
|
// Groups the object's values by a criterion. Pass either a string attribute
|
||||||
// to group by, or a function that returns the criterion.
|
// to group by, or a function that returns the criterion.
|
||||||
_.groupBy = group(function(result, key, value) {
|
_.groupBy = group(function(result, key, value) {
|
||||||
(_.has(result, key) ? result[key] : (result[key] = [])).push(value);
|
_.has(result, key) ? result[key].push(value) : result[key] = [value];
|
||||||
});
|
});
|
||||||
|
|
||||||
// Indexes the object's values by a criterion, similar to `groupBy`, but for
|
// Indexes the object's values by a criterion, similar to `groupBy`, but for
|
||||||
|
@ -367,7 +369,7 @@
|
||||||
// Use a comparator function to figure out the smallest index at which
|
// Use a comparator function to figure out the smallest index at which
|
||||||
// an object should be inserted so as to maintain order. Uses binary search.
|
// an object should be inserted so as to maintain order. Uses binary search.
|
||||||
_.sortedIndex = function(array, obj, iterator, context) {
|
_.sortedIndex = function(array, obj, iterator, context) {
|
||||||
iterator = iterator == null ? _.identity : lookupIterator(iterator);
|
iterator = lookupIterator(iterator);
|
||||||
var value = iterator.call(context, obj);
|
var value = iterator.call(context, obj);
|
||||||
var low = 0, high = array.length;
|
var low = 0, high = array.length;
|
||||||
while (low < high) {
|
while (low < high) {
|
||||||
|
@ -399,7 +401,9 @@
|
||||||
// allows it to work with `_.map`.
|
// allows it to work with `_.map`.
|
||||||
_.first = _.head = _.take = function(array, n, guard) {
|
_.first = _.head = _.take = function(array, n, guard) {
|
||||||
if (array == null) return void 0;
|
if (array == null) return void 0;
|
||||||
return (n == null) || guard ? array[0] : slice.call(array, 0, n);
|
if ((n == null) || guard) return array[0];
|
||||||
|
if (n < 0) return [];
|
||||||
|
return slice.call(array, 0, n);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns everything but the last entry of the array. Especially useful on
|
// Returns everything but the last entry of the array. Especially useful on
|
||||||
|
@ -414,11 +418,8 @@
|
||||||
// values in the array. The **guard** check allows it to work with `_.map`.
|
// values in the array. The **guard** check allows it to work with `_.map`.
|
||||||
_.last = function(array, n, guard) {
|
_.last = function(array, n, guard) {
|
||||||
if (array == null) return void 0;
|
if (array == null) return void 0;
|
||||||
if ((n == null) || guard) {
|
if ((n == null) || guard) return array[array.length - 1];
|
||||||
return array[array.length - 1];
|
return slice.call(array, Math.max(array.length - n, 0));
|
||||||
} else {
|
|
||||||
return slice.call(array, Math.max(array.length - n, 0));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
|
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
|
||||||
|
@ -459,6 +460,17 @@
|
||||||
return _.difference(array, slice.call(arguments, 1));
|
return _.difference(array, slice.call(arguments, 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Split an array into two arrays: one whose elements all satisfy the given
|
||||||
|
// predicate, and one whose elements all do not satisfy the predicate.
|
||||||
|
_.partition = function(array, predicate, context) {
|
||||||
|
predicate = lookupIterator(predicate);
|
||||||
|
var pass = [], fail = [];
|
||||||
|
each(array, function(elem) {
|
||||||
|
(predicate.call(context, elem) ? pass : fail).push(elem);
|
||||||
|
});
|
||||||
|
return [pass, fail];
|
||||||
|
};
|
||||||
|
|
||||||
// Produce a duplicate-free version of the array. If the array has already
|
// Produce a duplicate-free version of the array. If the array has already
|
||||||
// been sorted, you have the option of using a faster algorithm.
|
// been sorted, you have the option of using a faster algorithm.
|
||||||
// Aliased as `unique`.
|
// Aliased as `unique`.
|
||||||
|
@ -492,7 +504,7 @@
|
||||||
var rest = slice.call(arguments, 1);
|
var rest = slice.call(arguments, 1);
|
||||||
return _.filter(_.uniq(array), function(item) {
|
return _.filter(_.uniq(array), function(item) {
|
||||||
return _.every(rest, function(other) {
|
return _.every(rest, function(other) {
|
||||||
return _.indexOf(other, item) >= 0;
|
return _.contains(other, item);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -507,7 +519,7 @@
|
||||||
// Zip together multiple lists into a single array -- elements that share
|
// Zip together multiple lists into a single array -- elements that share
|
||||||
// an index go together.
|
// an index go together.
|
||||||
_.zip = function() {
|
_.zip = function() {
|
||||||
var length = _.max(_.pluck(arguments, "length").concat(0));
|
var length = _.max(_.pluck(arguments, 'length').concat(0));
|
||||||
var results = new Array(length);
|
var results = new Array(length);
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
results[i] = _.pluck(arguments, '' + i);
|
results[i] = _.pluck(arguments, '' + i);
|
||||||
|
@ -613,19 +625,27 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// Partially apply a function by creating a version that has had some of its
|
// Partially apply a function by creating a version that has had some of its
|
||||||
// arguments pre-filled, without changing its dynamic `this` context.
|
// arguments pre-filled, without changing its dynamic `this` context. _ acts
|
||||||
|
// as a placeholder, allowing any combination of arguments to be pre-filled.
|
||||||
_.partial = function(func) {
|
_.partial = function(func) {
|
||||||
var args = slice.call(arguments, 1);
|
var boundArgs = slice.call(arguments, 1);
|
||||||
return function() {
|
return function() {
|
||||||
return func.apply(this, args.concat(slice.call(arguments)));
|
var position = 0;
|
||||||
|
var args = boundArgs.slice();
|
||||||
|
for (var i = 0, length = args.length; i < length; i++) {
|
||||||
|
if (args[i] === _) args[i] = arguments[position++];
|
||||||
|
}
|
||||||
|
while (position < arguments.length) args.push(arguments[position++]);
|
||||||
|
return func.apply(this, args);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bind all of an object's methods to that object. Useful for ensuring that
|
// Bind a number of an object's methods to that object. Remaining arguments
|
||||||
// all callbacks defined on an object belong to it.
|
// are the method names to be bound. Useful for ensuring that all callbacks
|
||||||
|
// defined on an object belong to it.
|
||||||
_.bindAll = function(obj) {
|
_.bindAll = function(obj) {
|
||||||
var funcs = slice.call(arguments, 1);
|
var funcs = slice.call(arguments, 1);
|
||||||
if (funcs.length === 0) throw new Error("bindAll must be passed function names");
|
if (funcs.length === 0) throw new Error('bindAll must be passed function names');
|
||||||
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
|
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
@ -664,12 +684,13 @@
|
||||||
var previous = 0;
|
var previous = 0;
|
||||||
options || (options = {});
|
options || (options = {});
|
||||||
var later = function() {
|
var later = function() {
|
||||||
previous = options.leading === false ? 0 : new Date;
|
previous = options.leading === false ? 0 : _.now();
|
||||||
timeout = null;
|
timeout = null;
|
||||||
result = func.apply(context, args);
|
result = func.apply(context, args);
|
||||||
|
context = args = null;
|
||||||
};
|
};
|
||||||
return function() {
|
return function() {
|
||||||
var now = new Date;
|
var now = _.now();
|
||||||
if (!previous && options.leading === false) previous = now;
|
if (!previous && options.leading === false) previous = now;
|
||||||
var remaining = wait - (now - previous);
|
var remaining = wait - (now - previous);
|
||||||
context = this;
|
context = this;
|
||||||
|
@ -679,6 +700,7 @@
|
||||||
timeout = null;
|
timeout = null;
|
||||||
previous = now;
|
previous = now;
|
||||||
result = func.apply(context, args);
|
result = func.apply(context, args);
|
||||||
|
context = args = null;
|
||||||
} else if (!timeout && options.trailing !== false) {
|
} else if (!timeout && options.trailing !== false) {
|
||||||
timeout = setTimeout(later, remaining);
|
timeout = setTimeout(later, remaining);
|
||||||
}
|
}
|
||||||
|
@ -692,24 +714,33 @@
|
||||||
// leading edge, instead of the trailing.
|
// leading edge, instead of the trailing.
|
||||||
_.debounce = function(func, wait, immediate) {
|
_.debounce = function(func, wait, immediate) {
|
||||||
var timeout, args, context, timestamp, result;
|
var timeout, args, context, timestamp, result;
|
||||||
|
|
||||||
|
var later = function() {
|
||||||
|
var last = _.now() - timestamp;
|
||||||
|
if (last < wait) {
|
||||||
|
timeout = setTimeout(later, wait - last);
|
||||||
|
} else {
|
||||||
|
timeout = null;
|
||||||
|
if (!immediate) {
|
||||||
|
result = func.apply(context, args);
|
||||||
|
context = args = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return function() {
|
return function() {
|
||||||
context = this;
|
context = this;
|
||||||
args = arguments;
|
args = arguments;
|
||||||
timestamp = new Date();
|
timestamp = _.now();
|
||||||
var later = function() {
|
|
||||||
var last = (new Date()) - timestamp;
|
|
||||||
if (last < wait) {
|
|
||||||
timeout = setTimeout(later, wait - last);
|
|
||||||
} else {
|
|
||||||
timeout = null;
|
|
||||||
if (!immediate) result = func.apply(context, args);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var callNow = immediate && !timeout;
|
var callNow = immediate && !timeout;
|
||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
timeout = setTimeout(later, wait);
|
timeout = setTimeout(later, wait);
|
||||||
}
|
}
|
||||||
if (callNow) result = func.apply(context, args);
|
if (callNow) {
|
||||||
|
result = func.apply(context, args);
|
||||||
|
context = args = null;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -731,11 +762,7 @@
|
||||||
// allowing you to adjust arguments, run code before and after, and
|
// allowing you to adjust arguments, run code before and after, and
|
||||||
// conditionally execute the original function.
|
// conditionally execute the original function.
|
||||||
_.wrap = function(func, wrapper) {
|
_.wrap = function(func, wrapper) {
|
||||||
return function() {
|
return _.partial(wrapper, func);
|
||||||
var args = [func];
|
|
||||||
push.apply(args, arguments);
|
|
||||||
return wrapper.apply(this, args);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns a function that is the composition of a list of functions, each
|
// Returns a function that is the composition of a list of functions, each
|
||||||
|
@ -765,8 +792,9 @@
|
||||||
|
|
||||||
// Retrieve the names of an object's properties.
|
// Retrieve the names of an object's properties.
|
||||||
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
||||||
_.keys = nativeKeys || function(obj) {
|
_.keys = function(obj) {
|
||||||
if (obj !== Object(obj)) throw new TypeError('Invalid object');
|
if (!_.isObject(obj)) return [];
|
||||||
|
if (nativeKeys) return nativeKeys(obj);
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var key in obj) if (_.has(obj, key)) keys.push(key);
|
for (var key in obj) if (_.has(obj, key)) keys.push(key);
|
||||||
return keys;
|
return keys;
|
||||||
|
@ -921,7 +949,8 @@
|
||||||
// from different frames are.
|
// from different frames are.
|
||||||
var aCtor = a.constructor, bCtor = b.constructor;
|
var aCtor = a.constructor, bCtor = b.constructor;
|
||||||
if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
|
if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
|
||||||
_.isFunction(bCtor) && (bCtor instanceof bCtor))) {
|
_.isFunction(bCtor) && (bCtor instanceof bCtor))
|
||||||
|
&& ('constructor' in a && 'constructor' in b)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Add the first object to the stack of traversed objects.
|
// Add the first object to the stack of traversed objects.
|
||||||
|
@ -1061,6 +1090,30 @@
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_.constant = function(value) {
|
||||||
|
return function () {
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
_.property = function(key) {
|
||||||
|
return function(obj) {
|
||||||
|
return obj[key];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns a predicate for checking whether an object has a given set of `key:value` pairs.
|
||||||
|
_.matches = function(attrs) {
|
||||||
|
return function(obj) {
|
||||||
|
if (obj === attrs) return true; //avoid comparing an object to itself.
|
||||||
|
for (var key in attrs) {
|
||||||
|
if (attrs[key] !== obj[key])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Run a function **n** times.
|
// Run a function **n** times.
|
||||||
_.times = function(n, iterator, context) {
|
_.times = function(n, iterator, context) {
|
||||||
var accum = Array(Math.max(0, n));
|
var accum = Array(Math.max(0, n));
|
||||||
|
@ -1077,6 +1130,9 @@
|
||||||
return min + Math.floor(Math.random() * (max - min + 1));
|
return min + Math.floor(Math.random() * (max - min + 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A (possibly faster) way to get the current timestamp as an integer.
|
||||||
|
_.now = Date.now || function() { return new Date().getTime(); };
|
||||||
|
|
||||||
// List of HTML entities for escaping.
|
// List of HTML entities for escaping.
|
||||||
var entityMap = {
|
var entityMap = {
|
||||||
escape: {
|
escape: {
|
||||||
|
@ -1273,4 +1329,16 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// AMD registration happens at the end for compatibility with AMD loaders
|
||||||
|
// that may not enforce next-turn semantics on modules. Even though general
|
||||||
|
// practice for AMD registration is to be anonymous, underscore registers
|
||||||
|
// as a named module because, like jQuery, it is a base library that is
|
||||||
|
// popular enough to be bundled in a third party lib, but not be part of
|
||||||
|
// an AMD load request. Those cases could generate an error when an
|
||||||
|
// anonymous define() is called outside of a loader request.
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define('underscore', [], function() {
|
||||||
|
return _;
|
||||||
|
});
|
||||||
|
}
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
|
@ -1337,12 +1337,13 @@ instance.web.WebClient = instance.web.Client.extend({
|
||||||
if (_.isEmpty(state) || state.action == "login") {
|
if (_.isEmpty(state) || state.action == "login") {
|
||||||
self.menu.has_been_loaded.done(function() {
|
self.menu.has_been_loaded.done(function() {
|
||||||
new instance.web.Model("res.users").call("read", [self.session.uid, ["action_id"]]).done(function(data) {
|
new instance.web.Model("res.users").call("read", [self.session.uid, ["action_id"]]).done(function(data) {
|
||||||
var first_menu_id = self.menu.$el.find("a:first").data("menu");
|
|
||||||
if(first_menu_id)
|
|
||||||
self.menu.menu_click(first_menu_id);
|
|
||||||
|
|
||||||
if(data.action_id) {
|
if(data.action_id) {
|
||||||
self.action_manager.do_action(data.action_id[0]);
|
self.action_manager.do_action(data.action_id[0]);
|
||||||
|
self.menu.open_action(data.action_id[0]);
|
||||||
|
} else {
|
||||||
|
var first_menu_id = self.menu.$el.find("a:first").data("menu");
|
||||||
|
if(first_menu_id)
|
||||||
|
self.menu.menu_click(first_menu_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -915,6 +915,10 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
|
||||||
sign = -1;
|
sign = -1;
|
||||||
field = field.slice(1);
|
field = field.slice(1);
|
||||||
}
|
}
|
||||||
|
//m2o should be searched based on value[1] not based whole value(i.e. [id, value])
|
||||||
|
if(_.isArray(a[field]) && a[field].length == 2 && _.isString(a[field][1])){
|
||||||
|
return sign * compare(a[field][1], b[field][1]);
|
||||||
|
}
|
||||||
return sign * compare(a[field], b[field]);
|
return sign * compare(a[field], b[field]);
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -119,6 +119,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
|
||||||
if (select_exp.val()) {
|
if (select_exp.val()) {
|
||||||
self.exports.unlink([parseInt(select_exp.val(), 10)]);
|
self.exports.unlink([parseInt(select_exp.val(), 10)]);
|
||||||
select_exp.remove();
|
select_exp.remove();
|
||||||
|
self.$el.find("#fields_list option").remove();
|
||||||
if (self.$el.find('#saved_export_list option').length <= 1) {
|
if (self.$el.find('#saved_export_list option').length <= 1) {
|
||||||
self.$el.find('#ExistsExportList').hide();
|
self.$el.find('#ExistsExportList').hide();
|
||||||
}
|
}
|
||||||
|
@ -166,18 +167,16 @@ instance.web.DataExport = instance.web.Dialog.extend({
|
||||||
export_fields: _(fields).map(function (field) {
|
export_fields: _(fields).map(function (field) {
|
||||||
return [0, 0, {name: field}];
|
return [0, 0, {name: field}];
|
||||||
})
|
})
|
||||||
}, function (export_list_id) {
|
}).then(function (export_list_id) {
|
||||||
if (!export_list_id.result) {
|
if (!export_list_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.$el.find("#saved_export_list").append(
|
if (!self.$el.find("#saved_export_list").length || self.$el.find("#saved_export_list").is(":hidden")) {
|
||||||
new Option(value, export_list_id.result));
|
|
||||||
if (self.$el.find("#saved_export_list").is(":hidden")) {
|
|
||||||
self.show_exports_list();
|
self.show_exports_list();
|
||||||
}
|
}
|
||||||
|
self.$el.find("#saved_export_list").append( new Option(value, export_list_id) );
|
||||||
});
|
});
|
||||||
this.on_show_save_list();
|
this.on_show_save_list();
|
||||||
this.$el.find("#fields_list option").remove();
|
|
||||||
},
|
},
|
||||||
on_click: function(id, record) {
|
on_click: function(id, record) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -355,7 +355,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'autocompleteopen': function () {
|
'autocompleteopen': function () {
|
||||||
this.$el.autocomplete('widget').css('z-index', 1004);
|
this.$el.autocomplete('widget').css('z-index', 9999);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -677,6 +677,11 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
|
||||||
* @returns instance.web.search.Field
|
* @returns instance.web.search.Field
|
||||||
*/
|
*/
|
||||||
make_field: function (item, field, parent) {
|
make_field: function (item, field, parent) {
|
||||||
|
// M2O combined with selection widget is pointless and broken in search views,
|
||||||
|
// but has been used in the past for unsupported hacks -> ignore it
|
||||||
|
if (field.type === "many2one" && item.attrs.widget === "selection"){
|
||||||
|
item.attrs.widget = undefined;
|
||||||
|
}
|
||||||
var obj = instance.web.search.fields.get_any( [item.attrs.widget, field.type]);
|
var obj = instance.web.search.fields.get_any( [item.attrs.widget, field.type]);
|
||||||
if(obj) {
|
if(obj) {
|
||||||
return new (obj) (item, field, parent || this);
|
return new (obj) (item, field, parent || this);
|
||||||
|
|
|
@ -3125,7 +3125,8 @@ instance.web.form.CompletionFieldMixin = {
|
||||||
if (self.options.quick_create === undefined || self.options.quick_create) {
|
if (self.options.quick_create === undefined || self.options.quick_create) {
|
||||||
new instance.web.DataSet(this, this.field.relation, self.build_context())
|
new instance.web.DataSet(this, this.field.relation, self.build_context())
|
||||||
.name_create(name).done(function(data) {
|
.name_create(name).done(function(data) {
|
||||||
self.add_id(data[0]);
|
if (!self.get('effective_readonly'))
|
||||||
|
self.add_id(data[0]);
|
||||||
}).fail(function(error, event) {
|
}).fail(function(error, event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
slow_create();
|
slow_create();
|
||||||
|
@ -5005,7 +5006,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
|
||||||
this.searchview.on('search_data', self, function(domains, contexts, groupbys) {
|
this.searchview.on('search_data', self, function(domains, contexts, groupbys) {
|
||||||
if (self.initial_ids) {
|
if (self.initial_ids) {
|
||||||
self.do_search(domains.concat([[["id", "in", self.initial_ids]], self.domain]),
|
self.do_search(domains.concat([[["id", "in", self.initial_ids]], self.domain]),
|
||||||
contexts, groupbys);
|
contexts.concat(self.context), groupbys);
|
||||||
self.initial_ids = undefined;
|
self.initial_ids = undefined;
|
||||||
} else {
|
} else {
|
||||||
self.do_search(domains.concat([self.domain]), contexts.concat(self.context), groupbys);
|
self.do_search(domains.concat([self.domain]), contexts.concat(self.context), groupbys);
|
||||||
|
|
|
@ -408,6 +408,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
if (total) {
|
if (total) {
|
||||||
var range_start = this.page * limit + 1;
|
var range_start = this.page * limit + 1;
|
||||||
var range_stop = range_start - 1 + limit;
|
var range_stop = range_start - 1 + limit;
|
||||||
|
if (this.records.length) {
|
||||||
|
range_stop = range_start - 1 + this.records.length;
|
||||||
|
}
|
||||||
if (range_stop > total) {
|
if (range_stop > total) {
|
||||||
range_stop = total;
|
range_stop = total;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +605,17 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
|
||||||
_(ids).each(function (id) {
|
_(ids).each(function (id) {
|
||||||
self.records.remove(self.records.get(id));
|
self.records.remove(self.records.get(id));
|
||||||
});
|
});
|
||||||
self.configure_pager(self.dataset);
|
if (self.records.length === 0 && self.dataset.size() > 0) {
|
||||||
|
//Trigger previous manually to navigate to previous page,
|
||||||
|
//If all records are deleted on current page.
|
||||||
|
self.$pager.find('ul li:first a').trigger('click');
|
||||||
|
} else if (self.dataset.size() == self.limit()) {
|
||||||
|
//Reload listview to update current page with next page records
|
||||||
|
//because pager going to be hidden if dataset.size == limit
|
||||||
|
self.reload();
|
||||||
|
} else {
|
||||||
|
self.configure_pager(self.dataset);
|
||||||
|
}
|
||||||
self.compute_aggregates();
|
self.compute_aggregates();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,15 +21,32 @@ openerp.web_calendar = function(instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_fc_defaultOptions() {
|
function get_fc_defaultOptions() {
|
||||||
|
shortTimeformat = Date.CultureInfo.formatPatterns.shortTime;
|
||||||
return {
|
return {
|
||||||
weekNumberTitle: _t("W"),
|
weekNumberTitle: _t("W"),
|
||||||
allDayText: _t("all-day"),
|
allDayText: _t("All day"),
|
||||||
|
buttonText : {
|
||||||
|
today: _t("Today"),
|
||||||
|
month: _t("Month"),
|
||||||
|
week: _t("Week"),
|
||||||
|
day: _t("Day")
|
||||||
|
},
|
||||||
monthNames: Date.CultureInfo.monthNames,
|
monthNames: Date.CultureInfo.monthNames,
|
||||||
monthNamesShort: Date.CultureInfo.abbreviatedMonthNames,
|
monthNamesShort: Date.CultureInfo.abbreviatedMonthNames,
|
||||||
dayNames: Date.CultureInfo.dayNames,
|
dayNames: Date.CultureInfo.dayNames,
|
||||||
dayNamesShort: Date.CultureInfo.abbreviatedDayNames,
|
dayNamesShort: Date.CultureInfo.abbreviatedDayNames,
|
||||||
firstDay: Date.CultureInfo.firstDayOfWeek,
|
firstDay: Date.CultureInfo.firstDayOfWeek,
|
||||||
weekNumbers: true
|
weekNumbers: true,
|
||||||
|
axisFormat : shortTimeformat.replace(/:mm/,'(:mm)'),
|
||||||
|
timeFormat : {
|
||||||
|
// for agendaWeek and agendaDay
|
||||||
|
agenda: shortTimeformat + '{ - ' + shortTimeformat + '}', // 5:00 - 6:30
|
||||||
|
// for all other views
|
||||||
|
'': shortTimeformat.replace(/:mm/,'(:mm)') // 7pm
|
||||||
|
},
|
||||||
|
weekMode : 'liquid',
|
||||||
|
aspectRatio: 1.8,
|
||||||
|
snapMinutes: 15,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,17 +275,7 @@ openerp.web_calendar = function(instance) {
|
||||||
|
|
||||||
unselectAuto: false,
|
unselectAuto: false,
|
||||||
|
|
||||||
// Options
|
|
||||||
timeFormat : {
|
|
||||||
// for agendaWeek and agendaDay
|
|
||||||
agenda: 'h:mm{ - h:mm}', // 5:00 - 6:30
|
|
||||||
|
|
||||||
// for all other views
|
|
||||||
'': 'h(:mm)tt' // 7pm
|
|
||||||
},
|
|
||||||
weekMode : 'liquid',
|
|
||||||
aspectRatio: 1.8,
|
|
||||||
snapMinutes: 15,
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -293,11 +300,18 @@ openerp.web_calendar = function(instance) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!this.sidebar && this.options.$sidebar) {
|
if (!this.sidebar && this.options.$sidebar) {
|
||||||
|
translate = get_fc_defaultOptions();
|
||||||
this.sidebar = new instance.web_calendar.Sidebar(this);
|
this.sidebar = new instance.web_calendar.Sidebar(this);
|
||||||
this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container'));
|
this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container'));
|
||||||
|
|
||||||
this.$small_calendar = self.$el.find(".oe_calendar_mini");
|
this.$small_calendar = self.$el.find(".oe_calendar_mini");
|
||||||
this.$small_calendar.datepicker({ onSelect: self.calendarMiniChanged(self) });
|
this.$small_calendar.datepicker({
|
||||||
|
onSelect: self.calendarMiniChanged(self),
|
||||||
|
dayNamesMin : translate.dayNamesShort,
|
||||||
|
monthNames: translate.monthNamesShort,
|
||||||
|
firstDay: translate.firstDay,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (this.useContacts) {
|
if (this.useContacts) {
|
||||||
//Get my Partner ID
|
//Get my Partner ID
|
||||||
|
|
Loading…
Reference in New Issue