Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
K
kpp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Veselov
kpp
Commits
31a96f53
Commit
31a96f53
authored
Apr 01, 2017
by
Nikolay Gromov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Табы (продолжение)
parent
31546776
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
90 deletions
+22
-90
blocks-demo.html
src/blocks-demo.html
+4
-4
off-canvas.js
src/blocks/off-canvas/off-canvas.js
+5
-4
tabs.js
src/blocks/tabs/tabs.js
+12
-82
tabs.scss
src/blocks/tabs/tabs.scss
+1
-0
No files found.
src/blocks-demo.html
View file @
31a96f53
...
@@ -1868,16 +1868,16 @@
...
@@ -1868,16 +1868,16 @@
<div
class=
"tabs"
>
<div
class=
"tabs"
>
<ul
class=
"tabs__links"
role=
"tablist"
>
<ul
class=
"tabs__links"
role=
"tablist"
>
<li
class=
"tabs__link-wrap tabs__link-wrap--active"
role=
"presentation"
>
<li
class=
"tabs__link-wrap tabs__link-wrap--active"
role=
"presentation"
>
<a
href=
"#demo-tab-01"
class=
"tabs__link"
role=
"tab"
>
Вкладка 01
</a>
<a
href=
"#demo-tab-01"
class=
"tabs__link"
data-toggle=
"tab"
role=
"tab"
>
Вкладка 01
</a>
</li>
</li>
<li
class=
"tabs__link-wrap"
role=
"presentation"
>
<li
class=
"tabs__link-wrap"
role=
"presentation"
>
<
a
href=
"#demo-tab-02"
class=
"tabs__link"
role=
"tab"
>
Вкладка 02
</a
>
<
span
data-target=
"#demo-tab-02"
class=
"tabs__link"
data-toggle=
"tab"
role=
"tab"
>
Вкладка 02
</span
>
</li>
</li>
<li
class=
"tabs__link-wrap"
role=
"presentation"
>
<li
class=
"tabs__link-wrap"
role=
"presentation"
>
<a
href=
"#demo-tab-03"
class=
"tabs__link"
role=
"tab"
>
Вкладка 03
</a>
<a
href=
"#demo-tab-03"
class=
"tabs__link"
data-toggle=
"tab"
role=
"tab"
>
Вкладка 03
</a>
</li>
</li>
<li
class=
"tabs__link-wrap"
role=
"presentation"
>
<li
class=
"tabs__link-wrap"
role=
"presentation"
>
<a
href=
"#demo-tab-04"
class=
"tabs__link"
role=
"tab"
>
Вкладка 04
</a>
<a
href=
"#demo-tab-04"
class=
"tabs__link"
data-toggle=
"tab"
role=
"tab"
>
Вкладка 04
</a>
</li>
</li>
</ul>
</ul>
<div
class=
"tabs__content-wrapper"
>
<div
class=
"tabs__content-wrapper"
>
...
...
src/blocks/off-canvas/off-canvas.js
View file @
31a96f53
...
@@ -5,11 +5,12 @@ document.addEventListener('DOMContentLoaded', function(){
...
@@ -5,11 +5,12 @@ document.addEventListener('DOMContentLoaded', function(){
event
.
preventDefault
();
event
.
preventDefault
();
offCanvasToggle
();
offCanvasToggle
();
}
}
if
(
event
.
target
.
dataset
.
toggleNative
===
'off-canvas'
)
{
//
if(event.target.dataset.toggleNative === 'off-canvas') {
offCanvasToggle
();
//
offCanvasToggle();
}
//
}
});
});
// реакция на свайп
document
.
addEventListener
(
'touchstart'
,
handleTouchStart
,
false
);
document
.
addEventListener
(
'touchstart'
,
handleTouchStart
,
false
);
document
.
addEventListener
(
'touchmove'
,
handleTouchMove
,
false
);
document
.
addEventListener
(
'touchmove'
,
handleTouchMove
,
false
);
var
xDown
=
null
;
var
xDown
=
null
;
...
@@ -28,7 +29,7 @@ document.addEventListener('DOMContentLoaded', function(){
...
@@ -28,7 +29,7 @@ document.addEventListener('DOMContentLoaded', function(){
var
xDiff
=
xDown
-
xUp
;
var
xDiff
=
xDown
-
xUp
;
var
yDiff
=
yDown
-
yUp
;
var
yDiff
=
yDown
-
yUp
;
if
(
Math
.
abs
(
xDiff
)
+
Math
.
abs
(
yDiff
)
>
1
5
0
){
//to deal with to short swipes
if
(
Math
.
abs
(
xDiff
)
+
Math
.
abs
(
yDiff
)
>
1
0
0
){
//to deal with to short swipes
if
(
Math
.
abs
(
xDiff
)
>
Math
.
abs
(
yDiff
)
)
{
/*most significant*/
if
(
Math
.
abs
(
xDiff
)
>
Math
.
abs
(
yDiff
)
)
{
/*most significant*/
if
(
xDiff
>
0
)
{
/* left swipe */
if
(
xDiff
>
0
)
{
/* left swipe */
...
...
src/blocks/tabs/tabs.js
View file @
31a96f53
(
function
()
{
document
.
addEventListener
(
'DOMContentLoaded'
,
function
()
{
'use strict'
;
// в процессе разработки
// Источник: https://github.com/callmenick/responsive-tabs/blob/master/js/src/tabs.js
document
.
addEventListener
(
'click'
,
function
(
event
)
{
if
(
event
.
target
.
dataset
.
toggle
===
'tab'
)
{
/**
event
.
preventDefault
();
* tabs
var
target
=
event
.
target
.
hash
===
undefined
?
event
.
target
.
dataset
.
target
:
event
.
target
.
hash
;
*
console
.
log
(
target
);
* @description The Tabs component.
if
(
target
!==
undefined
)
{
* @param {Object} options The options hash
console
.
log
(
document
.
querySelector
(
target
)
);
*/
var
tabs
=
function
(
options
)
{
var
el
=
document
.
querySelector
(
options
.
el
);
var
tabNavigationLinks
=
el
.
querySelectorAll
(
options
.
tabNavigationLinks
);
var
tabContentContainers
=
el
.
querySelectorAll
(
options
.
tabContentContainers
);
var
activeIndex
=
0
;
var
initCalled
=
false
;
/**
* init
*
* @description Initializes the component by removing the no-js class from
* the component, and attaching event listeners to each of the nav items.
* Returns nothing.
*/
var
init
=
function
()
{
if
(
!
initCalled
)
{
initCalled
=
true
;
el
.
classList
.
remove
(
'no-js'
);
for
(
var
i
=
0
;
i
<
tabNavigationLinks
.
length
;
i
++
)
{
var
link
=
tabNavigationLinks
[
i
];
handleClick
(
link
,
i
);
}
}
}
}
};
/**
* handleClick
*
* @description Handles click event listeners on each of the links in the
* tab navigation. Returns nothing.
* @param {HTMLElement} link The link to listen for events on
* @param {Number} index The index of that link
*/
var
handleClick
=
function
(
link
,
index
)
{
link
.
addEventListener
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
goToTab
(
index
);
});
});
};
/**
* goToTab
*
* @description Goes to a specific tab based on index. Returns nothing.
* @param {Number} index The index of the tab to go to
*/
var
goToTab
=
function
(
index
)
{
if
(
index
!==
activeIndex
&&
index
>=
0
&&
index
<=
tabNavigationLinks
.
length
)
{
tabNavigationLinks
[
activeIndex
].
classList
.
remove
(
'is-active'
);
tabNavigationLinks
[
index
].
classList
.
add
(
'is-active'
);
tabContentContainers
[
activeIndex
].
classList
.
remove
(
'is-active'
);
tabContentContainers
[
index
].
classList
.
add
(
'is-active'
);
activeIndex
=
index
;
}
};
/**
* Returns init and goToTab
*/
return
{
init
:
init
,
goToTab
:
goToTab
};
};
/**
* Attach to global namespace
*/
window
.
tabs
=
tabs
;
})
()
;
});
src/blocks/tabs/tabs.scss
View file @
31a96f53
...
@@ -25,6 +25,7 @@ $field-padding-horizontal: 0.7em !default;
...
@@ -25,6 +25,7 @@ $field-padding-horizontal: 0.7em !default;
display
:
flex
;
display
:
flex
;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
align-items
:
flex-end
;
align-items
:
flex-end
;
cursor
:
pointer
;
.no-js
&
{
.no-js
&
{
display
:
none
;
display
:
none
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment