Created
December 12, 2014 15:05
-
-
Save pierr/41cf363f51a7b81ff44a to your computer and use it in GitHub Desktop.
offline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global window, i18n*/ | |
/** | |
* Enregistre l'évènement de mise à jour de l'application cache. | |
* @return {function} | |
*/ | |
module.exports = { | |
initialize: function() { | |
window.addEventListener("load", (function() { | |
return window.applicationCache.addEventListener("updateready", (function() { | |
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) { | |
window.applicationCache.swapCache(); | |
alert(i18n.t('application.newVersion')); | |
return window.location.reload(); | |
} | |
}), false); | |
}), false); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global window, navigator*/ | |
module.exports = { | |
//By default the property is true. | |
isOnline: function() { | |
return true; | |
} | |
}; | |
/** | |
* Check the application status. | |
* @return {[type]} [description] | |
*/ | |
function checkStatus() { | |
//Publish the online property. | |
Backbone.Mediator.publish(module.exports.isOnline() ? 'connectivity:online' : 'connectivity:offline'); | |
} | |
module.exports.checkStatus = checkStatus; | |
if ('onLine' in navigator) { | |
$(window).on('online offline', checkStatus); | |
checkStatus(); | |
module.exports.isOnline = function() { | |
return navigator.onLine === true; | |
}; //On publie la ppte si elle existe. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
/** | |
* Initialize l'ecouteur d'évènement pour la couleur de l'icone de connexion au réseau. | |
* @return {function} | |
*/ | |
initialize: function() { | |
var signalIconSelector = 'header i.fa-signal'; | |
Backbone.Mediator.subscribe('connectivity:online', (function() { | |
return $(signalIconSelector).css({ | |
color: 'white' | |
}); | |
}), this); | |
Backbone.Mediator.subscribe('connectivity:offline', (function() { | |
return $(signalIconSelector).css({ | |
color: 'red' | |
}); | |
}), this); | |
require('../../helper/connectivity').checkStatus(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment