2013-08-16 15:44:11 +04:00
|
|
|
// # Ghost Mobile Interactions
|
|
|
|
|
2013-09-18 01:57:40 +04:00
|
|
|
/*global window, document, $, FastClick */
|
2013-08-16 15:44:11 +04:00
|
|
|
|
|
|
|
(function () {
|
2013-09-24 14:46:30 +04:00
|
|
|
'use strict';
|
2013-08-16 15:44:11 +04:00
|
|
|
|
2013-09-18 01:11:13 +04:00
|
|
|
FastClick.attach(document.body);
|
2013-08-16 15:44:11 +04:00
|
|
|
|
|
|
|
// ### Show content preview when swiping left on content list
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.manage').on('click', '.content-list ol li', function (event) {
|
2013-08-16 15:44:11 +04:00
|
|
|
if (window.matchMedia('(max-width: 800px)').matches) {
|
2013-09-18 01:11:13 +04:00
|
|
|
event.preventDefault();
|
2013-08-16 15:44:11 +04:00
|
|
|
event.stopPropagation();
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.content-list').animate({right: '100%', left: '-100%', 'margin-right': '15px'}, 300);
|
|
|
|
$('.content-preview').animate({right: '0', left: '0', 'margin-left': '0'}, 300);
|
2013-08-16 15:44:11 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-09-15 22:47:31 +04:00
|
|
|
// ### Hide content preview
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.manage').on('click', '.content-preview .button-back', function (event) {
|
2013-09-15 22:47:31 +04:00
|
|
|
if (window.matchMedia('(max-width: 800px)').matches) {
|
2013-09-18 01:11:13 +04:00
|
|
|
event.preventDefault();
|
2013-09-15 22:47:31 +04:00
|
|
|
event.stopPropagation();
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.content-list').animate({right: '0', left: '0', 'margin-right': '0'}, 300);
|
|
|
|
$('.content-preview').animate({right: '-100%', left: '100%', 'margin-left': '15px'}, 300);
|
2013-09-15 22:47:31 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-16 15:44:11 +04:00
|
|
|
// ### Show settings options page when swiping left on settings menu link
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.settings').on('click', '.settings-menu li', function (event) {
|
2013-08-16 15:44:11 +04:00
|
|
|
if (window.matchMedia('(max-width: 800px)').matches) {
|
2013-09-18 01:11:13 +04:00
|
|
|
event.preventDefault();
|
2013-08-16 15:44:11 +04:00
|
|
|
event.stopPropagation();
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.settings-sidebar').animate({right: '100%', left: '-102%', 'margin-right': '15px'}, 300);
|
|
|
|
$('.settings-content').animate({right: '0', left: '0', 'margin-left': '0'}, 300);
|
|
|
|
$('.settings-content .button-back, .settings-content .button-save').css('display', 'inline-block');
|
2013-09-15 22:47:31 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// ### Hide settings options page
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.settings').on('click', '.settings-content .button-back', function (event) {
|
2013-09-15 22:47:31 +04:00
|
|
|
if (window.matchMedia('(max-width: 800px)').matches) {
|
2013-09-18 01:11:13 +04:00
|
|
|
event.preventDefault();
|
2013-09-15 22:47:31 +04:00
|
|
|
event.stopPropagation();
|
2013-09-24 14:46:30 +04:00
|
|
|
$('.settings-sidebar').animate({right: '0', left: '0', 'margin-right': '0'}, 300);
|
|
|
|
$('.settings-content').animate({right: '-100%', left: '100%', 'margin-left': '15'}, 300);
|
|
|
|
$('.settings-content .button-back, .settings-content .button-save').css('display', 'none');
|
2013-08-16 15:44:11 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// ### Toggle the sidebar menu
|
2013-09-15 22:47:31 +04:00
|
|
|
$('[data-off-canvas]').on('click', function (event) {
|
2013-08-16 15:44:11 +04:00
|
|
|
if (window.matchMedia('(max-width: 650px)').matches) {
|
2013-09-15 22:47:31 +04:00
|
|
|
event.preventDefault();
|
2013-08-16 15:44:11 +04:00
|
|
|
$('body').toggleClass('off-canvas');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}());
|