File manager - Edit - /home/jardides/www/Jardi-design/media/com_jce/editor/pro/js/transform.js
Back
/* jce - 2.9.51 | 2023-10-18 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2023 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */ !function($) { var oldSetOption = $.ui.resizable.prototype._setOption; function getRatio(o) { return o.width / o.height; } $.ui.resizable.prototype._setOption = function(key, value) { oldSetOption.apply(this, arguments), "aspectRatio" === key && (this._aspectRatio = !!value); }, $.widget("ui.resize", { options: { ratio: 4 / 3, width: 800, height: 600 }, _init: function() { var self = this, pos = (this.width = $(this.element).width() || $(this.element).attr("width"), this.height = $(this.element).height() || $(this.element).attr("height"), { left: $(this.element).parent().innerWidth() / 2 - this.width / 2, top: $(this.element).parent().innerHeight() / 2 - this.height / 2 }), ratio = this.getRatio(); $('<div id="resize-container" class="transform-widget"></div>').appendTo($(this.element).parent()).append(this.element).css(pos).resizable({ handles: "all", aspectRatio: getRatio(this.options), containment: "parent", start: function() { self._trigger("start", null); }, resize: function(event, ui) { var ui = ui.element[0], w = Math.round(ui.clientWidth), ui = Math.round(ui.clientHeight); $(self.element).css({ width: w, height: ui }), self._trigger("resize", null, { width: Math.round(ratio.x * w, 1), height: Math.round(ratio.x * ui, 1) }); }, stop: function(event, ui) { self._trigger("stop", null, ui.size); } }).draggable({ containment: "parent" }), $(this.element).css({ top: "", left: "" }), $.support.cssFloat || $("#resize-container").attr("unselectable", "on"), $("div.uk-resizable-handle.uk-resizable-se", "#resize-container").removeClass("uk-icon uk-icon-gripsmall-diagonal-se"); }, _getPosition: function(width, height) { var $parent = $("#resize-container").parent(), width = width || this.width, height = height || this.height; return { left: ($parent.outerWidth() - width) / 2, top: ($parent.outerHeight() - height) / 2 }; }, setSize: function(w, h) { var self = this, $parent = $("#resize-container").parent(), pw = $parent.outerWidth(), ph = $parent.outerHeight(), $parent = this.getRatio(); w = Math.round(w / $parent.x, 1), h = Math.round(h / $parent.y, 1), $(this.element).animate({ width: w, height: h }, { step: function(now, fx) { "width" == fx.prop && $("#resize-container").css("left", (pw - now) / 2), "height" == fx.prop && $("#resize-container").css("top", (ph - now) / 2), $("#resize-container").css(fx.prop, now); }, complete: function() { self._trigger("stop", null); } }); }, setConstrain: function(s) { var ratio = s; s && (ratio = getRatio(s)), this.setRatio(ratio); }, getRatio: function() { return { x: this.options.width / this.width, y: this.options.height / this.height }; }, setRatio: function(ratio) { var r; "undefined" == $.type(ratio) && (ratio = (r = this.getRatio()).x / r.y), $("#resize-container").data("uiResizable") ? $("#resize-container").resizable("option", "aspectRatio", ratio) : this.options.ratio = ratio; }, reset: function() { var pos = this._getPosition(); $("#resize-container").css({ top: pos.top, left: pos.left, width: "", height: "" }), $(this.element).css({ top: "" }), this.setRatio(getRatio(this.options)); }, remove: function() { $("#resize-container").parent().append(this.element), $("#resize-container").remove(), this.destroy(); }, destroy: function() { $.Widget.prototype.destroy.apply(this, arguments); } }), $.widget("ui.rotate", { options: {}, _init: function() { var $parent = $(this.element).parent(); $(this.element).wrap('<div id="rotate-container"></div>'), $("#rotate-container").css({ top: ($parent.height() - $(this.element).height()) / 2, left: ($parent.width() - $(this.element).width()) / 2 }), $.support.cssFloat || $("#rotate-container").attr("unselectable", "on"); }, rotate: function(angle) { var s; switch (angle) { default: s = "scaleY(1) scaleX(1)"; break; case "0": case "90": case "-90": case "180": s = "rotate(" + angle + "deg)"; break; case "vertical": s = "scaleY(-1)"; break; case "horizontal": s = "scaleX(-1)"; break; case "vertical|horizontal": s = "scaleX(-1) scaleY(-1)"; } $(this.element).animate({ transform: s }); }, remove: function() { $(this.element).unwrap(), this.destroy(); }, destroy: function() { $.Widget.prototype.destroy.apply(this, arguments); } }), $.widget("ui.crop", { options: { ratio: 4 / 3, width: 800, height: 600, selection: "", clone: null, handles: "all" }, _init: function() { var self = this, $parent = (this.width = $(this.element).width() || $(this.element).attr("width"), this.height = $(this.element).height() || $(this.element).attr("height"), $(this.element).parent()), top = $(this.element).css("top") || ($parent.outerHeight() - this.height) / 2, $clone = ($(this.element).css({ top: "", left: "" }), this.options.clone ? $(this.options.clone) : $(this.element).clone()), $crop = ($clone.css("top", ""), $('<div id="crop-container"></div>').appendTo($parent).append(this.element).append('<div id="crop-mask"></div>').append('<div id="crop-window"></div>').append('<div id="crop-widget" class="transform-widget"></div>'), $("#crop-window")), $widget = $("#crop-widget"); $crop.append($clone).css({ width: this.width, height: this.height }), $widget.css({ width: this.width, height: this.height }).resizable({ handles: this.options.handles, aspectRatio: this.options.ratio, containment: "#crop-container", start: function(event, ui) { self._trigger("start", null); }, resize: function(event, ui) { var ui = ui.element[0], w = Math.round(ui.clientWidth), h = Math.round(ui.clientHeight); $clone.css({ top: -ui.offsetTop, left: -ui.offsetLeft }), $crop.css({ width: w, height: h, top: ui.offsetTop, left: ui.offsetLeft }), self._trigger("change", null, self.getArea()); }, stop: function() { self._trigger("stop", null, self.getArea()); } }), $("#crop-window, #crop-widget").draggable({ containment: "#crop-container", drag: function(event, ui) { var top = ui.position.top, ui = ui.position.left; $widget.css({ top: top, left: ui }), $crop.css({ top: top, left: ui }), $clone.css({ top: -top, left: -ui }), self._trigger("change", null, self.getArea()); }, stop: function() { self._trigger("stop", null, self.getArea()); } }), $.support.cssFloat || $widget.attr("unselectable", "on"), $("div.uk-resizable-handle.uk-resizable-se", $widget).removeClass("uk-icon uk-icon-gripsmall-diagonal-se"), $('<div id="crop-box"></div>').css({ width: this.width, height: this.height, top: top }).appendTo($parent).append($("#crop-container")), this.options.selection && this.setArea(this.options.selection), $("#crop-widget").on("dblclick", function() { self.reset(), self._trigger("reset", null, self.getArea()); }); }, setConstrain: function(s) { var ratio = s; s && (ratio = getRatio(s), this.setArea(s)), this.setRatio(ratio); }, getRatio: function() { return { x: this.width / this.options.width, y: this.height / this.options.height }; }, setRatio: function(ratio) { $("#crop-widget").resizable("option", "aspectRatio", ratio); }, setArea: function(o, update) { var key, self = this, r = this.getRatio(), o = { left: Math.round(o.x * r.x, 1), top: Math.round(o.y * r.y, 1), width: Math.round(o.width * r.x, 1), height: Math.round(o.height * r.y, 1) }, data = this._calculateSelection(o, { width: this.width, height: this.height }); for (key in data) Number.isNaN(data[key]) && (data[key] = 0); $("#crop-widget, #crop-window").animate(data, { step: function(now, fx) { "crop-window" != fx.elem.id || "left" != fx.prop && "top" != fx.prop || $(fx.elem).children("img, canvas").css(fx.prop, 0 - now), update && self._trigger("change", null, { x: Math.round(data.left / r.x, 1), y: Math.round(data.top / r.y, 1), width: Math.round(data.width / r.x, 1), height: Math.round(data.height / r.y, 1) }); }, complete: function() { update && self._trigger("stop", null, { x: Math.round(data.left / r.x, 1), y: Math.round(data.top / r.y, 1), width: Math.round(data.width / r.x, 1), height: Math.round(data.height / r.y, 1) }); } }); }, getDimensions: function() { return { width: $("#crop-container").width(), height: $("#crop-container").height() }; }, _calculateSelection: function(dim, img) { var x = parseInt(dim.left), y = parseInt(dim.top), w = parseInt(dim.width), dim = parseInt(dim.height), w = Math.min(w, this.options.width), dim = Math.min(dim, this.options.height); return Number.isNaN(x) ? w <= img.width && (x = Math.floor((img.width - w) / 2)) : x + w > img.width && (w = img.width - x), Number.isNaN(y) ? dim <= img.height && (y = Math.floor((img.height - dim) / 2)) : y + dim > img.height && (dim = img.height - y), w = Math.min(w, Math.floor(img.width)), dim = Math.min(dim, Math.floor(img.height)), { left: Math.max(0, x), top: Math.max(0, y), width: w, height: dim }; }, getArea: function() { var n = $("#crop-window").get(0), r = this.getRatio(); return { x: Math.round(n.offsetLeft / r.x, 1), y: Math.round(n.offsetTop / r.y, 1), width: Math.round(n.clientWidth / r.x, 1), height: Math.round(n.clientHeight / r.y, 1) }; }, reset: function() { $("#crop-widget, #crop-window").css({ width: this.width, height: this.height, left: 0, top: 0 }), $("#crop-window").children().css({ left: 0, top: 0 }); var ratio = this.width / this.height; this.setRatio(ratio); }, remove: function() { var $parent = $("#crop-container").parent(); $(this.element).css("top", $parent.css("top")).appendTo($parent.parent()), $parent.remove(), this.destroy(); }, destroy: function() { $.Widget.prototype.destroy.apply(this, arguments); } }); }(jQuery);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings