チェックイン登録/編集画面のインラインスクリプトをcheckin.jsに移動
This commit is contained in:
		
							
								
								
									
										51
									
								
								resources/assets/js/checkin.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								resources/assets/js/checkin.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
function updateTags() {
 | 
			
		||||
    $('input[name=tags]').val(
 | 
			
		||||
        $('#tags')
 | 
			
		||||
            .find('li')
 | 
			
		||||
            .map(function () {
 | 
			
		||||
                return $(this).data('value');
 | 
			
		||||
            })
 | 
			
		||||
            .get()
 | 
			
		||||
            .join(' ')
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function insertTag(value) {
 | 
			
		||||
    $('#tags').append('<li class="list-inline-item badge badge-primary" style="cursor: pointer;" data-value="' + value + '"><span class="oi oi-tag"></span> ' + value + ' | x</li>');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var initTags = $('input[name=tags]').val();
 | 
			
		||||
if (initTags.trim() !== '') {
 | 
			
		||||
    initTags.split(' ').forEach(function (value) {
 | 
			
		||||
        insertTag(value);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$('#tagInput').on('keydown', function (ev) {
 | 
			
		||||
    var $this = $(this);
 | 
			
		||||
    if ($this.val().trim() !== '') {
 | 
			
		||||
        switch (ev.key) {
 | 
			
		||||
            case 'Tab':
 | 
			
		||||
            case 'Enter':
 | 
			
		||||
            case ' ':
 | 
			
		||||
                insertTag($this.val().trim());
 | 
			
		||||
                $this.val('');
 | 
			
		||||
                updateTags();
 | 
			
		||||
                ev.preventDefault();
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    } else if (ev.key === 'Enter') {
 | 
			
		||||
        // 誤爆防止
 | 
			
		||||
        ev.preventDefault();
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$('#tags')
 | 
			
		||||
    .on('click', 'li', function (ev) {
 | 
			
		||||
        $(this).remove();
 | 
			
		||||
        updateTags();
 | 
			
		||||
    })
 | 
			
		||||
    .parent()
 | 
			
		||||
    .on('click', function (ev) {
 | 
			
		||||
        $('#tagInput').focus();
 | 
			
		||||
    });
 | 
			
		||||
@@ -99,54 +99,5 @@
 | 
			
		||||
@endsection
 | 
			
		||||
 | 
			
		||||
@push('script')
 | 
			
		||||
    <script>
 | 
			
		||||
        function updateTags() {
 | 
			
		||||
            $('input[name=tags]').val(
 | 
			
		||||
                $('#tags')
 | 
			
		||||
                    .find('li')
 | 
			
		||||
                    .map(function () {
 | 
			
		||||
                        return $(this).data('value');
 | 
			
		||||
                    })
 | 
			
		||||
                    .get()
 | 
			
		||||
                    .join(' ')
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        function insertTag(value) {
 | 
			
		||||
            $('#tags').append('<li class="list-inline-item badge badge-primary" style="cursor: pointer;" data-value="' + value + '"><span class="oi oi-tag"></span> ' + value + ' | x</li>');
 | 
			
		||||
        }
 | 
			
		||||
        var initTags = $('input[name=tags]').val();
 | 
			
		||||
        if (initTags.trim() !== '') {
 | 
			
		||||
            initTags.split(' ').forEach(function (value) {
 | 
			
		||||
                insertTag(value);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $('#tagInput').on('keydown', function (ev) {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            if ($this.val().trim() !== '') {
 | 
			
		||||
                switch (ev.key) {
 | 
			
		||||
                    case 'Tab':
 | 
			
		||||
                    case 'Enter':
 | 
			
		||||
                    case ' ':
 | 
			
		||||
                        insertTag($this.val().trim());
 | 
			
		||||
                        $this.val('');
 | 
			
		||||
                        updateTags();
 | 
			
		||||
                        ev.preventDefault();
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            } else if (ev.key === 'Enter') {
 | 
			
		||||
                // 誤爆防止
 | 
			
		||||
                ev.preventDefault();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        $('#tags')
 | 
			
		||||
            .on('click', 'li', function (ev) {
 | 
			
		||||
                $(this).remove();
 | 
			
		||||
                updateTags();
 | 
			
		||||
            })
 | 
			
		||||
            .parent()
 | 
			
		||||
            .on('click', function (ev) {
 | 
			
		||||
                $('#tagInput').focus();
 | 
			
		||||
            });
 | 
			
		||||
    </script>
 | 
			
		||||
    <script src="{{ mix('js/checkin.js') }}"></script>
 | 
			
		||||
@endpush
 | 
			
		||||
@@ -100,54 +100,5 @@
 | 
			
		||||
@endsection
 | 
			
		||||
 | 
			
		||||
@push('script')
 | 
			
		||||
    <script>
 | 
			
		||||
        function updateTags() {
 | 
			
		||||
            $('input[name=tags]').val(
 | 
			
		||||
                $('#tags')
 | 
			
		||||
                    .find('li')
 | 
			
		||||
                    .map(function () {
 | 
			
		||||
                        return $(this).data('value');
 | 
			
		||||
                    })
 | 
			
		||||
                    .get()
 | 
			
		||||
                    .join(' ')
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
        function insertTag(value) {
 | 
			
		||||
            $('#tags').append('<li class="list-inline-item badge badge-primary" style="cursor: pointer;" data-value="' + value + '"><span class="oi oi-tag"></span> ' + value + ' | x</li>');
 | 
			
		||||
        }
 | 
			
		||||
        var initTags = $('input[name=tags]').val();
 | 
			
		||||
        if (initTags.trim() !== '') {
 | 
			
		||||
            initTags.split(' ').forEach(function (value) {
 | 
			
		||||
                insertTag(value);
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $('#tagInput').on('keydown', function (ev) {
 | 
			
		||||
            var $this = $(this);
 | 
			
		||||
            if ($this.val().trim() !== '') {
 | 
			
		||||
                switch (ev.key) {
 | 
			
		||||
                    case 'Tab':
 | 
			
		||||
                    case 'Enter':
 | 
			
		||||
                    case ' ':
 | 
			
		||||
                        insertTag($this.val().trim());
 | 
			
		||||
                        $this.val('');
 | 
			
		||||
                        updateTags();
 | 
			
		||||
                        ev.preventDefault();
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
            } else if (ev.key === 'Enter') {
 | 
			
		||||
                // 誤爆防止
 | 
			
		||||
                ev.preventDefault();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        $('#tags')
 | 
			
		||||
            .on('click', 'li', function (ev) {
 | 
			
		||||
                $(this).remove();
 | 
			
		||||
                updateTags();
 | 
			
		||||
            })
 | 
			
		||||
            .parent()
 | 
			
		||||
            .on('click', function (ev) {
 | 
			
		||||
                $('#tagInput').focus();
 | 
			
		||||
            });
 | 
			
		||||
    </script>
 | 
			
		||||
    <script src="{{ mix('js/checkin.js') }}"></script>
 | 
			
		||||
@endpush
 | 
			
		||||
							
								
								
									
										1
									
								
								webpack.mix.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								webpack.mix.js
									
									
									
									
										vendored
									
									
								
							@@ -13,6 +13,7 @@ let mix = require('laravel-mix');
 | 
			
		||||
 | 
			
		||||
mix.js('resources/assets/js/app.js', 'public/js')
 | 
			
		||||
    .js('resources/assets/js/home.js', 'public/js')
 | 
			
		||||
    .js('resources/assets/js/checkin.js', 'public/js')
 | 
			
		||||
    .js('resources/assets/js/user/stats.js', 'public/js/user')
 | 
			
		||||
    .js('resources/assets/js/setting/privacy.js', 'public/js/setting')
 | 
			
		||||
    .sass('resources/assets/sass/app.scss', 'public/css')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user