Skip to content

Commit

Permalink
Cleaning (crop)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Oct 7, 2015
1 parent bf27702 commit 4430dd7
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 329 deletions.
3 changes: 0 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ module.exports = function(grunt) {
'resources/assets/bower_components/mirrormark/dist/js/mirrormark.package.js',
// Upload
'resources/assets/bower_components/dropzone/dist/dropzone.js',
// Image crop
//'resources/assets/bower_components/imgareaselect/jquery.imgareaselect.dev.js',
// Sharp
'resources/assets/js/sharp.form.js',
'resources/assets/js/sharp.date.js',
Expand All @@ -41,7 +39,6 @@ module.exports = function(grunt) {
'resources/assets/js/sharp.ref.js',
'resources/assets/js/sharp.refSublistItem.js',
'resources/assets/js/sharp.upload.js',
'resources/assets/js/sharp.imagecrop.js',
'resources/assets/js/sharp.customSearch.js',
'resources/assets/js/sharp.list.js'
],
Expand Down
148 changes: 0 additions & 148 deletions resources/assets/js/sharp.imagecrop.js

This file was deleted.

15 changes: 5 additions & 10 deletions resources/assets/js/sharp.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,14 @@ $(window).load(function () {

});

function activate($source, jsonData) {
$source.parents(".state").removeClass("state-inactive").addClass("state-active");
}

function deactivate($source, jsonData) {
$source.parents(".state").removeClass("state-active").addClass("state-inactive");
}

var $pageOverlay = null;
var $body = $("body");
var $pageOverlay = null;

function showPageOverlay() {
if(!$pageOverlay) {
$pageOverlay = $("<div>").addClass("sharp-page-overlay hidden");
$pageOverlay = $("<div>")
.addClass("sharp-page-overlay hidden")
.append('<i class="fa fa-cog fa-spin"></i>');
$body.append($pageOverlay);
}
$pageOverlay.removeClass("hidden");
Expand Down
7 changes: 7 additions & 0 deletions resources/assets/less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ body.sharp-auth {
bottom: 0;
z-index: 9998;
position: fixed;
text-align: center;

i {
color: #fff;
margin-top: 30%;
font-size: 140px;
}
}

@import "header.less";
Expand Down
6 changes: 6 additions & 0 deletions resources/assets/sharp.css
Original file line number Diff line number Diff line change
Expand Up @@ -8618,6 +8618,12 @@ body.sharp-auth {
bottom: 0;
z-index: 9998;
position: fixed;
text-align: center;
}
.sharp-page-overlay i {
color: #fff;
margin-top: 30%;
font-size: 140px;
}
#sharp header {
background-color: #2f353b;
Expand Down
149 changes: 1 addition & 148 deletions resources/assets/sharp.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -29267,154 +29267,7 @@ function createSharpFile($el) {

$el.sharp_file(params);
}
;(function($)
{
$.fn.sharp_fileCrop = function (options)
{

var defauts = {
ratio: ''
};

var params = $.extend(defauts, options);

return this.each(function()
{
var id = Math.round(new Date().getTime() + (Math.random() * 100));

var $glassPane = $(".crop-img-glasspane");
if(!$glassPane.length)
{
$glassPane = $("<div>").addClass("crop-img-glasspane");
$("body").append($glassPane);
}

$(this).parents(".sharp-file").attr("id", "sharp_filetag_"+id);

var $wrapper = $("<div>").addClass("crop-img-wrapper");
var $imgCrop = $("<img>");

var $btnCrop = $('<a>')
.addClass("btn btn-crop")
.html('<i class="fa fa-check"></i>')
.data("filetagid", id);

$btnCrop.click(function() {
var selection = ias.getSelection();
var imgWidth = $imgCrop.width();
var imgHeight = $imgCrop.height();
var x1 = selection.x1 / imgWidth;
var y1 = selection.y1 / imgHeight;
var x2 = selection.x2 / imgWidth;
var y2 = selection.y2 / imgHeight;

var $sharpFileTag = $("#sharp_filetag_"+$(this).data("filetagid"));
var $thumbnail = $sharpFileTag.find(".sharp-file-thumbnail");
var $hiddenCropField = $sharpFileTag.find(".sharp-file-crop-values");

$hiddenCropField.val(x1+","+y1+","+x2+","+y2);

var $thumbCropMask = $thumbnail.parent().find(".sharp-file-crop-mask");
if(!$thumbCropMask.length)
{
$thumbCropMask = $("<div>").addClass("sharp-file-crop-mask");
$thumbnail.before($thumbCropMask);
}

var wThumb = $thumbnail.width();
var hThumb = $thumbnail.height();

$thumbCropMask.css({
top: y1*hThumb,
left: x1*wThumb,
right: wThumb-x2*wThumb,
bottom: hThumb-y2*hThumb
});

$thumbCropMask.show();

hide();
});

var $btnBack = $('<a>')
.addClass("btn btn-back")
.html('<i class="fa fa-arrow-left"></i>');
$btnBack.click(function() {
hide();
});

var $btnCancel = $('<a>')
.addClass("btn btn-cancel")
.html('<i class="fa fa-times"></i>')
.data("filetagid", id);
$btnCancel.click(function() {
var $sharpFileTag = $("#sharp_filetag_"+$(this).data("filetagid"));
var $hiddenCropField = $sharpFileTag.find(".sharp-file-crop-values");
$hiddenCropField.val('');

var $thumbCropMask = $sharpFileTag.find(".sharp-file-crop-mask");
if($thumbCropMask.length) $thumbCropMask.remove();

hide();
});


$wrapper.append($imgCrop);
$wrapper.append($btnCrop);
$wrapper.append($btnCancel);
$wrapper.append($btnBack);

$("body").append($wrapper);

$imgCrop.imgAreaSelect({
handles: true,
parent: '.crop-img-wrapper',
aspectRatio: params.ratio
});

var ias = $imgCrop.imgAreaSelect({ instance: true });

var $link = $(this);

$link.click(function(e) {
e.preventDefault();

$glassPane.show();
$imgCrop.attr("src", $link.attr("href"));
$wrapper.show();

ias.update();
});

function hide()
{
$wrapper.hide();
$glassPane.hide();
}

});

}

})(jQuery);

$(window).load(function() {

$('.sharp-file .sharp-file-crop').each(function() {

createSharpFileCrop($(this));

});

});

function createSharpFileCrop($el)
{
var params = {};
if($el.data("ratio") != undefined) params.ratio= $el.data("ratio");

$el.sharp_fileCrop(params);
};(function ($) {
;(function ($) {
$.fn.sharp_customSearch = function (options) {
var defauts = {
minchar: 0
Expand Down
4 changes: 2 additions & 2 deletions resources/assets/sharp.form.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/assets/sharp.min.css

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions resources/assets/sharp.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -12544,19 +12544,14 @@ module.exports = eventmap;

});

function activate($source, jsonData) {
$source.parents(".state").removeClass("state-inactive").addClass("state-active");
}

function deactivate($source, jsonData) {
$source.parents(".state").removeClass("state-active").addClass("state-inactive");
}

var $pageOverlay = null;
var $body = $("body");
var $pageOverlay = null;

function showPageOverlay() {
if(!$pageOverlay) {
$pageOverlay = $("<div>").addClass("sharp-page-overlay hidden");
$pageOverlay = $("<div>")
.addClass("sharp-page-overlay hidden")
.append('<i class="fa fa-cog fa-spin"></i>');
$body.append($pageOverlay);
}
$pageOverlay.removeClass("hidden");
Expand Down
Loading

0 comments on commit 4430dd7

Please sign in to comment.