4 if (typeof define ===
'function' && define.amd) {
6 define(
'pnotify.nonblock', [
'jquery',
'pnotify'], factory);
9 factory(jQuery, PNotify);
11 }(
function($, PNotify){
14 re_mouse_events = /^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/,
15 re_ui_events = /^(focus|blur|select|change|reset)$|^key(press|down|up)$/,
16 re_html_events = /^(scroll|resize|(un)?load|abort|error)$/;
18 var dom_event =
function(e, orig_e){
21 if (document.createEvent &&
this.dispatchEvent) {
23 e = e.replace(re_on,
'');
24 if (e.match(re_mouse_events)) {
28 event_object = document.createEvent(
"MouseEvents");
29 event_object.initMouseEvent(
30 e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail,
31 orig_e.screenX, orig_e.screenY, orig_e.clientX, orig_e.clientY,
32 orig_e.ctrlKey, orig_e.altKey, orig_e.shiftKey, orig_e.metaKey, orig_e.button, orig_e.relatedTarget
34 }
else if (e.match(re_ui_events)) {
35 event_object = document.createEvent(
"UIEvents");
36 event_object.initUIEvent(e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail);
37 }
else if (e.match(re_html_events)) {
38 event_object = document.createEvent(
"HTMLEvents");
39 event_object.initEvent(e, orig_e.bubbles, orig_e.cancelable);
41 if (!event_object)
return;
42 this.dispatchEvent(event_object);
45 if (!e.match(re_on)) e =
"on"+e;
46 event_object = document.createEventObject(orig_e);
47 this.fireEvent(e, event_object);
54 var nonblock_last_elem;
56 var nonblock_pass =
function(notice, e, e_name){
57 notice.elem.css(
"display",
"none");
58 var element_below = document.elementFromPoint(e.clientX, e.clientY);
59 notice.elem.css(
"display",
"block");
60 var jelement_below = $(element_below);
61 var cursor_style = jelement_below.css(
"cursor");
62 notice.elem.css(
"cursor", cursor_style !==
"auto" ? cursor_style :
"default");
64 if (!nonblock_last_elem || nonblock_last_elem.get(0) != element_below) {
65 if (nonblock_last_elem) {
66 dom_event.call(nonblock_last_elem.get(0),
"mouseleave", e.originalEvent);
67 dom_event.call(nonblock_last_elem.get(0),
"mouseout", e.originalEvent);
69 dom_event.call(element_below,
"mouseenter", e.originalEvent);
70 dom_event.call(element_below,
"mouseover", e.originalEvent);
72 dom_event.call(element_below, e_name, e.originalEvent);
74 nonblock_last_elem = jelement_below;
78 PNotify.prototype.options.nonblock = {
84 PNotify.prototype.modules.nonblock = {
88 init:
function(notice, options){
90 this.myOptions = options;
92 "mouseenter":
function(e){
93 if (that.myOptions.nonblock) e.stopPropagation();
94 if (that.myOptions.nonblock) {
96 notice.elem.stop().animate({
"opacity": that.myOptions.nonblock_opacity},
"fast");
99 "mouseleave":
function(e){
100 if (that.myOptions.nonblock) e.stopPropagation();
101 nonblock_last_elem = null;
102 notice.elem.css(
"cursor",
"auto");
104 if (that.myOptions.nonblock && notice.animating !==
"out")
105 notice.elem.stop().animate({
"opacity": notice.options.opacity},
"fast");
107 "mouseover":
function(e){
108 if (that.myOptions.nonblock) e.stopPropagation();
110 "mouseout":
function(e){
111 if (that.myOptions.nonblock) e.stopPropagation();
113 "mousemove":
function(e){
114 if (that.myOptions.nonblock) {
116 nonblock_pass(notice, e,
"onmousemove");
119 "mousedown":
function(e){
120 if (that.myOptions.nonblock) {
123 nonblock_pass(notice, e,
"onmousedown");
126 "mouseup":
function(e){
127 if (that.myOptions.nonblock) {
130 nonblock_pass(notice, e,
"onmouseup");
133 "click":
function(e){
134 if (that.myOptions.nonblock) {
136 nonblock_pass(notice, e,
"onclick");
139 "dblclick":
function(e){
140 if (that.myOptions.nonblock) {
142 nonblock_pass(notice, e,
"ondblclick");
147 update:
function(notice, options){
148 this.myOptions = options;