-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#36 Clicking widget has same effect as clicking 'Save Text To File'
context menu entry
- Loading branch information
1 parent
5c3576b
commit 4bc49c3
Showing
10 changed files
with
86 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
getText(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
self.on("click", function () { | ||
getText(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
self.on("click", function () { | ||
function getText(){ | ||
|
||
self.postMessage(window.getSelection().toString()); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
var { Hotkey } = require("sdk/hotkeys"), | ||
Selection = require("./Selection"), | ||
Notification = require("./Notification"), | ||
File = require("./File"); | ||
Tab = require("./Tab"); | ||
|
||
exports.init = function() { | ||
|
||
Hotkey({ | ||
combo: "shift-f1", | ||
onPress: function() { | ||
|
||
if(Selection.getText() === null){ | ||
|
||
Notification.sendMsg("noTextSelected_id"); | ||
|
||
}else{ | ||
File.saveTo(Selection.getText()); | ||
} | ||
Tab.getSelectedTextHotkey(); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
var tab = require('tabs'); | ||
var tab = require('tabs'), | ||
Data = require("./Data"), | ||
File = require("./File"), | ||
Notification = require("./Notification"); | ||
|
||
exports.getTitle = function() { | ||
|
||
return tab.activeTab.title; | ||
} | ||
}; | ||
|
||
exports.getURL = function() { | ||
|
||
return tab.activeTab.url; | ||
} | ||
}; | ||
|
||
exports.getSelectedText = function() { | ||
|
||
tab.activeTab.attach({ | ||
contentScriptFile: [ Data.get("js/SendSelectedText.js"), Data.get("js/GetSelectedText.js") ], | ||
onMessage: function(selectedText) { | ||
File.saveTo(selectedText); | ||
} | ||
}); | ||
}; | ||
|
||
exports.getSelectedTextHotkey = function() { | ||
|
||
tab.activeTab.attach({ | ||
contentScriptFile: [ Data.get("js/SendSelectedText.js"), Data.get("js/GetSelectedText.js") ], | ||
onMessage: function(selectedText) { | ||
|
||
if(selectedText === "" || selectedText === null){ | ||
|
||
Notification.sendMsg("noTextSelected_id"); | ||
|
||
}else{ | ||
File.saveTo(selectedText); | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
var widget = require("sdk/widget"), | ||
Localisation = require("./Localisation"), | ||
Data = require("./Data"); | ||
Data = require("./Data"), | ||
Tab = require("./Tab"); | ||
|
||
exports.init = function(panel) { | ||
|
||
widget.Widget({ | ||
var widgetObj = widget.Widget({ | ||
id: "save-text-to-file-widget", | ||
label: Localisation.getString("saveTextToFile_id"), | ||
contentURL: Data.get("images/ico.png"), | ||
panel: panel | ||
panel: panel, | ||
onClick: function() { | ||
|
||
Tab.getSelectedText(); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require("./Hotkey").init(); | ||
require("./Panel").init(); | ||
//require("./Widget").init(panel); | ||
var panel = require("./Panel").init(); | ||
require("./Widget").init(panel); | ||
require("./ContextMenu").init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters