[Pkg-mozext-commits] [itsalltext] 271/459: Fading buttons.
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository itsalltext.
commit 367acbf0db6c0ebe3f8deb74d0d372bce4cdafb1
Author: docwhat at gerf.org <docwhat at gerf.org>
Date: Mon Oct 1 13:18:29 2007 -0400
Fading buttons.
---
src/chrome/content/cacheobj.js | 45 +++++++++++++++++++++++++++++----
src/chrome/content/itsalltext.js | 14 ++++++++--
src/chrome/content/preferences.xul | 22 +++++++++++-----
src/chrome/locale/en-US/preferences.dtd | 1 +
src/defaults/preferences/itsalltext.js | 1 +
5 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index df6d38d..b12e501 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -39,6 +39,8 @@ function CacheObj(node) {
that.button = null;
that.initial_background = '';
that.private_is_watching = false;
+ that.button_fade_timer = null;
+ that.is_focused = false;
that.node_id = that.getNodeIdentifier(node);
var doc = node.ownerDocument;
@@ -95,9 +97,16 @@ function CacheObj(node) {
* @param {Event} event The event object.
*/
that.mouseover = function(event) {
+ if (event.type === 'focus') {
+ that.is_focused = true;
+ }
+ if (that.button_fade_timer) {
+ clearTimeout(that.button_fade_timer);
+ }
var style = that.button?that.button.style:null;
if (style) {
- style.setProperty('opacity', '0.7', 'important');
+ style.setProperty('opacity', '0.7', 'important');
+ style.setProperty('display', 'block', 'important');
}
ItsAllText.refreshTextarea(that.node);
};
@@ -108,9 +117,33 @@ function CacheObj(node) {
* @param {Event} event The event object.
*/
that.mouseout = function(event) {
- var style = that.button?that.button.style:null;
+ if (that.button_fade_timer) {
+ clearTimeout(that.button_fade_timer);
+ }
+ if (that.is_focused && event.type !== 'blur') {
+ /* we're focused, don't fade until we're blurred. */
+ return;
+ }
+ that.is_focused = false;
+
+ var style = that.button?that.button.style:null, f;
+ var cur = 0.7;
+ var dest = 0;
+ var fps = 12;
+ var num_frames = (ItsAllText.preferences.fade_time * fps);
+ var increment = (cur - dest) / num_frames;
+ var wait = (1 / fps) / 1000;
if (style) {
- style.setProperty('opacity', '0.1', 'important');
+ f = function () {
+ cur -= increment;
+ if (cur > dest) {
+ style.setProperty('opacity', cur, 'important');
+ that.button_fade_timer = setTimeout(f, wait);
+ } else {
+ style.setProperty('display', 'none', 'important');
+ }
+ };
+ f();
}
};
}
@@ -511,6 +544,8 @@ CacheObj.prototype.addGumDrop = function() {
var node = cache_object.node;
node.addEventListener( "mouseover", cache_object.mouseover, false);
node.addEventListener( "mouseout", cache_object.mouseout, false);
+ node.addEventListener( "focus", cache_object.mouseover, false);
+ node.addEventListener( "blur", cache_object.mouseout, false);
if (ItsAllText.getDisableGumdrops()) {
return;
}
@@ -531,7 +566,7 @@ CacheObj.prototype.addGumDrop = function() {
// Image Attributes
gumdrop.style.setProperty('cursor', 'pointer', 'important');
- gumdrop.style.setProperty('display', 'block', 'important');
+ gumdrop.style.setProperty('display', 'none', 'important');
gumdrop.style.setProperty('position', 'absolute', 'important');
gumdrop.style.setProperty('padding', '0', 'important');
gumdrop.style.setProperty('margin', '0', 'important');
@@ -591,7 +626,7 @@ CacheObj.prototype.adjust = function() {
) {
display = 'none';
}
- if (style.display != display) {
+ if (display === 'none' && style.display != display) {
style.setProperty('display', display, 'important');
}
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index f60e35d..9ecb68e 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -200,7 +200,11 @@ var ItsAllText = function() {
*/
private_get: function(aData) {
var po = that.preference_observer;
- return po.private_branch['get'+(po.types[aData])+'Pref'](aData);
+ var real_type = po.types[aData];
+ var type = real_type === 'Float' ? 'Char' : real_type;
+ var retval = '';
+ retval = po.private_branch['get' + type + 'Pref'](aData);
+ return real_type === 'Float' ? parseFloat(retval) : retval;
},
/**
@@ -210,7 +214,12 @@ var ItsAllText = function() {
*/
private_set: function(aData, value) {
var po = that.preference_observer;
- return po.private_branch['set'+(po.types[aData])+'Pref'](aData, value);
+ var real_type = po.types[aData];
+ var type = real_type === 'Float' ? 'Char' : real_type;
+ if (real_type === 'Float') {
+ value = '' + parseFloat(value);
+ }
+ po.private_branch['set'+type+'Pref'](aData);
}
};
@@ -229,6 +238,7 @@ var ItsAllText = function() {
refresh: 'Int',
debug: 'Bool',
gumdrop_position: 'Char',
+ fade_time: 'Float',
extensions: 'Char'
},
diff --git a/src/chrome/content/preferences.xul b/src/chrome/content/preferences.xul
index 8a89b44..c31ee09 100644
--- a/src/chrome/content/preferences.xul
+++ b/src/chrome/content/preferences.xul
@@ -29,6 +29,8 @@
name="extensions.itsalltext.extensions" type="string"/>
<preference id="pref_gumdrop_position"
name="extensions.itsalltext.gumdrop_position" type="string"/>
+ <preference id="pref_fade_time"
+ name="extensions.itsalltext.fade_time" type="string"/>
<preference id="pref_debug"
name="extensions.itsalltext.debug" type="bool"/>
</preferences>
@@ -79,21 +81,29 @@
<radiogroup id="gumpdrop_pos" preference="pref_gumdrop_position">
<vbox>
<hbox>
- <radio value="upper-left" label="&gumdrop_position.upper_left;"/>
- <radio value="upper-right" label="&gumdrop_position.upper_right;"/>
+ <radio value="upper-left" label="&gumdrop_position.upper_left;" tabindex="5"/>
+ <radio value="upper-right" label="&gumdrop_position.upper_right;" tabindex="6"/>
</hbox>
<hbox>
- <radio value="lower-left" label="&gumdrop_position.lower_left;"/>
- <radio value="lower-right" label="&gumdrop_position.lower_right;"/>
+ <radio value="lower-left" label="&gumdrop_position.lower_left;" tabindex="7"/>
+ <radio value="lower-right" label="&gumdrop_position.lower_right;" tabindex="8"/>
</hbox>
</vbox>
- <radio value="none" label="&gumdrop_position.disable;"/>
+ <radio value="none" label="&gumdrop_position.disable;" tabindex="9"/>
</radiogroup>
</row>
<row align="center">
+ <label control="fade_time" value="&fade_time.label;" tabindex="10"/>
+ <hbox>
+ <textbox preference="pref_fade_time" id="fade_time" size="3"
+ maxlength="3" tabindex="11"/>
+ <spacer/>
+ </hbox>
+ </row>
+ <row align="center">
<label control="debug"
value="&debug.label;"/>
- <checkbox preference="pref_debug" id="debug" tabindex="5"
+ <checkbox preference="pref_debug" id="debug" tabindex="12"
label="&debug.humor;"/>
</row>
</rows>
diff --git a/src/chrome/locale/en-US/preferences.dtd b/src/chrome/locale/en-US/preferences.dtd
index e4e4aa9..5f7ad2a 100644
--- a/src/chrome/locale/en-US/preferences.dtd
+++ b/src/chrome/locale/en-US/preferences.dtd
@@ -12,3 +12,4 @@
<!ENTITY gumdrop_position.upper_right "Upper Right">
<!ENTITY gumdrop_position.lower_left "Lower Left">
<!ENTITY gumdrop_position.lower_right "Lower Right">
+<!ENTITY fade_time.label "Duration of button fade">
diff --git a/src/defaults/preferences/itsalltext.js b/src/defaults/preferences/itsalltext.js
index e14fe23..c8e6168 100644
--- a/src/defaults/preferences/itsalltext.js
+++ b/src/defaults/preferences/itsalltext.js
@@ -1,6 +1,7 @@
pref("extensions.itsalltext.charset", "UTF-8");
pref("extensions.itsalltext.editor", "");
pref("extensions.itsalltext.refresh", 3);
+pref("extensions.itsalltext.fade_time", '2.3');
pref("extensions.itsalltext.debug", false);
pref("extensions.itsalltext.gumdrop_position", 'lower-right');
pref("extensions.itsalltext.extensions", '.txt,.html,.css,.xml,.xsl,.js');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git
More information about the Pkg-mozext-commits
mailing list