barryvdh / laravel-elfinder

elFinder bundle for Laravel
741 stars 171 forks source link

standalonepopup.js and hardcoded elfinderUrl with different route prefix in config/elfinder.php #128

Open dbr0 opened 8 years ago

dbr0 commented 8 years ago

Hi, first of all thanks for this great piece of code.

I'm using the elfinder in my Larvel app with ckeditor and all is working fine. I need to fine tune it some more but for the amount of energy I put into it I think its ok.

I'm having "problem" using elfinder in standalone popup with colorbox. It's all working good but I have changed my default route prefix in myapp\config\elfinder.php from elfinder to some-other-prefix. The problem arises because in the standalonepopup.js the elfinder url is defined as var elfinderUrl = '/elfinder/popup/'; so I need to manually change this to var elfinderUrl = '/some-other-prefix/popup/';. And now I have to manually change it every time that file updates (and if I'm getting this thing right this will happen whenever I update composer).

gzai commented 8 years ago

I change a little source code standalonepopup

in my view when using standalonepopup

        <script type="text/javascript">
                    var elfinderUrl = "{{ route('elfinder.popup', ['thumbnail']) }}";
        </script>
        <script type='text/javascript' src='{{ asset('packages/barryvdh/elfinder/js/standalonepopup.js') }}'></script>

in standalonepopup.js if view set to publish

        $(document).on('click','.popup_selector',function (event) {
                    event.preventDefault();
                    // var triggerUrl = elfinderUrl + updateID;
                    var triggerUrl = ( typeof elfinderUrl !== 'undefined' ) ? elfinderUrl : '';

                    $.colorbox({
                                open: true,
                                href: triggerUrl,
                                fastIframe: true,
                                iframe: true,
                                width: '70%',
                                height: '50%',
                   });

                    $(window).resize(function () {
                                $(".colorbox").colorbox.resize({
                                            width: "70%",
                                            height: "50%"
                                });
                    });

        });