Browse Source

+ 'always' method

dev
RubaXa 11 years ago
parent
commit
062b975340
  1. 466
      Ply.min.js
  2. 11
      src/Ply.es6
  3. 3
      src/dom.es6
  4. 12
      src/promise.es6
  5. 6
      src/ui.es6
  6. 12
      tests/Ply.ui.tests.js

466
Ply.min.js vendored

File diff suppressed because one or more lines are too long

11
src/Ply.es6

@ -4,8 +4,8 @@
* Обязательно нужен JSON и Promise
*/
/*global require, define, window */
((factory) => {
/*global require, define, window*/
(factory => {
'use strict';
if( typeof define === 'function' && define.amd ){
@ -39,6 +39,13 @@
;
//
// $-like object
//
var $ = require('jquery');
//
// Настройки по умолчанию
//

3
src/dom.es6

@ -3,9 +3,6 @@
*/
var $ = require('jquery');
/**
* Разбор строки "tag#id.foo.bar"
* @const {RegExp}

12
src/promise.js → src/promise.es6

@ -6,7 +6,6 @@
var Promise = window.Deferred || window.Promise;
/**
* Создать «Обещание»
* @param {Function} executor
@ -59,3 +58,14 @@ function _cast(value) {
return value && value.then ? value : _resolvePromise(value);
}
//
// Проверяем поддержку метода always
//
if (!_resolvePromise().always) {
Promise.prototype.always = function (callback) {
this.then(callback, callback);
return this;
};
}

6
src/ui.es6

@ -2,7 +2,7 @@
* @desc Диалоги
*/
/*global define, Ply */
/*global Ply */
;;;(Ply => {
'use strict';
@ -396,9 +396,9 @@
}
return Ply.open(name, options, data).then((layer) => {
return _promise((resolve) => {
return _promise((resolve, reject) => {
layer.options.close = () => {
resolve(layer.result);
(layer.result.state ? resolve : reject)(layer.result);
};
});
});

12
tests/Ply.ui.tests.js

@ -2,14 +2,15 @@
module('Ply.ui');
promiseTest('dialog("unknown")', function () {
asyncTest('dialog("unknown")', function () {
setTimeout(function () {
simulateEvent(Ply.stack.last.overlayEl, 'click');
}, 50);
return Ply.dialog('unknown').then(function (ui) {
Ply.dialog('unknown').always(function (ui) {
equal(ui.by, 'overlay', 'ui.by');
equal(ui.state, false, 'ui.state');
start();
});
});
@ -27,18 +28,19 @@
});
promiseTest('dialog("confirm")', function () {
asyncTest('dialog("confirm")', function () {
setTimeout(function () {
var el = Ply.stack.last.wrapEl;
el.getElementsByTagName('button')[1].click();
}, 50);
return Ply.dialog('confirm', { effect: 'none:1' }, {
Ply.dialog('confirm', { effect: 'none:1' }, {
title: "???",
text: "!!!"
}).then(function (ui) {
}).always(function (ui) {
equal(ui.by, 'cancel', 'ui.by');
equal(ui.state, false, 'ui.state');
start();
});
});

Loading…
Cancel
Save