Tolto sito MP-Site come MP_Site-old e creato sito empty MP-SITE x travaso

This commit is contained in:
Samuele E. Locatelli
2018-11-10 09:03:32 +01:00
parent cc83039645
commit 5f0f39ff6e
469 changed files with 52791 additions and 14391 deletions
+219
View File
@@ -0,0 +1,219 @@
<!-- IGNORE THE HTML BLOCK BELOW, THE INTERESTING PART IS AFTER IT -->
<h1 align="center">Popper.js</h1>
<p align="center">
<strong>A library used to position poppers in web applications.</strong>
</p>
<p align="center">
<a href="https://travis-ci.org/FezVrasta/popper.js/branches" target="_blank"><img src="https://travis-ci.org/FezVrasta/popper.js.svg?branch=master" alt="Build Status"/></a>
<img src="http://img.badgesize.io/https://unpkg.com/popper.js/dist/popper.min.js?compression=gzip" alt="Stable Release Size"/>
<a href="https://www.bithound.io/github/FezVrasta/popper.js"><img src="https://www.bithound.io/github/FezVrasta/popper.js/badges/score.svg" alt="bitHound Overall Score"></a>
<a href="https://codeclimate.com/github/FezVrasta/popper.js/coverage"><img src="https://codeclimate.com/github/FezVrasta/popper.js/badges/coverage.svg" alt="Istanbul Code Coverage"/></a>
<a href="https://gitter.im/FezVrasta/popper.js" target="_blank"><img src="https://img.shields.io/gitter/room/nwjs/nw.js.svg" alt="Get support or discuss"/></a>
<br />
<a href="https://saucelabs.com/u/popperjs" target="_blank"><img src="https://badges.herokuapp.com/browsers?labels=none&googlechrome=latest&firefox=latest&microsoftedge=latest&iexplore=11,10&safari=latest&iphone=latest" alt="SauceLabs Reports"/></a>
</p>
<img src="https://raw.githubusercontent.com/FezVrasta/popper.js/master/popperjs.png" align="right" width=250 />
<!-- 🚨 HEY! HERE BEGINS THE INTERESTING STUFF 🚨 -->
## Wut? Poppers?
A popper is an element on the screen which "pops out" from the natural flow of your application.
Common examples of poppers are tooltips, popovers and drop-downs.
## So, yet another tooltip library?
Well, basically, **no**.
Popper.js is a **positioning engine**, its purpose is to calculate the position of an element
to make it possible to position it near a given reference element.
The engine is completely modular and most of its features are implemented as **modifiers**
(similar to middlewares or plugins).
The whole code base is written in ES2015 and its features are automatically tested on real browsers thanks to [SauceLabs](https://saucelabs.com/) and [TravisCI](https://travis-ci.org/).
Popper.js has zero dependencies. No jQuery, no LoDash, nothing.
It's used by big companies like [Twitter in Bootstrap v4](https://getbootstrap.com/), [Microsoft in WebClipper](https://github.com/OneNoteDev/WebClipper) and [Atlassian in AtlasKit](https://aui-cdn.atlassian.com/atlaskit/registry/).
### Popper.js
This is the engine, the library that computes and, optionally, applies the styles to
the poppers.
Some of the key points are:
- Position elements keeping them in their original DOM context (doesn't mess with your DOM!);
- Allows to export the computed informations to integrate with React and other view libraries;
- Supports Shadow DOM elements;
- Completely customizable thanks to the modifiers based structure;
Visit our [project page](https://fezvrasta.github.io/popper.js) to see a lot of examples of what you can do with Popper.js!
Find [the documentation here](/docs/_includes/popper-documentation.md).
### Tooltip.js
Since lots of users just need a simple way to integrate powerful tooltips in their projects,
we created **Tooltip.js**.
It's a small library that makes it easy to automatically create tooltips using as engine Popper.js.
Its API is almost identical to the famous tooltip system of Bootstrap, in this way it will be
easy to integrate it in your projects.
The tooltips generated by Tooltip.js are accessible thanks to the `aria` tags.
Find [the documentation here](/docs/_includes/tooltip-documentation.md).
## Installation
Popper.js is available on the following package managers and CDNs:
| Source | |
|:-------|:---------------------------------------------------------------------------------|
| npm | `npm install popper.js --save` |
| yarn | `yarn add popper.js` |
| NuGet | `PM> Install-Package popper.js` |
| Bower | `bower install popper.js --save` |
| unpkg | [`https://unpkg.com/popper.js`](https://unpkg.com/popper.js) |
| cdnjs | [`https://cdnjs.com/libraries/popper.js`](https://cdnjs.com/libraries/popper.js) |
Tooltip.js as well:
| Source | |
|:-------|:---------------------------------------------------------------------------------|
| npm | `npm install tooltip.js --save` |
| yarn | `yarn add tooltip.js` |
| Bower* | `bower install tooltip.js=https://unpkg.com/tooltip.js --save` |
| unpkg | [`https://unpkg.com/tooltip.js`](https://unpkg.com/tooltip.js) |
| cdnjs | [`https://cdnjs.com/libraries/popper.js`](https://cdnjs.com/libraries/popper.js) |
\*: Bower isn't officially supported, it can be used to install Tooltip.js only trough the unpkg.com CDN. This method has the limitation of not being able to define a specific version of the library. Bower and Popper.js suggests to use npm or Yarn for your projects.
For more info, [read the related issue](https://github.com/FezVrasta/popper.js/issues/390).
### Dist targets
Popper.js is currently shipped with 3 targets in mind: UMD, ESM and ESNext.
- UMD - Universal Module Definition: AMD, RequireJS and globals;
- ESM - ES Modules: For webpack/Rollup or browser supporting the spec;
- ESNext: Available in `dist/`, can be used with webpack and `babel-preset-env`;
Make sure to use the right one for your needs. If you want to import it with a `<script>` tag, use UMD.
## Usage
Given an existing popper DOM node, ask Popper.js to position it near its button
```js
var reference = document.querySelector('.my-button');
var popper = document.querySelector('.my-popper');
var anotherPopper = new Popper(
reference,
popper,
{
// popper options here
}
);
```
### Callbacks
Popper.js supports two kinds of callbacks, the `onCreate` callback is called after
the popper has been initalized. The `onUpdate` one is called on any subsequent update.
```js
const reference = document.querySelector('.my-button');
const popper = document.querySelector('.my-popper');
new Popper(reference, popper, {
onCreate: (data) => {
// data is an object containing all the informations computed
// by Popper.js and used to style the popper and its arrow
// The complete description is available in Popper.js documentation
},
onUpdate: (data) => {
// same as `onCreate` but called on subsequent updates
}
});
```
### Writing your own modifiers
Popper.js is based on a "plugin-like" architecture, most of its features are fully encapsulated "modifiers".
A modifier is a function that is called each time Popper.js needs to compute the position of the popper. For this reason, modifiers should be very performant to avoid bottlenecks.
To learn how to create a modifier, [read the modifiers documentation](docs/_includes/popper-documentation.md#modifiers--object)
### React, Vue.js, Angular, AngularJS, Ember.js (etc...) integration
Integrating 3rd party libraries in React or other libraries can be a pain because
they usually alter the DOM and drive the libraries crazy.
Popper.js limits all its DOM modifications inside the `applyStyle` modifier,
you can simply disable it and manually apply the popper coordinates using
your library of choice.
For a comprehensive list of libraries that let you use Popper.js into existing
frameworks, visit the [MENTIONS](/MENTIONS.md) page.
Alternatively, you may even override your own `applyStyles` with your custom one and
integrate Popper.js by yourself!
```js
function applyReactStyle(data) {
// export data in your framework and use its content to apply the style to your popper
};
const reference = document.querySelector('.my-button');
const popper = document.querySelector('.my-popper');
new Popper(reference, popper, {
modifiers: {
applyStyle: { enabled: false },
applyReactStyle: {
enabled: true,
fn: applyReactStyle,
order: 800,
},
},
});
```
### Migration from Popper.js v0
Since the API changed, we prepared some migration instructions to make it easy to upgrade to
Popper.js v1.
https://github.com/FezVrasta/popper.js/issues/62
Feel free to comment inside the issue if you have any questions.
### Performances
Popper.js is very performant. It usually takes 0.5ms to compute a popper's position (on an iMac with 3.5G GHz Intel Core i5).
This means that it will not cause any [jank](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/anatomy-of-jank), leading to a smooth user experience.
## Notes
### Libraries using Popper.js
The aim of Popper.js is to provide a stable and powerful positioning engine ready to
be used in 3rd party libraries.
Visit the [MENTIONS](/MENTIONS.md) page for an updated list of projects.
### Credits
I want to thank some friends and projects for the work they did:
- [@AndreaScn](https://github.com/AndreaScn) for his work on the GitHub Page and the manual testing he did during the development;
- [@vampolo](https://github.com/vampolo) for the original idea and for the name of the library;
- [Sysdig](https://github.com/Draios) for all the awesome things I learned during these years that made it possible for me to write this library;
- [Tether.js](http://github.hubspot.com/tether/) for having inspired me in writing a positioning library ready for the real world;
- [The Contributors](https://github.com/FezVrasta/popper.js/graphs/contributors) for their much appreciated Pull Requests and bug reports;
- **you** for the star you'll give to this project and for being so awesome to give this project a try 🙂
### Copyright and license
Code and documentation copyright 2016 **Federico Zivolo**. Code released under the [MIT license](LICENSE.md). Docs released under Creative Commons.
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+3944
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+159
View File
@@ -0,0 +1,159 @@
/**
* @fileoverview This file only declares the public portions of the API.
* It should not define internal pieces such as utils or modifier details.
*
* Original definitions by: edcarroll <https://github.com/edcarroll>, ggray <https://github.com/giladgray>, rhysd <https://rhysd.github.io>, joscha <https://github.com/joscha>, seckardt <https://github.com/seckardt>, marcfallows <https://github.com/marcfallows>
*/
/**
* This kind of namespace declaration is not necessary, but is kept here for backwards-compatibility with
* popper.js 1.x. It can be removed in 2.x so that the default export is simply the Popper class
* and all the types / interfaces are top-level named exports.
*/
declare namespace Popper {
export type Position = 'top' | 'right' | 'bottom' | 'left';
export type Placement = 'auto-start'
| 'auto'
| 'auto-end'
| 'top-start'
| 'top'
| 'top-end'
| 'right-start'
| 'right'
| 'right-end'
| 'bottom-end'
| 'bottom'
| 'bottom-start'
| 'left-end'
| 'left'
| 'left-start';
export type Boundary = 'scrollParent' | 'viewport' | 'window';
export type Behavior = 'flip' | 'clockwise' | 'counterclockwise';
export type ModifierFn = (data: Data, options: Object) => Data;
export interface BaseModifier {
order?: number;
enabled?: boolean;
fn?: ModifierFn;
}
export interface Modifiers {
shift?: BaseModifier;
offset?: BaseModifier & {
offset?: number | string,
};
preventOverflow?: BaseModifier & {
priority?: Position[],
padding?: number,
boundariesElement?: Boundary | Element,
escapeWithReference?: boolean
};
keepTogether?: BaseModifier;
arrow?: BaseModifier & {
element?: string | Element,
};
flip?: BaseModifier & {
behavior?: Behavior | Position[],
padding?: number,
boundariesElement?: Boundary | Element,
};
inner?: BaseModifier;
hide?: BaseModifier;
applyStyle?: BaseModifier & {
onLoad?: Function,
gpuAcceleration?: boolean,
};
computeStyle?: BaseModifier & {
gpuAcceleration?: boolean;
x?: 'bottom' | 'top',
y?: 'left' | 'right'
};
[name: string]: (BaseModifier & Record<string, any>) | undefined;
}
export interface Offset {
top: number;
left: number;
width: number;
height: number;
}
export interface Data {
instance: Popper;
placement: Placement;
originalPlacement: Placement;
flipped: boolean;
hide: boolean;
arrowElement: Element;
styles: CSSStyleDeclaration;
boundaries: Object;
offsets: {
popper: Offset,
reference: Offset,
arrow: {
top: number,
left: number,
},
};
}
export interface PopperOptions {
placement?: Placement;
positionFixed?: boolean;
eventsEnabled?: boolean;
modifiers?: Modifiers;
removeOnDestroy?: boolean;
onCreate?(data: Data): void;
onUpdate?(data: Data): void;
}
export interface ReferenceObject {
clientHeight: number;
clientWidth: number;
getBoundingClientRect(): ClientRect;
}
}
// Re-export types in the Popper namespace so that they can be accessed as top-level named exports.
// These re-exports should be removed in 2.x when the "declare namespace Popper" syntax is removed.
export type Position = Popper.Position;
export type Placement = Popper.Placement;
export type Boundary = Popper.Boundary;
export type Behavior = Popper.Behavior;
export type ModifierFn = Popper.ModifierFn;
export type BaseModifier = Popper.BaseModifier;
export type Modifiers = Popper.Modifiers;
export type Offset = Popper.Offset;
export type Data = Popper.Data;
export type PopperOptions = Popper.PopperOptions;
export type ReferenceObject = Popper.ReferenceObject;
declare class Popper {
static modifiers: (BaseModifier & { name: string })[];
static placements: Placement[];
static Defaults: PopperOptions;
options: PopperOptions;
constructor(reference: Element | ReferenceObject, popper: Element, options?: PopperOptions);
destroy(): void;
update(): void;
scheduleUpdate(): void;
enableEventListeners(): void;
disableEventListeners(): void;
}
export default Popper;
+355
View File
@@ -0,0 +1,355 @@
/**
* jintervals -- JavaScript library for interval formatting
*
* jintervals is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* jintervals is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with jintervals. If not, see
* <http://www.gnu.org/licenses/>.
*
* Copyright (c) 2009 Rene Saarsoo <http://code.google.com/p/jintervals/>
*
*/
var jintervals = (function() {
function jintervals(seconds, format) {
return Interpreter.evaluate(new Time(seconds), Parser.parse(format));
};
/**
* Parses format string into data structure,
* that can be interpreted later.
*/
var Parser = {
parse: function(format) {
var unparsed = format;
var result = [];
while ( unparsed.length > 0 ) {
// leave plain text untouched
var textMatch = /^([^\\{]+)([\\{].*|)$/.exec(unparsed);
if (textMatch) {
result.push(textMatch[1]);
unparsed = textMatch[2];
}
// parse jintervals {Code} separately
var match = /^([{].*?(?:[}]|$))(.*)$/i.exec(unparsed);
if (match) {
result.push(this.parseCode(match[1]));
unparsed = match[2];
}
// backslash escapes next character
// transform \{ --> {
// transform \\ --> \
if (unparsed.charAt(0) === "\\") {
result.push(unparsed.charAt(1));
unparsed = unparsed.slice(2);
}
}
return result;
},
// parses single {Code} in format string
// Returns object representing the code or false when incorrect format string
parseCode: function(code) {
var re = /^[{]([smhdg])([smhdg]*)?(ays?|ours?|inutes?|econds?|reatests?|\.)?(\?(.*))?[}]$/i;
var matches = re.exec(code);
if (!matches) {
return false;
}
return {
// single-letter uppercase name of the type
type: matches[1].toUpperCase(),
// when code begins with lowercase letter, then set showing limited amount to true
limited: (matches[1].toLowerCase() == matches[1]),
paddingLength: (matches[2] || "").length + 1,
format: (matches[3]||"") == "" ? false : (matches[3] == "." ? "letter" : "full"),
optional: !!matches[4],
optionalSuffix: matches[5] || ""
};
}
};
/**
* Evaluates parse tree in the context of given time object
*/
var Interpreter = {
evaluate: function(time, parseTree) {
var smallestUnit = this.smallestUnit(parseTree);
var result = "";
while ( parseTree.length > 0 ) {
var code = parseTree.shift();
// leave plain text untouched
if (typeof code === "string") {
result += code;
}
// evaluate the code
else if (typeof code === "object") {
var unit = (code.type == "G") ? time.getGreatestUnit() : code.type;
var smallest = (code.type == "G") ? unit : smallestUnit;
var value = time.get(unit, code.limited, smallest);
var suffix = code.format ? Localization.translate(code.format, unit, value) : "";
// show when not optional or totalvalue is non-zero
if (!code.optional || time.get(unit) != 0) {
result += this.zeropad(value, code.paddingLength) + suffix + code.optionalSuffix;
}
}
// otherwise we have error
else {
result += "?";
}
}
return result;
},
/**
* Finds the smallest unit from parse tree.
*
* For example when parse tree contains "d", "m", "h" then returns "m"
*/
smallestUnit: function(parseTree) {
var unitOrder = {
"S": 0,
"M": 1,
"H": 2,
"D": 3
};
var smallest = "D";
for (var i = 0; i < parseTree.length; i++) {
if (typeof parseTree[i] === "object") {
var type = parseTree[i].type;
if (type !== "G" && unitOrder[type] < unitOrder[smallest]) {
smallest = type;
}
}
}
return smallest;
},
// utility function to pad number with leading zeros
zeropad: function(nr, decimals) {
var padLength = decimals - (""+nr).length;
return (padLength > 0) ? this.repeat("0", padLength) + nr : nr;
},
// utility function to repeat string
repeat: function(string, times) {
var result = "";
for (var i=0; i < times; i++) {
result += string;
}
return result;
}
};
/**
* Time class that deals with the actual computation of time units.
*/
var Time = function(s) {
this.seconds = s;
};
Time.prototype = {
nextUnit: {D: "H", H: "M", M: "S", S: "S"},
/**
* Returns the value of time in given unit
*
* @param {String} unit Either "S", "M", "H" or "D"
* @param {Boolean} limited When true 67 seconds will become just 7 seconds (defaults to false)
* @param {String} smallest The name of smallest unit. Defaults to next unit.
* For example for "D" it will be "H", for "H" it will be "M" and so on...
*/
get: function(unit, limited, smallest) {
if (!this[unit]) {
return "?";
}
smallest = smallest || this.nextUnit[unit];
return this[unit](limited, smallest);
},
// functions for each unit
S: function(limited, smallest) {
return limited ? this.seconds - this.M(false, smallest) * 60 : this.seconds;
},
M: function(limited, smallest) {
var minutes = this.seconds / 60;
minutes = (smallest === "M") ? Math.round(minutes): Math.floor(minutes);
if (limited) {
minutes = minutes - this.H(false, smallest) * 60;
}
return minutes;
},
H: function(limited, smallest) {
var hours = this.M(false, smallest) / 60;
hours = (smallest === "H") ? Math.round(hours): Math.floor(hours);
if (limited) {
hours = hours - this.D(false, smallest) * 24;
}
return hours;
},
D: function(limited, smallest) {
var days = this.H(false, smallest) / 24;
return (smallest === "D") ? Math.round(days): Math.floor(days);
},
/**
* Returns the name of greatest time unit.
*
* For example when we have 2 hours, 30 minutes, and 7 seconds,
* then the greatest unit is hour and "H" is returned.
*/
getGreatestUnit: function() {
if (this.seconds < 60) {
return "S";
}
else if (this.M(false, "M") < 60) {
return "M";
}
else if (this.H(false, "H") < 24) {
return "H";
}
else {
return "D";
}
}
};
var Localization = {
translate: function(format, lcType, value) {
var loc = this.locales[this.currentLocale];
var translation = loc[format][lcType];
if (typeof translation === "string") {
return translation;
}
else {
return translation[loc.plural(value)];
}
},
locale: function(loc) {
if (loc) {
this.currentLocale = loc;
}
return this.currentLocale;
},
currentLocale: "en_US",
locales: {
en_US: {
letter: {
D: "d",
H: "h",
M: "m",
S: "s"
},
full: {
D: [" day", " days"],
H: [" hour", " hours"],
M: [" minute", " minutes"],
S: [" second", " seconds"]
},
plural: function(nr) {
return (nr == 1) ? 0 : 1;
}
},
et_EE: {
letter: {
D: "p",
H: "h",
M: "m",
S: "s"
},
full: {
D: [" p\u00E4ev", " p\u00E4eva"],
H: [" tund", " tundi"],
M: [" minut", " minutit"],
S: [" sekund", " sekundit"]
},
plural: function(nr) {
return (nr == 1) ? 0 : 1;
}
},
lt_LT: {
letter: {
D: "d",
H: "h",
M: "m",
S: "s"
},
full: {
D: [" dieną", " dienas", " dienų"],
H: [" valandą", " valandas", " valandų"],
M: [" minutę", " minutes", " minučių"],
S: [" sekundę", " sekundes", " sekundžų"]
},
plural: function(n) {
return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);
}
},
ru_RU: {
letter: {
D: "д",
H: "ч",
M: "м",
S: "с"
},
full: {
D: [" день", " дня", " дней"],
H: [" час", " часа", " часов"],
M: [" минута", " минуты", " минут"],
S: [" секунда", " секунды", " секунд"]
},
plural: function(n) {
return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);
}
},
fi_FI: {
letter: {
D: "p",
H: "h",
M: "m",
S: "s"
},
full: {
D: [" päivä", " päivää"],
H: [" tunti", " tuntia"],
M: [" minuutti", " minuuttia"],
S: [" sekunti", " sekunttia"]
},
plural: function(nr) {
return (nr == 1) ? 0 : 1;
}
}
}
};
// Changing and getting current locale
jintervals.locale = function(loc) {
return Localization.locale(loc);
};
jintervals.Time = Time;
return jintervals;
})();
File diff suppressed because it is too large Load Diff
+10364
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+153
View File
@@ -0,0 +1,153 @@
(function($) {
function incrementer(ct, increment) {
return function() { ct += increment; return ct; };
}
function pad2(number) {
return (number < 10 ? '0' : '') + number;
}
function defaultFormatMilliseconds(millis) {
var x, seconds, minutes, hours;
x = millis / 1000;
seconds = Math.floor(x % 60);
x /= 60;
minutes = Math.floor(x % 60);
x /= 60;
hours = Math.floor(x % 24);
// x /= 24;
// days = Math.floor(x);
return [pad2(hours), pad2(minutes), pad2(seconds)].join(':');
}
//NOTE: This is a the 'lazy func def' pattern described at http://michaux.ca/articles/lazy-function-definition-pattern
function formatMilliseconds(millis, data) {
// Use jintervals if available, else default formatter
var formatter;
if (typeof jintervals == 'function') {
formatter = function(millis, data) { return jintervals(millis / 1000, data.format); };
} else {
formatter = defaultFormatMilliseconds;
}
formatMilliseconds = function(millis, data) {
return formatter(millis, data);
};
return formatMilliseconds(millis, data);
}
var methods = {
init: function(options) {
var defaults = {
updateInterval: 1000,
startTime: 0,
format: '{HH}:{MM}:{SS}',
formatter: formatMilliseconds
};
// if (options) { $.extend(settings, options); }
var settings = $.extend({}, defaults, options);
return this.each(function() {
var $this = $(this),
data = $this.data('stopwatch');
// If the plugin hasn't been initialized yet
if (!data) {
// Setup the stopwatch data
data = settings;
data.active = false;
data.target = $this;
data.elapsed = settings.startTime;
// create counter
data.incrementer = incrementer(data.startTime, data.updateInterval);
data.tick_function = function() {
var millis = data.incrementer();
data.elapsed = millis;
data.target.trigger('tick.stopwatch', [millis]);
data.target.stopwatch('render');
};
$this.data('stopwatch', data);
}
});
},
start: function() {
return this.each(function() {
var $this = $(this),
data = $this.data('stopwatch');
// Mark as active
data.active = true;
data.timerID = setInterval(data.tick_function, data.updateInterval);
$this.data('stopwatch', data);
});
},
stop: function() {
return this.each(function() {
var $this = $(this),
data = $this.data('stopwatch');
clearInterval(data.timerID);
data.active = false;
$this.data('stopwatch', data);
});
},
destroy: function() {
return this.each(function() {
var $this = $(this),
data = $this.data('stopwatch');
$this.stopwatch('stop').unbind('.stopwatch').removeData('stopwatch');
});
},
render: function() {
var $this = $(this),
data = $this.data('stopwatch');
$this.html(data.formatter(data.elapsed, data));
},
getTime: function() {
var $this = $(this),
data = $this.data('stopwatch');
return data.elapsed;
},
toggle: function() {
return this.each(function() {
var $this = $(this);
var data = $this.data('stopwatch');
if (data.active) {
$this.stopwatch('stop');
} else {
$this.stopwatch('start');
}
});
},
reset: function() {
return this.each(function() {
var $this = $(this);
data = $this.data('stopwatch');
data.incrementer = incrementer(data.startTime, data.updateInterval);
data.elapsed = data.startTime;
$this.data('stopwatch', data);
});
}
};
// Define the function
$.fn.stopwatch = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.stopwatch');
}
};
})(jQuery);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+47
View File
File diff suppressed because one or more lines are too long