Skip to content

Commit

Permalink
Bug: links leaving full screen mobile mode
Browse files Browse the repository at this point in the history
Fixes #50
  • Loading branch information
satrun77 committed Apr 22, 2016
1 parent 0b88af7 commit feb8d38
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
41 changes: 32 additions & 9 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ $(function () {
globalNotice.slideUp();
}, 15000);

globalNotice.on('click', function () {
globalNotice.addClass('has-event').on('click', function () {
globalNotice.slideUp();
});
}

// Confirm links
$('.close-issue, .delete-project, #users-list .delete').on('click', function () {
$('.close-issue, .delete-project, #users-list .delete').addClass('has-event').on('click', function () {
return ConfirmDialog.show($(this), function () {
return true;
});
Expand Down Expand Up @@ -83,7 +83,7 @@ $(function () {
}

// Clickable elements
$('.vlink').on('click', function (e) {
$('.vlink').addClass('has-event').on('click', function (e) {
e.preventDefault();
return window.location = $(this).data('url');
});
Expand All @@ -93,8 +93,31 @@ $(function () {

// Kanban board
Kanban().init();

// Stop links from leaving full screen mode on iOS devices.
StayInWebApp();
});

function StayInWebApp() {
//detect iOS full screen mode
if (("standalone" in window.navigator) && window.navigator.standalone) {
//bind to the click event of all specified elements
$("body").delegate('a', "click", function (event) {
//only stay in web app for links that are set to _self (or not set)
if (!$(this).hasClass('has-event')
&& ($(this).attr("target") == undefined || $(this).attr("target") == "" || $(this).attr("target") == "_self")) {
//get the destination of the link clicked
var dest = $(this).attr("href");

//prevent default behavior (opening safari)
event.preventDefault();
//update location of the web app
window.location = dest;
}
});
}
}

var GlobalSaving = {
status: false,
_saving: null,
Expand Down Expand Up @@ -201,7 +224,7 @@ var Autocomplete = {
source: this.suggestions,
select: $.proxy(function (event, ui) {
var append = $($.proxy(this.options.template, this, ui)());
append.find('.delete').on('click', $.proxy(function (e) {
append.find('.delete').addClass('has-event').on('click', $.proxy(function (e) {
e.preventDefault();
if ($.proxy(this.options.onRemove, this, append, ui.item.id)()) {
this.remove(append, ui.item.id);
Expand Down Expand Up @@ -251,7 +274,7 @@ var Selection = {
init: function (options) {
var me = this;
this.options = $.extend(this.options, options);
this.options.items.on({
this.options.items.addClass('has-event').on({
mouseenter: function () {
return me.showHighlight($(this).css('cursor', 'pointer'));
},
Expand Down Expand Up @@ -316,19 +339,19 @@ function Discussion() {
if (instance.length == 0) {
return this;
}
instance.find('li .edit').on('click', $.proxy(function (e) {
instance.find('li .edit').addClass('has-event').on('click', $.proxy(function (e) {
e.preventDefault();
return this.edit($(e.currentTarget));
}, this));
instance.find('li .delete').on('click', $.proxy(function (e) {
instance.find('li .delete').addClass('has-event').on('click', $.proxy(function (e) {
e.preventDefault();
return this.remove($(e.currentTarget));
}, this));
instance.find('li .save').on('click', $.proxy(function (e) {
instance.find('li .save').addClass('has-event').on('click', $.proxy(function (e) {
e.preventDefault();
return this.save($(e.currentTarget));
}, this));
instance.find('li .cancel').on('click', $.proxy(function (e) {
instance.find('li .cancel').addClass('has-event').on('click', $.proxy(function (e) {
e.preventDefault();
return this.cancel($(e.currentTarget));
}, this));
Expand Down
8 changes: 4 additions & 4 deletions resources/js/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $(function () {
'use strict';

// Radio button selection
$('.radio-btn .btn').on('click', function () {
$('.radio-btn .btn').addClass('has-event').on('click', function () {
$(this).siblings().each(function() {
var btn = $(this), color = btn.find('input').data('color');
btn.removeClass('active').css({
Expand Down Expand Up @@ -32,7 +32,7 @@ $(function () {
});

// Left column assign users
$('.delete-from-project').on('click', function (e) {
$('.delete-from-project').addClass('has-event').on('click', function (e) {
e.preventDefault();
var user_id = $(this).data('user-id');
ConfirmDialog.show($(this), function (el) {
Expand Down Expand Up @@ -79,7 +79,7 @@ $(function () {
});

// Issue assign user
$('.assign-user').on('click', function (e) {
$('.assign-user').addClass('has-event').on('click', function (e) {
e.preventDefault();
var issue = $(this).data('issue-id');
var user = $(this).data('assign-id');
Expand All @@ -97,7 +97,7 @@ $(function () {
});

// Change issue project
$('.change-project').on('click', function (e) {
$('.change-project').addClass('has-event').on('click', function (e) {
e.preventDefault();
var issue = $(this).data('issue-id');
var project = $(this).data('project-id');
Expand Down

0 comments on commit feb8d38

Please sign in to comment.