Changeset 718


Ignore:
Timestamp:
Jan 29, 2015 6:01:14 PM (10 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/assets/js/frontend/lecture.js

    r717 r718  
    128128
    129129function DoCloseLecture () {
    130         g_Flash.SetVariable("command", "Quit App");
     130        g_Flash.SetVariable("command", "Quit App");             
     131}
     132
     133function getLectureState () {
     134        var state = g_Flash.GetVariable("dataChanged");
     135        return state == 'true' ? true: (state == 'false' ? false:false);
    131136}
    132137
     
    176181        var inFormOrLink = false;
    177182
    178         /*$( window ).bind('beforeunload',function(e) {
    179                 console.log('unload');
    180                 e.preventDefault();
    181         });*/
     183        $(window).on('beforeunload', function() {
     184                var e = $.Event('webapp:page:closing');
     185                $(window).trigger(e); // let other modules determine whether to prevent closing
     186                if(e.isDefaultPrevented()) {
     187                        return e.message;
     188                }
     189        });
     190
     191        $(window).on('webapp:page:closing', function(e) {
     192                if(getLectureState()) {
     193                        e.preventDefault();
     194                        e.message = 'Bạn đang soạn bài giảng và chưa lưu dữ liệu. Bạn có muốn chuyển khỏi ứng dụng khÃŽng?';
     195                }
     196        });
     197
    182198})
Note: See TracChangeset for help on using the changeset viewer.