0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-12-25 01:53:48 +01:00

Implemented Stay in web app

This commit is contained in:
peteruithoven 2014-02-28 13:56:51 +01:00
parent d13fe57d3a
commit f21734be84
4 changed files with 51 additions and 1 deletions

View File

@ -24,6 +24,7 @@
<script src="js/libs/add2home.js" type="text/javascript"></script> <script src="js/libs/add2home.js" type="text/javascript"></script>
<script src="js/libs/jquery.showpassword.js" type="text/javascript"></script> <script src="js/libs/jquery.showpassword.js" type="text/javascript"></script>
<script src="js/libs/chosen.jquery.min.js" type="text/javascript"></script> <script src="js/libs/chosen.jquery.min.js" type="text/javascript"></script>
<script src="js/libs/jquery.stayInWebApp.js" type="text/javascript"></script>
<script src="js/api/NetworkAPI.js" type="text/javascript"></script> <script src="js/api/NetworkAPI.js" type="text/javascript"></script>
<script src="js/api/ConnectAPI.js" type="text/javascript"></script> <script src="js/api/ConnectAPI.js" type="text/javascript"></script>
<script src="js/NetworkPanel.js" type="text/javascript"></script> <script src="js/NetworkPanel.js" type="text/javascript"></script>

View File

@ -25,8 +25,9 @@ function Box() {
// create box dom element // create box dom element
var link = (boxData.link)? boxData.link : url; var link = (boxData.link)? boxData.link : url;
var linkElement = $("<a href='"+link+"' class='link'>"+_self.wifiboxid+"</a>");
_element = $("<li id='"+_self.localip+"' class='box'></li>"); _element = $("<li id='"+_self.localip+"' class='box'></li>");
_element.append("<a href='"+link+"' class='link'>"+_self.wifiboxid+"</a>"); _element.append(linkElement);
_element.hide().appendTo(parentElement).fadeIn(500); _element.hide().appendTo(parentElement).fadeIn(500);
// create network panel dom element // create network panel dom element

View File

@ -0,0 +1,44 @@
/*!
* jQuery stayInWebApp Plugin
* version: 0.4 (2012-06-19)
*/
;(function($) {
//extend the jQuery object, adding $.stayInWebApp() as a function
$.extend({
stayInWebApp: function(selector,includeAbsolute) {
//detect iOS full screen mode
if(("standalone" in window.navigator) && window.navigator.standalone) {
//if the selector is empty, default to all links
if(!selector) {
selector = 'a';
}
// ignore absolute links by default
if(!includeAbsolute) {
includeAbsolute = false;
}
//bind to the click event of all specified elements
$("body").delegate(selector,"click",function(event) {
//TODO: execute all other events if this element has more bound events
/* NEEDS TESTING
for(i = 0; i < $(this).data('events'); i++) {
console.log($(this).data('events'));
}
*/
//only stay in web app for links that are set to _self (or not set)
if($(this).attr("target") == undefined || $(this).attr("target") == "" || $(this).attr("target") == "_self") {
//get the destination of the link clicked
var dest = $(this).attr("href");
//if the destination is an absolute url, ignore it
if(!dest.match(/^http(s?)/g) || includeAbsolute) {
//prevent default behavior (opening safari)
event.preventDefault();
//update location of the web app
self.location = dest;
}
}
});
}
} //end stayInWebApp func
});
})( jQuery );

View File

@ -62,6 +62,10 @@ $(function() {
spinner.spin($preloader[0]); spinner.spin($preloader[0]);
retrieveList(); retrieveList();
// make sure all links are opened in same WebApp (added to homescreen)
// and they don't start a browser
$.stayInWebApp('a',true);
}); });
function retrieveList() { function retrieveList() {