13 Commits
13 changed files with 504 additions and 236 deletions

No files matched your search

-1
View File
@@ -1,2 +1 @@
vendor 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.", "description": "Light WordPress profiler.",
"keywords" : ["wordpress", "performance"], "keywords" : ["wordpress", "performance"],
"type" : "wordpress-plugin", "type" : "wordpress-plugin",
"homepage" : "https://bitbucket.org/Rarst/laps", "homepage" : "https://github.com/Rarst/laps",
"license" : "MIT", "license" : "MIT",
"authors" : [ "authors" : [
{ {
@@ -13,8 +13,7 @@
} }
], ],
"support" : { "support" : {
"issues": "https://bitbucket.org/Rarst/laps/issues", "issues": "https://github.com/Rarst/laps/issues"
"source": "https://bitbucket.org/Rarst/laps/src"
}, },
"autoload" : { "autoload" : {
"classmap": ["src/"] "classmap": ["src/"]
@@ -23,5 +22,8 @@
"composer/installers": "~1.0", "composer/installers": "~1.0",
"symfony/stopwatch" : "~2.4", "symfony/stopwatch" : "~2.4",
"mustache/mustache" : "~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": []
}
+17 -3
View File
@@ -19,29 +19,43 @@
#wpadminbar .laps-timeline { #wpadminbar .laps-timeline {
overflow: hidden; overflow: hidden;
height: 20px; height: 20px;
margin: 6px 0; margin-bottom: 20px;
background-color: #f5f5f5; background-color: #f5f5f5;
border-radius: 4px; border-radius: 4px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); -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); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
margin: 6px 0;
position: relative; position: relative;
} }
#wpadminbar .laps-timeline .event { #wpadminbar .laps-timeline .event {
float: left; float: left;
width: 0%; width: 0%;
height: 20px; height: 100%;
font-size: 12px; font-size: 12px;
color: #fff; line-height: 20px;
color: #ffffff;
text-align: center; text-align: center;
background-color: #5bc0de; background-color: #5bc0de;
-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); -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); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
-webkit-transition: width 0.6s ease; -webkit-transition: width 0.6s ease;
-o-transition: width 0.6s ease;
transition: width 0.6s ease; transition: width 0.6s ease;
position: absolute; position: absolute;
border-left: 1px solid #f5f5f5; border-left: 1px solid #f5f5f5;
min-width: 2px; 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 { #wpadminbar .laps-timeline .event-theme {
background-color: #5cb85c; background-color: #5cb85c;
} }
+13 -27
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 "variables.less";
@import "mixins.less";
#wpadminbar { #wpadminbar {
@@ -31,51 +33,35 @@
} }
.laps-timeline { .laps-timeline {
overflow: hidden; .progress;
height: 20px;
margin: 6px 0; margin: 6px 0;
background-color: @timeline-bg;
border-radius: 4px;
.box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
position: relative; position: relative;
}
.laps-timeline .event { .event {
float: left; .progress-bar;
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 position: absolute; // disable stacking at start
border-left: 1px solid @timeline-bg; border-left: 1px solid @timeline-bg;
min-width: 2px; min-width: 2px;
} }
.laps-timeline .event-theme { .event-theme {
background-color: @event-theme-color; background-color: @event-theme-color;
} }
.event-plugin {
.laps-timeline .event-plugin {
background-color: @event-plugin-color; background-color: @event-plugin-color;
} }
.event-core {
.laps-timeline .event-core {
background-color: @event-core-color; background-color: @event-core-color;
} }
.event-query {
.laps-timeline .event-query {
background-color: @event-info-color; background-color: @event-info-color;
} }
.event-http {
.laps-timeline .event-http {
background-color: @event-warning-color; background-color: @event-warning-color;
} }
}
@import "tooltip.less"; @import "../vendor/twbs/bootstrap/less/tooltip.less";
.tooltip.in { .tooltip.in {
.opacity(1); .opacity(1);
-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; @font-size-small: 12px;
@line-height-computed: 20px;
// colors // colors
@timeline-bg: #f5f5f5; @timeline-bg: #f5f5f5;
@@ -7,6 +8,8 @@
@event-core-color: #f0ad4e; @event-core-color: #f0ad4e;
@event-info-color: #5bc0de; @event-info-color: #5bc0de;
@event-warning-color: #d9534f; @event-warning-color: #d9534f;
@progress-bg: @timeline-bg;
@progress-bar-bg: @event-info-color;
// because admin bar is 99999 // because admin bar is 99999
@zindex-tooltip: 100000; @zindex-tooltip: 100000;
+155 -83
View File
@@ -1,26 +1,17 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: tooltip.js v3.0.2 * Bootstrap: tooltip.js v3.2.0
* http://getbootstrap.com/javascript/#tooltip * http://getbootstrap.com/javascript/#tooltip
* Inspired by the original jQuery.tipsy by Jason Frame * Inspired by the original jQuery.tipsy by Jason Frame
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 Twitter, Inc.
* * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* 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.
* ======================================================================== */ * ======================================================================== */
// modified to use lapstooltip as name
+function ($) { "use strict"; // modified to use lapstooltip as plugin name
+function ($) {
'use strict';
// TOOLTIP PUBLIC CLASS DEFINITION // TOOLTIP PUBLIC CLASS DEFINITION
// =============================== // ===============================
@@ -36,16 +27,22 @@
this.init('lapstooltip', element, options) this.init('lapstooltip', element, options)
} }
Tooltip.VERSION = '3.2.0'
Tooltip.DEFAULTS = { Tooltip.DEFAULTS = {
animation: true animation: true,
, placement: 'top' placement: 'top',
, selector: false selector: false,
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
, trigger: 'hover focus' trigger: 'hover focus',
, title: '' title: '',
, delay: 0 delay: 0,
, html: false html: false,
, container: false container: false,
viewport: {
selector: 'body',
padding: 0
}
} }
Tooltip.prototype.init = function (type, element, options) { Tooltip.prototype.init = function (type, element, options) {
@@ -53,6 +50,7 @@
this.type = type this.type = type
this.$element = $(element) this.$element = $(element)
this.options = this.getOptions(options) this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
var triggers = this.options.trigger.split(' ') var triggers = this.options.trigger.split(' ')
@@ -62,8 +60,8 @@
if (trigger == 'click') { if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') { } else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 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)) this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
@@ -84,8 +82,8 @@
if (options.delay && typeof options.delay == 'number') { if (options.delay && typeof options.delay == 'number') {
options.delay = { options.delay = {
show: options.delay show: options.delay,
, hide: options.delay hide: options.delay
} }
} }
@@ -105,7 +103,12 @@
Tooltip.prototype.enter = function (obj) { Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ? 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) clearTimeout(self.timeout)
@@ -120,7 +123,12 @@
Tooltip.prototype.leave = function (obj) { Tooltip.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ? 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) clearTimeout(self.timeout)
@@ -134,16 +142,22 @@
} }
Tooltip.prototype.show = function () { Tooltip.prototype.show = function () {
var e = $.Event('show.bs.'+ this.type) var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) { if (this.hasContent() && this.enabled) {
this.$element.trigger(e) 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 $tip = this.tip()
var tipId = this.getUID(this.type)
this.setContent() this.setContent()
$tip.attr('id', tipId)
this.$element.attr('aria-describedby', tipId)
if (this.options.animation) $tip.addClass('fade') if (this.options.animation) $tip.addClass('fade')
@@ -159,6 +173,7 @@
.detach() .detach()
.css({ top: 0, left: 0, display: 'block' }) .css({ top: 0, left: 0, display: 'block' })
.addClass(placement) .addClass(placement)
.data('bs.' + this.type, this)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
@@ -167,18 +182,14 @@
var actualHeight = $tip[0].offsetHeight var actualHeight = $tip[0].offsetHeight
if (autoPlace) { if (autoPlace) {
var $parent = this.$element.parent()
var orgPlacement = placement var orgPlacement = placement
var docScroll = document.documentElement.scrollTop || document.body.scrollTop var $parent = this.$element.parent()
var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth() var parentDim = this.getPosition($parent)
var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' : placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' : placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' : placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' : placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
placement placement
$tip $tip
@@ -189,12 +200,21 @@
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
this.applyPlacement(calculatedOffset, placement) 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) { Tooltip.prototype.applyPlacement = function (offset, placement) {
var replace
var $tip = this.tip() var $tip = this.tip()
var width = $tip[0].offsetWidth var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight var height = $tip[0].offsetHeight
@@ -210,42 +230,42 @@
offset.top = offset.top + marginTop offset.top = offset.top + marginTop
offset.left = offset.left + marginLeft offset.left = offset.left + marginLeft
$tip // $.fn.offset doesn't round pixel values
.offset(offset) // so we use setOffset directly with our own function B-0
.addClass('in') $.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 // check to see if placing tip in new offset caused the tip to resize itself
var actualWidth = $tip[0].offsetWidth var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) { if (placement == 'top' && actualHeight != height) {
replace = true
offset.top = offset.top + height - actualHeight offset.top = offset.top + height - actualHeight
} }
if (/bottom|top/.test(placement)) { var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
var delta = 0
if (offset.left < 0) { if (delta.left) offset.left += delta.left
delta = offset.left * -2 else offset.top += delta.top
offset.left = 0
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'
$tip.offset(offset) $tip.offset(offset)
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
} }
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left') Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
} else { this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
this.replaceArrow(actualHeight - height, actualHeight, 'top')
}
if (replace) $tip.offset(offset)
}
Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
} }
Tooltip.prototype.setContent = function () { Tooltip.prototype.setContent = function () {
@@ -261,8 +281,11 @@
var $tip = this.tip() var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type) var e = $.Event('hide.bs.' + this.type)
this.$element.removeAttr('aria-describedby')
function complete() { function complete() {
if (that.hoverState != 'in') $tip.detach() if (that.hoverState != 'in') $tip.detach()
that.$element.trigger('hidden.bs.' + that.type)
} }
this.$element.trigger(e) this.$element.trigger(e)
@@ -273,18 +296,18 @@
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
$tip $tip
.one($.support.transition.end, complete) .one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
complete() complete()
this.$element.trigger('hidden.bs.' + this.type) this.hoverState = null
return this return this
} }
Tooltip.prototype.fixTitle = function () { Tooltip.prototype.fixTitle = function () {
var $e = this.$element 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', '') $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
} }
} }
@@ -293,12 +316,15 @@
return this.getTitle() return this.getTitle()
} }
Tooltip.prototype.getPosition = function () { Tooltip.prototype.getPosition = function ($element) {
var el = this.$element[0] $element = $element || this.$element
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { var el = $element[0]
width: el.offsetWidth var isBody = el.tagName == 'BODY'
, height: el.offsetHeight return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
}, this.$element.offset()) 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) { 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 == '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 == '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 } /* 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 () { Tooltip.prototype.getTitle = function () {
@@ -319,12 +374,18 @@
return title return title
} }
Tooltip.prototype.getUID = function (prefix) {
do prefix += ~~(Math.random() * 1000000)
while (document.getElementById(prefix))
return prefix
}
Tooltip.prototype.tip = function () { Tooltip.prototype.tip = function () {
return this.$tip = this.$tip || $(this.options.template) return (this.$tip = this.$tip || $(this.options.template))
} }
Tooltip.prototype.arrow = function () { 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 () { Tooltip.prototype.validate = function () {
@@ -348,11 +409,20 @@
} }
Tooltip.prototype.toggle = function (e) { 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) self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
} }
Tooltip.prototype.destroy = function () { Tooltip.prototype.destroy = function () {
clearTimeout(this.timeout)
this.hide().$element.off('.' + this.type).removeData('bs.' + this.type) this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
} }
@@ -360,19 +430,21 @@
// TOOLTIP PLUGIN DEFINITION // TOOLTIP PLUGIN DEFINITION
// ========================= // =========================
var old = $.fn.lapstooltip function Plugin(option) {
$.fn.lapstooltip = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs.lapstooltip') var data = $this.data('bs.lapstooltip')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data && option == 'destroy') return
if (!data) $this.data('bs.lapstooltip', (data = new Tooltip(this, options))) if (!data) $this.data('bs.lapstooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
var old = $.fn.lapstooltip
$.fn.lapstooltip = Plugin
$.fn.lapstooltip.Constructor = Tooltip $.fn.lapstooltip.Constructor = Tooltip
+2 -2
View File
@@ -1,10 +1,10 @@
<?php <?php
/* /*
Plugin Name: Laps Plugin Name: Laps
Plugin URI: https://bitbucket.org/Rarst/laps/ Plugin URI: https://github.com/Rarst/laps
Description: Light WordPress profiler. Description: Light WordPress profiler.
Author: Andrey "Rarst" Savchenko Author: Andrey "Rarst" Savchenko
Version: 1.1 Version:
Author URI: http://www.rarst.net/ Author URI: http://www.rarst.net/
Text Domain: laps Text Domain: laps
Domain Path: /lang Domain Path: /lang
+6 -6
View File
@@ -1,4 +1,4 @@
# Description # Laps — light WP profiler
Laps is light WordPress profiler (in a plugin), which aims to be: Laps is light WordPress profiler (in a plugin), which aims to be:
@@ -36,12 +36,12 @@ Laps is a Composer package and can be installed in plugin directory via:
composer create-project rarst/laps --no-dev composer create-project rarst/laps --no-dev
# Frequently Asked Questions
None... Yet.
# Changelog # Changelog
## 1.2.1
- disabled tooltip animation to fix JS errors and UI disappearing from under cursor
## 1.2 ## 1.2
- merged RP with additional core events in admin - merged RP with additional core events in admin
@@ -65,4 +65,4 @@ Laps own code is licensed under MIT and it makes use of code from:
- Composer (MIT) - Composer (MIT)
- Symfony Stopwatch (MIT) - Symfony Stopwatch (MIT)
- Mustache.php (MIT) - Mustache.php (MIT)
- Twitter Bootstrap (Apache License 2.0) - Twitter Bootstrap (MIT)
+1 -1
View File
@@ -202,7 +202,7 @@ class Laps {
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function () { jQuery(document).ready(function () {
jQuery(".laps-timeline .event").lapstooltip({ jQuery(".laps-timeline .event").lapstooltip({
container: '#wpadminbar', placement: 'bottom', html: true container: '#wpadminbar', placement: 'bottom', html: true, animation: false
// , trigger: 'click' // , trigger: 'click'
}); });
}); });