update library

This commit is contained in:
Piro / SHIMODA Hiroshi 2012-02-08 03:23:10 +09:00
parent 771d997464
commit a00e0bcb0d

View File

@ -1,7 +1,7 @@
/**
* @fileOverview Popup Notification (Door Hanger) Based Confirmation Library for Firefox 4.0 or later
* @author SHIMODA "Piro" Hiroshi
* @version 3
* @version 4
* Basic usage:
*
* @example
@ -91,7 +91,7 @@ catch(e) {
var confirmWithPopup;
(function() {
const currentRevision = 3;
const currentRevision = 4;
var loadedRevision = 'confirmWithPopup' in namespace ?
namespace.confirmWithPopup.revision :
@ -214,11 +214,16 @@ var confirmWithPopup;
var accessKeys = [];
var numericAccessKey = 0;
var buttons = options.buttons.map(function(aLabel, aIndex) {
// see resource://gre/modules/CommonDialog.jsm
var accessKey;
var match = aLabel.match(/\s*\(&([0-9a-z])\)/i);
if (match) {
accessKey = match[1];
aLabel = aLabel.replace(match[0], '');
var match;
if (match = aLabel.match(/^\s*(.*?)\s*\(\&([^&])\)(:)?$/)) {
aLabel = (match[1] + (match[3] || '')).replace(/\&\&/g, '&');
accessKey = match[2];
}
else if (match = aLabel.match(/^\s*(.*[^&])?\&(([^&]).*$)/)) {
aLabel = (match[1] + match[2]).replace(/\&\&/g, '&');
accessKey = match[3];
}
else {
let lastUniqueKey;
@ -226,15 +231,8 @@ var confirmWithPopup;
for (let i = 0, maxi = aLabel.length; i < maxi; i++)
{
let possibleAccessKey = aLabel.charAt(i);
if (possibleAccessKey == '&' && i < maxi-1) {
possibleAccessKey = aLabel.charAt(i+1);
if (possibleAccessKey != '&') {
accessKey = possibleAccessKey;
}
i++;
}
else if (!lastUniqueKey &&
accessKeys.indexOf(possibleAccessKey) < 0) {
if (!lastUniqueKey &&
accessKeys.indexOf(possibleAccessKey) < 0) {
lastUniqueKey = possibleAccessKey;
}
sanitizedLabel.push(possibleAccessKey);
@ -244,7 +242,7 @@ var confirmWithPopup;
if (!accessKey || !/[0-9a-z]/i.test(accessKey))
accessKey = ++numericAccessKey;
aLabel = sanitizedLabel.join('');
aLabel = sanitizedLabel.join('').replace(/\&\&/g, '&');
}
accessKeys.push(accessKey);