@@ -19,6 +19,7 @@ Cu.import("resource://gre/modules/AddonManager.jsm");
19
19
function LOG ( m ) ( m = addon . name + ' Message @ '
20
20
+ ( new Date ( ) ) . toISOString ( ) + "\n> " + m ,
21
21
dump ( m + "\n" ) , Services . console . logStringMessage ( m ) ) ;
22
+ function rsc ( n ) 'resource://' + addon . tag + '/' + n ;
22
23
23
24
let i$ = {
24
25
onOpenWindow : function ( aWindow ) {
@@ -36,6 +37,22 @@ let i$ = {
36
37
onWindowTitleChange : function ( ) { }
37
38
} ;
38
39
40
+ let showAlertNotification = Cc [ "@mozilla.org/alerts-service;1" ] . getService ( Ci . nsIAlertsService ) ;
41
+ showAlertNotification = showAlertNotification . showAlertNotification . bind ( showAlertNotification ) ;
42
+
43
+ function iNotify ( aMsg , callback ) {
44
+ let nme = addon . branch . getIntPref ( 'nme' ) ;
45
+
46
+ if ( nme == 2 ) {
47
+ showAlertNotification ( rsc ( "icon.png" ) , addon . name , aMsg , ! 1 , "" ,
48
+ ( s , t ) => t == "alertshow" || callback ( t ) ) ;
49
+ } else {
50
+ if ( nme ) Services . prompt . alert ( null , addon . name , aMsg ) ;
51
+
52
+ callback ( ) ;
53
+ }
54
+ }
55
+
39
56
function onClickHanlder ( ev ) {
40
57
ev . preventDefault ( ) ;
41
58
@@ -50,7 +67,7 @@ function onClickHanlder(ev) {
50
67
let d = this . ownerDocument ,
51
68
l = this . lastChild ,
52
69
f = this . firstChild ;
53
- l . textContent = 'Installing...' ;
70
+ l . textContent = ' Installing...' ;
54
71
f . className = f . className . replace ( 'plus' , 'hourglass' ) ;
55
72
d . body . appendChild ( d . createElement ( 'style' ) ) . textContent = '@keyframes '
56
73
+ addon . tag + '{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}' ;
@@ -118,8 +135,7 @@ function onClickHanlder(ev) {
118
135
}
119
136
f . style . animation = null ;
120
137
f . className = f . className . replace ( 'hourglass' , c ) ;
121
- Services . prompt . alert ( null , addon . name , aMsg ) ;
122
- oFile . remove ( ! 1 ) ;
138
+ iNotify ( aMsg , ( ) => oFile . remove ( ! 1 ) ) ;
123
139
} ;
124
140
125
141
aInstall . addListener ( {
@@ -315,9 +331,18 @@ function startup(data) {
315
331
} ;
316
332
addon . branch = Services . prefs . getBranch ( 'extensions.' + addon . tag + '.' ) ;
317
333
334
+ let io = Services . io ;
335
+ io . getProtocolHandler ( "resource" )
336
+ . QueryInterface ( Ci . nsIResProtocolHandler )
337
+ . setSubstitution ( addon . tag ,
338
+ io . newURI ( __SCRIPT_URI_SPEC__ + '/../' , null , null ) ) ;
339
+
318
340
i$ . wmf ( loadIntoWindowStub ) ;
319
341
Services . wm . addListener ( i$ ) ;
320
342
343
+ if ( ! addon . branch . getPrefType ( 'nme' ) ) {
344
+ addon . branch . setIntPref ( 'nme' , 2 ) ;
345
+ }
321
346
addon . branch . setCharPref ( 'version' , addon . version ) ;
322
347
} ) ;
323
348
}
@@ -328,6 +353,10 @@ function shutdown(data, reason) {
328
353
329
354
Services . wm . removeListener ( i$ ) ;
330
355
i$ . wmf ( unloadFromWindow ) ;
356
+
357
+ Services . io . getProtocolHandler ( "resource" )
358
+ . QueryInterface ( Ci . nsIResProtocolHandler )
359
+ . setSubstitution ( addon . tag , null ) ;
331
360
}
332
361
333
362
function install ( data , reason ) { }
0 commit comments