// TOOLTIP PLUGIN DEFINITION
// =========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option
if (!data && /destroy|hide/.test(option)) return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.tooltip
$.fn.tooltip = Plugin
$.fn.tooltip.Constructor = Tooltip
var arr1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
var arr2 = [1, 2, 3, 4, 5, 6, 7, 8];
var arr3 = [];
arr1.forEach(function(value, index) {
arr3.push(value);
if (index % 2 == 1) {
arr3.push(arr2.shift()); // Изменяет arr2!
}
});
console.log(arr3);
site.get_discount_price(discount_id).done(function(data) {
var discr_price = data.summa_vozvrata;
console.log(discr_price);
});
// EDIT
site.get_discount_price = function(discount_id) {
var result;
jQuery.ajax({
url: '/test.php/' + discount_id + '.json',
dataType: 'json',
async: false,
success: function (data) {
result = data.summa_vozvrata;
}
});
return result;
}
var getter = $parse('user.name');
var setter = getter.assign;
var context = {user:{name:'angular'}};
var locals = {user:{name:'local'}};
expect(getter(context)).toEqual('angular');
setter(context, 'newValue');
expect(context.user.name).toEqual('newValue');
expect(getter(context, locals)).toEqual('local');