1 define([
'jquery',
'jquery-cropper/jquery-cropper'],
function($) {
11 this.init =
function(selector) {
13 $fieldWrapper = $field.closest(
'.elgg-field');
14 $imgWrapper = $fieldWrapper.siblings(
'.elgg-entity-edit-icon-crop-wrapper');
15 $img = $imgWrapper.find(
'> img').eq(0);
16 $inputWrapper = $fieldWrapper.siblings(
'.elgg-entity-edit-icon-crop-input').eq(0);
18 $messagesWrapper = $fieldWrapper.siblings(
'.elgg-entity-edit-icon-crop-messages');
21 $(document).
on(
'change', selector, this.replaceImg);
23 var $remove = $fieldWrapper.siblings(
'.elgg-entity-edit-icon-remove').find(
'input[type="checkbox"]');
24 $remove.on(
'change', this.checkRemoveState);
26 if ($img[0].hasAttribute(
'src')) {
30 $img.on(
'ready',
function() {
32 if ($field.not(
':visible')) {
33 $field.data(
'resetNeeded',
true);
36 $field.parents(
'.elgg-tabs-component').find(
' > .elgg-body > .elgg-menu-navigation-tabs-container > ul > li').on(
'open',
function() {
37 if ($field.is(
':visible')) {
38 $img.cropper(
'enable');
39 $img.cropper(
'resize');
41 if ($field.data(
'resetNeeded')) {
42 $img.cropper(
'reset');
45 $field.data(
'resetNeeded',
false);
48 $img.cropper(
'disable');
54 this.replaceImg =
function() {
55 var oFReader =
new FileReader();
56 oFReader.readAsDataURL(this.
files[0]);
59 $imgWrapper.addClass(
'hidden');
60 $img.off(
'crop.iconCropper');
61 $img.cropper(
'destroy');
64 var data = $img.data().iconCropper;
65 data.aspectRatio = data.initialAspectRatio;
70 oFReader.onload =
function (oFREvent) {
71 var image =
new Image();
72 image.src = this.result;
74 image.onload =
function(imageEvent) {
75 $img.attr(
'src', this.src);
77 $inputWrapper.find(
'input[name="_entity_edit_icon_crop_guid"], input[name="_entity_edit_icon_crop_type"], input[name="_entity_edit_icon_crop_name"]').remove();
86 this.reload =
function(extra_data) {
87 extra_data = extra_data || {};
89 $imgWrapper.removeClass(
'hidden');
91 var data = $img.data().iconCropper;
92 $.extend(data, extra_data);
95 $img.on(
'crop.iconCropper', this.crop);
98 this.crop =
function(event) {
99 var cropDetails = $img.cropper(
'getData',
true);
101 that.resetMessages();
103 var minWidth = $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-width').data(
'minWidth');
104 if (minWidth > 0 && cropDetails.width < minWidth) {
105 that.showMessage(
'width');
108 var minHeight = $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-height').data(
'minHeight');
109 if (minHeight > 0 && cropDetails.height < minHeight) {
110 that.showMessage(
'height');
113 $inputWrapper.find(
'input[name$="x1"]').val(cropDetails.x);
114 $inputWrapper.find(
'input[name$="y1"]').val(cropDetails.y);
115 $inputWrapper.find(
'input[name$="x2"]').val(cropDetails.x + cropDetails.width);
116 $inputWrapper.find(
'input[name$="y2"]').val(cropDetails.y + cropDetails.height);
119 this.resetMessages =
function() {
120 if (!$messagesWrapper.length) {
124 $messagesWrapper.addClass(
'hidden');
125 $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-generic').addClass(
'hidden');
126 $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-width').addClass(
'hidden');
127 $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-height').addClass(
'hidden');
130 this.showMessage =
function(message_type) {
131 if ($.inArray(message_type, [
'width',
'height']) < 0) {
135 if (!$messagesWrapper.length) {
139 $messagesWrapper.removeClass(
'hidden');
140 $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-generic').removeClass(
'hidden');
141 $messagesWrapper.find(
'.elgg-entity-edit-icon-crop-error-' + message_type).removeClass(
'hidden');
144 this.show =
function() {
145 $fieldWrapper.removeClass(
'hidden');
147 $img.trigger(
'crop.iconCropper');
150 this.hide =
function() {
151 $fieldWrapper.addClass(
'hidden');
152 $imgWrapper.addClass(
'hidden');
153 this.resetMessages();
156 this.checkRemoveState =
function() {
157 if ($(
this).is(
':checked')) {
define(['jquery', 'jquery-cropper/jquery-cropper'], function($){function Cropper(){var $field;var $fieldWrapper;var $img;var $imgWrapper;var $inputWrapper;var $messagesWrapper;var that=this;this.init=function(selector){$field=$(selector);$fieldWrapper=$field.closest('.elgg-field');$imgWrapper=$fieldWrapper.siblings('.elgg-entity-edit-icon-crop-wrapper');$img=$imgWrapper.find('> img').eq(0);$inputWrapper=$fieldWrapper.siblings('.elgg-entity-edit-icon-crop-input').eq(0);$messagesWrapper=$fieldWrapper.siblings('.elgg-entity-edit-icon-crop-messages');$(document).on('change', selector, this.replaceImg);var $remove=$fieldWrapper.siblings('.elgg-entity-edit-icon-remove').find('input[type="checkbox"]');$remove.on('change', this.checkRemoveState);if($img[0].hasAttribute('src')){this.reload();}$img.on('ready', function(){if($field.not(':visible')){$field.data('resetNeeded', true);}$field.parents('.elgg-tabs-component').find(' >.elgg-body >.elgg-menu-navigation-tabs-container > ul > li').on('open', function(){if($field.is(':visible')){$img.cropper('enable');$img.cropper('resize');if($field.data('resetNeeded')){$img.cropper('reset');$field.data('resetNeeded', false);}}else{$img.cropper('disable');}});});};this.replaceImg=function(){var oFReader=new FileReader();oFReader.readAsDataURL(this.files[0]);$imgWrapper.addClass('hidden');$img.off('crop.iconCropper');$img.cropper('destroy');$img.attr('src', '');var data=$img.data().iconCropper;data.aspectRatio=data.initialAspectRatio;that.resetMessages();oFReader.onload=function(oFREvent){var image=new Image();image.src=this.result;image.onload=function(imageEvent){$img.attr('src', this.src);$inputWrapper.find('input[name="_entity_edit_icon_crop_guid"], input[name="_entity_edit_icon_crop_type"], input[name="_entity_edit_icon_crop_name"]').remove();that.reload({data:{}});};};};this.reload=function(extra_data){extra_data=extra_data||{};$imgWrapper.removeClass('hidden');var data=$img.data().iconCropper;$.extend(data, extra_data);$img.cropper(data);$img.on('crop.iconCropper', this.crop);};this.crop=function(event){var cropDetails=$img.cropper('getData', true);that.resetMessages();var minWidth=$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-width').data('minWidth');if(minWidth > 0 &&cropDetails.width< minWidth){that.showMessage('width');}var minHeight=$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-height').data('minHeight');if(minHeight > 0 &&cropDetails.height< minHeight){that.showMessage('height');}$inputWrapper.find('input[name $="x1"]').val(cropDetails.x);$inputWrapper.find('input[name $="y1"]').val(cropDetails.y);$inputWrapper.find('input[name $="x2"]').val(cropDetails.x+cropDetails.width);$inputWrapper.find('input[name $="y2"]').val(cropDetails.y+cropDetails.height);};this.resetMessages=function(){if(!$messagesWrapper.length){return;}$messagesWrapper.addClass('hidden');$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-generic').addClass('hidden');$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-width').addClass('hidden');$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-height').addClass('hidden');};this.showMessage=function(message_type){if($.inArray(message_type, ['width', 'height'])< 0){return;}if(!$messagesWrapper.length){return;}$messagesWrapper.removeClass('hidden');$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-generic').removeClass('hidden');$messagesWrapper.find('.elgg-entity-edit-icon-crop-error-'+message_type).removeClass('hidden');};this.show=function(){$fieldWrapper.removeClass('hidden');this.reload();$img.trigger('crop.iconCropper');};this.hide=function(){$fieldWrapper.addClass('hidden');$imgWrapper.addClass('hidden');this.resetMessages();};this.checkRemoveState=function(){if($(this).is(':checked')){that.hide();}else{that.show();}};};return Cropper;})
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition files
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on
if($entity instanceof ElggEntity &&$entity->hasIcon('master', $icon_type)) if(isset($cropper_data['existingAspectRatio'], $cropper_data['aspectRatio'])) $img