Полезная информация

Многие проблемы быстрее решаются поиском по форуму и чтением FAQ, чем созданием новой темы и томительным ожиданием ответа.

№465126-08-2012 01:38:45

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Kamui пишет

2. Открытие окна загрузок;

Выделить код

Код:

BrowserDownloadsUI();

Добавлено 26-08-2012 01:41:20

Kamui пишет

Осталась одна проблема, например когда я открываю окно загрузок, я не могу его закрыть жестом которым я закрываю вкладку (вниз-вправо), это видимо потому что выполняется не сочетание клавиш Ctrl+W, а именно функция закрытия вкладки. Вот здесь я точно сам не справлюсь, нужна помощь.

Я не понял.

Отредактировано bunda1 (26-08-2012 01:41:20)

Отсутствует

 

№465226-08-2012 01:46:48

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

bunda1 пишет

Я не понял.

Ну то есть раньше у меня был жест который выполнял нажатие Ctrl+w, что позволяло закрывать не только вкладки, но и окно загрузок или "Библиотеку" закладок. Самый простой вариант наверно, сделать жест выполняющий Ctrl+w, а не как сейчас gBrowser.removeCurrentTab();. Можно так сделать?

Отсутствует

 

№465326-08-2012 01:49:20

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Kод закрывающей все остальные окна кроме текущего

Выделить код

Код:

var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
var enumerator = windowManager.getEnumerator(null);
var thisWindow = windowManager.getMostRecentWindow(null);
while (enumerator.hasMoreElements()) {var thatWindow = enumerator.getNext(); if (thisWindow != thatWindow) {thatWindow.close();}}

Отсутствует

 

№465426-08-2012 01:51:40

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

bunda1 пишет

Kод закрывающей все остальные окна кроме текущего

