mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Started a jQuery utilities file for Ghost jQuery plugins and helpers
This commit is contained in:
parent
7111960fac
commit
d59f0809cd
2 changed files with 41 additions and 0 deletions
40
core/client/assets/lib/jquery-utils.js
vendored
Normal file
40
core/client/assets/lib/jquery-utils.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// # 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;
|
||||
};
|
||||
|
||||
}());
|
|
@ -51,6 +51,7 @@
|
|||
<script src="/public/vendor/jquery/jquery-ui-1.10.3.custom.min.js"></script>
|
||||
<script src="/public/vendor/packery.pkgd.min.js"></script>
|
||||
|
||||
<script src="/public/lib/jquery-utils.js"></script>
|
||||
<script src="/public/init.js"></script>
|
||||
<script src="/public/tpl/hbs-tpl.js"></script>
|
||||
<script src="/public/toggle.js"></script>
|
||||
|
|
Loading…
Add table
Reference in a new issue