Changeset 605 for CMESS/mediaplayer/branches
- Timestamp:
- 22.06.2009 08:33:40 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CMESS/mediaplayer/branches/3.1/com/zms/mediaplayer/mediaplayer.metaobj.xml
r588 r605 2688 2688 <item type="dictionary"><dictionary> 2689 2689 <item key="custom"> 2690 <data content_type="application/x-javascript" filename="import.js" type="file">7661722074656d705f6e6f745f617661696c61626c65203d20276e6f7420617661696c61626c65273b0d0a0d0a66756e6374696f6e20636865636b4974656d28246f626a290d0a7b0d0a0969662028246f626a2e617474722827636c61737327292e696e6465784f662827696d706f72745f66696c652729203e202d31290d0a0909246f626a203d20246f626a2e706172656e747328272e696d706f72745f6f626a65637427292e65712830293b0d0a0d0a0969662028246f626a2e617474722827636c61737327292e696e6465784f662827696d706f72745f6f626a6563742729203e202d31290d0a097b0d0a09097661722074656d705f66696c6573203d20246f626a2e6368696c6472656e28272e696d706f72745f66696c653a6c7428332927293b0d0a09090d0a090974656d705f66696c65732e656163682866756e6374696f6e28696e6465782c206f626a290d0a0909097b0d0a0909090976617220246f626a203d2024286f626a293b0d0a090909090d0a0909090969662028246f626a2e6368696c6472656e28277370616e27292e65712830292e746578742829203d3d2074656d705f6e6f745f617661696c61626c65290d0a090909097b0d0a0909090909246f626a2e647261676761626c65282764697361626c6527293b0d0a0909090909246f626a2e64726f707061626c652827656e61626c6527293b0d0a090909097d0d0a09090909656c73650d0a090909097b0d0a0909090909246f626a2e647261676761626c652827656e61626c6527293b0d0a0909090909246f626a2e64726f707061626c65282764697361626c6527293b0d0a090909097d0d0a0909097d293b0d0a0909090d0a09096966202874656d705f66696c65732e6c656e677468203d3d20246f626a2e6368696c6472656e28272e75692d647261676761626c652d64697361626c656427292e6c656e677468290d0a09097b0d0a090909246f626a2e647261676761626c65282764657374726f7927293b0d0a09090964656c6574654974656d28246f626a2e706172656e747328276c692729293b0d0a09097d0d0a097d0d0a7d0d0a0d0a66756e6374696f6e20636f707946696c656e616d65546f547261736828246f626a290d0a7b0d0a09766172202474656d705f6c69203d202428646f63756d656e742e637265617465456c656d656e7428276c692729293b0d0a092f2f20636f70792066696c656e616d6520746f206e6577206c6973742d6974656d200d0a092474656d705f6c692e617070656e6428246f626a2e6368696c6472656e28277370616e27292e65712830292e746578742829293b0d0a092f2f20696e6974206e6577206974656d20617320647261676761626c650d0a09696e697454726173684974656d282474656d705f6c69293b0d0a090d0a092f2f20617070656e642066696c656e616d6520746f2074726173680d0a092428272366696c655f74726173685f66696c657327292e617070656e64282474656d705f6c69293b0d0a092f2f2064656c6574652066696c656e616d652066726f6d20696d706f72742d6c6973740d0a09246f626a2e6368696c6472656e28277370616e27292e746578742874656d705f6e6f745f617661696c61626c65293b0d0a7d0d0a0d0a66756e6374696f6e2064656c6574654974656d28246f626a290d0a7b0d0a09246f626a2e666164654f75742827736c6f77272c2066756e6374696f6e2829207b20242874686973292e72656d6f766528293b207d20290d0a7d0d0a0d0a66756e6374696f6e2064726f704974656d546f496d706f727446696c6528652c207569290d0a7b0d0a097661722074656d705f66696c656e616d65203d206e756c6c3b0d0a090d0a096966202875692e647261676761626c652e686173436c617373282774726173685f66696c652729290d0a097b0d0a090974656d705f66696c656e616d65203d2075692e647261676761626c652e7465787428293b0d0a09092f2f2064656c657465207472617368206974656d0d0a090964656c6574654974656d2875692e647261676761626c65293b0d0a097d0d0a09656c73650d0a097b0d0a090974656d705f66696c656e616d65093d2075692e647261676761626c652e6368696c6472656e28277370616e27292e65712830292e7465787428293b0d0a09092f2f2073657420736f757263652066696c656e616d6520746f20656d7074790d0a090975692e647261676761626c652e6368696c6472656e28277370616e27292e65712830292e746578742874656d705f6e6f745f617661696c61626c65293b0d0a09090d0a0909636865636b4974656d2875692e647261676761626c65293b0d0a097d0d0a090d0a09242874686973292e6368696c6472656e28277370616e27292e65712830292e746578742874656d705f66696c656e616d65293b0d0a09636865636b4974656d2824287468697329293b0d0a7d0d0a0d0a66756e6374696f6e20696e69744974656d28246f626a290d0a7b0d0a096966202821246f626a2e686173436c6173732827696d706f72745f6f626a6563742729290d0a097b0d0a0909246f626a2e616464436c6173732827696d706f72745f6f626a65637427293b0d0a0909246f626a2e647261676761626c65280d0a09097b0d0a09090968656c7065723a2027636c6f6e65272c200d0a0909097265766572743a2027696e76616c6964272c200d0a090909637572736f723a20276d6f7665272c200d0a09097d293b0d0a097d0d0a09246f626a2e6368696c6472656e28276469763a6e6f74285b636c6173732a3d22696d706f72745f66696c65225d2927292e656163682866756e6374696f6e28696e6465782c206f626a290d0a09097b0d0a09090924286f626a292e616464436c6173732827696d706f72745f66696c6527293b0d0a09090924286f626a292e647261676761626c65280d0a0909097b0d0a0909090968656c7065723a2027636c6f6e65272c200d0a090909097265766572743a2027696e76616c6964272c200d0a09090909637572736f723a20276d6f7665272c200d0a0909097d292e64726f707061626c65280d0a0909097b0d0a090909096163636570743a20272e696d706f72745f66696c652c202e74726173685f66696c65272c0d0a0909090964726f703a2064726f704974656d546f496d706f727446696c650d0a0909097d293b0d0a09097d293b0d0a7d0d0a0d0a66756e6374696f6e20696e697454726173684974656d28246f626a290d0a7b0d0a096966202821246f626a2e686173436c617373282774726173685f66696c652729290d0a097b0d0a0909246f626a2e616464436c617373282774726173685f66696c6527293b0d0a0909246f626a2e647261676761626c65280d0a09097b0d0a09090968656c7065723a2027636c6f6e65272c200d0a0909097265766572743a2027696e76616c6964272c200d0a090909637572736f723a20276d6f7665272c200d0a09097d293b0d0a097d0d0a7d0d0a0d0a66756e6374696f6e207375626d6974466f726d28290d0a7b0d0a097661722074656d705f786d6c093d2027273b0d0a097661722074656d705f6c6973093d202428272366696c655f696d706f7274203e20756c3a6e6f74285b69645d29203e206c6927293b0d0a090d0a0974656d705f786d6c202b3d20273c6c6973743e5c6e273b0d0a090d0a09666f7220287661722069203d20303b2069203c2074656d705f6c69732e6c656e6774683b20692b2b290d0a097b0d0a09097661722074656d705f66696c6573203d20242874656d705f6c69735b695d292e6368696c6472656e282764697627292e65712830292e6368696c6472656e28276469763a5b636c6173732a3d2275692d64726f707061626c652d64697361626c6564225d27293b0d0a09090d0a090974656d705f786d6c202b3d20223c6974656d20747970653d5c2264696374696f6e6172795c223e3c64696374696f6e6172793e5c6e223b0d0a09090d0a0909666f722028766172206a203d20303b206a203c2074656d705f66696c65732e6c656e6774683b206a2b2b290d0a09097b0d0a0909097661722074656d705f74797065203d20242874656d705f66696c65735b6a5d292e6368696c6472656e28273a68656164657227292e65712830292e7465787428293b0d0a0909090d0a09090974656d705f786d6c202b3d20273c6974656d206b65793d2227202b2074656d705f747970652e7265706c616365282f5b3a5c735d2f672c20272729202b2027223e270d0a09090974656d705f786d6c202b3d20273c215b434441544127202b20275b27202b20242874656d705f66696c65735b6a5d292e6368696c6472656e28277370616e27292e65712830292e746578742829202b20275d27202b20275d3e273b0d0a09090974656d705f786d6c202b3d20273c2f6974656d3e5c6e273b0d0a09097d0d0a09090d0a090974656d705f786d6c202b3d20273c2f64696374696f6e6172793e3c2f6974656d3e5c6e273b0d0a097d0d0a090d0a0974656d705f786d6c202b3d20273c2f6c6973743e5c6e273b0d0a090d0a0924282723696d706f72745f666f726d203e20696e7075743a68696464656e27292e76616c2874656d705f786d6c293b0d0a090d0a0972657475726e20747275653b0d0a7d0d0a0d0a242827646f63756d656e7427292e72656164792866756e6374696f6e2829200d0a097b0d0a09092428272366696c655f747261736827292e64726f707061626c65280d0a09097b200d0a0909096163636570743a20222e696d706f72745f6f626a6563742c202e696d706f72745f66696c65222c200d0a090909616374697665436c6173733a202764726f707061626c652d616374697665272c200d0a090909686f766572436c6173733a202764726f707061626c652d686f766572272c0d0a09090964726f703a2066756e6374696f6e28652c207569290d0a090909097b200d0a09090909096966202875692e647261676761626c652e706172656e747328272366696c655f696d706f727427292e6c656e677468290d0a09090909097b0d0a0909090909096966202875692e647261676761626c652e617474722827636c61737327292e696e6465784f662827696d706f72745f6f626a6563742729203e202d31290d0a0909090909097b0d0a0909090909090975692e647261676761626c652e6368696c6472656e28272e696d706f72745f66696c653a6e6f74285b636c6173732a3d2275692d647261676761626c652d64697361626c6564225d2927292e656163682866756e6374696f6e28696e6465782c206f626a290d0a09090909090909097b0d0a090909090909090909636f707946696c656e616d65546f54726173682824286f626a29293b0d0a09090909090909097d293b0d0a0909090909097d0d0a090909090909656c73650d0a0909090909097b0d0a09090909090909636f707946696c656e616d65546f54726173682875692e647261676761626c65293b0d0a0909090909097d0d0a0909090909090d0a090909090909636865636b4974656d2875692e647261676761626c65293b0d0a09090909097d0d0a0909090909656c73650d0a09090909097b0d0a0909090909092f2f75692e647261676761626c652e666164654f75742866756e6374696f6e2829207b2075692e647261676761626c652e617070656e64546f282428652e74617267657429292e66616465496e28293b207d293b0d0a09090909090975692e647261676761626c652e617070656e64546f282428652e74617267657429293b0d0a09090909097d0d0a090909097d0d0a09097d293b0d0a09092428272366696c655f6e6577203e206c69203e20646976203e206469765b6e616d655d27292e64726f707061626c65280d0a09097b0d0a0909096163636570743a20272e696d706f72745f66696c652c202e74726173685f66696c65272c0d0a09090964726f703a2066756e6374696f6e28652c207569290d0a090909097b0d0a0909090909766172202474656d705f6c695f636c6f6e65093d20242874686973292e706172656e747328276c6927292e65712830292e636c6f6e6528293b0d0a09090909097661722074656d705f66696c656e616d6509093d206e756c6c3b0d0a09090909097661722074656d705f74797065090909093d20242874686973292e6368696c6472656e28273a68656164657227292e65712830292e7465787428293b0d0a09090909090d0a09090909096966202875692e647261676761626c652e686173436c617373282774726173685f66696c652729290d0a09090909097b0d0a09090909090974656d705f66696c656e616d65203d2075692e647261676761626c652e7465787428293b0d0a0909090909092f2f2064656c657465207472617368206974656d0d0a09090909090964656c6574654974656d2875692e647261676761626c65293b0d0a09090909097d0d0a0909090909656c73650d0a09090909097b0d0a09090909090974656d705f66696c656e616d65093d2075692e647261676761626c652e6368696c6472656e28277370616e27292e65712830292e7465787428293b0d0a0909090909092f2f2073657420736f757263652066696c656e616d6520746f20656d7074790d0a09090909090975692e647261676761626c652e6368696c6472656e28277370616e27292e746578742874656d705f6e6f745f617661696c61626c65293b0d0a0909090909090d0a090909090909636865636b4974656d2875692e647261676761626c65293b0d0a09090909097d0d0a0909090909090d0a09090909092f2f207265706c61636520616e79203a20616e64207768697465737061636520696e2074797065200d0a090909090974656d705f74797065203d2074656d705f747970652e7265706c616365282f5b3a5c735d2f672c202727293b0d0a09090909090d0a09090909092f2f20636f70792066696c656e616d652066726f6d20736f7572636520746f20636c6f6e650d0a09090909092474656d705f6c695f636c6f6e652e6368696c6472656e282764697627292e65712830292e6368696c6472656e28276469765b6e616d653d27202b2074656d705f74797065202b20275d27292e65712830292e6368696c6472656e28277370616e27292e65712830292e746578742874656d705f66696c656e616d65293b0d0a09090909092f2f20636f70792066696c656e616d6520746f20636c6f6e652d6865616465720d0a09090909092474656d705f6c695f636c6f6e652e6368696c6472656e282764697627292e65712830292e6368696c6472656e28277027292e65712830292e746578742874656d705f66696c656e616d65293b0d0a09090909090d0a0909090909696e69744974656d282474656d705f6c695f636c6f6e652e6368696c6472656e282764697627292e6571283029293b0d0a09090909090d0a09090909092f2f20617070656e6420636c6f6e6520696e2066696c655f696d706f7274206c6973740d0a09090909092428272366696c655f696d706f7274203e20756c27292e65712830292e617070656e64282474656d705f6c695f636c6f6e65293b0d0a09090909090d0a0909090909636865636b4974656d282474656d705f6c695f636c6f6e652e6368696c6472656e28276469765b636c6173732a3d696d706f72745f6f626a6563745d27292e6571283029293b0d0a090909097d0d0a09097d293b0d0a09092428272e696d706f72745f6f626a6563742c202e696d706f72745f66696c6527292e647261676761626c65280d0a09097b0d0a09090968656c7065723a2027636c6f6e65272c200d0a0909097265766572743a2027696e76616c6964272c200d0a090909637572736f723a20276d6f7665272c200d0a0909092f2f637572736f7241743a207b206c6566743a204d6174682e726f756e6428242874686973292e77696474682829202f2032292c20746f703a204d6174682e726f756e6428242874686973292e6865696768742829202f203229207d0d0a0909092f2f73746172743a2066756e6374696f6e28652c20756929207b202473656c6563745f7461626c652e73656c65637461626c65282764697361626c6527293b207d0d0a090909656e643a2066756e6374696f6e28652c20756929207b20636865636b4974656d2875692e647261676761626c65293b207d0d0a09097d293b0d0a09092428272e696d706f72745f66696c6527292e64726f707061626c65280d0a09097b0d0a0909096163636570743a20272e696d706f72745f66696c652c202e74726173685f66696c65272c0d0a09090964726f703a2064726f704974656d546f496d706f727446696c650d0a09097d293b0d0a09090d0a09092428272e696d706f72745f6f626a65637427292e656163682866756e6374696f6e28696e6465782c206f626a290d0a09097b0d0a090909636865636b4974656d2824286f626a29293b0d0a09097d293b0d0a097d293b</data></item> 2690 <data content_type="text/x-c" filename="ui.dialog.js" type="file"><![CDATA[/* 2691 * jQuery UI Dialog 1.6rc6 2692 * 2693 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) 2694 * Dual licensed under the MIT (MIT-LICENSE.txt) 2695 * and GPL (GPL-LICENSE.txt) licenses. 2696 * 2697 * http://docs.jquery.com/UI/Dialog 2698 * 2699 * Depends: 2700 * ui.core.js 2701 * ui.draggable.js 2702 * ui.resizable.js 2703 */ 2704 (function($) { 2705 2706 var setDataSwitch = { 2707 dragStart: "start.draggable", 2708 drag: "drag.draggable", 2709 dragStop: "stop.draggable", 2710 maxHeight: "maxHeight.resizable", 2711 minHeight: "minHeight.resizable", 2712 maxWidth: "maxWidth.resizable", 2713 minWidth: "minWidth.resizable", 2714 resizeStart: "start.resizable", 2715 resize: "drag.resizable", 2716 resizeStop: "stop.resizable" 2717 }; 2718 2719 $.widget("ui.dialog", { 2720 2721 _init: function() { 2722 this.originalTitle = this.element.attr('title'); 2723 2724 var self = this, 2725 options = this.options, 2726 2727 title = options.title || this.originalTitle || ' ', 2728 titleId = $.ui.dialog.getTitleId(this.element), 2729 2730 uiDialog = (this.uiDialog = $('<div/>')) 2731 .appendTo(document.body) 2732 .hide() 2733 .addClass( 2734 'ui-dialog ' + 2735 'ui-widget ' + 2736 'ui-widget-content ' + 2737 'ui-corner-all ' + 2738 options.dialogClass 2739 ) 2740 .css({ 2741 position: 'absolute', 2742 overflow: 'hidden', 2743 zIndex: options.zIndex 2744 }) 2745 // setting tabIndex makes the div focusable 2746 // setting outline to 0 prevents a border on focus in Mozilla 2747 .attr('tabIndex', -1).css('outline', 0).keydown(function(event) { 2748 (options.closeOnEscape && event.keyCode 2749 && event.keyCode == $.ui.keyCode.ESCAPE && self.close(event)); 2750 }) 2751 .attr({ 2752 role: 'dialog', 2753 'aria-labelledby': titleId 2754 }) 2755 .mousedown(function(event) { 2756 self.moveToTop(event); 2757 }), 2758 2759 uiDialogContent = this.element 2760 .show() 2761 .removeAttr('title') 2762 .addClass( 2763 'ui-dialog-content ' + 2764 'ui-widget-content') 2765 .appendTo(uiDialog), 2766 2767 uiDialogTitlebar = (this.uiDialogTitlebar = $('<div></div>')) 2768 .addClass( 2769 'ui-dialog-titlebar ' + 2770 'ui-widget-header ' + 2771 'ui-corner-all ' + 2772 'ui-helper-clearfix' 2773 ) 2774 .prependTo(uiDialog), 2775 2776 uiDialogTitlebarClose = $('<a href="#"/>') 2777 .addClass( 2778 'ui-dialog-titlebar-close ' + 2779 'ui-corner-all' 2780 ) 2781 .attr('role', 'button') 2782 .hover( 2783 function() { 2784 uiDialogTitlebarClose.addClass('ui-state-hover'); 2785 }, 2786 function() { 2787 uiDialogTitlebarClose.removeClass('ui-state-hover'); 2788 } 2789 ) 2790 .focus(function() { 2791 uiDialogTitlebarClose.addClass('ui-state-focus'); 2792 }) 2793 .blur(function() { 2794 uiDialogTitlebarClose.removeClass('ui-state-focus'); 2795 }) 2796 .mousedown(function(ev) { 2797 ev.stopPropagation(); 2798 }) 2799 .click(function(event) { 2800 self.close(event); 2801 return false; 2802 }) 2803 .appendTo(uiDialogTitlebar), 2804 2805 uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>')) 2806 .addClass( 2807 'ui-icon ' + 2808 'ui-icon-closethick' 2809 ) 2810 .text(options.closeText) 2811 .appendTo(uiDialogTitlebarClose), 2812 2813 uiDialogTitle = $('<span/>') 2814 .addClass('ui-dialog-title') 2815 .attr('id', titleId) 2816 .html(title) 2817 .prependTo(uiDialogTitlebar); 2818 2819 uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); 2820 2821 (options.draggable && $.fn.draggable && this._makeDraggable()); 2822 (options.resizable && $.fn.resizable && this._makeResizable()); 2823 2824 this._createButtons(options.buttons); 2825 this._isOpen = false; 2826 2827 (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe()); 2828 (options.autoOpen && this.open()); 2829 2830 }, 2831 2832 destroy: function() { 2833 (this.overlay && this.overlay.destroy()); 2834 (this.shadow && this._destroyShadow()); 2835 this.uiDialog.hide(); 2836 this.element 2837 .unbind('.dialog') 2838 .removeData('dialog') 2839 .removeClass('ui-dialog-content ui-widget-content') 2840 .hide().appendTo('body'); 2841 this.uiDialog.remove(); 2842 2843 (this.originalTitle && this.element.attr('title', this.originalTitle)); 2844 }, 2845 2846 close: function(event) { 2847 if (false === this._trigger('beforeclose', event)) { 2848 return; 2849 } 2850 2851 (this.overlay && this.overlay.destroy()); 2852 (this.shadow && this._destroyShadow()); 2853 this.uiDialog 2854 .hide(this.options.hide) 2855 .unbind('keypress.ui-dialog'); 2856 2857 this._trigger('close', event); 2858 $.ui.dialog.overlay.resize(); 2859 2860 this._isOpen = false; 2861 }, 2862 2863 isOpen: function() { 2864 return this._isOpen; 2865 }, 2866 2867 // the force parameter allows us to move modal dialogs to their correct 2868 // position on open 2869 moveToTop: function(force, event) { 2870 2871 if ((this.options.modal && !force) 2872 || (!this.options.stack && !this.options.modal)) { 2873 return this._trigger('focus', event); 2874 } 2875 2876 var maxZ = this.options.zIndex, options = this.options; 2877 $('.ui-dialog:visible').each(function() { 2878 maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex); 2879 }); 2880 (this.overlay && this.overlay.$el.css('z-index', ++maxZ)); 2881 (this.shadow && this.shadow.css('z-index', ++maxZ)); 2882 2883 //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. 2884 // http://ui.jquery.com/bugs/ticket/3193 2885 var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') }; 2886 this.uiDialog.css('z-index', ++maxZ); 2887 this.element.attr(saveScroll); 2888 this._trigger('focus', event); 2889 }, 2890 2891 open: function(event) { 2892 if (this._isOpen) { return; } 2893 2894 var options = this.options, 2895 uiDialog = this.uiDialog; 2896 2897 this.overlay = options.modal ? new $.ui.dialog.overlay(this) : null; 2898 (uiDialog.next().length && uiDialog.appendTo('body')); 2899 this._size(); 2900 this._position(options.position); 2901 uiDialog.show(options.show); 2902 this.moveToTop(true, event); 2903 2904 // prevent tabbing out of modal dialogs 2905 (options.modal && uiDialog.bind('keypress.ui-dialog', function(event) { 2906 if (event.keyCode != $.ui.keyCode.TAB) { 2907 return; 2908 } 2909 2910 var tabbables = $(':tabbable', this), 2911 first = tabbables.filter(':first')[0], 2912 last = tabbables.filter(':last')[0]; 2913 2914 if (event.target == last && !event.shiftKey) { 2915 setTimeout(function() { 2916 first.focus(); 2917 }, 1); 2918 } else if (event.target == first && event.shiftKey) { 2919 setTimeout(function() { 2920 last.focus(); 2921 }, 1); 2922 } 2923 })); 2924 2925 // set focus to the first tabbable element in: 2926 // - content area 2927 // - button pane 2928 // - title bar 2929 $([]) 2930 .add(uiDialog.find('.ui-dialog-content :tabbable:first')) 2931 .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) 2932 .add(uiDialog.find('.ui-dialog-titlebar :tabbable:first')) 2933 .filter(':first') 2934 .focus(); 2935 2936 if(options.shadow) 2937 this._createShadow(); 2938 2939 this._trigger('open', event); 2940 this._isOpen = true; 2941 }, 2942 2943 _createButtons: function(buttons) { 2944 var self = this, 2945 hasButtons = false, 2946 uiDialogButtonPane = $('<div></div>') 2947 .addClass( 2948 'ui-dialog-buttonpane ' + 2949 'ui-widget-content ' + 2950 'ui-helper-clearfix' 2951 ); 2952 2953 // if we already have a button pane, remove it 2954 this.uiDialog.find('.ui-dialog-buttonpane').remove(); 2955 2956 (typeof buttons == 'object' && buttons !== null && 2957 $.each(buttons, function() { return !(hasButtons = true); })); 2958 if (hasButtons) { 2959 $.each(buttons, function(name, fn) { 2960 $('<button type="button"></button>') 2961 .addClass( 2962 'ui-state-default ' + 2963 'ui-corner-all' 2964 ) 2965 .text(name) 2966 .click(function() { fn.apply(self.element[0], arguments); }) 2967 .hover( 2968 function() { 2969 $(this).addClass('ui-state-hover'); 2970 }, 2971 function() { 2972 $(this).removeClass('ui-state-hover'); 2973 } 2974 ) 2975 .focus(function() { 2976 $(this).addClass('ui-state-focus'); 2977 }) 2978 .blur(function() { 2979 $(this).removeClass('ui-state-focus'); 2980 }) 2981 .appendTo(uiDialogButtonPane); 2982 }); 2983 uiDialogButtonPane.appendTo(this.uiDialog); 2984 } 2985 }, 2986 2987 _makeDraggable: function() { 2988 var self = this, 2989 options = this.options; 2990 2991 this.uiDialog.draggable({ 2992 cancel: '.ui-dialog-content', 2993 helper: options.dragHelper, 2994 handle: '.ui-dialog-titlebar', 2995 containment: 'document', 2996 start: function() { 2997 (options.dragStart && options.dragStart.apply(self.element[0], arguments)); 2998 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.hide(); 2999 }, 3000 drag: function() { 3001 (options.drag && options.drag.apply(self.element[0], arguments)); 3002 self._refreshShadow(1); 3003 }, 3004 stop: function() { 3005 (options.dragStop && options.dragStop.apply(self.element[0], arguments)); 3006 $.ui.dialog.overlay.resize(); 3007 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.show(); 3008 self._refreshShadow(); 3009 } 3010 }); 3011 }, 3012 3013 _makeResizable: function(handles) { 3014 handles = (handles === undefined ? this.options.resizable : handles); 3015 var self = this, 3016 options = this.options, 3017 resizeHandles = typeof handles == 'string' 3018 ? handles 3019 : 'n,e,s,w,se,sw,ne,nw'; 3020 3021 this.uiDialog.resizable({ 3022 cancel: '.ui-dialog-content', 3023 alsoResize: this.element, 3024 helper: options.resizeHelper, 3025 maxWidth: options.maxWidth, 3026 maxHeight: options.maxHeight, 3027 minWidth: options.minWidth, 3028 minHeight: options.minHeight, 3029 start: function() { 3030 (options.resizeStart && options.resizeStart.apply(self.element[0], arguments)); 3031 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.hide(); 3032 }, 3033 resize: function() { 3034 (options.resize && options.resize.apply(self.element[0], arguments)); 3035 self._refreshShadow(1); 3036 }, 3037 handles: resizeHandles, 3038 stop: function() { 3039 (options.resizeStop && options.resizeStop.apply(self.element[0], arguments)); 3040 $.ui.dialog.overlay.resize(); 3041 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.show(); 3042 self._refreshShadow(); 3043 } 3044 }) 3045 .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se'); 3046 }, 3047 3048 _position: function(pos) { 3049 var wnd = $(window), doc = $(document), 3050 pTop = doc.scrollTop(), pLeft = doc.scrollLeft(), 3051 minTop = pTop; 3052 3053 if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) { 3054 pos = [ 3055 pos == 'right' || pos == 'left' ? pos : 'center', 3056 pos == 'top' || pos == 'bottom' ? pos : 'middle' 3057 ]; 3058 } 3059 if (pos.constructor != Array) { 3060 pos = ['center', 'middle']; 3061 } 3062 if (pos[0].constructor == Number) { 3063 pLeft += pos[0]; 3064 } else { 3065 switch (pos[0]) { 3066 case 'left': 3067 pLeft += 0; 3068 break; 3069 case 'right': 3070 pLeft += wnd.width() - this.uiDialog.outerWidth(); 3071 break; 3072 default: 3073 case 'center': 3074 pLeft += (wnd.width() - this.uiDialog.outerWidth()) / 2; 3075 } 3076 } 3077 if (pos[1].constructor == Number) { 3078 pTop += pos[1]; 3079 } else { 3080 switch (pos[1]) { 3081 case 'top': 3082 pTop += 0; 3083 break; 3084 case 'bottom': 3085 pTop += wnd.height() - this.uiDialog.outerHeight(); 3086 break; 3087 default: 3088 case 'middle': 3089 pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2; 3090 } 3091 } 3092 3093 // prevent the dialog from being too high (make sure the titlebar 3094 // is accessible) 3095 pTop = Math.max(pTop, minTop); 3096 this.uiDialog.css({top: pTop, left: pLeft}); 3097 }, 3098 3099 _setData: function(key, value){ 3100 (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value)); 3101 switch (key) { 3102 case "buttons": 3103 this._createButtons(value); 3104 break; 3105 case "closeText": 3106 this.uiDialogTitlebarCloseText.text(value); 3107 break; 3108 case "draggable": 3109 (value 3110 ? this._makeDraggable() 3111 : this.uiDialog.draggable('destroy')); 3112 break; 3113 case "height": 3114 this.uiDialog.height(value); 3115 break; 3116 case "position": 3117 this._position(value); 3118 break; 3119 case "resizable": 3120 var uiDialog = this.uiDialog, 3121 isResizable = this.uiDialog.is(':data(resizable)'); 3122 3123 // currently resizable, becoming non-resizable 3124 (isResizable && !value && uiDialog.resizable('destroy')); 3125 3126 // currently resizable, changing handles 3127 (isResizable && typeof value == 'string' && 3128 uiDialog.resizable('option', 'handles', value)); 3129 3130 // currently non-resizable, becoming resizable 3131 (isResizable || this._makeResizable(value)); 3132 3133 break; 3134 case "title": 3135 $(".ui-dialog-title", this.uiDialogTitlebar).html(value || ' '); 3136 break; 3137 case "width": 3138 this.uiDialog.width(value); 3139 break; 3140 } 3141 3142 $.widget.prototype._setData.apply(this, arguments); 3143 }, 3144 3145 _size: function() { 3146 /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content 3147 * divs will both have width and height set, so we need to reset them 3148 */ 3149 var options = this.options; 3150 3151 // reset content sizing 3152 this.element.css({ 3153 height: 0, 3154 minHeight: 0, 3155 width: 'auto' 3156 }); 3157 3158 // reset wrapper sizing 3159 // determine the height of all the non-content elements 3160 var nonContentHeight = this.uiDialog.css({ 3161 height: 'auto', 3162 width: options.width 3163 }) 3164 .height(); 3165 3166 this.element 3167 .css({ 3168 minHeight: Math.max(options.minHeight - nonContentHeight, 0), 3169 height: options.height == 'auto' 3170 ? 'auto' 3171 : options.height - nonContentHeight 3172 }); 3173 }, 3174 3175 _createShadow: function() { 3176 this.shadow = $('<div class="ui-widget-shadow"></div>').css('position', 'absolute').appendTo(document.body); 3177 this._refreshShadow(); 3178 return this.shadow; 3179 }, 3180 3181 _refreshShadow: function(dragging) { 3182 // IE6 is simply to slow to handle the reflow in a good way, so 3183 // resizing only happens on stop, and the shadow is hidden during drag/resize 3184 if(dragging && $.browser.msie && $.browser.version < 7) return; 3185 3186 var offset = this.uiDialog.offset(); 3187 this.shadow.css({ 3188 left: offset.left, 3189 top: offset.top, 3190 width: this.uiDialog.outerWidth(), 3191 height: this.uiDialog.outerHeight() 3192 }); 3193 }, 3194 3195 _destroyShadow: function() { 3196 this.shadow.remove(); 3197 this.shadow = null; 3198 } 3199 3200 }); 3201 3202 $.extend($.ui.dialog, { 3203 version: "1.6rc6", 3204 defaults: { 3205 autoOpen: true, 3206 bgiframe: false, 3207 buttons: {}, 3208 closeOnEscape: true, 3209 closeText: 'close', 3210 draggable: true, 3211 height: 'auto', 3212 minHeight: 150, 3213 minWidth: 150, 3214 modal: false, 3215 position: 'center', 3216 resizable: true, 3217 shadow: true, 3218 stack: true, 3219 title: '', 3220 width: 300, 3221 zIndex: 1000 3222 }, 3223 3224 getter: 'isOpen', 3225 3226 uuid: 0, 3227 3228 getTitleId: function($el) { 3229 return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid); 3230 }, 3231 3232 overlay: function(dialog) { 3233 this.$el = $.ui.dialog.overlay.create(dialog); 3234 } 3235 }); 3236 3237 $.extend($.ui.dialog.overlay, { 3238 instances: [], 3239 events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), 3240 function(event) { return event + '.dialog-overlay'; }).join(' '), 3241 create: function(dialog) { 3242 if (this.instances.length === 0) { 3243 // prevent use of anchors and inputs 3244 // we use a setTimeout in case the overlay is created from an 3245 // event that we're going to be cancelling (see #2804) 3246 setTimeout(function() { 3247 $('a, :input').bind($.ui.dialog.overlay.events, function() { 3248 // allow use of the element if inside a dialog and 3249 // - there are no modal dialogs 3250 // - there are modal dialogs, but we are in front of the topmost modal 3251 var allow = false; 3252 var $dialog = $(this).parents('.ui-dialog'); 3253 if ($dialog.length) { 3254 var $overlays = $('.ui-dialog-overlay'); 3255 if ($overlays.length) { 3256 var maxZ = parseInt($overlays.css('z-index'), 10); 3257 $overlays.each(function() { 3258 maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10)); 3259 }); 3260 allow = parseInt($dialog.css('z-index'), 10) > maxZ; 3261 } else { 3262 allow = true; 3263 } 3264 } 3265 return allow; 3266 }); 3267 }, 1); 3268 3269 // allow closing by pressing the escape key 3270 $(document).bind('keydown.dialog-overlay', function(event) { 3271 (dialog.options.closeOnEscape && event.keyCode 3272 && event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event)); 3273 }); 3274 3275 // handle window resize 3276 $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); 3277 } 3278 3279 var $el = $('<div></div>').appendTo(document.body) 3280 .addClass('ui-widget-overlay').css({ 3281 width: this.width(), 3282 height: this.height() 3283 }); 3284 3285 (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe()); 3286 3287 this.instances.push($el); 3288 return $el; 3289 }, 3290 3291 destroy: function($el) { 3292 this.instances.splice($.inArray(this.instances, $el), 1); 3293 3294 if (this.instances.length === 0) { 3295 $('a, :input').add([document, window]).unbind('.dialog-overlay'); 3296 } 3297 3298 $el.remove(); 3299 }, 3300 3301 height: function() { 3302 // handle IE 6 3303 if ($.browser.msie && $.browser.version < 7) { 3304 var scrollHeight = Math.max( 3305 document.documentElement.scrollHeight, 3306 document.body.scrollHeight 3307 ); 3308 var offsetHeight = Math.max( 3309 document.documentElement.offsetHeight, 3310 document.body.offsetHeight 3311 ); 3312 3313 if (scrollHeight < offsetHeight) { 3314 return $(window).height() + 'px'; 3315 } else { 3316 return scrollHeight + 'px'; 3317 } 3318 // handle "good" browsers 3319 } else { 3320 return $(document).height() + 'px'; 3321 } 3322 }, 3323 3324 width: function() { 3325 // handle IE 6 3326 if ($.browser.msie && $.browser.version < 7) { 3327 var scrollWidth = Math.max( 3328 document.documentElement.scrollWidth, 3329 document.body.scrollWidth 3330 ); 3331 var offsetWidth = Math.max( 3332 document.documentElement.offsetWidth, 3333 document.body.offsetWidth 3334 ); 3335 3336 if (scrollWidth < offsetWidth) { 3337 return $(window).width() + 'px'; 3338 } else { 3339 return scrollWidth + 'px'; 3340 } 3341 // handle "good" browsers 3342 } else { 3343 return $(document).width() + 'px'; 3344 } 3345 }, 3346 3347 resize: function() { 3348 /* If the dialog is draggable and the user drags it past the 3349 * right edge of the window, the document becomes wider so we 3350 * need to stretch the overlay. If the user then drags the 3351 * dialog back to the left, the document will become narrower, 3352 * so we need to shrink the overlay to the appropriate size. 3353 * This is handled by shrinking the overlay before setting it 3354 * to the full document size. 3355 */ 3356 var $overlays = $([]); 3357 $.each($.ui.dialog.overlay.instances, function() { 3358 $overlays = $overlays.add(this); 3359 }); 3360 3361 $overlays.css({ 3362 width: 0, 3363 height: 0 3364 }).css({ 3365 width: $.ui.dialog.overlay.width(), 3366 height: $.ui.dialog.overlay.height() 3367 }); 3368 } 3369 }); 3370 3371 $.extend($.ui.dialog.overlay.prototype, { 3372 destroy: function() { 3373 $.ui.dialog.overlay.destroy(this.$el); 3374 } 3375 }); 3376 3377 })(jQuery); 3378 ]]></data></item> 3379 <item key="id"><![CDATA[ui.dialog.js]]></item> 3380 <item key="mandatory" type="int">0</item> 3381 <item key="multilang" type="int">0</item> 3382 <item key="name"><![CDATA[ui.dialog.js]]></item> 3383 <item key="repetitive" type="int">0</item> 3384 <item key="type"><![CDATA[resource]]></item> 3385 </dictionary> 3386 </item> 3387 <item type="dictionary"><dictionary> 3388 <item key="custom"> 3389 <data content_type="text/x-c" filename="jquery.Jcrop.js" type="file"><![CDATA[/** 3390 * jquery.Jcrop.js v0.9.8 3391 * jQuery Image Cropping Plugin 3392 * @author Kelly Hallman <khallman@gmail.com> 3393 * Copyright (c) 2008-2009 Kelly Hallman - released under MIT License {{{ 3394 * 3395 * Permission is hereby granted, free of charge, to any person 3396 * obtaining a copy of this software and associated documentation 3397 * files (the "Software"), to deal in the Software without 3398 * restriction, including without limitation the rights to use, 3399 * copy, modify, merge, publish, distribute, sublicense, and/or sell 3400 * copies of the Software, and to permit persons to whom the 3401 * Software is furnished to do so, subject to the following 3402 * conditions: 3403 3404 * The above copyright notice and this permission notice shall be 3405 * included in all copies or substantial portions of the Software. 3406 3407 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3408 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 3409 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3410 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 3411 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 3412 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 3413 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 3414 * OTHER DEALINGS IN THE SOFTWARE. 3415 3416 * }}} 3417 */ 3418 3419 (function($) { 3420 3421 $.Jcrop = function(obj,opt) 3422 { 3423 // Initialization {{{ 3424 3425 // Sanitize some options {{{ 3426 var obj = obj, opt = opt; 3427 3428 if (typeof(obj) !== 'object') obj = $(obj)[0]; 3429 if (typeof(opt) !== 'object') opt = { }; 3430 3431 // Some on-the-fly fixes for MSIE...sigh 3432 if (!('trackDocument' in opt)) 3433 { 3434 opt.trackDocument = $.browser.msie ? false : true; 3435 if ($.browser.msie && $.browser.version.split('.')[0] == '8') 3436 opt.trackDocument = true; 3437 } 3438 3439 if (!('keySupport' in opt)) 3440 opt.keySupport = $.browser.msie ? false : true; 3441 3442 // }}} 3443 // Extend the default options {{{ 3444 var defaults = { 3445 3446 // Basic Settings 3447 trackDocument: false, 3448 baseClass: 'jcrop', 3449 addClass: null, 3450 3451 // Styling Options 3452 bgColor: 'black', 3453 bgOpacity: .6, 3454 borderOpacity: .4, 3455 handleOpacity: .5, 3456 3457 handlePad: 5, 3458 handleSize: 9, 3459 handleOffset: 5, 3460 edgeMargin: 14, 3461 3462 aspectRatio: 0, 3463 keySupport: true, 3464 cornerHandles: true, 3465 sideHandles: true, 3466 drawBorders: true, 3467 dragEdges: true, 3468 3469 boxWidth: 0, 3470 boxHeight: 0, 3471 3472 boundary: 8, 3473 animationDelay: 20, 3474 swingSpeed: 3, 3475 3476 allowSelect: true, 3477 allowMove: true, 3478 allowResize: true, 3479 3480 minSelect: [ 0, 0 ], 3481 maxSize: [ 0, 0 ], 3482 minSize: [ 0, 0 ], 3483 3484 // Callbacks / Event Handlers 3485 onChange: function() { }, 3486 onSelect: function() { } 3487 3488 }; 3489 var options = defaults; 3490 setOptions(opt); 3491 3492 // }}} 3493 // Initialize some jQuery objects {{{ 3494 3495 var $origimg = $(obj); 3496 var $img = $origimg.clone().removeAttr('id').css({ position: 'absolute' }); 3497 3498 $img.width($origimg.width()); 3499 $img.height($origimg.height()); 3500 $origimg.after($img).hide(); 3501 3502 presize($img,options.boxWidth,options.boxHeight); 3503 3504 var boundx = $img.width(), 3505 boundy = $img.height(), 3506 3507 $div = $('<div />') 3508 .width(boundx).height(boundy) 3509 .addClass(cssClass('holder')) 3510 .css({ 3511 position: 'relative', 3512 backgroundColor: options.bgColor 3513 }).insertAfter($origimg).append($img); 3514 ; 3515 3516 if (options.addClass) $div.addClass(options.addClass); 3517 //$img.wrap($div); 3518 3519 var $img2 = $('<img />')/*{{{*/ 3520 .attr('src',$img.attr('src')) 3521 .css('position','absolute') 3522 .width(boundx).height(boundy) 3523 ;/*}}}*/ 3524 var $img_holder = $('<div />')/*{{{*/ 3525 .width(pct(100)).height(pct(100)) 3526 .css({ 3527 zIndex: 310, 3528 position: 'absolute', 3529 overflow: 'hidden' 3530 }) 3531 .append($img2) 3532 ;/*}}}*/ 3533 var $hdl_holder = $('<div />')/*{{{*/ 3534 .width(pct(100)).height(pct(100)) 3535 .css('zIndex',320); 3536 /*}}}*/ 3537 var $sel = $('<div />')/*{{{*/ 3538 .css({ 3539 position: 'absolute', 3540 zIndex: 300 3541 }) 3542 .insertBefore($img) 3543 .append($img_holder,$hdl_holder) 3544 ;/*}}}*/ 3545 3546 var bound = options.boundary; 3547 var $trk = newTracker().width(boundx+(bound*2)).height(boundy+(bound*2)) 3548 .css({ position: 'absolute', top: px(-bound), left: px(-bound), zIndex: 290 }) 3549 .mousedown(newSelection); 3550 3551 /* }}} */ 3552 // Set more variables {{{ 3553 3554 var xlimit, ylimit, xmin, ymin; 3555 var xscale, yscale, enabled = true; 3556 var docOffset = getPos($img), 3557 // Internal states 3558 btndown, lastcurs, dimmed, animating, 3559 shift_down; 3560 3561 // }}} 3562 3563 3564 // }}} 3565 // Internal Modules {{{ 3566 3567 var Coords = function()/*{{{*/ 3568 { 3569 var x1 = 0, y1 = 0, x2 = 0, y2 = 0, ox, oy; 3570 3571 function setPressed(pos)/*{{{*/ 3572 { 3573 var pos = rebound(pos); 3574 x2 = x1 = pos[0]; 3575 y2 = y1 = pos[1]; 3576 }; 3577 /*}}}*/ 3578 function setCurrent(pos)/*{{{*/ 3579 { 3580 var pos = rebound(pos); 3581 ox = pos[0] - x2; 3582 oy = pos[1] - y2; 3583 x2 = pos[0]; 3584 y2 = pos[1]; 3585 }; 3586 /*}}}*/ 3587 function getOffset()/*{{{*/ 3588 { 3589 return [ ox, oy ]; 3590 }; 3591 /*}}}*/ 3592 function moveOffset(offset)/*{{{*/ 3593 { 3594 var ox = offset[0], oy = offset[1]; 3595 3596 if (0 > x1 + ox) ox -= ox + x1; 3597 if (0 > y1 + oy) oy -= oy + y1; 3598 3599 if (boundy < y2 + oy) oy += boundy - (y2 + oy); 3600 if (boundx < x2 + ox) ox += boundx - (x2 + ox); 3601 3602 x1 += ox; 3603 x2 += ox; 3604 y1 += oy; 3605 y2 += oy; 3606 }; 3607 /*}}}*/ 3608 function getCorner(ord)/*{{{*/ 3609 { 3610 var c = getFixed(); 3611 switch(ord) 3612 { 3613 case 'ne': return [ c.x2, c.y ]; 3614 case 'nw': return [ c.x, c.y ]; 3615 case 'se': return [ c.x2, c.y2 ]; 3616 case 'sw': return [ c.x, c.y2 ]; 3617 } 3618 }; 3619 /*}}}*/ 3620 function getFixed()/*{{{*/ 3621 { 3622 if (!options.aspectRatio) return getRect(); 3623 // This function could use some optimization I think... 3624 var aspect = options.aspectRatio, 3625 min_x = options.minSize[0]/xscale, 3626 min_y = options.minSize[1]/yscale, 3627 max_x = options.maxSize[0]/xscale, 3628 max_y = options.maxSize[1]/yscale, 3629 rw = x2 - x1, 3630 rh = y2 - y1, 3631 rwa = Math.abs(rw), 3632 rha = Math.abs(rh), 3633 real_ratio = rwa / rha, 3634 xx, yy 3635 ; 3636 if (max_x == 0) { max_x = boundx * 10 } 3637 if (max_y == 0) { max_y = boundy * 10 } 3638 if (real_ratio < aspect) 3639 { 3640 yy = y2; 3641 w = rha * aspect; 3642 xx = rw < 0 ? x1 - w : w + x1; 3643 3644 if (xx < 0) 3645 { 3646 xx = 0; 3647 h = Math.abs((xx - x1) / aspect); 3648 yy = rh < 0 ? y1 - h: h + y1; 3649 } 3650 else if (xx > boundx) 3651 { 3652 xx = boundx; 3653 h = Math.abs((xx - x1) / aspect); 3654 yy = rh < 0 ? y1 - h : h + y1; 3655 } 3656 } 3657 else 3658 { 3659 xx = x2; 3660 h = rwa / aspect; 3661 yy = rh < 0 ? y1 - h : y1 + h; 3662 if (yy < 0) 3663 { 3664 yy = 0; 3665 w = Math.abs((yy - y1) * aspect); 3666 xx = rw < 0 ? x1 - w : w + x1; 3667 } 3668 else if (yy > boundy) 3669 { 3670 yy = boundy; 3671 w = Math.abs(yy - y1) * aspect; 3672 xx = rw < 0 ? x1 - w : w + x1; 3673 } 3674 } 3675 3676 // Magic %-) 3677 if(xx > x1) { // right side 3678 if(xx - x1 < min_x) { 3679 xx = x1 + min_x; 3680 } else if (xx - x1 > max_x) { 3681 xx = x1 + max_x; 3682 } 3683 if(yy > y1) { 3684 yy = y1 + (xx - x1)/aspect; 3685 } else { 3686 yy = y1 - (xx - x1)/aspect; 3687 } 3688 } else if (xx < x1) { // left side 3689 if(x1 - xx < min_x) { 3690 xx = x1 - min_x 3691 } else if (x1 - xx > max_x) { 3692 xx = x1 - max_x; 3693 } 3694 if(yy > y1) { 3695 yy = y1 + (x1 - xx)/aspect; 3696 } else { 3697 yy = y1 - (x1 - xx)/aspect; 3698 } 3699 } 3700 3701 if(xx < 0) { 3702 x1 -= xx; 3703 xx = 0; 3704 } else if (xx > boundx) { 3705 x1 -= xx - boundx; 3706 xx = boundx; 3707 } 3708 3709 if(yy < 0) { 3710 y1 -= yy; 3711 yy = 0; 3712 } else if (yy > boundy) { 3713 y1 -= yy - boundy; 3714 yy = boundy; 3715 } 3716 3717 return last = makeObj(flipCoords(x1,y1,xx,yy)); 3718 }; 3719 /*}}}*/ 3720 function rebound(p)/*{{{*/ 3721 { 3722 if (p[0] < 0) p[0] = 0; 3723 if (p[1] < 0) p[1] = 0; 3724 3725 if (p[0] > boundx) p[0] = boundx; 3726 if (p[1] > boundy) p[1] = boundy; 3727 3728 return [ p[0], p[1] ]; 3729 }; 3730 /*}}}*/ 3731 function flipCoords(x1,y1,x2,y2)/*{{{*/ 3732 { 3733 var xa = x1, xb = x2, ya = y1, yb = y2; 3734 if (x2 < x1) 3735 { 3736 xa = x2; 3737 xb = x1; 3738 } 3739 if (y2 < y1) 3740 { 3741 ya = y2; 3742 yb = y1; 3743 } 3744 return [ Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb) ]; 3745 }; 3746 /*}}}*/ 3747 function getRect()/*{{{*/ 3748 { 3749 var xsize = x2 - x1; 3750 var ysize = y2 - y1; 3751 3752 if (xlimit && (Math.abs(xsize) > xlimit)) 3753 x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit); 3754 if (ylimit && (Math.abs(ysize) > ylimit)) 3755 y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit); 3756 3757 if (ymin && (Math.abs(ysize) < ymin)) 3758 y2 = (ysize > 0) ? (y1 + ymin) : (y1 - ymin); 3759 if (xmin && (Math.abs(xsize) < xmin)) 3760 x2 = (xsize > 0) ? (x1 + xmin) : (x1 - xmin); 3761 3762 if (x1 < 0) { x2 -= x1; x1 -= x1; } 3763 if (y1 < 0) { y2 -= y1; y1 -= y1; } 3764 if (x2 < 0) { x1 -= x2; x2 -= x2; } 3765 if (y2 < 0) { y1 -= y2; y2 -= y2; } 3766 if (x2 > boundx) { var delta = x2 - boundx; x1 -= delta; x2 -= delta; } 3767 if (y2 > boundy) { var delta = y2 - boundy; y1 -= delta; y2 -= delta; } 3768 if (x1 > boundx) { var delta = x1 - boundy; y2 -= delta; y1 -= delta; } 3769 if (y1 > boundy) { var delta = y1 - boundy; y2 -= delta; y1 -= delta; } 3770 3771 return makeObj(flipCoords(x1,y1,x2,y2)); 3772 }; 3773 /*}}}*/ 3774 function makeObj(a)/*{{{*/ 3775 { 3776 return { x: a[0], y: a[1], x2: a[2], y2: a[3], 3777 w: a[2] - a[0], h: a[3] - a[1] }; 3778 }; 3779 /*}}}*/ 3780 3781 return { 3782 flipCoords: flipCoords, 3783 setPressed: setPressed, 3784 setCurrent: setCurrent, 3785 getOffset: getOffset, 3786 moveOffset: moveOffset, 3787 getCorner: getCorner, 3788 getFixed: getFixed 3789 }; 3790 }(); 3791 3792 /*}}}*/ 3793 var Selection = function()/*{{{*/ 3794 { 3795 var start, end, dragmode, awake, hdep = 370; 3796 var borders = { }; 3797 var handle = { }; 3798 var seehandles = false; 3799 var hhs = options.handleOffset; 3800 3801 /* Insert draggable elements {{{*/ 3802 3803 // Insert border divs for outline 3804 if (options.drawBorders) { 3805 borders = { 3806 top: insertBorder('hline') 3807 .css('top',$.browser.msie?px(-1):px(0)), 3808 bottom: insertBorder('hline'), 3809 left: insertBorder('vline'), 3810 right: insertBorder('vline') 3811 }; 3812 } 3813 3814 // Insert handles on edges 3815 if (options.dragEdges) { 3816 handle.t = insertDragbar('n'); 3817 handle.b = insertDragbar('s'); 3818 handle.r = insertDragbar('e'); 3819 handle.l = insertDragbar('w'); 3820 } 3821 3822 // Insert side handles 3823 options.sideHandles && 3824 createHandles(['n','s','e','w']); 3825 3826 // Insert corner handles 3827 options.cornerHandles && 3828 createHandles(['sw','nw','ne','se']); 3829 3830 /*}}}*/ 3831 // Private Methods 3832 function insertBorder(type)/*{{{*/ 3833 { 3834 var jq = $('<div />') 3835 .css({position: 'absolute', opacity: options.borderOpacity }) 3836 .addClass(cssClass(type)); 3837 $img_holder.append(jq); 3838 return jq; 3839 }; 3840 /*}}}*/ 3841 function dragDiv(ord,zi)/*{{{*/ 3842 { 3843 var jq = $('<div />') 3844 .mousedown(createDragger(ord)) 3845 .css({ 3846 cursor: ord+'-resize', 3847 position: 'absolute', 3848 zIndex: zi 3849 }) 3850 ; 3851 $hdl_holder.append(jq); 3852 return jq; 3853 }; 3854 /*}}}*/ 3855 function insertHandle(ord)/*{{{*/ 3856 { 3857 return dragDiv(ord,hdep++) 3858 .css({ top: px(-hhs+1), left: px(-hhs+1), opacity: options.handleOpacity }) 3859 .addClass(cssClass('handle')); 3860 }; 3861 /*}}}*/ 3862 function insertDragbar(ord)/*{{{*/ 3863 { 3864 var s = options.handleSize, 3865 o = hhs, 3866 h = s, w = s, 3867 t = o, l = o; 3868 3869 switch(ord) 3870 { 3871 case 'n': case 's': w = pct(100); break; 3872 case 'e': case 'w': h = pct(100); break; 3873 } 3874 3875 return dragDiv(ord,hdep++).width(w).height(h) 3876 .css({ top: px(-t+1), left: px(-l+1)}); 3877 }; 3878 /*}}}*/ 3879 function createHandles(li)/*{{{*/ 3880 { 3881 for(i in li) handle[li[i]] = insertHandle(li[i]); 3882 }; 3883 /*}}}*/ 3884 function moveHandles(c)/*{{{*/ 3885 { 3886 var midvert = Math.round((c.h / 2) - hhs), 3887 midhoriz = Math.round((c.w / 2) - hhs), 3888 north = west = -hhs+1, 3889 east = c.w - hhs, 3890 south = c.h - hhs, 3891 x, y; 3892 3893 'e' in handle && 3894 handle.e.css({ top: px(midvert), left: px(east) }) && 3895 handle.w.css({ top: px(midvert) }) && 3896 handle.s.css({ top: px(south), left: px(midhoriz) }) && 3897 handle.n.css({ left: px(midhoriz) }); 3898 3899 'ne' in handle && 3900 handle.ne.css({ left: px(east) }) && 3901 handle.se.css({ top: px(south), left: px(east) }) && 3902 handle.sw.css({ top: px(south) }); 3903 3904 'b' in handle && 3905 handle.b.css({ top: px(south) }) && 3906 handle.r.css({ left: px(east) }); 3907 }; 3908 /*}}}*/ 3909 function moveto(x,y)/*{{{*/ 3910 { 3911 $img2.css({ top: px(-y), left: px(-x) }); 3912 $sel.css({ top: px(y), left: px(x) }); 3913 }; 3914 /*}}}*/ 3915 function resize(w,h)/*{{{*/ 3916 { 3917 $sel.width(w).height(h); 3918 }; 3919 /*}}}*/ 3920 function refresh()/*{{{*/ 3921 { 3922 var c = Coords.getFixed(); 3923 3924 Coords.setPressed([c.x,c.y]); 3925 Coords.setCurrent([c.x2,c.y2]); 3926 3927 updateVisible(); 3928 }; 3929 /*}}}*/ 3930 3931 // Internal Methods 3932 function updateVisible()/*{{{*/ 3933 { if (awake) return update(); }; 3934 /*}}}*/ 3935 function update()/*{{{*/ 3936 { 3937 var c = Coords.getFixed(); 3938 3939 resize(c.w,c.h); 3940 moveto(c.x,c.y); 3941 3942 options.drawBorders && 3943 borders['right'].css({ left: px(c.w-1) }) && 3944 borders['bottom'].css({ top: px(c.h-1) }); 3945 3946 seehandles && moveHandles(c); 3947 awake || show(); 3948 3949 options.onChange(unscale(c)); 3950 }; 3951 /*}}}*/ 3952 function show()/*{{{*/ 3953 { 3954 $sel.show(); 3955 $img.css('opacity',options.bgOpacity); 3956 awake = true; 3957 }; 3958 /*}}}*/ 3959 function release()/*{{{*/ 3960 { 3961 disableHandles(); 3962 $sel.hide(); 3963 $img.css('opacity',1); 3964 awake = false; 3965 }; 3966 /*}}}*/ 3967 function showHandles()//{{{ 3968 { 3969 if (seehandles) 3970 { 3971 moveHandles(Coords.getFixed()); 3972 $hdl_holder.show(); 3973 } 3974 }; 3975 //}}} 3976 function enableHandles()/*{{{*/ 3977 { 3978 seehandles = true; 3979 if (options.allowResize) 3980 { 3981 moveHandles(Coords.getFixed()); 3982 $hdl_holder.show(); 3983 return true; 3984 } 3985 }; 3986 /*}}}*/ 3987 function disableHandles()/*{{{*/ 3988 { 3989 seehandles = false; 3990 $hdl_holder.hide(); 3991 }; 3992 /*}}}*/ 3993 function animMode(v)/*{{{*/ 3994 { 3995 (animating = v) ? disableHandles(): enableHandles(); 3996 }; 3997 /*}}}*/ 3998 function done()/*{{{*/ 3999 { 4000 animMode(false); 4001 refresh(); 4002 }; 4003 /*}}}*/ 4004 4005 var $track = newTracker().mousedown(createDragger('move')) 4006 .css({ cursor: 'move', position: 'absolute', zIndex: 360 }) 4007 4008 $img_holder.append($track); 4009 disableHandles(); 4010 4011 return { 4012 updateVisible: updateVisible, 4013 update: update, 4014 release: release, 4015 refresh: refresh, 4016 setCursor: function (cursor) { $track.css('cursor',cursor); }, 4017 enableHandles: enableHandles, 4018 enableOnly: function() { seehandles = true; }, 4019 showHandles: showHandles, 4020 disableHandles: disableHandles, 4021 animMode: animMode, 4022 done: done 4023 }; 4024 }(); 4025 /*}}}*/ 4026 var Tracker = function()/*{{{*/ 4027 { 4028 var onMove = function() { }, 4029 onDone = function() { }, 4030 trackDoc = options.trackDocument; 4031 4032 if (!trackDoc) 4033 { 4034 $trk 4035 .mousemove(trackMove) 4036 .mouseup(trackUp) 4037 .mouseout(trackUp) 4038 ; 4039 } 4040 4041 function toFront()/*{{{*/ 4042 { 4043 $trk.css({zIndex:450}); 4044 if (trackDoc) 4045 { 4046 $(document) 4047 .mousemove(trackMove) 4048 .mouseup(trackUp) 4049 ; 4050 } 4051 } 4052 /*}}}*/ 4053 function toBack()/*{{{*/ 4054 { 4055 $trk.css({zIndex:290}); 4056 if (trackDoc) 4057 { 4058 $(document) 4059 .unbind('mousemove',trackMove) 4060 .unbind('mouseup',trackUp) 4061 ; 4062 } 4063 } 4064 /*}}}*/ 4065 function trackMove(e)/*{{{*/ 4066 { 4067 onMove(mouseAbs(e)); 4068 }; 4069 /*}}}*/ 4070 function trackUp(e)/*{{{*/ 4071 { 4072 e.preventDefault(); 4073 e.stopPropagation(); 4074 4075 if (btndown) 4076 { 4077 btndown = false; 4078 4079 onDone(mouseAbs(e)); 4080 options.onSelect(unscale(Coords.getFixed())); 4081 toBack(); 4082 onMove = function() { }; 4083 onDone = function() { }; 4084 } 4085 4086 return false; 4087 }; 4088 /*}}}*/ 4089 4090 function activateHandlers(move,done)/* {{{ */ 4091 { 4092 btndown = true; 4093 onMove = move; 4094 onDone = done; 4095 toFront(); 4096 return false; 4097 }; 4098 /* }}} */ 4099 4100 function setCursor(t) { $trk.css('cursor',t); }; 4101 4102 $img.before($trk); 4103 return { 4104 activateHandlers: activateHandlers, 4105 setCursor: setCursor 4106 }; 4107 }(); 4108 /*}}}*/ 4109 var KeyManager = function()/*{{{*/ 4110 { 4111 var $keymgr = $('<input type="radio" />') 4112 .css({ position: 'absolute', left: '-30px' }) 4113 .keypress(parseKey) 4114 .blur(onBlur), 4115 4116 $keywrap = $('<div />') 4117 .css({ 4118 position: 'absolute', 4119 overflow: 'hidden' 4120 }) 4121 .append($keymgr) 4122 ; 4123 4124 function watchKeys()/*{{{*/ 4125 { 4126 if (options.keySupport) 4127 { 4128 $keymgr.show(); 4129 $keymgr.focus(); 4130 } 4131 }; 4132 /*}}}*/ 4133 function onBlur(e)/*{{{*/ 4134 { 4135 $keymgr.hide(); 4136 }; 4137 /*}}}*/ 4138 function doNudge(e,x,y)/*{{{*/ 4139 { 4140 if (options.allowMove) { 4141 Coords.moveOffset([x,y]); 4142 Selection.updateVisible(); 4143 }; 4144 e.preventDefault(); 4145 e.stopPropagation(); 4146 }; 4147 /*}}}*/ 4148 function parseKey(e)/*{{{*/ 4149 { 4150 if (e.ctrlKey) return true; 4151 shift_down = e.shiftKey ? true : false; 4152 var nudge = shift_down ? 10 : 1; 4153 switch(e.keyCode) 4154 { 4155 case 37: doNudge(e,-nudge,0); break; 4156 case 39: doNudge(e,nudge,0); break; 4157 case 38: doNudge(e,0,-nudge); break; 4158 case 40: doNudge(e,0,nudge); break; 4159 4160 case 27: Selection.release(); break; 4161 4162 case 9: return true; 4163 } 4164 4165 return nothing(e); 4166 }; 4167 /*}}}*/ 4168 4169 if (options.keySupport) $keywrap.insertBefore($img); 4170 return { 4171 watchKeys: watchKeys 4172 }; 4173 }(); 4174 /*}}}*/ 4175 4176 // }}} 4177 // Internal Methods {{{ 4178 4179 function px(n) { return '' + parseInt(n) + 'px'; }; 4180 function pct(n) { return '' + parseInt(n) + '%'; }; 4181 function cssClass(cl) { return options.baseClass + '-' + cl; }; 4182 function getPos(obj)/*{{{*/ 4183 { 4184 // Updated in v0.9.4 to use built-in dimensions plugin 4185 var pos = $(obj).offset(); 4186 return [ pos.left, pos.top ]; 4187 }; 4188 /*}}}*/ 4189 function mouseAbs(e)/*{{{*/ 4190 { 4191 return [ (e.pageX - docOffset[0]), (e.pageY - docOffset[1]) ]; 4192 }; 4193 /*}}}*/ 4194 function myCursor(type)/*{{{*/ 4195 { 4196 if (type != lastcurs) 4197 { 4198 Tracker.setCursor(type); 4199 //Handles.xsetCursor(type); 4200 lastcurs = type; 4201 } 4202 }; 4203 /*}}}*/ 4204 function startDragMode(mode,pos)/*{{{*/ 4205 { 4206 docOffset = getPos($img); 4207 Tracker.setCursor(mode=='move'?mode:mode+'-resize'); 4208 4209 if (mode == 'move') 4210 return Tracker.activateHandlers(createMover(pos), doneSelect); 4211 4212 var fc = Coords.getFixed(); 4213 var opp = oppLockCorner(mode); 4214 var opc = Coords.getCorner(oppLockCorner(opp)); 4215 4216 Coords.setPressed(Coords.getCorner(opp)); 4217 Coords.setCurrent(opc); 4218 4219 Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect); 4220 }; 4221 /*}}}*/ 4222 function dragmodeHandler(mode,f)/*{{{*/ 4223 { 4224 return function(pos) { 4225 if (!options.aspectRatio) switch(mode) 4226 { 4227 case 'e': pos[1] = f.y2; break; 4228 case 'w': pos[1] = f.y2; break; 4229 case 'n': pos[0] = f.x2; break; 4230 case 's': pos[0] = f.x2; break; 4231 } 4232 else switch(mode) 4233 { 4234 case 'e': pos[1] = f.y+1; break; 4235 case 'w': pos[1] = f.y+1; break; 4236 case 'n': pos[0] = f.x+1; break; 4237 case 's': pos[0] = f.x+1; break; 4238 } 4239 Coords.setCurrent(pos); 4240 Selection.update(); 4241 }; 4242 }; 4243 /*}}}*/ 4244 function createMover(pos)/*{{{*/ 4245 { 4246 var lloc = pos; 4247 KeyManager.watchKeys(); 4248 4249 return function(pos) 4250 { 4251 Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]); 4252 lloc = pos; 4253 4254 Selection.update(); 4255 }; 4256 }; 4257 /*}}}*/ 4258 function oppLockCorner(ord)/*{{{*/ 4259 { 4260 switch(ord) 4261 { 4262 case 'n': return 'sw'; 4263 case 's': return 'nw'; 4264 case 'e': return 'nw'; 4265 case 'w': return 'ne'; 4266 case 'ne': return 'sw'; 4267 case 'nw': return 'se'; 4268 case 'se': return 'nw'; 4269 case 'sw': return 'ne'; 4270 }; 4271 }; 4272 /*}}}*/ 4273 function createDragger(ord)/*{{{*/ 4274 { 4275 return function(e) { 4276 if (options.disabled) return false; 4277 if ((ord == 'move') && !options.allowMove) return false; 4278 btndown = true; 4279 startDragMode(ord,mouseAbs(e)); 4280 e.stopPropagation(); 4281 e.preventDefault(); 4282 return false; 4283 }; 4284 }; 4285 /*}}}*/ 4286 function presize($obj,w,h)/*{{{*/ 4287 { 4288 var nw = $obj.width(), nh = $obj.height(); 4289 if ((nw > w) && w > 0) 4290 { 4291 nw = w; 4292 nh = (w/$obj.width()) * $obj.height(); 4293 } 4294 if ((nh > h) && h > 0) 4295 { 4296 nh = h; 4297 nw = (h/$obj.height()) * $obj.width(); 4298 } 4299 xscale = $obj.width() / nw; 4300 yscale = $obj.height() / nh; 4301 $obj.width(nw).height(nh); 4302 }; 4303 /*}}}*/ 4304 function unscale(c)/*{{{*/ 4305 { 4306 return { 4307 x: parseInt(c.x * xscale), y: parseInt(c.y * yscale), 4308 x2: parseInt(c.x2 * xscale), y2: parseInt(c.y2 * yscale), 4309 w: parseInt(c.w * xscale), h: parseInt(c.h * yscale) 4310 }; 4311 }; 4312 /*}}}*/ 4313 function doneSelect(pos)/*{{{*/ 4314 { 4315 var c = Coords.getFixed(); 4316 if (c.w > options.minSelect[0] && c.h > options.minSelect[1]) 4317 { 4318 Selection.enableHandles(); 4319 Selection.done(); 4320 } 4321 else 4322 { 4323 Selection.release(); 4324 } 4325 Tracker.setCursor( options.allowSelect?'crosshair':'default' ); 4326 }; 4327 /*}}}*/ 4328 function newSelection(e)/*{{{*/ 4329 { 4330 if (options.disabled) return false; 4331 if (!options.allowSelect) return false; 4332 btndown = true; 4333 docOffset = getPos($img); 4334 Selection.disableHandles(); 4335 myCursor('crosshair'); 4336 var pos = mouseAbs(e); 4337 Coords.setPressed(pos); 4338 Tracker.activateHandlers(selectDrag,doneSelect); 4339 KeyManager.watchKeys(); 4340 Selection.update(); 4341 4342 e.stopPropagation(); 4343 e.preventDefault(); 4344 return false; 4345 }; 4346 /*}}}*/ 4347 function selectDrag(pos)/*{{{*/ 4348 { 4349 Coords.setCurrent(pos); 4350 Selection.update(); 4351 }; 4352 /*}}}*/ 4353 function newTracker() 4354 { 4355 var trk = $('<div></div>').addClass(cssClass('tracker')); 4356 $.browser.msie && trk.css({ opacity: 0, backgroundColor: 'white' }); 4357 return trk; 4358 }; 4359 4360 // }}} 4361 // API methods {{{ 4362 4363 function animateTo(a)/*{{{*/ 4364 { 4365 var x1 = a[0] / xscale, 4366 y1 = a[1] / yscale, 4367 x2 = a[2] / xscale, 4368 y2 = a[3] / yscale; 4369 4370 if (animating) return; 4371 4372 var animto = Coords.flipCoords(x1,y1,x2,y2); 4373 var c = Coords.getFixed(); 4374 var animat = initcr = [ c.x, c.y, c.x2, c.y2 ]; 4375 var interv = options.animationDelay; 4376 4377 var x = animat[0]; 4378 var y = animat[1]; 4379 var x2 = animat[2]; 4380 var y2 = animat[3]; 4381 var ix1 = animto[0] - initcr[0]; 4382 var iy1 = animto[1] - initcr[1]; 4383 var ix2 = animto[2] - initcr[2]; 4384 var iy2 = animto[3] - initcr[3]; 4385 var pcent = 0; 4386 var velocity = options.swingSpeed; 4387 4388 Selection.animMode(true); 4389 4390 var animator = function() 4391 { 4392 return function() 4393 { 4394 pcent += (100 - pcent) / velocity; 4395 4396 animat[0] = x + ((pcent / 100) * ix1); 4397 animat[1] = y + ((pcent / 100) * iy1); 4398 animat[2] = x2 + ((pcent / 100) * ix2); 4399 animat[3] = y2 + ((pcent / 100) * iy2); 4400 4401 if (pcent < 100) animateStart(); 4402 else Selection.done(); 4403 4404 if (pcent >= 99.8) pcent = 100; 4405 4406 setSelectRaw(animat); 4407 }; 4408 }(); 4409 4410 function animateStart() 4411 { window.setTimeout(animator,interv); }; 4412 4413 animateStart(); 4414 }; 4415 /*}}}*/ 4416 function setSelect(rect)//{{{ 4417 { 4418 setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]); 4419 }; 4420 //}}} 4421 function setSelectRaw(l) /*{{{*/ 4422 { 4423 Coords.setPressed([l[0],l[1]]); 4424 Coords.setCurrent([l[2],l[3]]); 4425 Selection.update(); 4426 }; 4427 /*}}}*/ 4428 function setOptions(opt)/*{{{*/ 4429 { 4430 if (typeof(opt) != 'object') opt = { }; 4431 options = $.extend(options,opt); 4432 4433 if (typeof(options.onChange)!=='function') 4434 options.onChange = function() { }; 4435 4436 if (typeof(options.onSelect)!=='function') 4437 options.onSelect = function() { }; 4438 4439 }; 4440 /*}}}*/ 4441 function tellSelect()/*{{{*/ 4442 { 4443 return unscale(Coords.getFixed()); 4444 }; 4445 /*}}}*/ 4446 function tellScaled()/*{{{*/ 4447 { 4448 return Coords.getFixed(); 4449 }; 4450 /*}}}*/ 4451 function setOptionsNew(opt)/*{{{*/ 4452 { 4453 setOptions(opt); 4454 interfaceUpdate(); 4455 }; 4456 /*}}}*/ 4457 function disableCrop()//{{{ 4458 { 4459 options.disabled = true; 4460 Selection.disableHandles(); 4461 Selection.setCursor('default'); 4462 Tracker.setCursor('default'); 4463 }; 4464 //}}} 4465 function enableCrop()//{{{ 4466 { 4467 options.disabled = false; 4468 interfaceUpdate(); 4469 }; 4470 //}}} 4471 function cancelCrop()//{{{ 4472 { 4473 Selection.done(); 4474 Tracker.activateHandlers(null,null); 4475 }; 4476 //}}} 4477 function destroy()//{{{ 4478 { 4479 $div.remove(); 4480 $origimg.show(); 4481 }; 4482 //}}} 4483 4484 function interfaceUpdate(alt)//{{{ 4485 // This method tweaks the interface based on options object. 4486 // Called when options are changed and at end of initialization. 4487 { 4488 options.allowResize ? 4489 alt?Selection.enableOnly():Selection.enableHandles(): 4490 Selection.disableHandles(); 4491 4492 Tracker.setCursor( options.allowSelect? 'crosshair': 'default' ); 4493 Selection.setCursor( options.allowMove? 'move': 'default' ); 4494 4495 $div.css('backgroundColor',options.bgColor); 4496 4497 if ('setSelect' in options) { 4498 setSelect(opt.setSelect); 4499 Selection.done(); 4500 delete(options.setSelect); 4501 } 4502 4503 if ('trueSize' in options) { 4504 xscale = options.trueSize[0] / boundx; 4505 yscale = options.trueSize[1] / boundy; 4506 } 4507 4508 xlimit = options.maxSize[0] || 0; 4509 ylimit = options.maxSize[1] || 0; 4510 xmin = options.minSize[0] || 0; 4511 ymin = options.minSize[1] || 0; 4512 4513 if ('outerImage' in options) 4514 { 4515 $img.attr('src',options.outerImage); 4516 delete(options.outerImage); 4517 } 4518 4519 Selection.refresh(); 4520 }; 4521 //}}} 4522 4523 // }}} 4524 4525 $hdl_holder.hide(); 4526 interfaceUpdate(true); 4527 4528 var api = { 4529 animateTo: animateTo, 4530 setSelect: setSelect, 4531 setOptions: setOptionsNew, 4532 tellSelect: tellSelect, 4533 tellScaled: tellScaled, 4534 4535 disable: disableCrop, 4536 enable: enableCrop, 4537 cancel: cancelCrop, 4538 4539 focus: KeyManager.watchKeys, 4540 4541 getBounds: function() { return [ boundx * xscale, boundy * yscale ]; }, 4542 getWidgetSize: function() { return [ boundx, boundy ]; }, 4543 4544 release: Selection.release, 4545 destroy: destroy 4546 4547 }; 4548 4549 $origimg.data('Jcrop',api); 4550 return api; 4551 }; 4552 4553 $.fn.Jcrop = function(options)/*{{{*/ 4554 { 4555 function attachWhenDone(from)/*{{{*/ 4556 { 4557 var loadsrc = options.useImg || from.src; 4558 var img = new Image(); 4559 img.onload = function() { $.Jcrop(from,options); }; 4560 img.src = loadsrc; 4561 }; 4562 /*}}}*/ 4563 if (typeof(options) !== 'object') options = { }; 4564 4565 // Iterate over each object, attach Jcrop 4566 this.each(function() 4567 { 4568 // If we've already attached to this object 4569 if ($(this).data('Jcrop')) 4570 { 4571 // The API can be requested this way (undocumented) 4572 if (options == 'api') return $(this).data('Jcrop'); 4573 // Otherwise, we just reset the options... 4574 else $(this).data('Jcrop').setOptions(options); 4575 } 4576 // If we haven't been attached, preload and attach 4577 else attachWhenDone(this); 4578 }); 4579 4580 // Return "this" so we're chainable a la jQuery plugin-style! 4581 return this; 4582 }; 4583 /*}}}*/ 4584 4585 })(jQuery); 4586 ]]></data></item> 4587 <item key="id"><![CDATA[jcrop.js]]></item> 4588 <item key="mandatory" type="int">0</item> 4589 <item key="multilang" type="int">0</item> 4590 <item key="name"><![CDATA[jcrop.js]]></item> 4591 <item key="repetitive" type="int">0</item> 4592 <item key="type"><![CDATA[resource]]></item> 4593 </dictionary> 4594 </item> 4595 <item type="dictionary"><dictionary> 4596 <item key="custom"> 4597 <data content_type="application/x-javascript" filename="import.js" type="file">766172202474656d705f6469616c6f6709090909093d206e756c6c3b0d0a766172202474656d705f6974656d5f636f6e7461696e6572093d206e756c6c3b0d0a7661722074656d705f656d7074795f696d67090909093d2027656d7074792e706e67273b0d0a7661722074656d705f6e6f5f7468756d625f6c69737409093d206e756c6c3b0d0a7661722074656d705f6e6f745f617661696c61626c6509093d20276e6f7420617661696c61626c65273b0d0a7661722074656d705f70617468090909090909093d206e756c6c3b0d0a7661722074656d705f7468756d626c6573735f6974656d73093d206e756c6c3b0d0a0d0a7661722074656d705f63726f705f61706909090909093d206e756c6c3b0d0a766172202474656d705f63726f700909090909093d206e756c6c3b0d0a0d0a66756e6374696f6e20636865636b4974656d28246f626a290d0a7b0d0a0969662028246f626a2e617474722827636c61737327292e696e6465784f662827696d706f72745f66696c652729203e202d31290d0a0909246f626a203d20246f626a2e706172656e747328272e696d706f72745f6f626a65637427292e65712830293b0d0a0d0a0969662028246f626a2e617474722827636c61737327292e696e6465784f662827696d706f72745f6f626a6563742729203e202d31290d0a097b0d0a09097661722074656d705f66696c6573203d20246f626a2e6368696c6472656e28276469765b636c6173732a3d22696d706f72745f66696c65225d3a6c7428332927293b0d0a09090d0a090974656d705f66696c65732e656163682866756e6374696f6e28696e6465782c206f626a290d0a0909097b0d0a0909090976617220246f626a203d2024286f626a293b0d0a090909090d0a0909090969662028246f626a2e6368696c6472656e2827696e7075745b6e616d653d2266696c656e616d65225d27292e65712830292e76616c2829203d3d20274e6f6e6527290d0a090909097b0d0a0909090909246f626a2e647261676761626c65282764697361626c6527293b0d0a0909090909246f626a2e64726f707061626c652827656e61626c6527293b0d0a090909097d0d0a09090909656c73650d0a090909097b0d0a0909090909246f626a2e647261676761626c652827656e61626c6527293b0d0a0909090909246f626a2e64726f707061626c65282764697361626c6527293b0d0a090909097d0d0a0909097d293b0d0a0909090d0a09096966202874656d705f66696c65732e6c656e677468203d3d20246f626a2e6368696c6472656e28272e75692d647261676761626c652d64697361626c656427292e6c656e677468290d0a09097b0d0a090909246f626a2e647261676761626c65282764657374726f7927293b0d0a09090964656c6574654974656d28246f626a2e706172656e747328276c692729293b0d0a09097d0d0a097d0d0a7d0d0a0d0a66756e6374696f6e20636c6561724f626a28246f626a290d0a7b0d0a092f2f20636c6561722068696464656e2076616c7565730d0a09246f626a2e6368696c6472656e2827696e7075743a68696464656e27292e76616c28274e6f6e6527293b0d0a092f2f20636c6561722066696c656e616d650d0a09246f626a2e6368696c6472656e28277370616e27292e746578742874656d705f6e6f745f617661696c61626c65293b0d0a092f2f2073657420696d61676520746f20656d7074792d696d670d0a09246f626a2e6368696c6472656e2827696d6727292e65712830292e617474722827737263272c2074656d705f656d7074795f696d67293b0d0a7d0d0a0d0a66756e6374696f6e20636f70794461746128247372632c202464657374290d0a7b0d0a0924646573742e617070656e6428247372632e6368696c6472656e2827696e7075743a68696464656e27292e636c6f6e652829293b0d0a0924646573742e617070656e6428247372632e6368696c6472656e28277370616e27292e636c6f6e652829293b0d0a0924646573742e617070656e6428247372632e6368696c6472656e2827696d6727292e636c6f6e652829293b0d0a7d0d0a0d0a66756e6374696f6e20636f707944617461546f54726173682824737263290d0a7b0d0a09766172202474656d705f6c69203d202428646f63756d656e742e637265617465456c656d656e7428276c692729293b0d0a090d0a09636f70794461746128247372632c202474656d705f6c69293b0d0a090d0a092f2f20696e6974206e6577206974656d20617320647261676761626c650d0a09696e697454726173684974656d282474656d705f6c69293b0d0a090d0a092f2f20617070656e6420696d706f72745f66696c6520746f2074726173680d0a092428272366696c655f74726173685f66696c657327292e617070656e64282474656d705f6c69293b0d0a090d0a09636c6561724f626a2824737263293b0d0a7d0d0a0d0a66756e6374696f6e206372656174655468756d627328290d0a7b0d0a0974656d705f7468756d626c6573735f6974656d73203d206765745468756d626c6573734974656d7328293b0d0a090d0a0968616e646c655468756d626c6573734974656d7328293b0d0a7d0d0a0d0a66756e6374696f6e2064656c6574654974656d28246f626a290d0a7b0d0a09246f626a2e666164654f75742827736c6f77272c2066756e6374696f6e2829207b20242874686973292e72656d6f766528293b207d20290d0a7d0d0a0d0a66756e6374696f6e2064726f704974656d546f496d706f727446696c6528652c207569290d0a7b0d0a097661722074656d705f7479706509090909093d20242874686973292e6368696c6472656e28273a68656164657227292e65712830292e7465787428292e7265706c616365282f5b3a5c735d2f672c202727293b0d0a09766172202474656d705f646573745f686561646572093d20242874686973292e6368696c6472656e28273a68656164657227292e65712830292e636c6f6e6528293b0d0a09766172202474656d705f646573745f706172656e74093d206e756c6c3b0d0a09766172202474656d705f64657374090909093d206e756c6c3b0d0a09766172202474656d705f73726320090909093d2075692e647261676761626c653b0d0a090d0a0976617220646573745f69735f6e657709093d20242874686973292e706172656e747328272366696c655f6e657727292e6c656e677468203e20303b0d0a09766172207372635f69735f7472617368093d2075692e647261676761626c652e706172656e747328272366696c655f747261736827292e6c656e677468203e20303b0d0a090d0a092474656d705f646573745f706172656e74203d20646573745f69735f6e6577203f20242874686973292e706172656e747328276c6927292e65712830292e636c6f6e652829203a20242874686973292e706172656e747328276c6927292e65712830293b0d0a092474656d705f64657374090909093d202474656d705f646573745f706172656e742e6368696c6472656e282764697627292e65712830292e6368696c6472656e28276469765b6e616d653d27202b2074656d705f74797065202b20275d27292e65712830293b0d0a090d0a0969662028646573745f69735f6e6577290d0a097b0d0a09092f2f20617070656e6420636c6f6e6520696e2066696c655f696d706f7274206c6973740d0a09092428272366696c655f696d706f7274203e20756c27292e65712830292e617070656e64282474656d705f646573745f706172656e74293b0d0a09092f2f2073657420696d706f72745f6f626a656374206e616d650d0a09092474656d705f646573742e7369626c696e677328277027292e65712830292e74657874282474656d705f7372632e6368696c6472656e28277370616e27292e65712830292e746578742829293b0d0a097d0d0a090d0a092474656d705f646573742e656d70747928293b0d0a092f2f20636f7079206461746120696e746f206e657720696d706f72745f66696c650d0a09636f707944617461282474656d705f7372632c202474656d705f64657374293b0d0a092f2f20636f70792068656164657220696e746f20696d706f72745f66696c6520286974207761732064656c65746564207768696c6520656d7074792d696e67290d0a092474656d705f646573742e6368696c6472656e2827696e7075743a6c61737427292e6166746572282474656d705f646573745f686561646572293b0d0a090d0a0969662028646573745f69735f6e6577290d0a0909696e69744974656d282474656d705f646573745f706172656e742e6368696c6472656e282764697627292e6571283029293b0d0a090d0a09636865636b4974656d282474656d705f646573745f706172656e742e6368696c6472656e28276469765b636c6173732a3d22696d706f72745f6f626a656374225d27292e6571283029293b0d0a0d0a09696620287372635f69735f7472617368290d0a097b0d0a09092f2f2064656c657465207472617368206974656d0d0a090964656c6574654974656d282474656d705f737263293b0d0a097d0d0a09656c73650d0a097b0d0a0909636c6561724f626a282474656d705f737263293b0d0a0909636865636b4974656d282474656d705f737263293b0d0a097d0d0a7d0d0a0d0a66756e6374696f6e206765745468756d626c6573734974656d7328290d0a7b0d0a097661722074656d705f726573756c74203d206e657720417272617928293b0d0a090d0a092474656d705f6974656d5f636f6e7461696e65722e6368696c6472656e28276c6927292e656163682866756e6374696f6e28696e6465782c206974656d290d0a097b0d0a09096966202824286974656d292e6368696c6472656e282764697627292e65712830292e6368696c6472656e28276469763a5b6e616d653d22736d616c6c225d27292e65712830292e0d0a09090909096368696c6472656e2827696e7075745b6e616d653d2266696c656e616d65225d27292e65712830292e76616c2829203d3d20274e6f6e6527290d0a09090974656d705f726573756c742e707573682824286974656d292e6368696c6472656e282764697627292e6571283029293b0d0a097d293b0d0a090d0a0972657475726e2074656d705f726573756c743b0d0a7d0d0a0d0a66756e6374696f6e2068616e646c655468756d626c6573734974656d7328290d0a7b0d0a096966202874656d705f7468756d626c6573735f6974656d732e6c656e677468203e2030290d0a097b0d0a09096966202874656d705f63726f705f61706920213d206e756c6c290d0a09090974656d705f63726f705f6170692e64657374726f7928293b0d0a0d0a09092474656d705f63726f702e617474722827737263272c2074656d705f70617468202b20272f27202b2074656d705f7468756d626c6573735f6974656d735b305d2e6368696c6472656e28276469763a5b6e616d653d226d656469756d225d27292e65712830292e0d0a09090909090909090909090909096368696c6472656e2827696e7075745b6e616d653d2266696c656e616d65225d27292e65712830292e76616c2829293b0d0a09090d0a09092474656d705f6469616c6f672e6469616c6f6728276f70656e27293b0d0a09090d0a090974656d705f63726f705f617069203d20242e4a63726f7028272367616c6c6572795f63726f70272c207b2068616e646c6573203a2074727565207d293b0d0a09090d0a09092f2a0d0a0909766172202474656d705f63726f70203d202428272367616c6c6572795f63726f7027293b0d0a09090d0a09092474656d705f63726f702e617474722827737263272c2074656d705f70617468202b20272f27202b20242874656d705f6e6f5f7468756d625f6c697374292e6368696c6472656e282764697627292e65712830292e6368696c6472656e28276469763a5b6e616d653d226d656469756d225d27292e65712830292e6368696c6472656e28277370616e27292e65712830292e746578742829293b0d0a09090d0a09092474656d705f63726f702e4a63726f70280d0a09097b0d0a09090968616e646c6573203a20747275650d0a09097d293b0d0a09092a2f0d0a097d0d0a7d0d0a0d0a66756e6374696f6e20696e69744974656d28246f626a290d0a7b0d0a096966202821246f626a2e686173436c6173732827696d706f72745f6f626a6563742729290d0a0909246f626a2e616464436c6173732827696d706f72745f6f626a65637427293b0d0a09246f626a2e6368696c6472656e28276469763a6e6f74285b636c6173732a3d22696d706f72745f66696c65225d2927292e616464436c6173732827696d706f72745f66696c6527293b0d0a090d0a09246f626a2e66696e6428272e696d706f72745f66696c6527292e64726f707061626c65280d0a09097b0d0a0909096163636570743a20272e696d706f72745f66696c652c202e74726173685f66696c65272c0d0a09090964726f70093a2064726f704974656d546f496d706f727446696c650d0a09097d293b0d0a09246f626a2e61646428272e696d706f72745f66696c6527292e647261676761626c65280d0a09097b0d0a09090968656c7065723a2027636c6f6e65272c200d0a0909097265766572743a2027696e76616c6964272c200d0a090909637572736f723a20276d6f7665272c200d0a09097d293b0d0a7d0d0a0d0a66756e6374696f6e20696e697454726173684974656d28246f626a290d0a7b0d0a096966202821246f626a2e686173436c617373282774726173685f66696c652729290d0a097b0d0a0909246f626a2e616464436c617373282774726173685f66696c6527293b0d0a0909246f626a2e647261676761626c65280d0a09097b0d0a09090968656c7065723a2027636c6f6e65272c200d0a0909097265766572743a2027696e76616c6964272c200d0a090909637572736f723a20276d6f7665272c200d0a09097d293b0d0a097d0d0a7d0d0a0d0a66756e6374696f6e207375626d6974466f726d28290d0a7b0d0a097661722074656d705f786d6c203d2027273b0d0a090d0a0974656d705f786d6c202b3d20273c6c6973743e5c6e273b0d0a090d0a092f2f20636f6e76657274206974656d7320696e746f20786d6c0d0a092474656d705f6974656d5f636f6e7461696e65722e6368696c6472656e28276c6927292e656163682866756e6374696f6e2028696e6465782c206f626a290d0a097b0d0a090974656d705f786d6c202b3d20223c6974656d20747970653d5c2264696374696f6e6172795c223e3c64696374696f6e6172793e5c6e223b0d0a09090d0a090924286f626a292e6368696c6472656e282764697627292e65712830292e6368696c6472656e28276469763a5b636c6173732a3d22696d706f72745f66696c65225d27292e656163682866756e6374696f6e2028696e6465782c206f626a290d0a09097b0d0a0909090974656d705f786d6c202b3d20273c6974656d206b65793d2227202b2024286f626a292e6174747228276e616d652729202b20272220747970653d5c2264696374696f6e6172795c223e5c6e270d0a0909090974656d705f786d6c202b3d20223c64696374696f6e6172793e5c6e223b0d0a090909090d0a090909092f2f206164642066696c656e616d650d0a0909090974656d705f786d6c202b3d20273c6974656d206b65793d2266696c656e616d65223e5c6e270d0a0909090974656d705f786d6c202b3d20273c215b434441544127202b20275b27202b2024286f626a292e6368696c6472656e2827696e7075745b6e616d653d2266696c656e616d65225d27292e65712830292e76616c2829202b20275d27202b20275d3e273b0d0a0909090974656d705f786d6c202b3d20273c2f6974656d3e5c6e273b0d0a090909092f2f206164642063726f702d646174610d0a0909090974656d705f786d6c202b3d20273c6974656d206b65793d2263726f70223e270d0a0909090974656d705f786d6c202b3d20273c215b434441544127202b20275b27202b2024286f626a292e6368696c6472656e2827696e7075745b6e616d653d2263726f70225d27292e65712830292e76616c2829202b20275d27202b20275d3e273b0d0a0909090974656d705f786d6c202b3d20273c2f6974656d3e5c6e273b0d0a090909090d0a0909090974656d705f786d6c202b3d20273c2f64696374696f6e6172793e5c6e273b0d0a0909090974656d705f786d6c202b3d20273c2f6974656d3e5c6e273b0d0a09097d293b0d0a09090d0a090974656d705f786d6c202b3d20273c2f64696374696f6e6172793e3c2f6974656d3e5c6e273b0d0a097d293b0d0a090d0a0974656d705f786d6c202b3d20273c2f6c6973743e5c6e273b0d0a090d0a0924282723696d706f72745f666f726d203e20696e7075743a68696464656e27292e76616c2874656d705f786d6c293b0d0a090d0a0972657475726e20747275653b0d0a7d0d0a0d0a242827646f63756d656e7427292e72656164792866756e6374696f6e2829200d0a7b0d0a092474656d705f6469616c6f6709090909093d202428272367616c6c6572795f6469616c6f6727293b0d0a092474656d705f6974656d5f636f6e7461696e6572093d202428272366696c655f696d706f7274203e20756c3a6e6f74285b69645d2927293b0d0a0974656d705f70617468200909090909093d2024282723696d706f72745f6672616d65203e20696e7075743a68696464656e27292e65712830292e76616c28293b0d0a090d0a092428272366696c655f747261736827292e64726f707061626c65280d0a097b200d0a09096163636570743a20222e696d706f72745f6f626a6563742c202e696d706f72745f66696c65222c200d0a0909616374697665436c6173733a202764726f707061626c652d616374697665272c200d0a0909686f766572436c6173733a202764726f707061626c652d686f766572272c0d0a090964726f703a2066756e6374696f6e28652c207569290d0a0909097b200d0a090909096966202875692e647261676761626c652e706172656e747328272366696c655f696d706f727427292e6c656e677468290d0a090909097b0d0a09090909092f2f20636f7079206120636f6d706c65746520696d706f72745f6f626a65637420746f2074726173680d0a09090909096966202875692e647261676761626c652e686173436c6173732827696d706f72745f6f626a6563742729290d0a09090909097b0d0a09090909090975692e647261676761626c652e6368696c6472656e28272e696d706f72745f66696c653a6e6f74285b636c6173732a3d2275692d647261676761626c652d64697361626c6564225d2927292e656163682866756e6374696f6e28696e6465782c206f626a290d0a090909090909097b0d0a0909090909090909636f707944617461546f54726173682824286f626a29293b0d0a090909090909097d293b0d0a09090909097d0d0a09090909092f2f20636f707920612073696e676c6520696d706f72745f66696c6520746f2074726173680d0a0909090909656c73650d0a09090909097b0d0a090909090909636f707944617461546f54726173682875692e647261676761626c65293b0d0a09090909097d0d0a09090909090d0a0909090909636865636b4974656d2875692e647261676761626c65293b0d0a090909097d0d0a0909097d0d0a097d293b0d0a092f2f2064726f7020696d706f72745f66696c65206174206e65772d6f626a6563740d0a092428272366696c655f6e6577203e206c69203e20646976203e206469765b6e616d655d27292e64726f707061626c65280d0a097b0d0a09096163636570743a20272e696d706f72745f66696c652c202e74726173685f66696c65272c0d0a090964726f70093a2064726f704974656d546f496d706f727446696c650d0a097d293b0d0a090d0a092428272e696d706f72745f6f626a65637427292e656163682866756e6374696f6e28696e6465782c206f626a290d0a097b0d0a0909696e69744974656d2824286f626a29290d0a0909636865636b4974656d2824286f626a29293b0d0a097d293b0d0a090d0a092474656d705f63726f70203d202428272367616c6c6572795f63726f7027293b0d0a090d0a092428272367616c6c6572795f627574746f6e5f63726f7027292e636c69636b2866756e6374696f6e28290d0a097b0d0a09097661722074656d705f636f6f726473203d2074656d705f63726f705f6170692e74656c6c53656c65637428293b0d0a09090d0a090974656d705f7468756d626c6573735f6974656d735b305d2e6368696c6472656e28276469765b6e616d653d22736d616c6c225d27292e65712830292e6368696c6472656e2827696e7075745b6e616d653d2263726f70225d27292e65712830292e0d0a09090976616c2874656d705f636f6f7264732e78202b20272c27202b2074656d705f636f6f7264732e79202b20272c27202b2074656d705f636f6f7264732e7832202b20272c27202b2074656d705f636f6f7264732e7932293b0d0a0909090d0a090974656d705f7468756d626c6573735f6974656d732e736869667428293b0d0a09090d0a09096966202874656d705f7468756d626c6573735f6974656d732e6c656e677468203e2030290d0a09090968616e646c655468756d626c6573734974656d7328293b0d0a0909656c73650d0a09097b0d0a090909696620282474656d705f6469616c6f672e69734f70656e290d0a090909092474656d705f6469616c6f672e636c6f736528293b0d0a09097d0d0a097d293b0d0a090d0a092474656d705f6469616c6f672e6469616c6f67280d0a097b0d0a09096175746f4f70656e3a2066616c73652c0d0a0909686569676874093a203730302c0d0a09096d6f64616c09093a20747275652c0d0a09097469746c6509093a202743726f70205468756d62272c0d0a0909776964746809093a203835300d0a097d293b0d0a7d293b</data></item> 2691 4598 <item key="id"><![CDATA[import.js]]></item> 2692 4599 <item key="mandatory" type="int">0</item> … … 3146 5053 return temp_result 3147 5054 3148 def getFileData(type, import_dict, file_dict): 3149 if (import_dict.has_key(type) and (file_dict.has_key(import_dict[type]))): 3150 temp_data = file_dict[import_dict[type]] 5055 def createTempImages(file_list): 5056 temp_folder = context.temp_folder 5057 5058 temp_folder_id = 'zmsgallery_import' 5059 if (temp_folder_id not in temp_folder.objectIds()): 5060 temp_folder.manage_addFolder(temp_folder_id) 5061 5062 temp_folder = getattr(temp_folder, temp_folder_id) 5063 temp_file_ids = temp_folder.objectIds() 5064 5065 for i in range(0, len(file_list)): 5066 if (file_list[i]['filename'] in temp_file_ids): 5067 temp_folder.manage_delObjects(file_list[i]['filename']) 5068 5069 temp_folder.manage_addImage(file_list[i]['filename'], file_list[i]['data']) 5070 # create a preview image 5071 file_list[i]['preview_id'] = context.ZMSGallery_preview(temp_folder, file_list[i]['filename'], 25, 25) 5072 5073 ''' 5074 temp_id = context.getId() + '_' + REQUEST['AUTHENTICATED_USER'].getId() 5075 if temp_id in temp_folder.objectIds(): 5076 temp_folder.manage_delObjects([temp_id]) 3151 5077 else: 3152 temp_data = None 5078 temp_image_id = temp_folder.manage_addImage(temp_id, files_dict['file1.jpg']['medium']['img_obj']['data']) 5079 ''' 5080 5081 return temp_folder.absolute_url() 5082 5083 def getFileData(temp_folder, filename): 5084 temp_data = None 5085 5086 if ((temp_folder is not None) and (filename in temp_folder.objectIds())): 5087 temp_data = getattr(temp_folder, filename) 5088 temp_data = {'filename' : temp_data.getId(), 5089 'data' : temp_data.data, 5090 'content_type' : temp_data.getContentType(), 5091 'size' : temp_data.get_size()} 3153 5092 3154 5093 return temp_data … … 3164 5103 temp_file_dict[temp_short_name] = {'small' : None, 'medium' : None, 'large' : None} 3165 5104 5105 temp_image = context.ImageFromData(one_file['data'], one_file['filename']) 5106 3166 5107 temp_type = (len(temp_type) > 0) and temp_type[0][1:-1] or 'medium' 3167 temp_file_dict[temp_short_name][temp_type] = {'filename' : one_file['filename'], 'img_obj' : one_file} 5108 temp_file_dict[temp_short_name][temp_type] = {'filename' : one_file['filename'], 5109 'preview_id' : one_file['preview_id'], 5110 'height' : temp_image.getHeight(), 5111 'width' : temp_image.getWidth(), 5112 'img_obj' : one_file} 3168 5113 3169 5114 return temp_file_dict … … 3175 5120 return temp_files 3176 5121 3177 def importFiles(import_list, file_list): 3178 temp_file_dict = {} 3179 for one_file in file_list: 3180 temp_file_dict[one_file['filename']] = one_file 5122 def importFiles(import_list): 5123 temp_folder = context.temp_folder 3181 5124 3182 for one_import in import_list: 3183 temp_values = {'id_prefix' : 'galleryImages', 3184 'active' : 1, 3185 'align' : 'LEFT', 3186 'img' : getFileData('small', one_import, temp_file_dict), 3187 'imghires' : getFileData('medium', one_import, temp_file_dict), 3188 'imgsuperres' : getFileData('large', one_import, temp_file_dict)} 3189 3190 context.manage_addZMSCustom('ZMSGraphic', temp_values, REQUEST) 3191 3192 def renderFiles(files_dict): 5125 temp_folder_id = 'zmsgallery_import' 5126 if (temp_folder_id in temp_folder.objectIds()): 5127 temp_folder = getattr(context.temp_folder, temp_folder_id) 5128 5129 for one_import in import_list: 5130 if ((one_import['small']['filename'].lower() == 'none') and 5131 (len(one_import['small']['crop']) > 0) and 5132 (one_import['medium']['filename'].lower() != 'none')): 5133 temp_box = one_import['small']['crop'].split(',') 5134 temp_box = (int(temp_box[0]), int(temp_box[1]), int(temp_box[2]), int(temp_box[3])) 5135 5136 one_import['small']['filename'] = context.ZMSGallery_crop(temp_folder, one_import['medium']['filename'], temp_box) 5137 5138 temp_values = {'id_prefix' : 'galleryImages', 5139 'active' : 1, 5140 'align' : 'LEFT', 5141 'img' : getFileData(temp_folder, one_import['small']['filename']), 5142 'imghires' : getFileData(temp_folder, one_import['medium']['filename']), 5143 'imgsuperres' : getFileData(temp_folder, one_import['large']['filename'])} 5144 5145 context.manage_addZMSCustom('ZMSGraphic', temp_values, REQUEST) 5146 5147 if(temp_folder_id in context.temp_folder.objectIds()): 5148 context.temp_folder.manage_delObjects(temp_folder_id) 5149 5150 5151 def renderFiles(files_dict, img_path): 3193 5152 temp_result = '' 3194 5153 … … 3197 5156 temp_keys.sort() 3198 5157 3199 temp_result += '<ul> '5158 temp_result += '<ul>\n' 3200 5159 for one_key in temp_keys: 3201 temp_result += '<li> '3202 temp_result += '<div class="import_object"> '3203 temp_result += '<p>%s</p> '%one_key5160 temp_result += '<li>\n' 5161 temp_result += '<div class="import_object">\n' 5162 temp_result += '<p>%s</p>\n'%one_key 3204 5163 3205 5164 temp_key_list = files_dict[one_key].keys() … … 3208 5167 for other_key in temp_key_list: 3209 5168 if (files_dict[one_key][other_key] is None): 3210 temp_text = 'not available' 5169 temp_filename = None 5170 temp_filename_preview = None 5171 temp_text = 'not available' 3211 5172 else: 3212 temp_text = files_dict[one_key][other_key]['filename'] 3213 3214 temp_result += '<div name="%s" class="import_file">'%other_key 3215 temp_result += '<h7>%s: </h7>'%other_key 3216 temp_result += '<span>%s</span>'%temp_text 3217 temp_result += '</div>' 3218 temp_result += '</li>' 5173 temp_filename = files_dict[one_key][other_key]['filename'] 5174 temp_filename_preview = files_dict[one_key][other_key]['preview_id'] 5175 temp_text = files_dict[one_key][other_key]['filename'] 5176 5177 temp_result += renderImage(other_key, temp_text, img_path, temp_filename, temp_filename_preview) 5178 5179 temp_result += '</div>\n' 5180 temp_result += '</li>\n' 3219 5181 3220 temp_result += '</ul>' 5182 temp_result += '</ul>\n' 5183 5184 return temp_result 5185 5186 def renderImage(header, text, img_path, filename = None, filename_preview = None): 5187 if (header is not None and text is not None and img_path is not None): 5188 temp_result = '<div name="%s" class="import_file">\n'%header 5189 temp_result += '<input type="hidden" name="filename" value="%s" />\n'%filename 5190 temp_result += '<input type="hidden" name="filename_preview" value="%s" />\n'%filename_preview 5191 temp_result += '<input type="hidden" name="crop" value="" />\n' 5192 temp_result += '<h7>%s: </h7>\n'%header 5193 temp_result += '<span>%s</span>\n'%text 5194 temp_result += '<img src="%s/%s" width="25" height="25" />\n'%(img_path, filename_preview) 5195 temp_result += '</div>\n' 5196 else: 5197 temp_result = '' 3221 5198 3222 5199 return temp_result … … 3229 5206 3230 5207 if (temp_xml is not None): 3231 importFiles(context.parseXmlString(temp_xml) , getFileList())5208 importFiles(context.parseXmlString(temp_xml)) 3232 5209 context.setObjProperty('galleryUpload', None, temp_lang) 3233 5210 else: 5211 temp_file_list = getFileList() 5212 temp_path = createTempImages(temp_file_list) 5213 3234 5214 temp_result += '<div id="import_frame" style="border:1px solid #000; height:300px; padding:5px;">' 5215 temp_result += '<input type="hidden" name="path" value="%s" />'%temp_path 3235 5216 temp_result += '<div id="file_import" style="text-align:left; display:block; float:left; width:60%; min-height:12em; border:1px solid #000;">' 3236 temp_result += renderFiles(getFileDict( getFileList()))5217 temp_result += renderFiles(getFileDict(temp_file_list), temp_path) 3237 5218 3238 temp_result += '<ul id="file_new"> '3239 temp_result += '<li> <div>'3240 temp_result += '<p>empty object</p> '3241 temp_result += '<div name="small"><h7>small:</h7><span>not available</span></div>'3242 temp_result += '<div name="medium"><h7>medium:</h7><span>not available</span></div>'3243 temp_result += '<div name="large"><h7>large:</h7><span>not available</span></div>'3244 temp_result += '</div> </li></ul>'5219 temp_result += '<ul id="file_new">\n' 5220 temp_result += '<li>\n<div>\n' 5221 temp_result += '<p>empty object</p>\n' 5222 temp_result += renderImage('small', 'not available', temp_path, None, None) 5223 temp_result += renderImage('medium', 'not available', temp_path, None, None) 5224 temp_result += renderImage('large', 'not available', temp_path, None, None) 5225 temp_result += '</div>\n</li>\n</ul>\n' 3245 5226 3246 temp_result += '</div>' 3247 temp_result += '<div id="file_trash" style="margin:1px; border:1px solid #000; text-align:left; display:block; float:right; width:32%; min-height:18em;">' 3248 temp_result += '<p>insert trash here</p>' 3249 temp_result += '<ul id="file_trash_files"></ul>' 3250 temp_result += '</div>' 3251 temp_result += '<form id="import_form" name="import_form" action="%s/manage?lang=%s&manage_lang=%s" method="post" onsubmit="return submitForm();">'%(context.absolute_url(), temp_lang, temp_lang) 3252 temp_result += '<input type="hidden" id="import_files_xml" name="import_files_xml" value="" />' 3253 temp_result += '<input type="submit" value="import files" />' 3254 temp_result += '</form>' 3255 temp_result += '</div>' 3256 5227 temp_result += '</div>\n' 5228 temp_result += '<div id="file_trash" style="margin:1px; border:1px solid #000; text-align:left; display:block; float:right; width:32%; min-height:18em;">\n' 5229 temp_result += '<p>insert trash here</p>\n' 5230 temp_result += '<ul id="file_trash_files"></ul>\n' 5231 temp_result += '</div>\n' 5232 temp_result += '<form id="import_form" name="import_form" action="%s/manage?lang=%s&manage_lang=%s" method="post" onsubmit="return submitForm();">\n'%(context.absolute_url(), temp_lang, temp_lang) 5233 temp_result += '<input type="hidden" id="import_files_xml" name="import_files_xml" value="" />\n' 5234 temp_result += '<input type="submit" value="import files" />\n' 5235 temp_result += '</form>\n' 5236 temp_result += '</div>\n' 5237 5238 temp_result += '<input type="button" onclick="createThumbs();" value="do something" />\n' 5239 3257 5240 return temp_result 3258 5241 … … 3269 5252 <item type="dictionary"><dictionary> 3270 5253 <item key="custom"><![CDATA[<dtml-var manage_page_header> 3271 <title>Import Images-Files...</title>3272 3273 5254 <script type="text/javascript" src="metaobj_manager/ZMSGallery.ui.core.js"></script> 3274 5255 <script type="text/javascript" src="metaobj_manager/ZMSGallery.ui.draggable.js"></script> 3275 5256 <script type="text/javascript" src="metaobj_manager/ZMSGallery.ui.droppable.js"></script> 5257 <script type="text/javascript" src="metaobj_manager/ZMSGallery.ui.dialog.js"></script> 5258 <script type="text/javascript" src="metaobj_manager/ZMSGallery.jcrop.js"></script> 3276 5259 3277 5260 <script type="text/javascript" src="metaobj_manager/ZMSGallery.import.js"></script> 5261 5262 <link type="text/css" href="<dtml-var "ZMS_COMMON">/css/jquery/cupertino/ui.all.css" rel="stylesheet" /> 5263 <link type="text/css" href="<dtml-var "ZMS_COMMON">/css/jcrop/jcrop.css" rel="stylesheet" /> 3278 5264 </head> 3279 5265 <dtml-var "manage_tabs(_,_,my_manage_options=[{'label':'Import Image-Files...','action':''}])"> 3280 5266 <dtml-var f_bo_area> 3281 5267 3282 <dtml-comment>3283 <form action="plant_importKML" method="post" enctype="multipart/form-data">3284 <table cellspacing="1" cellpadding="1" border="0">3285 <tr valign="top">3286 <td class="form-label">Import KML</td>3287 <td class="form-element"><input class="form-small" type="file" size="25" name="plant_kml_upload"/></td>3288 </tr>3289 <tr>3290 <td class="form-label"> </td>3291 <td class="form-element">3292 <br />3293 <input class="form-element" type="submit" name="btn_import" value=" Import ">3294 <input class="form-element" type="submit" name="btn_cancel" value=" Cancel ">3295 </td>3296 </tr>3297 </table>3298 </form>3299 </dtml-comment>3300 3301 3302 5268 <dtml-var "ZMSGallery_handleImageImport_py()"> 3303 5269 3304 <dtml-comment> 3305 <dtml-call "setObjProperty('galleryUpload',_.None,lang)"> 3306 </dtml-comment> 5270 <div id="gallery_dialog"> 5271 <img id="gallery_crop" src="" /> 5272 <input id="gallery_button_crop" type="button" value="Crop" /> 5273 </div> 3307 5274 3308 5275 <dtml-var f_eo_area> … … 3314 5281 <item key="repetitive" type="int">0</item> 3315 5282 <item key="type"><![CDATA[DTML Method]]></item> 5283 </dictionary> 5284 </item> 5285 <item type="dictionary"><dictionary> 5286 <item key="custom"><![CDATA[from PIL import Image 5287 from cStringIO import StringIO 5288 import os.path 5289 5290 def ZMSGallery_crop(temp_folder, source_id, coords): 5291 temp_result = None 5292 5293 if ((temp_folder is not None) and (source_id in temp_folder.objectIds())): 5294 temp_source = getattr(temp_folder, source_id) 5295 temp_source = StringIO(str(temp_source.data)) 5296 5297 temp_image = Image.open(temp_source) 5298 temp_image = temp_image.convert('RGB') 5299 temp_thumb = temp_image.crop(coords) 5300 5301 temp_dest = StringIO() 5302 temp_thumb.save(temp_dest, "JPEG") 5303 temp_dest.seek(0) 5304 5305 temp_path, temp_ext = os.path.splitext(source_id) 5306 temp_dest_id = temp_path + '_thumb.jpg' 5307 5308 if (temp_dest_id in temp_folder.objectIds()): 5309 temp_folder.manage_delObjects(temp_dest_id) 5310 5311 temp_folder.manage_addImage(temp_dest_id, temp_dest) 5312 5313 temp_result = temp_dest_id 5314 5315 return temp_result]]></item> 5316 <item key="id"><![CDATA[ZMSGallery_crop]]></item> 5317 <item key="mandatory" type="int">0</item> 5318 <item key="multilang" type="int">0</item> 5319 <item key="name"><![CDATA[ZMSGallery_crop]]></item> 5320 <item key="repetitive" type="int">0</item> 5321 <item key="type"><![CDATA[External Method]]></item> 5322 </dictionary> 5323 </item> 5324 <item type="dictionary"><dictionary> 5325 <item key="custom"><![CDATA[from PIL import Image 5326 from cStringIO import StringIO 5327 import os.path 5328 5329 def ZMSGallery_preview(temp_folder, source_id, max_widht, max_height): 5330 temp_result = None 5331 5332 if ((temp_folder is not None) and (source_id in temp_folder.objectIds())): 5333 temp_source = getattr(temp_folder, source_id) 5334 temp_source = StringIO(str(temp_source.data)) 5335 5336 temp_image = Image.open(temp_source) 5337 temp_image = temp_image.convert('RGB') 5338 temp_image.thumbnail((max_widht, max_height)) 5339 5340 temp_dest = StringIO() 5341 temp_image.save(temp_dest, "JPEG") 5342 temp_dest.seek(0) 5343 5344 temp_path, temp_ext = os.path.splitext(source_id) 5345 temp_dest_id = temp_path + '_preview.jpg' 5346 5347 if (temp_dest_id in temp_folder.objectIds()): 5348 temp_folder.manage_delObjects(temp_dest_id) 5349 5350 temp_folder.manage_addImage(temp_dest_id, temp_dest) 5351 5352 temp_result = temp_dest_id 5353 5354 return temp_result]]></item> 5355 <item key="id"><![CDATA[ZMSGallery_preview]]></item> 5356 <item key="mandatory" type="int">0</item> 5357 <item key="multilang" type="int">0</item> 5358 <item key="name"><![CDATA[ZMSGallery_preview]]></item> 5359 <item key="repetitive" type="int">0</item> 5360 <item key="type"><![CDATA[External Method]]></item> 3316 5361 </dictionary> 3317 5362 </item>
Note: See TracChangeset
for help on using the changeset viewer.