Наверно это не подходит :( а есть код который просто отправляет сочетание клавиш Ctrl+w?

Отсутствует

 

№465526-08-2012 01:59:21

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Kamui пишет

Наверно это не подходит :( а есть код который просто отправляет сочетание клавиш Ctrl+w?

Ctrl+w - Закрыть вкладку :(

Отсутствует

 

№465626-08-2012 02:04:04

LongLogin
Участник
 
Группа: Members
Зарегистрирован: 30-01-2011
Сообщений: 2083
UA: Firefox 14.0

Re: Custom Buttons

Kamui пишет

bunda1 пишет:
Kод закрывающей все остальные окна кроме текущего

Наверно это не подходит

у меня подошло

Добавлено 26-08-2012 02:05:05
на FireGestures

Отредактировано LongLogin (26-08-2012 02:05:05)

Отсутствует

 

№465726-08-2012 02:05:24

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

bunda1 пишет

Ctrl+w - Закрыть вкладку :(

Беда в том что я использую этот жест не только для закрытия вкладки :/ Ну да ладно, пока это не так важно. Тут возникала еще проблемка, иногда не получается вызвать конекстное меню, потому что из-за малейшего движения начинают "рисоваться жесты", может можно как-то сделать чтобы жест "рисовался" после какой-то задержки или после того как указатель пройдет какое-то минимальное расстояние?

Сейчас у меня такой код:

Выделить код

Код:

// Mouse Gestures................................ 
var ucjsMouseGestures={


// options
enableWheelGestures: true,
enableRockerGestures: true,
enablePopupGestures: true,


_lastX: 0,
_lastY: 0,
_directionChain: '',
_isMouseDownL: false,
_isMouseDownR: false,
_hideFireContext: false, //for windows
_shouldFireContext: false, //for linux

POPUP_ID: 'GesturePopup',
GESTURES:{
      'L':{name:'History Back',cmd:function(){document.getElementById("Browser:Back").doCommand();}},
      'R':{name:'History Forward',cmd:function(){document.getElementById("Browser:Forward").doCommand();}},
      'UD':{name:'Reload',cmd:function(){document.getElementById("Browser:Reload").doCommand();}},
      'U':{name:'Stop',cmd:function(){document.getElementById("Browser:Stop").doCommand();}},
      'UDU':{name:'Reload Skip Cache',cmd:function(){document.getElementById("Browser:ReloadSkipCache").doCommand();}},
      'DR':{name:'Close Tab',cmd:function(){gBrowser.removeCurrentTab();}},
      'DL':{name:'Undo Tab',cmd:function(){document.getElementById('History:UndoCloseTab').doCommand();}},
      'D':{name:'Open New Tab',cmd:function(){document.getElementById("cmd_newNavigatorTab").doCommand();document.getElementById("searchbar").focus();goDoCommand('cmd_selectAll');}},
      'W-':{name:'Previous Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(-1,true);}},
      'W+':{name:'Next Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(+1,true);}},
      'LR':{name:'Open Panorama',cmd:function(){document.getElementById("Browser:ToggleTabView").doCommand();}},
      'RL':{name:'Open Downloads',cmd:function(){BrowserDownloadsUI();}},
      'DU':{name:'Open Addons',cmd:function(){BrowserOpenAddonsMgr();}},
},

init:function(){
    var self=this;
    var events=["mousedown","mousemove","mouseup","contextmenu"];
    if(this.enableRockerGestures)events.push("draggesture");
    if(this.enableWheelGestures)events.push("DOMMouseScroll");
    function registerEvents(aAction,eventArray){
        eventArray.forEach(function(aType){
                getBrowser().mPanelContainer[aAction+"EventListener"](aType,self,aType=="contextmenu");
        });
    };
    registerEvents("add",events);
    window.addEventListener("unload",function(){
            registerEvents("remove",events);
        },false);
},

handleEvent:function(event){
    switch(event.type){
        case"mousedown":
            if(event.button==2){
                this._isMouseDownR=true;
                this._hideFireContext=false;
                this._startGesture(event);
            }
            if(this.enableRockerGestures){
                if(event.button==2&&this._isMouseDownL){
                    this._isMouseDownR=false;
                    this._shouldFireContext=false;
                    this._hideFireContext=true;
                    this._directionChain="L>R";
                    this._stopGesture(event);
                }else if(event.button==0){
                    this._isMouseDownL=true;
                    if(this._isMouseDownR){
                        this._isMouseDownL=false;
                        this._shouldFireContext=false;
                        this._hideFireContext=true;
                        this._directionChain="L<R";
                        this._stopGesture(event);
                    }
                }
            }
            break;
        case"mousemove":
            if(this._isMouseDownR){
                this._hideFireContext=true;
                this._progressGesture(event);
            }
            break;
        case"mouseup":
            if(event.ctrlKey&&event.button==2){
                this._isMouseDownL=false;
                this._isMouseDownR=false;
                this._shouldFireContext=false;
                this._hideFireContext=false;
                this._directionChain='';
                event.preventDefault();
                XULBrowserWindow.statusTextField.label="Reset Gesture";
                break;
            }
            if(this._isMouseDownR&&event.button==2){
                if(this._directionChain)this._shouldFireContext=false;
                this._isMouseDownR=false;
                this._stopGesture(event);
                if(this._shouldFireContext&&!this._hideFireContext){
                    this._shouldFireContext=false;
                    this._displayContextMenu(event);
                }
            }else if(this.enableRockerGestures&&event.button==0&&this._isMouseDownL){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
            }else if(this.enablePopupGestures&&(event.button==0||event.button==1)&&event.target.localName=='menuitem'){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
                var popup=document.getElementById(this.POPUP_ID);
                var activeItem=event.target;
                switch(popup.getAttribute("gesturecommand")){
                    case"WebSearchPopup":
                        var selText=popup.getAttribute("selectedtext");
                        var engine=activeItem.engine;
                        if(!engine)break;
                        var submission=engine.getSubmission(selText,null);
                        if(!submission)break;
                        document.getElementById('searchbar').textbox.value=selText;
                        gBrowser.loadOneTab(submission.uri.spec,null,null,submission.postData,null,false);
                        break;
                    case"ClosedTabsPopup":
                        undoCloseTab(activeItem.index);
                        break;
                    case"HistoryPopup":
                        gBrowser.webNavigation.gotoIndex(activeItem.index);
                        break;
                    case"AllTabsPopup":
                        gBrowser.selectedTab=gBrowser.mTabs[activeItem.index];
                        break;
                }
                popup.hidePopup();
            }
            break;
    case"popuphiding":
        var popup=document.getElementById(this.POPUP_ID);
        popup.removeEventListener("popuphiding",this,true);
        document.documentElement.removeEventListener("mouseup",this,true);
        while(popup.hasChildNodes())popup.removeChild(popup.lastChild);
        break;
    case"contextmenu":
        if(this._isMouseDownL||this._isMouseDownR||this._hideFireContext){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=true;
            this._hideFireContext=false;
        }
        break;
    case"DOMMouseScroll":
        if(this.enableWheelGestures&&this._isMouseDownR){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=false;
            this._hideFireContext=true;
            this._directionChain="W"+(event.detail>0?"+":"-");
            this._stopGesture(event);
        }
        break;
    case"draggesture":
        this._isMouseDownL=false;
        break;
    }
},

_displayContextMenu:function(event){
    var evt=event.originalTarget.ownerDocument.createEvent("MouseEvents");
    evt.initMouseEvent("contextmenu",true,true,event.originalTarget.defaultView,0,event.screenX,event.screenY,event.clientX,event.clientY,false,false,false,false,2,null);
    event.originalTarget.dispatchEvent(evt);
},

_startGesture:function(event){
    this._lastX=event.screenX;
    this._lastY=event.screenY;
    this._directionChain="";
},

_progressGesture:function(event){
    var x=event.screenX, y=event.screenY;
    var lastX=this._lastX, lastY=this._lastY;
    var subX=x-lastX, subY=y-lastY;
    var distX=(subX>0?subX:(-subX)),distY=(subY>0?subY:(-subY));
    var direction;
    if(distX<10&&distY<10)return;
    if(distX>distY)direction=subX<0?"L":"R";
    else direction=subY<0?"U":"D";
    var dChain = this._directionChain;
    if(direction!=dChain.charAt(dChain.length-1)){
        dChain+=direction;
        this._directionChain+=direction;
        var gesture=this.GESTURES[dChain];
        XULBrowserWindow.statusTextField.label="Gesture: "+dChain+(gesture?' ('+gesture.name+')':'');
    }
    this._lastX=x;
    this._lastY=y;
},

_stopGesture:function(event){
    try{
        if(dChain=this._directionChain)this.GESTURES[dChain].cmd(this,event);
        XULBrowserWindow.statusTextField.label="";
    }catch(e){
        XULBrowserWindow.statusTextField.label='Unknown Gesture: '+dChain;
    }
    this._directionChain="";
},

_buildPopup:function(event,gestureCmd){
    if(!this.enablePopupGestures)return;
    var popup=document.getElementById(this.POPUP_ID);
    if(!popup){
        popup=document.createElement("popup");
        popup.id=this.POPUP_ID;
    }
    document.getElementById("mainPopupSet").appendChild(popup);
    popup.setAttribute("gesturecommand",gestureCmd);
    switch(gestureCmd){
        case"WebSearchPopup":
            var searchSvc=Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
            var engines=searchSvc.getVisibleEngines({});
            if(engines.length<1)throw"No search engines installed.";
            for(var i=engines.length-1;i>=0;--i){
                var engine = engines[i];
                var menuitem=document.createElement("menuitem");
                menuitem.setAttribute("label",engine.name);
                menuitem.setAttribute("class","menuitem-iconic");
                if(engine.iconURI)menuitem.setAttribute("src",engine.iconURI.spec);
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.engine=engine;
            }
            popup.setAttribute("selectedtext",getBrowserSelection().toString());
            break;
        case"ClosedTabsPopup":
            try{
                if(!gPrefService.getBoolPref("browser.sessionstore.enabled"))throw"Session Restore feature is disabled.";
            }catch(e){}
            var ss=Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
            if(ss.getClosedTabCount(window)==0)throw"No restorable tabs in this window.";
            var undoItems=eval("("+ss.getClosedTabData(window)+")");
            for(var i=0,LEN=undoItems.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                menuitem.setAttribute("label",undoItems[i].title);
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.index=i;
                var iconURL=undoItems[i].image;
                if(iconURL)menuitem.setAttribute("image",iconURL);
            }
            break;
        case"HistoryPopup":
            var sessionHistory=gBrowser.webNavigation.sessionHistory;
            if(sessionHistory.count<1)throw"No back/forward history for this tab.";
            var curIdx=sessionHistory.index;
            for(var i=0,shc=sessionHistory.count;i<shc;i++){
                var entry=sessionHistory.getEntryAtIndex(i,false);
                if(!entry)continue;
                var menuitem=document.createElement("menuitem");
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.setAttribute("label",entry.title);
                try{
                    var iconURL=Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService).getFaviconForPage(entry.URI).spec;
                    menuitem.style.listStyleImage="url("+iconURL+")";
                }catch(e){}
                menuitem.index=i;
                if(i==curIdx){
                    menuitem.style.listStyleImage="";
                    menuitem.setAttribute("type","radio");
                    menuitem.setAttribute("checked","true");
                    menuitem.className="unified-nav-current";
                    activeItem=menuitem;
                }else{
                    menuitem.className=i<curIdx?"unified-nav-back menuitem-iconic":"unified-nav-forward menuitem-iconic";
                }
            }
            break;
        case"AllTabsPopup":
            var tabs=gBrowser.mTabs;
            if(tabs.length<1)return;
            for(var i=0,LEN=tabs.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                var tab=tabs[i];
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.setAttribute("label",tab.label);
                menuitem.setAttribute("crop",tab.getAttribute("crop"));
                menuitem.setAttribute("image",tab.getAttribute("image"));
                menuitem.index=i;
                if(tab.selected)activeItem=menuitem;
            }
            break;
    }
    document.popupNode=null;
    document.tooltipNode=null;
    popup.addEventListener("popuphiding",this,true);
    popup.openPopup(null,"",event.clientX,event.clientY,false,false);
    document.documentElement.addEventListener("mouseup",this,true);
},
  };
// Запускаем функцию
if (this.CBMouseGesturesRun) return;
this.CBMouseGesturesRun = true; 
ucjsMouseGestures.init()
LongLogin пишет

у меня подошло

Добавлено Сегодня 05:05:05
на FireGestures

А вкладка с этим кодом закрывается?

Отредактировано Kamui (26-08-2012 02:06:13)

Отсутствует

 

№465826-08-2012 02:11:07

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Kamui пишет

Наверно это не подходит :( а есть код который просто отправляет сочетание клавиш Ctrl+w?

Выделить код

Код:

var evt = document.createEvent("KeyEvents");
    evt.initKeyEvent(
      "keypress",
      true,
      true,
      null,
      true,  // holds Ctrl key
      false,  // holds Alt key
      false,  // holds Shift key
      false,  // holds Meta key
      false,  // presses a special key, @see http://mxr.mozilla.org/mozilla/source/dom/public/idl/events/nsIDOMKeyEvent.idl
      "W".charCodeAt(0)  // presses a normal key, e.g. "A".charCodeAt(0),
    );
    document.documentElement.dispatchEvent(evt);

Отредактировано bunda1 (26-08-2012 02:11:29)

Отсутствует

 

№465926-08-2012 02:23:24

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

bunda1
Код закрывает вкладку, но окно загрузок все равно не закрывает, видимо просто жест в окне загрузок не работает, ну и ладно.
А что насчет:

Kamui пишет

Тут возникала еще проблемка, иногда не получается вызвать конекстное меню, потому что из-за малейшего движения начинают "рисоваться жесты", может можно как-то сделать чтобы жест "рисовался" после какой-то задержки или после того как указатель пройдет какое-то минимальное расстояние?

Отсутствует

 

№466026-08-2012 02:23:47

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Kamui пишет

А вкладка с этим кодом закрывается?

Выделить код

Код:

gBrowser.removeCurrentTab();
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
var enumerator = windowManager.getEnumerator(null);
var thisWindow = windowManager.getMostRecentWindow(null);
while (enumerator.hasMoreElements()) {var thatWindow = enumerator.getNext(); if (thisWindow != thatWindow) {thatWindow.close();}}

Отсутствует

 

№466126-08-2012 02:25:49

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

bunda1
Я забыл уточнить что жест я делаю над окном загрузок, а там он видимо не работает, ну и фиг с ним :) Осталась только одна проблемка, описал ее выше.

Отсутствует

 

№466226-08-2012 02:26:27

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Kamui пишет

Тут возникала еще проблемка, иногда не получается вызвать конекстное меню, потому что из-за малейшего движения начинают "рисоваться жесты", может можно как-то сделать чтобы жест "рисовался" после какой-то задержки или после того как указатель пройдет какое-то минимальное расстояние?

У меня такой проблемы ни когда не было, может у тебя с мышью проблемы.
Папробуй:

скрытый текст

Выделить код

Код:

// Mouse Gestures................................ 
var ucjsMouseGestures={


// options
enableWheelGestures: true,
enableRockerGestures: true,
enablePopupGestures: true,


_lastX: 0,
_lastY: 0,
_directionChain: '',
_isMouseDownL: false,
_isMouseDownR: false,
_hideFireContext: false, //for windows
_shouldFireContext: false, //for linux

POPUP_ID: 'GesturePopup',
GESTURES:{
      'L':{name:'History Back',cmd:function(){document.getElementById("Browser:Back").doCommand();}},
      'R':{name:'History Forward',cmd:function(){document.getElementById("Browser:Forward").doCommand();}},
      'UD':{name:'Reload',cmd:function(){document.getElementById("Browser:Reload").doCommand();}},
      'U':{name:'Stop',cmd:function(){document.getElementById("Browser:Stop").doCommand();}},
      'UDU':{name:'Reload Skip Cache',cmd:function(){document.getElementById("Browser:ReloadSkipCache").doCommand();}},
      'DR':{name:'Close Tab',cmd:function(){gBrowser.removeCurrentTab();}},
      'DL':{name:'Undo Tab',cmd:function(){document.getElementById('History:UndoCloseTab').doCommand();}},
      'D':{name:'Open New Tab',cmd:function(){document.getElementById("cmd_newNavigatorTab").doCommand();document.getElementById("searchbar").focus();goDoCommand('cmd_selectAll');}},
      'W-':{name:'Previous Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(-1,true);}},
      'W+':{name:'Next Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(+1,true);}},
      'LR':{name:'Open Panorama',cmd:function(){document.getElementById("Browser:ToggleTabView").doCommand();}},
      'RL':{name:'Open Downloads',cmd:function(){BrowserDownloadsUI();}},
      'DU':{name:'Open Addons',cmd:function(){BrowserOpenAddonsMgr();}},
},

init:function(){
    var self=this;
    var events=["mousedown","mousemove","mouseup","contextmenu"];
    if(this.enableRockerGestures)events.push("draggesture");
    if(this.enableWheelGestures)events.push("DOMMouseScroll");
    function registerEvents(aAction,eventArray){
        eventArray.forEach(function(aType){
                getBrowser().mPanelContainer[aAction+"EventListener"](aType,self,aType=="contextmenu");
        });
    };
    registerEvents("add",events);
    window.addEventListener("unload",function(){
            registerEvents("remove",events);
        },false);
},

handleEvent:function(event){
    switch(event.type){
        case"mousedown":
            if(event.button==2){
                this._isMouseDownR=true;
                this._hideFireContext=false;
                this._startGesture(event);
            }
            if(this.enableRockerGestures){
                if(event.button==2&&this._isMouseDownL){
                    this._isMouseDownR=false;
                    this._shouldFireContext=false;
                    this._hideFireContext=true;
                    this._directionChain="L>R";
                    this._stopGesture(event);
                }else if(event.button==0){
                    this._isMouseDownL=true;
                    if(this._isMouseDownR){
                        this._isMouseDownL=false;
                        this._shouldFireContext=false;
                        this._hideFireContext=true;
                        this._directionChain="L<R";
                        this._stopGesture(event);
                    }
                }
            }
            break;
        case"mousemove":
            if(this._isMouseDownR){
                this._hideFireContext=true;
                this._progressGesture(event);
            }
            break;
        case"mouseup":
            if(event.ctrlKey&&event.button==2){
                this._isMouseDownL=false;
                this._isMouseDownR=false;
                this._shouldFireContext=false;
                this._hideFireContext=false;
                this._directionChain='';
                event.preventDefault();
                XULBrowserWindow.statusTextField.label="Reset Gesture";
                break;
            }
            if(this._isMouseDownR&&event.button==2){
                if(this._directionChain)this._shouldFireContext=false;
                this._isMouseDownR=false;
                this._stopGesture(event);
                if(this._shouldFireContext&&!this._hideFireContext){
                    this._shouldFireContext=false;
                    this._displayContextMenu(event);
                }
            }else if(this.enableRockerGestures&&event.button==0&&this._isMouseDownL){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
            }else if(this.enablePopupGestures&&(event.button==0||event.button==1)&&event.target.localName=='menuitem'){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
                var popup=document.getElementById(this.POPUP_ID);
                var activeItem=event.target;
                switch(popup.getAttribute("gesturecommand")){
                    case"WebSearchPopup":
                        var selText=popup.getAttribute("selectedtext");
                        var engine=activeItem.engine;
                        if(!engine)break;
                        var submission=engine.getSubmission(selText,null);
                        if(!submission)break;
                        document.getElementById('searchbar').textbox.value=selText;
                        gBrowser.loadOneTab(submission.uri.spec,null,null,submission.postData,null,false);
                        break;
                    case"ClosedTabsPopup":
                        undoCloseTab(activeItem.index);
                        break;
                    case"HistoryPopup":
                        gBrowser.webNavigation.gotoIndex(activeItem.index);
                        break;
                    case"AllTabsPopup":
                        gBrowser.selectedTab=gBrowser.mTabs[activeItem.index];
                        break;
                }
                popup.hidePopup();
            }
            break;
    case"popuphiding":
        var popup=document.getElementById(this.POPUP_ID);
        popup.removeEventListener("popuphiding",this,true);
        document.documentElement.removeEventListener("mouseup",this,true);
        while(popup.hasChildNodes())popup.removeChild(popup.lastChild);
        break;
    case"contextmenu":
        if(this._isMouseDownL||this._isMouseDownR||this._hideFireContext){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=true;
            this._hideFireContext=false;
        }
        break;
    case"DOMMouseScroll":
        if(this.enableWheelGestures&&this._isMouseDownR){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=false;
            this._hideFireContext=true;
            this._directionChain="W"+(event.detail>0?"+":"-");
            this._stopGesture(event);
        }
        break;
    case"draggesture":
        this._isMouseDownL=false;
        break;
    }
},

_displayContextMenu:function(event){
    var evt=event.originalTarget.ownerDocument.createEvent("MouseEvents");
    evt.initMouseEvent("contextmenu",true,true,event.originalTarget.defaultView,0,event.screenX,event.screenY,event.clientX,event.clientY,false,false,false,false,2,null);
    event.originalTarget.dispatchEvent(evt);
},

_startGesture:function(event){
    this._lastX=event.screenX;
    this._lastY=event.screenY;
    this._directionChain="";
},

_progressGesture:function(event){
    var x=event.screenX, y=event.screenY;
    var lastX=this._lastX, lastY=this._lastY;
    var subX=x-lastX, subY=y-lastY;
    var distX=(subX>0?subX:(-subX)),distY=(subY>0?subY:(-subY));
    var direction;
    if(distX<10&&distY<10)return;
    if(distX>distY)direction=subX<0?"L":"R";
    else direction=subY<0?"U":"D";
    var dChain = this._directionChain;
    if(direction!=dChain.charAt(dChain.length-1)){
        dChain+=direction;
        this._directionChain+=direction;
        var gesture=this.GESTURES[dChain];
        XULBrowserWindow.statusTextField.label="Gesture: "+dChain+(gesture?' ('+gesture.name+')':'');
    }
    this._lastX=x;
    this._lastY=y;
},

_stopGesture:function(event){
    try{
        if(dChain=this._directionChain)this.GESTURES[dChain].cmd(this,event);
        XULBrowserWindow.statusTextField.label="";
    }catch(e){
        XULBrowserWindow.statusTextField.label='Unknown Gesture: '+dChain;
    }
    this._directionChain="";
},

_buildPopup:function(event,gestureCmd){
    if(!this.enablePopupGestures)return;
    var popup=document.getElementById(this.POPUP_ID);
    if(!popup){
        popup=document.createElement("popup");
        popup.id=this.POPUP_ID;
    }
    document.getElementById("mainPopupSet").appendChild(popup);
    popup.setAttribute("gesturecommand",gestureCmd);
    switch(gestureCmd){
        case"WebSearchPopup":
            var searchSvc=Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
            var engines=searchSvc.getVisibleEngines({});
            if(engines.length<1)throw"No search engines installed.";
            for(var i=engines.length-1;i>=0;--i){
                var engine = engines[i];
                var menuitem=document.createElement("menuitem");
                menuitem.setAttribute("label",engine.name);
                menuitem.setAttribute("class","menuitem-iconic");
                if(engine.iconURI)menuitem.setAttribute("src",engine.iconURI.spec);
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.engine=engine;
            }
            popup.setAttribute("selectedtext",getBrowserSelection().toString());
            break;
        case"ClosedTabsPopup":
            try{
                if(!gPrefService.getBoolPref("browser.sessionstore.enabled"))throw"Session Restore feature is disabled.";
            }catch(e){}
            var ss=Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
            if(ss.getClosedTabCount(window)==0)throw"No restorable tabs in this window.";
            var undoItems=eval("("+ss.getClosedTabData(window)+")");
            for(var i=0,LEN=undoItems.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                menuitem.setAttribute("label",undoItems[i].title);
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.index=i;
                var iconURL=undoItems[i].image;
                if(iconURL)menuitem.setAttribute("image",iconURL);
            }
            break;
        case"HistoryPopup":
            var sessionHistory=gBrowser.webNavigation.sessionHistory;
            if(sessionHistory.count<1)throw"No back/forward history for this tab.";
            var curIdx=sessionHistory.index;
            for(var i=0,shc=sessionHistory.count;i<shc;i++){
                var entry=sessionHistory.getEntryAtIndex(i,false);
                if(!entry)continue;
                var menuitem=document.createElement("menuitem");
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.setAttribute("label",entry.title);
                try{
                    var iconURL=Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService).getFaviconForPage(entry.URI).spec;
                    menuitem.style.listStyleImage="url("+iconURL+")";
                }catch(e){}
                menuitem.index=i;
                if(i==curIdx){
                    menuitem.style.listStyleImage="";
                    menuitem.setAttribute("type","radio");
                    menuitem.setAttribute("checked","true");
                    menuitem.className="unified-nav-current";
                    activeItem=menuitem;
                }else{
                    menuitem.className=i<curIdx?"unified-nav-back menuitem-iconic":"unified-nav-forward menuitem-iconic";
                }
            }
            break;
        case"AllTabsPopup":
            var tabs=gBrowser.mTabs;
            if(tabs.length<1)return;
            for(var i=0,LEN=tabs.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                var tab=tabs[i];
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.setAttribute("label",tab.label);
                menuitem.setAttribute("crop",tab.getAttribute("crop"));
                menuitem.setAttribute("image",tab.getAttribute("image"));
                menuitem.index=i;
                if(tab.selected)activeItem=menuitem;
            }
            break;
    }
    document.popupNode=null;
    document.tooltipNode=null;
    popup.addEventListener("popuphiding",this,true);
    popup.openPopup(null,"",event.clientX,event.clientY,false,false);
    document.documentElement.addEventListener("mouseup",this,true);
},
  };
// Запускаем функцию
if (this.CBMouseGesturesRun) return;
this.CBMouseGesturesRun = true; 
ucjsMouseGestures.init()


Папробуй: userChrome.js/mousegesturesvisual/MouseGesturesVisual.uc.js at 38d21e0840785a1ba1b680fd880f78d6de2bf471 · ardiman/userChrome.js · GitHub

Отредактировано bunda1 (26-08-2012 02:36:56)

Отсутствует

 

№466326-08-2012 02:39:12

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

LongLogin пишет

у меня закрывает
в FireGestures

Видимо у Firegestures прав больше и его жесты работают во всех окнах, а жесты кнопки не работают в окне загрузок и библиотеке закладок.

bunda1 пишет

У меня такой проблемы ни когда не было, может у тебя с мышью проблемы.

Здесь не то чтобы проблема с мышью, просто приходится точно останавливать мышь чтобы вызвать контекстное меню, например увидел картинку и навожу на нее указатель и жму ПКМ, меню не появится, потому что произошел захват клика ПКМ из-за малейшего движения, надеюсь понятно объяснил :D Так вот можно ли сделать задержку хотя бы 100мс перед захватом клика мыши, т.е. если ПКМ нажата дольше 100мс, значит начинается "рисоваться" жест.

Добавлено 26-08-2012 02:46:03

У меня такой проблемы ни когда не было, может у тебя с мышью проблемы.
Папробуй:

скрытый текст

Выделить код

Код:

// Mouse Gestures................................ 
var ucjsMouseGestures={


// options
enableWheelGestures: true,
enableRockerGestures: true,
enablePopupGestures: true,


_lastX: 0,
_lastY: 0,
_directionChain: '',
_isMouseDownL: false,
_isMouseDownR: false,
_hideFireContext: false, //for windows
_shouldFireContext: false, //for linux

POPUP_ID: 'GesturePopup',
GESTURES:{
      'L':{name:'History Back',cmd:function(){document.getElementById("Browser:Back").doCommand();}},
      'R':{name:'History Forward',cmd:function(){document.getElementById("Browser:Forward").doCommand();}},
      'UD':{name:'Reload',cmd:function(){document.getElementById("Browser:Reload").doCommand();}},
      'U':{name:'Stop',cmd:function(){document.getElementById("Browser:Stop").doCommand();}},
      'UDU':{name:'Reload Skip Cache',cmd:function(){document.getElementById("Browser:ReloadSkipCache").doCommand();}},
      'DR':{name:'Close Tab',cmd:function(){gBrowser.removeCurrentTab();}},
      'DL':{name:'Undo Tab',cmd:function(){document.getElementById('History:UndoCloseTab').doCommand();}},
      'D':{name:'Open New Tab',cmd:function(){document.getElementById("cmd_newNavigatorTab").doCommand();document.getElementById("searchbar").focus();goDoCommand('cmd_selectAll');}},
      'W-':{name:'Previous Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(-1,true);}},
      'W+':{name:'Next Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(+1,true);}},
      'LR':{name:'Open Panorama',cmd:function(){document.getElementById("Browser:ToggleTabView").doCommand();}},
      'RL':{name:'Open Downloads',cmd:function(){BrowserDownloadsUI();}},
      'DU':{name:'Open Addons',cmd:function(){BrowserOpenAddonsMgr();}},
},

init:function(){
    var self=this;
    var events=["mousedown","mousemove","mouseup","contextmenu"];
    if(this.enableRockerGestures)events.push("draggesture");
    if(this.enableWheelGestures)events.push("DOMMouseScroll");
    function registerEvents(aAction,eventArray){
        eventArray.forEach(function(aType){
                getBrowser().mPanelContainer[aAction+"EventListener"](aType,self,aType=="contextmenu");
        });
    };
    registerEvents("add",events);
    window.addEventListener("unload",function(){
            registerEvents("remove",events);
        },false);
},

handleEvent:function(event){
    switch(event.type){
        case"mousedown":
            if(event.button==2){
                this._isMouseDownR=true;
                this._hideFireContext=false;
                this._startGesture(event);
            }
            if(this.enableRockerGestures){
                if(event.button==2&&this._isMouseDownL){
                    this._isMouseDownR=false;
                    this._shouldFireContext=false;
                    this._hideFireContext=true;
                    this._directionChain="L>R";
                    this._stopGesture(event);
                }else if(event.button==0){
                    this._isMouseDownL=true;
                    if(this._isMouseDownR){
                        this._isMouseDownL=false;
                        this._shouldFireContext=false;
                        this._hideFireContext=true;
                        this._directionChain="L<R";
                        this._stopGesture(event);
                    }
                }
            }
            break;
        case"mousemove":
            if(this._isMouseDownR){
                this._hideFireContext=true;
                this._progressGesture(event);
            }
            break;
        case"mouseup":
            if(event.ctrlKey&&event.button==2){
                this._isMouseDownL=false;
                this._isMouseDownR=false;
                this._shouldFireContext=false;
                this._hideFireContext=false;
                this._directionChain='';
                event.preventDefault();
                XULBrowserWindow.statusTextField.label="Reset Gesture";
                break;
            }
            if(this._isMouseDownR&&event.button==2){
                if(this._directionChain)this._shouldFireContext=false;
                this._isMouseDownR=false;
                this._stopGesture(event);
                if(this._shouldFireContext&&!this._hideFireContext){
                    this._shouldFireContext=false;
                    this._displayContextMenu(event);
                }
            }else if(this.enableRockerGestures&&event.button==0&&this._isMouseDownL){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
            }else if(this.enablePopupGestures&&(event.button==0||event.button==1)&&event.target.localName=='menuitem'){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
                var popup=document.getElementById(this.POPUP_ID);
                var activeItem=event.target;
                switch(popup.getAttribute("gesturecommand")){
                    case"WebSearchPopup":
                        var selText=popup.getAttribute("selectedtext");
                        var engine=activeItem.engine;
                        if(!engine)break;
                        var submission=engine.getSubmission(selText,null);
                        if(!submission)break;
                        document.getElementById('searchbar').textbox.value=selText;
                        gBrowser.loadOneTab(submission.uri.spec,null,null,submission.postData,null,false);
                        break;
                    case"ClosedTabsPopup":
                        undoCloseTab(activeItem.index);
                        break;
                    case"HistoryPopup":
                        gBrowser.webNavigation.gotoIndex(activeItem.index);
                        break;
                    case"AllTabsPopup":
                        gBrowser.selectedTab=gBrowser.mTabs[activeItem.index];
                        break;
                }
                popup.hidePopup();
            }
            break;
    case"popuphiding":
        var popup=document.getElementById(this.POPUP_ID);
        popup.removeEventListener("popuphiding",this,true);
        document.documentElement.removeEventListener("mouseup",this,true);
        while(popup.hasChildNodes())popup.removeChild(popup.lastChild);
        break;
    case"contextmenu":
        if(this._isMouseDownL||this._isMouseDownR||this._hideFireContext){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=true;
            this._hideFireContext=false;
        }
        break;
    case"DOMMouseScroll":
        if(this.enableWheelGestures&&this._isMouseDownR){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=false;
            this._hideFireContext=true;
            this._directionChain="W"+(event.detail>0?"+":"-");
            this._stopGesture(event);
        }
        break;
    case"draggesture":
        this._isMouseDownL=false;
        break;
    }
},

_displayContextMenu:function(event){
    var evt=event.originalTarget.ownerDocument.createEvent("MouseEvents");
    evt.initMouseEvent("contextmenu",true,true,event.originalTarget.defaultView,0,event.screenX,event.screenY,event.clientX,event.clientY,false,false,false,false,2,null);
    event.originalTarget.dispatchEvent(evt);
},

_startGesture:function(event){
    this._lastX=event.screenX;
    this._lastY=event.screenY;
    this._directionChain="";
},

_progressGesture:function(event){
    var x=event.screenX, y=event.screenY;
    var lastX=this._lastX, lastY=this._lastY;
    var subX=x-lastX, subY=y-lastY;
    var distX=(subX>0?subX:(-subX)),distY=(subY>0?subY:(-subY));
    var direction;
    if(distX<10&&distY<10)return;
    if(distX>distY)direction=subX<0?"L":"R";
    else direction=subY<0?"U":"D";
    var dChain = this._directionChain;
    if(direction!=dChain.charAt(dChain.length-1)){
        dChain+=direction;
        this._directionChain+=direction;
        var gesture=this.GESTURES[dChain];
        XULBrowserWindow.statusTextField.label="Gesture: "+dChain+(gesture?' ('+gesture.name+')':'');
    }
    this._lastX=x;
    this._lastY=y;
},

_stopGesture:function(event){
    try{
        if(dChain=this._directionChain)this.GESTURES[dChain].cmd(this,event);
        XULBrowserWindow.statusTextField.label="";
    }catch(e){
        XULBrowserWindow.statusTextField.label='Unknown Gesture: '+dChain;
    }
    this._directionChain="";
},

_buildPopup:function(event,gestureCmd){
    if(!this.enablePopupGestures)return;
    var popup=document.getElementById(this.POPUP_ID);
    if(!popup){
        popup=document.createElement("popup");
        popup.id=this.POPUP_ID;
    }
    document.getElementById("mainPopupSet").appendChild(popup);
    popup.setAttribute("gesturecommand",gestureCmd);
    switch(gestureCmd){
        case"WebSearchPopup":
            var searchSvc=Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
            var engines=searchSvc.getVisibleEngines({});
            if(engines.length<1)throw"No search engines installed.";
            for(var i=engines.length-1;i>=0;--i){
                var engine = engines[i];
                var menuitem=document.createElement("menuitem");
                menuitem.setAttribute("label",engine.name);
                menuitem.setAttribute("class","menuitem-iconic");
                if(engine.iconURI)menuitem.setAttribute("src",engine.iconURI.spec);
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.engine=engine;
            }
            popup.setAttribute("selectedtext",getBrowserSelection().toString());
            break;
        case"ClosedTabsPopup":
            try{
                if(!gPrefService.getBoolPref("browser.sessionstore.enabled"))throw"Session Restore feature is disabled.";
            }catch(e){}
            var ss=Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
            if(ss.getClosedTabCount(window)==0)throw"No restorable tabs in this window.";
            var undoItems=eval("("+ss.getClosedTabData(window)+")");
            for(var i=0,LEN=undoItems.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                menuitem.setAttribute("label",undoItems[i].title);
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.index=i;
                var iconURL=undoItems[i].image;
                if(iconURL)menuitem.setAttribute("image",iconURL);
            }
            break;
        case"HistoryPopup":
            var sessionHistory=gBrowser.webNavigation.sessionHistory;
            if(sessionHistory.count<1)throw"No back/forward history for this tab.";
            var curIdx=sessionHistory.index;
            for(var i=0,shc=sessionHistory.count;i<shc;i++){
                var entry=sessionHistory.getEntryAtIndex(i,false);
                if(!entry)continue;
                var menuitem=document.createElement("menuitem");
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.setAttribute("label",entry.title);
                try{
                    var iconURL=Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService).getFaviconForPage(entry.URI).spec;
                    menuitem.style.listStyleImage="url("+iconURL+")";
                }catch(e){}
                menuitem.index=i;
                if(i==curIdx){
                    menuitem.style.listStyleImage="";
                    menuitem.setAttribute("type","radio");
                    menuitem.setAttribute("checked","true");
                    menuitem.className="unified-nav-current";
                    activeItem=menuitem;
                }else{
                    menuitem.className=i<curIdx?"unified-nav-back menuitem-iconic":"unified-nav-forward menuitem-iconic";
                }
            }
            break;
        case"AllTabsPopup":
            var tabs=gBrowser.mTabs;
            if(tabs.length<1)return;
            for(var i=0,LEN=tabs.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                var tab=tabs[i];
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.setAttribute("label",tab.label);
                menuitem.setAttribute("crop",tab.getAttribute("crop"));
                menuitem.setAttribute("image",tab.getAttribute("image"));
                menuitem.index=i;
                if(tab.selected)activeItem=menuitem;
            }
            break;
    }
    document.popupNode=null;
    document.tooltipNode=null;
    popup.addEventListener("popuphiding",this,true);
    popup.openPopup(null,"",event.clientX,event.clientY,false,false);
    document.documentElement.addEventListener("mouseup",this,true);
},
  };
// Запускаем функцию
if (this.CBMouseGesturesRun) return;
this.CBMouseGesturesRun = true; 
ucjsMouseGestures.init()


Папробуй: userChrome.js/mousegesturesvisual/MouseGesturesVisual.uc.js at 38d21e0840785a1ba1b680fd880f78d6de2bf471 · ardiman/userChrome.js · GitHub

Все тоже самое :(

Отредактировано Kamui (26-08-2012 02:46:03)

Отсутствует

 

№466426-08-2012 02:48:30

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Не знаю, надо подумать.

Отредактировано bunda1 (26-08-2012 02:50:00)

Отсутствует

 

№466526-08-2012 02:48:37

LongLogin
Участник
 
Группа: Members
Зарегистрирован: 30-01-2011
Сообщений: 2083
UA: Firefox 14.0

Re: Custom Buttons

у меня закрывает
в FireGestures

Kamui пишет

Видимо у Firegestures прав больше и его жесты работают во всех окнах, а жесты кнопки не работают в окне загрузок и библиотеке закладок.

нет нет, над окном загрузок не работает тоже

а что если Загрузки открывать во вкладке. проблема решиться

и ещё вспомнил про параметр отвечающий за то,  чтобы призакрытии вкладки не закрывалось окно

Отсутствует

 

№466626-08-2012 02:51:23

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

LongLogin пишет

а что если Загрузки открывать во вкладке. проблема решиться

Выделить код

Код:

getBrowser().selectedTab = getBrowser().addTab("chrome://mozapps/content/downloads/downloads.xul");

Отредактировано bunda1 (26-08-2012 02:51:39)

Отсутствует

 

№466726-08-2012 02:54:20

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

bunda1 пишет

У меня такой проблемы ни когда не было, может у тебя с мышью проблемы.
Папробуй:

скрытый текст

Выделить код

Код:

// Mouse Gestures................................ 
var ucjsMouseGestures={


// options
enableWheelGestures: true,
enableRockerGestures: true,
enablePopupGestures: true,


_lastX: 0,
_lastY: 0,
_directionChain: '',
_isMouseDownL: false,
_isMouseDownR: false,
_hideFireContext: false, //for windows
_shouldFireContext: false, //for linux

POPUP_ID: 'GesturePopup',
GESTURES:{
      'L':{name:'History Back',cmd:function(){document.getElementById("Browser:Back").doCommand();}},
      'R':{name:'History Forward',cmd:function(){document.getElementById("Browser:Forward").doCommand();}},
      'UD':{name:'Reload',cmd:function(){document.getElementById("Browser:Reload").doCommand();}},
      'U':{name:'Stop',cmd:function(){document.getElementById("Browser:Stop").doCommand();}},
      'UDU':{name:'Reload Skip Cache',cmd:function(){document.getElementById("Browser:ReloadSkipCache").doCommand();}},
      'DR':{name:'Close Tab',cmd:function(){gBrowser.removeCurrentTab();}},
      'DL':{name:'Undo Tab',cmd:function(){document.getElementById('History:UndoCloseTab').doCommand();}},
      'D':{name:'Open New Tab',cmd:function(){document.getElementById("cmd_newNavigatorTab").doCommand();document.getElementById("searchbar").focus();goDoCommand('cmd_selectAll');}},
      'W-':{name:'Previous Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(-1,true);}},
      'W+':{name:'Next Tab',cmd:function(){gBrowser.mTabContainer.advanceSelectedTab(+1,true);}},
      'LR':{name:'Open Panorama',cmd:function(){document.getElementById("Browser:ToggleTabView").doCommand();}},
      'RL':{name:'Open Downloads',cmd:function(){BrowserDownloadsUI();}},
      'DU':{name:'Open Addons',cmd:function(){BrowserOpenAddonsMgr();}},
},

init:function(){
    var self=this;
    var events=["mousedown","mousemove","mouseup","contextmenu"];
    if(this.enableRockerGestures)events.push("draggesture");
    if(this.enableWheelGestures)events.push("DOMMouseScroll");
    function registerEvents(aAction,eventArray){
        eventArray.forEach(function(aType){
                getBrowser().mPanelContainer[aAction+"EventListener"](aType,self,aType=="contextmenu");
        });
    };
    registerEvents("add",events);
    window.addEventListener("unload",function(){
            registerEvents("remove",events);
        },false);
},

handleEvent:function(event){
    switch(event.type){
        case"mousedown":
            if(event.button==2){
                this._isMouseDownR=true;
                this._hideFireContext=false;
                this._startGesture(event);
            }
            if(this.enableRockerGestures){
                if(event.button==2&&this._isMouseDownL){
                    this._isMouseDownR=false;
                    this._shouldFireContext=false;
                    this._hideFireContext=true;
                    this._directionChain="L>R";
                    this._stopGesture(event);
                }else if(event.button==0){
                    this._isMouseDownL=true;
                    if(this._isMouseDownR){
                        this._isMouseDownL=false;
                        this._shouldFireContext=false;
                        this._hideFireContext=true;
                        this._directionChain="L<R";
                        this._stopGesture(event);
                    }
                }
            }
            break;
        case"mousemove":
            if(this._isMouseDownR){
                this._hideFireContext=true;
                this._progressGesture(event);
            }
            break;
        case"mouseup":
            if(event.ctrlKey&&event.button==2){
                this._isMouseDownL=false;
                this._isMouseDownR=false;
                this._shouldFireContext=false;
                this._hideFireContext=false;
                this._directionChain='';
                event.preventDefault();
                XULBrowserWindow.statusTextField.label="Reset Gesture";
                break;
            }
            if(this._isMouseDownR&&event.button==2){
                if(this._directionChain)this._shouldFireContext=false;
                this._isMouseDownR=false;
                this._stopGesture(event);
                if(this._shouldFireContext&&!this._hideFireContext){
                    this._shouldFireContext=false;
                    this._displayContextMenu(event);
                }
            }else if(this.enableRockerGestures&&event.button==0&&this._isMouseDownL){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
            }else if(this.enablePopupGestures&&(event.button==0||event.button==1)&&event.target.localName=='menuitem'){
                this._isMouseDownL=false;
                this._shouldFireContext=false;
                var popup=document.getElementById(this.POPUP_ID);
                var activeItem=event.target;
                switch(popup.getAttribute("gesturecommand")){
                    case"WebSearchPopup":
                        var selText=popup.getAttribute("selectedtext");
                        var engine=activeItem.engine;
                        if(!engine)break;
                        var submission=engine.getSubmission(selText,null);
                        if(!submission)break;
                        document.getElementById('searchbar').textbox.value=selText;
                        gBrowser.loadOneTab(submission.uri.spec,null,null,submission.postData,null,false);
                        break;
                    case"ClosedTabsPopup":
                        undoCloseTab(activeItem.index);
                        break;
                    case"HistoryPopup":
                        gBrowser.webNavigation.gotoIndex(activeItem.index);
                        break;
                    case"AllTabsPopup":
                        gBrowser.selectedTab=gBrowser.mTabs[activeItem.index];
                        break;
                }
                popup.hidePopup();
            }
            break;
    case"popuphiding":
        var popup=document.getElementById(this.POPUP_ID);
        popup.removeEventListener("popuphiding",this,true);
        document.documentElement.removeEventListener("mouseup",this,true);
        while(popup.hasChildNodes())popup.removeChild(popup.lastChild);
        break;
    case"contextmenu":
        if(this._isMouseDownL||this._isMouseDownR||this._hideFireContext){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=true;
            this._hideFireContext=false;
        }
        break;
    case"DOMMouseScroll":
        if(this.enableWheelGestures&&this._isMouseDownR){
            event.preventDefault();
            event.stopPropagation();
            this._shouldFireContext=false;
            this._hideFireContext=true;
            this._directionChain="W"+(event.detail>0?"+":"-");
            this._stopGesture(event);
        }
        break;
    case"draggesture":
        this._isMouseDownL=false;
        break;
    }
},

_displayContextMenu:function(event){
    var evt=event.originalTarget.ownerDocument.createEvent("MouseEvents");
    evt.initMouseEvent("contextmenu",true,true,event.originalTarget.defaultView,0,event.screenX,event.screenY,event.clientX,event.clientY,false,false,false,false,2,null);
    event.originalTarget.dispatchEvent(evt);
},

_startGesture:function(event){
    this._lastX=event.screenX;
    this._lastY=event.screenY;
    this._directionChain="";
},

_progressGesture:function(event){
    var x=event.screenX, y=event.screenY;
    var lastX=this._lastX, lastY=this._lastY;
    var subX=x-lastX, subY=y-lastY;
    var distX=(subX>0?subX:(-subX)),distY=(subY>0?subY:(-subY));
    var direction;
    if(distX<10&&distY<10)return;
    if(distX>distY)direction=subX<0?"L":"R";
    else direction=subY<0?"U":"D";
    var dChain = this._directionChain;
    if(direction!=dChain.charAt(dChain.length-1)){
        dChain+=direction;
        this._directionChain+=direction;
        var gesture=this.GESTURES[dChain];
        XULBrowserWindow.statusTextField.label="Gesture: "+dChain+(gesture?' ('+gesture.name+')':'');
    }
    this._lastX=x;
    this._lastY=y;
},

_stopGesture:function(event){
    try{
        if(dChain=this._directionChain)this.GESTURES[dChain].cmd(this,event);
        XULBrowserWindow.statusTextField.label="";
    }catch(e){
        XULBrowserWindow.statusTextField.label='Unknown Gesture: '+dChain;
    }
    this._directionChain="";
},

_buildPopup:function(event,gestureCmd){
    if(!this.enablePopupGestures)return;
    var popup=document.getElementById(this.POPUP_ID);
    if(!popup){
        popup=document.createElement("popup");
        popup.id=this.POPUP_ID;
    }
    document.getElementById("mainPopupSet").appendChild(popup);
    popup.setAttribute("gesturecommand",gestureCmd);
    switch(gestureCmd){
        case"WebSearchPopup":
            var searchSvc=Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
            var engines=searchSvc.getVisibleEngines({});
            if(engines.length<1)throw"No search engines installed.";
            for(var i=engines.length-1;i>=0;--i){
                var engine = engines[i];
                var menuitem=document.createElement("menuitem");
                menuitem.setAttribute("label",engine.name);
                menuitem.setAttribute("class","menuitem-iconic");
                if(engine.iconURI)menuitem.setAttribute("src",engine.iconURI.spec);
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.engine=engine;
            }
            popup.setAttribute("selectedtext",getBrowserSelection().toString());
            break;
        case"ClosedTabsPopup":
            try{
                if(!gPrefService.getBoolPref("browser.sessionstore.enabled"))throw"Session Restore feature is disabled.";
            }catch(e){}
            var ss=Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
            if(ss.getClosedTabCount(window)==0)throw"No restorable tabs in this window.";
            var undoItems=eval("("+ss.getClosedTabData(window)+")");
            for(var i=0,LEN=undoItems.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                menuitem.setAttribute("label",undoItems[i].title);
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.index=i;
                var iconURL=undoItems[i].image;
                if(iconURL)menuitem.setAttribute("image",iconURL);
            }
            break;
        case"HistoryPopup":
            var sessionHistory=gBrowser.webNavigation.sessionHistory;
            if(sessionHistory.count<1)throw"No back/forward history for this tab.";
            var curIdx=sessionHistory.index;
            for(var i=0,shc=sessionHistory.count;i<shc;i++){
                var entry=sessionHistory.getEntryAtIndex(i,false);
                if(!entry)continue;
                var menuitem=document.createElement("menuitem");
                popup.insertBefore(menuitem,popup.firstChild);
                menuitem.setAttribute("label",entry.title);
                try{
                    var iconURL=Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService).getFaviconForPage(entry.URI).spec;
                    menuitem.style.listStyleImage="url("+iconURL+")";
                }catch(e){}
                menuitem.index=i;
                if(i==curIdx){
                    menuitem.style.listStyleImage="";
                    menuitem.setAttribute("type","radio");
                    menuitem.setAttribute("checked","true");
                    menuitem.className="unified-nav-current";
                    activeItem=menuitem;
                }else{
                    menuitem.className=i<curIdx?"unified-nav-back menuitem-iconic":"unified-nav-forward menuitem-iconic";
                }
            }
            break;
        case"AllTabsPopup":
            var tabs=gBrowser.mTabs;
            if(tabs.length<1)return;
            for(var i=0,LEN=tabs.length;i<LEN;i++){
                var menuitem=popup.appendChild(document.createElement("menuitem"));
                var tab=tabs[i];
                menuitem.setAttribute("class","menuitem-iconic bookmark-item");
                menuitem.setAttribute("label",tab.label);
                menuitem.setAttribute("crop",tab.getAttribute("crop"));
                menuitem.setAttribute("image",tab.getAttribute("image"));
                menuitem.index=i;
                if(tab.selected)activeItem=menuitem;
            }
            break;
    }
    document.popupNode=null;
    document.tooltipNode=null;
    popup.addEventListener("popuphiding",this,true);
    popup.openPopup(null,"",event.clientX,event.clientY,false,false);
    document.documentElement.addEventListener("mouseup",this,true);
},
  };
// Запускаем функцию
if (this.CBMouseGesturesRun) return;
this.CBMouseGesturesRun = true; 
ucjsMouseGestures.init()

Код под спойлером аналогичен тому который у меня сейчас, ты хотел внести какие-то изменения и забыл? :)

bunda1 пишет
LongLogin пишет

а что если Загрузки открывать во вкладке. проблема решиться

Выделить код

Код:

getBrowser().selectedTab = getBrowser().addTab("chrome://mozapps/content/downloads/downloads.xul");

Так и сделаю пожалуй :)

bunda1 пишет

Папробуй: userChrome.js/mousegesturesvisual/MouseGesturesVisual.uc.js at 38d21e0840785a1ba1b680fd880f78d6de2bf471 · ardiman/userChrome.js · GitHub

Мне кажется здесь вот этот код может быть полезен:

Выделить код

Код:

if (distX < 10 && distY < 10) return;

Кстати еще было бы хорошо, как в расширениях, если через определенный интервал жест отменялся и открывалось контекстное меню, так по-моему везде сделано :) и тогда можно будет не заморачиваться с предыдущей проблемой.

Отредактировано Kamui (26-08-2012 03:25:41)

Отсутствует

 

№466826-08-2012 03:30:19

LongLogin
Участник
 
Группа: Members
Зарегистрирован: 30-01-2011
Сообщений: 2083
UA: Firefox 14.0

Re: Custom Buttons

Kamui
так почему не подошёл код закрывающий остальные окна кроме текущего?

bunda1 пишет
Выделить код

Код:

var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
var enumerator = windowManager.getEnumerator(null);
var thisWindow = windowManager.getMostRecentWindow(null);
while (enumerator.hasMoreElements()) {var thatWindow = enumerator.getNext(); if (thisWindow != thatWindow) {thatWindow.close();}}

Отсутствует

 

№466926-08-2012 03:39:08

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

LongLogin
Если повесить этот код на жест, то будут закрываться только окна, а если использовать код который еще закрывает вкладку, то если мне надо закрыть только окно, также будет закрываться и текущая вкладка, что нежелательно. Я сделал открытие окна загрузок во вкладке как посоветовали и все:)

Отсутствует

 

№467026-08-2012 12:51:27

firepox
Участник
 
Группа: Members
Зарегистрирован: 17-11-2011
Сообщений: 358
UA: Firefox 14.0

Re: Custom Buttons

Context translate(Firefox)
Возможно доработать?

1. при клике по кнопке ЛК- появляется поле для ввода текста. (перевод осуществляется в одном из переводчиков)
если перед кликом выделен текст, то начинается сразу перевод выделенного текста.

2. при клике по кнопке колесиком - появляется поле для ввода текста. (перевод осуществляется во всех переводчиках)
если перед кликом выделен текст, то начинается сразу перевод выделенного текста.

3. добавить сюда:
857989.png
пункты: перевести во ВСЕХ.

зы
практика показывает, что нужно переводить фразы в нескольких переводчиках.
если добавить, то, что я прошу - будет экономия времени, да и вообще - удобно.
спасибо.

Отредактировано firepox (26-08-2012 12:52:31)

Отсутствует

 

№467126-08-2012 23:42:32

LongLogin
Участник
 
Группа: Members
Зарегистрирован: 30-01-2011
Сообщений: 2083
UA: Firefox 14.0

Re: Custom Buttons

а, у Kamui в [firefox] 16.0 новая панель Загрузок, а он нам голову морочил
безобразие
такой на голубом глазу - почему у меня не закрывается, ну почему?
и этож ещё баг может быть какой-нибудь
Finished downloads don't disappear in the download panel despite browser.download.panel.removeFinishedDownloads is set "true". How can this problem be solved?

Отсутствует

 

№467227-08-2012 01:00:15

Kamui
Участник
 
Группа: Members
Зарегистрирован: 31-03-2011
Сообщений: 1796
UA: Firefox 16.0

Re: Custom Buttons

LongLogin
Хоть у меня и [firefox] 16, но панель загрузок самая что ни на есть старая :D

скрытый текст
h_1346014781_5767327_a99cfb4b79.png

Отсутствует

 

№467327-08-2012 11:57:32

villa7
Участник
 
Группа: Members
Зарегистрирован: 21-07-2012
Сообщений: 2235
UA: Firefox 14.0

Re: Custom Buttons

Есть такая кнопочка Relative tabs вот здесь - http://forum.mozilla-russia.org/viewtopic.php?pid=418265#p418265  открывает любую новую вкладку справа от текущей, можно как нибудь сделать не отдельной кнопкой а положить в инициализацию другой и что-бы иконка не менялась, а то ложу код в другую кнопку и меняется иконка кнопки.


Лучше спросить у знающих - чем лезть не зная.

Отсутствует

 

№467427-08-2012 12:52:39

firepox
Участник
 
Группа: Members
Зарегистрирован: 17-11-2011
Сообщений: 358
UA: Firefox 14.0

Re: Custom Buttons

Уважаемые специалисты!
Помогите пожалуйста с этим http://forum.mozilla-russia.org/viewtopic.php?pid=578844#p578844
спасибо

Отсутствует

 

№467527-08-2012 13:59:40

LongLogin
Участник
 
Группа: Members
Зарегистрирован: 30-01-2011
Сообщений: 2083
UA: Firefox 14.0

Re: Custom Buttons

Kamui
это не важно, факт в том что она была переработана в 16, иначе панель бы закрывалась как окно

или она не окно, а гибрид какой-то?
потому что, что означает: Если повесить этот код на жест, то будут закрываться только окна - до сих пор не понятен
да, будет окно Загрузки закрываться как окно
а как оно должно закрываться?
--------
отличная схемка, я и QuickNote так закрываю - RD (вправо-вниз), и очень хорошо

Отсутствует

 

Board footer

Powered by PunBB
Modified by Mozilla Russia
Copyright © 2004–2020 Mozilla Russia GitHub mark
Язык отображения форума: [Русский] [English]