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
|
|
|
|
2014-02-19 23:55:30 +04:00
|
|
|
// ### general wrapper to handle conditional screen size actions
|
|
|
|
function responsiveAction(event, mediaCondition, cb) {
|
|
|
|
if (!window.matchMedia(mediaCondition).matches) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
cb();
|
|
|
|
}
|
|
|
|
|
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) {
|
2014-02-19 23:55:30 +04:00
|
|
|
responsiveAction(event, '(max-width: 800px)', function () {
|
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);
|
2014-02-19 23:55:30 +04:00
|
|
|
});
|
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) {
|
2014-02-19 23:55:30 +04:00
|
|
|
responsiveAction(event, '(max-width: 800px)', function () {
|
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);
|
2014-02-19 23:55:30 +04:00
|
|
|
});
|
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) {
|
2014-02-19 23:55:30 +04:00
|
|
|
responsiveAction(event, '(max-width: 800px)', function () {
|
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');
|
2014-02-19 23:55:30 +04:00
|
|
|
});
|
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) {
|
2014-02-19 23:55:30 +04:00
|
|
|
responsiveAction(event, '(max-width: 800px)', function () {
|
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');
|
2014-02-19 23:55:30 +04:00
|
|
|
});
|
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) {
|
2014-02-19 23:55:30 +04:00
|
|
|
responsiveAction(event, '(max-width: 650px)', function () {
|
2013-08-16 15:44:11 +04:00
|
|
|
$('body').toggleClass('off-canvas');
|
2014-02-19 23:55:30 +04:00
|
|
|
});
|
2013-08-16 15:44:11 +04:00
|
|
|
});
|
|
|
|
|
2014-02-19 23:55:30 +04:00
|
|
|
}());
|