diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-17 13:39:33 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:28 +0200 | 
| commit | a659ad9c711c3d9d1692aa9bb2c169db0d0d641d (patch) | |
| tree | 47ae4ee549248cb393d1eac1f07462189606ace4 | |
| parent | 761d509b87553cdd5f02b53c4db2ede94569c561 (diff) | |
| download | Ishtar-a659ad9c711c3d9d1692aa9bb2c169db0d0d641d.tar.bz2 Ishtar-a659ad9c711c3d9d1692aa9bb2c169db0d0d641d.zip | |
Add jquery-resizable lib
| -rw-r--r-- | ishtar_common/static/js/jquery-resizable.js | 194 | ||||
| -rw-r--r-- | ishtar_common/templates/base.html | 1 | 
2 files changed, 195 insertions, 0 deletions
| diff --git a/ishtar_common/static/js/jquery-resizable.js b/ishtar_common/static/js/jquery-resizable.js new file mode 100644 index 000000000..9f2fd7a70 --- /dev/null +++ b/ishtar_common/static/js/jquery-resizable.js @@ -0,0 +1,194 @@ +/// <reference path="../bower_components/jquery/dist/jquery.js" /> +/* +jquery-resizable +Version 0.32 - 5/5/2018 +© 2015-2018 Rick Strahl, West Wind Technologies +www.west-wind.com +Licensed under MIT License +*/ +(function(factory, undefined) { +	if (typeof define === 'function' && define.amd) { +		// AMD +		define(['jquery'], factory); +	} else if (typeof module === 'object' && typeof module.exports === 'object') { +		// CommonJS +		module.exports = factory(require('jquery')); +	} else { +		// Global jQuery +		factory(jQuery); +	} +}(function($, undefined) { +     +    // do not use jquery ui resize +    /* if ($.fn.resizable) return; */ + +    $.fn.resizable = function fnResizable(options) { +        var defaultOptions = { +            // selector for handle that starts dragging +            handleSelector: null, +            // resize the width +            resizeWidth: true, +            // resize the height +            resizeHeight: true, +            // the side that the width resizing is relative to +            resizeWidthFrom: 'right', +            // the side that the height resizing is relative to +            resizeHeightFrom: 'bottom', +            // hook into start drag operation (event passed) +            onDragStart: null, +            // hook into stop drag operation (event passed) +            onDragEnd: null, +            // hook into each drag operation (event passed) +            onDrag: null, +            // disable touch-action on $handle +            // prevents browser level actions like forward back gestures +            touchActionNone: true, +            // instance id +            instanceId: null +    }; +        if (typeof options == "object") +            defaultOptions = $.extend(defaultOptions, options); + +        return this.each(function () { +            var opt = $.extend({}, defaultOptions); +            if (!opt.instanceId) +                opt.instanceId = "rsz_" + new Date().getTime();             + +            var startPos, startTransition; + +            // get the element to resize  +            var $el = $(this); +            var $handle; + +            if (options === 'destroy') {             +                opt = $el.data('resizable'); +                if (!opt) +                    return; + +                $handle = getHandle(opt.handleSelector, $el); +                $handle.off("mousedown." + opt.instanceId + " touchstart." + opt.instanceId); +                if (opt.touchActionNone) +                    $handle.css("touch-action", ""); +                $el.removeClass("resizable"); +                return; +            } +           +            $el.data('resizable', opt); + +            // get the drag handle + +            $handle = getHandle(opt.handleSelector, $el); + +            if (opt.touchActionNone) +                $handle.css("touch-action", "none"); + +            $el.addClass("resizable"); +            $handle.on("mousedown." + opt.instanceId + " touchstart." + opt.instanceId, startDragging); + +            function noop(e) { +                e.stopPropagation(); +                e.preventDefault(); +            }; + +            function startDragging(e) { +                // Prevent dragging a ghost image in HTML5 / Firefox and maybe others     +                if ( e.preventDefault ) { +                  e.preventDefault(); +                } +                 +                startPos = getMousePos(e); +                startPos.width = parseInt($el.width(), 10); +                startPos.height = parseInt($el.height(), 10); + +                startTransition = $el.css("transition"); +                $el.css("transition", "none"); + +                if (opt.onDragStart) { +                    if (opt.onDragStart(e, $el, opt) === false) +                        return; +                } +                 +                $(document).on('mousemove.' + opt.instanceId, doDrag); +                $(document).on('mouseup.' + opt.instanceId, stopDragging); +                if (window.Touch || navigator.maxTouchPoints) { +                    $(document).on('touchmove.' + opt.instanceId, doDrag); +                    $(document).on('touchend.' + opt.instanceId, stopDragging); +                } +                $(document).on('selectstart.' + opt.instanceId, noop); // disable selection +                $("iframe").css("pointer-events","none"); +            } + +            function doDrag(e) { +                 +                var pos = getMousePos(e), newWidth, newHeight; + +                if (opt.resizeWidthFrom === 'left') +                    newWidth = startPos.width - pos.x + startPos.x; +                else +                    newWidth = startPos.width + pos.x - startPos.x; + +                if (opt.resizeHeightFrom === 'top') +                    newHeight = startPos.height - pos.y + startPos.y; +                else +                    newHeight = startPos.height + pos.y - startPos.y; + +                if (!opt.onDrag || opt.onDrag(e, $el, newWidth, newHeight, opt) !== false) { +                    if (opt.resizeHeight) +                        $el.height(newHeight);                     + +                    if (opt.resizeWidth) +                        $el.width(newWidth);                     +                } +            } + +            function stopDragging(e) { +                e.stopPropagation(); +                e.preventDefault(); + +                $(document).off('mousemove.' + opt.instanceId); +                $(document).off('mouseup.' + opt.instanceId); + +                if (window.Touch || navigator.maxTouchPoints) { +                    $(document).off('touchmove.' + opt.instanceId); +                    $(document).off('touchend.' + opt.instanceId); +                } +                $(document).off('selectstart.' + opt.instanceId, noop);                 + +                // reset changed values +                $el.css("transition", startTransition); +                $("iframe").css("pointer-events","auto"); + +                if (opt.onDragEnd) +                    opt.onDragEnd(e, $el, opt); + +                return false; +            } + +            function getMousePos(e) { +                var pos = { x: 0, y: 0, width: 0, height: 0 }; +                if (typeof e.clientX === "number") { +                    pos.x = e.clientX; +                    pos.y = e.clientY; +                } else if (e.originalEvent.touches) { +                    pos.x = e.originalEvent.touches[0].clientX; +                    pos.y = e.originalEvent.touches[0].clientY; +                } else +                    return null; + +                return pos; +            } + +            function getHandle(selector, $el) { +                if (selector && selector.trim()[0] === ">") { +                    selector = selector.trim().replace(/^>\s*/, ""); +                    return $el.find(selector); +                } + +                // Search for the selector, but only in the parent element to limit the scope +                // This works for multiple objects on a page (using .class syntax most likely) +                // as long as each has a separate parent container.  +                return selector ? $el.parent().find(selector) : $el; +            }  +        }); +    }; +})); diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index f88f1eba6..aec214238 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -43,6 +43,7 @@      <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.pieRenderer.min.js?ver={{VERSION}}"></script>      <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.dateAxisRenderer.min.js?ver={{VERSION}}"></script>      <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jqplot/plugins/jqplot.cursor.min.js?ver={{VERSION}}"></script> +    <script language="javascript" type="text/javascript" src="{{STATIC_URL}}js/jquery-resizable.js?ver={{VERSION}}"></script>      {{EXTRA_JS|safe}}      <script type='text/javascript'>      var static_path = "{{STATIC_URL}}"; | 
