21 Commits
Author SHA1 Message Date
Andrey Savchenko 1d87865377 Updated readme. 2014-07-11 17:48:19 +03:00
Andrey Savchenko 283f8632df Disabled tooltip animation to fix JS error and UI disappearing from under cursor. 2014-07-11 17:47:54 +03:00
Andrey Savchenko eac2ab5fad Simplified robo task for tooltip to single write. 2014-06-29 00:25:59 +03:00
Andrey Savchenko 26df4f5579 Updated Bootstrap license info in readme. 2014-06-28 23:25:50 +03:00
Andrey Savchenko 83972fdb69 Updated tooltip script. 2014-06-28 23:25:02 +03:00
Andrey Savchenko e42787ec16 Added robo task to generate edited tooltip script from Bootstrap source. 2014-06-28 23:10:48 +03:00
Andrey Savchenko 174b171cdd Refactored less workflow to reference Bootstrap sources. 2014-06-28 22:26:26 +03:00
Andrey Savchenko 2a6c9339d3 Added Robo configuration file for automation. 2014-06-28 22:24:48 +03:00
Andrey Savchenko 103e0c36f5 Committed composer.lock file. 2014-06-28 22:24:05 +03:00
Andrey Savchenko 0e48a61157 Added Bootstrap as development dependency. 2014-06-28 22:23:39 +03:00
Andrey Savchenko 68f8ae42e9 Updated plugin header 2014-05-31 21:36:04 +03:00
Andrey Savchenko f8fa008ec7 Updated links in composer.json for GitHub 2014-05-31 21:32:59 +03:00
Andrey Savchenko b0d376ea8c Updated version in plugin header. 2014-05-24 19:09:54 +03:00
Andrey Savchenko 5cea91d656 Updated readme for 1.2 release. 2014-05-18 23:04:09 +03:00
Andrey Savchenko f568830513 Positioned timeline containers to fix absolute positioning of events inside. 2014-05-18 23:01:09 +03:00
Andrey Savchenko 00ba356da7 Refactored Toolbar event. 2014-05-18 22:41:45 +03:00
Andrey Savchenko 54bb79b202 Updated installation instructions for Packagist. 2014-05-18 22:02:46 +03:00
Andrey Savchenko 334d1cbacc Renamed .hgignore to .gitignore 2014-05-18 22:00:51 +03:00
Tom Nowell 32d8752261 use the core event category rather than admin 2014-04-14 14:36:38 +00:00
Tom Nowell 84eba6e39d Add additional core events 2014-04-12 18:41:11 +00:00
Andrey Savchenko b774292fda Added tag 1.1 for changeset a0de24fa9421 2013-12-11 18:05:59 +02:00
15 changed files with 577 additions and 262 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
vendor
-2
View File
@@ -1,2 +0,0 @@
vendor
composer.lock
+51
View File
@@ -0,0 +1,51 @@
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks {
/**
* Watches for changes.
*/
public function watch() {
$less_callback = function () {
$this->less();
};
$this->taskWatch()
->monitor( 'css/variables.less', $less_callback )
->monitor( 'css/laps.less', $less_callback )
->run();
}
/**
* Compiles stylesheet from less into css.
*/
public function less() {
$this->taskExec( 'lessc css/laps.less css/laps.css' )->run();
}
/**
* Copies tooltip.js from Bootstrap sources and edits plugin name.
*/
public function tooltip() {
$replacements = array(
'+function ($) {' => '// modified to use lapstooltip as plugin name' . "\n\n" . '+function ($) {',
'this.init(\'tooltip\'' => 'this.init(\'lapstooltip\'',
'bs.tooltip' => 'bs.lapstooltip',
'$.fn.tooltip' => '$.fn.lapstooltip',
);
$source = strtr( file_get_contents( 'vendor/twbs/bootstrap/js/tooltip.js' ), $replacements );
$this->taskWriteToFile( 'js/tooltip.js' )
->text( $source )
->run();
}
}
+5 -3
View File
@@ -3,7 +3,7 @@
"description": "Light WordPress profiler.",
"keywords" : ["wordpress", "performance"],
"type" : "wordpress-plugin",
"homepage" : "https://bitbucket.org/Rarst/laps",
"homepage" : "https://github.com/Rarst/laps",
"license" : "MIT",
"authors" : [
{
@@ -13,8 +13,7 @@
}
],
"support" : {
"issues": "https://bitbucket.org/Rarst/laps/issues",
"source": "https://bitbucket.org/Rarst/laps/src"
"issues": "https://github.com/Rarst/laps/issues"
},
"autoload" : {
"classmap": ["src/"]
@@ -23,5 +22,8 @@
"composer/installers": "~1.0",
"symfony/stopwatch" : "~2.4",
"mustache/mustache" : "~2.4"
},
"require-dev": {
"twbs/bootstrap": "~3.2"
}
}
Generated
+251
View File
@@ -0,0 +1,251 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "7495421e8df337988c9906e05aab637b",
"packages": [
{
"name": "composer/installers",
"version": "v1.0.15",
"source": {
"type": "git",
"url": "https://github.com/composer/installers.git",
"reference": "8e6a72a78f6cfd537fde3350720dfdc9ae3c5621"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/installers/zipball/8e6a72a78f6cfd537fde3350720dfdc9ae3c5621",
"reference": "8e6a72a78f6cfd537fde3350720dfdc9ae3c5621",
"shasum": ""
},
"replace": {
"roundcube/plugin-installer": "*",
"shama/baton": "*"
},
"require-dev": {
"composer/composer": "1.0.*@dev",
"phpunit/phpunit": "4.1.*"
},
"type": "composer-installer",
"extra": {
"class": "Composer\\Installers\\Installer",
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-0": {
"Composer\\Installers\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kyle Robinson Young",
"email": "kyle@dontkry.com",
"homepage": "https://github.com/shama",
"role": "Developer"
}
],
"description": "A multi-framework Composer library installer",
"homepage": "http://composer.github.com/installers/",
"keywords": [
"Craft",
"Dolibarr",
"Hurad",
"MODX Evo",
"OXID",
"WolfCMS",
"agl",
"annotatecms",
"bitrix",
"cakephp",
"codeigniter",
"concrete5",
"croogo",
"drupal",
"elgg",
"fuelphp",
"installer",
"joomla",
"kohana",
"laravel",
"lithium",
"magento",
"mako",
"mediawiki",
"modulework",
"moodle",
"phpbb",
"piwik",
"ppi",
"roundcube",
"shopware",
"silverstripe",
"symfony",
"typo3",
"wordpress",
"zend",
"zikula"
],
"time": "2014-06-23 16:25:28"
},
{
"name": "mustache/mustache",
"version": "v2.6.1",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/mustache.php.git",
"reference": "1430ca884912eaba2b3830856b45685733b16789"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/1430ca884912eaba2b3830856b45685733b16789",
"reference": "1430ca884912eaba2b3830856b45685733b16789",
"shasum": ""
},
"require": {
"php": ">=5.2.4"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"psr-0": {
"Mustache": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Justin Hileman",
"email": "justin@justinhileman.info",
"homepage": "http://justinhileman.com"
}
],
"description": "A Mustache implementation in PHP.",
"homepage": "https://github.com/bobthecow/mustache.php",
"keywords": [
"mustache",
"templating"
],
"time": "2014-06-20 19:34:49"
},
{
"name": "symfony/stopwatch",
"version": "v2.5.0",
"target-dir": "Symfony/Component/Stopwatch",
"source": {
"type": "git",
"url": "https://github.com/symfony/Stopwatch.git",
"reference": "724d73604ebe6c1c9bdf36533b556123bd9075a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/724d73604ebe6c1c9bdf36533b556123bd9075a1",
"reference": "724d73604ebe6c1c9bdf36533b556123bd9075a1",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Stopwatch\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Stopwatch Component",
"homepage": "http://symfony.com",
"time": "2014-04-18 20:40:13"
}
],
"packages-dev": [
{
"name": "twbs/bootstrap",
"version": "v3.2.0",
"source": {
"type": "git",
"url": "https://github.com/twbs/bootstrap.git",
"reference": "c068162161154a4b85110ea1e7dd3d7897ce2b72"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/c068162161154a4b85110ea1e7dd3d7897ce2b72",
"reference": "c068162161154a4b85110ea1e7dd3d7897ce2b72",
"shasum": ""
},
"replace": {
"twitter/bootstrap": "self.version"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jacob Thornton",
"email": "jacobthornton@gmail.com"
},
{
"name": "Mark Otto",
"email": "markdotto@gmail.com"
}
],
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
"homepage": "http://getbootstrap.com",
"keywords": [
"JS",
"css",
"framework",
"front-end",
"less",
"mobile-first",
"responsive",
"web"
],
"time": "2014-06-26 16:36:48"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"platform": [],
"platform-dev": []
}
+18 -3
View File
@@ -19,28 +19,43 @@
#wpadminbar .laps-timeline {
overflow: hidden;
height: 20px;
margin: 6px 0;
margin-bottom: 20px;
background-color: #f5f5f5;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
margin: 6px 0;
position: relative;
}
#wpadminbar .laps-timeline .event {
float: left;
width: 0%;
height: 20px;
height: 100%;
font-size: 12px;
color: #fff;
line-height: 20px;
color: #ffffff;
text-align: center;
background-color: #5bc0de;
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
-webkit-transition: width 0.6s ease;
-o-transition: width 0.6s ease;
transition: width 0.6s ease;
position: absolute;
border-left: 1px solid #f5f5f5;
min-width: 2px;
}
#wpadminbar .laps-timeline .event[aria-valuenow="1"],
#wpadminbar .laps-timeline .event[aria-valuenow="2"] {
min-width: 30px;
}
#wpadminbar .laps-timeline .event[aria-valuenow="0"] {
color: #777777;
min-width: 30px;
background-color: transparent;
background-image: none;
box-shadow: none;
}
#wpadminbar .laps-timeline .event-theme {
background-color: #5cb85c;
}
+34 -47
View File
@@ -1,5 +1,7 @@
@import (reference) "../vendor/twbs/bootstrap/less/variables.less";
@import (reference) "../vendor/twbs/bootstrap/less/mixins.less";
@import (reference) "../vendor/twbs/bootstrap/less/progress-bars.less";
@import "variables.less";
@import "mixins.less";
#wpadminbar {
@@ -7,9 +9,9 @@
.ab-sub-wrapper {
min-width: 90%;
width: 90%;
position: fixed;
left: 5%;
width: 90%;
position: fixed;
left: 5%;
}
.ab-submenu {
@@ -31,50 +33,35 @@
}
.laps-timeline {
overflow: hidden;
height: 20px;
margin: 6px 0;
background-color: @timeline-bg;
border-radius: 4px;
.box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
.progress;
margin: 6px 0;
position: relative;
.event {
.progress-bar;
position: absolute; // disable stacking at start
border-left: 1px solid @timeline-bg;
min-width: 2px;
}
.event-theme {
background-color: @event-theme-color;
}
.event-plugin {
background-color: @event-plugin-color;
}
.event-core {
background-color: @event-core-color;
}
.event-query {
background-color: @event-info-color;
}
.event-http {
background-color: @event-warning-color;
}
}
.laps-timeline .event {
float: left;
width: 0%;
height: 20px;
font-size: @font-size-small;
color: #fff;
text-align: center;
background-color: @event-info-color;
.box-shadow(inset 0 -1px 0 rgba(0, 0, 0, .15));
.transition(width .6s ease);
position: absolute; // disable stacking at start
border-left: 1px solid @timeline-bg;
min-width: 2px;
}
.laps-timeline .event-theme {
background-color: @event-theme-color;
}
.laps-timeline .event-plugin {
background-color: @event-plugin-color;
}
.laps-timeline .event-core {
background-color: @event-core-color;
}
.laps-timeline .event-query {
background-color: @event-info-color;
}
.laps-timeline .event-http {
background-color: @event-warning-color;
}
@import "tooltip.less";
@import "../vendor/twbs/bootstrap/less/tooltip.less";
.tooltip.in {
.opacity(1);
@@ -82,7 +69,7 @@
.tooltip-inner {
line-height: 20px;
text-align: left;
text-align: left;
}
}
-16
View File
@@ -1,16 +0,0 @@
.transition(@transition) {
-webkit-transition: @transition;
transition: @transition;
}
.box-shadow(@shadow) {
-webkit-box-shadow: @shadow; // iOS <4.3 & Android <4.1
box-shadow: @shadow;
}
.opacity(@opacity) {
opacity: @opacity;
// IE8 filter
@opacity-ie: (@opacity * 100);
filter: ~"alpha(opacity=@{opacity-ie})";
}
-94
View File
@@ -1,94 +0,0 @@
//
// Tooltips
// --------------------------------------------------
// Base class
.tooltip {
position: absolute;
z-index: @zindex-tooltip;
display: block;
visibility: visible;
font-size: @font-size-small;
line-height: 1.4;
.opacity(0);
&.in { .opacity(.9); }
&.top { margin-top: -3px; padding: @tooltip-arrow-width 0; }
&.right { margin-left: 3px; padding: 0 @tooltip-arrow-width; }
&.bottom { margin-top: 3px; padding: @tooltip-arrow-width 0; }
&.left { margin-left: -3px; padding: 0 @tooltip-arrow-width; }
}
// Wrapper for the tooltip content
.tooltip-inner {
max-width: @tooltip-max-width;
padding: 3px 8px;
color: @tooltip-color;
text-align: center;
text-decoration: none;
background-color: @tooltip-bg;
border-radius: @border-radius-base;
}
// Arrows
.tooltip-arrow {
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.tooltip {
&.top .tooltip-arrow {
bottom: 0;
left: 50%;
margin-left: -@tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
border-top-color: @tooltip-arrow-color;
}
&.top-left .tooltip-arrow {
bottom: 0;
left: @tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
border-top-color: @tooltip-arrow-color;
}
&.top-right .tooltip-arrow {
bottom: 0;
right: @tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width 0;
border-top-color: @tooltip-arrow-color;
}
&.right .tooltip-arrow {
top: 50%;
left: 0;
margin-top: -@tooltip-arrow-width;
border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0;
border-right-color: @tooltip-arrow-color;
}
&.left .tooltip-arrow {
top: 50%;
right: 0;
margin-top: -@tooltip-arrow-width;
border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width;
border-left-color: @tooltip-arrow-color;
}
&.bottom .tooltip-arrow {
top: 0;
left: 50%;
margin-left: -@tooltip-arrow-width;
border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
border-bottom-color: @tooltip-arrow-color;
}
&.bottom-left .tooltip-arrow {
top: 0;
left: @tooltip-arrow-width;
border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
border-bottom-color: @tooltip-arrow-color;
}
&.bottom-right .tooltip-arrow {
top: 0;
right: @tooltip-arrow-width;
border-width: 0 @tooltip-arrow-width @tooltip-arrow-width;
border-bottom-color: @tooltip-arrow-color;
}
}
+3
View File
@@ -1,4 +1,5 @@
@font-size-small: 12px;
@line-height-computed: 20px;
// colors
@timeline-bg: #f5f5f5;
@@ -7,6 +8,8 @@
@event-core-color: #f0ad4e;
@event-info-color: #5bc0de;
@event-warning-color: #d9534f;
@progress-bg: @timeline-bg;
@progress-bar-bg: @event-info-color;
// because admin bar is 99999
@zindex-tooltip: 100000;
+159 -87
View File
@@ -1,26 +1,17 @@
/* ========================================================================
* Bootstrap: tooltip.js v3.0.2
* Bootstrap: tooltip.js v3.2.0
* http://getbootstrap.com/javascript/#tooltip
* Inspired by the original jQuery.tipsy by Jason Frame
* ========================================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
// modified to use lapstooltip as name
+function ($) { "use strict";
// modified to use lapstooltip as plugin name
+function ($) {
'use strict';
// TOOLTIP PUBLIC CLASS DEFINITION
// ===============================
@@ -36,23 +27,30 @@
this.init('lapstooltip', element, options)
}
Tooltip.VERSION = '3.2.0'
Tooltip.DEFAULTS = {
animation: true
, placement: 'top'
, selector: false
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
, trigger: 'hover focus'
, title: ''
, delay: 0
, html: false
, container: false
animation: true,
placement: 'top',
selector: false,
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
trigger: 'hover focus',
title: '',
delay: 0,
html: false,
container: false,
viewport: {
selector: 'body',
padding: 0
}
}
Tooltip.prototype.init = function (type, element, options) {
this.enabled = true
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.enabled = true
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
var triggers = this.options.trigger.split(' ')
@@ -62,8 +60,8 @@
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
@@ -84,8 +82,8 @@
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
, hide: options.delay
show: options.delay,
hide: options.delay
}
}
@@ -105,7 +103,12 @@
Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
obj : $(obj.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
}
clearTimeout(self.timeout)
@@ -120,7 +123,12 @@
Tooltip.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
obj : $(obj.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
}
clearTimeout(self.timeout)
@@ -134,16 +142,22 @@
}
Tooltip.prototype.show = function () {
var e = $.Event('show.bs.'+ this.type)
var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) {
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
var inDom = $.contains(document.documentElement, this.$element[0])
if (e.isDefaultPrevented() || !inDom) return
var that = this
var $tip = this.tip()
var tipId = this.getUID(this.type)
this.setContent()
$tip.attr('id', tipId)
this.$element.attr('aria-describedby', tipId)
if (this.options.animation) $tip.addClass('fade')
@@ -159,6 +173,7 @@
.detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement)
.data('bs.' + this.type, this)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
@@ -167,18 +182,14 @@
var actualHeight = $tip[0].offsetHeight
if (autoPlace) {
var $parent = this.$element.parent()
var orgPlacement = placement
var docScroll = document.documentElement.scrollTop || document.body.scrollTop
var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
var $parent = this.$element.parent()
var parentDim = this.getPosition($parent)
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
placement
$tip
@@ -189,12 +200,21 @@
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
this.applyPlacement(calculatedOffset, placement)
this.$element.trigger('shown.bs.' + this.type)
var complete = function () {
that.$element.trigger('shown.bs.' + that.type)
that.hoverState = null
}
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) :
complete()
}
}
Tooltip.prototype.applyPlacement = function(offset, placement) {
var replace
Tooltip.prototype.applyPlacement = function (offset, placement) {
var $tip = this.tip()
var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight
@@ -210,42 +230,42 @@
offset.top = offset.top + marginTop
offset.left = offset.left + marginLeft
$tip
.offset(offset)
.addClass('in')
// $.fn.offset doesn't round pixel values
// so we use setOffset directly with our own function B-0
$.offset.setOffset($tip[0], $.extend({
using: function (props) {
$tip.css({
top: Math.round(props.top),
left: Math.round(props.left)
})
}
}, offset), 0)
$tip.addClass('in')
// check to see if placing tip in new offset caused the tip to resize itself
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) {
replace = true
offset.top = offset.top + height - actualHeight
}
if (/bottom|top/.test(placement)) {
var delta = 0
var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
if (offset.left < 0) {
delta = offset.left * -2
offset.left = 0
if (delta.left) offset.left += delta.left
else offset.top += delta.top
$tip.offset(offset)
var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
var arrowPosition = delta.left ? 'left' : 'top'
var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
}
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
} else {
this.replaceArrow(actualHeight - height, actualHeight, 'top')
}
if (replace) $tip.offset(offset)
$tip.offset(offset)
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
}
Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
}
Tooltip.prototype.setContent = function () {
@@ -261,8 +281,11 @@
var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type)
this.$element.removeAttr('aria-describedby')
function complete() {
if (that.hoverState != 'in') $tip.detach()
that.$element.trigger('hidden.bs.' + that.type)
}
this.$element.trigger(e)
@@ -273,18 +296,18 @@
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one($.support.transition.end, complete)
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) :
complete()
this.$element.trigger('hidden.bs.' + this.type)
this.hoverState = null
return this
}
Tooltip.prototype.fixTitle = function () {
var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
}
}
@@ -293,12 +316,15 @@
return this.getTitle()
}
Tooltip.prototype.getPosition = function () {
var el = this.$element[0]
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth
, height: el.offsetHeight
}, this.$element.offset())
Tooltip.prototype.getPosition = function ($element) {
$element = $element || this.$element
var el = $element[0]
var isBody = el.tagName == 'BODY'
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
width: isBody ? $(window).width() : $element.outerWidth(),
height: isBody ? $(window).height() : $element.outerHeight()
}, isBody ? { top: 0, left: 0 } : $element.offset())
}
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
@@ -306,6 +332,35 @@
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
}
Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
var delta = { top: 0, left: 0 }
if (!this.$viewport) return delta
var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
var viewportDimensions = this.getPosition(this.$viewport)
if (/right|left/.test(placement)) {
var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
if (topEdgeOffset < viewportDimensions.top) { // top overflow
delta.top = viewportDimensions.top - topEdgeOffset
} else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
}
} else {
var leftEdgeOffset = pos.left - viewportPadding
var rightEdgeOffset = pos.left + viewportPadding + actualWidth
if (leftEdgeOffset < viewportDimensions.left) { // left overflow
delta.left = viewportDimensions.left - leftEdgeOffset
} else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
}
}
return delta
}
Tooltip.prototype.getTitle = function () {
@@ -319,12 +374,18 @@
return title
}
Tooltip.prototype.getUID = function (prefix) {
do prefix += ~~(Math.random() * 1000000)
while (document.getElementById(prefix))
return prefix
}
Tooltip.prototype.tip = function () {
return this.$tip = this.$tip || $(this.options.template)
return (this.$tip = this.$tip || $(this.options.template))
}
Tooltip.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
}
Tooltip.prototype.validate = function () {
@@ -348,11 +409,20 @@
}
Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
var self = this
if (e) {
self = $(e.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(e.currentTarget, this.getDelegateOptions())
$(e.currentTarget).data('bs.' + this.type, self)
}
}
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
}
Tooltip.prototype.destroy = function () {
clearTimeout(this.timeout)
this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
}
@@ -360,19 +430,21 @@
// TOOLTIP PLUGIN DEFINITION
// =========================
var old = $.fn.lapstooltip
$.fn.lapstooltip = function (option) {
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.lapstooltip')
var options = typeof option == 'object' && option
if (!data && option == 'destroy') return
if (!data) $this.data('bs.lapstooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.lapstooltip
$.fn.lapstooltip = Plugin
$.fn.lapstooltip.Constructor = Tooltip
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
/*
Plugin Name: Laps
Plugin URI: https://bitbucket.org/Rarst/laps/
Plugin URI: https://github.com/Rarst/laps
Description: Light WordPress profiler.
Author: Andrey "Rarst" Savchenko
Version: 1.1
Version:
Author URI: http://www.rarst.net/
Text Domain: laps
Domain Path: /lang
+13 -7
View File
@@ -1,4 +1,4 @@
# Description
# Laps — light WP profiler
Laps is light WordPress profiler (in a plugin), which aims to be:
@@ -34,14 +34,20 @@ There are also additional optional timelines, displaying:
Laps is a Composer package and can be installed in plugin directory via:
composer create-project rarst/laps --repository-url=http://rarst.net
# Frequently Asked Questions
None... Yet.
composer create-project rarst/laps --no-dev
# Changelog
## 1.2.1
- disabled tooltip animation to fix JS errors and UI disappearing from under cursor
## 1.2
- merged RP with additional core events in admin
- implemented (ballpark) toolbar event
- fixed issue with event offsets in timelines
## 1.1
- added SQL timeline
@@ -59,4 +65,4 @@ Laps own code is licensed under MIT and it makes use of code from:
- Composer (MIT)
- Symfony Stopwatch (MIT)
- Mustache.php (MIT)
- Twitter Bootstrap (Apache License 2.0)
- Twitter Bootstrap (MIT)
+37
View File
@@ -42,6 +42,32 @@ class Core_Events extends Laps_Events {
'category' => 'core',
);
$stops['admin_init'][- 1] = array(
'event' => 'Core Admin Init',
'category' => 'core',
);
$stops['admin_init'][ PHP_INT_MAX -1 ] = array(
'action' => 'stop',
'event' => 'Core Admin Init',
'category' => 'core',
);
$stops['_admin_menu'][- 1] = array(
'event' => 'Admin Menu',
'category' => 'core',
);
$stops['admin_menu'][ PHP_INT_MAX -1 ] = array(
'action' => 'stop',
'event' => 'Admin Menu',
'category' => 'core',
);
$stops['admin_bar_menu'][-1] = array(
'event' => 'Toolbar',
'category' => 'core',
);
$stops['loop_start'][10] = array(
'event' => 'Main Loop',
'category' => 'theme',
@@ -53,6 +79,17 @@ class Core_Events extends Laps_Events {
'category' => 'theme',
);
$stops['admin_enqueue_scripts'][10] = array(
'event' => 'Admin Print Scripts',
'category' => 'core',
);
$stops['admin_print_scripts'][10] = array(
'action' => 'stop',
'event' => 'Admin Print Scripts',
'category' => 'core',
);
return $stops;
}
}
+3 -1
View File
@@ -202,7 +202,7 @@ class Laps {
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(".laps-timeline .event").lapstooltip({
container: '#wpadminbar', placement: 'bottom', html: true
container: '#wpadminbar', placement: 'bottom', html: true, animation: false
// , trigger: 'click'
});
});
@@ -229,6 +229,8 @@ class Laps {
)
);
self::$stopwatch->stop( 'Toolbar' );
$events = self::$stopwatch->getSectionEvents( '__root__' );
$start = $timestart * 1000;
$end = microtime( true ) * 1000;