1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-09-12 15:01:39 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

添加Metronic(作为LFS)

This commit is contained in:
2022-03-01 21:24:58 +08:00
parent 080ca33954
commit 465c454101
3280 changed files with 561969 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2013 Maurizio Napoleoni;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,92 @@
# [Bootstrap MaxLength](http://mimo84.github.com/bootstrap-maxlength/) [![Build Status](https://travis-ci.org/mimo84/bootstrap-maxlength.png?branch=master)](https://travis-ci.org/mimo84/bootstrap-maxlength) [![Total views](https://sourcegraph.com/api/repos/github.com/mimo84/bootstrap-maxlength/counters/views.png)](https://sourcegraph.com/github.com/mimo84/bootstrap-maxlength)
This plugin integrates by default with Twitter bootstrap using badges to display the maximum length of the field where the user is inserting text.
This plugin uses the HTML5 attribute "maxlength" to work.
The indicator badge show up on focusing on the element, and disappear when the focus is lost.
## Configurable options
* **alwaysShow**: if true the threshold will be ignored and the remaining length indication will be always showing up while typing or on focus on the input. Default: false.
* **threshold**: this is a number indicating how many chars are left to start displaying the indications. Default: 10.
* **warningClass**: it's the class of the element with the indicator. By default is the bootstrap "badge badge-info" but can be changed to anything you'd like.
* **limitReachedClass**: it's the class the element gets when the limit is reached. Default is "badge badge-warning".
* **separator**: represents the separator between the number of typed chars and total number of available chars. Default is "/".
* **preText**: is a string of text that can be outputted in front of the indicator. preText is empty by default.
* **postText**: is a string outputted after the indicator. postText is empty by default.
* **showMaxLength**: if false, will display just the number of typed characters, e.g. will not display the max length. Default: true.
* **showCharsTyped**: if false, will display just the remaining length, e.g. will display remaining lenght instead of number of typed characters. Default: true.
* **placement**: is a string, define where to output the counter. Possible values are: **bottom** ( *default option* ), **left**, **top**, **right**, **bottom-right**, **top-right**, **top-left**, **bottom-left** and **centered-right**.
* **message**: an alternative way to provide the message text, i.e. 'You have typed %charsTyped% chars, %charsRemaining% of %charsTotal% remaining'. %charsTyped%, %charsRemaining% and %charsTotal% will be replaced by the actual values. This overrides the options separator, preText, postText and showMaxLength.
* **utf8**: if true the input will count using utf8 bytesize/encoding. For example: the '£' character is counted as two characters.
## Examples
Basic implementation:
$('input[maxlength]').maxlength();
Change the threshold value:
$('input.className').maxlength({
threshold: 20
});
An example will all the configurable options:
$('input.className').maxlength({
alwaysShow: true,
threshold: 10,
warningClass: "label label-info",
limitReachedClass: "label label-warning",
placement: 'top',
preText: 'used ',
separator: ' of ',
postText: ' chars.'
});
The same example using the message option:
$('input.className').maxlength({
alwaysShow: true,
threshold: 10,
warningClass: "label label-info",
limitReachedClass: "label label-warning",
placement: 'top',
message: 'used %charsTyped% of %charsTotal% chars.'
});
## Changelog
### 1.5.3
* Fixed #40, error on resize event.
### 1.5.2
* Fixed #44 (pasted text in can cause it to go over the max length)
### 1.5.1
* Added self protection of multiple focus events
* Added back detection of window resizing
### 1.5.0
* Removed window.resize event
* Maxlength is created and destroyed each time
* Fixed Doesn't update the limit after input's maxlength attribute was changed [#31](https://github.com/mimo84/bootstrap-maxlength/issues/31)
* Added Gruntfile
* Added qunit unit tests
### 1.4.2
* Fixed issue with counting when the user moves with shift+tab keyboard shortcut.
* Replaced the warningClass limitReachedClass options to use labels rather than badges for Bootstrap 3.0 better compatibility.
### 1.4.1
* Added support for TAB key when the maxlength is reached.

View File

@@ -0,0 +1,31 @@
{
"name": "bootstrap-maxlength",
"title": "BootStrap Maxlength",
"description": "jQuery and Bootstrap plugin for character count on inputs",
"keywords": [
"count",
"input",
"maxlength",
"length",
"textarea",
"form"
],
"version": "1.5.2",
"author": {
"name": "Maurizio Napoleoni",
"url": "http://zoomingin.net"
},
"licenses": [
{
"type": "MIT License",
"url" : "https://github.com/mimo84/bootstrap-maxlength/blob/master/LICENSE"
}
],
"bugs": "https://github.com/mimo84/bootstrap-maxlength/issues",
"homepage": "http://mimo84.github.com/bootstrap-maxlength/",
"docs": "http://mimo84.github.com/bootstrap-maxlength/",
"download": "https://github.com/mimo84/bootstrap-maxlength/zipball/master",
"dependencies": {
"jquery": ">=1.9"
}
}

View File

@@ -0,0 +1,322 @@
(function ($) {
'use strict';
$.fn.extend({
maxlength: function (options, callback) {
var documentBody = $('body'),
defaults = {
alwaysShow: false, // if true the indicator it's always shown.
threshold: 10, // Represents how many chars left are needed to show up the counter
warningClass: 'label label-success',
limitReachedClass: 'label label-important',
separator: ' / ',
preText: '',
postText: '',
showMaxLength : true,
placement: 'bottom',
showCharsTyped: true, // show the number of characters typed and not the number of characters remaining
validate: false, // if the browser doesn't support the maxlength attribute, attempt to type more than
// the indicated chars, will be prevented.
utf8: false // counts using bytesize rather than length. eg: '£' is counted as 2 characters.
};
if ($.isFunction(options) && !callback) {
callback = options;
options = {};
}
options = $.extend(defaults, options);
/**
* Return the length of the specified input.
*
* @param input
* @return {number}
*/
function inputLength(input) {
var text = input.val();
// Remove all double-character (\r\n) linebreaks, so they're counted only once.
text = text.replace(new RegExp('\r?\n','g'), '\n');
// var matches = text.match(/\n/g);
var currentLength = 0;
if (options.utf8) {
currentLength = utf8Length(input.val());
} else {
currentLength = input.val().length;
}
return currentLength;
}
/**
* Return the length of the specified input in UTF8 encoding.
*
* @param input
* @return {number}
*/
function utf8Length(string) {
var utf8length = 0;
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utf8length++;
}
else if((c > 127) && (c < 2048)) {
utf8length = utf8length+2;
}
else {
utf8length = utf8length+3;
}
}
return utf8length;
}
/**
* Return true if the indicator should be showing up.
*
* @param input
* @param thereshold
* @param maxlength
* @return {number}
*/
function charsLeftThreshold(input, thereshold, maxlength) {
var output = true;
if (!options.alwaysShow && (maxlength - inputLength(input) > thereshold)) {
output = false;
}
return output;
}
/**
* Returns how many chars are left to complete the fill up of the form.
*
* @param input
* @param maxlength
* @return {number}
*/
function remainingChars(input, maxlength) {
var length = maxlength - inputLength(input);
return length;
}
/**
* When called displays the indicator.
*
* @param indicator
*/
function showRemaining(indicator) {
indicator.css({
display: 'block'
});
}
/**
* When called shows the indicator.
*
* @param indicator
*/
function hideRemaining(indicator) {
indicator.css({
display: 'none'
});
}
/**
* This function updates the value in the indicator
*
* @param maxLengthThisInput
* @param typedChars
* @return String
*/
function updateMaxLengthHTML(maxLengthThisInput, typedChars) {
var output = '';
if (options.message){
output = options.message.replace('%charsTyped%', typedChars)
.replace('%charsRemaining%', maxLengthThisInput - typedChars)
.replace('%charsTotal%', maxLengthThisInput);
} else {
if (options.preText) {
output += options.preText;
}
if (!options.showCharsTyped) {
output += maxLengthThisInput - typedChars;
}
else {
output += typedChars;
}
if (options.showMaxLength) {
output += options.separator + maxLengthThisInput;
}
if (options.postText) {
output += options.postText;
}
}
return output;
}
/**
* This function updates the value of the counter in the indicator.
* Wants as parameters: the number of remaining chars, the element currently managed,
* the maxLength for the current input and the indicator generated for it.
*
* @param remaining
* @param currentInput
* @param maxLengthCurrentInput
* @param maxLengthIndicator
*/
function manageRemainingVisibility(remaining, currentInput, maxLengthCurrentInput, maxLengthIndicator) {
maxLengthIndicator.html(updateMaxLengthHTML(maxLengthCurrentInput, (maxLengthCurrentInput - remaining)));
if (remaining > 0) {
if (charsLeftThreshold(currentInput, options.threshold, maxLengthCurrentInput)) {
showRemaining(maxLengthIndicator.removeClass(options.limitReachedClass).addClass(options.warningClass));
} else {
hideRemaining(maxLengthIndicator);
}
} else {
showRemaining(maxLengthIndicator.removeClass(options.warningClass).addClass(options.limitReachedClass));
}
}
/**
* This function returns an object containing all the
* informations about the position of the current input
*
* @param currentInput
* @return object {bottom height left right top width}
*
*/
function getPosition(currentInput) {
var el = currentInput[0];
return $.extend({}, (typeof el.getBoundingClientRect === 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth,
height: el.offsetHeight
}, currentInput.offset());
}
/**
* This function places the maxLengthIndicator at the
* top / bottom / left / right of the currentInput
*
* @param currentInput
* @param maxLengthIndicator
* @return null
*
*/
function place(currentInput, maxLengthIndicator) {
var pos = getPosition(currentInput),
inputOuter = currentInput.outerWidth(),
outerWidth = maxLengthIndicator.outerWidth(),
actualWidth = maxLengthIndicator.width(),
actualHeight = maxLengthIndicator.height();
switch (options.placement) {
case 'bottom':
maxLengthIndicator.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2});
break;
case 'top':
maxLengthIndicator.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2});
break;
case 'left':
maxLengthIndicator.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth});
break;
case 'right':
maxLengthIndicator.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width});
break;
case 'bottom-right':
maxLengthIndicator.css({top: pos.top + pos.height, left: pos.left + pos.width});
break;
case 'top-right':
maxLengthIndicator.css({top: pos.top - actualHeight, left: pos.left + inputOuter});
break;
case 'top-left':
maxLengthIndicator.css({top: pos.top - actualHeight, left: pos.left - outerWidth});
break;
case 'bottom-left':
maxLengthIndicator.css({top: pos.top + currentInput.outerHeight(), left: pos.left - outerWidth});
break;
case 'centered-right':
maxLengthIndicator.css({top: pos.top + (actualHeight / 2), left: pos.left + inputOuter - outerWidth - 3});
break;
}
}
/**
* This function retrieves the maximum length of currentInput
*
* @param currentInput
* @return {number}
*
*/
function getMaxLength(currentInput) {
return currentInput.attr('maxlength') || currentInput.attr('size');
}
return this.each(function() {
var currentInput = $(this),
maxLengthCurrentInput,
maxLengthIndicator;
$(window).resize(function() {
if(maxLengthIndicator) {
place(currentInput, maxLengthIndicator);
}
});
currentInput.focus(function () {
var maxlengthContent = updateMaxLengthHTML(maxLengthCurrentInput, '0');
maxLengthCurrentInput = getMaxLength(currentInput);
if (!maxLengthIndicator) {
maxLengthIndicator = $('<span class="bootstrap-maxlength"></span>').css({
display: 'none',
position: 'absolute',
whiteSpace: 'nowrap',
zIndex: 1099
}).html(maxlengthContent);
}
// We need to detect resizes if we are dealing with a textarea:
if (currentInput.is('textarea')) {
currentInput.data('maxlenghtsizex', currentInput.outerWidth());
currentInput.data('maxlenghtsizey', currentInput.outerHeight());
currentInput.mouseup(function() {
if (currentInput.outerWidth() !== currentInput.data('maxlenghtsizex') || currentInput.outerHeight() !== currentInput.data('maxlenghtsizey')) {
place(currentInput, maxLengthIndicator);
}
currentInput.data('maxlenghtsizex', currentInput.outerWidth());
currentInput.data('maxlenghtsizey', currentInput.outerHeight());
});
}
documentBody.append(maxLengthIndicator);
var remaining = remainingChars(currentInput, getMaxLength(currentInput));
manageRemainingVisibility(remaining, currentInput, maxLengthCurrentInput, maxLengthIndicator);
place(currentInput, maxLengthIndicator);
});
currentInput.blur(function() {
maxLengthIndicator.remove();
});
currentInput.keyup(function() {
var remaining = remainingChars(currentInput, getMaxLength(currentInput)),
output = true;
if (options.validate && remaining < 0) {
output = false;
} else {
manageRemainingVisibility(remaining, currentInput, maxLengthCurrentInput, maxLengthIndicator);
}
return output;
});
});
}
});
}(jQuery));

