');
e.click();
var p = tip(e);
ok(p.is(':visible'), 'popover shown');
e.remove();
ok(!p.is(':visible'), 'popover closed');
});
// test("should store name and value and lastSavedValue", function () {
test("should store name and value", function () {
var v = 'abr><"&
').text(v).html(),
e = $('
qwe').appendTo('#qunit-fixture').editable(),
e2 = $('
'+v+'').appendTo('#qunit-fixture').editable(),
e3 = $('
'+esc_v+'').appendTo('#qunit-fixture').editable();
equal(e.data('editable').options.name, 'abc', 'name exists');
equal(e.data('editable').value, '123', 'value exists');
// equal(e.data('editable').lastSavedValue, '123', 'lastSavedValue exists');
equal(e2.data('editable').value, visible_v, 'value taken from elem content correctly');
// equal(e2.data('editable').lastSavedValue, visible_v, 'lastSavedValue taken from text correctly');
equal(e3.data('editable').value, v, 'value taken from elem content correctly (escaped)');
// equal(e3.data('editable').lastSavedValue, v, 'lastSavedValue taken from text correctly (escaped)');
});
test("should take container's title from json options", function () {
//do not test inline
if(fc.c === 'inline') {
expect(0);
return;
}
var title = 'abc',
//add to fx because qunit-fixture has wrong positioning
e = $('
').appendTo(fx).editable({
placement: 'bottom',
title: title
});
e.click();
var p = tip(e);
ok(p.is(':visible'), 'popover shown');
//todo: for jqueryui phantomjs calcs wrong position. Need investigation
if(!$.browser.webkit && fc.f !== 'jqueryui') {
ok(p.offset().top > e.offset().top, 'placement ok');
}
ok(p.find(':contains("'+title+'")').length, 'title ok');
e.remove();
});
test("should close all other containers on click on editable", function () {
var e1 = $('
abc').appendTo('#qunit-fixture').editable(),
e2 = $('
abcd').appendTo('#qunit-fixture').editable();
e1.click()
var p1 = tip(e1);
ok(p1.is(':visible'), 'popover1 visible');
e2.click()
var p2 = tip(e2);
ok(p2.is(':visible'), 'popover2 visible');
ok(!p1.is(':visible'), 'popover1 closed');
p2.find('button[type=button]').click();
ok(!p2.is(':visible'), 'popover2 closed');
});
test("click outside popoover should hide it", function () {
var e = $('
abc').appendTo('#qunit-fixture').editable(),
e1 = $('
').appendTo('body');
e.click();
var p = tip(e);
ok(p.is(':visible'), 'popover shown');
p.click();
ok(p.is(':visible'), 'popover still shown');
e1.click();
ok(!p.is(':visible'), 'popover closed');
});
//unfortunatly, testing this feature does not always work in browsers. Tested manually.
/*
test("enablefocus option", function () {
// focusing not passed in phantomjs
if($.browser.webkit) {
ok(true, 'skipped in PhantomJS');
return;
}
var e = $('
abc').appendTo('#qunit-fixture').editable({
enablefocus: true
}),
e1 = $('
abcd').appendTo('#qunit-fixture').editable({
enablefocus: false
});
e.click()
var p = tip(e);
ok(p.is(':visible'), 'popover 1 visible');
p.find('button[type=button]').click();
ok(!p.is(':visible'), 'popover closed');
ok(e.is(':focus'), 'element 1 is focused');
e1.click()
p = tip(e1);
ok(p.is(':visible'), 'popover 2 visible');
p.find('button[type=button]').click();
ok(!p.is(':visible'), 'popover closed');
ok(!e1.is(':focus'), 'element 2 is not focused');
});
*/
}(jQuery));