Server IP : 202.29.229.35 / Your IP : 3.145.90.123 Web Server : Apache System : Linux aapanel2 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 User : www ( 1001) PHP Version : 5.5.38 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.ivecr2.ac.th/stdcard/cropper/docs/js/ |
Upload File : |
$(function () { 'use strict'; var console = window.console || { log: function () {} }, $alert = $('.docs-alert'), $message = $alert.find('.message'), showMessage = function (message, type) { $message.text(message); if (type) { $message.addClass(type); } $alert.fadeIn(); setTimeout(function () { $alert.fadeOut(); }, 3000); }; $.fn.cropper.setDefaults({ minContainerWidth: 160, minContainerHeight: 90 }); // Demo // ------------------------------------------------------------------------- (function () { var $image = $('.img-container > img'), $dataX = $('#dataX'), $dataY = $('#dataY'), $dataHeight = $('#dataHeight'), $dataWidth = $('#dataWidth'), $dataRotate = $('#dataRotate'), options = { aspectRatio: 16 / 9, preview: '.img-preview', crop: function (data) { $dataX.val(Math.round(data.x)); $dataY.val(Math.round(data.y)); $dataHeight.val(Math.round(data.height)); $dataWidth.val(Math.round(data.width)); $dataRotate.val(Math.round(data.rotate)); } }; $image.on({ 'build.cropper': function (e) { console.log(e.type); }, 'built.cropper': function (e) { console.log(e.type); } }).cropper(options); // Methods $(document.body).on('click', '[data-method]', function () { var data = $(this).data(), $target, result; if (data.method) { data = $.extend({}, data); // Clone a new one if (typeof data.target !== 'undefined') { $target = $(data.target); if (typeof data.option === 'undefined') { try { data.option = JSON.parse($target.val()); } catch (e) { console.log(e.message); } } } result = $image.cropper(data.method, data.option); if (data.method === 'getDataURL') { $('#getDataURLModal').modal().find('.modal-body').html('<img src="' + result + '">'); } if ($.isPlainObject(result) && $target) { try { $target.val(JSON.stringify(result)); } catch (e) { console.log(e.message); } } } }).on('keydown', function (e) { if (this.scrollTop > 300) { return; } switch (e.which) { case 37: e.preventDefault(); $image.cropper('move', -1, 0); break; case 38: e.preventDefault(); $image.cropper('move', 0, -1); break; case 39: e.preventDefault(); $image.cropper('move', 1, 0); break; case 40: e.preventDefault(); $image.cropper('move', 0, 1); break; } }); // Import image var $inputImage = $('#inputImage'), URL = window.URL || window.webkitURL, blobURL; if (URL) { $inputImage.change(function () { var files = this.files, file; if (files && files.length) { file = files[0]; if (/^image\/\w+$/.test(file.type)) { blobURL = URL.createObjectURL(file); $image.one('built.cropper', function () { URL.revokeObjectURL(blobURL); // Revoke when load complete }).cropper('reset', true).cropper('replace', blobURL); $inputImage.val(''); } else { showMessage('Please choose an image file.'); } } }); } else { $inputImage.parent().remove(); } // Options $('.docs-options :checkbox').on('change', function () { var $this = $(this); options[$this.val()] = $this.prop('checked'); $image.cropper('destroy').cropper(options); }); // Tooltips $('[data-toggle="tooltip"]').tooltip(); }()); // Examples // ------------------------------------------------------------------------- // Example 1 (function () { $('.cropper-example-1 > img').cropper({ aspectRatio: 16 / 9, autoCropArea: 0.5, guides: false, highlight: false, dragCrop: false, movable: false, resizable: false }); })(); // Example 2 (function () { var $image = $('#cropper-example-2 > img'), imageData, cropBoxData; $('#cropper-example-2-modal').on('shown.bs.modal', function () { $image.cropper({ global: false, built: function () { $image.cropper('setImageData', imageData); $image.cropper('setCropBoxData', cropBoxData); } }); }).on('hidden.bs.modal', function () { imageData = $image.cropper('getImageData'); cropBoxData = $image.cropper('getCropBoxData'); $image.cropper('destroy'); }); })(); });