mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
40 lines
873 B
JavaScript
40 lines
873 B
JavaScript
// # Ghost jQuery Utils
|
|
|
|
/*global window, document, $ */
|
|
|
|
(function () {
|
|
"use strict";
|
|
|
|
// UTILS
|
|
|
|
/**
|
|
* Allows to check contents of each element exactly
|
|
* @param obj
|
|
* @param index
|
|
* @param meta
|
|
* @param stack
|
|
* @returns {boolean}
|
|
*/
|
|
$.expr[":"].containsExact = function (obj, index, meta, stack) {
|
|
return (obj.textContent || obj.innerText || $(obj).text() || "") === meta[3];
|
|
};
|
|
|
|
/**
|
|
* Center an element to the window vertically and centrally
|
|
* @returns {*}
|
|
*/
|
|
$.fn.center = function () {
|
|
this.css({
|
|
'position': 'fixed',
|
|
'left': '50%',
|
|
'top': '50%'
|
|
});
|
|
this.css({
|
|
'margin-left': -this.outerWidth() / 2 + 'px',
|
|
'margin-top': -this.outerHeight() / 2 + 'px'
|
|
});
|
|
|
|
return this;
|
|
};
|
|
|
|
}()); |