Created
February 18, 2013 16:18
-
-
Save a-ignatov-parc/4978536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Инициализируем попапы для всех элементов что попадают под селектор и получаем конструктор | |
| // поповера | |
| var popoverConstructor = $(selector).popover({ | |
| html: true, | |
| container: '.b-container', | |
| template: 'some template...', | |
| content: function() { | |
| // Обрабатываем контент и возвращаем | |
| return content; | |
| }, | |
| placement: 'top' | |
| }).data().popover.constructor; | |
| // Переопределяем прототип чтоб мы могли изменить поведение именно этого поповера | |
| popoverConstructor.prototype = $.extend({}, popoverConstructor.prototype, { | |
| // Поведение метода applyPlacement можно изменить двумя способами. | |
| // 1. Мы выполняем оригинальный метод, а потом делаем допозиционирование | |
| applyPlacement: (function(fn) { | |
| return function() { | |
| var result = fn.apply(this, arguments); | |
| // Тут делаем допозиционирование и возвращаем результат оригинального метода | |
| return result; | |
| } | |
| })(popoverConstructor.prototype.applyPlacement), | |
| // 2. Мы полностью переопределяем метод и пишем позиционирование сами | |
| applyPlacement: function() { | |
| // Позиционируем поповер сами | |
| }, | |
| replaceArrow: function(delta, dimension, position) { | |
| // Позиционируем стрелку | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment