PANmedia / raptor-editor

Raptor, an HTML5 WYSIWYG content editor!
www.raptor-editor.com
GNU General Public License v3.0
533 stars 136 forks source link

Raptor.reisterUI(new Button(...)) Uncaught ReferenceError: Button is not defined #174

Open yannick9906 opened 9 years ago

yannick9906 commented 9 years ago

I have tried to add a new button and I got this error. I used the Raptor Version with Expose API methods activated.

Here's my HTML Code:

                <link type="text/css" rel="stylesheet" href="raptor/raptor-front-end.css" />
                <script src="raptor/libraries/jquery.js"></script>
                <script src="raptor/libraries/jquery-ui.js"></script>
                <script src="raptor/raptor.min.js"></script>
                <script>
                    function a() {
                        document.addEventListener('keydown', function(e){
                            /*console.log('keydown');*/
                            var keys = [];
                            if(e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) {
                                if(e.metaKey) {
                                    keys.push('Cmd');
                                }
                                if(e.shiftKey) {
                                    keys.push('Shift');
                                }
                                if(e.ctrlKey) {
                                    keys.push('Ctrl');
                                }
                                if(e.altKey) {
                                    keys.push('Alt');
                                }
                            }
                            if(e.which) {
                                /*console.log(e.which);*/
                                keys.push(String.fromCharCode(e.which));
                            }
                            /*console.log(keys.join('+'));*/
                            if(keys.length >= 2 && keys[keys.length-1] != '') {
                                window.postMessage({type: 'dolphin_shortcuts', keys:keys}, '*');
                            }
                        });
                    }a();
                </script>
                <script>
                    window.oncontextmenu = function(event) {
                        var target = event.target.getAttribute('obj_url');
                        window.postMessage({type: 'dolphin_clickTarget', target:target}, '*');
                    };
                </script>
                <script src="raptor/buttons.js"></script>
                <script>
                      $('.editable').raptor({
                        layouts: {
                            toolbar: {
                                uiOrder: [
                                    ['cancel', 'Freigeben']
                                ]
                            },
                            hoverPanel: {
                                uiOrder: [
                                    ['clickButtonToEdit']
                                ]
                            },
                        }
                    });
                </script>

and the code of "buttons.js"

Raptor.registerUi(new Button({
    name: 'Freigeben',

    action: function() {
        alert('Freigegeben');
    }
}));

I Hope you can help me - Google couldn't.

Petah commented 9 years ago

Sorry, what error did you get? I can't see a error message in the above.

yannick9906 commented 9 years ago

I got this error like in the title: Uncaught ReferenceError: Button is not defined(buttons.js:1)

Petah commented 9 years ago

Oh, sorry.

Try Raptor.Button

yannick9906 commented 9 years ago

The Error now disappeared, but I can't see the button anywhere in the UI