Skip to content

Commit

Permalink
how should not be string
Browse files Browse the repository at this point in the history
  • Loading branch information
vitkarpov committed Nov 30, 2015
1 parent d09169e commit 01a0233
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 8 deletions.
16 changes: 8 additions & 8 deletions blocks/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,21 +683,21 @@
var that = this;
var params = params || {};
var how = how || {};

var data = this.nbdata();

if (how === 'fixed' || data.how === 'fixed') {
how = {fixed: true};
}

// по умолчанию попап позиционирова абсолютно
var isFixed = false;

// сделаем попап фиксированным, если
// у popup-toggler задан how.fixed = true
// сделаем попап фиксированным, если:
// - у popup-toggler задан how.fixed = true
// - был задан атрибут data-nb-how = 'fixed' у самого попапа
if (how.fixed) {
isFixed = true;
}
// или если был задан атрибут data-nb-how = 'fixed'
// в настройках самого попапа
if (data && data.how == 'fixed') {
isFixed = true;
}

var using = function(props) {
var $el = $(this);
Expand Down
33 changes: 33 additions & 0 deletions unittests/spec/popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,39 @@ describe("Popup Tests", function() {
});
});

describe("Popup should be fixed", function() {
beforeEach(function() {
this.toggler1 = nb.find('popup-toggler-fixed1');
this.toggler2 = nb.find('popup-toggler-fixed2');
});
afterEach(function() {
this.toggler1.destroy();
this.toggler2.destroy();
});

it("when it`s toggler has how: 'fixed' option", function(done) {
var toggler = this.toggler1;
var popup = toggler.getPopup();

popup.on('nb-opened', function() {
expect(popup.$node.parent().hasClass('ui-dialog-fixed')).to.be.ok();
done();
});
toggler.open();
});

it("when it has data-nb-how attr defined as fixed", function(done) {
var toggler = this.toggler2;
var popup = toggler.getPopup();

popup.on('nb-opened', function() {
expect(popup.$node.parent().hasClass('ui-dialog-fixed')).to.be.ok();
done();
});
toggler.open();
});
});

describe("Popup extra modifier", function() {
describe("in case of popup_mod", function() {
beforeEach(function() {
Expand Down
26 changes: 26 additions & 0 deletions unittests/spec/popup/popup.yate
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ match .popup {
</span>
</a>

// тогглер сам задает fixed для попапа
<a id="popup-toggler-fixed1" class="_init" data-nb="popup-toggler" data-nb-popup-toggler="{{id: 'popup-fixed1', appendTo: '.content', how: 'fixed'}}" href="#default">
<span class="link__inner">
"popup"
</span>
</a>

<a id="popup-toggler-fixed2" class="_init" data-nb="popup-toggler" data-nb-popup-toggler="{{id: 'popup-fixed2', appendTo: '.content'}}" href="#default">
<span class="link__inner">
"popup"
</span>
</a>

// Попап, находящийся в тесном блоке, проверяется выравнивание хвостика.
<div class="tight" style="width: 50px; height: 20px;">
<a id="popup-toggler-tight" class="_init" data-nb="popup-toggler" data-nb-popup-toggler="{{id: 'popup-tight', appendTo: '.tight'}}" href="#default">
Expand Down Expand Up @@ -82,6 +95,19 @@ match .popup {
'content': 'Hello, words!'
})

nb-popup({
'id': 'popup-fixed1'
'content': 'Hello, words!'
})

nb-popup({
'id': 'popup-fixed2'
'data-nb': {
'how': 'fixed'
}
'content': 'Hello, words!'
})

nb-popup-menu({
'id': 'popup-menu'
'menu': [
Expand Down

0 comments on commit 01a0233

Please sign in to comment.