summaryrefslogtreecommitdiff
path: root/lib/scripts/toolbar.js
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2009-05-28 17:35:07 +0200
committerAndreas Gohr <andi@splitbrain.org>2009-05-28 17:35:07 +0200
commit9b53a46b10ccc4f557513b3cc16803304e19403f (patch)
treee2de0203c9639bfd7a5acd0862b428d5f1e74cef /lib/scripts/toolbar.js
parent6b6da7f587c020b3439dc14c8250766f895adb93 (diff)
downloadrpg-9b53a46b10ccc4f557513b3cc16803304e19403f.tar.gz
rpg-9b53a46b10ccc4f557513b3cc16803304e19403f.tar.bz2
Make sub-toolbars in pickers possible
Ignore-this: ace153a4684f7b345df56d796717a172 Now all types of buttons kan also be placed in a toolbar picker window. It should even be possible to create deep nested picker cascades. darcs-hash:20090528153507-7ad00-828c7a9022b7a4021bf8a74bcd0771373deee254.gz
Diffstat (limited to 'lib/scripts/toolbar.js')
-rw-r--r--lib/scripts/toolbar.js54
1 files changed, 53 insertions, 1 deletions
diff --git a/lib/scripts/toolbar.js b/lib/scripts/toolbar.js
index 18d2daede..5c51af1eb 100644
--- a/lib/scripts/toolbar.js
+++ b/lib/scripts/toolbar.js
@@ -1,3 +1,7 @@
+
+// used to identify pickers
+var pickercounter=0;
+
/**
* Create a toolbar
*
@@ -40,7 +44,7 @@ function initToolbar(tbid,edid,tb){
// type is a init function -> execute it
actionFunc = 'addBtnAction'+tb[i]['type'].charAt(0).toUpperCase()+tb[i]['type'].substring(1);
if( isFunction(window[actionFunc]) ){
- if(window[actionFunc](btn, tb[i], edid, i)){
+ if(window[actionFunc](btn, tb[i], edid)){
toolbar.appendChild(btn);
}
continue;
@@ -69,6 +73,7 @@ function tb_format(btn, props, edid) {
fixtxt(props['open']),
fixtxt(props['close']),
fixtxt(sample));
+ pickerClose();
return false;
}
@@ -83,11 +88,58 @@ function tb_format(btn, props, edid) {
*/
function tb_insert(btn, props, edid) {
insertAtCarret(edid,fixtxt(props['insert']));
+ pickerClose();
}
+/**
+ * Add button action for picker buttons and create picker element
+ *
+ * @param DOMElement btn Button element to add the action to
+ * @param array props Associative array of button properties
+ * @param string edid ID of the editor textarea
+ * @return boolean If button should be appended
+ * @author Gabriel Birke <birke@d-scribe.de>
+ */
+function addBtnActionPicker(btn, props, edid) {
+ var pickerid = 'picker'+(pickercounter++);
+ createPicker(pickerid, props, edid);
+ addEvent(btn,'click',function(){
+ pickerToggle(pickerid,btn);
+ return false;
+ });
+ return true;
+}
+/**
+ * Show/Hide a previosly created picker window
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function pickerToggle(pickerid,btn){
+ var picker = $(pickerid);
+ if(picker.style.display == 'none'){
+ var x = findPosX(btn);
+ var y = findPosY(btn);
+ picker.style.display = 'block';
+ picker.style.left = (x+3)+'px';
+ picker.style.top = (y+btn.offsetHeight+3)+'px';
+ }else{
+ picker.style.display = 'none';
+ }
+}
+/**
+ * Close all open pickers
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function pickerClose(){
+ var pobjs = getElementsByClass('picker');
+ for(var i=0; i<pobjs.length; i++){
+ pobjs[i].style.display = 'none';
+ }
+}
/**