mirror of
https://github.com/tabler/tabler.git
synced 2026-07-16 18:41:40 +04:00
Merge remote-tracking branch 'origin/dev-v1-navbars' into dev-v1-navbars
This commit is contained in:
@@ -109,6 +109,25 @@ $(document).ready(function () {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
Autosize plugin
|
||||
*/
|
||||
if(window.autosize) {
|
||||
(function() {
|
||||
|
||||
var $elem = $('[data-toggle="autosize"]');
|
||||
console.log('$elem', $elem);
|
||||
|
||||
if ($elem) {
|
||||
$elem.each(function() {
|
||||
autosize($(this));
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
||||
});
|
||||
|
||||
window.tabler = tabler;
|
||||
|
||||
+5
-2
@@ -48,8 +48,6 @@
|
||||
],
|
||||
"homepage": "https://tabler.io",
|
||||
"devDependencies": {
|
||||
"apexcharts": "3.6.2",
|
||||
"bootstrap": "twbs/bootstrap#41fcd13",
|
||||
"browser-sync": "^2.26.5",
|
||||
"bundlesize": "0.15.3",
|
||||
"clean-css-cli": "4.3.0",
|
||||
@@ -73,5 +71,10 @@
|
||||
"terser": "3.17.0",
|
||||
"icon-font-generator": "2.1.10",
|
||||
"svgo": "1.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"apexcharts": "3.6.2",
|
||||
"bootstrap": "twbs/bootstrap#41fcd13",
|
||||
"autosize": "4.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: Autosize
|
||||
---
|
||||
|
||||
A small, stand-alone script to automatically adjust textarea height.
|
||||
|
||||
### Default markup
|
||||
|
||||
{% example html %}
|
||||
<label class="form-label">Autosize example</label>
|
||||
<textarea class="form-control" data-toggle="autosize" placeholder="Typing something…"></textarea>
|
||||
{% endexample %}
|
||||
@@ -12,7 +12,7 @@
|
||||
{% if include.show-form %}
|
||||
<form action="">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Search something..." name="s">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Search something…" name="s">
|
||||
<span class="input-group-btn ml-2">
|
||||
<button class="btn btn-sm btn-default" type="submit">
|
||||
<span class="fe fe-search"></span>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<div class="form-group">
|
||||
<label class="form-label">Input group</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Search for...">
|
||||
<input type="text" class="form-control" placeholder="Search for…">
|
||||
<span class="input-group-append">
|
||||
<button class="btn btn-primary" type="button">Go!</button>
|
||||
</span>
|
||||
@@ -71,7 +71,7 @@
|
||||
<label class="form-label">Separated inputs</label>
|
||||
<div class="row row-xs">
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" placeholder="Search for...">
|
||||
<input type="text" class="form-control" placeholder="Search for…">
|
||||
</div>
|
||||
<span class="col-auto">
|
||||
<button class="btn btn-secondary" type="button">{% include ui/icon.html icon="search" %}</button>
|
||||
@@ -82,7 +82,7 @@
|
||||
<label class="form-label">ZIP Code</label>
|
||||
<div class="row row-sm">
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" placeholder="Search for...">
|
||||
<input type="text" class="form-control" placeholder="Search for…">
|
||||
</div>
|
||||
<span class="col-auto align-self-center">
|
||||
<span class="form-help" data-toggle="popover" data-placement="top"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<p class="mb-4">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam corporis dolorem earum et, fugiat illum
|
||||
incidunt modi ne... </p>
|
||||
incidunt modi ne… </p>
|
||||
{% include ui/avatar-list.html text="+5" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<header class="navbar {% if include.dark %} bg-dark text-white{% endif %}">
|
||||
{% include parts/navbar.html logo=true user-menu=1 person=5 dark=false white-logo=include.dark %}
|
||||
</header>
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
<script src="{{ site.base }}/libs/apexcharts/apexcharts.min.js"></script>
|
||||
<script src="{{ site.base }}/libs/peity/jquery.peity.min.js"></script>
|
||||
<script src="{{ site.base }}/libs/autosize/autosize.min.js"></script>
|
||||
|
||||
|
||||
<script src="{{ site.base }}/js/tabler.js"></script>
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
<header class="navbar {% if include.dark %} bg-dark text-white{% endif %}">
|
||||
{% include parts/navbar.html logo=true search=true user-menu=1 person=5 dark=false white-logo=include.dark %}
|
||||
</header>
|
||||
|
||||
{% comment %}
|
||||
{% if page.nav-position == "top" or page.nav-position == "all" %}
|
||||
<header class="navbar navbar-expand-md">
|
||||
<div class="container">
|
||||
{% include layout/menu.html %}
|
||||
</div>
|
||||
</header>
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="form-group">
|
||||
<label class="form-label">Icon input</label>
|
||||
<div class="input-icon mb-3">
|
||||
<input type="text" class="form-control" placeholder="Search for...">
|
||||
<input type="text" class="form-control" placeholder="Search for…">
|
||||
<span class="input-icon-addon">
|
||||
{% include ui/icon.html icon="search" %}
|
||||
</span>
|
||||
@@ -12,4 +12,4 @@
|
||||
</span>
|
||||
<input type="text" class="form-control" placeholder="Username">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,14 +7,25 @@
|
||||
{% include ui/icon.html icon="menu" %}
|
||||
</a>
|
||||
|
||||
|
||||
<a href="{{ site.base }}" class="navbar-brand text-inherit">
|
||||
{% if include.icon %}<span class="text-green">{% include ui/icon.html icon=include.icon %}</span>{% endif %}
|
||||
{% if include.stamp %}<span class="stamp bg-primary text-white">UI</span>{% endif %}
|
||||
{% if include.logo %}<img src="{{ site.base }}/img/logo{% if include.white-logo %}-white{% endif %}.svg" alt="" class="navbar-brand-logo mr-3">{% endif %}
|
||||
{% if include.logo %}
|
||||
<img src="{{ site.base }}/img/logo{% if include.white-logo %}-white{% endif %}.svg" alt="{{ site.title }}" class="d-none d-md-block navbar-brand-logo mr-3">
|
||||
<img src="{{ site.base }}/img/logo-small{% if include.white-logo %}-white{% endif %}.svg" alt="{{ site.title }}" class="d-md-none navbar-brand-logo mr-3">
|
||||
{% endif %}
|
||||
{% if include.title %}<span class="d-inline">{{ include.title }}</span>{% endif %}
|
||||
</a>
|
||||
|
||||
{% if include.search %}
|
||||
<div class="w-auto flex-fill max-w-md ml-0 ml-md-8 mr-auto d-none d-lg-block">
|
||||
<div class="input-icon">
|
||||
<span class="input-icon-addon">{% include ui/icon.html icon="search" %}</span>
|
||||
<input type="text" class="form-control" placeholder="Search" tabindex="-1">
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if include.plus-left %}
|
||||
<a href="#" class="btn btn-primary">
|
||||
{% include ui/icon.html icon="plus" %}
|
||||
@@ -59,18 +70,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if include.search %}
|
||||
<!-- Navbar Search -->
|
||||
<form class="input-group m-2 my-lg-0 ">
|
||||
<span class="input-group-prepend">
|
||||
<button type="button"
|
||||
class="btn no-shadow no-bg px-0">{% include ui/icon.html icon="search" %}</button>
|
||||
</span>
|
||||
<input type="text" class="form-control no-border no-shadow no-bg typeahead" placeholder="Search..."
|
||||
data-plugin="typeahead">
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<ul class="nav navbar-menu order-1 order-lg-2">
|
||||
@@ -129,8 +128,8 @@
|
||||
<a href="#" data-toggle="dropdown"
|
||||
class="nav-link d-flex align-items-center py-0 px-lg-0 px-2 text-color ml-2">
|
||||
{% if include.user-menu == 1 %}
|
||||
{% include ui/avatar.html src=person.photo %}
|
||||
<span class="ml-2 d-none d-lg-block leading-none">
|
||||
{% include ui/avatar.html src=person.photo %}
|
||||
<span class="ml-2 d-none d-lg-block leading-none">
|
||||
<span>{{ person.full_name }}</span>
|
||||
<span class="text-muted d-block mt-1 text-h6">Administrator</span>
|
||||
</span>
|
||||
@@ -157,14 +156,14 @@
|
||||
{% include ui/icon.html icon="mail" class="dropdown-icon" %} Inbox
|
||||
</a>
|
||||
<a class="dropdown-item" href="#">
|
||||
{% include ui/icon.html icon="send" class="dropdown-icon" %} Message
|
||||
{% include ui/icon.html icon="send" class="dropdown-icon" %} Message
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">
|
||||
{% include ui/icon.html icon="help-circle" class="dropdown-icon" %} Need help?
|
||||
{% include ui/icon.html icon="help-circle" class="dropdown-icon" %} Need help?
|
||||
</a>
|
||||
<a class="dropdown-item" href="#">
|
||||
{% include ui/icon.html icon="log-out" class="dropdown-icon" %} Sign out
|
||||
{% include ui/icon.html icon="log-out" class="dropdown-icon" %} Sign out
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% assign elem = include.element | default: 'div' %}
|
||||
<{{ elem }} class="spinner-{{ include.type | default: 'border' }}{% if include.color %} text-{{ include.color }}{% endif %}{% if include['size'] %} spinner-{{ include.type | default: 'border' }}-{{ include['size'] }}{% endif %}{% if include.class %} {{ include.class }}{% endif %}" role="status">
|
||||
<span class="sr-only">loading...</span>
|
||||
<span class="sr-only">loading…</span>
|
||||
</{{ elem }}>
|
||||
|
||||
@@ -2,20 +2,15 @@
|
||||
layout: base
|
||||
---
|
||||
|
||||
<div class="d-flex h-auto min-h-screen">
|
||||
<div class="d-flex h-auto min-h-screen flex-wrap">
|
||||
|
||||
{% if page.nav-position == "left" or page.nav-position == "right" or page.nav-position == "all" %}
|
||||
{% include layout/sidenav.html %}
|
||||
{% endif %}
|
||||
|
||||
<div class="main-content flex-fill d-flex flex-column mw-100">
|
||||
{% include layout/header.html %}
|
||||
{% include layout/topnav.html %}
|
||||
|
||||
{% comment %}
|
||||
{% if page.nav-position == "top" or page.nav-position == "all" %}
|
||||
{% include layout/topnav.html %}
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
<div class="main-content flex-fill d-flex flex-column mw-100">
|
||||
|
||||
<div class="d-flex flex-fill">
|
||||
|
||||
|
||||
+10
-10
@@ -5,7 +5,7 @@ menu: level-1.level-2.level-3.level-4
|
||||
---
|
||||
|
||||
<div class="row row-cards">
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
@@ -25,7 +25,7 @@ menu: level-1.level-2.level-3.level-4
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
@@ -45,7 +45,7 @@ menu: level-1.level-2.level-3.level-4
|
||||
{% include js/charts.html id="card-chart-1" chart-id="revenue-bg" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
@@ -67,7 +67,7 @@ menu: level-1.level-2.level-3.level-4
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-6 col-md-4 col-lg-3">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex">
|
||||
@@ -89,22 +89,22 @@ menu: level-1.level-2.level-3.level-4
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6 col-sm-4 col-xl-2">
|
||||
<div class="col-6 col-sm-4 col-lg-2">
|
||||
{% include cards/small-stats-3.html number=43 title="New Tickets" percentage=6 %}
|
||||
</div>
|
||||
<div class="col-6 col-sm-4 col-xl-2">
|
||||
<div class="col-6 col-sm-4 col-lg-2">
|
||||
{% include cards/small-stats-3.html number=17 title="Closed Today" percentage=-3 %}
|
||||
</div>
|
||||
<div class="col-6 col-sm-4 col-xl-2">
|
||||
<div class="col-6 col-sm-4 col-lg-2">
|
||||
{% include cards/small-stats-3.html number=7 title="New Replies" percentage=9 %}
|
||||
</div>
|
||||
<div class="col-6 col-sm-4 col-xl-2">
|
||||
<div class="col-6 col-sm-4 col-lg-2">
|
||||
{% include cards/small-stats-3.html number="27.3K" title="Followers" percentage=3 %}
|
||||
</div>
|
||||
<div class="col-6 col-sm-4 col-xl-2">
|
||||
<div class="col-6 col-sm-4 col-lg-2">
|
||||
{% include cards/small-stats-3.html number="$95" title="Daily Earnings" percentage=-2 %}
|
||||
</div>
|
||||
<div class="col-6 col-sm-4 col-xl-2">
|
||||
<div class="col-6 col-sm-4 col-lg-2">
|
||||
{% include cards/small-stats-3.html number=621 title="Products" percentage=-1 %}
|
||||
</div>
|
||||
|
||||
|
||||
+53
-5
@@ -103,6 +103,9 @@ $avatar-sizes: (
|
||||
"xl": 6rem
|
||||
) !default;
|
||||
|
||||
/**
|
||||
Fonts
|
||||
*/
|
||||
$font-size-base: 1rem !default;
|
||||
$font-weight-base: 400 !default;
|
||||
$line-height-base: 1.375 !default;
|
||||
@@ -114,7 +117,7 @@ Typography
|
||||
*/
|
||||
$headings-font-weight: 600 !default;
|
||||
|
||||
$small-font-size: 80% !default;
|
||||
$small-font-size: 87.5% !default;
|
||||
|
||||
$h1-font-size: $font-size-base * 1.875 !default;
|
||||
$h2-font-size: $font-size-base * 1.5 !default;
|
||||
@@ -127,13 +130,51 @@ $blockquote-font-size: $h4-font-size !default;
|
||||
$lead-font-size: $h3-font-size !default;
|
||||
|
||||
/**
|
||||
Ribbons
|
||||
Sizing
|
||||
*/
|
||||
$ribbon-margin: .25rem !default;
|
||||
$spacer: 1rem !default;
|
||||
$spacers: (
|
||||
0: 0rem,
|
||||
1: .25rem,
|
||||
2: .5rem,
|
||||
4: 1rem,
|
||||
5: 1.5rem,
|
||||
6: 2rem,
|
||||
7: 2.5rem,
|
||||
8: 3rem,
|
||||
) !default;
|
||||
|
||||
$loader-size: 2.5rem !default;
|
||||
$size-spacers: (
|
||||
9: 4rem,
|
||||
10: 5rem,
|
||||
11: 6rem,
|
||||
12: 8rem,
|
||||
13: 10rem,
|
||||
14: 12rem,
|
||||
15: 14rem,
|
||||
16: 16rem,
|
||||
17: 18rem,
|
||||
18: 20rem,
|
||||
auto: auto,
|
||||
px: 1px,
|
||||
full: 100%
|
||||
) !default;
|
||||
|
||||
$sizes: (
|
||||
$size-max-spacers: (
|
||||
xs: 20rem,
|
||||
sm: 24rem,
|
||||
md: 28rem,
|
||||
lg: 32rem,
|
||||
xl: 36rem,
|
||||
2 xl: 42rem,
|
||||
3 xl: 48rem,
|
||||
4 xl: 56rem,
|
||||
5 xl: 64rem,
|
||||
6 xl: 72rem,
|
||||
full: 100%
|
||||
) !default;
|
||||
|
||||
$sizes-percentage: (
|
||||
1: 1%,
|
||||
25: 25%,
|
||||
50: 50%,
|
||||
@@ -142,6 +183,13 @@ $sizes: (
|
||||
auto: auto
|
||||
) !default;
|
||||
|
||||
/**
|
||||
Ribbons
|
||||
*/
|
||||
$ribbon-margin: .25rem !default;
|
||||
|
||||
$loader-size: 2.5rem !default;
|
||||
|
||||
$generate-social-colors: true !default;
|
||||
$generate-color-hues: true !default;
|
||||
$generate-colors: true !default;
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
.navbar {
|
||||
background: #fff;
|
||||
border-bottom: 1px solid $border-color;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
display: flex;
|
||||
min-height: 3.75rem;
|
||||
padding: .75rem 1rem;
|
||||
width: 100%;
|
||||
|
||||
.nav-link {
|
||||
color: inherit;
|
||||
|
||||
+14
-34
@@ -10,41 +10,21 @@
|
||||
.min-w-0 { min-width: 0 !important; }
|
||||
.min-w-full { min-width: 100% !important; }
|
||||
|
||||
.h-1 { height: .25rem !important; }
|
||||
.h-2 { height: .5rem !important; }
|
||||
.h-3 { height: .75rem !important; }
|
||||
.h-4 { height: 1rem !important; }
|
||||
.h-6 { height: 1.5rem !important; }
|
||||
.h-8 { height: 2rem !important; }
|
||||
.h-10 { height: 2.5rem !important; }
|
||||
.h-12 { height: 3rem !important; }
|
||||
.h-16 { height: 4rem !important; }
|
||||
.h-24 { height: 6rem !important; }
|
||||
.h-32 { height: 8rem !important; }
|
||||
.h-48 { height: 12rem !important; }
|
||||
.h-64 { height: 16rem !important; }
|
||||
.h-auto { height: auto !important; }
|
||||
.h-px { height: 1px !important; }
|
||||
.h-full { height: 100% !important; }
|
||||
@each $size-name, $size in $sizes-percentage {
|
||||
.w-#{$size-name}p { width: $size !important; }
|
||||
.h-#{$size-name}p { height: $size !important; }
|
||||
}
|
||||
|
||||
@each $size-name, $size in map_merge($spacers, $size-spacers) {
|
||||
.w-#{$size-name} { width: $size !important; }
|
||||
.h-#{$size-name} { height: $size !important; }
|
||||
}
|
||||
|
||||
.h-screen { height: 100vh !important; }
|
||||
|
||||
.w-1 { width: .25rem !important; }
|
||||
.w-2 { width: .5rem !important; }
|
||||
.w-3 { width: .75rem !important; }
|
||||
.w-4 { width: 1rem !important; }
|
||||
.w-6 { width: 1.5rem !important; }
|
||||
.w-8 { width: 2rem !important; }
|
||||
.w-10 { width: 2.5rem !important; }
|
||||
.w-12 { width: 3rem !important; }
|
||||
.w-16 { width: 4rem !important; }
|
||||
.w-24 { width: 6rem !important; }
|
||||
.w-32 { width: 8rem !important; }
|
||||
.w-48 { width: 12rem !important; }
|
||||
.w-64 { width: 16rem !important; }
|
||||
.w-auto { width: auto !important; }
|
||||
.w-px { width: 1px !important; }
|
||||
|
||||
.w-full { width: 100% !important; }
|
||||
.w-screen { width: 100vw !important; }
|
||||
|
||||
@each $size-name, $size in $size-max-spacers {
|
||||
.max-w-#{$size-name} { max-width: $size !important; }
|
||||
.max-h-#{$size-name} { max-height: $size !important; }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
/*!
|
||||
autosize 4.0.2
|
||||
license: MIT
|
||||
http://www.jacklmoore.com/autosize
|
||||
*/
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(['module', 'exports'], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
factory(module, exports);
|
||||
} else {
|
||||
var mod = {
|
||||
exports: {}
|
||||
};
|
||||
factory(mod, mod.exports);
|
||||
global.autosize = mod.exports;
|
||||
}
|
||||
})(this, function (module, exports) {
|
||||
'use strict';
|
||||
|
||||
var map = typeof Map === "function" ? new Map() : function () {
|
||||
var keys = [];
|
||||
var values = [];
|
||||
|
||||
return {
|
||||
has: function has(key) {
|
||||
return keys.indexOf(key) > -1;
|
||||
},
|
||||
get: function get(key) {
|
||||
return values[keys.indexOf(key)];
|
||||
},
|
||||
set: function set(key, value) {
|
||||
if (keys.indexOf(key) === -1) {
|
||||
keys.push(key);
|
||||
values.push(value);
|
||||
}
|
||||
},
|
||||
delete: function _delete(key) {
|
||||
var index = keys.indexOf(key);
|
||||
if (index > -1) {
|
||||
keys.splice(index, 1);
|
||||
values.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
var createEvent = function createEvent(name) {
|
||||
return new Event(name, { bubbles: true });
|
||||
};
|
||||
try {
|
||||
new Event('test');
|
||||
} catch (e) {
|
||||
// IE does not support `new Event()`
|
||||
createEvent = function createEvent(name) {
|
||||
var evt = document.createEvent('Event');
|
||||
evt.initEvent(name, true, false);
|
||||
return evt;
|
||||
};
|
||||
}
|
||||
|
||||
function assign(ta) {
|
||||
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
|
||||
|
||||
var heightOffset = null;
|
||||
var clientWidth = null;
|
||||
var cachedHeight = null;
|
||||
|
||||
function init() {
|
||||
var style = window.getComputedStyle(ta, null);
|
||||
|
||||
if (style.resize === 'vertical') {
|
||||
ta.style.resize = 'none';
|
||||
} else if (style.resize === 'both') {
|
||||
ta.style.resize = 'horizontal';
|
||||
}
|
||||
|
||||
if (style.boxSizing === 'content-box') {
|
||||
heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
|
||||
} else {
|
||||
heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
||||
}
|
||||
// Fix when a textarea is not on document body and heightOffset is Not a Number
|
||||
if (isNaN(heightOffset)) {
|
||||
heightOffset = 0;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
function changeOverflow(value) {
|
||||
{
|
||||
// Chrome/Safari-specific fix:
|
||||
// When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
|
||||
// made available by removing the scrollbar. The following forces the necessary text reflow.
|
||||
var width = ta.style.width;
|
||||
ta.style.width = '0px';
|
||||
// Force reflow:
|
||||
/* jshint ignore:start */
|
||||
ta.offsetWidth;
|
||||
/* jshint ignore:end */
|
||||
ta.style.width = width;
|
||||
}
|
||||
|
||||
ta.style.overflowY = value;
|
||||
}
|
||||
|
||||
function getParentOverflows(el) {
|
||||
var arr = [];
|
||||
|
||||
while (el && el.parentNode && el.parentNode instanceof Element) {
|
||||
if (el.parentNode.scrollTop) {
|
||||
arr.push({
|
||||
node: el.parentNode,
|
||||
scrollTop: el.parentNode.scrollTop
|
||||
});
|
||||
}
|
||||
el = el.parentNode;
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function resize() {
|
||||
if (ta.scrollHeight === 0) {
|
||||
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
|
||||
return;
|
||||
}
|
||||
|
||||
var overflows = getParentOverflows(ta);
|
||||
var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
|
||||
|
||||
ta.style.height = '';
|
||||
ta.style.height = ta.scrollHeight + heightOffset + 'px';
|
||||
|
||||
// used to check if an update is actually necessary on window.resize
|
||||
clientWidth = ta.clientWidth;
|
||||
|
||||
// prevents scroll-position jumping
|
||||
overflows.forEach(function (el) {
|
||||
el.node.scrollTop = el.scrollTop;
|
||||
});
|
||||
|
||||
if (docTop) {
|
||||
document.documentElement.scrollTop = docTop;
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
resize();
|
||||
|
||||
var styleHeight = Math.round(parseFloat(ta.style.height));
|
||||
var computed = window.getComputedStyle(ta, null);
|
||||
|
||||
// Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
|
||||
var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
|
||||
|
||||
// The actual height not matching the style height (set via the resize method) indicates that
|
||||
// the max-height has been exceeded, in which case the overflow should be allowed.
|
||||
if (actualHeight < styleHeight) {
|
||||
if (computed.overflowY === 'hidden') {
|
||||
changeOverflow('scroll');
|
||||
resize();
|
||||
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
|
||||
}
|
||||
} else {
|
||||
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
|
||||
if (computed.overflowY !== 'hidden') {
|
||||
changeOverflow('hidden');
|
||||
resize();
|
||||
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if (cachedHeight !== actualHeight) {
|
||||
cachedHeight = actualHeight;
|
||||
var evt = createEvent('autosize:resized');
|
||||
try {
|
||||
ta.dispatchEvent(evt);
|
||||
} catch (err) {
|
||||
// Firefox will throw an error on dispatchEvent for a detached element
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=889376
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pageResize = function pageResize() {
|
||||
if (ta.clientWidth !== clientWidth) {
|
||||
update();
|
||||
}
|
||||
};
|
||||
|
||||
var destroy = function (style) {
|
||||
window.removeEventListener('resize', pageResize, false);
|
||||
ta.removeEventListener('input', update, false);
|
||||
ta.removeEventListener('keyup', update, false);
|
||||
ta.removeEventListener('autosize:destroy', destroy, false);
|
||||
ta.removeEventListener('autosize:update', update, false);
|
||||
|
||||
Object.keys(style).forEach(function (key) {
|
||||
ta.style[key] = style[key];
|
||||
});
|
||||
|
||||
map.delete(ta);
|
||||
}.bind(ta, {
|
||||
height: ta.style.height,
|
||||
resize: ta.style.resize,
|
||||
overflowY: ta.style.overflowY,
|
||||
overflowX: ta.style.overflowX,
|
||||
wordWrap: ta.style.wordWrap
|
||||
});
|
||||
|
||||
ta.addEventListener('autosize:destroy', destroy, false);
|
||||
|
||||
// IE9 does not fire onpropertychange or oninput for deletions,
|
||||
// so binding to onkeyup to catch most of those events.
|
||||
// There is no way that I know of to detect something like 'cut' in IE9.
|
||||
if ('onpropertychange' in ta && 'oninput' in ta) {
|
||||
ta.addEventListener('keyup', update, false);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', pageResize, false);
|
||||
ta.addEventListener('input', update, false);
|
||||
ta.addEventListener('autosize:update', update, false);
|
||||
ta.style.overflowX = 'hidden';
|
||||
ta.style.wordWrap = 'break-word';
|
||||
|
||||
map.set(ta, {
|
||||
destroy: destroy,
|
||||
update: update
|
||||
});
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
function destroy(ta) {
|
||||
var methods = map.get(ta);
|
||||
if (methods) {
|
||||
methods.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
function update(ta) {
|
||||
var methods = map.get(ta);
|
||||
if (methods) {
|
||||
methods.update();
|
||||
}
|
||||
}
|
||||
|
||||
var autosize = null;
|
||||
|
||||
// Do nothing in Node.js environment and IE8 (or lower)
|
||||
if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
|
||||
autosize = function autosize(el) {
|
||||
return el;
|
||||
};
|
||||
autosize.destroy = function (el) {
|
||||
return el;
|
||||
};
|
||||
autosize.update = function (el) {
|
||||
return el;
|
||||
};
|
||||
} else {
|
||||
autosize = function autosize(el, options) {
|
||||
if (el) {
|
||||
Array.prototype.forEach.call(el.length ? el : [el], function (x) {
|
||||
return assign(x, options);
|
||||
});
|
||||
}
|
||||
return el;
|
||||
};
|
||||
autosize.destroy = function (el) {
|
||||
if (el) {
|
||||
Array.prototype.forEach.call(el.length ? el : [el], destroy);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
autosize.update = function (el) {
|
||||
if (el) {
|
||||
Array.prototype.forEach.call(el.length ? el : [el], update);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
}
|
||||
|
||||
exports.default = autosize;
|
||||
module.exports = exports['default'];
|
||||
});
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
autosize 4.0.2
|
||||
license: MIT
|
||||
http://www.jacklmoore.com/autosize
|
||||
*/
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1<n.indexOf(e)},get:function(e){return o[n.indexOf(e)]},set:function(e,t){-1===n.indexOf(e)&&(n.push(e),o.push(t))},delete:function(e){var t=n.indexOf(e);-1<t&&(n.splice(t,1),o.splice(t,1))}}),c=function(e){return new Event(e,{bubbles:!0})};try{new Event("test")}catch(e){c=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}function r(r){if(r&&r.nodeName&&"TEXTAREA"===r.nodeName&&!p.has(r)){var e,n=null,o=null,i=null,d=function(){r.clientWidth!==o&&a()},l=function(t){window.removeEventListener("resize",d,!1),r.removeEventListener("input",a,!1),r.removeEventListener("keyup",a,!1),r.removeEventListener("autosize:destroy",l,!1),r.removeEventListener("autosize:update",a,!1),Object.keys(t).forEach(function(e){r.style[e]=t[e]}),p.delete(r)}.bind(r,{height:r.style.height,resize:r.style.resize,overflowY:r.style.overflowY,overflowX:r.style.overflowX,wordWrap:r.style.wordWrap});r.addEventListener("autosize:destroy",l,!1),"onpropertychange"in r&&"oninput"in r&&r.addEventListener("keyup",a,!1),window.addEventListener("resize",d,!1),r.addEventListener("input",a,!1),r.addEventListener("autosize:update",a,!1),r.style.overflowX="hidden",r.style.wordWrap="break-word",p.set(r,{destroy:l,update:a}),"vertical"===(e=window.getComputedStyle(r,null)).resize?r.style.resize="none":"both"===e.resize&&(r.style.resize="horizontal"),n="content-box"===e.boxSizing?-(parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)):parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),isNaN(n)&&(n=0),a()}function s(e){var t=r.style.width;r.style.width="0px",r.offsetWidth,r.style.width=t,r.style.overflowY=e}function u(){if(0!==r.scrollHeight){var e=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(r),t=document.documentElement&&document.documentElement.scrollTop;r.style.height="",r.style.height=r.scrollHeight+n+"px",o=r.clientWidth,e.forEach(function(e){e.node.scrollTop=e.scrollTop}),t&&(document.documentElement.scrollTop=t)}}function a(){u();var e=Math.round(parseFloat(r.style.height)),t=window.getComputedStyle(r,null),n="content-box"===t.boxSizing?Math.round(parseFloat(t.height)):r.offsetHeight;if(n<e?"hidden"===t.overflowY&&(s("scroll"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight):"hidden"!==t.overflowY&&(s("hidden"),u(),n="content-box"===t.boxSizing?Math.round(parseFloat(window.getComputedStyle(r,null).height)):r.offsetHeight),i!==n){i=n;var o=c("autosize:resized");try{r.dispatchEvent(o)}catch(e){}}}}function i(e){var t=p.get(e);t&&t.destroy()}function d(e){var t=p.get(e);t&&t.update()}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return r(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],d),e}),t.default=l,e.exports=t.default});
|
||||
Reference in New Issue
Block a user