+ // connect action buttons
+ var allbuttons = $.makeArray(action_buttons)
+ $.merge(allbuttons,
+ $.makeArray($('*.toolbar-button-groups-container button', toolbar)) );
+
+ $(allbuttons).each(function() {
+ var button = $(this);
+ var hk = button.attr('ui:hotkey');
+ if(hk) hk = new Hotkey( parseInt(hk) );
+
+ try {
+ var params = $.evalJSON(button.attr('ui:action-params'));
+ } catch(object) {
+ $.log('JSON exception in ', button, ': ', object);
+ button.attr('disabled', 'disabled');
+ return;
+ }
+
+ var callback = function() {
+ editor.callScriptlet(button.attr('ui:action'), self, params);
+ };
+
+ // connect button
+ button.click(callback);
+
+ // connect hotkey
+ if(hk) {
+ self.hotkeys[hk.code] = callback;
+ $.log('hotkey', hk);
+ }
+
+ // tooltip
+ if (button.attr('ui:tooltip') )
+ {
+ var tooltip = button.attr('ui:tooltip');
+ if(hk) tooltip += ' ['+hk+']';
+
+ button.wTooltip({
+ delay: 1000,
+ style: {
+ border: "1px solid #7F7D67",
+ opacity: 0.9,
+ background: "#FBFBC6",
+ padding: "1px",
+ fontSize: "12px"
+ },
+ content: tooltip
+ });
+ }
+ });
+}
+
+Panel.prototype.hotkeyPressed = function(event)
+{
+ code = event.keyCode;
+ if(event.altKey) code = code | 0x100;
+ if(event.ctrlKey) code = code | 0x200;
+ if(event.shiftKey) code = code | 0x400;
+
+ var callback = this.hotkeys[code];
+ if(callback) callback();
+}
+
+Panel.prototype.isHotkey = function(event) {
+ code = event.keyCode;
+ if(event.altKey) code = code | 0x100;
+ if(event.ctrlKey) code = code | 0x200;
+ if(event.shiftKey) code = code | 0x400;
+
+ if(this.hotkeys[code] != null)
+ return true;
+
+ return false;
+}
+
+//
+Panel.prototype.fireEvent = function(name) {
+ $(document).trigger('panel:'+name, this);
+}
+
+function Editor()
+{
+ this.rootDiv = $('#panels');