View File

@@ -0,0 +1,10 @@
/* ==========================================================
*
* bootstrap-maxlength.js v 1.5.3
* Copyright 2014 Maurizio Napoleoni @mimonap
* Licensed under MIT License
* URL: https://github.com/mimo84/bootstrap-maxlength/blob/master/LICENSE
*
* ========================================================== */
!function(a){"use strict";a.fn.extend({maxlength:function(b,c){function d(a){var c=a.val();c=c.replace(new RegExp("\r?\n","g"),"\n");var d=0;return d=b.utf8?e(a.val()):a.val().length}function e(a){for(var b=0,c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b++:b+=d>127&&2048>d?2:3}return b}function f(a,c,e){var f=!0;return!b.alwaysShow&&e-d(a)>c&&(f=!1),f}function g(a,b){var c=b-d(a);return c}function h(a){a.css({display:"block"})}function i(a){a.css({display:"none"})}function j(a,c){var d="";return b.message?d=b.message.replace("%charsTyped%",c).replace("%charsRemaining%",a-c).replace("%charsTotal%",a):(b.preText&&(d+=b.preText),d+=b.showCharsTyped?c:a-c,b.showMaxLength&&(d+=b.separator+a),b.postText&&(d+=b.postText)),d}function k(a,c,d,e){e.html(j(d,d-a)),a>0?f(c,b.threshold,d)?h(e.removeClass(b.limitReachedClass).addClass(b.warningClass)):i(e):h(e.removeClass(b.warningClass).addClass(b.limitReachedClass))}function l(b){var c=b[0];return a.extend({},"function"==typeof c.getBoundingClientRect?c.getBoundingClientRect():{width:c.offsetWidth,height:c.offsetHeight},b.offset())}function m(a,c){var d=l(a),e=a.outerWidth(),f=c.outerWidth(),g=c.width(),h=c.height();switch(b.placement){case"bottom":c.css({top:d.top+d.height,left:d.left+d.width/2-g/2});break;case"top":c.css({top:d.top-h,left:d.left+d.width/2-g/2});break;case"left":c.css({top:d.top+d.height/2-h/2,left:d.left-g});break;case"right":c.css({top:d.top+d.height/2-h/2,left:d.left+d.width});break;case"bottom-right":c.css({top:d.top+d.height,left:d.left+d.width});break;case"top-right":c.css({top:d.top-h,left:d.left+e});break;case"top-left":c.css({top:d.top-h,left:d.left-f});break;case"bottom-left":c.css({top:d.top+a.outerHeight(),left:d.left-f});break;case"centered-right":c.css({top:d.top+h/2,left:d.left+e-f-3})}}function n(a){return a.attr("maxlength")||a.attr("size")}var o=a("body"),p={alwaysShow:!1,threshold:10,warningClass:"label label-success",limitReachedClass:"label label-important",separator:" / ",preText:"",postText:"",showMaxLength:!0,placement:"bottom",showCharsTyped:!0,validate:!1,utf8:!1};return a.isFunction(b)&&!c&&(c=b,b={}),b=a.extend(p,b),this.each(function(){var c,d,e=a(this);a(window).resize(function(){d&&m(e,d)}),e.focus(function(){var b=j(c,"0");c=n(e),d||(d=a('<span class="bootstrap-maxlength"></span>').css({display:"none",position:"absolute",whiteSpace:"nowrap",zIndex:1099}).html(b)),e.is("textarea")&&(e.data("maxlenghtsizex",e.outerWidth()),e.data("maxlenghtsizey",e.outerHeight()),e.mouseup(function(){(e.outerWidth()!==e.data("maxlenghtsizex")||e.outerHeight()!==e.data("maxlenghtsizey"))&&m(e,d),e.data("maxlenghtsizex",e.outerWidth()),e.data("maxlenghtsizey",e.outerHeight())})),o.append(d);var f=g(e,n(e));k(f,e,c,d),m(e,d)}),e.blur(function(){d.remove()}),e.keyup(function(){var a=g(e,n(e)),f=!0;return b.validate&&0>a?f=!1:k(a,e,c,d),f})})}})}(jQuery);