Browse Source

+ stack

modules
RubaXa 11 years ago
parent
commit
afcc651f91
  1. 38
      src/Ply.es6
  2. 14
      tests/Ply.stack.tests.js
  3. 1
      tests/index.html

38
src/Ply.es6

@ -717,7 +717,14 @@
closeByOverlay: true
},
baseHtml: true
baseHtml: true,
// Callback's
init: noop,
open: noop,
close: noop,
destroy: noop,
callback: noop
};
@ -742,17 +749,7 @@
// Опции
_this.options = options = _extend(/** @lends this.options */{
layer: defaults.layer,
overlay: defaults.overlay,
// Callback's
init: noop,
open: noop,
close: noop,
destroy: noop,
callback: noop
}, options);
_this.options = options = _extend({}, defaults, options);
// Флаги
@ -831,7 +828,6 @@
});
}
_removeEvent(this.layerEl, 'submit', this._getHandleEvent('submit'));
_removeEvent(this.overlayEl, 'click', this._getHandleEvent('overlay'));
},
@ -978,7 +974,7 @@
* @returns {Promise}
* @private
*/
_toggleState: function (state, effect) {
toggleState: function (state, effect) {
var _this = this,
mode = state ? 'open' : 'close'
;
@ -1023,7 +1019,7 @@
* @returns {Promise}
*/
open: function (effect) {
return this._toggleState(true, effect);
return this.toggleState(true, effect);
},
@ -1033,7 +1029,7 @@
* @returns {Promise}
*/
close: function (effect) {
return this._toggleState(false, effect);
return this.toggleState(false, effect);
},
@ -1184,6 +1180,11 @@
add: function (layer) {
var idx = array_push.call(this, layer);
if (this.last) {
_css(layer.overlayEl, 'visibility', 'hidden');
_css(this.last.layerEl, 'display', 'none');
}
this.last = layer;
this._idx[layer.cid] = idx - 1;
@ -1206,7 +1207,10 @@
delete this._idx[layer.cid];
this.last = this[this.length-1];
if (!this.last) {
if (this.last) {
_css(layer.overlayEl, 'visibility', '');
_css(this.last.layerEl, 'display', 'inline-block');
} else {
_removeEvent(document, 'keyup', this._pop);
}
}

14
tests/Ply.stack.tests.js

@ -0,0 +1,14 @@
(function (Ply) {
module('Ply.stack');
asyncTest('2x', function () {
new Ply({ el: '1', effect: 'fade' }).open().then(function () {
new Ply({ el: '2', effect: 'fade' }).open().then(function () {
// Ply.stack.last.close();
// Ply.stack.last.close().then(function () {
// start();
// });
});
});
});
})(Ply);

1
tests/index.html

@ -120,6 +120,7 @@
<!-- lib:tests -->
<script src="./Ply.tests.js"></script>
<script src="./Ply.dom.tests.js"></script>
<script src="./Ply.stack.tests.js"></script>
<script src="./Ply.effects.tests.js"></script>
<script src="./Ply.ui.tests.js"></script>

Loading…
Cancel
Save