wax_theme 0.1.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/_includes/wax/collection/gallery.html +33 -0
- data/_includes/wax/collection/interactive_metadata.html +53 -0
- data/_includes/wax/footer.html +35 -0
- data/_includes/wax/head.html +16 -0
- data/_includes/wax/header.html +35 -0
- data/_includes/wax/image_viewer/leaflet.html +11 -0
- data/_includes/wax/image_viewer/mirador.html +8 -0
- data/_includes/wax/image_viewer/simple.html +5 -0
- data/_includes/wax/inline_image.html +12 -0
- data/_includes/wax/item/metadata.html +23 -0
- data/_includes/wax/item/pagination.html +23 -0
- data/_includes/wax/mirador_compare.html +11 -0
- data/_includes/wax/parallax.html +23 -0
- data/_includes/wax/search.html +12 -0
- data/_layouts/wax/collection_item.html +41 -0
- data/_layouts/wax/default.html +20 -0
- data/_layouts/wax/exhibit.html +15 -0
- data/_layouts/wax/page.html +13 -0
- data/_layouts/wax/reuse_page.html +7 -0
- data/_sass/_bootstrap.scss +9030 -0
- data/_sass/_syntax.scss +129 -0
- data/_sass/_wax.scss +482 -0
- data/assets/css/datatables.css +24 -0
- data/assets/css/leaflet.css +636 -0
- data/assets/js/bootstrap.min.js +7 -0
- data/assets/js/datatables.min.js +325 -0
- data/assets/js/elasticlunr.min.js +10 -0
- data/assets/js/jquery-3.2.1.min.js +4 -0
- data/assets/js/leaflet-iiif.min.js +8 -0
- data/assets/js/leaflet.js +5 -0
- data/assets/js/popper.min.js +5 -0
- data/assets/js/wax.js +91 -0
- data/assets/logo.png +0 -0
- data/assets/mirador/css/mirador-combined.css +4107 -0
- data/assets/mirador/fonts/FontAwesome.otf +0 -0
- data/assets/mirador/fonts/MaterialIcons-Regular.eot +0 -0
- data/assets/mirador/fonts/MaterialIcons-Regular.ijmap +1 -0
- data/assets/mirador/fonts/MaterialIcons-Regular.svg +2373 -0
- data/assets/mirador/fonts/MaterialIcons-Regular.ttf +0 -0
- data/assets/mirador/fonts/MaterialIcons-Regular.woff +0 -0
- data/assets/mirador/fonts/MaterialIcons-Regular.woff2 +0 -0
- data/assets/mirador/fonts/fontawesome-webfont.eot +0 -0
- data/assets/mirador/fonts/fontawesome-webfont.svg +2671 -0
- data/assets/mirador/fonts/fontawesome-webfont.ttf +0 -0
- data/assets/mirador/fonts/fontawesome-webfont.woff +0 -0
- data/assets/mirador/fonts/fontawesome-webfont.woff2 +0 -0
- data/assets/mirador/images/border_type_1.png +0 -0
- data/assets/mirador/images/border_type_2.png +0 -0
- data/assets/mirador/images/border_type_3.png +0 -0
- data/assets/mirador/images/border_type_4.png +0 -0
- data/assets/mirador/images/border_type_5.png +0 -0
- data/assets/mirador/images/debut_dark.png +0 -0
- data/assets/mirador/locales/ar/translation.json +42 -0
- data/assets/mirador/locales/de/translation.json +103 -0
- data/assets/mirador/locales/en/translation.json +106 -0
- data/assets/mirador/locales/es/translation.json +86 -0
- data/assets/mirador/locales/fr/translation.json +103 -0
- data/assets/mirador/locales/ga/translation.json +97 -0
- data/assets/mirador/locales/ja/translation.json +82 -0
- data/assets/mirador/locales/ko/translation.json +83 -0
- data/assets/mirador/locales/nl/translation.json +39 -0
- data/assets/mirador/locales/zh-CN/translation.json +76 -0
- data/assets/mirador/locales/zh-TW/translation.json +76 -0
- data/assets/mirador/locales/zh/translation.json +74 -0
- data/assets/mirador/mirador.js +49145 -0
- data/assets/mirador/plugins/advlist/index.js +7 -0
- data/assets/mirador/plugins/advlist/plugin.js +160 -0
- data/assets/mirador/plugins/advlist/plugin.min.js +1 -0
- data/assets/mirador/plugins/anchor/index.js +7 -0
- data/assets/mirador/plugins/anchor/plugin.js +118 -0
- data/assets/mirador/plugins/anchor/plugin.min.js +1 -0
- data/assets/mirador/plugins/autolink/index.js +7 -0
- data/assets/mirador/plugins/autolink/plugin.js +180 -0
- data/assets/mirador/plugins/autolink/plugin.min.js +1 -0
- data/assets/mirador/plugins/autoresize/index.js +7 -0
- data/assets/mirador/plugins/autoresize/plugin.js +169 -0
- data/assets/mirador/plugins/autoresize/plugin.min.js +1 -0
- data/assets/mirador/plugins/autosave/index.js +7 -0
- data/assets/mirador/plugins/autosave/plugin.js +226 -0
- data/assets/mirador/plugins/autosave/plugin.min.js +1 -0
- data/assets/mirador/plugins/bbcode/index.js +7 -0
- data/assets/mirador/plugins/bbcode/plugin.js +101 -0
- data/assets/mirador/plugins/bbcode/plugin.min.js +1 -0
- data/assets/mirador/plugins/charmap/index.js +7 -0
- data/assets/mirador/plugins/charmap/plugin.js +1275 -0
- data/assets/mirador/plugins/charmap/plugin.min.js +1 -0
- data/assets/mirador/plugins/code/index.js +7 -0
- data/assets/mirador/plugins/code/plugin.js +94 -0
- data/assets/mirador/plugins/code/plugin.min.js +1 -0
- data/assets/mirador/plugins/codesample/css/prism.css +138 -0
- data/assets/mirador/plugins/codesample/index.js +7 -0
- data/assets/mirador/plugins/codesample/plugin.js +967 -0
- data/assets/mirador/plugins/codesample/plugin.min.js +1 -0
- data/assets/mirador/plugins/colorpicker/index.js +7 -0
- data/assets/mirador/plugins/colorpicker/plugin.js +126 -0
- data/assets/mirador/plugins/colorpicker/plugin.min.js +1 -0
- data/assets/mirador/plugins/contextmenu/index.js +7 -0
- data/assets/mirador/plugins/contextmenu/plugin.js +168 -0
- data/assets/mirador/plugins/contextmenu/plugin.min.js +1 -0
- data/assets/mirador/plugins/directionality/index.js +7 -0
- data/assets/mirador/plugins/directionality/plugin.js +66 -0
- data/assets/mirador/plugins/directionality/plugin.min.js +1 -0
- data/assets/mirador/plugins/emoticons/img/smiley-cool.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-cry.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-embarassed.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-frown.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-innocent.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-kiss.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-laughing.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-sealed.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-smile.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-surprised.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-undecided.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-wink.gif +0 -0
- data/assets/mirador/plugins/emoticons/img/smiley-yell.gif +0 -0
- data/assets/mirador/plugins/emoticons/index.js +7 -0
- data/assets/mirador/plugins/emoticons/plugin.js +87 -0
- data/assets/mirador/plugins/emoticons/plugin.min.js +1 -0
- data/assets/mirador/plugins/fullpage/index.js +7 -0
- data/assets/mirador/plugins/fullpage/plugin.js +519 -0
- data/assets/mirador/plugins/fullpage/plugin.min.js +1 -0
- data/assets/mirador/plugins/fullscreen/index.js +7 -0
- data/assets/mirador/plugins/fullscreen/plugin.js +177 -0
- data/assets/mirador/plugins/fullscreen/plugin.min.js +1 -0
- data/assets/mirador/plugins/help/img/logo.png +0 -0
- data/assets/mirador/plugins/help/index.js +7 -0
- data/assets/mirador/plugins/help/plugin.js +727 -0
- data/assets/mirador/plugins/help/plugin.min.js +1 -0
- data/assets/mirador/plugins/hr/index.js +7 -0
- data/assets/mirador/plugins/hr/plugin.js +39 -0
- data/assets/mirador/plugins/hr/plugin.min.js +1 -0
- data/assets/mirador/plugins/image/index.js +7 -0
- data/assets/mirador/plugins/image/plugin.js +1211 -0
- data/assets/mirador/plugins/image/plugin.min.js +1 -0
- data/assets/mirador/plugins/imagetools/index.js +7 -0
- data/assets/mirador/plugins/imagetools/plugin.js +3684 -0
- data/assets/mirador/plugins/imagetools/plugin.min.js +1 -0
- data/assets/mirador/plugins/importcss/index.js +7 -0
- data/assets/mirador/plugins/importcss/plugin.js +264 -0
- data/assets/mirador/plugins/importcss/plugin.min.js +1 -0
- data/assets/mirador/plugins/insertdatetime/index.js +7 -0
- data/assets/mirador/plugins/insertdatetime/plugin.js +173 -0
- data/assets/mirador/plugins/insertdatetime/plugin.min.js +1 -0
- data/assets/mirador/plugins/legacyoutput/index.js +7 -0
- data/assets/mirador/plugins/legacyoutput/plugin.js +220 -0
- data/assets/mirador/plugins/legacyoutput/plugin.min.js +1 -0
- data/assets/mirador/plugins/link/index.js +7 -0
- data/assets/mirador/plugins/link/plugin.js +713 -0
- data/assets/mirador/plugins/link/plugin.min.js +1 -0
- data/assets/mirador/plugins/lists/index.js +7 -0
- data/assets/mirador/plugins/lists/plugin.js +1115 -0
- data/assets/mirador/plugins/lists/plugin.min.js +1 -0
- data/assets/mirador/plugins/media/index.js +7 -0
- data/assets/mirador/plugins/media/plugin.js +1166 -0
- data/assets/mirador/plugins/media/plugin.min.js +1 -0
- data/assets/mirador/plugins/nonbreaking/index.js +7 -0
- data/assets/mirador/plugins/nonbreaking/plugin.js +85 -0
- data/assets/mirador/plugins/nonbreaking/plugin.min.js +1 -0
- data/assets/mirador/plugins/noneditable/index.js +7 -0
- data/assets/mirador/plugins/noneditable/plugin.js +118 -0
- data/assets/mirador/plugins/noneditable/plugin.min.js +1 -0
- data/assets/mirador/plugins/pagebreak/index.js +7 -0
- data/assets/mirador/plugins/pagebreak/plugin.js +109 -0
- data/assets/mirador/plugins/pagebreak/plugin.min.js +1 -0
- data/assets/mirador/plugins/paste/index.js +7 -0
- data/assets/mirador/plugins/paste/plugin.js +1497 -0
- data/assets/mirador/plugins/paste/plugin.min.js +1 -0
- data/assets/mirador/plugins/preview/index.js +7 -0
- data/assets/mirador/plugins/preview/plugin.js +123 -0
- data/assets/mirador/plugins/preview/plugin.min.js +1 -0
- data/assets/mirador/plugins/print/index.js +7 -0
- data/assets/mirador/plugins/print/plugin.js +38 -0
- data/assets/mirador/plugins/print/plugin.min.js +1 -0
- data/assets/mirador/plugins/save/index.js +7 -0
- data/assets/mirador/plugins/save/plugin.js +120 -0
- data/assets/mirador/plugins/save/plugin.min.js +1 -0
- data/assets/mirador/plugins/searchreplace/index.js +7 -0
- data/assets/mirador/plugins/searchreplace/plugin.js +603 -0
- data/assets/mirador/plugins/searchreplace/plugin.min.js +1 -0
- data/assets/mirador/plugins/spellchecker/index.js +7 -0
- data/assets/mirador/plugins/spellchecker/plugin.js +757 -0
- data/assets/mirador/plugins/spellchecker/plugin.min.js +1 -0
- data/assets/mirador/plugins/tabfocus/index.js +7 -0
- data/assets/mirador/plugins/tabfocus/plugin.js +124 -0
- data/assets/mirador/plugins/tabfocus/plugin.min.js +1 -0
- data/assets/mirador/plugins/table/index.js +7 -0
- data/assets/mirador/plugins/table/plugin.js +10144 -0
- data/assets/mirador/plugins/table/plugin.min.js +1 -0
- data/assets/mirador/plugins/template/index.js +7 -0
- data/assets/mirador/plugins/template/plugin.js +345 -0
- data/assets/mirador/plugins/template/plugin.min.js +1 -0
- data/assets/mirador/plugins/textcolor/index.js +7 -0
- data/assets/mirador/plugins/textcolor/plugin.js +346 -0
- data/assets/mirador/plugins/textcolor/plugin.min.js +1 -0
- data/assets/mirador/plugins/textpattern/index.js +7 -0
- data/assets/mirador/plugins/textpattern/plugin.js +370 -0
- data/assets/mirador/plugins/textpattern/plugin.min.js +1 -0
- data/assets/mirador/plugins/toc/index.js +7 -0
- data/assets/mirador/plugins/toc/plugin.js +228 -0
- data/assets/mirador/plugins/toc/plugin.min.js +1 -0
- data/assets/mirador/plugins/visualblocks/css/visualblocks.css +154 -0
- data/assets/mirador/plugins/visualblocks/index.js +7 -0
- data/assets/mirador/plugins/visualblocks/plugin.js +135 -0
- data/assets/mirador/plugins/visualblocks/plugin.min.js +1 -0
- data/assets/mirador/plugins/visualchars/index.js +7 -0
- data/assets/mirador/plugins/visualchars/plugin.js +505 -0
- data/assets/mirador/plugins/visualchars/plugin.min.js +1 -0
- data/assets/mirador/plugins/wordcount/index.js +7 -0
- data/assets/mirador/plugins/wordcount/plugin.js +343 -0
- data/assets/mirador/plugins/wordcount/plugin.min.js +1 -0
- data/assets/mirador/skins/lightgray/content.inline.min.css +1 -0
- data/assets/mirador/skins/lightgray/content.min.css +1 -0
- data/assets/mirador/skins/lightgray/content.mobile.min.css +1 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce-mobile.woff +0 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce-small.eot +0 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce-small.svg +63 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce-small.ttf +0 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce-small.woff +0 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce.eot +0 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce.svg +131 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce.ttf +0 -0
- data/assets/mirador/skins/lightgray/fonts/tinymce.woff +0 -0
- data/assets/mirador/skins/lightgray/img/anchor.gif +0 -0
- data/assets/mirador/skins/lightgray/img/loader.gif +0 -0
- data/assets/mirador/skins/lightgray/img/object.gif +0 -0
- data/assets/mirador/skins/lightgray/img/trans.gif +0 -0
- data/assets/mirador/skins/lightgray/skin.min.css +1 -0
- data/assets/mirador/skins/lightgray/skin.mobile.min.css +2 -0
- data/assets/mirador/themes/inlite/index.js +7 -0
- data/assets/mirador/themes/inlite/theme.js +10235 -0
- data/assets/mirador/themes/inlite/theme.min.js +1 -0
- data/assets/mirador/themes/mobile/index.js +7 -0
- data/assets/mirador/themes/mobile/theme.js +13546 -0
- data/assets/mirador/themes/mobile/theme.min.js +1 -0
- data/assets/mirador/themes/modern/index.js +7 -0
- data/assets/mirador/themes/modern/theme.js +10041 -0
- data/assets/mirador/themes/modern/theme.min.js +1 -0
- data/assets/styles.scss +51 -0
- metadata +343 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=function(e){return!1!==e.settings.image_dimensions},i=function(e){return!0===e.settings.image_advtab},g=function(e){return e.getParam("image_prepend_url","")},n=function(e){return e.getParam("image_class_list")},r=function(e){return!1!==e.settings.image_description},a=function(e){return!0===e.settings.image_title},o=function(e){return!0===e.settings.image_caption},l=function(e){return e.getParam("image_list",!1)},u=function(e){return e.getParam("images_upload_url",!1)},c=function(e){return e.getParam("images_upload_handler",!1)},s=function(e){return e.getParam("images_upload_url")},m=function(e){return e.getParam("images_upload_handler")},f=function(e){return e.getParam("images_upload_base_path")},p=function(e){return e.getParam("images_upload_credentials")},h="undefined"!=typeof window?window:Function("return this;")(),v=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:h,r=0;r<e.length&&n!==undefined&&null!==n;++r)n=n[e[r]];return n}(e.split("."),t)},t={getOrDie:function(e,t){var n=v(e,t);if(n===undefined||null===n)throw e+" not available on this browser";return n}};function b(){return new(t.getOrDie("FileReader"))}var y,x=tinymce.util.Tools.resolve("tinymce.util.Promise"),w=tinymce.util.Tools.resolve("tinymce.util.Tools"),C=tinymce.util.Tools.resolve("tinymce.util.XHR"),S=function(e,t){return Math.max(parseInt(e,10),parseInt(t,10))},N=function(e,n){var r=document.createElement("img");function t(e,t){r.parentNode&&r.parentNode.removeChild(r),n({width:e,height:t})}r.onload=function(){t(S(r.width,r.clientWidth),S(r.height,r.clientHeight))},r.onerror=function(){t(0,0)};var a=r.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left="0px",a.width=a.height="auto",document.body.appendChild(r),r.src=e},_=function(e,a,t){return function n(e,r){return r=r||[],w.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=n(e.menu):(t.value=e.value,a(t)),r.push(t)}),r}(e,t||[])},A=function(e){return e&&(e=e.replace(/px$/,"")),e},T=function(e){return 0<e.length&&/^[0-9]+$/.test(e)&&(e+="px"),e},R=function(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e},I=function(e,t){var n=l(e);"string"==typeof n?C.send({url:n,success:function(e){t(JSON.parse(e))}}):"function"==typeof n?n(t):t(n)},O=function(e,t,n){function r(){n.onload=n.onerror=null,e.selection&&(e.selection.select(n),e.nodeChanged())}n.onload=function(){t.width||t.height||!d(e)||e.dom.setAttribs(n,{width:n.clientWidth,height:n.clientHeight}),r()},n.onerror=r},L=function(r){return new x(function(e,t){var n=new b;n.onload=function(){e(n.result)},n.onerror=function(){t(b.error.message)},n.readAsDataURL(r)})},P=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),U=Object.prototype.hasOwnProperty,E=(y=function(e,t){return t},function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var a=e[r];for(var o in a)U.call(a,o)&&(n[o]=y(n[o],a[o]))}return n}),k=P.DOM,M=function(e){return e.style.marginLeft&&e.style.marginRight&&e.style.marginLeft===e.style.marginRight?A(e.style.marginLeft):""},D=function(e){return e.style.marginTop&&e.style.marginBottom&&e.style.marginTop===e.style.marginBottom?A(e.style.marginTop):""},z=function(e){return e.style.borderWidth?A(e.style.borderWidth):""},B=function(e,t){return e.hasAttribute(t)?e.getAttribute(t):""},H=function(e,t){return e.style[t]?e.style[t]:""},j=function(e){return null!==e.parentNode&&"FIGURE"===e.parentNode.nodeName},F=function(e,t,n){e.setAttribute(t,n)},W=function(e){var t,n,r,a;j(e)?(a=(r=e).parentNode,k.insertAfter(r,a),k.remove(a)):(t=e,n=k.create("figure",{"class":"image"}),k.insertAfter(n,t),n.appendChild(t),n.appendChild(k.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable="false")},J=function(e,t){var n=e.getAttribute("style"),r=t(null!==n?n:"");0<r.length?(e.setAttribute("style",r),e.setAttribute("data-mce-style",r)):e.removeAttribute("style")},V=function(e,r){return function(e,t,n){e.style[t]?(e.style[t]=T(n),J(e,r)):F(e,t,n)}},G=function(e,t){return e.style[t]?A(e.style[t]):B(e,t)},$=function(e,t){var n=T(t);e.style.marginLeft=n,e.style.marginRight=n},X=function(e,t){var n=T(t);e.style.marginTop=n,e.style.marginBottom=n},q=function(e,t){var n=T(t);e.style.borderWidth=n},K=function(e,t){e.style.borderStyle=t},Q=function(e){return"FIGURE"===e.nodeName},Y=function(e,t){var n=document.createElement("img");return F(n,"style",t.style),(M(n)||""!==t.hspace)&&$(n,t.hspace),(D(n)||""!==t.vspace)&&X(n,t.vspace),(z(n)||""!==t.border)&&q(n,t.border),(H(n,"borderStyle")||""!==t.borderStyle)&&K(n,t.borderStyle),e(n.getAttribute("style"))},Z=function(e,t){return{src:B(t,"src"),alt:B(t,"alt"),title:B(t,"title"),width:G(t,"width"),height:G(t,"height"),"class":B(t,"class"),style:e(B(t,"style")),caption:j(t),hspace:M(t),vspace:D(t),border:z(t),borderStyle:H(t,"borderStyle")}},ee=function(e,t,n,r,a){n[r]!==t[r]&&a(e,r,n[r])},te=function(r,a){return function(e,t,n){r(e,n),J(e,a)}},ne=function(e,t,n){var r=Z(e,n);ee(n,r,t,"caption",function(e,t,n){return W(e)}),ee(n,r,t,"src",F),ee(n,r,t,"alt",F),ee(n,r,t,"title",F),ee(n,r,t,"width",V(0,e)),ee(n,r,t,"height",V(0,e)),ee(n,r,t,"class",F),ee(n,r,t,"style",te(function(e,t){return F(e,"style",t)},e)),ee(n,r,t,"hspace",te($,e)),ee(n,r,t,"vspace",te(X,e)),ee(n,r,t,"border",te(q,e)),ee(n,r,t,"borderStyle",te(K,e))},re=function(e,t){var n=e.dom.styles.parse(t),r=R(n),a=e.dom.styles.parse(e.dom.styles.serialize(r));return e.dom.styles.serialize(a)},ae=function(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"figure.image");return n?e.dom.select("img",n)[0]:t&&("IMG"!==t.nodeName||t.getAttribute("data-mce-object")||t.getAttribute("data-mce-placeholder"))?null:t},oe=function(t,e){var n=t.dom,r=n.getParent(e.parentNode,function(e){return t.schema.getTextBlockElements()[e.nodeName]});return r?n.split(r,e):e},ie=function(t){var e=ae(t);return e?Z(function(e){return re(t,e)},e):{src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""}},le=function(t,e){var n=function(e,t){var n=document.createElement("img");if(ne(e,E(t,{caption:!1}),n),F(n,"alt",t.alt),t.caption){var r=k.create("figure",{"class":"image"});return r.appendChild(n),r.appendChild(k.create("figcaption",{contentEditable:!0},"Caption")),r.contentEditable="false",r}return n}(function(e){return re(t,e)},e);t.dom.setAttrib(n,"data-mce-id","__mcenew"),t.focus(),t.selection.setContent(n.outerHTML);var r=t.dom.select('*[data-mce-id="__mcenew"]')[0];if(t.dom.setAttrib(r,"data-mce-id",null),Q(r)){var a=oe(t,r);t.selection.select(a)}else t.selection.select(r)},ue=function(e,t){var n=ae(e);n?t.src?function(t,e){var n,r=ae(t);if(ne(function(e){return re(t,e)},e,r),n=r,t.dom.setAttrib(n,"src",n.getAttribute("src")),Q(r.parentNode)){var a=r.parentNode;oe(t,a),t.selection.select(r.parentNode)}else t.selection.select(r),O(t,e,r)}(e,t):function(e,t){if(t){var n=e.dom.is(t.parentNode,"figure.image")?t.parentNode:t;e.dom.remove(n),e.focus(),e.nodeChanged(),e.dom.isEmpty(e.getBody())&&(e.setContent(""),e.selection.setCursorLocation())}}(e,n):t.src&&le(e,t)},ce=function(n,r){r.find("#style").each(function(e){var t=Y(function(e){return re(n,e)},E({src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""},r.toJSON()));e.value(t)})},se=function(t){return{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:(o=t,function(e){var t=o.dom,n=e.control.rootControl;if(i(o)){var r=n.toJSON(),a=t.parseStyle(r.style);n.find("#vspace").value(""),n.find("#hspace").value(""),((a=R(a))["margin-top"]&&a["margin-bottom"]||a["margin-right"]&&a["margin-left"])&&(a["margin-top"]===a["margin-bottom"]?n.find("#vspace").value(A(a["margin-top"])):n.find("#vspace").value(""),a["margin-right"]===a["margin-left"]?n.find("#hspace").value(A(a["margin-right"])):n.find("#hspace").value("")),a["border-width"]?n.find("#border").value(A(a["border-width"])):n.find("#border").value(""),a["border-style"]?n.find("#borderStyle").value(a["border-style"]):n.find("#borderStyle").value(""),n.find("#style").value(t.serializeStyle(t.parseStyle(t.serializeStyle(a))))}})},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,defaults:{type:"textbox",maxWidth:50,onchange:function(e){ce(t,e.control.rootControl)}},items:[{label:"Vertical space",name:"vspace"},{label:"Border width",name:"border"},{label:"Horizontal space",name:"hspace"},{label:"Border style",type:"listbox",name:"borderStyle",width:90,maxWidth:90,onselect:function(e){ce(t,e.control.rootControl)},values:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]};var o},de=function(e,t){e.state.set("oldVal",e.value()),t.state.set("oldVal",t.value())},ge=function(e,t){var n=e.find("#width")[0],r=e.find("#height")[0],a=e.find("#constrain")[0];n&&r&&a&&t(n,r,a.checked())},me=function(e,t,n){var r=e.state.get("oldVal"),a=t.state.get("oldVal"),o=e.value(),i=t.value();n&&r&&a&&o&&i&&(o!==r?(i=Math.round(o/r*i),isNaN(i)||t.value(i)):(o=Math.round(i/a*o),isNaN(o)||e.value(o))),de(e,t)},fe=function(e){ge(e,me)},pe=function(){var e=function(e){fe(e.control.rootControl)};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}},he=function(e){ge(e,de)},ve=fe,be=function(e){e.meta=e.control.rootControl.toJSON()},ye=function(s,e){var t=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:function(e){var t,n,r,a,o,i,l,u,c;n=s,i=(t=e).meta||{},l=t.control,u=l.rootControl,(c=u.find("#image-list")[0])&&c.value(n.convertURL(l.value(),"src")),w.each(i,function(e,t){u.find("#"+t).value(e)}),i.width||i.height||(r=n.convertURL(l.value(),"src"),a=g(n),o=new RegExp("^(?:[a-z]+:)?//","i"),a&&!o.test(r)&&r.substring(0,a.length)!==a&&(r=a+r),l.value(r),N(n.documentBaseURI.toAbsolute(l.value()),function(e){e.width&&e.height&&d(n)&&(u.find("#width").value(e.width),u.find("#height").value(e.height),he(u))}))},onbeforecall:be},e];return r(s)&&t.push({name:"alt",type:"textbox",label:"Image description"}),a(s)&&t.push({name:"title",type:"textbox",label:"Image Title"}),d(s)&&t.push(pe()),n(s)&&t.push({name:"class",type:"listbox",label:"Class",values:_(n(s),function(e){e.value&&(e.textStyle=function(){return s.formatter.getCssText({inline:"img",classes:[e.value]})})})}),o(s)&&t.push({name:"caption",type:"checkbox",label:"Caption"}),t},xe=function(e,t){return{title:"General",type:"form",items:ye(e,t)}},we=ye,Ce=function(){return t.getOrDie("URL")},Se=function(e){return Ce().createObjectURL(e)},Ne=function(e){Ce().revokeObjectURL(e)},_e=tinymce.util.Tools.resolve("tinymce.ui.Factory");function Ae(){return new(t.getOrDie("XMLHttpRequest"))}var Te=function(){};function Re(i){var t=function(e,r,a,t){var o,n;(o=new Ae).open("POST",i.url),o.withCredentials=i.credentials,o.upload.onprogress=function(e){t(e.loaded/e.total*100)},o.onerror=function(){a("Image upload failed due to a XHR Transport error. Code: "+o.status)},o.onload=function(){var e,t,n;o.status<200||300<=o.status?a("HTTP Error: "+o.status):(e=JSON.parse(o.responseText))&&"string"==typeof e.location?r((t=i.basePath,n=e.location,t?t.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):a("Invalid JSON: "+o.responseText)},(n=new FormData).append("file",e.blob(),e.filename()),o.send(n)};return i=w.extend({credentials:!1,handler:t},i),{upload:function(e){return i.url||i.handler!==t?(r=e,a=i.handler,new x(function(e,t){try{a(r,e,t,Te)}catch(n){t(n.message)}})):x.reject("Upload url missing from the settings.");var r,a}}}var Ie=function(u){return function(e){var t=_e.get("Throbber"),n=e.control.rootControl,r=new t(n.getEl()),a=e.control.value(),o=Se(a),i=Re({url:s(u),basePath:f(u),credentials:p(u),handler:m(u)}),l=function(){r.hide(),Ne(o)};return r.show(),L(a).then(function(e){var t=u.editorUpload.blobCache.create({blob:a,blobUri:o,name:a.name?a.name.replace(/\.[^\.]+$/,""):null,base64:e.split(",")[1]});return i.upload(t).then(function(e){var t=n.find("#src");return t.value(e),n.find("tabpanel")[0].activateTab(0),t.fire("change"),l(),e})})["catch"](function(e){u.windowManager.alert(e),l()})}},Oe=".jpg,.jpeg,.png,.gif",Le=function(e){return{title:"Upload",type:"form",layout:"flex",direction:"column",align:"stretch",padding:"20 20 20 20",items:[{type:"container",layout:"flex",direction:"column",align:"center",spacing:10,items:[{text:"Browse for an image",type:"browsebutton",accept:Oe,onchange:Ie(e)},{text:"OR",type:"label"}]},{text:"Drop an image here",type:"dropzone",accept:Oe,height:100,onchange:Ie(e)}]}},Pe=function(o){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var i=new Array(arguments.length-1),n=1;n<arguments.length;n++)i[n-1]=arguments[n];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var a=i.concat(n);return o.apply(null,a)}},Ue=function(t,e){var n=e.control.getRoot();ve(n),t.undoManager.transact(function(){var e=E(ie(t),n.toJSON());ue(t,e)}),t.editorUpload.uploadImagesAuto()};function Ee(o){function e(e){var n,t,r=ie(o);if(e&&(t={type:"listbox",label:"Image list",name:"image-list",values:_(e,function(e){e.value=o.convertURL(e.value||e.url,"src")},[{text:"None",value:""}]),value:r.src&&o.convertURL(r.src,"src"),onselect:function(e){var t=n.find("#alt");(!t.value()||e.lastControl&&t.value()===e.lastControl.text())&&t.value(e.control.text()),n.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){t=this}}),i(o)||u(o)||c(o)){var a=[xe(o,t)];i(o)&&a.push(se(o)),(u(o)||c(o))&&a.push(Le(o)),n=o.windowManager.open({title:"Insert/edit image",data:r,bodyType:"tabpanel",body:a,onSubmit:Pe(Ue,o)})}else n=o.windowManager.open({title:"Insert/edit image",data:r,body:we(o,t),onSubmit:Pe(Ue,o)});he(n)}return{open:function(){I(o,e)}}}var ke=function(e){e.addCommand("mceImage",Ee(e).open)},Me=function(o){return function(e){for(var t,n,r=e.length,a=function(e){e.attr("contenteditable",o?"true":null)};r--;)t=e[r],(n=t.attr("class"))&&/\bimage\b/.test(n)&&(t.attr("contenteditable",o?"false":null),w.each(t.getAll("figcaption"),a))}},De=function(e){e.on("preInit",function(){e.parser.addNodeFilter("figure",Me(!0)),e.serializer.addNodeFilter("figure",Me(!1))})},ze=function(e){e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:Ee(e).open,stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:Ee(e).open,context:"insert",prependToContext:!0})};e.add("image",function(e){De(e),ze(e),ke(e)})}();
|
|
@@ -0,0 +1,3684 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
var imagetools = (function () {
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var Cell = function (initial) {
|
|
6
|
+
var value = initial;
|
|
7
|
+
var get = function () {
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
var set = function (v) {
|
|
11
|
+
value = v;
|
|
12
|
+
};
|
|
13
|
+
var clone = function () {
|
|
14
|
+
return Cell(get());
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
get: get,
|
|
18
|
+
set: set,
|
|
19
|
+
clone: clone
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
24
|
+
|
|
25
|
+
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
26
|
+
|
|
27
|
+
function create(width, height) {
|
|
28
|
+
return resize(document.createElement('canvas'), width, height);
|
|
29
|
+
}
|
|
30
|
+
function clone(canvas) {
|
|
31
|
+
var tCanvas, ctx;
|
|
32
|
+
tCanvas = create(canvas.width, canvas.height);
|
|
33
|
+
ctx = get2dContext(tCanvas);
|
|
34
|
+
ctx.drawImage(canvas, 0, 0);
|
|
35
|
+
return tCanvas;
|
|
36
|
+
}
|
|
37
|
+
function get2dContext(canvas) {
|
|
38
|
+
return canvas.getContext('2d');
|
|
39
|
+
}
|
|
40
|
+
function get3dContext(canvas) {
|
|
41
|
+
var gl = null;
|
|
42
|
+
try {
|
|
43
|
+
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
|
|
44
|
+
} catch (e) {
|
|
45
|
+
}
|
|
46
|
+
if (!gl) {
|
|
47
|
+
gl = null;
|
|
48
|
+
}
|
|
49
|
+
return gl;
|
|
50
|
+
}
|
|
51
|
+
function resize(canvas, width, height) {
|
|
52
|
+
canvas.width = width;
|
|
53
|
+
canvas.height = height;
|
|
54
|
+
return canvas;
|
|
55
|
+
}
|
|
56
|
+
var $_bdk07odqjm0ofyr0 = {
|
|
57
|
+
create: create,
|
|
58
|
+
clone: clone,
|
|
59
|
+
resize: resize,
|
|
60
|
+
get2dContext: get2dContext,
|
|
61
|
+
get3dContext: get3dContext
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function getWidth(image) {
|
|
65
|
+
return image.naturalWidth || image.width;
|
|
66
|
+
}
|
|
67
|
+
function getHeight(image) {
|
|
68
|
+
return image.naturalHeight || image.height;
|
|
69
|
+
}
|
|
70
|
+
var $_exy4tfdrjm0ofyr2 = {
|
|
71
|
+
getWidth: getWidth,
|
|
72
|
+
getHeight: getHeight
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var promise = function () {
|
|
76
|
+
var Promise = function (fn) {
|
|
77
|
+
if (typeof this !== 'object')
|
|
78
|
+
throw new TypeError('Promises must be constructed via new');
|
|
79
|
+
if (typeof fn !== 'function')
|
|
80
|
+
throw new TypeError('not a function');
|
|
81
|
+
this._state = null;
|
|
82
|
+
this._value = null;
|
|
83
|
+
this._deferreds = [];
|
|
84
|
+
doResolve(fn, bind(resolve, this), bind(reject, this));
|
|
85
|
+
};
|
|
86
|
+
var asap = Promise.immediateFn || typeof setImmediate === 'function' && setImmediate || function (fn) {
|
|
87
|
+
setTimeout(fn, 1);
|
|
88
|
+
};
|
|
89
|
+
function bind(fn, thisArg) {
|
|
90
|
+
return function () {
|
|
91
|
+
fn.apply(thisArg, arguments);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var isArray = Array.isArray || function (value) {
|
|
95
|
+
return Object.prototype.toString.call(value) === '[object Array]';
|
|
96
|
+
};
|
|
97
|
+
function handle(deferred) {
|
|
98
|
+
var me = this;
|
|
99
|
+
if (this._state === null) {
|
|
100
|
+
this._deferreds.push(deferred);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
asap(function () {
|
|
104
|
+
var cb = me._state ? deferred.onFulfilled : deferred.onRejected;
|
|
105
|
+
if (cb === null) {
|
|
106
|
+
(me._state ? deferred.resolve : deferred.reject)(me._value);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var ret;
|
|
110
|
+
try {
|
|
111
|
+
ret = cb(me._value);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
deferred.reject(e);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
deferred.resolve(ret);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function resolve(newValue) {
|
|
120
|
+
try {
|
|
121
|
+
if (newValue === this)
|
|
122
|
+
throw new TypeError('A promise cannot be resolved with itself.');
|
|
123
|
+
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
|
124
|
+
var then = newValue.then;
|
|
125
|
+
if (typeof then === 'function') {
|
|
126
|
+
doResolve(bind(then, newValue), bind(resolve, this), bind(reject, this));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
this._state = true;
|
|
131
|
+
this._value = newValue;
|
|
132
|
+
finale.call(this);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
reject.call(this, e);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function reject(newValue) {
|
|
138
|
+
this._state = false;
|
|
139
|
+
this._value = newValue;
|
|
140
|
+
finale.call(this);
|
|
141
|
+
}
|
|
142
|
+
function finale() {
|
|
143
|
+
for (var i = 0, len = this._deferreds.length; i < len; i++) {
|
|
144
|
+
handle.call(this, this._deferreds[i]);
|
|
145
|
+
}
|
|
146
|
+
this._deferreds = null;
|
|
147
|
+
}
|
|
148
|
+
function Handler(onFulfilled, onRejected, resolve, reject) {
|
|
149
|
+
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
|
150
|
+
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
|
151
|
+
this.resolve = resolve;
|
|
152
|
+
this.reject = reject;
|
|
153
|
+
}
|
|
154
|
+
function doResolve(fn, onFulfilled, onRejected) {
|
|
155
|
+
var done = false;
|
|
156
|
+
try {
|
|
157
|
+
fn(function (value) {
|
|
158
|
+
if (done)
|
|
159
|
+
return;
|
|
160
|
+
done = true;
|
|
161
|
+
onFulfilled(value);
|
|
162
|
+
}, function (reason) {
|
|
163
|
+
if (done)
|
|
164
|
+
return;
|
|
165
|
+
done = true;
|
|
166
|
+
onRejected(reason);
|
|
167
|
+
});
|
|
168
|
+
} catch (ex) {
|
|
169
|
+
if (done)
|
|
170
|
+
return;
|
|
171
|
+
done = true;
|
|
172
|
+
onRejected(ex);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
Promise.prototype['catch'] = function (onRejected) {
|
|
176
|
+
return this.then(null, onRejected);
|
|
177
|
+
};
|
|
178
|
+
Promise.prototype.then = function (onFulfilled, onRejected) {
|
|
179
|
+
var me = this;
|
|
180
|
+
return new Promise(function (resolve, reject) {
|
|
181
|
+
handle.call(me, new Handler(onFulfilled, onRejected, resolve, reject));
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
Promise.all = function () {
|
|
185
|
+
var args = Array.prototype.slice.call(arguments.length === 1 && isArray(arguments[0]) ? arguments[0] : arguments);
|
|
186
|
+
return new Promise(function (resolve, reject) {
|
|
187
|
+
if (args.length === 0)
|
|
188
|
+
return resolve([]);
|
|
189
|
+
var remaining = args.length;
|
|
190
|
+
function res(i, val) {
|
|
191
|
+
try {
|
|
192
|
+
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
193
|
+
var then = val.then;
|
|
194
|
+
if (typeof then === 'function') {
|
|
195
|
+
then.call(val, function (val) {
|
|
196
|
+
res(i, val);
|
|
197
|
+
}, reject);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
args[i] = val;
|
|
202
|
+
if (--remaining === 0) {
|
|
203
|
+
resolve(args);
|
|
204
|
+
}
|
|
205
|
+
} catch (ex) {
|
|
206
|
+
reject(ex);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (var i = 0; i < args.length; i++) {
|
|
210
|
+
res(i, args[i]);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
Promise.resolve = function (value) {
|
|
215
|
+
if (value && typeof value === 'object' && value.constructor === Promise) {
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
return new Promise(function (resolve) {
|
|
219
|
+
resolve(value);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
Promise.reject = function (value) {
|
|
223
|
+
return new Promise(function (resolve, reject) {
|
|
224
|
+
reject(value);
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
Promise.race = function (values) {
|
|
228
|
+
return new Promise(function (resolve, reject) {
|
|
229
|
+
for (var i = 0, len = values.length; i < len; i++) {
|
|
230
|
+
values[i].then(resolve, reject);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
return Promise;
|
|
235
|
+
};
|
|
236
|
+
var Promise = window.Promise ? window.Promise : promise();
|
|
237
|
+
|
|
238
|
+
var constant = function (value) {
|
|
239
|
+
return function () {
|
|
240
|
+
return value;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
var curry = function (f) {
|
|
246
|
+
var x = [];
|
|
247
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
248
|
+
x[_i - 1] = arguments[_i];
|
|
249
|
+
}
|
|
250
|
+
var args = new Array(arguments.length - 1);
|
|
251
|
+
for (var i = 1; i < arguments.length; i++)
|
|
252
|
+
args[i - 1] = arguments[i];
|
|
253
|
+
return function () {
|
|
254
|
+
var x = [];
|
|
255
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
256
|
+
x[_i] = arguments[_i];
|
|
257
|
+
}
|
|
258
|
+
var newArgs = new Array(arguments.length);
|
|
259
|
+
for (var j = 0; j < newArgs.length; j++)
|
|
260
|
+
newArgs[j] = arguments[j];
|
|
261
|
+
var all = args.concat(newArgs);
|
|
262
|
+
return f.apply(null, all);
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
var never = constant(false);
|
|
270
|
+
var always = constant(true);
|
|
271
|
+
|
|
272
|
+
var never$1 = never;
|
|
273
|
+
var always$1 = always;
|
|
274
|
+
var none = function () {
|
|
275
|
+
return NONE;
|
|
276
|
+
};
|
|
277
|
+
var NONE = function () {
|
|
278
|
+
var eq = function (o) {
|
|
279
|
+
return o.isNone();
|
|
280
|
+
};
|
|
281
|
+
var call$$1 = function (thunk) {
|
|
282
|
+
return thunk();
|
|
283
|
+
};
|
|
284
|
+
var id = function (n) {
|
|
285
|
+
return n;
|
|
286
|
+
};
|
|
287
|
+
var noop$$1 = function () {
|
|
288
|
+
};
|
|
289
|
+
var nul = function () {
|
|
290
|
+
return null;
|
|
291
|
+
};
|
|
292
|
+
var undef = function () {
|
|
293
|
+
return undefined;
|
|
294
|
+
};
|
|
295
|
+
var me = {
|
|
296
|
+
fold: function (n, s) {
|
|
297
|
+
return n();
|
|
298
|
+
},
|
|
299
|
+
is: never$1,
|
|
300
|
+
isSome: never$1,
|
|
301
|
+
isNone: always$1,
|
|
302
|
+
getOr: id,
|
|
303
|
+
getOrThunk: call$$1,
|
|
304
|
+
getOrDie: function (msg) {
|
|
305
|
+
throw new Error(msg || 'error: getOrDie called on none.');
|
|
306
|
+
},
|
|
307
|
+
getOrNull: nul,
|
|
308
|
+
getOrUndefined: undef,
|
|
309
|
+
or: id,
|
|
310
|
+
orThunk: call$$1,
|
|
311
|
+
map: none,
|
|
312
|
+
ap: none,
|
|
313
|
+
each: noop$$1,
|
|
314
|
+
bind: none,
|
|
315
|
+
flatten: none,
|
|
316
|
+
exists: never$1,
|
|
317
|
+
forall: always$1,
|
|
318
|
+
filter: none,
|
|
319
|
+
equals: eq,
|
|
320
|
+
equals_: eq,
|
|
321
|
+
toArray: function () {
|
|
322
|
+
return [];
|
|
323
|
+
},
|
|
324
|
+
toString: constant('none()')
|
|
325
|
+
};
|
|
326
|
+
if (Object.freeze)
|
|
327
|
+
Object.freeze(me);
|
|
328
|
+
return me;
|
|
329
|
+
}();
|
|
330
|
+
var some = function (a) {
|
|
331
|
+
var constant_a = function () {
|
|
332
|
+
return a;
|
|
333
|
+
};
|
|
334
|
+
var self = function () {
|
|
335
|
+
return me;
|
|
336
|
+
};
|
|
337
|
+
var map = function (f) {
|
|
338
|
+
return some(f(a));
|
|
339
|
+
};
|
|
340
|
+
var bind = function (f) {
|
|
341
|
+
return f(a);
|
|
342
|
+
};
|
|
343
|
+
var me = {
|
|
344
|
+
fold: function (n, s) {
|
|
345
|
+
return s(a);
|
|
346
|
+
},
|
|
347
|
+
is: function (v) {
|
|
348
|
+
return a === v;
|
|
349
|
+
},
|
|
350
|
+
isSome: always$1,
|
|
351
|
+
isNone: never$1,
|
|
352
|
+
getOr: constant_a,
|
|
353
|
+
getOrThunk: constant_a,
|
|
354
|
+
getOrDie: constant_a,
|
|
355
|
+
getOrNull: constant_a,
|
|
356
|
+
getOrUndefined: constant_a,
|
|
357
|
+
or: self,
|
|
358
|
+
orThunk: self,
|
|
359
|
+
map: map,
|
|
360
|
+
ap: function (optfab) {
|
|
361
|
+
return optfab.fold(none, function (fab) {
|
|
362
|
+
return some(fab(a));
|
|
363
|
+
});
|
|
364
|
+
},
|
|
365
|
+
each: function (f) {
|
|
366
|
+
f(a);
|
|
367
|
+
},
|
|
368
|
+
bind: bind,
|
|
369
|
+
flatten: constant_a,
|
|
370
|
+
exists: bind,
|
|
371
|
+
forall: bind,
|
|
372
|
+
filter: function (f) {
|
|
373
|
+
return f(a) ? me : NONE;
|
|
374
|
+
},
|
|
375
|
+
equals: function (o) {
|
|
376
|
+
return o.is(a);
|
|
377
|
+
},
|
|
378
|
+
equals_: function (o, elementEq) {
|
|
379
|
+
return o.fold(never$1, function (b) {
|
|
380
|
+
return elementEq(a, b);
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
toArray: function () {
|
|
384
|
+
return [a];
|
|
385
|
+
},
|
|
386
|
+
toString: function () {
|
|
387
|
+
return 'some(' + a + ')';
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
return me;
|
|
391
|
+
};
|
|
392
|
+
var from = function (value) {
|
|
393
|
+
return value === null || value === undefined ? NONE : some(value);
|
|
394
|
+
};
|
|
395
|
+
var Option = {
|
|
396
|
+
some: some,
|
|
397
|
+
none: none,
|
|
398
|
+
from: from
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
var Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
402
|
+
|
|
403
|
+
var path = function (parts, scope) {
|
|
404
|
+
var o = scope !== undefined && scope !== null ? scope : Global;
|
|
405
|
+
for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i)
|
|
406
|
+
o = o[parts[i]];
|
|
407
|
+
return o;
|
|
408
|
+
};
|
|
409
|
+
var resolve = function (p, scope) {
|
|
410
|
+
var parts = p.split('.');
|
|
411
|
+
return path(parts, scope);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
var unsafe = function (name, scope) {
|
|
415
|
+
return resolve(name, scope);
|
|
416
|
+
};
|
|
417
|
+
var getOrDie = function (name, scope) {
|
|
418
|
+
var actual = unsafe(name, scope);
|
|
419
|
+
if (actual === undefined || actual === null)
|
|
420
|
+
throw name + ' not available on this browser';
|
|
421
|
+
return actual;
|
|
422
|
+
};
|
|
423
|
+
var $_ektrqldwjm0ofyrf = { getOrDie: getOrDie };
|
|
424
|
+
|
|
425
|
+
function Blob (parts, properties) {
|
|
426
|
+
var f = $_ektrqldwjm0ofyrf.getOrDie('Blob');
|
|
427
|
+
return new f(parts, properties);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function FileReader () {
|
|
431
|
+
var f = $_ektrqldwjm0ofyrf.getOrDie('FileReader');
|
|
432
|
+
return new f();
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function Uint8Array (arr) {
|
|
436
|
+
var f = $_ektrqldwjm0ofyrf.getOrDie('Uint8Array');
|
|
437
|
+
return new f(arr);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
var requestAnimationFrame = function (callback) {
|
|
441
|
+
var f = $_ektrqldwjm0ofyrf.getOrDie('requestAnimationFrame');
|
|
442
|
+
f(callback);
|
|
443
|
+
};
|
|
444
|
+
var atob = function (base64) {
|
|
445
|
+
var f = $_ektrqldwjm0ofyrf.getOrDie('atob');
|
|
446
|
+
return f(base64);
|
|
447
|
+
};
|
|
448
|
+
var $_22m7oe1jm0ofyrl = {
|
|
449
|
+
atob: atob,
|
|
450
|
+
requestAnimationFrame: requestAnimationFrame
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
function imageToBlob(image) {
|
|
454
|
+
var src = image.src;
|
|
455
|
+
if (src.indexOf('data:') === 0) {
|
|
456
|
+
return dataUriToBlob(src);
|
|
457
|
+
}
|
|
458
|
+
return anyUriToBlob(src);
|
|
459
|
+
}
|
|
460
|
+
function blobToImage(blob) {
|
|
461
|
+
return new Promise(function (resolve, reject) {
|
|
462
|
+
var blobUrl = URL.createObjectURL(blob);
|
|
463
|
+
var image = new Image();
|
|
464
|
+
var removeListeners = function () {
|
|
465
|
+
image.removeEventListener('load', loaded);
|
|
466
|
+
image.removeEventListener('error', error);
|
|
467
|
+
};
|
|
468
|
+
function loaded() {
|
|
469
|
+
removeListeners();
|
|
470
|
+
resolve(image);
|
|
471
|
+
}
|
|
472
|
+
function error() {
|
|
473
|
+
removeListeners();
|
|
474
|
+
reject('Unable to load data of type ' + blob.type + ': ' + blobUrl);
|
|
475
|
+
}
|
|
476
|
+
image.addEventListener('load', loaded);
|
|
477
|
+
image.addEventListener('error', error);
|
|
478
|
+
image.src = blobUrl;
|
|
479
|
+
if (image.complete) {
|
|
480
|
+
loaded();
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function anyUriToBlob(url) {
|
|
485
|
+
return new Promise(function (resolve, reject) {
|
|
486
|
+
var xhr = new XMLHttpRequest();
|
|
487
|
+
xhr.open('GET', url, true);
|
|
488
|
+
xhr.responseType = 'blob';
|
|
489
|
+
xhr.onload = function () {
|
|
490
|
+
if (this.status == 200) {
|
|
491
|
+
resolve(this.response);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
xhr.onerror = function () {
|
|
495
|
+
var _this = this;
|
|
496
|
+
var corsError = function () {
|
|
497
|
+
var obj = new Error('No access to download image');
|
|
498
|
+
obj.code = 18;
|
|
499
|
+
obj.name = 'SecurityError';
|
|
500
|
+
return obj;
|
|
501
|
+
};
|
|
502
|
+
var genericError = function () {
|
|
503
|
+
return new Error('Error ' + _this.status + ' downloading image');
|
|
504
|
+
};
|
|
505
|
+
reject(this.status === 0 ? corsError() : genericError());
|
|
506
|
+
};
|
|
507
|
+
xhr.send();
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function dataUriToBlobSync(uri) {
|
|
511
|
+
var data = uri.split(',');
|
|
512
|
+
var matches = /data:([^;]+)/.exec(data[0]);
|
|
513
|
+
if (!matches)
|
|
514
|
+
return Option.none();
|
|
515
|
+
var mimetype = matches[1];
|
|
516
|
+
var base64 = data[1];
|
|
517
|
+
var sliceSize = 1024;
|
|
518
|
+
var byteCharacters = $_22m7oe1jm0ofyrl.atob(base64);
|
|
519
|
+
var bytesLength = byteCharacters.length;
|
|
520
|
+
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
|
521
|
+
var byteArrays = new Array(slicesCount);
|
|
522
|
+
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
|
523
|
+
var begin = sliceIndex * sliceSize;
|
|
524
|
+
var end = Math.min(begin + sliceSize, bytesLength);
|
|
525
|
+
var bytes = new Array(end - begin);
|
|
526
|
+
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
|
527
|
+
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
|
528
|
+
}
|
|
529
|
+
byteArrays[sliceIndex] = Uint8Array(bytes);
|
|
530
|
+
}
|
|
531
|
+
return Option.some(Blob(byteArrays, { type: mimetype }));
|
|
532
|
+
}
|
|
533
|
+
function dataUriToBlob(uri) {
|
|
534
|
+
return new Promise(function (resolve, reject) {
|
|
535
|
+
dataUriToBlobSync(uri).fold(function () {
|
|
536
|
+
reject('uri is not base64: ' + uri);
|
|
537
|
+
}, resolve);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function uriToBlob(url) {
|
|
541
|
+
if (url.indexOf('blob:') === 0) {
|
|
542
|
+
return anyUriToBlob(url);
|
|
543
|
+
}
|
|
544
|
+
if (url.indexOf('data:') === 0) {
|
|
545
|
+
return dataUriToBlob(url);
|
|
546
|
+
}
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
function canvasToBlob(canvas, type, quality) {
|
|
550
|
+
type = type || 'image/png';
|
|
551
|
+
if (HTMLCanvasElement.prototype.toBlob) {
|
|
552
|
+
return new Promise(function (resolve) {
|
|
553
|
+
canvas.toBlob(function (blob) {
|
|
554
|
+
resolve(blob);
|
|
555
|
+
}, type, quality);
|
|
556
|
+
});
|
|
557
|
+
} else {
|
|
558
|
+
return dataUriToBlob(canvas.toDataURL(type, quality));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function canvasToDataURL(getCanvas, type, quality) {
|
|
562
|
+
type = type || 'image/png';
|
|
563
|
+
return getCanvas.then(function (canvas) {
|
|
564
|
+
return canvas.toDataURL(type, quality);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function blobToCanvas(blob) {
|
|
568
|
+
return blobToImage(blob).then(function (image) {
|
|
569
|
+
revokeImageUrl(image);
|
|
570
|
+
var context, canvas;
|
|
571
|
+
canvas = $_bdk07odqjm0ofyr0.create($_exy4tfdrjm0ofyr2.getWidth(image), $_exy4tfdrjm0ofyr2.getHeight(image));
|
|
572
|
+
context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
573
|
+
context.drawImage(image, 0, 0);
|
|
574
|
+
return canvas;
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
function blobToDataUri(blob) {
|
|
578
|
+
return new Promise(function (resolve) {
|
|
579
|
+
var reader = new FileReader();
|
|
580
|
+
reader.onloadend = function () {
|
|
581
|
+
resolve(reader.result);
|
|
582
|
+
};
|
|
583
|
+
reader.readAsDataURL(blob);
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
function blobToArrayBuffer(blob) {
|
|
587
|
+
return new Promise(function (resolve) {
|
|
588
|
+
var reader = new FileReader();
|
|
589
|
+
reader.onloadend = function () {
|
|
590
|
+
resolve(reader.result);
|
|
591
|
+
};
|
|
592
|
+
reader.readAsArrayBuffer(blob);
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
function blobToBase64(blob) {
|
|
596
|
+
return blobToDataUri(blob).then(function (dataUri) {
|
|
597
|
+
return dataUri.split(',')[1];
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function revokeImageUrl(image) {
|
|
601
|
+
URL.revokeObjectURL(image.src);
|
|
602
|
+
}
|
|
603
|
+
var $_aqivtudpjm0ofyql = {
|
|
604
|
+
blobToImage: blobToImage,
|
|
605
|
+
imageToBlob: imageToBlob,
|
|
606
|
+
blobToArrayBuffer: blobToArrayBuffer,
|
|
607
|
+
blobToDataUri: blobToDataUri,
|
|
608
|
+
blobToBase64: blobToBase64,
|
|
609
|
+
dataUriToBlobSync: dataUriToBlobSync,
|
|
610
|
+
canvasToBlob: canvasToBlob,
|
|
611
|
+
canvasToDataURL: canvasToDataURL,
|
|
612
|
+
blobToCanvas: blobToCanvas,
|
|
613
|
+
uriToBlob: uriToBlob
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
var blobToImage$1 = function (image) {
|
|
617
|
+
return $_aqivtudpjm0ofyql.blobToImage(image);
|
|
618
|
+
};
|
|
619
|
+
var imageToBlob$1 = function (blob) {
|
|
620
|
+
return $_aqivtudpjm0ofyql.imageToBlob(blob);
|
|
621
|
+
};
|
|
622
|
+
var blobToDataUri$1 = function (blob) {
|
|
623
|
+
return $_aqivtudpjm0ofyql.blobToDataUri(blob);
|
|
624
|
+
};
|
|
625
|
+
var blobToBase64$1 = function (blob) {
|
|
626
|
+
return $_aqivtudpjm0ofyql.blobToBase64(blob);
|
|
627
|
+
};
|
|
628
|
+
var dataUriToBlobSync$1 = function (uri) {
|
|
629
|
+
return $_aqivtudpjm0ofyql.dataUriToBlobSync(uri);
|
|
630
|
+
};
|
|
631
|
+
var uriToBlob$1 = function (uri) {
|
|
632
|
+
return Option.from($_aqivtudpjm0ofyql.uriToBlob(uri));
|
|
633
|
+
};
|
|
634
|
+
var $_cjzpf9dojm0ofyqd = {
|
|
635
|
+
blobToImage: blobToImage$1,
|
|
636
|
+
imageToBlob: imageToBlob$1,
|
|
637
|
+
blobToDataUri: blobToDataUri$1,
|
|
638
|
+
blobToBase64: blobToBase64$1,
|
|
639
|
+
dataUriToBlobSync: dataUriToBlobSync$1,
|
|
640
|
+
uriToBlob: uriToBlob$1
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
function create$1(getCanvas, blob, uri) {
|
|
644
|
+
var initialType = blob.type;
|
|
645
|
+
var getType = constant(initialType);
|
|
646
|
+
function toBlob() {
|
|
647
|
+
return Promise.resolve(blob);
|
|
648
|
+
}
|
|
649
|
+
function toDataURL() {
|
|
650
|
+
return uri;
|
|
651
|
+
}
|
|
652
|
+
function toBase64() {
|
|
653
|
+
return uri.split(',')[1];
|
|
654
|
+
}
|
|
655
|
+
function toAdjustedBlob(type, quality) {
|
|
656
|
+
return getCanvas.then(function (canvas) {
|
|
657
|
+
return $_aqivtudpjm0ofyql.canvasToBlob(canvas, type, quality);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
function toAdjustedDataURL(type, quality) {
|
|
661
|
+
return getCanvas.then(function (canvas) {
|
|
662
|
+
return $_aqivtudpjm0ofyql.canvasToDataURL(canvas, type, quality);
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
function toAdjustedBase64(type, quality) {
|
|
666
|
+
return toAdjustedDataURL(type, quality).then(function (dataurl) {
|
|
667
|
+
return dataurl.split(',')[1];
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function toCanvas() {
|
|
671
|
+
return getCanvas.then($_bdk07odqjm0ofyr0.clone);
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
getType: getType,
|
|
675
|
+
toBlob: toBlob,
|
|
676
|
+
toDataURL: toDataURL,
|
|
677
|
+
toBase64: toBase64,
|
|
678
|
+
toAdjustedBlob: toAdjustedBlob,
|
|
679
|
+
toAdjustedDataURL: toAdjustedDataURL,
|
|
680
|
+
toAdjustedBase64: toAdjustedBase64,
|
|
681
|
+
toCanvas: toCanvas
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
function fromBlob(blob) {
|
|
685
|
+
return $_aqivtudpjm0ofyql.blobToDataUri(blob).then(function (uri) {
|
|
686
|
+
return create$1($_aqivtudpjm0ofyql.blobToCanvas(blob), blob, uri);
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
function fromCanvas(canvas, type) {
|
|
690
|
+
return $_aqivtudpjm0ofyql.canvasToBlob(canvas, type).then(function (blob) {
|
|
691
|
+
return create$1(Promise.resolve(canvas), blob, canvas.toDataURL());
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
function fromImage(image) {
|
|
695
|
+
return $_aqivtudpjm0ofyql.imageToBlob(image).then(function (blob) {
|
|
696
|
+
return fromBlob(blob);
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
var fromBlobAndUrlSync = function (blob, url) {
|
|
700
|
+
return create$1($_aqivtudpjm0ofyql.blobToCanvas(blob), blob, url);
|
|
701
|
+
};
|
|
702
|
+
var $_filu11e4jm0ofyrx = {
|
|
703
|
+
fromBlob: fromBlob,
|
|
704
|
+
fromCanvas: fromCanvas,
|
|
705
|
+
fromImage: fromImage,
|
|
706
|
+
fromBlobAndUrlSync: fromBlobAndUrlSync
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
function clamp(value, min, max) {
|
|
710
|
+
value = parseFloat(value);
|
|
711
|
+
if (value > max) {
|
|
712
|
+
value = max;
|
|
713
|
+
} else if (value < min) {
|
|
714
|
+
value = min;
|
|
715
|
+
}
|
|
716
|
+
return value;
|
|
717
|
+
}
|
|
718
|
+
function identity$1() {
|
|
719
|
+
return [
|
|
720
|
+
1,
|
|
721
|
+
0,
|
|
722
|
+
0,
|
|
723
|
+
0,
|
|
724
|
+
0,
|
|
725
|
+
0,
|
|
726
|
+
1,
|
|
727
|
+
0,
|
|
728
|
+
0,
|
|
729
|
+
0,
|
|
730
|
+
0,
|
|
731
|
+
0,
|
|
732
|
+
1,
|
|
733
|
+
0,
|
|
734
|
+
0,
|
|
735
|
+
0,
|
|
736
|
+
0,
|
|
737
|
+
0,
|
|
738
|
+
1,
|
|
739
|
+
0,
|
|
740
|
+
0,
|
|
741
|
+
0,
|
|
742
|
+
0,
|
|
743
|
+
0,
|
|
744
|
+
1
|
|
745
|
+
];
|
|
746
|
+
}
|
|
747
|
+
var DELTA_INDEX = [
|
|
748
|
+
0,
|
|
749
|
+
0.01,
|
|
750
|
+
0.02,
|
|
751
|
+
0.04,
|
|
752
|
+
0.05,
|
|
753
|
+
0.06,
|
|
754
|
+
0.07,
|
|
755
|
+
0.08,
|
|
756
|
+
0.1,
|
|
757
|
+
0.11,
|
|
758
|
+
0.12,
|
|
759
|
+
0.14,
|
|
760
|
+
0.15,
|
|
761
|
+
0.16,
|
|
762
|
+
0.17,
|
|
763
|
+
0.18,
|
|
764
|
+
0.2,
|
|
765
|
+
0.21,
|
|
766
|
+
0.22,
|
|
767
|
+
0.24,
|
|
768
|
+
0.25,
|
|
769
|
+
0.27,
|
|
770
|
+
0.28,
|
|
771
|
+
0.3,
|
|
772
|
+
0.32,
|
|
773
|
+
0.34,
|
|
774
|
+
0.36,
|
|
775
|
+
0.38,
|
|
776
|
+
0.4,
|
|
777
|
+
0.42,
|
|
778
|
+
0.44,
|
|
779
|
+
0.46,
|
|
780
|
+
0.48,
|
|
781
|
+
0.5,
|
|
782
|
+
0.53,
|
|
783
|
+
0.56,
|
|
784
|
+
0.59,
|
|
785
|
+
0.62,
|
|
786
|
+
0.65,
|
|
787
|
+
0.68,
|
|
788
|
+
0.71,
|
|
789
|
+
0.74,
|
|
790
|
+
0.77,
|
|
791
|
+
0.8,
|
|
792
|
+
0.83,
|
|
793
|
+
0.86,
|
|
794
|
+
0.89,
|
|
795
|
+
0.92,
|
|
796
|
+
0.95,
|
|
797
|
+
0.98,
|
|
798
|
+
1,
|
|
799
|
+
1.06,
|
|
800
|
+
1.12,
|
|
801
|
+
1.18,
|
|
802
|
+
1.24,
|
|
803
|
+
1.3,
|
|
804
|
+
1.36,
|
|
805
|
+
1.42,
|
|
806
|
+
1.48,
|
|
807
|
+
1.54,
|
|
808
|
+
1.6,
|
|
809
|
+
1.66,
|
|
810
|
+
1.72,
|
|
811
|
+
1.78,
|
|
812
|
+
1.84,
|
|
813
|
+
1.9,
|
|
814
|
+
1.96,
|
|
815
|
+
2,
|
|
816
|
+
2.12,
|
|
817
|
+
2.25,
|
|
818
|
+
2.37,
|
|
819
|
+
2.5,
|
|
820
|
+
2.62,
|
|
821
|
+
2.75,
|
|
822
|
+
2.87,
|
|
823
|
+
3,
|
|
824
|
+
3.2,
|
|
825
|
+
3.4,
|
|
826
|
+
3.6,
|
|
827
|
+
3.8,
|
|
828
|
+
4,
|
|
829
|
+
4.3,
|
|
830
|
+
4.7,
|
|
831
|
+
4.9,
|
|
832
|
+
5,
|
|
833
|
+
5.5,
|
|
834
|
+
6,
|
|
835
|
+
6.5,
|
|
836
|
+
6.8,
|
|
837
|
+
7,
|
|
838
|
+
7.3,
|
|
839
|
+
7.5,
|
|
840
|
+
7.8,
|
|
841
|
+
8,
|
|
842
|
+
8.4,
|
|
843
|
+
8.7,
|
|
844
|
+
9,
|
|
845
|
+
9.4,
|
|
846
|
+
9.6,
|
|
847
|
+
9.8,
|
|
848
|
+
10
|
|
849
|
+
];
|
|
850
|
+
function multiply(matrix1, matrix2) {
|
|
851
|
+
var i, j, k, val, col = [], out = new Array(10);
|
|
852
|
+
for (i = 0; i < 5; i++) {
|
|
853
|
+
for (j = 0; j < 5; j++) {
|
|
854
|
+
col[j] = matrix2[j + i * 5];
|
|
855
|
+
}
|
|
856
|
+
for (j = 0; j < 5; j++) {
|
|
857
|
+
val = 0;
|
|
858
|
+
for (k = 0; k < 5; k++) {
|
|
859
|
+
val += matrix1[j + k * 5] * col[k];
|
|
860
|
+
}
|
|
861
|
+
out[j + i * 5] = val;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return out;
|
|
865
|
+
}
|
|
866
|
+
function adjust(matrix, adjustValue) {
|
|
867
|
+
adjustValue = clamp(adjustValue, 0, 1);
|
|
868
|
+
return matrix.map(function (value, index) {
|
|
869
|
+
if (index % 6 === 0) {
|
|
870
|
+
value = 1 - (1 - value) * adjustValue;
|
|
871
|
+
} else {
|
|
872
|
+
value *= adjustValue;
|
|
873
|
+
}
|
|
874
|
+
return clamp(value, 0, 1);
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function adjustContrast(matrix, value) {
|
|
878
|
+
var x;
|
|
879
|
+
value = clamp(value, -1, 1);
|
|
880
|
+
value *= 100;
|
|
881
|
+
if (value < 0) {
|
|
882
|
+
x = 127 + value / 100 * 127;
|
|
883
|
+
} else {
|
|
884
|
+
x = value % 1;
|
|
885
|
+
if (x === 0) {
|
|
886
|
+
x = DELTA_INDEX[value];
|
|
887
|
+
} else {
|
|
888
|
+
x = DELTA_INDEX[Math.floor(value)] * (1 - x) + DELTA_INDEX[Math.floor(value) + 1] * x;
|
|
889
|
+
}
|
|
890
|
+
x = x * 127 + 127;
|
|
891
|
+
}
|
|
892
|
+
return multiply(matrix, [
|
|
893
|
+
x / 127,
|
|
894
|
+
0,
|
|
895
|
+
0,
|
|
896
|
+
0,
|
|
897
|
+
0.5 * (127 - x),
|
|
898
|
+
0,
|
|
899
|
+
x / 127,
|
|
900
|
+
0,
|
|
901
|
+
0,
|
|
902
|
+
0.5 * (127 - x),
|
|
903
|
+
0,
|
|
904
|
+
0,
|
|
905
|
+
x / 127,
|
|
906
|
+
0,
|
|
907
|
+
0.5 * (127 - x),
|
|
908
|
+
0,
|
|
909
|
+
0,
|
|
910
|
+
0,
|
|
911
|
+
1,
|
|
912
|
+
0,
|
|
913
|
+
0,
|
|
914
|
+
0,
|
|
915
|
+
0,
|
|
916
|
+
0,
|
|
917
|
+
1
|
|
918
|
+
]);
|
|
919
|
+
}
|
|
920
|
+
function adjustSaturation(matrix, value) {
|
|
921
|
+
var x, lumR, lumG, lumB;
|
|
922
|
+
value = clamp(value, -1, 1);
|
|
923
|
+
x = 1 + (value > 0 ? 3 * value : value);
|
|
924
|
+
lumR = 0.3086;
|
|
925
|
+
lumG = 0.6094;
|
|
926
|
+
lumB = 0.082;
|
|
927
|
+
return multiply(matrix, [
|
|
928
|
+
lumR * (1 - x) + x,
|
|
929
|
+
lumG * (1 - x),
|
|
930
|
+
lumB * (1 - x),
|
|
931
|
+
0,
|
|
932
|
+
0,
|
|
933
|
+
lumR * (1 - x),
|
|
934
|
+
lumG * (1 - x) + x,
|
|
935
|
+
lumB * (1 - x),
|
|
936
|
+
0,
|
|
937
|
+
0,
|
|
938
|
+
lumR * (1 - x),
|
|
939
|
+
lumG * (1 - x),
|
|
940
|
+
lumB * (1 - x) + x,
|
|
941
|
+
0,
|
|
942
|
+
0,
|
|
943
|
+
0,
|
|
944
|
+
0,
|
|
945
|
+
0,
|
|
946
|
+
1,
|
|
947
|
+
0,
|
|
948
|
+
0,
|
|
949
|
+
0,
|
|
950
|
+
0,
|
|
951
|
+
0,
|
|
952
|
+
1
|
|
953
|
+
]);
|
|
954
|
+
}
|
|
955
|
+
function adjustHue(matrix, angle) {
|
|
956
|
+
var cosVal, sinVal, lumR, lumG, lumB;
|
|
957
|
+
angle = clamp(angle, -180, 180) / 180 * Math.PI;
|
|
958
|
+
cosVal = Math.cos(angle);
|
|
959
|
+
sinVal = Math.sin(angle);
|
|
960
|
+
lumR = 0.213;
|
|
961
|
+
lumG = 0.715;
|
|
962
|
+
lumB = 0.072;
|
|
963
|
+
return multiply(matrix, [
|
|
964
|
+
lumR + cosVal * (1 - lumR) + sinVal * -lumR,
|
|
965
|
+
lumG + cosVal * -lumG + sinVal * -lumG,
|
|
966
|
+
lumB + cosVal * -lumB + sinVal * (1 - lumB),
|
|
967
|
+
0,
|
|
968
|
+
0,
|
|
969
|
+
lumR + cosVal * -lumR + sinVal * 0.143,
|
|
970
|
+
lumG + cosVal * (1 - lumG) + sinVal * 0.14,
|
|
971
|
+
lumB + cosVal * -lumB + sinVal * -0.283,
|
|
972
|
+
0,
|
|
973
|
+
0,
|
|
974
|
+
lumR + cosVal * -lumR + sinVal * -(1 - lumR),
|
|
975
|
+
lumG + cosVal * -lumG + sinVal * lumG,
|
|
976
|
+
lumB + cosVal * (1 - lumB) + sinVal * lumB,
|
|
977
|
+
0,
|
|
978
|
+
0,
|
|
979
|
+
0,
|
|
980
|
+
0,
|
|
981
|
+
0,
|
|
982
|
+
1,
|
|
983
|
+
0,
|
|
984
|
+
0,
|
|
985
|
+
0,
|
|
986
|
+
0,
|
|
987
|
+
0,
|
|
988
|
+
1
|
|
989
|
+
]);
|
|
990
|
+
}
|
|
991
|
+
function adjustBrightness(matrix, value) {
|
|
992
|
+
value = clamp(255 * value, -255, 255);
|
|
993
|
+
return multiply(matrix, [
|
|
994
|
+
1,
|
|
995
|
+
0,
|
|
996
|
+
0,
|
|
997
|
+
0,
|
|
998
|
+
value,
|
|
999
|
+
0,
|
|
1000
|
+
1,
|
|
1001
|
+
0,
|
|
1002
|
+
0,
|
|
1003
|
+
value,
|
|
1004
|
+
0,
|
|
1005
|
+
0,
|
|
1006
|
+
1,
|
|
1007
|
+
0,
|
|
1008
|
+
value,
|
|
1009
|
+
0,
|
|
1010
|
+
0,
|
|
1011
|
+
0,
|
|
1012
|
+
1,
|
|
1013
|
+
0,
|
|
1014
|
+
0,
|
|
1015
|
+
0,
|
|
1016
|
+
0,
|
|
1017
|
+
0,
|
|
1018
|
+
1
|
|
1019
|
+
]);
|
|
1020
|
+
}
|
|
1021
|
+
function adjustColors(matrix, adjustR, adjustG, adjustB) {
|
|
1022
|
+
adjustR = clamp(adjustR, 0, 2);
|
|
1023
|
+
adjustG = clamp(adjustG, 0, 2);
|
|
1024
|
+
adjustB = clamp(adjustB, 0, 2);
|
|
1025
|
+
return multiply(matrix, [
|
|
1026
|
+
adjustR,
|
|
1027
|
+
0,
|
|
1028
|
+
0,
|
|
1029
|
+
0,
|
|
1030
|
+
0,
|
|
1031
|
+
0,
|
|
1032
|
+
adjustG,
|
|
1033
|
+
0,
|
|
1034
|
+
0,
|
|
1035
|
+
0,
|
|
1036
|
+
0,
|
|
1037
|
+
0,
|
|
1038
|
+
adjustB,
|
|
1039
|
+
0,
|
|
1040
|
+
0,
|
|
1041
|
+
0,
|
|
1042
|
+
0,
|
|
1043
|
+
0,
|
|
1044
|
+
1,
|
|
1045
|
+
0,
|
|
1046
|
+
0,
|
|
1047
|
+
0,
|
|
1048
|
+
0,
|
|
1049
|
+
0,
|
|
1050
|
+
1
|
|
1051
|
+
]);
|
|
1052
|
+
}
|
|
1053
|
+
function adjustSepia(matrix, value) {
|
|
1054
|
+
value = clamp(value, 0, 1);
|
|
1055
|
+
return multiply(matrix, adjust([
|
|
1056
|
+
0.393,
|
|
1057
|
+
0.769,
|
|
1058
|
+
0.189,
|
|
1059
|
+
0,
|
|
1060
|
+
0,
|
|
1061
|
+
0.349,
|
|
1062
|
+
0.686,
|
|
1063
|
+
0.168,
|
|
1064
|
+
0,
|
|
1065
|
+
0,
|
|
1066
|
+
0.272,
|
|
1067
|
+
0.534,
|
|
1068
|
+
0.131,
|
|
1069
|
+
0,
|
|
1070
|
+
0,
|
|
1071
|
+
0,
|
|
1072
|
+
0,
|
|
1073
|
+
0,
|
|
1074
|
+
1,
|
|
1075
|
+
0,
|
|
1076
|
+
0,
|
|
1077
|
+
0,
|
|
1078
|
+
0,
|
|
1079
|
+
0,
|
|
1080
|
+
1
|
|
1081
|
+
], value));
|
|
1082
|
+
}
|
|
1083
|
+
function adjustGrayscale(matrix, value) {
|
|
1084
|
+
value = clamp(value, 0, 1);
|
|
1085
|
+
return multiply(matrix, adjust([
|
|
1086
|
+
0.33,
|
|
1087
|
+
0.34,
|
|
1088
|
+
0.33,
|
|
1089
|
+
0,
|
|
1090
|
+
0,
|
|
1091
|
+
0.33,
|
|
1092
|
+
0.34,
|
|
1093
|
+
0.33,
|
|
1094
|
+
0,
|
|
1095
|
+
0,
|
|
1096
|
+
0.33,
|
|
1097
|
+
0.34,
|
|
1098
|
+
0.33,
|
|
1099
|
+
0,
|
|
1100
|
+
0,
|
|
1101
|
+
0,
|
|
1102
|
+
0,
|
|
1103
|
+
0,
|
|
1104
|
+
1,
|
|
1105
|
+
0,
|
|
1106
|
+
0,
|
|
1107
|
+
0,
|
|
1108
|
+
0,
|
|
1109
|
+
0,
|
|
1110
|
+
1
|
|
1111
|
+
], value));
|
|
1112
|
+
}
|
|
1113
|
+
var $_6geeiye5jm0ofys3 = {
|
|
1114
|
+
identity: identity$1,
|
|
1115
|
+
adjust: adjust,
|
|
1116
|
+
multiply: multiply,
|
|
1117
|
+
adjustContrast: adjustContrast,
|
|
1118
|
+
adjustBrightness: adjustBrightness,
|
|
1119
|
+
adjustSaturation: adjustSaturation,
|
|
1120
|
+
adjustHue: adjustHue,
|
|
1121
|
+
adjustColors: adjustColors,
|
|
1122
|
+
adjustSepia: adjustSepia,
|
|
1123
|
+
adjustGrayscale: adjustGrayscale
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
function colorFilter(ir, matrix) {
|
|
1127
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1128
|
+
return applyColorFilter(canvas, ir.getType(), matrix);
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
function applyColorFilter(canvas, type, matrix) {
|
|
1132
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1133
|
+
var pixels;
|
|
1134
|
+
function applyMatrix(pixels, m) {
|
|
1135
|
+
var d = pixels.data, r, g, b, a, i, m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3], m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7], m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11], m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15], m16 = m[16], m17 = m[17], m18 = m[18], m19 = m[19];
|
|
1136
|
+
for (i = 0; i < d.length; i += 4) {
|
|
1137
|
+
r = d[i];
|
|
1138
|
+
g = d[i + 1];
|
|
1139
|
+
b = d[i + 2];
|
|
1140
|
+
a = d[i + 3];
|
|
1141
|
+
d[i] = r * m0 + g * m1 + b * m2 + a * m3 + m4;
|
|
1142
|
+
d[i + 1] = r * m5 + g * m6 + b * m7 + a * m8 + m9;
|
|
1143
|
+
d[i + 2] = r * m10 + g * m11 + b * m12 + a * m13 + m14;
|
|
1144
|
+
d[i + 3] = r * m15 + g * m16 + b * m17 + a * m18 + m19;
|
|
1145
|
+
}
|
|
1146
|
+
return pixels;
|
|
1147
|
+
}
|
|
1148
|
+
pixels = applyMatrix(context.getImageData(0, 0, canvas.width, canvas.height), matrix);
|
|
1149
|
+
context.putImageData(pixels, 0, 0);
|
|
1150
|
+
return $_filu11e4jm0ofyrx.fromCanvas(canvas, type);
|
|
1151
|
+
}
|
|
1152
|
+
function convoluteFilter(ir, matrix) {
|
|
1153
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1154
|
+
return applyConvoluteFilter(canvas, ir.getType(), matrix);
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
function applyConvoluteFilter(canvas, type, matrix) {
|
|
1158
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1159
|
+
var pixelsIn, pixelsOut;
|
|
1160
|
+
function applyMatrix(pixelsIn, pixelsOut, matrix) {
|
|
1161
|
+
var rgba, drgba, side, halfSide, x, y, r, g, b, cx, cy, scx, scy, offset, wt, w, h;
|
|
1162
|
+
function clamp(value, min, max) {
|
|
1163
|
+
if (value > max) {
|
|
1164
|
+
value = max;
|
|
1165
|
+
} else if (value < min) {
|
|
1166
|
+
value = min;
|
|
1167
|
+
}
|
|
1168
|
+
return value;
|
|
1169
|
+
}
|
|
1170
|
+
side = Math.round(Math.sqrt(matrix.length));
|
|
1171
|
+
halfSide = Math.floor(side / 2);
|
|
1172
|
+
rgba = pixelsIn.data;
|
|
1173
|
+
drgba = pixelsOut.data;
|
|
1174
|
+
w = pixelsIn.width;
|
|
1175
|
+
h = pixelsIn.height;
|
|
1176
|
+
for (y = 0; y < h; y++) {
|
|
1177
|
+
for (x = 0; x < w; x++) {
|
|
1178
|
+
r = g = b = 0;
|
|
1179
|
+
for (cy = 0; cy < side; cy++) {
|
|
1180
|
+
for (cx = 0; cx < side; cx++) {
|
|
1181
|
+
scx = clamp(x + cx - halfSide, 0, w - 1);
|
|
1182
|
+
scy = clamp(y + cy - halfSide, 0, h - 1);
|
|
1183
|
+
offset = (scy * w + scx) * 4;
|
|
1184
|
+
wt = matrix[cy * side + cx];
|
|
1185
|
+
r += rgba[offset] * wt;
|
|
1186
|
+
g += rgba[offset + 1] * wt;
|
|
1187
|
+
b += rgba[offset + 2] * wt;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
offset = (y * w + x) * 4;
|
|
1191
|
+
drgba[offset] = clamp(r, 0, 255);
|
|
1192
|
+
drgba[offset + 1] = clamp(g, 0, 255);
|
|
1193
|
+
drgba[offset + 2] = clamp(b, 0, 255);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
return pixelsOut;
|
|
1197
|
+
}
|
|
1198
|
+
pixelsIn = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
1199
|
+
pixelsOut = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
1200
|
+
pixelsOut = applyMatrix(pixelsIn, pixelsOut, matrix);
|
|
1201
|
+
context.putImageData(pixelsOut, 0, 0);
|
|
1202
|
+
return $_filu11e4jm0ofyrx.fromCanvas(canvas, type);
|
|
1203
|
+
}
|
|
1204
|
+
function functionColorFilter(colorFn) {
|
|
1205
|
+
var filterImpl = function (canvas, type, value) {
|
|
1206
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1207
|
+
var pixels, i, lookup = new Array(256);
|
|
1208
|
+
function applyLookup(pixels, lookup) {
|
|
1209
|
+
var d = pixels.data, i;
|
|
1210
|
+
for (i = 0; i < d.length; i += 4) {
|
|
1211
|
+
d[i] = lookup[d[i]];
|
|
1212
|
+
d[i + 1] = lookup[d[i + 1]];
|
|
1213
|
+
d[i + 2] = lookup[d[i + 2]];
|
|
1214
|
+
}
|
|
1215
|
+
return pixels;
|
|
1216
|
+
}
|
|
1217
|
+
for (i = 0; i < lookup.length; i++) {
|
|
1218
|
+
lookup[i] = colorFn(i, value);
|
|
1219
|
+
}
|
|
1220
|
+
pixels = applyLookup(context.getImageData(0, 0, canvas.width, canvas.height), lookup);
|
|
1221
|
+
context.putImageData(pixels, 0, 0);
|
|
1222
|
+
return $_filu11e4jm0ofyrx.fromCanvas(canvas, type);
|
|
1223
|
+
};
|
|
1224
|
+
return function (ir, value) {
|
|
1225
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1226
|
+
return filterImpl(canvas, ir.getType(), value);
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
function complexAdjustableColorFilter(matrixAdjustFn) {
|
|
1231
|
+
return function (ir, adjust) {
|
|
1232
|
+
return colorFilter(ir, matrixAdjustFn($_6geeiye5jm0ofys3.identity(), adjust));
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
function basicColorFilter(matrix) {
|
|
1236
|
+
return function (ir) {
|
|
1237
|
+
return colorFilter(ir, matrix);
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
function basicConvolutionFilter(kernel) {
|
|
1241
|
+
return function (ir) {
|
|
1242
|
+
return convoluteFilter(ir, kernel);
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
var $_bakf7ye3jm0ofyrr = {
|
|
1246
|
+
invert: basicColorFilter([
|
|
1247
|
+
-1,
|
|
1248
|
+
0,
|
|
1249
|
+
0,
|
|
1250
|
+
0,
|
|
1251
|
+
255,
|
|
1252
|
+
0,
|
|
1253
|
+
-1,
|
|
1254
|
+
0,
|
|
1255
|
+
0,
|
|
1256
|
+
255,
|
|
1257
|
+
0,
|
|
1258
|
+
0,
|
|
1259
|
+
-1,
|
|
1260
|
+
0,
|
|
1261
|
+
255,
|
|
1262
|
+
0,
|
|
1263
|
+
0,
|
|
1264
|
+
0,
|
|
1265
|
+
1,
|
|
1266
|
+
0
|
|
1267
|
+
]),
|
|
1268
|
+
brightness: complexAdjustableColorFilter($_6geeiye5jm0ofys3.adjustBrightness),
|
|
1269
|
+
hue: complexAdjustableColorFilter($_6geeiye5jm0ofys3.adjustHue),
|
|
1270
|
+
saturate: complexAdjustableColorFilter($_6geeiye5jm0ofys3.adjustSaturation),
|
|
1271
|
+
contrast: complexAdjustableColorFilter($_6geeiye5jm0ofys3.adjustContrast),
|
|
1272
|
+
grayscale: complexAdjustableColorFilter($_6geeiye5jm0ofys3.adjustGrayscale),
|
|
1273
|
+
sepia: complexAdjustableColorFilter($_6geeiye5jm0ofys3.adjustSepia),
|
|
1274
|
+
colorize: function (ir, adjustR, adjustG, adjustB) {
|
|
1275
|
+
return colorFilter(ir, $_6geeiye5jm0ofys3.adjustColors($_6geeiye5jm0ofys3.identity(), adjustR, adjustG, adjustB));
|
|
1276
|
+
},
|
|
1277
|
+
sharpen: basicConvolutionFilter([
|
|
1278
|
+
0,
|
|
1279
|
+
-1,
|
|
1280
|
+
0,
|
|
1281
|
+
-1,
|
|
1282
|
+
5,
|
|
1283
|
+
-1,
|
|
1284
|
+
0,
|
|
1285
|
+
-1,
|
|
1286
|
+
0
|
|
1287
|
+
]),
|
|
1288
|
+
emboss: basicConvolutionFilter([
|
|
1289
|
+
-2,
|
|
1290
|
+
-1,
|
|
1291
|
+
0,
|
|
1292
|
+
-1,
|
|
1293
|
+
1,
|
|
1294
|
+
1,
|
|
1295
|
+
0,
|
|
1296
|
+
1,
|
|
1297
|
+
2
|
|
1298
|
+
]),
|
|
1299
|
+
gamma: functionColorFilter(function (color, value) {
|
|
1300
|
+
return Math.pow(color / 255, 1 - value) * 255;
|
|
1301
|
+
}),
|
|
1302
|
+
exposure: functionColorFilter(function (color, value) {
|
|
1303
|
+
return 255 * (1 - Math.exp(-(color / 255) * value));
|
|
1304
|
+
}),
|
|
1305
|
+
colorFilter: colorFilter,
|
|
1306
|
+
convoluteFilter: convoluteFilter
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
function scale(image, dW, dH) {
|
|
1310
|
+
var sW = $_exy4tfdrjm0ofyr2.getWidth(image);
|
|
1311
|
+
var sH = $_exy4tfdrjm0ofyr2.getHeight(image);
|
|
1312
|
+
var wRatio = dW / sW;
|
|
1313
|
+
var hRatio = dH / sH;
|
|
1314
|
+
var scaleCapped = false;
|
|
1315
|
+
if (wRatio < 0.5 || wRatio > 2) {
|
|
1316
|
+
wRatio = wRatio < 0.5 ? 0.5 : 2;
|
|
1317
|
+
scaleCapped = true;
|
|
1318
|
+
}
|
|
1319
|
+
if (hRatio < 0.5 || hRatio > 2) {
|
|
1320
|
+
hRatio = hRatio < 0.5 ? 0.5 : 2;
|
|
1321
|
+
scaleCapped = true;
|
|
1322
|
+
}
|
|
1323
|
+
var scaled = _scale(image, wRatio, hRatio);
|
|
1324
|
+
return !scaleCapped ? scaled : scaled.then(function (tCanvas) {
|
|
1325
|
+
return scale(tCanvas, dW, dH);
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
function _scale(image, wRatio, hRatio) {
|
|
1329
|
+
return new Promise(function (resolve) {
|
|
1330
|
+
var sW = $_exy4tfdrjm0ofyr2.getWidth(image);
|
|
1331
|
+
var sH = $_exy4tfdrjm0ofyr2.getHeight(image);
|
|
1332
|
+
var dW = Math.floor(sW * wRatio);
|
|
1333
|
+
var dH = Math.floor(sH * hRatio);
|
|
1334
|
+
var canvas = $_bdk07odqjm0ofyr0.create(dW, dH);
|
|
1335
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1336
|
+
context.drawImage(image, 0, 0, sW, sH, 0, 0, dW, dH);
|
|
1337
|
+
resolve(canvas);
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
var $_9op1hje7jm0ofysb = { scale: scale };
|
|
1341
|
+
|
|
1342
|
+
function rotate(ir, angle) {
|
|
1343
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1344
|
+
return applyRotate(canvas, ir.getType(), angle);
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
function applyRotate(image, type, angle) {
|
|
1348
|
+
var canvas = $_bdk07odqjm0ofyr0.create(image.width, image.height);
|
|
1349
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1350
|
+
var translateX = 0, translateY = 0;
|
|
1351
|
+
angle = angle < 0 ? 360 + angle : angle;
|
|
1352
|
+
if (angle == 90 || angle == 270) {
|
|
1353
|
+
$_bdk07odqjm0ofyr0.resize(canvas, canvas.height, canvas.width);
|
|
1354
|
+
}
|
|
1355
|
+
if (angle == 90 || angle == 180) {
|
|
1356
|
+
translateX = canvas.width;
|
|
1357
|
+
}
|
|
1358
|
+
if (angle == 270 || angle == 180) {
|
|
1359
|
+
translateY = canvas.height;
|
|
1360
|
+
}
|
|
1361
|
+
context.translate(translateX, translateY);
|
|
1362
|
+
context.rotate(angle * Math.PI / 180);
|
|
1363
|
+
context.drawImage(image, 0, 0);
|
|
1364
|
+
return $_filu11e4jm0ofyrx.fromCanvas(canvas, type);
|
|
1365
|
+
}
|
|
1366
|
+
function flip(ir, axis) {
|
|
1367
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1368
|
+
return applyFlip(canvas, ir.getType(), axis);
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
function applyFlip(image, type, axis) {
|
|
1372
|
+
var canvas = $_bdk07odqjm0ofyr0.create(image.width, image.height);
|
|
1373
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1374
|
+
if (axis == 'v') {
|
|
1375
|
+
context.scale(1, -1);
|
|
1376
|
+
context.drawImage(image, 0, -canvas.height);
|
|
1377
|
+
} else {
|
|
1378
|
+
context.scale(-1, 1);
|
|
1379
|
+
context.drawImage(image, -canvas.width, 0);
|
|
1380
|
+
}
|
|
1381
|
+
return $_filu11e4jm0ofyrx.fromCanvas(canvas, type);
|
|
1382
|
+
}
|
|
1383
|
+
function crop(ir, x, y, w, h) {
|
|
1384
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1385
|
+
return applyCrop(canvas, ir.getType(), x, y, w, h);
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
function applyCrop(image, type, x, y, w, h) {
|
|
1389
|
+
var canvas = $_bdk07odqjm0ofyr0.create(w, h);
|
|
1390
|
+
var context = $_bdk07odqjm0ofyr0.get2dContext(canvas);
|
|
1391
|
+
context.drawImage(image, -x, -y);
|
|
1392
|
+
return $_filu11e4jm0ofyrx.fromCanvas(canvas, type);
|
|
1393
|
+
}
|
|
1394
|
+
function resize$1(ir, w, h) {
|
|
1395
|
+
return ir.toCanvas().then(function (canvas) {
|
|
1396
|
+
return $_9op1hje7jm0ofysb.scale(canvas, w, h).then(function (newCanvas) {
|
|
1397
|
+
return $_filu11e4jm0ofyrx.fromCanvas(newCanvas, ir.getType());
|
|
1398
|
+
});
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
var $_fhnth1e6jm0ofys8 = {
|
|
1402
|
+
rotate: rotate,
|
|
1403
|
+
flip: flip,
|
|
1404
|
+
crop: crop,
|
|
1405
|
+
resize: resize$1
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
var BinaryReader = function () {
|
|
1409
|
+
function BinaryReader(ar) {
|
|
1410
|
+
this.littleEndian = false;
|
|
1411
|
+
this._dv = new DataView(ar);
|
|
1412
|
+
}
|
|
1413
|
+
BinaryReader.prototype.readByteAt = function (idx) {
|
|
1414
|
+
return this._dv.getUint8(idx);
|
|
1415
|
+
};
|
|
1416
|
+
BinaryReader.prototype.read = function (idx, size) {
|
|
1417
|
+
if (idx + size > this.length()) {
|
|
1418
|
+
return null;
|
|
1419
|
+
}
|
|
1420
|
+
var mv = this.littleEndian ? 0 : -8 * (size - 1);
|
|
1421
|
+
for (var i = 0, sum = 0; i < size; i++) {
|
|
1422
|
+
sum |= this.readByteAt(idx + i) << Math.abs(mv + i * 8);
|
|
1423
|
+
}
|
|
1424
|
+
return sum;
|
|
1425
|
+
};
|
|
1426
|
+
BinaryReader.prototype.BYTE = function (idx) {
|
|
1427
|
+
return this.read(idx, 1);
|
|
1428
|
+
};
|
|
1429
|
+
BinaryReader.prototype.SHORT = function (idx) {
|
|
1430
|
+
return this.read(idx, 2);
|
|
1431
|
+
};
|
|
1432
|
+
BinaryReader.prototype.LONG = function (idx) {
|
|
1433
|
+
return this.read(idx, 4);
|
|
1434
|
+
};
|
|
1435
|
+
BinaryReader.prototype.SLONG = function (idx) {
|
|
1436
|
+
var num = this.read(idx, 4);
|
|
1437
|
+
return num > 2147483647 ? num - 4294967296 : num;
|
|
1438
|
+
};
|
|
1439
|
+
BinaryReader.prototype.CHAR = function (idx) {
|
|
1440
|
+
return String.fromCharCode(this.read(idx, 1));
|
|
1441
|
+
};
|
|
1442
|
+
BinaryReader.prototype.STRING = function (idx, count) {
|
|
1443
|
+
return this.asArray('CHAR', idx, count).join('');
|
|
1444
|
+
};
|
|
1445
|
+
BinaryReader.prototype.SEGMENT = function (idx, size) {
|
|
1446
|
+
var ar = this._dv.buffer;
|
|
1447
|
+
switch (arguments.length) {
|
|
1448
|
+
case 2:
|
|
1449
|
+
return ar.slice(idx, idx + size);
|
|
1450
|
+
case 1:
|
|
1451
|
+
return ar.slice(idx);
|
|
1452
|
+
default:
|
|
1453
|
+
return ar;
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
BinaryReader.prototype.asArray = function (type, idx, count) {
|
|
1457
|
+
var values = [];
|
|
1458
|
+
for (var i = 0; i < count; i++) {
|
|
1459
|
+
values[i] = this[type](idx + i);
|
|
1460
|
+
}
|
|
1461
|
+
return values;
|
|
1462
|
+
};
|
|
1463
|
+
BinaryReader.prototype.length = function () {
|
|
1464
|
+
return this._dv ? this._dv.byteLength : 0;
|
|
1465
|
+
};
|
|
1466
|
+
return BinaryReader;
|
|
1467
|
+
}();
|
|
1468
|
+
|
|
1469
|
+
var tags = {
|
|
1470
|
+
tiff: {
|
|
1471
|
+
274: 'Orientation',
|
|
1472
|
+
270: 'ImageDescription',
|
|
1473
|
+
271: 'Make',
|
|
1474
|
+
272: 'Model',
|
|
1475
|
+
305: 'Software',
|
|
1476
|
+
34665: 'ExifIFDPointer',
|
|
1477
|
+
34853: 'GPSInfoIFDPointer'
|
|
1478
|
+
},
|
|
1479
|
+
exif: {
|
|
1480
|
+
36864: 'ExifVersion',
|
|
1481
|
+
40961: 'ColorSpace',
|
|
1482
|
+
40962: 'PixelXDimension',
|
|
1483
|
+
40963: 'PixelYDimension',
|
|
1484
|
+
36867: 'DateTimeOriginal',
|
|
1485
|
+
33434: 'ExposureTime',
|
|
1486
|
+
33437: 'FNumber',
|
|
1487
|
+
34855: 'ISOSpeedRatings',
|
|
1488
|
+
37377: 'ShutterSpeedValue',
|
|
1489
|
+
37378: 'ApertureValue',
|
|
1490
|
+
37383: 'MeteringMode',
|
|
1491
|
+
37384: 'LightSource',
|
|
1492
|
+
37385: 'Flash',
|
|
1493
|
+
37386: 'FocalLength',
|
|
1494
|
+
41986: 'ExposureMode',
|
|
1495
|
+
41987: 'WhiteBalance',
|
|
1496
|
+
41990: 'SceneCaptureType',
|
|
1497
|
+
41988: 'DigitalZoomRatio',
|
|
1498
|
+
41992: 'Contrast',
|
|
1499
|
+
41993: 'Saturation',
|
|
1500
|
+
41994: 'Sharpness'
|
|
1501
|
+
},
|
|
1502
|
+
gps: {
|
|
1503
|
+
0: 'GPSVersionID',
|
|
1504
|
+
1: 'GPSLatitudeRef',
|
|
1505
|
+
2: 'GPSLatitude',
|
|
1506
|
+
3: 'GPSLongitudeRef',
|
|
1507
|
+
4: 'GPSLongitude'
|
|
1508
|
+
},
|
|
1509
|
+
thumb: {
|
|
1510
|
+
513: 'JPEGInterchangeFormat',
|
|
1511
|
+
514: 'JPEGInterchangeFormatLength'
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
var tagDescs = {
|
|
1515
|
+
'ColorSpace': {
|
|
1516
|
+
1: 'sRGB',
|
|
1517
|
+
0: 'Uncalibrated'
|
|
1518
|
+
},
|
|
1519
|
+
'MeteringMode': {
|
|
1520
|
+
0: 'Unknown',
|
|
1521
|
+
1: 'Average',
|
|
1522
|
+
2: 'CenterWeightedAverage',
|
|
1523
|
+
3: 'Spot',
|
|
1524
|
+
4: 'MultiSpot',
|
|
1525
|
+
5: 'Pattern',
|
|
1526
|
+
6: 'Partial',
|
|
1527
|
+
255: 'Other'
|
|
1528
|
+
},
|
|
1529
|
+
'LightSource': {
|
|
1530
|
+
1: 'Daylight',
|
|
1531
|
+
2: 'Fliorescent',
|
|
1532
|
+
3: 'Tungsten',
|
|
1533
|
+
4: 'Flash',
|
|
1534
|
+
9: 'Fine weather',
|
|
1535
|
+
10: 'Cloudy weather',
|
|
1536
|
+
11: 'Shade',
|
|
1537
|
+
12: 'Daylight fluorescent (D 5700 - 7100K)',
|
|
1538
|
+
13: 'Day white fluorescent (N 4600 -5400K)',
|
|
1539
|
+
14: 'Cool white fluorescent (W 3900 - 4500K)',
|
|
1540
|
+
15: 'White fluorescent (WW 3200 - 3700K)',
|
|
1541
|
+
17: 'Standard light A',
|
|
1542
|
+
18: 'Standard light B',
|
|
1543
|
+
19: 'Standard light C',
|
|
1544
|
+
20: 'D55',
|
|
1545
|
+
21: 'D65',
|
|
1546
|
+
22: 'D75',
|
|
1547
|
+
23: 'D50',
|
|
1548
|
+
24: 'ISO studio tungsten',
|
|
1549
|
+
255: 'Other'
|
|
1550
|
+
},
|
|
1551
|
+
'Flash': {
|
|
1552
|
+
0: 'Flash did not fire',
|
|
1553
|
+
1: 'Flash fired',
|
|
1554
|
+
5: 'Strobe return light not detected',
|
|
1555
|
+
7: 'Strobe return light detected',
|
|
1556
|
+
9: 'Flash fired, compulsory flash mode',
|
|
1557
|
+
13: 'Flash fired, compulsory flash mode, return light not detected',
|
|
1558
|
+
15: 'Flash fired, compulsory flash mode, return light detected',
|
|
1559
|
+
16: 'Flash did not fire, compulsory flash mode',
|
|
1560
|
+
24: 'Flash did not fire, auto mode',
|
|
1561
|
+
25: 'Flash fired, auto mode',
|
|
1562
|
+
29: 'Flash fired, auto mode, return light not detected',
|
|
1563
|
+
31: 'Flash fired, auto mode, return light detected',
|
|
1564
|
+
32: 'No flash function',
|
|
1565
|
+
65: 'Flash fired, red-eye reduction mode',
|
|
1566
|
+
69: 'Flash fired, red-eye reduction mode, return light not detected',
|
|
1567
|
+
71: 'Flash fired, red-eye reduction mode, return light detected',
|
|
1568
|
+
73: 'Flash fired, compulsory flash mode, red-eye reduction mode',
|
|
1569
|
+
77: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected',
|
|
1570
|
+
79: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected',
|
|
1571
|
+
89: 'Flash fired, auto mode, red-eye reduction mode',
|
|
1572
|
+
93: 'Flash fired, auto mode, return light not detected, red-eye reduction mode',
|
|
1573
|
+
95: 'Flash fired, auto mode, return light detected, red-eye reduction mode'
|
|
1574
|
+
},
|
|
1575
|
+
'ExposureMode': {
|
|
1576
|
+
0: 'Auto exposure',
|
|
1577
|
+
1: 'Manual exposure',
|
|
1578
|
+
2: 'Auto bracket'
|
|
1579
|
+
},
|
|
1580
|
+
'WhiteBalance': {
|
|
1581
|
+
0: 'Auto white balance',
|
|
1582
|
+
1: 'Manual white balance'
|
|
1583
|
+
},
|
|
1584
|
+
'SceneCaptureType': {
|
|
1585
|
+
0: 'Standard',
|
|
1586
|
+
1: 'Landscape',
|
|
1587
|
+
2: 'Portrait',
|
|
1588
|
+
3: 'Night scene'
|
|
1589
|
+
},
|
|
1590
|
+
'Contrast': {
|
|
1591
|
+
0: 'Normal',
|
|
1592
|
+
1: 'Soft',
|
|
1593
|
+
2: 'Hard'
|
|
1594
|
+
},
|
|
1595
|
+
'Saturation': {
|
|
1596
|
+
0: 'Normal',
|
|
1597
|
+
1: 'Low saturation',
|
|
1598
|
+
2: 'High saturation'
|
|
1599
|
+
},
|
|
1600
|
+
'Sharpness': {
|
|
1601
|
+
0: 'Normal',
|
|
1602
|
+
1: 'Soft',
|
|
1603
|
+
2: 'Hard'
|
|
1604
|
+
},
|
|
1605
|
+
'GPSLatitudeRef': {
|
|
1606
|
+
N: 'North latitude',
|
|
1607
|
+
S: 'South latitude'
|
|
1608
|
+
},
|
|
1609
|
+
'GPSLongitudeRef': {
|
|
1610
|
+
E: 'East longitude',
|
|
1611
|
+
W: 'West longitude'
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
var ExifReader = function () {
|
|
1615
|
+
function ExifReader(ar) {
|
|
1616
|
+
this._offsets = {
|
|
1617
|
+
tiffHeader: 10,
|
|
1618
|
+
IFD0: null,
|
|
1619
|
+
IFD1: null,
|
|
1620
|
+
exifIFD: null,
|
|
1621
|
+
gpsIFD: null
|
|
1622
|
+
};
|
|
1623
|
+
this._tiffTags = {};
|
|
1624
|
+
var self = this;
|
|
1625
|
+
self._reader = new BinaryReader(ar);
|
|
1626
|
+
self._idx = self._offsets.tiffHeader;
|
|
1627
|
+
if (self.SHORT(0) !== 65505 || self.STRING(4, 5).toUpperCase() !== 'EXIF\0') {
|
|
1628
|
+
throw new Error('Exif data cannot be read or not available.');
|
|
1629
|
+
}
|
|
1630
|
+
self._reader.littleEndian = self.SHORT(self._idx) == 18761;
|
|
1631
|
+
if (self.SHORT(self._idx += 2) !== 42) {
|
|
1632
|
+
throw new Error('Invalid Exif data.');
|
|
1633
|
+
}
|
|
1634
|
+
self._offsets.IFD0 = self._offsets.tiffHeader + self.LONG(self._idx += 2);
|
|
1635
|
+
self._tiffTags = self.extractTags(self._offsets.IFD0, tags.tiff);
|
|
1636
|
+
if ('ExifIFDPointer' in self._tiffTags) {
|
|
1637
|
+
self._offsets.exifIFD = self._offsets.tiffHeader + self._tiffTags.ExifIFDPointer;
|
|
1638
|
+
delete self._tiffTags.ExifIFDPointer;
|
|
1639
|
+
}
|
|
1640
|
+
if ('GPSInfoIFDPointer' in self._tiffTags) {
|
|
1641
|
+
self._offsets.gpsIFD = self._offsets.tiffHeader + self._tiffTags.GPSInfoIFDPointer;
|
|
1642
|
+
delete self._tiffTags.GPSInfoIFDPointer;
|
|
1643
|
+
}
|
|
1644
|
+
var IFD1Offset = self.LONG(self._offsets.IFD0 + self.SHORT(self._offsets.IFD0) * 12 + 2);
|
|
1645
|
+
if (IFD1Offset) {
|
|
1646
|
+
self._offsets.IFD1 = self._offsets.tiffHeader + IFD1Offset;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
ExifReader.prototype.BYTE = function (idx) {
|
|
1650
|
+
return this._reader.BYTE(idx);
|
|
1651
|
+
};
|
|
1652
|
+
ExifReader.prototype.SHORT = function (idx) {
|
|
1653
|
+
return this._reader.SHORT(idx);
|
|
1654
|
+
};
|
|
1655
|
+
ExifReader.prototype.LONG = function (idx) {
|
|
1656
|
+
return this._reader.LONG(idx);
|
|
1657
|
+
};
|
|
1658
|
+
ExifReader.prototype.SLONG = function (idx) {
|
|
1659
|
+
return this._reader.SLONG(idx);
|
|
1660
|
+
};
|
|
1661
|
+
ExifReader.prototype.CHAR = function (idx) {
|
|
1662
|
+
return this._reader.CHAR(idx);
|
|
1663
|
+
};
|
|
1664
|
+
ExifReader.prototype.STRING = function (idx, count) {
|
|
1665
|
+
return this._reader.STRING(idx, count);
|
|
1666
|
+
};
|
|
1667
|
+
ExifReader.prototype.SEGMENT = function (idx, size) {
|
|
1668
|
+
return this._reader.SEGMENT(idx, size);
|
|
1669
|
+
};
|
|
1670
|
+
ExifReader.prototype.asArray = function (type, idx, count) {
|
|
1671
|
+
var values = [];
|
|
1672
|
+
for (var i = 0; i < count; i++) {
|
|
1673
|
+
values[i] = this[type](idx + i);
|
|
1674
|
+
}
|
|
1675
|
+
return values;
|
|
1676
|
+
};
|
|
1677
|
+
ExifReader.prototype.length = function () {
|
|
1678
|
+
return this._reader.length();
|
|
1679
|
+
};
|
|
1680
|
+
ExifReader.prototype.UNDEFINED = function () {
|
|
1681
|
+
return this.BYTE.apply(this, arguments);
|
|
1682
|
+
};
|
|
1683
|
+
ExifReader.prototype.RATIONAL = function (idx) {
|
|
1684
|
+
return this.LONG(idx) / this.LONG(idx + 4);
|
|
1685
|
+
};
|
|
1686
|
+
ExifReader.prototype.SRATIONAL = function (idx) {
|
|
1687
|
+
return this.SLONG(idx) / this.SLONG(idx + 4);
|
|
1688
|
+
};
|
|
1689
|
+
ExifReader.prototype.ASCII = function (idx) {
|
|
1690
|
+
return this.CHAR(idx);
|
|
1691
|
+
};
|
|
1692
|
+
ExifReader.prototype.TIFF = function () {
|
|
1693
|
+
return this._tiffTags;
|
|
1694
|
+
};
|
|
1695
|
+
ExifReader.prototype.EXIF = function () {
|
|
1696
|
+
var self = this;
|
|
1697
|
+
var Exif = null;
|
|
1698
|
+
if (self._offsets.exifIFD) {
|
|
1699
|
+
try {
|
|
1700
|
+
Exif = self.extractTags(self._offsets.exifIFD, tags.exif);
|
|
1701
|
+
} catch (ex) {
|
|
1702
|
+
return null;
|
|
1703
|
+
}
|
|
1704
|
+
if (Exif.ExifVersion && Array.isArray(Exif.ExifVersion)) {
|
|
1705
|
+
for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) {
|
|
1706
|
+
exifVersion += String.fromCharCode(Exif.ExifVersion[i]);
|
|
1707
|
+
}
|
|
1708
|
+
Exif.ExifVersion = exifVersion;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
return Exif;
|
|
1712
|
+
};
|
|
1713
|
+
ExifReader.prototype.GPS = function () {
|
|
1714
|
+
var self = this;
|
|
1715
|
+
var GPS = null;
|
|
1716
|
+
if (self._offsets.gpsIFD) {
|
|
1717
|
+
try {
|
|
1718
|
+
GPS = self.extractTags(self._offsets.gpsIFD, tags.gps);
|
|
1719
|
+
} catch (ex) {
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
if (GPS.GPSVersionID && Array.isArray(GPS.GPSVersionID)) {
|
|
1723
|
+
GPS.GPSVersionID = GPS.GPSVersionID.join('.');
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return GPS;
|
|
1727
|
+
};
|
|
1728
|
+
ExifReader.prototype.thumb = function () {
|
|
1729
|
+
var self = this;
|
|
1730
|
+
if (self._offsets.IFD1) {
|
|
1731
|
+
try {
|
|
1732
|
+
var IFD1Tags = self.extractTags(self._offsets.IFD1, tags.thumb);
|
|
1733
|
+
if ('JPEGInterchangeFormat' in IFD1Tags) {
|
|
1734
|
+
return self.SEGMENT(self._offsets.tiffHeader + IFD1Tags.JPEGInterchangeFormat, IFD1Tags.JPEGInterchangeFormatLength);
|
|
1735
|
+
}
|
|
1736
|
+
} catch (ex) {
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
return null;
|
|
1740
|
+
};
|
|
1741
|
+
ExifReader.prototype.extractTags = function (IFD_offset, tags2extract) {
|
|
1742
|
+
var self = this;
|
|
1743
|
+
var length, i, tag, type, count, size, offset, value, values = [], hash = {};
|
|
1744
|
+
var types = {
|
|
1745
|
+
1: 'BYTE',
|
|
1746
|
+
7: 'UNDEFINED',
|
|
1747
|
+
2: 'ASCII',
|
|
1748
|
+
3: 'SHORT',
|
|
1749
|
+
4: 'LONG',
|
|
1750
|
+
5: 'RATIONAL',
|
|
1751
|
+
9: 'SLONG',
|
|
1752
|
+
10: 'SRATIONAL'
|
|
1753
|
+
};
|
|
1754
|
+
var sizes = {
|
|
1755
|
+
'BYTE': 1,
|
|
1756
|
+
'UNDEFINED': 1,
|
|
1757
|
+
'ASCII': 1,
|
|
1758
|
+
'SHORT': 2,
|
|
1759
|
+
'LONG': 4,
|
|
1760
|
+
'RATIONAL': 8,
|
|
1761
|
+
'SLONG': 4,
|
|
1762
|
+
'SRATIONAL': 8
|
|
1763
|
+
};
|
|
1764
|
+
length = self.SHORT(IFD_offset);
|
|
1765
|
+
for (i = 0; i < length; i++) {
|
|
1766
|
+
values = [];
|
|
1767
|
+
offset = IFD_offset + 2 + i * 12;
|
|
1768
|
+
tag = tags2extract[self.SHORT(offset)];
|
|
1769
|
+
if (tag === undefined) {
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
type = types[self.SHORT(offset += 2)];
|
|
1773
|
+
count = self.LONG(offset += 2);
|
|
1774
|
+
size = sizes[type];
|
|
1775
|
+
if (!size) {
|
|
1776
|
+
throw new Error('Invalid Exif data.');
|
|
1777
|
+
}
|
|
1778
|
+
offset += 4;
|
|
1779
|
+
if (size * count > 4) {
|
|
1780
|
+
offset = self.LONG(offset) + self._offsets.tiffHeader;
|
|
1781
|
+
}
|
|
1782
|
+
if (offset + size * count >= self.length()) {
|
|
1783
|
+
throw new Error('Invalid Exif data.');
|
|
1784
|
+
}
|
|
1785
|
+
if (type === 'ASCII') {
|
|
1786
|
+
hash[tag] = self.STRING(offset, count).replace(/\0$/, '').trim();
|
|
1787
|
+
continue;
|
|
1788
|
+
} else {
|
|
1789
|
+
values = self.asArray(type, offset, count);
|
|
1790
|
+
value = count == 1 ? values[0] : values;
|
|
1791
|
+
if (tagDescs.hasOwnProperty(tag) && typeof value != 'object') {
|
|
1792
|
+
hash[tag] = tagDescs[tag][value];
|
|
1793
|
+
} else {
|
|
1794
|
+
hash[tag] = value;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return hash;
|
|
1799
|
+
};
|
|
1800
|
+
return ExifReader;
|
|
1801
|
+
}();
|
|
1802
|
+
|
|
1803
|
+
var extractFrom = function (blob) {
|
|
1804
|
+
return $_aqivtudpjm0ofyql.blobToArrayBuffer(blob).then(function (ar) {
|
|
1805
|
+
try {
|
|
1806
|
+
var br = new BinaryReader(ar);
|
|
1807
|
+
if (br.SHORT(0) === 65496) {
|
|
1808
|
+
var headers = extractHeaders(br);
|
|
1809
|
+
var app1 = headers.filter(function (header) {
|
|
1810
|
+
return header.name === 'APP1';
|
|
1811
|
+
});
|
|
1812
|
+
var meta = {};
|
|
1813
|
+
if (app1.length) {
|
|
1814
|
+
var exifReader = new ExifReader(app1[0].segment);
|
|
1815
|
+
meta = {
|
|
1816
|
+
tiff: exifReader.TIFF(),
|
|
1817
|
+
exif: exifReader.EXIF(),
|
|
1818
|
+
gps: exifReader.GPS(),
|
|
1819
|
+
thumb: exifReader.thumb()
|
|
1820
|
+
};
|
|
1821
|
+
} else {
|
|
1822
|
+
return Promise.reject('Headers did not include required information');
|
|
1823
|
+
}
|
|
1824
|
+
meta.rawHeaders = headers;
|
|
1825
|
+
return meta;
|
|
1826
|
+
}
|
|
1827
|
+
return Promise.reject('Image was not a jpeg');
|
|
1828
|
+
} catch (ex) {
|
|
1829
|
+
return Promise.reject('Unsupported format or not an image: ' + blob.type + ' (Exception: ' + ex.message + ')');
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
};
|
|
1833
|
+
var extractHeaders = function (br) {
|
|
1834
|
+
var headers = [], idx, marker, length = 0;
|
|
1835
|
+
idx = 2;
|
|
1836
|
+
while (idx <= br.length()) {
|
|
1837
|
+
marker = br.SHORT(idx);
|
|
1838
|
+
if (marker >= 65488 && marker <= 65495) {
|
|
1839
|
+
idx += 2;
|
|
1840
|
+
continue;
|
|
1841
|
+
}
|
|
1842
|
+
if (marker === 65498 || marker === 65497) {
|
|
1843
|
+
break;
|
|
1844
|
+
}
|
|
1845
|
+
length = br.SHORT(idx + 2) + 2;
|
|
1846
|
+
if (marker >= 65505 && marker <= 65519) {
|
|
1847
|
+
headers.push({
|
|
1848
|
+
hex: marker,
|
|
1849
|
+
name: 'APP' + (marker & 15),
|
|
1850
|
+
start: idx,
|
|
1851
|
+
length: length,
|
|
1852
|
+
segment: br.SEGMENT(idx, length)
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
idx += length;
|
|
1856
|
+
}
|
|
1857
|
+
return headers;
|
|
1858
|
+
};
|
|
1859
|
+
var $_64a2gle8jm0ofyse = { extractFrom: extractFrom };
|
|
1860
|
+
|
|
1861
|
+
var invert = function (ir) {
|
|
1862
|
+
return $_bakf7ye3jm0ofyrr.invert(ir);
|
|
1863
|
+
};
|
|
1864
|
+
var sharpen = function (ir) {
|
|
1865
|
+
return $_bakf7ye3jm0ofyrr.sharpen(ir);
|
|
1866
|
+
};
|
|
1867
|
+
var emboss = function (ir) {
|
|
1868
|
+
return $_bakf7ye3jm0ofyrr.emboss(ir);
|
|
1869
|
+
};
|
|
1870
|
+
var gamma = function (ir, value) {
|
|
1871
|
+
return $_bakf7ye3jm0ofyrr.gamma(ir, value);
|
|
1872
|
+
};
|
|
1873
|
+
var exposure = function (ir, value) {
|
|
1874
|
+
return $_bakf7ye3jm0ofyrr.exposure(ir, value);
|
|
1875
|
+
};
|
|
1876
|
+
var colorize = function (ir, adjustR, adjustG, adjustB) {
|
|
1877
|
+
return $_bakf7ye3jm0ofyrr.colorize(ir, adjustR, adjustG, adjustB);
|
|
1878
|
+
};
|
|
1879
|
+
var brightness = function (ir, adjust) {
|
|
1880
|
+
return $_bakf7ye3jm0ofyrr.brightness(ir, adjust);
|
|
1881
|
+
};
|
|
1882
|
+
var hue = function (ir, adjust) {
|
|
1883
|
+
return $_bakf7ye3jm0ofyrr.hue(ir, adjust);
|
|
1884
|
+
};
|
|
1885
|
+
var saturate = function (ir, adjust) {
|
|
1886
|
+
return $_bakf7ye3jm0ofyrr.saturate(ir, adjust);
|
|
1887
|
+
};
|
|
1888
|
+
var contrast = function (ir, adjust) {
|
|
1889
|
+
return $_bakf7ye3jm0ofyrr.contrast(ir, adjust);
|
|
1890
|
+
};
|
|
1891
|
+
var grayscale = function (ir, adjust) {
|
|
1892
|
+
return $_bakf7ye3jm0ofyrr.grayscale(ir, adjust);
|
|
1893
|
+
};
|
|
1894
|
+
var sepia = function (ir, adjust) {
|
|
1895
|
+
return $_bakf7ye3jm0ofyrr.sepia(ir, adjust);
|
|
1896
|
+
};
|
|
1897
|
+
var flip$1 = function (ir, axis) {
|
|
1898
|
+
return $_fhnth1e6jm0ofys8.flip(ir, axis);
|
|
1899
|
+
};
|
|
1900
|
+
var crop$1 = function (ir, x, y, w, h) {
|
|
1901
|
+
return $_fhnth1e6jm0ofys8.crop(ir, x, y, w, h);
|
|
1902
|
+
};
|
|
1903
|
+
var resize$2 = function (ir, w, h) {
|
|
1904
|
+
return $_fhnth1e6jm0ofys8.resize(ir, w, h);
|
|
1905
|
+
};
|
|
1906
|
+
var rotate$1 = function (ir, angle) {
|
|
1907
|
+
return $_fhnth1e6jm0ofys8.rotate(ir, angle);
|
|
1908
|
+
};
|
|
1909
|
+
var exifRotate = function (ir) {
|
|
1910
|
+
var ROTATE_90 = 6;
|
|
1911
|
+
var ROTATE_180 = 3;
|
|
1912
|
+
var ROTATE_270 = 8;
|
|
1913
|
+
var checkRotation = function (data) {
|
|
1914
|
+
var orientation = data.tiff.Orientation;
|
|
1915
|
+
switch (orientation) {
|
|
1916
|
+
case ROTATE_90:
|
|
1917
|
+
return rotate$1(ir, 90);
|
|
1918
|
+
case ROTATE_180:
|
|
1919
|
+
return rotate$1(ir, 180);
|
|
1920
|
+
case ROTATE_270:
|
|
1921
|
+
return rotate$1(ir, 270);
|
|
1922
|
+
default:
|
|
1923
|
+
return ir;
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
};
|
|
1927
|
+
var notJpeg = function () {
|
|
1928
|
+
return ir;
|
|
1929
|
+
};
|
|
1930
|
+
return ir.toBlob().then($_64a2gle8jm0ofyse.extractFrom).then(checkRotation, notJpeg);
|
|
1931
|
+
};
|
|
1932
|
+
var $_6vp8sye2jm0ofyrn = {
|
|
1933
|
+
invert: invert,
|
|
1934
|
+
sharpen: sharpen,
|
|
1935
|
+
emboss: emboss,
|
|
1936
|
+
brightness: brightness,
|
|
1937
|
+
hue: hue,
|
|
1938
|
+
saturate: saturate,
|
|
1939
|
+
contrast: contrast,
|
|
1940
|
+
grayscale: grayscale,
|
|
1941
|
+
sepia: sepia,
|
|
1942
|
+
colorize: colorize,
|
|
1943
|
+
gamma: gamma,
|
|
1944
|
+
exposure: exposure,
|
|
1945
|
+
flip: flip$1,
|
|
1946
|
+
crop: crop$1,
|
|
1947
|
+
resize: resize$2,
|
|
1948
|
+
rotate: rotate$1,
|
|
1949
|
+
exifRotate: exifRotate
|
|
1950
|
+
};
|
|
1951
|
+
|
|
1952
|
+
var blobToImageResult = function (blob) {
|
|
1953
|
+
return $_filu11e4jm0ofyrx.fromBlob(blob);
|
|
1954
|
+
};
|
|
1955
|
+
var fromBlobAndUrlSync$1 = function (blob, uri) {
|
|
1956
|
+
return $_filu11e4jm0ofyrx.fromBlobAndUrlSync(blob, uri);
|
|
1957
|
+
};
|
|
1958
|
+
var imageToImageResult = function (image) {
|
|
1959
|
+
return $_filu11e4jm0ofyrx.fromImage(image);
|
|
1960
|
+
};
|
|
1961
|
+
var imageResultToBlob = function (ir, type, quality) {
|
|
1962
|
+
if (type === undefined && quality === undefined) {
|
|
1963
|
+
return imageResultToOriginalBlob(ir);
|
|
1964
|
+
} else {
|
|
1965
|
+
return ir.toAdjustedBlob(type, quality);
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
var imageResultToOriginalBlob = function (ir) {
|
|
1969
|
+
return ir.toBlob();
|
|
1970
|
+
};
|
|
1971
|
+
var imageResultToDataURL = function (ir) {
|
|
1972
|
+
return ir.toDataURL();
|
|
1973
|
+
};
|
|
1974
|
+
var $_b7i5rsebjm0ofyt2 = {
|
|
1975
|
+
blobToImageResult: blobToImageResult,
|
|
1976
|
+
fromBlobAndUrlSync: fromBlobAndUrlSync$1,
|
|
1977
|
+
imageToImageResult: imageToImageResult,
|
|
1978
|
+
imageResultToBlob: imageResultToBlob,
|
|
1979
|
+
imageResultToOriginalBlob: imageResultToOriginalBlob,
|
|
1980
|
+
imageResultToDataURL: imageResultToDataURL
|
|
1981
|
+
};
|
|
1982
|
+
|
|
1983
|
+
var url = function () {
|
|
1984
|
+
return $_ektrqldwjm0ofyrf.getOrDie('URL');
|
|
1985
|
+
};
|
|
1986
|
+
var createObjectURL = function (blob) {
|
|
1987
|
+
return url().createObjectURL(blob);
|
|
1988
|
+
};
|
|
1989
|
+
var revokeObjectURL = function (u) {
|
|
1990
|
+
url().revokeObjectURL(u);
|
|
1991
|
+
};
|
|
1992
|
+
var $_finsnbecjm0ofyt4 = {
|
|
1993
|
+
createObjectURL: createObjectURL,
|
|
1994
|
+
revokeObjectURL: revokeObjectURL
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
1998
|
+
|
|
1999
|
+
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
2000
|
+
|
|
2001
|
+
var global$4 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
2002
|
+
|
|
2003
|
+
var getToolbarItems = function (editor) {
|
|
2004
|
+
return editor.getParam('imagetools_toolbar', 'rotateleft rotateright | flipv fliph | crop editimage imageoptions');
|
|
2005
|
+
};
|
|
2006
|
+
var getProxyUrl = function (editor) {
|
|
2007
|
+
return editor.getParam('imagetools_proxy');
|
|
2008
|
+
};
|
|
2009
|
+
var getCorsHosts = function (editor) {
|
|
2010
|
+
return editor.getParam('imagetools_cors_hosts', [], 'string[]');
|
|
2011
|
+
};
|
|
2012
|
+
var getCredentialsHosts = function (editor) {
|
|
2013
|
+
return editor.getParam('imagetools_credentials_hosts', [], 'string[]');
|
|
2014
|
+
};
|
|
2015
|
+
var getApiKey = function (editor) {
|
|
2016
|
+
return editor.getParam('api_key', editor.getParam('imagetools_api_key', '', 'string'), 'string');
|
|
2017
|
+
};
|
|
2018
|
+
var getUploadTimeout = function (editor) {
|
|
2019
|
+
return editor.getParam('images_upload_timeout', 30000, 'number');
|
|
2020
|
+
};
|
|
2021
|
+
var shouldReuseFilename = function (editor) {
|
|
2022
|
+
return editor.getParam('images_reuse_filename', false, 'boolean');
|
|
2023
|
+
};
|
|
2024
|
+
|
|
2025
|
+
var global$5 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
2026
|
+
|
|
2027
|
+
var global$6 = tinymce.util.Tools.resolve('tinymce.ui.Factory');
|
|
2028
|
+
|
|
2029
|
+
function UndoStack () {
|
|
2030
|
+
var data = [];
|
|
2031
|
+
var index = -1;
|
|
2032
|
+
function add(state) {
|
|
2033
|
+
var removed;
|
|
2034
|
+
removed = data.splice(++index);
|
|
2035
|
+
data.push(state);
|
|
2036
|
+
return {
|
|
2037
|
+
state: state,
|
|
2038
|
+
removed: removed
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
function undo() {
|
|
2042
|
+
if (canUndo()) {
|
|
2043
|
+
return data[--index];
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
function redo() {
|
|
2047
|
+
if (canRedo()) {
|
|
2048
|
+
return data[++index];
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
function canUndo() {
|
|
2052
|
+
return index > 0;
|
|
2053
|
+
}
|
|
2054
|
+
function canRedo() {
|
|
2055
|
+
return index !== -1 && index < data.length - 1;
|
|
2056
|
+
}
|
|
2057
|
+
return {
|
|
2058
|
+
data: data,
|
|
2059
|
+
add: add,
|
|
2060
|
+
undo: undo,
|
|
2061
|
+
redo: redo,
|
|
2062
|
+
canUndo: canUndo,
|
|
2063
|
+
canRedo: canRedo
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
var global$7 = tinymce.util.Tools.resolve('tinymce.geom.Rect');
|
|
2068
|
+
|
|
2069
|
+
var loadImage$1 = function (image) {
|
|
2070
|
+
return new global$3(function (resolve) {
|
|
2071
|
+
var loaded = function () {
|
|
2072
|
+
image.removeEventListener('load', loaded);
|
|
2073
|
+
resolve(image);
|
|
2074
|
+
};
|
|
2075
|
+
if (image.complete) {
|
|
2076
|
+
resolve(image);
|
|
2077
|
+
} else {
|
|
2078
|
+
image.addEventListener('load', loaded);
|
|
2079
|
+
}
|
|
2080
|
+
});
|
|
2081
|
+
};
|
|
2082
|
+
var $_7qgyjgenjm0ofytw = { loadImage: loadImage$1 };
|
|
2083
|
+
|
|
2084
|
+
var global$8 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
|
|
2085
|
+
|
|
2086
|
+
var global$9 = tinymce.util.Tools.resolve('tinymce.util.Observable');
|
|
2087
|
+
|
|
2088
|
+
var global$10 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
2089
|
+
|
|
2090
|
+
var count = 0;
|
|
2091
|
+
function CropRect (currentRect, viewPortRect, clampRect, containerElm, action) {
|
|
2092
|
+
var instance;
|
|
2093
|
+
var handles;
|
|
2094
|
+
var dragHelpers;
|
|
2095
|
+
var blockers;
|
|
2096
|
+
var prefix = 'mce-';
|
|
2097
|
+
var id = prefix + 'crid-' + count++;
|
|
2098
|
+
handles = [
|
|
2099
|
+
{
|
|
2100
|
+
name: 'move',
|
|
2101
|
+
xMul: 0,
|
|
2102
|
+
yMul: 0,
|
|
2103
|
+
deltaX: 1,
|
|
2104
|
+
deltaY: 1,
|
|
2105
|
+
deltaW: 0,
|
|
2106
|
+
deltaH: 0,
|
|
2107
|
+
label: 'Crop Mask'
|
|
2108
|
+
},
|
|
2109
|
+
{
|
|
2110
|
+
name: 'nw',
|
|
2111
|
+
xMul: 0,
|
|
2112
|
+
yMul: 0,
|
|
2113
|
+
deltaX: 1,
|
|
2114
|
+
deltaY: 1,
|
|
2115
|
+
deltaW: -1,
|
|
2116
|
+
deltaH: -1,
|
|
2117
|
+
label: 'Top Left Crop Handle'
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
name: 'ne',
|
|
2121
|
+
xMul: 1,
|
|
2122
|
+
yMul: 0,
|
|
2123
|
+
deltaX: 0,
|
|
2124
|
+
deltaY: 1,
|
|
2125
|
+
deltaW: 1,
|
|
2126
|
+
deltaH: -1,
|
|
2127
|
+
label: 'Top Right Crop Handle'
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
name: 'sw',
|
|
2131
|
+
xMul: 0,
|
|
2132
|
+
yMul: 1,
|
|
2133
|
+
deltaX: 1,
|
|
2134
|
+
deltaY: 0,
|
|
2135
|
+
deltaW: -1,
|
|
2136
|
+
deltaH: 1,
|
|
2137
|
+
label: 'Bottom Left Crop Handle'
|
|
2138
|
+
},
|
|
2139
|
+
{
|
|
2140
|
+
name: 'se',
|
|
2141
|
+
xMul: 1,
|
|
2142
|
+
yMul: 1,
|
|
2143
|
+
deltaX: 0,
|
|
2144
|
+
deltaY: 0,
|
|
2145
|
+
deltaW: 1,
|
|
2146
|
+
deltaH: 1,
|
|
2147
|
+
label: 'Bottom Right Crop Handle'
|
|
2148
|
+
}
|
|
2149
|
+
];
|
|
2150
|
+
blockers = [
|
|
2151
|
+
'top',
|
|
2152
|
+
'right',
|
|
2153
|
+
'bottom',
|
|
2154
|
+
'left'
|
|
2155
|
+
];
|
|
2156
|
+
function getAbsoluteRect(outerRect, relativeRect) {
|
|
2157
|
+
return {
|
|
2158
|
+
x: relativeRect.x + outerRect.x,
|
|
2159
|
+
y: relativeRect.y + outerRect.y,
|
|
2160
|
+
w: relativeRect.w,
|
|
2161
|
+
h: relativeRect.h
|
|
2162
|
+
};
|
|
2163
|
+
}
|
|
2164
|
+
function getRelativeRect(outerRect, innerRect) {
|
|
2165
|
+
return {
|
|
2166
|
+
x: innerRect.x - outerRect.x,
|
|
2167
|
+
y: innerRect.y - outerRect.y,
|
|
2168
|
+
w: innerRect.w,
|
|
2169
|
+
h: innerRect.h
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
function getInnerRect() {
|
|
2173
|
+
return getRelativeRect(clampRect, currentRect);
|
|
2174
|
+
}
|
|
2175
|
+
function moveRect(handle, startRect, deltaX, deltaY) {
|
|
2176
|
+
var x, y, w, h, rect;
|
|
2177
|
+
x = startRect.x;
|
|
2178
|
+
y = startRect.y;
|
|
2179
|
+
w = startRect.w;
|
|
2180
|
+
h = startRect.h;
|
|
2181
|
+
x += deltaX * handle.deltaX;
|
|
2182
|
+
y += deltaY * handle.deltaY;
|
|
2183
|
+
w += deltaX * handle.deltaW;
|
|
2184
|
+
h += deltaY * handle.deltaH;
|
|
2185
|
+
if (w < 20) {
|
|
2186
|
+
w = 20;
|
|
2187
|
+
}
|
|
2188
|
+
if (h < 20) {
|
|
2189
|
+
h = 20;
|
|
2190
|
+
}
|
|
2191
|
+
rect = currentRect = global$7.clamp({
|
|
2192
|
+
x: x,
|
|
2193
|
+
y: y,
|
|
2194
|
+
w: w,
|
|
2195
|
+
h: h
|
|
2196
|
+
}, clampRect, handle.name === 'move');
|
|
2197
|
+
rect = getRelativeRect(clampRect, rect);
|
|
2198
|
+
instance.fire('updateRect', { rect: rect });
|
|
2199
|
+
setInnerRect(rect);
|
|
2200
|
+
}
|
|
2201
|
+
function render() {
|
|
2202
|
+
function createDragHelper(handle) {
|
|
2203
|
+
var startRect;
|
|
2204
|
+
var DragHelper = global$6.get('DragHelper');
|
|
2205
|
+
return new DragHelper(id, {
|
|
2206
|
+
document: containerElm.ownerDocument,
|
|
2207
|
+
handle: id + '-' + handle.name,
|
|
2208
|
+
start: function () {
|
|
2209
|
+
startRect = currentRect;
|
|
2210
|
+
},
|
|
2211
|
+
drag: function (e) {
|
|
2212
|
+
moveRect(handle, startRect, e.deltaX, e.deltaY);
|
|
2213
|
+
}
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
global$8('<div id="' + id + '" class="' + prefix + 'croprect-container"' + ' role="grid" aria-dropeffect="execute">').appendTo(containerElm);
|
|
2217
|
+
global$1.each(blockers, function (blocker) {
|
|
2218
|
+
global$8('#' + id, containerElm).append('<div id="' + id + '-' + blocker + '"class="' + prefix + 'croprect-block" style="display: none" data-mce-bogus="all">');
|
|
2219
|
+
});
|
|
2220
|
+
global$1.each(handles, function (handle) {
|
|
2221
|
+
global$8('#' + id, containerElm).append('<div id="' + id + '-' + handle.name + '" class="' + prefix + 'croprect-handle ' + prefix + 'croprect-handle-' + handle.name + '"' + 'style="display: none" data-mce-bogus="all" role="gridcell" tabindex="-1"' + ' aria-label="' + handle.label + '" aria-grabbed="false">');
|
|
2222
|
+
});
|
|
2223
|
+
dragHelpers = global$1.map(handles, createDragHelper);
|
|
2224
|
+
repaint(currentRect);
|
|
2225
|
+
global$8(containerElm).on('focusin focusout', function (e) {
|
|
2226
|
+
global$8(e.target).attr('aria-grabbed', e.type === 'focus');
|
|
2227
|
+
});
|
|
2228
|
+
global$8(containerElm).on('keydown', function (e) {
|
|
2229
|
+
var activeHandle;
|
|
2230
|
+
global$1.each(handles, function (handle) {
|
|
2231
|
+
if (e.target.id === id + '-' + handle.name) {
|
|
2232
|
+
activeHandle = handle;
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2235
|
+
});
|
|
2236
|
+
function moveAndBlock(evt, handle, startRect, deltaX, deltaY) {
|
|
2237
|
+
evt.stopPropagation();
|
|
2238
|
+
evt.preventDefault();
|
|
2239
|
+
moveRect(activeHandle, startRect, deltaX, deltaY);
|
|
2240
|
+
}
|
|
2241
|
+
switch (e.keyCode) {
|
|
2242
|
+
case global$10.LEFT:
|
|
2243
|
+
moveAndBlock(e, activeHandle, currentRect, -10, 0);
|
|
2244
|
+
break;
|
|
2245
|
+
case global$10.RIGHT:
|
|
2246
|
+
moveAndBlock(e, activeHandle, currentRect, 10, 0);
|
|
2247
|
+
break;
|
|
2248
|
+
case global$10.UP:
|
|
2249
|
+
moveAndBlock(e, activeHandle, currentRect, 0, -10);
|
|
2250
|
+
break;
|
|
2251
|
+
case global$10.DOWN:
|
|
2252
|
+
moveAndBlock(e, activeHandle, currentRect, 0, 10);
|
|
2253
|
+
break;
|
|
2254
|
+
case global$10.ENTER:
|
|
2255
|
+
case global$10.SPACEBAR:
|
|
2256
|
+
e.preventDefault();
|
|
2257
|
+
action();
|
|
2258
|
+
break;
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
function toggleVisibility(state) {
|
|
2263
|
+
var selectors;
|
|
2264
|
+
selectors = global$1.map(handles, function (handle) {
|
|
2265
|
+
return '#' + id + '-' + handle.name;
|
|
2266
|
+
}).concat(global$1.map(blockers, function (blocker) {
|
|
2267
|
+
return '#' + id + '-' + blocker;
|
|
2268
|
+
})).join(',');
|
|
2269
|
+
if (state) {
|
|
2270
|
+
global$8(selectors, containerElm).show();
|
|
2271
|
+
} else {
|
|
2272
|
+
global$8(selectors, containerElm).hide();
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
function repaint(rect) {
|
|
2276
|
+
function updateElementRect(name, rect) {
|
|
2277
|
+
if (rect.h < 0) {
|
|
2278
|
+
rect.h = 0;
|
|
2279
|
+
}
|
|
2280
|
+
if (rect.w < 0) {
|
|
2281
|
+
rect.w = 0;
|
|
2282
|
+
}
|
|
2283
|
+
global$8('#' + id + '-' + name, containerElm).css({
|
|
2284
|
+
left: rect.x,
|
|
2285
|
+
top: rect.y,
|
|
2286
|
+
width: rect.w,
|
|
2287
|
+
height: rect.h
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
global$1.each(handles, function (handle) {
|
|
2291
|
+
global$8('#' + id + '-' + handle.name, containerElm).css({
|
|
2292
|
+
left: rect.w * handle.xMul + rect.x,
|
|
2293
|
+
top: rect.h * handle.yMul + rect.y
|
|
2294
|
+
});
|
|
2295
|
+
});
|
|
2296
|
+
updateElementRect('top', {
|
|
2297
|
+
x: viewPortRect.x,
|
|
2298
|
+
y: viewPortRect.y,
|
|
2299
|
+
w: viewPortRect.w,
|
|
2300
|
+
h: rect.y - viewPortRect.y
|
|
2301
|
+
});
|
|
2302
|
+
updateElementRect('right', {
|
|
2303
|
+
x: rect.x + rect.w,
|
|
2304
|
+
y: rect.y,
|
|
2305
|
+
w: viewPortRect.w - rect.x - rect.w + viewPortRect.x,
|
|
2306
|
+
h: rect.h
|
|
2307
|
+
});
|
|
2308
|
+
updateElementRect('bottom', {
|
|
2309
|
+
x: viewPortRect.x,
|
|
2310
|
+
y: rect.y + rect.h,
|
|
2311
|
+
w: viewPortRect.w,
|
|
2312
|
+
h: viewPortRect.h - rect.y - rect.h + viewPortRect.y
|
|
2313
|
+
});
|
|
2314
|
+
updateElementRect('left', {
|
|
2315
|
+
x: viewPortRect.x,
|
|
2316
|
+
y: rect.y,
|
|
2317
|
+
w: rect.x - viewPortRect.x,
|
|
2318
|
+
h: rect.h
|
|
2319
|
+
});
|
|
2320
|
+
updateElementRect('move', rect);
|
|
2321
|
+
}
|
|
2322
|
+
function setRect(rect) {
|
|
2323
|
+
currentRect = rect;
|
|
2324
|
+
repaint(currentRect);
|
|
2325
|
+
}
|
|
2326
|
+
function setViewPortRect(rect) {
|
|
2327
|
+
viewPortRect = rect;
|
|
2328
|
+
repaint(currentRect);
|
|
2329
|
+
}
|
|
2330
|
+
function setInnerRect(rect) {
|
|
2331
|
+
setRect(getAbsoluteRect(clampRect, rect));
|
|
2332
|
+
}
|
|
2333
|
+
function setClampRect(rect) {
|
|
2334
|
+
clampRect = rect;
|
|
2335
|
+
repaint(currentRect);
|
|
2336
|
+
}
|
|
2337
|
+
function destroy() {
|
|
2338
|
+
global$1.each(dragHelpers, function (helper) {
|
|
2339
|
+
helper.destroy();
|
|
2340
|
+
});
|
|
2341
|
+
dragHelpers = [];
|
|
2342
|
+
}
|
|
2343
|
+
render();
|
|
2344
|
+
instance = global$1.extend({
|
|
2345
|
+
toggleVisibility: toggleVisibility,
|
|
2346
|
+
setClampRect: setClampRect,
|
|
2347
|
+
setRect: setRect,
|
|
2348
|
+
getInnerRect: getInnerRect,
|
|
2349
|
+
setInnerRect: setInnerRect,
|
|
2350
|
+
setViewPortRect: setViewPortRect,
|
|
2351
|
+
destroy: destroy
|
|
2352
|
+
}, global$9);
|
|
2353
|
+
return instance;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
var create$2 = function (settings) {
|
|
2357
|
+
var Control = global$6.get('Control');
|
|
2358
|
+
var ImagePanel = Control.extend({
|
|
2359
|
+
Defaults: { classes: 'imagepanel' },
|
|
2360
|
+
selection: function (rect) {
|
|
2361
|
+
if (arguments.length) {
|
|
2362
|
+
this.state.set('rect', rect);
|
|
2363
|
+
return this;
|
|
2364
|
+
}
|
|
2365
|
+
return this.state.get('rect');
|
|
2366
|
+
},
|
|
2367
|
+
imageSize: function () {
|
|
2368
|
+
var viewRect = this.state.get('viewRect');
|
|
2369
|
+
return {
|
|
2370
|
+
w: viewRect.w,
|
|
2371
|
+
h: viewRect.h
|
|
2372
|
+
};
|
|
2373
|
+
},
|
|
2374
|
+
toggleCropRect: function (state) {
|
|
2375
|
+
this.state.set('cropEnabled', state);
|
|
2376
|
+
},
|
|
2377
|
+
imageSrc: function (url) {
|
|
2378
|
+
var self$$1 = this, img = new Image();
|
|
2379
|
+
img.src = url;
|
|
2380
|
+
$_7qgyjgenjm0ofytw.loadImage(img).then(function () {
|
|
2381
|
+
var rect, $img;
|
|
2382
|
+
var lastRect = self$$1.state.get('viewRect');
|
|
2383
|
+
$img = self$$1.$el.find('img');
|
|
2384
|
+
if ($img[0]) {
|
|
2385
|
+
$img.replaceWith(img);
|
|
2386
|
+
} else {
|
|
2387
|
+
var bg = document.createElement('div');
|
|
2388
|
+
bg.className = 'mce-imagepanel-bg';
|
|
2389
|
+
self$$1.getEl().appendChild(bg);
|
|
2390
|
+
self$$1.getEl().appendChild(img);
|
|
2391
|
+
}
|
|
2392
|
+
rect = {
|
|
2393
|
+
x: 0,
|
|
2394
|
+
y: 0,
|
|
2395
|
+
w: img.naturalWidth,
|
|
2396
|
+
h: img.naturalHeight
|
|
2397
|
+
};
|
|
2398
|
+
self$$1.state.set('viewRect', rect);
|
|
2399
|
+
self$$1.state.set('rect', global$7.inflate(rect, -20, -20));
|
|
2400
|
+
if (!lastRect || lastRect.w !== rect.w || lastRect.h !== rect.h) {
|
|
2401
|
+
self$$1.zoomFit();
|
|
2402
|
+
}
|
|
2403
|
+
self$$1.repaintImage();
|
|
2404
|
+
self$$1.fire('load');
|
|
2405
|
+
});
|
|
2406
|
+
},
|
|
2407
|
+
zoom: function (value) {
|
|
2408
|
+
if (arguments.length) {
|
|
2409
|
+
this.state.set('zoom', value);
|
|
2410
|
+
return this;
|
|
2411
|
+
}
|
|
2412
|
+
return this.state.get('zoom');
|
|
2413
|
+
},
|
|
2414
|
+
postRender: function () {
|
|
2415
|
+
this.imageSrc(this.settings.imageSrc);
|
|
2416
|
+
return this._super();
|
|
2417
|
+
},
|
|
2418
|
+
zoomFit: function () {
|
|
2419
|
+
var self$$1 = this;
|
|
2420
|
+
var $img, pw, ph, w, h, zoom, padding;
|
|
2421
|
+
padding = 10;
|
|
2422
|
+
$img = self$$1.$el.find('img');
|
|
2423
|
+
pw = self$$1.getEl().clientWidth;
|
|
2424
|
+
ph = self$$1.getEl().clientHeight;
|
|
2425
|
+
w = $img[0].naturalWidth;
|
|
2426
|
+
h = $img[0].naturalHeight;
|
|
2427
|
+
zoom = Math.min((pw - padding) / w, (ph - padding) / h);
|
|
2428
|
+
if (zoom >= 1) {
|
|
2429
|
+
zoom = 1;
|
|
2430
|
+
}
|
|
2431
|
+
self$$1.zoom(zoom);
|
|
2432
|
+
},
|
|
2433
|
+
repaintImage: function () {
|
|
2434
|
+
var x, y, w, h, pw, ph, $img, $bg, zoom, rect, elm;
|
|
2435
|
+
elm = this.getEl();
|
|
2436
|
+
zoom = this.zoom();
|
|
2437
|
+
rect = this.state.get('rect');
|
|
2438
|
+
$img = this.$el.find('img');
|
|
2439
|
+
$bg = this.$el.find('.mce-imagepanel-bg');
|
|
2440
|
+
pw = elm.offsetWidth;
|
|
2441
|
+
ph = elm.offsetHeight;
|
|
2442
|
+
w = $img[0].naturalWidth * zoom;
|
|
2443
|
+
h = $img[0].naturalHeight * zoom;
|
|
2444
|
+
x = Math.max(0, pw / 2 - w / 2);
|
|
2445
|
+
y = Math.max(0, ph / 2 - h / 2);
|
|
2446
|
+
$img.css({
|
|
2447
|
+
left: x,
|
|
2448
|
+
top: y,
|
|
2449
|
+
width: w,
|
|
2450
|
+
height: h
|
|
2451
|
+
});
|
|
2452
|
+
$bg.css({
|
|
2453
|
+
left: x,
|
|
2454
|
+
top: y,
|
|
2455
|
+
width: w,
|
|
2456
|
+
height: h
|
|
2457
|
+
});
|
|
2458
|
+
if (this.cropRect) {
|
|
2459
|
+
this.cropRect.setRect({
|
|
2460
|
+
x: rect.x * zoom + x,
|
|
2461
|
+
y: rect.y * zoom + y,
|
|
2462
|
+
w: rect.w * zoom,
|
|
2463
|
+
h: rect.h * zoom
|
|
2464
|
+
});
|
|
2465
|
+
this.cropRect.setClampRect({
|
|
2466
|
+
x: x,
|
|
2467
|
+
y: y,
|
|
2468
|
+
w: w,
|
|
2469
|
+
h: h
|
|
2470
|
+
});
|
|
2471
|
+
this.cropRect.setViewPortRect({
|
|
2472
|
+
x: 0,
|
|
2473
|
+
y: 0,
|
|
2474
|
+
w: pw,
|
|
2475
|
+
h: ph
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
},
|
|
2479
|
+
bindStates: function () {
|
|
2480
|
+
var self$$1 = this;
|
|
2481
|
+
function setupCropRect(rect) {
|
|
2482
|
+
self$$1.cropRect = CropRect(rect, self$$1.state.get('viewRect'), self$$1.state.get('viewRect'), self$$1.getEl(), function () {
|
|
2483
|
+
self$$1.fire('crop');
|
|
2484
|
+
});
|
|
2485
|
+
self$$1.cropRect.on('updateRect', function (e) {
|
|
2486
|
+
var rect = e.rect;
|
|
2487
|
+
var zoom = self$$1.zoom();
|
|
2488
|
+
rect = {
|
|
2489
|
+
x: Math.round(rect.x / zoom),
|
|
2490
|
+
y: Math.round(rect.y / zoom),
|
|
2491
|
+
w: Math.round(rect.w / zoom),
|
|
2492
|
+
h: Math.round(rect.h / zoom)
|
|
2493
|
+
};
|
|
2494
|
+
self$$1.state.set('rect', rect);
|
|
2495
|
+
});
|
|
2496
|
+
self$$1.on('remove', self$$1.cropRect.destroy);
|
|
2497
|
+
}
|
|
2498
|
+
self$$1.state.on('change:cropEnabled', function (e) {
|
|
2499
|
+
self$$1.cropRect.toggleVisibility(e.value);
|
|
2500
|
+
self$$1.repaintImage();
|
|
2501
|
+
});
|
|
2502
|
+
self$$1.state.on('change:zoom', function () {
|
|
2503
|
+
self$$1.repaintImage();
|
|
2504
|
+
});
|
|
2505
|
+
self$$1.state.on('change:rect', function (e) {
|
|
2506
|
+
var rect = e.value;
|
|
2507
|
+
if (!self$$1.cropRect) {
|
|
2508
|
+
setupCropRect(rect);
|
|
2509
|
+
}
|
|
2510
|
+
self$$1.cropRect.setRect(rect);
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
return new ImagePanel(settings);
|
|
2515
|
+
};
|
|
2516
|
+
var $_60wl03eljm0ofyts = { create: create$2 };
|
|
2517
|
+
|
|
2518
|
+
function createState(blob) {
|
|
2519
|
+
return {
|
|
2520
|
+
blob: blob,
|
|
2521
|
+
url: $_finsnbecjm0ofyt4.createObjectURL(blob)
|
|
2522
|
+
};
|
|
2523
|
+
}
|
|
2524
|
+
function destroyState(state) {
|
|
2525
|
+
if (state) {
|
|
2526
|
+
$_finsnbecjm0ofyt4.revokeObjectURL(state.url);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
function destroyStates(states) {
|
|
2530
|
+
global$1.each(states, destroyState);
|
|
2531
|
+
}
|
|
2532
|
+
function open(editor, currentState, resolve, reject) {
|
|
2533
|
+
var win, undoStack = UndoStack(), mainPanel, filtersPanel, tempState, cropPanel, resizePanel, flipRotatePanel, imagePanel, sidePanel, mainViewContainer, invertPanel, brightnessPanel, huePanel, saturatePanel, contrastPanel, grayscalePanel, sepiaPanel, colorizePanel, sharpenPanel, embossPanel, gammaPanel, exposurePanel, panels, width, height, ratioW, ratioH;
|
|
2534
|
+
var reverseIfRtl = function (items) {
|
|
2535
|
+
return editor.rtl ? items.reverse() : items;
|
|
2536
|
+
};
|
|
2537
|
+
function recalcSize(e) {
|
|
2538
|
+
var widthCtrl, heightCtrl, newWidth, newHeight;
|
|
2539
|
+
widthCtrl = win.find('#w')[0];
|
|
2540
|
+
heightCtrl = win.find('#h')[0];
|
|
2541
|
+
newWidth = parseInt(widthCtrl.value(), 10);
|
|
2542
|
+
newHeight = parseInt(heightCtrl.value(), 10);
|
|
2543
|
+
if (win.find('#constrain')[0].checked() && width && height && newWidth && newHeight) {
|
|
2544
|
+
if (e.control.settings.name === 'w') {
|
|
2545
|
+
newHeight = Math.round(newWidth * ratioW);
|
|
2546
|
+
heightCtrl.value(newHeight);
|
|
2547
|
+
} else {
|
|
2548
|
+
newWidth = Math.round(newHeight * ratioH);
|
|
2549
|
+
widthCtrl.value(newWidth);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
width = newWidth;
|
|
2553
|
+
height = newHeight;
|
|
2554
|
+
}
|
|
2555
|
+
function floatToPercent(value) {
|
|
2556
|
+
return Math.round(value * 100) + '%';
|
|
2557
|
+
}
|
|
2558
|
+
function updateButtonUndoStates() {
|
|
2559
|
+
win.find('#undo').disabled(!undoStack.canUndo());
|
|
2560
|
+
win.find('#redo').disabled(!undoStack.canRedo());
|
|
2561
|
+
win.statusbar.find('#save').disabled(!undoStack.canUndo());
|
|
2562
|
+
}
|
|
2563
|
+
function disableUndoRedo() {
|
|
2564
|
+
win.find('#undo').disabled(true);
|
|
2565
|
+
win.find('#redo').disabled(true);
|
|
2566
|
+
}
|
|
2567
|
+
function displayState(state) {
|
|
2568
|
+
if (state) {
|
|
2569
|
+
imagePanel.imageSrc(state.url);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
function switchPanel(targetPanel) {
|
|
2573
|
+
return function () {
|
|
2574
|
+
var hidePanels = global$1.grep(panels, function (panel) {
|
|
2575
|
+
return panel.settings.name !== targetPanel;
|
|
2576
|
+
});
|
|
2577
|
+
global$1.each(hidePanels, function (panel) {
|
|
2578
|
+
panel.hide();
|
|
2579
|
+
});
|
|
2580
|
+
targetPanel.show();
|
|
2581
|
+
targetPanel.focus();
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
function addTempState(blob) {
|
|
2585
|
+
tempState = createState(blob);
|
|
2586
|
+
displayState(tempState);
|
|
2587
|
+
}
|
|
2588
|
+
function addBlobState(blob) {
|
|
2589
|
+
currentState = createState(blob);
|
|
2590
|
+
displayState(currentState);
|
|
2591
|
+
destroyStates(undoStack.add(currentState).removed);
|
|
2592
|
+
updateButtonUndoStates();
|
|
2593
|
+
}
|
|
2594
|
+
function crop() {
|
|
2595
|
+
var rect = imagePanel.selection();
|
|
2596
|
+
$_b7i5rsebjm0ofyt2.blobToImageResult(currentState.blob).then(function (ir) {
|
|
2597
|
+
$_6vp8sye2jm0ofyrn.crop(ir, rect.x, rect.y, rect.w, rect.h).then(imageResultToBlob).then(function (blob) {
|
|
2598
|
+
addBlobState(blob);
|
|
2599
|
+
cancel();
|
|
2600
|
+
});
|
|
2601
|
+
});
|
|
2602
|
+
}
|
|
2603
|
+
var tempAction = function (fn) {
|
|
2604
|
+
var args = [].slice.call(arguments, 1);
|
|
2605
|
+
return function () {
|
|
2606
|
+
var state = tempState || currentState;
|
|
2607
|
+
$_b7i5rsebjm0ofyt2.blobToImageResult(state.blob).then(function (ir) {
|
|
2608
|
+
fn.apply(this, [ir].concat(args)).then(imageResultToBlob).then(addTempState);
|
|
2609
|
+
});
|
|
2610
|
+
};
|
|
2611
|
+
};
|
|
2612
|
+
function action(fn) {
|
|
2613
|
+
var arg = [];
|
|
2614
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2615
|
+
arg[_i - 1] = arguments[_i];
|
|
2616
|
+
}
|
|
2617
|
+
var args = [].slice.call(arguments, 1);
|
|
2618
|
+
return function () {
|
|
2619
|
+
$_b7i5rsebjm0ofyt2.blobToImageResult(currentState.blob).then(function (ir) {
|
|
2620
|
+
fn.apply(this, [ir].concat(args)).then(imageResultToBlob).then(addBlobState);
|
|
2621
|
+
});
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
function cancel() {
|
|
2625
|
+
displayState(currentState);
|
|
2626
|
+
destroyState(tempState);
|
|
2627
|
+
switchPanel(mainPanel)();
|
|
2628
|
+
updateButtonUndoStates();
|
|
2629
|
+
}
|
|
2630
|
+
function waitForTempState(times, applyCall) {
|
|
2631
|
+
if (tempState) {
|
|
2632
|
+
applyCall();
|
|
2633
|
+
} else {
|
|
2634
|
+
setTimeout(function () {
|
|
2635
|
+
if (times-- > 0) {
|
|
2636
|
+
waitForTempState(times, applyCall);
|
|
2637
|
+
} else {
|
|
2638
|
+
editor.windowManager.alert('Error: failed to apply image operation.');
|
|
2639
|
+
}
|
|
2640
|
+
}, 10);
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
function applyTempState() {
|
|
2644
|
+
if (tempState) {
|
|
2645
|
+
addBlobState(tempState.blob);
|
|
2646
|
+
cancel();
|
|
2647
|
+
} else {
|
|
2648
|
+
waitForTempState(100, applyTempState);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
function zoomIn() {
|
|
2652
|
+
var zoom = imagePanel.zoom();
|
|
2653
|
+
if (zoom < 2) {
|
|
2654
|
+
zoom += 0.1;
|
|
2655
|
+
}
|
|
2656
|
+
imagePanel.zoom(zoom);
|
|
2657
|
+
}
|
|
2658
|
+
function zoomOut() {
|
|
2659
|
+
var zoom = imagePanel.zoom();
|
|
2660
|
+
if (zoom > 0.1) {
|
|
2661
|
+
zoom -= 0.1;
|
|
2662
|
+
}
|
|
2663
|
+
imagePanel.zoom(zoom);
|
|
2664
|
+
}
|
|
2665
|
+
function undo() {
|
|
2666
|
+
currentState = undoStack.undo();
|
|
2667
|
+
displayState(currentState);
|
|
2668
|
+
updateButtonUndoStates();
|
|
2669
|
+
}
|
|
2670
|
+
function redo() {
|
|
2671
|
+
currentState = undoStack.redo();
|
|
2672
|
+
displayState(currentState);
|
|
2673
|
+
updateButtonUndoStates();
|
|
2674
|
+
}
|
|
2675
|
+
function save() {
|
|
2676
|
+
resolve(currentState.blob);
|
|
2677
|
+
win.close();
|
|
2678
|
+
}
|
|
2679
|
+
function createPanel(items) {
|
|
2680
|
+
return global$6.create('Form', {
|
|
2681
|
+
layout: 'flex',
|
|
2682
|
+
direction: 'row',
|
|
2683
|
+
labelGap: 5,
|
|
2684
|
+
border: '0 0 1 0',
|
|
2685
|
+
align: 'center',
|
|
2686
|
+
pack: 'center',
|
|
2687
|
+
padding: '0 10 0 10',
|
|
2688
|
+
spacing: 5,
|
|
2689
|
+
flex: 0,
|
|
2690
|
+
minHeight: 60,
|
|
2691
|
+
defaults: {
|
|
2692
|
+
classes: 'imagetool',
|
|
2693
|
+
type: 'button'
|
|
2694
|
+
},
|
|
2695
|
+
items: items
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2698
|
+
var imageResultToBlob = function (ir) {
|
|
2699
|
+
return ir.toBlob();
|
|
2700
|
+
};
|
|
2701
|
+
function createFilterPanel(title, filter) {
|
|
2702
|
+
return createPanel(reverseIfRtl([
|
|
2703
|
+
{
|
|
2704
|
+
text: 'Back',
|
|
2705
|
+
onclick: cancel
|
|
2706
|
+
},
|
|
2707
|
+
{
|
|
2708
|
+
type: 'spacer',
|
|
2709
|
+
flex: 1
|
|
2710
|
+
},
|
|
2711
|
+
{
|
|
2712
|
+
text: 'Apply',
|
|
2713
|
+
subtype: 'primary',
|
|
2714
|
+
onclick: applyTempState
|
|
2715
|
+
}
|
|
2716
|
+
])).hide().on('show', function () {
|
|
2717
|
+
disableUndoRedo();
|
|
2718
|
+
$_b7i5rsebjm0ofyt2.blobToImageResult(currentState.blob).then(function (ir) {
|
|
2719
|
+
return filter(ir);
|
|
2720
|
+
}).then(imageResultToBlob).then(function (blob) {
|
|
2721
|
+
var newTempState = createState(blob);
|
|
2722
|
+
displayState(newTempState);
|
|
2723
|
+
destroyState(tempState);
|
|
2724
|
+
tempState = newTempState;
|
|
2725
|
+
});
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
function createVariableFilterPanel(title, filter, value, min, max) {
|
|
2729
|
+
function update(value) {
|
|
2730
|
+
$_b7i5rsebjm0ofyt2.blobToImageResult(currentState.blob).then(function (ir) {
|
|
2731
|
+
return filter(ir, value);
|
|
2732
|
+
}).then(imageResultToBlob).then(function (blob) {
|
|
2733
|
+
var newTempState = createState(blob);
|
|
2734
|
+
displayState(newTempState);
|
|
2735
|
+
destroyState(tempState);
|
|
2736
|
+
tempState = newTempState;
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
return createPanel(reverseIfRtl([
|
|
2740
|
+
{
|
|
2741
|
+
text: 'Back',
|
|
2742
|
+
onclick: cancel
|
|
2743
|
+
},
|
|
2744
|
+
{
|
|
2745
|
+
type: 'spacer',
|
|
2746
|
+
flex: 1
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
type: 'slider',
|
|
2750
|
+
flex: 1,
|
|
2751
|
+
ondragend: function (e) {
|
|
2752
|
+
update(e.value);
|
|
2753
|
+
},
|
|
2754
|
+
minValue: editor.rtl ? max : min,
|
|
2755
|
+
maxValue: editor.rtl ? min : max,
|
|
2756
|
+
value: value,
|
|
2757
|
+
previewFilter: floatToPercent
|
|
2758
|
+
},
|
|
2759
|
+
{
|
|
2760
|
+
type: 'spacer',
|
|
2761
|
+
flex: 1
|
|
2762
|
+
},
|
|
2763
|
+
{
|
|
2764
|
+
text: 'Apply',
|
|
2765
|
+
subtype: 'primary',
|
|
2766
|
+
onclick: applyTempState
|
|
2767
|
+
}
|
|
2768
|
+
])).hide().on('show', function () {
|
|
2769
|
+
this.find('slider').value(value);
|
|
2770
|
+
disableUndoRedo();
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
function createRgbFilterPanel(title, filter) {
|
|
2774
|
+
function update() {
|
|
2775
|
+
var r, g, b;
|
|
2776
|
+
r = win.find('#r')[0].value();
|
|
2777
|
+
g = win.find('#g')[0].value();
|
|
2778
|
+
b = win.find('#b')[0].value();
|
|
2779
|
+
$_b7i5rsebjm0ofyt2.blobToImageResult(currentState.blob).then(function (ir) {
|
|
2780
|
+
return filter(ir, r, g, b);
|
|
2781
|
+
}).then(imageResultToBlob).then(function (blob) {
|
|
2782
|
+
var newTempState = createState(blob);
|
|
2783
|
+
displayState(newTempState);
|
|
2784
|
+
destroyState(tempState);
|
|
2785
|
+
tempState = newTempState;
|
|
2786
|
+
});
|
|
2787
|
+
}
|
|
2788
|
+
var min = editor.rtl ? 2 : 0;
|
|
2789
|
+
var max = editor.rtl ? 0 : 2;
|
|
2790
|
+
return createPanel(reverseIfRtl([
|
|
2791
|
+
{
|
|
2792
|
+
text: 'Back',
|
|
2793
|
+
onclick: cancel
|
|
2794
|
+
},
|
|
2795
|
+
{
|
|
2796
|
+
type: 'spacer',
|
|
2797
|
+
flex: 1
|
|
2798
|
+
},
|
|
2799
|
+
{
|
|
2800
|
+
type: 'slider',
|
|
2801
|
+
label: 'R',
|
|
2802
|
+
name: 'r',
|
|
2803
|
+
minValue: min,
|
|
2804
|
+
value: 1,
|
|
2805
|
+
maxValue: max,
|
|
2806
|
+
ondragend: update,
|
|
2807
|
+
previewFilter: floatToPercent
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
type: 'slider',
|
|
2811
|
+
label: 'G',
|
|
2812
|
+
name: 'g',
|
|
2813
|
+
minValue: min,
|
|
2814
|
+
value: 1,
|
|
2815
|
+
maxValue: max,
|
|
2816
|
+
ondragend: update,
|
|
2817
|
+
previewFilter: floatToPercent
|
|
2818
|
+
},
|
|
2819
|
+
{
|
|
2820
|
+
type: 'slider',
|
|
2821
|
+
label: 'B',
|
|
2822
|
+
name: 'b',
|
|
2823
|
+
minValue: min,
|
|
2824
|
+
value: 1,
|
|
2825
|
+
maxValue: max,
|
|
2826
|
+
ondragend: update,
|
|
2827
|
+
previewFilter: floatToPercent
|
|
2828
|
+
},
|
|
2829
|
+
{
|
|
2830
|
+
type: 'spacer',
|
|
2831
|
+
flex: 1
|
|
2832
|
+
},
|
|
2833
|
+
{
|
|
2834
|
+
text: 'Apply',
|
|
2835
|
+
subtype: 'primary',
|
|
2836
|
+
onclick: applyTempState
|
|
2837
|
+
}
|
|
2838
|
+
])).hide().on('show', function () {
|
|
2839
|
+
win.find('#r,#g,#b').value(1);
|
|
2840
|
+
disableUndoRedo();
|
|
2841
|
+
});
|
|
2842
|
+
}
|
|
2843
|
+
cropPanel = createPanel(reverseIfRtl([
|
|
2844
|
+
{
|
|
2845
|
+
text: 'Back',
|
|
2846
|
+
onclick: cancel
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
type: 'spacer',
|
|
2850
|
+
flex: 1
|
|
2851
|
+
},
|
|
2852
|
+
{
|
|
2853
|
+
text: 'Apply',
|
|
2854
|
+
subtype: 'primary',
|
|
2855
|
+
onclick: crop
|
|
2856
|
+
}
|
|
2857
|
+
])).hide().on('show hide', function (e) {
|
|
2858
|
+
imagePanel.toggleCropRect(e.type === 'show');
|
|
2859
|
+
}).on('show', disableUndoRedo);
|
|
2860
|
+
function toggleConstrain(e) {
|
|
2861
|
+
if (e.control.value() === true) {
|
|
2862
|
+
ratioW = height / width;
|
|
2863
|
+
ratioH = width / height;
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
resizePanel = createPanel(reverseIfRtl([
|
|
2867
|
+
{
|
|
2868
|
+
text: 'Back',
|
|
2869
|
+
onclick: cancel
|
|
2870
|
+
},
|
|
2871
|
+
{
|
|
2872
|
+
type: 'spacer',
|
|
2873
|
+
flex: 1
|
|
2874
|
+
},
|
|
2875
|
+
{
|
|
2876
|
+
type: 'textbox',
|
|
2877
|
+
name: 'w',
|
|
2878
|
+
label: 'Width',
|
|
2879
|
+
size: 4,
|
|
2880
|
+
onkeyup: recalcSize
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
type: 'textbox',
|
|
2884
|
+
name: 'h',
|
|
2885
|
+
label: 'Height',
|
|
2886
|
+
size: 4,
|
|
2887
|
+
onkeyup: recalcSize
|
|
2888
|
+
},
|
|
2889
|
+
{
|
|
2890
|
+
type: 'checkbox',
|
|
2891
|
+
name: 'constrain',
|
|
2892
|
+
text: 'Constrain proportions',
|
|
2893
|
+
checked: true,
|
|
2894
|
+
onchange: toggleConstrain
|
|
2895
|
+
},
|
|
2896
|
+
{
|
|
2897
|
+
type: 'spacer',
|
|
2898
|
+
flex: 1
|
|
2899
|
+
},
|
|
2900
|
+
{
|
|
2901
|
+
text: 'Apply',
|
|
2902
|
+
subtype: 'primary',
|
|
2903
|
+
onclick: 'submit'
|
|
2904
|
+
}
|
|
2905
|
+
])).hide().on('submit', function (e) {
|
|
2906
|
+
var width = parseInt(win.find('#w').value(), 10), height = parseInt(win.find('#h').value(), 10);
|
|
2907
|
+
e.preventDefault();
|
|
2908
|
+
action($_6vp8sye2jm0ofyrn.resize, width, height)();
|
|
2909
|
+
cancel();
|
|
2910
|
+
}).on('show', disableUndoRedo);
|
|
2911
|
+
flipRotatePanel = createPanel(reverseIfRtl([
|
|
2912
|
+
{
|
|
2913
|
+
text: 'Back',
|
|
2914
|
+
onclick: cancel
|
|
2915
|
+
},
|
|
2916
|
+
{
|
|
2917
|
+
type: 'spacer',
|
|
2918
|
+
flex: 1
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
icon: 'fliph',
|
|
2922
|
+
tooltip: 'Flip horizontally',
|
|
2923
|
+
onclick: tempAction($_6vp8sye2jm0ofyrn.flip, 'h')
|
|
2924
|
+
},
|
|
2925
|
+
{
|
|
2926
|
+
icon: 'flipv',
|
|
2927
|
+
tooltip: 'Flip vertically',
|
|
2928
|
+
onclick: tempAction($_6vp8sye2jm0ofyrn.flip, 'v')
|
|
2929
|
+
},
|
|
2930
|
+
{
|
|
2931
|
+
icon: 'rotateleft',
|
|
2932
|
+
tooltip: 'Rotate counterclockwise',
|
|
2933
|
+
onclick: tempAction($_6vp8sye2jm0ofyrn.rotate, -90)
|
|
2934
|
+
},
|
|
2935
|
+
{
|
|
2936
|
+
icon: 'rotateright',
|
|
2937
|
+
tooltip: 'Rotate clockwise',
|
|
2938
|
+
onclick: tempAction($_6vp8sye2jm0ofyrn.rotate, 90)
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
type: 'spacer',
|
|
2942
|
+
flex: 1
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
text: 'Apply',
|
|
2946
|
+
subtype: 'primary',
|
|
2947
|
+
onclick: applyTempState
|
|
2948
|
+
}
|
|
2949
|
+
])).hide().on('show', disableUndoRedo);
|
|
2950
|
+
invertPanel = createFilterPanel('Invert', $_6vp8sye2jm0ofyrn.invert);
|
|
2951
|
+
sharpenPanel = createFilterPanel('Sharpen', $_6vp8sye2jm0ofyrn.sharpen);
|
|
2952
|
+
embossPanel = createFilterPanel('Emboss', $_6vp8sye2jm0ofyrn.emboss);
|
|
2953
|
+
brightnessPanel = createVariableFilterPanel('Brightness', $_6vp8sye2jm0ofyrn.brightness, 0, -1, 1);
|
|
2954
|
+
huePanel = createVariableFilterPanel('Hue', $_6vp8sye2jm0ofyrn.hue, 180, 0, 360);
|
|
2955
|
+
saturatePanel = createVariableFilterPanel('Saturate', $_6vp8sye2jm0ofyrn.saturate, 0, -1, 1);
|
|
2956
|
+
contrastPanel = createVariableFilterPanel('Contrast', $_6vp8sye2jm0ofyrn.contrast, 0, -1, 1);
|
|
2957
|
+
grayscalePanel = createVariableFilterPanel('Grayscale', $_6vp8sye2jm0ofyrn.grayscale, 0, 0, 1);
|
|
2958
|
+
sepiaPanel = createVariableFilterPanel('Sepia', $_6vp8sye2jm0ofyrn.sepia, 0, 0, 1);
|
|
2959
|
+
colorizePanel = createRgbFilterPanel('Colorize', $_6vp8sye2jm0ofyrn.colorize);
|
|
2960
|
+
gammaPanel = createVariableFilterPanel('Gamma', $_6vp8sye2jm0ofyrn.gamma, 0, -1, 1);
|
|
2961
|
+
exposurePanel = createVariableFilterPanel('Exposure', $_6vp8sye2jm0ofyrn.exposure, 1, 0, 2);
|
|
2962
|
+
filtersPanel = createPanel(reverseIfRtl([
|
|
2963
|
+
{
|
|
2964
|
+
text: 'Back',
|
|
2965
|
+
onclick: cancel
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
type: 'spacer',
|
|
2969
|
+
flex: 1
|
|
2970
|
+
},
|
|
2971
|
+
{
|
|
2972
|
+
text: 'hue',
|
|
2973
|
+
icon: 'hue',
|
|
2974
|
+
onclick: switchPanel(huePanel)
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
text: 'saturate',
|
|
2978
|
+
icon: 'saturate',
|
|
2979
|
+
onclick: switchPanel(saturatePanel)
|
|
2980
|
+
},
|
|
2981
|
+
{
|
|
2982
|
+
text: 'sepia',
|
|
2983
|
+
icon: 'sepia',
|
|
2984
|
+
onclick: switchPanel(sepiaPanel)
|
|
2985
|
+
},
|
|
2986
|
+
{
|
|
2987
|
+
text: 'emboss',
|
|
2988
|
+
icon: 'emboss',
|
|
2989
|
+
onclick: switchPanel(embossPanel)
|
|
2990
|
+
},
|
|
2991
|
+
{
|
|
2992
|
+
text: 'exposure',
|
|
2993
|
+
icon: 'exposure',
|
|
2994
|
+
onclick: switchPanel(exposurePanel)
|
|
2995
|
+
},
|
|
2996
|
+
{
|
|
2997
|
+
type: 'spacer',
|
|
2998
|
+
flex: 1
|
|
2999
|
+
}
|
|
3000
|
+
])).hide();
|
|
3001
|
+
mainPanel = createPanel(reverseIfRtl([
|
|
3002
|
+
{
|
|
3003
|
+
tooltip: 'Crop',
|
|
3004
|
+
icon: 'crop',
|
|
3005
|
+
onclick: switchPanel(cropPanel)
|
|
3006
|
+
},
|
|
3007
|
+
{
|
|
3008
|
+
tooltip: 'Resize',
|
|
3009
|
+
icon: 'resize2',
|
|
3010
|
+
onclick: switchPanel(resizePanel)
|
|
3011
|
+
},
|
|
3012
|
+
{
|
|
3013
|
+
tooltip: 'Orientation',
|
|
3014
|
+
icon: 'orientation',
|
|
3015
|
+
onclick: switchPanel(flipRotatePanel)
|
|
3016
|
+
},
|
|
3017
|
+
{
|
|
3018
|
+
tooltip: 'Brightness',
|
|
3019
|
+
icon: 'sun',
|
|
3020
|
+
onclick: switchPanel(brightnessPanel)
|
|
3021
|
+
},
|
|
3022
|
+
{
|
|
3023
|
+
tooltip: 'Sharpen',
|
|
3024
|
+
icon: 'sharpen',
|
|
3025
|
+
onclick: switchPanel(sharpenPanel)
|
|
3026
|
+
},
|
|
3027
|
+
{
|
|
3028
|
+
tooltip: 'Contrast',
|
|
3029
|
+
icon: 'contrast',
|
|
3030
|
+
onclick: switchPanel(contrastPanel)
|
|
3031
|
+
},
|
|
3032
|
+
{
|
|
3033
|
+
tooltip: 'Color levels',
|
|
3034
|
+
icon: 'drop',
|
|
3035
|
+
onclick: switchPanel(colorizePanel)
|
|
3036
|
+
},
|
|
3037
|
+
{
|
|
3038
|
+
tooltip: 'Gamma',
|
|
3039
|
+
icon: 'gamma',
|
|
3040
|
+
onclick: switchPanel(gammaPanel)
|
|
3041
|
+
},
|
|
3042
|
+
{
|
|
3043
|
+
tooltip: 'Invert',
|
|
3044
|
+
icon: 'invert',
|
|
3045
|
+
onclick: switchPanel(invertPanel)
|
|
3046
|
+
}
|
|
3047
|
+
]));
|
|
3048
|
+
imagePanel = $_60wl03eljm0ofyts.create({
|
|
3049
|
+
flex: 1,
|
|
3050
|
+
imageSrc: currentState.url
|
|
3051
|
+
});
|
|
3052
|
+
sidePanel = global$6.create('Container', {
|
|
3053
|
+
layout: 'flex',
|
|
3054
|
+
direction: 'column',
|
|
3055
|
+
pack: 'start',
|
|
3056
|
+
border: '0 1 0 0',
|
|
3057
|
+
padding: 5,
|
|
3058
|
+
spacing: 5,
|
|
3059
|
+
items: [
|
|
3060
|
+
{
|
|
3061
|
+
type: 'button',
|
|
3062
|
+
icon: 'undo',
|
|
3063
|
+
tooltip: 'Undo',
|
|
3064
|
+
name: 'undo',
|
|
3065
|
+
onclick: undo
|
|
3066
|
+
},
|
|
3067
|
+
{
|
|
3068
|
+
type: 'button',
|
|
3069
|
+
icon: 'redo',
|
|
3070
|
+
tooltip: 'Redo',
|
|
3071
|
+
name: 'redo',
|
|
3072
|
+
onclick: redo
|
|
3073
|
+
},
|
|
3074
|
+
{
|
|
3075
|
+
type: 'button',
|
|
3076
|
+
icon: 'zoomin',
|
|
3077
|
+
tooltip: 'Zoom in',
|
|
3078
|
+
onclick: zoomIn
|
|
3079
|
+
},
|
|
3080
|
+
{
|
|
3081
|
+
type: 'button',
|
|
3082
|
+
icon: 'zoomout',
|
|
3083
|
+
tooltip: 'Zoom out',
|
|
3084
|
+
onclick: zoomOut
|
|
3085
|
+
}
|
|
3086
|
+
]
|
|
3087
|
+
});
|
|
3088
|
+
mainViewContainer = global$6.create('Container', {
|
|
3089
|
+
type: 'container',
|
|
3090
|
+
layout: 'flex',
|
|
3091
|
+
direction: 'row',
|
|
3092
|
+
align: 'stretch',
|
|
3093
|
+
flex: 1,
|
|
3094
|
+
items: reverseIfRtl([
|
|
3095
|
+
sidePanel,
|
|
3096
|
+
imagePanel
|
|
3097
|
+
])
|
|
3098
|
+
});
|
|
3099
|
+
panels = [
|
|
3100
|
+
mainPanel,
|
|
3101
|
+
cropPanel,
|
|
3102
|
+
resizePanel,
|
|
3103
|
+
flipRotatePanel,
|
|
3104
|
+
filtersPanel,
|
|
3105
|
+
invertPanel,
|
|
3106
|
+
brightnessPanel,
|
|
3107
|
+
huePanel,
|
|
3108
|
+
saturatePanel,
|
|
3109
|
+
contrastPanel,
|
|
3110
|
+
grayscalePanel,
|
|
3111
|
+
sepiaPanel,
|
|
3112
|
+
colorizePanel,
|
|
3113
|
+
sharpenPanel,
|
|
3114
|
+
embossPanel,
|
|
3115
|
+
gammaPanel,
|
|
3116
|
+
exposurePanel
|
|
3117
|
+
];
|
|
3118
|
+
win = editor.windowManager.open({
|
|
3119
|
+
layout: 'flex',
|
|
3120
|
+
direction: 'column',
|
|
3121
|
+
align: 'stretch',
|
|
3122
|
+
minWidth: Math.min(global$5.DOM.getViewPort().w, 800),
|
|
3123
|
+
minHeight: Math.min(global$5.DOM.getViewPort().h, 650),
|
|
3124
|
+
title: 'Edit image',
|
|
3125
|
+
items: panels.concat([mainViewContainer]),
|
|
3126
|
+
buttons: reverseIfRtl([
|
|
3127
|
+
{
|
|
3128
|
+
text: 'Save',
|
|
3129
|
+
name: 'save',
|
|
3130
|
+
subtype: 'primary',
|
|
3131
|
+
onclick: save
|
|
3132
|
+
},
|
|
3133
|
+
{
|
|
3134
|
+
text: 'Cancel',
|
|
3135
|
+
onclick: 'close'
|
|
3136
|
+
}
|
|
3137
|
+
])
|
|
3138
|
+
});
|
|
3139
|
+
win.on('close', function () {
|
|
3140
|
+
reject();
|
|
3141
|
+
destroyStates(undoStack.data);
|
|
3142
|
+
undoStack = null;
|
|
3143
|
+
tempState = null;
|
|
3144
|
+
});
|
|
3145
|
+
undoStack.add(currentState);
|
|
3146
|
+
updateButtonUndoStates();
|
|
3147
|
+
imagePanel.on('load', function () {
|
|
3148
|
+
width = imagePanel.imageSize().w;
|
|
3149
|
+
height = imagePanel.imageSize().h;
|
|
3150
|
+
ratioW = height / width;
|
|
3151
|
+
ratioH = width / height;
|
|
3152
|
+
win.find('#w').value(width);
|
|
3153
|
+
win.find('#h').value(height);
|
|
3154
|
+
});
|
|
3155
|
+
imagePanel.on('crop', crop);
|
|
3156
|
+
}
|
|
3157
|
+
function edit(editor, imageResult) {
|
|
3158
|
+
return new global$3(function (resolve, reject) {
|
|
3159
|
+
return imageResult.toBlob().then(function (blob) {
|
|
3160
|
+
open(editor, createState(blob), resolve, reject);
|
|
3161
|
+
});
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3164
|
+
var $_5k00srehjm0ofyta = { edit: edit };
|
|
3165
|
+
|
|
3166
|
+
function getImageSize(img) {
|
|
3167
|
+
var width, height;
|
|
3168
|
+
function isPxValue(value) {
|
|
3169
|
+
return /^[0-9\.]+px$/.test(value);
|
|
3170
|
+
}
|
|
3171
|
+
width = img.style.width;
|
|
3172
|
+
height = img.style.height;
|
|
3173
|
+
if (width || height) {
|
|
3174
|
+
if (isPxValue(width) && isPxValue(height)) {
|
|
3175
|
+
return {
|
|
3176
|
+
w: parseInt(width, 10),
|
|
3177
|
+
h: parseInt(height, 10)
|
|
3178
|
+
};
|
|
3179
|
+
}
|
|
3180
|
+
return null;
|
|
3181
|
+
}
|
|
3182
|
+
width = img.width;
|
|
3183
|
+
height = img.height;
|
|
3184
|
+
if (width && height) {
|
|
3185
|
+
return {
|
|
3186
|
+
w: parseInt(width, 10),
|
|
3187
|
+
h: parseInt(height, 10)
|
|
3188
|
+
};
|
|
3189
|
+
}
|
|
3190
|
+
return null;
|
|
3191
|
+
}
|
|
3192
|
+
function setImageSize(img, size) {
|
|
3193
|
+
var width, height;
|
|
3194
|
+
if (size) {
|
|
3195
|
+
width = img.style.width;
|
|
3196
|
+
height = img.style.height;
|
|
3197
|
+
if (width || height) {
|
|
3198
|
+
img.style.width = size.w + 'px';
|
|
3199
|
+
img.style.height = size.h + 'px';
|
|
3200
|
+
img.removeAttribute('data-mce-style');
|
|
3201
|
+
}
|
|
3202
|
+
width = img.width;
|
|
3203
|
+
height = img.height;
|
|
3204
|
+
if (width || height) {
|
|
3205
|
+
img.setAttribute('width', size.w);
|
|
3206
|
+
img.setAttribute('height', size.h);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
function getNaturalImageSize(img) {
|
|
3211
|
+
return {
|
|
3212
|
+
w: img.naturalWidth,
|
|
3213
|
+
h: img.naturalHeight
|
|
3214
|
+
};
|
|
3215
|
+
}
|
|
3216
|
+
var $_dz9r4etjm0ofz09 = {
|
|
3217
|
+
getImageSize: getImageSize,
|
|
3218
|
+
setImageSize: setImageSize,
|
|
3219
|
+
getNaturalImageSize: getNaturalImageSize
|
|
3220
|
+
};
|
|
3221
|
+
|
|
3222
|
+
var typeOf = function (x) {
|
|
3223
|
+
if (x === null)
|
|
3224
|
+
return 'null';
|
|
3225
|
+
var t = typeof x;
|
|
3226
|
+
if (t === 'object' && Array.prototype.isPrototypeOf(x))
|
|
3227
|
+
return 'array';
|
|
3228
|
+
if (t === 'object' && String.prototype.isPrototypeOf(x))
|
|
3229
|
+
return 'string';
|
|
3230
|
+
return t;
|
|
3231
|
+
};
|
|
3232
|
+
var isType = function (type) {
|
|
3233
|
+
return function (value) {
|
|
3234
|
+
return typeOf(value) === type;
|
|
3235
|
+
};
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
|
|
3239
|
+
|
|
3240
|
+
|
|
3241
|
+
|
|
3242
|
+
|
|
3243
|
+
var isFunction = isType('function');
|
|
3244
|
+
|
|
3245
|
+
var find = function (xs, pred) {
|
|
3246
|
+
for (var i = 0, len = xs.length; i < len; i++) {
|
|
3247
|
+
var x = xs[i];
|
|
3248
|
+
if (pred(x, i, xs)) {
|
|
3249
|
+
return Option.some(x);
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
return Option.none();
|
|
3253
|
+
};
|
|
3254
|
+
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
3258
|
+
|
|
3259
|
+
var slice = Array.prototype.slice;
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
|
|
3267
|
+
var from$1 = isFunction(Array.from) ? Array.from : function (x) {
|
|
3268
|
+
return slice.call(x);
|
|
3269
|
+
};
|
|
3270
|
+
|
|
3271
|
+
function XMLHttpRequest$1 () {
|
|
3272
|
+
var f = $_ektrqldwjm0ofyrf.getOrDie('XMLHttpRequest');
|
|
3273
|
+
return new f();
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
var isValue = function (obj) {
|
|
3277
|
+
return obj !== null && obj !== undefined;
|
|
3278
|
+
};
|
|
3279
|
+
var traverse = function (json, path) {
|
|
3280
|
+
var value;
|
|
3281
|
+
value = path.reduce(function (result, key) {
|
|
3282
|
+
return isValue(result) ? result[key] : undefined;
|
|
3283
|
+
}, json);
|
|
3284
|
+
return isValue(value) ? value : null;
|
|
3285
|
+
};
|
|
3286
|
+
var requestUrlAsBlob = function (url, headers, withCredentials) {
|
|
3287
|
+
return new global$3(function (resolve) {
|
|
3288
|
+
var xhr;
|
|
3289
|
+
xhr = new XMLHttpRequest$1();
|
|
3290
|
+
xhr.onreadystatechange = function () {
|
|
3291
|
+
if (xhr.readyState === 4) {
|
|
3292
|
+
resolve({
|
|
3293
|
+
status: xhr.status,
|
|
3294
|
+
blob: this.response
|
|
3295
|
+
});
|
|
3296
|
+
}
|
|
3297
|
+
};
|
|
3298
|
+
xhr.open('GET', url, true);
|
|
3299
|
+
xhr.withCredentials = withCredentials;
|
|
3300
|
+
global$1.each(headers, function (value, key) {
|
|
3301
|
+
xhr.setRequestHeader(key, value);
|
|
3302
|
+
});
|
|
3303
|
+
xhr.responseType = 'blob';
|
|
3304
|
+
xhr.send();
|
|
3305
|
+
});
|
|
3306
|
+
};
|
|
3307
|
+
var readBlob = function (blob) {
|
|
3308
|
+
return new global$3(function (resolve) {
|
|
3309
|
+
var fr = new FileReader();
|
|
3310
|
+
fr.onload = function (e) {
|
|
3311
|
+
var data = e.target;
|
|
3312
|
+
resolve(data.result);
|
|
3313
|
+
};
|
|
3314
|
+
fr.readAsText(blob);
|
|
3315
|
+
});
|
|
3316
|
+
};
|
|
3317
|
+
var parseJson = function (text) {
|
|
3318
|
+
var json;
|
|
3319
|
+
try {
|
|
3320
|
+
json = JSON.parse(text);
|
|
3321
|
+
} catch (ex) {
|
|
3322
|
+
}
|
|
3323
|
+
return json;
|
|
3324
|
+
};
|
|
3325
|
+
var $_fqu6seyjm0ofz11 = {
|
|
3326
|
+
traverse: traverse,
|
|
3327
|
+
readBlob: readBlob,
|
|
3328
|
+
requestUrlAsBlob: requestUrlAsBlob,
|
|
3329
|
+
parseJson: parseJson
|
|
3330
|
+
};
|
|
3331
|
+
|
|
3332
|
+
var friendlyHttpErrors = [
|
|
3333
|
+
{
|
|
3334
|
+
code: 404,
|
|
3335
|
+
message: 'Could not find Image Proxy'
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
code: 403,
|
|
3339
|
+
message: 'Rejected request'
|
|
3340
|
+
},
|
|
3341
|
+
{
|
|
3342
|
+
code: 0,
|
|
3343
|
+
message: 'Incorrect Image Proxy URL'
|
|
3344
|
+
}
|
|
3345
|
+
];
|
|
3346
|
+
var friendlyServiceErrors = [
|
|
3347
|
+
{
|
|
3348
|
+
type: 'key_missing',
|
|
3349
|
+
message: 'The request did not include an api key.'
|
|
3350
|
+
},
|
|
3351
|
+
{
|
|
3352
|
+
type: 'key_not_found',
|
|
3353
|
+
message: 'The provided api key could not be found.'
|
|
3354
|
+
},
|
|
3355
|
+
{
|
|
3356
|
+
type: 'domain_not_trusted',
|
|
3357
|
+
message: 'The api key is not valid for the request origins.'
|
|
3358
|
+
}
|
|
3359
|
+
];
|
|
3360
|
+
var isServiceErrorCode = function (code) {
|
|
3361
|
+
return code === 400 || code === 403 || code === 500;
|
|
3362
|
+
};
|
|
3363
|
+
var getHttpErrorMsg = function (status) {
|
|
3364
|
+
var message = find(friendlyHttpErrors, function (error) {
|
|
3365
|
+
return status === error.code;
|
|
3366
|
+
}).fold(constant('Unknown ImageProxy error'), function (error) {
|
|
3367
|
+
return error.message;
|
|
3368
|
+
});
|
|
3369
|
+
return 'ImageProxy HTTP error: ' + message;
|
|
3370
|
+
};
|
|
3371
|
+
var handleHttpError = function (status) {
|
|
3372
|
+
var message = getHttpErrorMsg(status);
|
|
3373
|
+
return global$3.reject(message);
|
|
3374
|
+
};
|
|
3375
|
+
var getServiceErrorMsg = function (type) {
|
|
3376
|
+
return find(friendlyServiceErrors, function (error) {
|
|
3377
|
+
return error.type === type;
|
|
3378
|
+
}).fold(constant('Unknown service error'), function (error) {
|
|
3379
|
+
return error.message;
|
|
3380
|
+
});
|
|
3381
|
+
};
|
|
3382
|
+
var getServiceError = function (text) {
|
|
3383
|
+
var serviceError = $_fqu6seyjm0ofz11.parseJson(text);
|
|
3384
|
+
var errorType = $_fqu6seyjm0ofz11.traverse(serviceError, [
|
|
3385
|
+
'error',
|
|
3386
|
+
'type'
|
|
3387
|
+
]);
|
|
3388
|
+
var errorMsg = errorType ? getServiceErrorMsg(errorType) : 'Invalid JSON in service error message';
|
|
3389
|
+
return 'ImageProxy Service error: ' + errorMsg;
|
|
3390
|
+
};
|
|
3391
|
+
var handleServiceError = function (status, blob) {
|
|
3392
|
+
return $_fqu6seyjm0ofz11.readBlob(blob).then(function (text) {
|
|
3393
|
+
var serviceError = getServiceError(text);
|
|
3394
|
+
return global$3.reject(serviceError);
|
|
3395
|
+
});
|
|
3396
|
+
};
|
|
3397
|
+
var handleServiceErrorResponse = function (status, blob) {
|
|
3398
|
+
return isServiceErrorCode(status) ? handleServiceError(status, blob) : handleHttpError(status);
|
|
3399
|
+
};
|
|
3400
|
+
var $_6qym1vevjm0ofz0g = {
|
|
3401
|
+
handleServiceErrorResponse: handleServiceErrorResponse,
|
|
3402
|
+
handleHttpError: handleHttpError,
|
|
3403
|
+
getHttpErrorMsg: getHttpErrorMsg,
|
|
3404
|
+
getServiceErrorMsg: getServiceErrorMsg
|
|
3405
|
+
};
|
|
3406
|
+
|
|
3407
|
+
var appendApiKey = function (url, apiKey) {
|
|
3408
|
+
var separator = url.indexOf('?') === -1 ? '?' : '&';
|
|
3409
|
+
if (/[?&]apiKey=/.test(url) || !apiKey) {
|
|
3410
|
+
return url;
|
|
3411
|
+
} else {
|
|
3412
|
+
return url + separator + 'apiKey=' + encodeURIComponent(apiKey);
|
|
3413
|
+
}
|
|
3414
|
+
};
|
|
3415
|
+
var requestServiceBlob = function (url, apiKey) {
|
|
3416
|
+
var headers = {
|
|
3417
|
+
'Content-Type': 'application/json;charset=UTF-8',
|
|
3418
|
+
'tiny-api-key': apiKey
|
|
3419
|
+
};
|
|
3420
|
+
return $_fqu6seyjm0ofz11.requestUrlAsBlob(appendApiKey(url, apiKey), headers, false).then(function (result) {
|
|
3421
|
+
return result.status < 200 || result.status >= 300 ? $_6qym1vevjm0ofz0g.handleServiceErrorResponse(result.status, result.blob) : global$3.resolve(result.blob);
|
|
3422
|
+
});
|
|
3423
|
+
};
|
|
3424
|
+
function requestBlob(url, withCredentials) {
|
|
3425
|
+
return $_fqu6seyjm0ofz11.requestUrlAsBlob(url, {}, withCredentials).then(function (result) {
|
|
3426
|
+
return result.status < 200 || result.status >= 300 ? $_6qym1vevjm0ofz0g.handleHttpError(result.status) : global$3.resolve(result.blob);
|
|
3427
|
+
});
|
|
3428
|
+
}
|
|
3429
|
+
var getUrl = function (url, apiKey, withCredentials) {
|
|
3430
|
+
return apiKey ? requestServiceBlob(url, apiKey) : requestBlob(url, withCredentials);
|
|
3431
|
+
};
|
|
3432
|
+
var $_1fblseeujm0ofz0e = { getUrl: getUrl };
|
|
3433
|
+
|
|
3434
|
+
var count$1 = 0;
|
|
3435
|
+
var isEditableImage = function (editor, img) {
|
|
3436
|
+
var selectorMatched = editor.dom.is(img, 'img:not([data-mce-object],[data-mce-placeholder])');
|
|
3437
|
+
return selectorMatched && (isLocalImage(editor, img) || isCorsImage(editor, img) || editor.settings.imagetools_proxy);
|
|
3438
|
+
};
|
|
3439
|
+
var displayError = function (editor, error) {
|
|
3440
|
+
editor.notificationManager.open({
|
|
3441
|
+
text: error,
|
|
3442
|
+
type: 'error'
|
|
3443
|
+
});
|
|
3444
|
+
};
|
|
3445
|
+
var getSelectedImage = function (editor) {
|
|
3446
|
+
return editor.selection.getNode();
|
|
3447
|
+
};
|
|
3448
|
+
var extractFilename = function (editor, url) {
|
|
3449
|
+
var m = url.match(/\/([^\/\?]+)?\.(?:jpeg|jpg|png|gif)(?:\?|$)/i);
|
|
3450
|
+
if (m) {
|
|
3451
|
+
return editor.dom.encode(m[1]);
|
|
3452
|
+
}
|
|
3453
|
+
return null;
|
|
3454
|
+
};
|
|
3455
|
+
var createId = function () {
|
|
3456
|
+
return 'imagetools' + count$1++;
|
|
3457
|
+
};
|
|
3458
|
+
var isLocalImage = function (editor, img) {
|
|
3459
|
+
var url = img.src;
|
|
3460
|
+
return url.indexOf('data:') === 0 || url.indexOf('blob:') === 0 || new global$4(url).host === editor.documentBaseURI.host;
|
|
3461
|
+
};
|
|
3462
|
+
var isCorsImage = function (editor, img) {
|
|
3463
|
+
return global$1.inArray(getCorsHosts(editor), new global$4(img.src).host) !== -1;
|
|
3464
|
+
};
|
|
3465
|
+
var isCorsWithCredentialsImage = function (editor, img) {
|
|
3466
|
+
return global$1.inArray(getCredentialsHosts(editor), new global$4(img.src).host) !== -1;
|
|
3467
|
+
};
|
|
3468
|
+
var imageToBlob$2 = function (editor, img) {
|
|
3469
|
+
var src = img.src, apiKey;
|
|
3470
|
+
if (isCorsImage(editor, img)) {
|
|
3471
|
+
return $_1fblseeujm0ofz0e.getUrl(img.src, null, isCorsWithCredentialsImage(editor, img));
|
|
3472
|
+
}
|
|
3473
|
+
if (!isLocalImage(editor, img)) {
|
|
3474
|
+
src = getProxyUrl(editor);
|
|
3475
|
+
src += (src.indexOf('?') === -1 ? '?' : '&') + 'url=' + encodeURIComponent(img.src);
|
|
3476
|
+
apiKey = getApiKey(editor);
|
|
3477
|
+
return $_1fblseeujm0ofz0e.getUrl(src, apiKey, false);
|
|
3478
|
+
}
|
|
3479
|
+
return $_cjzpf9dojm0ofyqd.imageToBlob(img);
|
|
3480
|
+
};
|
|
3481
|
+
var findSelectedBlob = function (editor) {
|
|
3482
|
+
var blobInfo;
|
|
3483
|
+
blobInfo = editor.editorUpload.blobCache.getByUri(getSelectedImage(editor).src);
|
|
3484
|
+
if (blobInfo) {
|
|
3485
|
+
return global$3.resolve(blobInfo.blob());
|
|
3486
|
+
}
|
|
3487
|
+
return imageToBlob$2(editor, getSelectedImage(editor));
|
|
3488
|
+
};
|
|
3489
|
+
var startTimedUpload = function (editor, imageUploadTimerState) {
|
|
3490
|
+
var imageUploadTimer = global$2.setEditorTimeout(editor, function () {
|
|
3491
|
+
editor.editorUpload.uploadImagesAuto();
|
|
3492
|
+
}, getUploadTimeout(editor));
|
|
3493
|
+
imageUploadTimerState.set(imageUploadTimer);
|
|
3494
|
+
};
|
|
3495
|
+
var cancelTimedUpload = function (imageUploadTimerState) {
|
|
3496
|
+
clearTimeout(imageUploadTimerState.get());
|
|
3497
|
+
};
|
|
3498
|
+
var updateSelectedImage = function (editor, ir, uploadImmediately, imageUploadTimerState, size) {
|
|
3499
|
+
return ir.toBlob().then(function (blob) {
|
|
3500
|
+
var uri, name, blobCache, blobInfo, selectedImage;
|
|
3501
|
+
blobCache = editor.editorUpload.blobCache;
|
|
3502
|
+
selectedImage = getSelectedImage(editor);
|
|
3503
|
+
uri = selectedImage.src;
|
|
3504
|
+
if (shouldReuseFilename(editor)) {
|
|
3505
|
+
blobInfo = blobCache.getByUri(uri);
|
|
3506
|
+
if (blobInfo) {
|
|
3507
|
+
uri = blobInfo.uri();
|
|
3508
|
+
name = blobInfo.name();
|
|
3509
|
+
} else {
|
|
3510
|
+
name = extractFilename(editor, uri);
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
blobInfo = blobCache.create({
|
|
3514
|
+
id: createId(),
|
|
3515
|
+
blob: blob,
|
|
3516
|
+
base64: ir.toBase64(),
|
|
3517
|
+
uri: uri,
|
|
3518
|
+
name: name
|
|
3519
|
+
});
|
|
3520
|
+
blobCache.add(blobInfo);
|
|
3521
|
+
editor.undoManager.transact(function () {
|
|
3522
|
+
function imageLoadedHandler() {
|
|
3523
|
+
editor.$(selectedImage).off('load', imageLoadedHandler);
|
|
3524
|
+
editor.nodeChanged();
|
|
3525
|
+
if (uploadImmediately) {
|
|
3526
|
+
editor.editorUpload.uploadImagesAuto();
|
|
3527
|
+
} else {
|
|
3528
|
+
cancelTimedUpload(imageUploadTimerState);
|
|
3529
|
+
startTimedUpload(editor, imageUploadTimerState);
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
editor.$(selectedImage).on('load', imageLoadedHandler);
|
|
3533
|
+
if (size) {
|
|
3534
|
+
editor.$(selectedImage).attr({
|
|
3535
|
+
width: size.w,
|
|
3536
|
+
height: size.h
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
editor.$(selectedImage).attr({ src: blobInfo.blobUri() }).removeAttr('data-mce-src');
|
|
3540
|
+
});
|
|
3541
|
+
return blobInfo;
|
|
3542
|
+
});
|
|
3543
|
+
};
|
|
3544
|
+
var selectedImageOperation = function (editor, imageUploadTimerState, fn, size) {
|
|
3545
|
+
return function () {
|
|
3546
|
+
return editor._scanForImages().then(curry(findSelectedBlob, editor)).then($_b7i5rsebjm0ofyt2.blobToImageResult).then(fn).then(function (imageResult) {
|
|
3547
|
+
return updateSelectedImage(editor, imageResult, false, imageUploadTimerState, size);
|
|
3548
|
+
}, function (error) {
|
|
3549
|
+
displayError(editor, error);
|
|
3550
|
+
});
|
|
3551
|
+
};
|
|
3552
|
+
};
|
|
3553
|
+
var rotate$2 = function (editor, imageUploadTimerState, angle) {
|
|
3554
|
+
return function () {
|
|
3555
|
+
var size = $_dz9r4etjm0ofz09.getImageSize(getSelectedImage(editor));
|
|
3556
|
+
var flippedSize = size ? {
|
|
3557
|
+
w: size.h,
|
|
3558
|
+
h: size.w
|
|
3559
|
+
} : null;
|
|
3560
|
+
return selectedImageOperation(editor, imageUploadTimerState, function (imageResult) {
|
|
3561
|
+
return $_6vp8sye2jm0ofyrn.rotate(imageResult, angle);
|
|
3562
|
+
}, flippedSize)();
|
|
3563
|
+
};
|
|
3564
|
+
};
|
|
3565
|
+
var flip$2 = function (editor, imageUploadTimerState, axis) {
|
|
3566
|
+
return function () {
|
|
3567
|
+
return selectedImageOperation(editor, imageUploadTimerState, function (imageResult) {
|
|
3568
|
+
return $_6vp8sye2jm0ofyrn.flip(imageResult, axis);
|
|
3569
|
+
})();
|
|
3570
|
+
};
|
|
3571
|
+
};
|
|
3572
|
+
var editImageDialog = function (editor, imageUploadTimerState) {
|
|
3573
|
+
return function () {
|
|
3574
|
+
var img = getSelectedImage(editor), originalSize = $_dz9r4etjm0ofz09.getNaturalImageSize(img);
|
|
3575
|
+
var handleDialogBlob = function (blob) {
|
|
3576
|
+
return new global$3(function (resolve) {
|
|
3577
|
+
$_cjzpf9dojm0ofyqd.blobToImage(blob).then(function (newImage) {
|
|
3578
|
+
var newSize = $_dz9r4etjm0ofz09.getNaturalImageSize(newImage);
|
|
3579
|
+
if (originalSize.w !== newSize.w || originalSize.h !== newSize.h) {
|
|
3580
|
+
if ($_dz9r4etjm0ofz09.getImageSize(img)) {
|
|
3581
|
+
$_dz9r4etjm0ofz09.setImageSize(img, newSize);
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
$_finsnbecjm0ofyt4.revokeObjectURL(newImage.src);
|
|
3585
|
+
resolve(blob);
|
|
3586
|
+
});
|
|
3587
|
+
});
|
|
3588
|
+
};
|
|
3589
|
+
var openDialog = function (editor, imageResult) {
|
|
3590
|
+
return $_5k00srehjm0ofyta.edit(editor, imageResult).then(handleDialogBlob).then($_b7i5rsebjm0ofyt2.blobToImageResult).then(function (imageResult) {
|
|
3591
|
+
return updateSelectedImage(editor, imageResult, true, imageUploadTimerState);
|
|
3592
|
+
}, function () {
|
|
3593
|
+
});
|
|
3594
|
+
};
|
|
3595
|
+
findSelectedBlob(editor).then($_b7i5rsebjm0ofyt2.blobToImageResult).then(curry(openDialog, editor), function (error) {
|
|
3596
|
+
displayError(editor, error);
|
|
3597
|
+
});
|
|
3598
|
+
};
|
|
3599
|
+
};
|
|
3600
|
+
var $_9v70d1dnjm0ofypy = {
|
|
3601
|
+
rotate: rotate$2,
|
|
3602
|
+
flip: flip$2,
|
|
3603
|
+
editImageDialog: editImageDialog,
|
|
3604
|
+
isEditableImage: isEditableImage,
|
|
3605
|
+
cancelTimedUpload: cancelTimedUpload
|
|
3606
|
+
};
|
|
3607
|
+
|
|
3608
|
+
var register = function (editor, imageUploadTimerState) {
|
|
3609
|
+
global$1.each({
|
|
3610
|
+
mceImageRotateLeft: $_9v70d1dnjm0ofypy.rotate(editor, imageUploadTimerState, -90),
|
|
3611
|
+
mceImageRotateRight: $_9v70d1dnjm0ofypy.rotate(editor, imageUploadTimerState, 90),
|
|
3612
|
+
mceImageFlipVertical: $_9v70d1dnjm0ofypy.flip(editor, imageUploadTimerState, 'v'),
|
|
3613
|
+
mceImageFlipHorizontal: $_9v70d1dnjm0ofypy.flip(editor, imageUploadTimerState, 'h'),
|
|
3614
|
+
mceEditImage: $_9v70d1dnjm0ofypy.editImageDialog(editor, imageUploadTimerState)
|
|
3615
|
+
}, function (fn, cmd) {
|
|
3616
|
+
editor.addCommand(cmd, fn);
|
|
3617
|
+
});
|
|
3618
|
+
};
|
|
3619
|
+
var $_3kgkmfdljm0ofypv = { register: register };
|
|
3620
|
+
|
|
3621
|
+
var setup = function (editor, imageUploadTimerState, lastSelectedImageState) {
|
|
3622
|
+
editor.on('NodeChange', function (e) {
|
|
3623
|
+
var lastSelectedImage = lastSelectedImageState.get();
|
|
3624
|
+
if (lastSelectedImage && lastSelectedImage.src !== e.element.src) {
|
|
3625
|
+
$_9v70d1dnjm0ofypy.cancelTimedUpload(imageUploadTimerState);
|
|
3626
|
+
editor.editorUpload.uploadImagesAuto();
|
|
3627
|
+
lastSelectedImageState.set(null);
|
|
3628
|
+
}
|
|
3629
|
+
if ($_9v70d1dnjm0ofypy.isEditableImage(editor, e.element)) {
|
|
3630
|
+
lastSelectedImageState.set(e.element);
|
|
3631
|
+
}
|
|
3632
|
+
});
|
|
3633
|
+
};
|
|
3634
|
+
var $_ccmkoof0jm0ofz1a = { setup: setup };
|
|
3635
|
+
|
|
3636
|
+
var register$1 = function (editor) {
|
|
3637
|
+
editor.addButton('rotateleft', {
|
|
3638
|
+
title: 'Rotate counterclockwise',
|
|
3639
|
+
cmd: 'mceImageRotateLeft'
|
|
3640
|
+
});
|
|
3641
|
+
editor.addButton('rotateright', {
|
|
3642
|
+
title: 'Rotate clockwise',
|
|
3643
|
+
cmd: 'mceImageRotateRight'
|
|
3644
|
+
});
|
|
3645
|
+
editor.addButton('flipv', {
|
|
3646
|
+
title: 'Flip vertically',
|
|
3647
|
+
cmd: 'mceImageFlipVertical'
|
|
3648
|
+
});
|
|
3649
|
+
editor.addButton('fliph', {
|
|
3650
|
+
title: 'Flip horizontally',
|
|
3651
|
+
cmd: 'mceImageFlipHorizontal'
|
|
3652
|
+
});
|
|
3653
|
+
editor.addButton('editimage', {
|
|
3654
|
+
title: 'Edit image',
|
|
3655
|
+
cmd: 'mceEditImage'
|
|
3656
|
+
});
|
|
3657
|
+
editor.addButton('imageoptions', {
|
|
3658
|
+
title: 'Image options',
|
|
3659
|
+
icon: 'options',
|
|
3660
|
+
cmd: 'mceImage'
|
|
3661
|
+
});
|
|
3662
|
+
};
|
|
3663
|
+
var $_fq6uqyf1jm0ofz1b = { register: register$1 };
|
|
3664
|
+
|
|
3665
|
+
var register$2 = function (editor) {
|
|
3666
|
+
editor.addContextToolbar(curry($_9v70d1dnjm0ofypy.isEditableImage, editor), getToolbarItems(editor));
|
|
3667
|
+
};
|
|
3668
|
+
var $_6v2a13f2jm0ofz1d = { register: register$2 };
|
|
3669
|
+
|
|
3670
|
+
global.add('imagetools', function (editor) {
|
|
3671
|
+
var imageUploadTimerState = Cell(0);
|
|
3672
|
+
var lastSelectedImageState = Cell(null);
|
|
3673
|
+
$_3kgkmfdljm0ofypv.register(editor, imageUploadTimerState);
|
|
3674
|
+
$_fq6uqyf1jm0ofz1b.register(editor);
|
|
3675
|
+
$_6v2a13f2jm0ofz1d.register(editor);
|
|
3676
|
+
$_ccmkoof0jm0ofz1a.setup(editor, imageUploadTimerState, lastSelectedImageState);
|
|
3677
|
+
});
|
|
3678
|
+
function Plugin () {
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
return Plugin;
|
|
3682
|
+
|
|
3683
|
+
}());
|
|
3684
|
+
})();
|