├── .gitignore ├── .jshintrc ├── Gruntfile.js ├── LICENSE.md ├── README.md ├── angular-aviary.js ├── angular-aviary.min.js ├── angular-aviary.min.js.map ├── bower.json ├── karma.conf.js ├── lib └── aviary.js ├── package.json └── tests.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile ~/.gitignore_global 6 | 7 | # Ignore temporary files 8 | *.swp 9 | *.swo 10 | *.DS_Store 11 | .editorconfig 12 | .gitattributes 13 | .tmp 14 | 15 | # Ignore dependency libraries 16 | node_modules 17 | bower_components 18 | 19 | # Ignore logs 20 | *.log 21 | 22 | #IDE 23 | .idea 24 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "maxdepth": 2, 22 | "maxcomplexity": 10, 23 | "globals": { 24 | "angular": false 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | require('load-grunt-tasks')(grunt); 3 | 4 | grunt.initConfig({ 5 | pkg: grunt.file.readJSON('package.json'), 6 | uglify: { 7 | options: { 8 | banner: '/*\n\t<%= pkg.name %> v<%= pkg.version %>\n' + 9 | '\t(c) <%= grunt.template.today("yyyy") %> <%= pkg.author %> \n' + 10 | '\tLicense: <%= pkg.license %> \n*/\n' 11 | }, 12 | build: { 13 | options: { 14 | sourceMap: true 15 | }, 16 | files: { 17 | 'angular-aviary.min.js': ['angular-aviary.js'] 18 | } 19 | } 20 | }, 21 | karma: { 22 | unit: { 23 | configFile: 'karma.conf.js', 24 | singleRun: true 25 | } 26 | }, 27 | jshint: { 28 | src: ['angular-aviary.js', 'tests.js'] 29 | } 30 | }); 31 | 32 | grunt.registerTask('test', ['jshint','karma']); 33 | grunt.registerTask('default', ['jshint']); 34 | grunt.registerTask('build', ['uglify', 'jshint']); 35 | }; 36 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Massimiliano Sartoretto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular Aviary SDK 2 | 3 | An AngularJS directive for [the Creative SDK Image Editor UI component](https://creativesdk.adobe.com/docs/web/#/articles/gettingstarted/index.html). 4 | 5 | [Live Demo](https://eversnapteam.github.io/angular-aviary/) 6 | 7 | Copyright © 2016, [Massimiliano Sartoretto](mailto:massimilianosartoretto@gmail.com) 8 | 9 | Find me on: 10 | [![alt text][1.1]][1] 11 | [![alt text][2.1]][2] 12 | [![alt text][6.1]][6] 13 | 14 | [1.1]: http://i.imgur.com/tXSoThF.png (twitter icon with padding) 15 | [2.1]: http://i.imgur.com/P3YfQoD.png (facebook icon with padding) 16 | [6.1]: http://i.imgur.com/0o48UoR.png (github icon with padding) 17 | 18 | [1]: http://www.twitter.com/___Sarto 19 | [2]: http://www.facebook.com/profile.php?id=1549402605 20 | [6]: http://www.github.com/m00s 21 | 22 | Installation 23 | ------------ 24 | 25 | You can choose your preferred method of installation: 26 | * Through bower: `bower install angular-aviary --save` 27 | * Through npm: `npm install angular-aviary --save` 28 | * Download from github: [angular-aviary.min.js](https://github.com/m00s/angular-adobe-creative/blob/master/angular-aviary.min.js) 29 | 30 | Usage 31 | --------- 32 | 33 | ### Setup 34 | 35 | 1. Include the scripts: 36 | 37 | 1. the Creative SDK Image Editor script (`http` and `https` versions [available here](https://creativesdk.adobe.com/docs/web/#/articles/gettingstarted/index.html)) 38 | 1. `angular-aviary.min.js` 39 | 40 | Example: 41 | 42 | ```html 43 | 44 | 45 | ``` 46 | 47 | 1. Add the module `ngAviary` as a dependency to your app module: 48 | 49 | ```js 50 | var myApp = angular.module('myapp', ['ngAviary']); 51 | ``` 52 | 53 | ### Configuration 54 | 55 | To configure the Image Editor, call the `ngAviaryProvider.configure()` method (e.g. inside your app's `config()` callback): 56 | 57 | ```js 58 | myApp.config(function(ngAviaryProvider) { 59 | ngAviaryProvider.configure({ 60 | apiKey: 'my-awesome-api-key', 61 | theme: 'light', 62 | tools: 'all' 63 | }) 64 | }); 65 | ``` 66 | 67 | For the full list of config options, please refer to the [official docs](https://creativesdk.adobe.com/docs/web/#/articles/gettingstarted/index.html). 68 | 69 | ### ngAviary directive 70 | Use the `ngAviary` directive to create a toggle that triggers the Image Editor. 71 | 72 | Example: 73 | 74 | ```js 75 | Edit photo 81 | ``` 82 | 83 | You can use the HTML element you prefer as long as it supports the **onClick** event. (For a list of supported elements, refer to the [onClick docs](http://www.w3schools.com/jsref/event_onclick.asp)) 84 | 85 | Options that allow you to handle the Creative SDK Image Editor flow: 86 | 87 | |Attribute|Description|Required| 88 | |:-------|:---------|:---------:| 89 | |targetSelector|A string containing one or more CSS selector to query target image| :heavy_check_mark: 90 | |targetSrc|A string containing the url of the target image| :heavy_multiplication_x: 91 | |onSaveButtonClicked|Pass a function to be called before an image save happens, but after a user has clicked the save button, intending to save. | :heavy_multiplication_x: 92 | |onSave|Pass a function to be called when the image save is complete.| :heavy_multiplication_x: 93 | |onClose|Pass a function to be called when the editor is closed. `isDirty` parameter tells whether the editor was closed with unsaved changes.|:heavy_multiplication_x: 94 | |onError|The API can notify you of errors and you have the option to notify the user. They are otherwise silent.|:heavy_multiplication_x: 95 | -------------------------------------------------------------------------------- /angular-aviary.js: -------------------------------------------------------------------------------- 1 | /* 2 | angular-aviary v0.6.0 3 | (c) 2016 Massimiliano Sartoretto 4 | License: MIT 5 | */ 6 | 7 | 'format amd'; 8 | /* global define */ 9 | 10 | (function () { 11 | 'use strict'; 12 | 13 | function ngAviary(angular, Aviary) { 14 | 15 | ngAviaryDirective.$inject = ['ngAviary']; 16 | function ngAviaryDirective(ngAviary) { 17 | return { 18 | restrict: 'A', 19 | scope: { 20 | targetSelector: '@', 21 | targetSrc: '@', 22 | onSave: '&', 23 | onSaveButtonClicked: '&', 24 | onClose: '&' 25 | }, 26 | link: function (scope, element, attrs) { 27 | 28 | var targetImage = window.document.querySelector(scope.targetSelector); 29 | 30 | element.bind('click', function(e) { 31 | e.preventDefault(); 32 | return launchEditor(); 33 | }); 34 | 35 | // Callbacks obj 36 | var cbs = { 37 | onSaveButtonClicked: onSaveButtonClickedCb, 38 | onSave: onSaveCb, 39 | onError: onErrorCb, 40 | onClose: onCloseCb 41 | }; 42 | 43 | var featherEditor = new Aviary.Feather( 44 | angular.extend({}, ngAviary.configuration, cbs) 45 | ); 46 | 47 | function launchEditor() { 48 | featherEditor.launch({ 49 | image: targetImage, 50 | url: scope.targetSrc || targetImage.src 51 | }); 52 | return false; 53 | } 54 | 55 | function onSaveButtonClickedCb(imageID) { 56 | // User onSaveButtonClicked callback 57 | (scope.onSaveButtonClicked || angular.noop)({id: imageID}); 58 | } 59 | 60 | function onSaveCb(imageID, newURL) { 61 | // User onSave callback 62 | (scope.onSave || angular.noop)({ 63 | id: imageID, 64 | newURL: newURL 65 | }); 66 | 67 | if(scope.closeOnSave || ngAviary.configuration.closeOnSave){ 68 | featherEditor.close(); 69 | } 70 | } 71 | 72 | function onErrorCb(errorObj) { 73 | // User errback 74 | (scope.onError || angular.noop)({ 75 | error: errorObj 76 | }); 77 | } 78 | 79 | function onCloseCb(isDirty) { 80 | // User onClose callback 81 | (scope.onClose || angular.noop)({ 82 | isDirty: isDirty 83 | }); 84 | } 85 | } 86 | }; 87 | } 88 | 89 | function ngAviaryProvider(){ 90 | /* jshint validthis:true */ 91 | 92 | var defaults = { 93 | apiKey: null 94 | }; 95 | 96 | var requiredKeys = [ 97 | 'apiKey' 98 | ]; 99 | 100 | var config; 101 | 102 | this.configure = function(params) { 103 | // Can only be configured once 104 | if (config) { 105 | throw new Error('Already configured.'); 106 | } 107 | 108 | // Check if it is an `object` 109 | if (!(params instanceof Object)) { 110 | throw new TypeError('Invalid argument: `config` must be an `Object`.'); 111 | } 112 | 113 | // Extend default configuration 114 | config = angular.extend({}, defaults, params); 115 | 116 | // Check if all required keys are set 117 | angular.forEach(requiredKeys, function(key) { 118 | if (!config[key]) { 119 | throw new Error('Missing parameter:', key); 120 | } 121 | }); 122 | 123 | return config; 124 | }; 125 | 126 | this.$get = function() { 127 | if(!config) { 128 | throw new Error('ngAviary must be configured first.'); 129 | } 130 | 131 | var getConfig = (function() { 132 | return config; 133 | })(); 134 | 135 | return { 136 | configuration: getConfig 137 | }; 138 | }; 139 | } 140 | 141 | return angular 142 | .module('ngAviary', []) 143 | .directive('ngAviary', ngAviaryDirective) 144 | .provider('ngAviary', ngAviaryProvider); 145 | } 146 | 147 | if (typeof define === 'function' && define.amd) { 148 | define(['angular', 'Aviary'], ngAviary); 149 | } else if (typeof module !== 'undefined' && module && module.exports) { 150 | ngAviary(angular, require('Aviary')); 151 | module.exports = 'ngAviary'; 152 | } else { 153 | ngAviary(angular, (typeof global !== 'undefined' ? global : window).Aviary); 154 | } 155 | })(); 156 | -------------------------------------------------------------------------------- /angular-aviary.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | angular-aviary v0.6.0 3 | (c) 2016 Massimiliano Sartoretto 4 | License: MIT 5 | */ 6 | 7 | "format amd";!function(){"use strict";function a(a,b){function c(c){return{restrict:"A",scope:{targetSelector:"@",targetSrc:"@",onSave:"&",onSaveButtonClicked:"&",onClose:"&"},link:function(d,e){function f(){return m.launch({image:k,url:d.targetSrc||k.src}),!1}function g(b){(d.onSaveButtonClicked||a.noop)({id:b})}function h(b,e){(d.onSave||a.noop)({id:b,newURL:e}),(d.closeOnSave||c.configuration.closeOnSave)&&m.close()}function i(b){(d.onError||a.noop)({error:b})}function j(b){(d.onClose||a.noop)({isDirty:b})}var k=window.document.querySelector(d.targetSelector);e.bind("click",function(a){return a.preventDefault(),f()});var l={onSaveButtonClicked:g,onSave:h,onError:i,onClose:j},m=new b.Feather(a.extend({},c.configuration,l))}}}function d(){var b,c={apiKey:null},d=["apiKey"];this.configure=function(e){if(b)throw new Error("Already configured.");if(!(e instanceof Object))throw new TypeError("Invalid argument: `config` must be an `Object`.");return b=a.extend({},c,e),a.forEach(d,function(a){if(!b[a])throw new Error("Missing parameter:",a)}),b},this.$get=function(){if(!b)throw new Error("ngAviary must be configured first.");var a=function(){return b}();return{configuration:a}}}return c.$inject=["ngAviary"],a.module("ngAviary",[]).directive("ngAviary",c).provider("ngAviary",d)}"function"==typeof define&&define.amd?define(["angular","Aviary"],a):"undefined"!=typeof module&&module&&module.exports?(a(angular,require("Aviary")),module.exports="ngAviary"):a(angular,("undefined"!=typeof global?global:window).Aviary)}(); 8 | //# sourceMappingURL=angular-aviary.min.js.map -------------------------------------------------------------------------------- /angular-aviary.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"angular-aviary.min.js","sources":["angular-aviary.js"],"names":["ngAviary","angular","Aviary","ngAviaryDirective","restrict","scope","targetSelector","targetSrc","onSave","onSaveButtonClicked","onClose","link","element","launchEditor","featherEditor","launch","image","targetImage","url","src","onSaveButtonClickedCb","imageID","noop","id","onSaveCb","newURL","closeOnSave","configuration","close","onErrorCb","errorObj","onError","error","onCloseCb","isDirty","window","document","querySelector","bind","e","preventDefault","cbs","Feather","extend","ngAviaryProvider","config","defaults","apiKey","requiredKeys","this","configure","params","Error","Object","TypeError","forEach","key","$get","getConfig","$inject","module","directive","provider","define","amd","exports","require","global"],"mappings":";;;;;;AAMA,cAGA,WACE,YAEA,SAASA,GAASC,EAASC,GAGzB,QAASC,GAAkBH,GACzB,OACEI,SAAU,IACVC,OACEC,eAAgB,IAChBC,UAAW,IACXC,OAAQ,IACRC,oBAAqB,IACrBC,QAAU,KAEZC,KAAM,SAAUN,EAAOO,GAqBrB,QAASC,KAKP,MAJAC,GAAcC,QACZC,MAAOC,EACPC,IAAKb,EAAME,WAAaU,EAAYE,OAE/B,EAGT,QAASC,GAAsBC,IAE5BhB,EAAMI,qBAAuBR,EAAQqB,OAAOC,GAAIF,IAGnD,QAASG,GAASH,EAASI,IAExBpB,EAAMG,QAAUP,EAAQqB,OACvBC,GAAIF,EACJI,OAAQA,KAGPpB,EAAMqB,aAAe1B,EAAS2B,cAAcD,cAC7CZ,EAAcc,QAIlB,QAASC,GAAUC,IAEhBzB,EAAM0B,SAAW9B,EAAQqB,OACxBU,MAAOF,IAIX,QAASG,GAAUC,IAEhB7B,EAAMK,SAAWT,EAAQqB,OACxBY,QAASA,IAtDb,GAAIjB,GAAckB,OAAOC,SAASC,cAAchC,EAAMC,eAEtDM,GAAQ0B,KAAK,QAAS,SAASC,GAE7B,MADAA,GAAEC,iBACK3B,KAIT,IAAI4B,IACFhC,oBAAqBW,EACrBZ,OAAQgB,EACRO,QAASF,EACTnB,QAASuB,GAGPnB,EAAgB,GAAIZ,GAAOwC,QAC7BzC,EAAQ0C,UAAW3C,EAAS2B,cAAec,MA6CnD,QAASG,KAGP,GAQIC,GARAC,GACFC,OAAQ,MAGNC,GACF,SAKFC,MAAKC,UAAY,SAASC,GAExB,GAAIN,EACF,KAAM,IAAIO,OAAM,sBAIlB,MAAMD,YAAkBE,SACtB,KAAM,IAAIC,WAAU,kDAatB,OATAT,GAAS5C,EAAQ0C,UAAWG,EAAUK,GAGtClD,EAAQsD,QAAQP,EAAc,SAASQ,GACrC,IAAKX,EAAOW,GACV,KAAM,IAAIJ,OAAM,qBAAsBI,KAInCX,GAGTI,KAAKQ,KAAO,WACV,IAAIZ,EACF,KAAM,IAAIO,OAAM,qCAGlB,IAAIM,GAAY,WACd,MAAOb,KAGT,QACElB,cAAe+B,IAKrB,MA9HAvD,GAAkBwD,SAAW,YA8HtB1D,EACJ2D,OAAO,eACPC,UAAU,WAAY1D,GACtB2D,SAAS,WAAYlB,GAGJ,kBAAXmB,SAAyBA,OAAOC,IAC3CD,QAAQ,UAAW,UAAW/D,GACF,mBAAX4D,SAA0BA,QAAUA,OAAOK,SAC5DjE,EAASC,QAASiE,QAAQ,WAC1BN,OAAOK,QAAU,YAEjBjE,EAASC,SAA4B,mBAAXkE,QAAyBA,OAAShC,QAAQjC"} -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-aviary", 3 | "version": "0.6.0", 4 | "authors": [ 5 | "Massimiliano Sartoretto " 6 | ], 7 | "description": "An angular wrapper for Aviary SDK (Adobe Creative SDK)", 8 | "main": "angular-aviary.min.js", 9 | "dependencies": { 10 | "angular": ">=1.3.0" 11 | }, 12 | "devDependencies": { 13 | "angular-mocks": "1.3.x" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git@github.com:m00s/angular-aviary.git" 18 | }, 19 | "moduleType": [ 20 | "amd", 21 | "es6", 22 | "globals", 23 | "node" 24 | ], 25 | "keywords": [ 26 | "angular", 27 | "image", 28 | "adobe", 29 | "creative" 30 | ], 31 | "license": "MIT", 32 | "ignore": [ 33 | "**/.*", 34 | "node_modules", 35 | "bower_components", 36 | "tests.js" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | /* 2 | (c) 2015 Massimiliano Sartoretto 3 | License: MIT 4 | */ 5 | 6 | 'use strict'; 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | basePath: '', 11 | frameworks: ['jasmine'], 12 | logLevel: config.LOG_INFO, 13 | browsers: ['PhantomJS'], 14 | autoWatch: true, 15 | files: [ 16 | 'bower_components/angular/angular.js', 17 | 'bower_components/angular-mocks/angular-mocks.js', 18 | 'lib/aviary.js', 19 | 'angular-aviary.js', 20 | 'tests.js' 21 | ] 22 | }); 23 | }; 24 | -------------------------------------------------------------------------------- /lib/aviary.js: -------------------------------------------------------------------------------- 1 | !function(AV,window,document){AV.build={contentShouldUseStaging:!1,version:"4.2.1",bundled:!1,feather_baseURL:"http://feather.aviary.com/csdk/4.2.1.19/",feather_baseURL_SSL:"https://dme0ih8comzn4.cloudfront.net/csdk/4.2.1.19/",feather_stickerURL:"http://feather.aviary.com/stickers/",feather_stickerURL_SSL:"https://dme0ih8comzn4.cloudfront.net/stickers/",imgrecvBase:"http://featherservices.aviary.com/",imgrecvBase_SSL:"https://featherservices.aviary.com/",featherTargetAnnounce:"http://featherservices.aviary.com/feather_target_announce_v3.html",featherTargetAnnounce_SSL:"https://featherservices.aviary.com/feather_target_announce_v3.html",imgrecvServer:"http://featherservices.aviary.com/FeatherReceiver.aspx",imgrecvServer_SSL:"https://featherservices.aviary.com/FeatherReceiver.aspx",jsonp_imgserver:"http://featherservices.aviary.com/imgjsonpserver.aspx",jsonp_imgserver_SSL:"https://featherservices.aviary.com/imgjsonpserver.aspx",proxyServer:"http://featherservices.aviary.com/proxy.aspx",proxyServer_SSL:"https://featherservices.aviary.com/proxy.aspx",asyncImgrecvBase:"http://cc-api-aviary-cds.adobe.io/",asyncImgrecvBase_SSL:"https://cc-api-aviary-cds.adobe.io/",manifestURL:"http://cd.aviary.com",manifestURL_SSL:"https://d42hh4005hpu.cloudfront.net",gatewayAssetURL:"http://cc-api-aviary-cds.adobe.io",gatewayAssetURL_SSL:"https://cc-api-aviary-cds.adobe.io",cdsContentURL:"http://cd.aviary.com",cdsContentURL_SSL:"https://d42hh4005hpu.cloudfront.net",asyncFeatherTargetAnnounce:"http://cc-api-aviary-cds.adobe.io/feather_target_announce_v3.html",asyncFeatherTargetAnnounce_SSL:"https://cc-api-aviary-cds.adobe.io/feather_target_announce_v3.html",asyncImgrecvCreateJob:"http://cc-api-aviary-cds.adobe.io/v2/createjob",asyncImgrecvCreateJob_SSL:"https://cc-api-aviary-cds.adobe.io/v2/createjob",asyncImgrecvGetJobStatus:"http://cc-api-aviary-cds.adobe.io/v2/getjobstatus",asyncImgrecvGetJobStatus_SSL:"https://cc-api-aviary-cds.adobe.io/v2/getjobstatus",googleTracker:"UA-84575-22",inAppPurchaseFrameURL:"http://purchases.viary.com/gateway.aspx?p=flickr"};var eventSplitter=/\s+/,Events=AV.Events={on:function(e,t,n){var a,o,i;if(!t)return this;for(e=e.split(eventSplitter),a=this._callbacks||(this._callbacks={});o=e.shift();)i=a[o]||(a[o]=[]),i.push(t,n);return this},off:function(e,t,n){var a,o,i,r;if(!(o=this._callbacks))return this;if(!(e||t||n))return delete this._callbacks,this;for(e=e?e.split(eventSplitter):_.keys(o);a=e.shift();)if((i=o[a])&&(t||n))for(r=i.length-2;r>=0;r-=2)t&&i[r]!==t||n&&i[r+1]!==n||i.splice(r,2);else delete o[a];return this},trigger:function(e){var t,n,a,o,i,r,s,l;if(!(n=this._callbacks))return this;for(l=[],e=e.split(eventSplitter),o=1,i=arguments.length;i>o;o++)l[o-1]=arguments[o];for(;t=e.shift();){if((s=n.all)&&(s=s.slice()),(a=n[t])&&(a=a.slice()),a)for(o=0,i=a.length;i>o;o+=2)a[o].apply(a[o+1]||this,l);if(s)for(r=[t].concat(l),o=0,i=s.length;i>o;o+=2)s[o].apply(s[o+1]||this,r)}return this}};"undefined"==typeof AV&&(AV={}),AV.JSON={},function(){"use strict";function f(e){return 10>e?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,a,o,i,r,s=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),"function"==typeof rep&&(l=rep.call(t,e,l)),typeof l){case"string":return quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,r=[],"[object Array]"===Object.prototype.toString.apply(l)){for(i=l.length,n=0;i>n;n+=1)r[n]=str(n,l)||"null";return o=0===r.length?"[]":gap?"[\n"+gap+r.join(",\n"+gap)+"\n"+s+"]":"["+r.join(",")+"]",gap=s,o}if(rep&&"object"==typeof rep)for(i=rep.length,n=0;i>n;n+=1)a=rep[n],"string"==typeof a&&(o=str(a,l),o&&r.push(quote(a)+(gap?": ":":")+o));else for(a in l)Object.hasOwnProperty.call(l,a)&&(o=str(a,l),o&&r.push(quote(a)+(gap?": ":":")+o));return o=0===r.length?"{}":gap?"{\n"+gap+r.join(",\n"+gap)+"\n"+s+"}":"{"+r.join(",")+"}",gap=s,o}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof AV.JSON.stringify&&(AV.JSON.stringify=function(e,t,n){var a;if(gap="",indent="","number"==typeof n)for(a=0;n>a;a+=1)indent+=" ";else"string"==typeof n&&(indent=n);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("AV.JSON.stringify");return str("",{"":e})}),"function"!=typeof AV.JSON.parse&&(AV.JSON.parse=function(text,reviver){function walk(e,t){var n,a,o=e[t];if(o&&"object"==typeof o)for(n in o)Object.hasOwnProperty.call(o,n)&&(a=walk(o,n),void 0!==a?o[n]=a:delete o[n]);return reviver.call(e,t,o)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("AV.JSON.parse")})}(),"undefined"==typeof AV&&(AV={}),AV.validLanguages={en:!0,android:!0,bg:!0,ca:!0,zh_hans:!0,zh_hant:!0,cs:!0,da:!0,nl:!0,fi:!0,fr:!0,de:!0,he:!0,id:!0,it:!0,ja:!0,ko:!0,lv:!0,lt:!0,pl:!0,pt:!0,pt_br:!0,ru:!0,es:!0,sv:!0,tr:!0,vi:!0,el:!0,hu:!0,no:!0,sk:!0,uk:!0},AV.util={getX:function(e){for(var t=0;null!=e;)t+=e.offsetLeft,e=e.offsetParent;return t},getY:function(e){for(var t=0;null!=e;)t+=e.offsetTop,e=e.offsetParent;return t},getTouch:function(e){var t;return e.originalEvent&&(e=e.originalEvent),t=e.changedTouches&&1==e.changedTouches.length?e.changedTouches[0]:e.touches&&1==e.touches.length?e.touches[0]:!1},getScaledDims:function(e,t,n,a){a=a||n;var o=e,i=t,r=e/t;return(e>n||t>a)&&(e-n>r*(t-a)?(o=n,i=n*t/e+.5|0):(o=a*r+.5|0,i=a)),{width:o,height:i}},nextFrame:function(e){setTimeout(e,1)},getDomain:function(e,t){var n,a,o,i,r,s,l;return n="http://"==e.substr(0,7)?7:"https://"==e.substr(0,8)?8:"ftp://"==e.substr(0,6)?6:0,o=e.indexOf("/",n),-1==o&&(o=e.length),t?a=n:(s=e,l=e.lastIndexOf(":"),s=l>n?e.substring(n,l):e.substring(n,o),s.match(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/)?a=n:(i=e.lastIndexOf(".",o),r=e.lastIndexOf(".",i-1),a=-1==r?n:r+1)),e.substring(a,o)},extend:function(){var e,t,n,a,o,i,r=arguments[0]||{},s=1,l=arguments.length,c=!1;for("boolean"==typeof r&&(c=r,r=arguments[1]||{},s=2),"object"==typeof r||jQuery.isFunction(r)||(r={}),l===s&&(r=this,--s);l>s;s++)if(null!=(e=arguments[s]))for(t in e)n=r[t],a=e[t],r!==a&&(c&&a&&(jQuery.isPlainObject(a)||(o=jQuery.isArray(a)))?(o?(o=!1,i=n&&jQuery.isArray(n)?n:[]):i=n&&jQuery.isPlainObject(n)?n:{},r[t]=jQuery.extend(c,i,a)):void 0!==a&&(r[t]=a));return r},findItemByKeyValueFromArray:function(e,t,n){{var a,o;n.length}for(a=0;a127.5},color_expand:function(e){var t,n,a;return 4==e.length&&(t=e.charAt(1),n=e.charAt(2),a=e.charAt(3),e="#"+t+t+n+n+a+a),e},color_to_array:function(e){var t,n,a;return"#"==e.charAt(0)?(e=AV.util.color_expand(e),t=parseInt(e.substr(1,2),16),n=parseInt(e.substr(3,2),16),a=parseInt(e.substr(5,2),16)):"r"==e.charAt(0).toLowerCase()&&(e=AV.util.rgb_to_color(e),t=parseInt(e.substr(1,2),16),n=parseInt(e.substr(3,2),16),a=parseInt(e.substr(5,2),16)),e=[t,n,a,1]},array_to_color:function(e){var t=AV.util.array_to_rgb(e);return t=AV.util.rgb_to_color(t)},array_to_rgb:function(e){var t="rgb(0,0,0)";return e.join&&(e.length>3&&(e=e.slice(0,3)),t="rgb("+e.join(",")+")"),t},color_to_rgb:function(e){return e=AV.util.color_to_array(e),e=AV.util.array_to_rgb(e)},rgb_to_color:function(e){var t,n,a,o=/\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/,i=e.match(o);return i?(t=parseInt(i[1]).toString(16),1==t.length&&(t="0"+t),n=parseInt(i[2]).toString(16),1==n.length&&(n="0"+n),a=parseInt(i[3]).toString(16),1==a.length&&(a="0"+a),"#"+t+n+a):e},color_to_int:function(e){return e=AV.util.color_expand(e),e=AV.util.rgb_to_color(e),parseInt(e.substr(1),16)},getSafeAssetBaseURL:function(e){return e=e.replace("http://cd-test.aviary.com:1338",AV.build.cdsContentURL),"https:"==window.location.protocol&&(e=AV.build.contentShouldUseStaging?e.replace("http://testassets.aviary.com.s3.amazonaws.com","https://s3.amazonaws.com/testassets.aviary.com"):e.replace("http://assets.aviary.com","https://d2q6aqs27yssdp.cloudfront.net")),e},loadImagesSync:function(e,t,n){var a=0,o=e.length,i=function(){t&&a==e.length&&AV.util.nextFrame(t)},r=avpw$.support.cors&&!("Microsoft Internet Explorer"==navigator.appName)||n;-1!==navigator.userAgent.indexOf("Safari")&&-1===navigator.userAgent.indexOf("Chrome")&&(r=!1);for(var s=0;o>s;s++)!function(t){var n=e[t].img,o=e[t].src;n.onload=function(){e[t].mappingObject&&(e[t].mappingObject.w=n.width,e[t].mappingObject.h=n.height),a++,i()},r?(n.crossOrigin="Anonymous",n.src=o):avpw$.ajax({type:"GET",dataType:"json",url:AV.build.jsonp_imgserver+"?callback=?",data:{url:escape(o)},success:function(e){n.src=e.data}})}(s)},getApiVersion:function(e){return e&&e.apiVersion?parseInt(e.apiVersion,10):1},getUserFriendlyToolName:function(e){var t={overlay:"Stickers",drawing:"Draw",textwithfont:"Text",colorsplash:"Splash",tiltshift:"Tilt Shift",forcecrop:"Crop"},n="";return e&&(n=t[e]||e.substr(0,1).toUpperCase()+e.substr(1)),n},keyDownHandlerNumber:function(e,t){9==e.keyCode||27==e.keyCode||65==e.keyCode&&(e.ctrlKey===!0||e.metaKey===!0)||e.keyCode>=35&&e.keyCode<=39||((e.keyCode<48||e.keyCode>57)&&(e.keyCode<96||e.keyCode>105)&&46!==e.keyCode&&8!==e.keyCode?e.preventDefault():t&&t.apply(this,[e]))},getBrowserVersion:function(){var e,t=navigator.userAgent,n=t.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?(e=/\brv[ :]+(\d+)/g.exec(t)||[],"IE "+(e[1]||"")):"Chrome"===n[1]&&(e=t.match(/\bOPR\/(\d+)/),null!=e)?"Opera "+e[1]:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(e=t.match(/version\/(\d+)/i))&&n.splice(1,1,e[1]),n[1])},generatePointList:function(e,t){var n,a=function(e,t,n,o,i,r,s,l){var c=(o-t)*(o-t)+(i-n)*(i-n);if(l*l>c)return null;var u,d,p,h,g,f;void 0!==r?(u=(r+t)/2,d=(r+o)/2,p=(s+n)/2,h=(s+i)/2,g=(u+d)/2,f=(p+h)/2):(g=(t+o)/2,f=(n+i)/2),a(e,t,n,g,f,u,p,l),e.push([0|g,0|f]),a(e,g,f,o,i,d,h,l)},o=Math.floor(.2*t),i=0,r=[];for(i=0;in;n++)if(i[n]===t){r=!0;break}return"forcecrop"===t&&a.launchData.forceCropPreset?!0:(r||a.errorNotify("UNSUPPORTED_TOOL",[t]),r)},s=function(t,n,a){return e.objectNotify("tool",t,n,a)},l=function(e){null!=e&&(avpw$(".avpw_controlpanel").each(function(){avpw$(this).hide()}),avpw$("#avpw_controlpanel_"+e).show())},c=function(){var n,r=function(r){s(i,"panelWillClose"),s(r,"panelWillOpen"),o.trigger("canvas:activate",e.panelMode2WidgetMode(r)),l(r),s(r,"resetUI"),t.setTimeout(function(e){return function(){s(e,"panelDidClose"),i=r,s(r,"panelDidOpen"),n=!1}}(i),200),i=r,e.layoutNotify(a.launchData.openType,"disableZoomMode")};return function(e){n||(n=!0,r(e))}}(),u=function(t){if(!e.paintWidget||!e.paintWidget.busy){if(e.layoutNotify(a.launchData.openType,"showView",["editpanel"]),c(t),a.controlsWidgetInstance.onEggWaitThrobber.stop(),"mobile"==a.launchData.openType){var o,i=n.getElementById("avpw_main_"+t);i&&(o=i.getAttribute("data-header"),o&&(n.getElementById("avpw_control_toolname").innerHTML=o))}a.usageTracker.addUsage(t)}},d=function(){o.on("tool:open",g),o.on("tool:close",h),o.on("tool:init",f),o.on("tool:shutdown",y),o.on("tool:commit",v),o.on("tool:cancel",m),o.on("tool:undo",S),o.on("tool:redo",W)},p=function(){o.off("tool:open",g),o.off("tool:close",h),o.off("tool:init",f),o.off("tool:shutdown",y),o.off("tool:commit",v),o.off("tool:cancel",m),o.off("tool:undo",S),o.off("tool:redo",W)},h=function(){e.layoutNotify(a.launchData.openType,"showView",["main"]),c(null)},g=function(t,n){t=a.publicName2PanelMode(t),(r(t)||a.launchData.forceCropPreset)&&e.paintWidget&&!e.paintWidget.moduleLoaded(t,u)&&n&&(e.onEggWaitThrobber.stop(),e.onEggWaitThrobber.spin(avpw$(n).children(".avpw_icon_waiter")[0])),o.trigger("usage:tool",t,"opened"),o.trigger("usage:firstclick",t)},f=function(t){s(t,"init",[e])},v=function(){var e,t=i;t&&(e=s(i,"commit"),e!==!1&&(o.trigger("usage:tool",t,"applied",e!==!0?e:""),o.trigger("tool:commitDone")))},m=function(){s(i,"cancel"),o.trigger("usage:tool",i,"canceled"),a.featherGLEnabled&&(e.paintWidget.moaGL.createEffect(),e.paintWidget.moaGL.renderIdentity(),e.paintWidget.moaGL.finalizeEffect(),e.paintWidget.moaGL.commit())},y=function(e){s(e,"shutdown")},w=function(){return e.paintWidget.busy?!1:s(i,"onUndo")===!1?!1:(e.paintWidget.actions.undo(),s(i,"onUndoComplete"),!1)},b=function(){return e.paintWidget.busy?!1:s(i,"onUndo",[{global:!0}])===!1?!1:(e.paintWidget.actions.undoToCheckpoint(),s(i,"onUndoComplete",[{global:!0}]),!1)},_=function(){return e.paintWidget.busy?!1:s(i,"onRedo")===!1?!1:(e.paintWidget.actions.redo(),s(i,"onRedoComplete"),!1)},I=function(){if(e.paintWidget.busy)return!1;if(s(i,"onRedo",[{global:!0}])===!1)return!1;var t=e.paintWidget.actions.redoToCheckpoint();return t&&s(i,"onRedoComplete",[{global:!0}]),t},S=function(){o.trigger("usage:tool","undo","applied",i||""),e.paintWidget.actions.isACheckpoint()?b():w()},W=function(){o.trigger("usage:tool","redo","applied",i||""),I()||_()},A=this;return A.init=d,A.shutdown=p,A.notify=s,A.getActiveTool=function(){return i},d(),A},e}(this,"undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{}),AV.AssetManager=function(e,t){"use strict";var n,a={EFFECT:"effects",STICKER:"stickers",IMAGEBORDER:"frames",OVERLAYS:"overlays",PERMISSION:"permissions",FONTPACK:"fontpack"},o={},i=function(e){return n[a[e]]||[]},r=function(e,t){n?t&&t.apply(this,[i(e),a[e]]):(o.getPartnerAssets||(o.getPartnerAssets=[],u.authenticate()),o.getPartnerAssets.push(function(o){o&&o.status&&"Ok"===o.status?n=o:(AV.errorNotify("ERROR_AUTHENTICATING"),s()),AV.util.nextFrame(function(){n&&t&&t.apply(this,[i(e),a[e]])})}))},s=function(e,t){return n=[{needsPurchase:!1,assetId:"default_effects",assetType:"effect",displayName:"Default",resourceUrl:"js/proclist_default_effects.js"},{needsPurchase:!1,assetId:"original_effects",assetType:"effect",displayName:"Original",resourceUrl:"js/proclist_original_effects.js"},{needsPurchase:!1,assetId:"original_stickers",assetType:"sticker",displayName:"Original",resourceUrl:"js/stickers_original_stickers.js"},{needsPurchase:!1,assetId:"borders",assetType:"imageborder",displayName:"Default Image Borders",resourceUrl:"js/borders_original.js"}],t&&AV.util.nextFrame(function(){t.apply(this,[i(e)])}),!0},l=function(e){var t,n,a;if(e.messageName&&(a=o[e.messageName])){if("function"==typeof a)a.apply(this,[e.data]);else for(n=a.length,t=0;n>t;t++)a[t].apply(this,[e.data]);a=null}},c=e?r:s,u=this;return u.getAssets=c,u.getById=function(e){for(var t=0;t1?"high":"low","&sdkVersion="+AV.build.version,n?"&staging=2":"",t?t:""].join("")},u.getContentURLByVersionKey=function(e){var t=AV.build.contentShouldUseStaging;return AV.build.cdsContentURL+"/v1/content?versionKey="+e+(t?"&staging=2":"")},u.authenticate=function(){var e=function(e){var t={messageName:"getPartnerAssets",data:e};l(t)};return function(){return AV.controlsWidgetInstance.serverMessaging.sendMessage({id:"avpw_auth_form",action:u.getManifestURL(),method:"GET",dataType:"json",announcer:AV.build.asyncFeatherTargetAnnounce,origin:AV.build.asyncImgrecvBase,callback:e,onError:function(e){AV.errorNotify(e.status&&403==e.status?"ERROR_AUTHENTICATING":"ERROR_GET_ASSETS")}})}}(),u.types=a,u},AV.ServerMessaging=function(e){var t=[],n=function(e,n){var a,o,i=!0,r=t.shift();if(r&&(n&&r.origin&&(i=n===AV.util.getDomain(r.origin)),r.id&&(a=avpw$("#"+r.id),o=a.attr("target"),avpw$("#"+o).unbind("load"),avpw$("#"+r.id+"_target_holder").empty(),a.remove()),i&&r.callback)){if(r.dataType&&"json"===r.dataType&&"string"==typeof e)try{e=AV.JSON.parse(e)}catch(s){}r.callback.call(this,e)}t.length>0&&d()},a=function(e,t,n,a,o,i){return avpw$.ajax({url:e,type:t,data:n,dataType:a,error:function(t){i?i.call(this,t):AV.errorNotify("ERROR_SERVER_MESSAGING",[e])},success:o})},o=function(e,t,n,a,o,i){var r=new XDomainRequest;r.onload=function(){var e=r.responseText;window.setTimeout(function(){var t;try{t=AV.JSON.parse(e),o(t)}catch(n){o(e)}},0)},r.onerror=function(t){i?i.call(this,t):AV.errorNotify("ERROR_SERVER_MESSAGING",[e]),AV.errorNotify("ERROR_SERVER_MESSAGING",[e])},r.ontimeout=function(){},r.onprogress=function(){},r.open(t,e),n?r.send(avpw$.param(n)):r.send()},i=function(e,t,n,a,o){var i=avpw$("
").attr({id:e,action:t,target:n,method:a||"POST"}).css({display:"none"}),r=document.createDocumentFragment();for(var s in o)o.hasOwnProperty(s)&&r.appendChild(avpw$("").attr({name:s,value:o[s],type:"hidden"})[0]);return i.html(r),i.appendTo("#avpw_holder"),i},r=function(e,t,n){return n||(n=AV.build.feather_baseURL+"blank.html"),t||(t=e),['"].join("")},s=function(e,t,n){if(!e)return null;var a=e+"_target_holder",o=Math.floor(4294967295*Math.random()).toString(16),i="avpw_form_target_"+o,s=avpw$("#"+a);return s&&s.length||(s=avpw$('
').css({position:"absolute",top:0,left:0}).appendTo("#avpw_holder")),s.html(r(i)),avpw$("#"+i).load(t?function(){c(i,e,t)}:n),i},l=function(e,t,n,a,o,r,l){var c=s(e,r,l);t+="?responsecontenttypeheader="+escape("text/html");var u=i(e,t,c,n,o);return u.submit(),u},c=function(e,t,a){var o,i=t+"_announcer";if(window.postMessage)window[i]?window[i].postMessage("avpw_load:"+e,"*"):(o=avpw$(r(i,i,a)),o.load(function(){AV.util.nextFrame(function(){window[i].postMessage("avpw_load:"+e,"*")})}),avpw$("#avpw_holder").append(o));else{var s,l=function(){avpw$(s).unbind().remove()},c=t+"_observer",u=c,d=0,p=function(){var e;try{if("about:blank"==s.contentWindow.location)return}catch(t){}2===d&&(e=s.contentWindow.name,e&&(d=3,e!==u&&e.substr&&"avpw:"==e.substr(0,5)?(e=e.substr(5),n(e)):(AV.errorNotify("ERROR_SAVING",[AV.build.imgrecvServer]),n()),l())),1===d&&(d=2,s.contentWindow.location=""),d||(d=1)};s=avpw$(r(c,u,a+"#"+e))[0],avpw$(s).load(p),avpw$(s).appendTo("#avpw_holder")}},u=function(e){var t=e.data,a=AV.util.getDomain(e.origin);t.substr&&"avpw:"==t.substr(0,5)&&(t=t.substr(5),n(t,a))},d=function(){var e=t[0];e&&l(e.id,e.action,e.method,e.origin,e.keyValues,e.announcer)},p=function(e){e.announcer?(t.push(e),1===t.length&&d()):l(e.id,e.action,e.method,e.origin,e.keyValues,e.announcer,e.callback)},h=function(e){var t,n=e.transport||"xhr";"xhr"===n&&avpw$.support.cors&&(!AV.firefox||AV.firefox>=4)?(t=a(e.action,e.method,e.keyValues,e.dataType,e.callback,e.onError),t||p(e)):"function"==typeof XDomainRequest?o(e.action,e.method,e.keyValues,e.dataType,e.callback,e.onError):p(e)},g=function(){window.addEventListener?window.addEventListener("message",u,!1):window.attachEvent&&window.attachEvent("onmessage",u)},f=this;return f.shutdown=function(){window.removeEventListener?window.removeEventListener("message",u,!1):window.detachEvent&&window.detachEvent("onmessage",u),t=[]},f.sendMessage=h,g(),f},function(e,t,n){e.AV=e.AV||{};var a=e.AV,o=a.Events;a.usageTracker=function(){var e,i=null,r={},s=0,l=[],c=0,u=-1,d=!1,p={},h=function(){a.controlsWidgetInstance&&p.submit("close")},g=function(){d||(!function(e,t,n,a,o,i,r){e.GoogleAnalyticsObject=o,e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date,i=t.createElement(n),r=t.getElementsByTagName(n)[0],i.async=1,i.src=a,r.parentNode.insertBefore(i,r)}(t,n,"script","https://www.google-analytics.com/analytics.js","AV_ga"),AV_ga("create",a.build.googleTracker,"auto",{allowLinker:!0}),AV_ga("set","dimension1",a.launchData.apiKey),AV_ga("set","dimension2",a.build.version),AV_ga("set","dimension3",this.getUUID()),AV_ga("set","dimension4",a.launchData.language),AV_ga("set","dimension5",a.launchData.apiVersion+""),d=!0,AV_ga("send","event","editor","isWebGLUsed",a.featherGLEnabled.toString()))},f=function(e,t,n){AV_ga("send","event","tool",e+":"+t,n?n+"":"")},v=function(e,t,n){AV_ga("send","event","interaction",e+":"+t,n?n+"":"")},m=function(e){p.submit("firstclick",e),o.off("usage:firstclick")};return p.setup=function(){avpw$(t).bind("unload",h),o.on("usage:submit",p.submit,p),o.on("usage:tool",f,p),o.on("usage:firstclick",m,p),o.on("usage:interact",v)},p.shutdown=function(){avpw$(t).unbind("unload",h),o.off("usage:submit",p.submit),o.off("usage:tool",f),o.off("usage:firstclick",m),o.off("usage:interact",v)},p.clear=function(){i=null,r={},s=0,l=[],c=0,u=-1},p.getUUID=function(){return i?i:i=Math.floor(4294967295*Math.random()).toString(16)+Math.floor(4294967295*Math.random()).toString(16)},p.addUsage=function(e,t){t||(t=1),void 0===r[e]?r[e]=t:r[e]+=t,s+=t},p.setPageCount=function(e){var t;for(c=e,l=new Array(e),t=0;e>t;t++)l[t]=0},p.addPageHit=function(t){t!==e&&l[t]++,e=t},p.submit=function(e,n){g.call(this),"launch"===e?AV_ga("send","pageview",(t.location||"").toString()):AV_ga("send","event","submit",e,n)},p}();var i={lighting:{brightness:!0,contrast:!0},color:{saturation:!0,warmth:!0}};return a.getActiveTools=function(e){var t=a.featherUseFlash?a.flashSupportedTools:a.featherGLEnabled?a.glSupportedTools:a.defaultTools,n=e;n&&"all"!==n&&"All"!==n&&"ALL"!==n&&""!==n||(n=t),"string"==typeof n&&(n=e.split(","));var o,r,s=[],l={},c={};for(r=0;r1?a.launchData.appendTo:void 0]),a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"enableControls"),a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"bindEvents"),avpw$("#avpw_controls").fadeIn(c),a.util.nextFrame(function(){"mobile"==a.launchData.openType&&a.setPageWidth(avpw$("#avpw_controls").width()),a.controlsWidgetInstance.setupScrollPanels()}),a.launchData.noCloseButton&&avpw$("#avpw_control_cancel_pane").css("display","none"),u&&"canvas"===u.nodeName.toLowerCase()?void a.mockLauncher(u):(i=a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"getEmbedElement",[u]),o=n.createElement("img"),o.id="avpw_temp_loading_image",a.tempLoadingImageSrc=o.src,avpw$(o).load(function(){r=a.controlsWidgetInstance.getScaledDims(avpw$(u).width(),avpw$(u).height()),o.width=r.width,o.height=r.height,a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"getScaledImageDims",[o]),avpw$(o).unbind(),o.style.display="block",avpw$(i).append(o),a.controlsWidgetInstance.showWaitThrobber(!0),a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"hideOriginalImage",[u]),avpw$(i).show(),a.util.nextFrame(function(){a.paintWidgetLauncher_stage2(e,t)})}).error(function(){a.paintWidgetCloser(!0),a.errorNotify("BAD_IMAGE",[t])}),o.src=u.src,!1)},a.paintWidgetLauncher_stage2=function(e,t){var n,i,r=a.util.getImageElem(e),s=function(e){a.controlsWidgetInstance&&a.paintWidgetInstance&&(n=new Image,avpw$.support.cors&&a.launchData.enableCORS&&-1===e.indexOf("data:")&&(n.crossOrigin="Anonymous"),avpw$(n).load(function(e){if(a.controlsWidgetInstance&&a.paintWidgetInstance){if(i=a.controlsWidgetInstance.getScaledDims(n.width,n.height),a.controlsWidgetInstance.imageSizeTracker.setOrigSize(a.launchData,n,i),n.width=i.width,n.height=i.height,a.paintWidgetInstance.setDimensions(i.width,i.height),!a.paintWidgetInstance.setBackground(n))return a.paintWidgetCloser(!0),a.errorNotify("IMAGE_NOT_CLEAN",[t]),!1;a.paintWidgetInstance.setOrigSize(i.width,i.height),r.src!==t&&a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"scaleCanvas"),avpw$(a.paintWidgetInstance.canvas).insertBefore("#avpw_temp_loading_image"),l.remove(),a.tempLoadingImageSrc=t,a.controlsWidgetInstance.showWaitThrobber(!1),a.controlsWidgetInstance.loaderPhase=2,a.launchData.actionListJSON&&a.paintWidgetInstance.actions.importJSON(a.launchData.actionListJSON,a.fireLaunchComplete)}}).attr("src",e))};i=a.controlsWidgetInstance.getScaledDims(avpw$(r).width(),avpw$(r).height()),a.controlsWidgetInstance.loaderPhase=1,a.paintWidgetInstance=new a.PaintWidget(i.width,i.height,new a.Actions,new a.ModeManager,new a.FilterManager,new a.OverlayRegistry,new a.ImageBorderManager),a.controlsWidgetInstance.canvasUI=new a.PaintUI(a.paintWidgetInstance.canvas,a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"getEmbedElement")),a.controlsWidgetInstance.initWithPaintWidget(a.paintWidgetInstance),a.paintWidgetInstance.setOrigSize(i.width,i.height),a.controlsWidgetInstance.imageSizeTracker.setOrigSize(a.launchData,r,i);var l=avpw$("#avpw_temp_loading_image");if(a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"scaleCanvas"),null!=t)if(!a.launchData.enableCORS||!avpw$.support.cors||avpw$.browser.msie||avpw$.browser.safari&&-1===navigator.userAgent.indexOf("Chrome")&&parseInt(a.util.getBrowserVersion())<7)if(-1===t.indexOf("data:")){if(!t||!t.match(/^http(s|):\/\//))return void a.errorNotify("BAD_URL",[t]);a.util.isURLSameDomain(t)?s(t):avpw$.ajax({type:"GET",dataType:"json",url:a.build.jsonp_imgserver+"?callback=?",data:{url:escape(t)},success:function(e){s(e.data)},error:function(e,n,o){200===e.status&&"parsererror"===n&&a.controlsWidgetInstance&&(a.controlsWidgetInstance.showWaitThrobber(!1), 2 | a.util.nextFrame(function(){a.paintWidgetCloser(!0),a.errorNotify("BAD_URL",[t])}))}})}else s(t);else s(t);else{if(!a.paintWidgetInstance.setBackground(r))return a.paintWidgetCloser(!0),a.launchData.enableCORS&&avpw$.support.cors?a.errorNotify("ERROR_BAD_IMAGE_WITHOUT_CORS"):a.errorNotify("IMAGE_NOT_CLEAN",[t]),!1;avpw$("#avpw_controls").insertAfter(a.paintWidgetInstance.canvas),avpw$(a.paintWidgetInstance.canvas).insertBefore(l),l.remove(),a.tempLoadingImageSrc=r.src,a.controlsWidgetInstance.showWaitThrobber(!1),a.controlsWidgetInstance.loaderPhase=2,a.launchData.actionListJSON&&a.paintWidgetInstance.actions.importJSON(a.launchData.actionListJSON,a.fireLaunchComplete)}return o.trigger("usage:submit","launch"),a.launchData.actionListJSON||a.fireLaunchComplete(),!1},a.fireLaunchComplete=function(){var e=a.launchData.initTool;a.Events.trigger("layout:resize"),e&&(a.util.nextFrame(function(){o.trigger("tool:open",e)}),a.paintWidgetInstance.moduleLoaded(e,function(e){a.util.nextFrame(function(){avpw$("#avpw_holder").removeClass("avpw_init_hide")})})),"function"==typeof a.launchData.onReady&&a.launchData.onReady()},a.paintWidgetShutdown=function(){o.trigger("usage:submit","close"),a.paintWidgetInstance&&a.paintWidgetInstance.shutdown(),a.controlsWidgetInstance&&(a.controlsWidgetInstance.serverMessaging&&(a.controlsWidgetInstance.serverMessaging.shutdown(),a.controlsWidgetInstance.serverMessaging=null),a.controlsWidgetInstance.shutdown()),avpw$("#avpw_controls").hide(),a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"onShutdown"),"function"==typeof a.launchData.onClose&&a.launchData.onClose(a.paintWidgetInstance.dirty),a.paintWidgetInstance=null,a.controlsWidgetInstance=null,a.tempLoadingImageSrc=null},a.paintWidgetCloser=function(e){var t=a.launchData.closeDelay;a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"onClose",[e]),e||0===t?(avpw$("#avpw_controls").hide(),a.paintWidgetShutdown()):avpw$("#avpw_controls").fadeOut(t,function(){a.paintWidgetInstance&&a.paintWidgetShutdown()})},a.controlsWidget_saveResponder=function(e,t,i){"https:"===n.location.protocol&&("string"==typeof t&&(t=t.replace("http:","https:")),"string"==typeof i&&(i=i.replace("http:","https:")));var r;if("function"==typeof e&&(r=e.apply(a.launchData,[a.util.getImageId(a.controlsWidgetInstance.paintImgIdElem),t,i])),a.controlsWidgetInstance){var s=a.util.getImageElem(a.controlsWidgetInstance.paintImgIdElem);s.avpw_prevURL=t,o.trigger("tool:close"),r&&a.controlsWidgetInstance.messager.show("avpw_aviary_beensaved",!0),a.controlsWidgetInstance.paintWidget.dirty=!1,a.controlsWidgetInstance.saving=!1}},a.controlsWidget_onImageSaved=function(e,t){a.controlsWidget_saveResponder(a.launchData.onSave,e,t)},a.controlsWidget_onHiResImageSaved=function(e){a.controlsWidget_saveResponder(a.launchData.onSaveHiRes,e)},a.ControlsWidget=function(e,t,n,i,r){this.maxWidth=parseInt(a.launchData.maxSize),this.maxHeight=this.maxWidth,this.saving=!1,this.origURL=null,this.activeTools=n,this.quitCount=0,a.usageTracker.setup(),this.paintImgIdElem=t,o.on("layout:resize",this.setupScrollPanels,this),this.layoutNotify(a.launchData.openType,"showView",["main"]),e&&this.initWithPaintWidget(e);var s={className:"avpw_canvas_spinner",lines:12,length:6,width:2,radius:6,color:"#fff",speed:.5,trail:70},l={className:"avpw_tool_spinner",lines:12,length:6,width:2,radius:6,color:"#fff",speed:.5,trail:70};"mobile"!=a.launchData.openType&&(l.color="#555",l.length=4),this.waitThrobber=new a.Spinner(s),this.onEggWaitThrobber=new a.Spinner(l),this.toolManager=new a.ToolManager(this),this.assetManager=i,this.serverMessaging=r},a.ControlsWidget.prototype.tool={},a.ControlsWidget.prototype.layout={},a.ControlsWidget.prototype.layoutNotify=function(e,t,n){return this.objectNotify("layout",e,t,n)},a.ControlsWidget.prototype.objectNotify=function(e,t,n,a){if("object"==typeof this[e][t]){var o=this[e][t];if("function"==typeof o[n]){var i=o[n];return a||(a=[]),i.apply(o,a)}}return!0},a.ControlsWidget.prototype.shutdown=function(){this.canvasUI&&this.canvasUI.shutdown(),this.messager&&this.messager.hide(),o.off("layout:resize",this.setupScrollPanels),this.shutdownAllTools(),this.unbindControls(),this.toolsPager&&(this.toolsPager.shutdown(),this.toolsPager=null),this.paintWidget&&(this.paintWidget.showWaitThrobber=null),a.usageTracker.shutdown(),this.waitThrobber.stop(),this.onEggWaitThrobber.stop(),this.waitThrobber=null,this.onEggWaitThrobber=null,this.showPanel(null),this.toolManager.shutdown(),this.toolManager=null},a.ControlsWidget.prototype.initAllTools=function(){for(var e in this.activeTools){var t=this.activeTools[e];this.tool.hasOwnProperty(t)&&a.paintWidgetInstance.moduleLoaded(t,function(e){o.trigger("tool:init",e)}.AV_bindInst(this))}a.launchData.forceCropPreset&&a.paintWidgetInstance.moduleLoaded("forcecrop",function(e){o.trigger("tool:init","forcecrop")}.AV_bindInst(this))},a.ControlsWidget.prototype.shutdownAllTools=function(){for(var e in this.activeTools){var t=this.activeTools[e];o.trigger("tool:shutdown",t)}a.launchData&&a.launchData.forceCropPreset&&o.trigger("tool:shutdown","forcecrop")},a.ControlsWidget.prototype.bindControls=function(){},a.ControlsWidget.prototype.unbindControls=function(){},a.ControlsWidget.prototype.initWithPaintWidget=function(e){this.paintWidget=e,this.imageSizeTracker=new a.ImageSizeTracker(e.actions),a.featherUseFlash||this.initAllTools(),this.bindControls(),this.paintWidget.showWaitThrobber=this.showWaitThrobber.AV_bindInst(this)},a.ControlsWidget.prototype.showWaitThrobber=function(e,n){var o=300,i=this;if(e){var r=this.layoutNotify(a.launchData.openType,"getEmbedElement");r.is(":visible")&&(this.waitThrobber.spin(r[0]),avpw$(this.waitThrobber).fadeIn(o))}else avpw$(i.waitThrobber.el).fadeOut(o,i.waitThrobber.stop);n&&t.setTimeout(n,5)},a.publicName2PanelMode=function(e){return"stickers"===e&&(e="overlay"),"draw"===e&&(e="drawing"),"text"!==e||a.featherUseFlash||(e="textwithfont"),e},a.ControlsWidget.prototype.panelMode2WidgetMode=function(e){switch(e){case"rotate":return"rotate90";case"greeneye":return"redeye";case"pinch":return"bulge"}return e},a.ControlsWidget.prototype.setupScrollPanels=function(){if(this.activeTools&&this.activeTools.length){var e,t,n,o=this,i={},r=this.layoutNotify(a.launchData.openType,"getDims").TOOLS_BROWSER_WIDTH,s=function(){o.toolsPager=new a.Pager(l),o.toolsPager.changePage()},l={itemCount:this.activeTools.length,itemsPerPage:this.layoutNotify(a.launchData.openType,"getToolsPerPage"),pageWidth:r,leftArrow:avpw$("#avpw_lftArrow"),rightArrow:avpw$("#avpw_rghtArrow"),itemBuilder:function(n){return e=o.activeTools[n],t=a.util.getUserFriendlyToolName(e),t=a.getLocalizedString(t),a.template[a.launchData.layout].eggIcon({optionName:e,capOptionName:t})},pageTemplate:a.template[a.launchData.layout].genericScrollPanel,pipTemplate:a.template[a.launchData.layout].scrollPanelPip,lastPageTemplate:n,lastPageContents:i,pageContainer:avpw$("#avpw_control_main_scrolling_region"),pipContainer:avpw$("#avpw_tools_pager ul"),onPageChange:function(e){a.usageTracker.addPageHit(e)}};s(),avpw$("#avpw_control_main_scrolling_region").css("width",o.toolsPager.getPageCount()*r+"px"),this.assetManager.getAssets("PERMISSION",function(e){var t=!0;if(e)for(var n=0;ni;i+=a)for(o=0;n+a>o;o+=a)e.fillStyle=1==(o+i&1)?"#fff":"#ddd",e.fillRect(o,i,a,a)},a.ControlsWidget.prototype.showPanel=function(e){null!=e&&(avpw$(".avpw_controlpanel").each(function(){avpw$(this).hide()}),avpw$("#avpw_controlpanel_"+e).show())},a.ControlsWidget.prototype.save=function(){var e=null,n=!0,i=1e3,r=function(){return{apikey:a.launchData.apiKey,timestamp:a.launchData.timestamp,signature:a.launchData.signature,salt:a.launchData.salt,encryptionMethod:a.launchData.encryptionMethod}},s=function(e,t,n){var o=a.controlsWidgetInstance;if(o.layoutNotify(a.launchData.openType,"enableControls",[!0]),o.paintWidget.showWaitThrobber(!1),e){var i=avpw$(a.util.getImageElem(o.paintImgIdElem));i.avpw_prevURL=e,a.controlsWidget_onImageSaved(e,t)}else a.errorNotify("ERROR_SAVING",[a.build.imgrecvServer,n]),a.controlsWidgetInstance.saving=!1},l=function(e,t){var n=a.controlsWidgetInstance;if(n.layoutNotify(a.launchData.openType,"enableControls",[!0]),n.paintWidget.showWaitThrobber(!1),e){var o=avpw$(a.util.getImageElem(n.paintImgIdElem));o.avpw_prevURL=e,a.controlsWidget_onHiResImageSaved(e)}else a.errorNotify("ERROR_SAVING",[a.build.asyncImgrecvBase,t]),a.controlsWidgetInstance.saving=!1},c=function(e,t){var n,o,i,r,l="";if("string"==typeof e)if(-1===e.indexOf("---FEATHER-POSTMESSAGE---"))try{o=e.split("")[1].split("")[0]}catch(c){a.errorNotify("ERROR_SAVING",["Error parsing response."])}else n=e.split("---FEATHER-POSTMESSAGE---"),o=n[0],i=n[1];else if(r=avpw$(e).find("error"),r.length>0)l=r.text();else{var u=avpw$(e).find("url");u&&(o=u.text(),o=o.replace(/^\s+|\s+$/g,""));var d=avpw$(e).find("hiresurl");d&&(i=d.text(),i=i.replace(/^\s+|\s+$/g,""))}var p=[o,i,l];"function"==typeof t?t.apply(this,p):s.apply(this,p)},u=function(e,t){var n=a.S3Uploader.isCapable("image/"+(""===a.launchData.fileFormat?"png":a.launchData.fileFormat)),o=this;o.paintWidget.exportImage(null,function(i){function u(){a.controlsWidgetInstance.serverMessaging.sendMessage({id:"avpw_save_form",action:a.build.imgrecvServer,method:"POST",announcer:a.build.featherTargetAnnounce,origin:a.build.imgrecvBase,keyValues:a.util.extend(r(),{file:p,sessionid:a.usageTracker.getUUID(),actionlist:o.paintWidget.actions.exportJSON(!0),origurl:f,hiresurl:a.launchData.hiresUrl,contenttype:a.launchData.fileFormat,jpgquality:a.launchData.jpgQuality,debug:a.launchData.debug,asyncsave:a.launchData.asyncSave,usecustomfileexpiration:a.launchData.useCustomFileExpiration,encodedas:"base64text"}),callback:function(){(t||c).apply(this,arguments)}})}var d,p,h=i.indexOf(";",0),g=i.indexOf(",",h);d=i.slice(5,h),p=i.slice(g+1),i="";var f=o.origURL;f&&0===f.indexOf("data:")&&(f=""),n?a.S3Uploader.upload(d,p,function(t,n){t&&u(),e?l.call(this,n,null,t):s.call(this,n,null,t)}):u()})},d=function(e,t,n){var a=Math.round(t*n/1e6*10)/10,i=["didHitAzure:"+(e?"Yes":"No")," width:"+t," height:"+n," megaPixels:"+a].join("");o.trigger("usage:submit","saveHiRes",i)},p=function(){var o=a.paintWidgetInstance.getScaledSize(),s=function(){if(d(!0,o.hiresWidth,o.hiresHeight),!a.launchData.hiresUrl)return void a.errorNotify("ERROR_MISSING_HI_RES_URL");var s=a.util.extend(r(),{actionlist:this.paintWidget.actions.exportJSON(!0),origurl:a.launchData.hiresUrl,fileformat:a.launchData.fileFormat,notificationmethod:"GET",backgroundcolor:"0xffffffff",jpgquality:a.launchData.jpgQuality}),c=function(a){!a||a&&"JobFailed"===a.JobStatusCode?(l(null,a),t.clearInterval(e)):a&&"JobCompleted"===a.JobStatusCode&&(t.clearInterval(e),l(a.JobStatus)),n=!0},u=function(o){var s;o&&o.JobId?(s=o.JobId,e=t.setInterval(function(){n&&a.controlsWidgetInstance.serverMessaging.sendMessage({id:"avpw_save_form",action:a.build.asyncImgrecvGetJobStatus,method:"POST",dataType:"json",announcer:a.build.asyncFeatherTargetAnnounce,origin:a.build.asyncImgrecvBase,keyValues:a.util.extend(r(),{jobid:s}),callback:c}),n=!1},i)):l(null,o)};a.controlsWidgetInstance.serverMessaging.sendMessage({id:"avpw_save_form",action:a.build.asyncImgrecvCreateJob,method:"POST",dataType:"json",announcer:a.build.asyncFeatherTargetAnnounce,origin:a.build.asyncImgrecvBase,keyValues:s,callback:u})},c=this,p=function(){u.apply(c,[!0,function(e,t){d(!1,o.hiresWidth,o.hiresHeight),l.apply(this,arguments)}])},h=-1!==navigator.userAgent.indexOf("MSIE");if(h||a.launchData.forceHiResSave||a.launchData.hiresUrl!==a.launchData.url)s.call(this);else{var o=a.paintWidgetInstance.getScaledSize(),g=a.launchData.maxSize,f=a.launchData.hiresWidth,v=a.launchData.hiresHeight;f&&v?f>g&&v>g?s.call(this):o.hiresWidth0&&this.paintWidget&&this.paintWidget.dirty;if("function"==typeof a.launchData.onCloseButtonClicked){var n=a.launchData.onCloseButtonClicked.apply(a.launchData,[t]);if(n===!1)return!1}return t?this.showAreYouSure():a.paintWidgetCloser(),!1},a.ControlsWidget.prototype.getScaledDims=function(e,t){return a.util.getScaledDims(e,t,this.maxWidth,this.maxHeight)},a.TransformStyle=function(e){var t=this,n=e||"";return t.set=function(e){if(n)for(var t in e){var a=t+"\\([^\\)]*",o=new RegExp(a),i=!1,r=function(n,a,o){return i=!0,t+"("+e[t]};n=n.replace(o,r),i||(n+=" "+t+"("+e[t]+")")}else for(var t in e)n+=" "+t+"("+e[t]+")"},t.serialize=function(){return n},t},e}(this,"undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{}),AV.errorNotify=function(e,t){var n={BAD_IMAGE:{code:1,message:"There was a problem loading your image provided to the `image` config key. Either it's not actually an image file or it doesn't really exist."},UNSUPPORTED:{code:2,message:"It looks like you're using a browser that doesn't support the HTML canvas element (and also doesn't have Flash installed either). Please try accessing this page through a modern browser like Chrome, Firefox, Safari, or Internet Explorer (version 9 or higher). Your internets will thank you."},BAD_URL:{code:3,message:"There was a problem loading your image provided by URI to the `url` config key. It is not reachable by the public (and our service at "+(AV.featherUseFlash?AV.build.proxyServer:AV.build.imgrecvBase)+")"},UNSUPPORTED_TOOL:{code:4,message:"So sorry, but this tool is not available because it is not part of the set chosen with the `tools` config key. It's alternatively possible that your browser does not support this specific tool."},IMAGE_NOT_CLEAN:{code:5,message:"Uh oh! We can't edit this image because the editor wasn't set up correctly to load external files via their address. You must either provide images from the same domain as the web page with the editor OR pass the external image address via the `url` config key in order for Aviary to be able to get permission from the browser to open it for editing. Sorry for the inconvenience!"},UNSUPPORTED_FONT:{code:6,message:"So sorry, but this font looks to be unsupported by your browser or platform"},ERROR_SAVING:{code:7,message:"There was a problem saving your photo. Please try again."},NO_APIKEY:{code:8,message:"apiKey is required and not provided. See http://www.aviary.com/web-documentation#constructor-config-apikey."},ERROR_AUTHENTICATING:{code:9,message:"There was a problem retrieving access to content from our server. Please ensure all authentication keys are present or do not attempt premium partner authentication."},ERROR_BAD_THEME:{code:10,message:"Selected theme does not exist. Please use 'dark', 'light' or 'minimum' or see aviary.com/web for more info."},ERROR_BAD_IMAGE_WITHOUT_CORS:{code:11,message:"The image URL you are trying to use is either not on the same domain or is not configured for CORS. See http://enable-cors.org/ for more info."},ERROR_SERVER_MESSAGING:{code:12,message:"Error reaching Aviary services."},ERROR_BAD_AUTHENTICATION_PARAMETERS:{code:13,message:"Invalid authenticationURL response. Please check the formatting the response."},BAD_FORCECROP_TOOLS:{code:14,message:"If you're using the 'Force Crop' tool, the editor will disable the resize, orientation and crop tools so the user cannot change the intended forced size. It looks like the only tools you have enabled disabled by 'Force Crop'.."},ERROR_GET_ASSETS:{code:15,message:"Error getting assets. Please check your authentication parameters."},ERROR_MISSING_HI_RES_URL:{code:16,message:"Missing 'hiresUrl' from launch() method"},ERROR_WEBGL_LOST_CONTEXT:{code:17,message:"WebGL Error: the GL lost context."}},a=function(e){},o=n[e],i=o.message;return"function"==typeof AV.launchData.onError&&(o.args=t,i=AV.launchData.onError(o)||i),i&&a(i),i},function(e,t,n){"use strict";e.AV=e.AV||{};var a=e.AV,o=a.Events;e.Aviary=a,a.feather_loaded=!1,a.feather_loading=!1,a.build=a.build||{version:"",imgrecvServer:"imgrecvserver",flashGatewayServer:"",imgrecvBase:"",inAppPurchaseFrameURL:"",imgtrackServer:"imgtrackserver",filterServer:"",jsonp_imgserver:"",featherTargetAnnounce:"feather_target_announce_v3.html",proxyServer:"",feather_baseURL:"",feather_stickerURL:"",googleTracker:""},a.defaultTools=["enhance","effects","frames","overlays","overlay","orientation","crop","resize","lighting","color","sharpness","focus","vignette","blemish","whiten","redeye","drawing","colorsplash","textwithfont","meme"],a.glSupportedTools=["enhance","effects","frames","overlays","overlay","orientation","crop","resize","lighting","color","sharpness","focus","vignette","blemish","whiten","redeye","drawing","colorsplash","textwithfont","meme"],a.flashSupportedTools=["enhance","effects","overlay","crop","resize","orientation","brightness","contrast","saturation","sharpness","drawing","text","redeye","blemish"];var i={};return i.image=null,i.apiKey=void 0,i.apiVersion=4,i.appendTo=null,i.language="en",i.theme=null,i.minimumStyling=!1,i.maxSize=1024,i.noCloseButton=!1,i.launchDelay=300,i.closeDelay=300,i.forceCropPreset=null,i.forceHiResSave=!1,i.authenticationURL=null,i.tools=void 0,i.initTool="",i.cropPresets=["Custom","Original",["Square","1:1"],"3:2","3:5","4:3","4:5","4:6","5:7","8:10","16:9"],i.cropPresetDefault="Custom",i.cropPresetsStrict=!1,i.url=null,i.enableCORS=!1,i.postUrl=void 0,i.postData=null,i.fileFormat="",i.jpgQuality=100,i.displayImageSize=!1,i.hiresMaxSize=1e4,i.hiresWidth=null,i.hiresHeight=null,i.onLoad=void 0,i.onReady=void 0,i.onSaveButtonClicked=void 0,i.onSave=void 0,i.onSaveHiRes=void 0,i.onClose=void 0,i.onError=void 0,i.signature=null,i.timestamp=null,i.hiresUrl=void 0,i.isPremiumPartner=!0,i.useCustomFileExpiration=!1,i.allowInAppPurchase=!1,i.disableWebGL=!1,i.forceFlash=!1,i.forceSupport=!1,i.poweredByURL="http://www.aviary.com",i.giveFeedbackURL="http://support.aviary.com/",i.getWidgetURL="https://creativesdk.adobe.com",i.debug=!1,i.asyncSave=!0,a.baseConfig=i,function(e){var t=function(e){return{language:e.Feather_Language,forceFlash:e.Feather_ForceFlash,forceSupport:e.AV_Feather_ForceSupport,onLoad:e.Feather_OnLoad,onReady:e.Feather_OnLaunchComplete,onClose:e.Feather_OnClose,onSave:e.Feather_OnSave,noCloseButton:e.Feather_NoCloseButton,maxSize:e.Feather_MaxSize||e.Feather_MaxDisplaySize,tools:e.Feather_EditOptions,cropPresets:e.Feather_CropSizes,resizePresets:e.Feather_ResizeSizes,apiKey:e.Feather_APIKey,hiresUrl:e.Feather_HiResURL,postUrl:e.Feather_PostURL,fileFormat:e.Feather_FileFormat||e.Feather_ContentType,jpgQuality:e.Feather_FileQuality,signature:e.Feather_Signature,timestamp:e.Feather_Timestamp}};if(a.baseConfig=a.util.extend(a.baseConfig,t(e)),"https:"===e.location.protocol||"chrome-extension:"===e.location.protocol){var n,o;for(var i in a.build)a.build.hasOwnProperty(i)&&(o=i.split("_SSL"),2===o.length&&a.build[i]&&(n=o[0],a.build[n]=a.build[i]))}}(t),a.getLocalizedString=function(e){try{var t=a.lang[a.launchData.language][e];return void 0===t&&(t=e),t}catch(n){}return e},Function.prototype.AV_bindInst=function(e){var t=this;return function(){return t.apply(e,arguments)}},a.injectControls=function(){var e,t;if("popup"===a.launchData.openType?(e="",t=a.template[a.launchData.layout].saveBlock()):(e=a.template[a.launchData.layout].saveBlock(),t=""),a.criticalLayoutStyles&&!a.feather_loaded){var o=n.createElement("style");o.type="text/css";var i=n.createTextNode(a.criticalLayoutStyles);o.styleSheet?o.styleSheet.cssText=i.nodeValue:o.appendChild(i);var r=n.getElementsByTagName("head")[0];r.appendChild(o)}var s=a.template[a.launchData.layout].controls({internalSaveBlock:e,externalSaveBlock:t}),l=n.createElement("div");l.id="avpw_holder";var c="";a.featherUseFlash&&(c="avpw_flash "),a.msie&&(c+="avpw_ie"+a.msie),c&&(l.className=c);var u=n.getElementsByTagName("body");u&&(u=u[0]),u||(u=n.documentElement),u.appendChild(l),l.innerHTML=s},a.Feather=function(e){e||(e={});var i=this;e.authenticationURL&&(e.isPremiumPartner=!0,o.on("auth:update",function(e){r(e)}));var r=function(n){t.avpw$.ajax({url:e.authenticationURL,cache:!1,type:"GET",contentType:"application/json"}).done(function(e){for(var t,o=["salt","timestamp","signature","encryptionMethod"],r=[],s=0;s0&&a.errorNotify("ERROR_BAD_AUTHENTICATION_PARAMETERS",[r.join(", ")]),i.updateConfig({salt:e.salt,timestamp:e.timestamp,signature:e.signature,encryptionMethod:e.encryptionMethod}),n&&n()})},s=function(){a.injectControls(),a.util.nextFrame(a.loadStageFinal)},l=function(){"undefined"!=typeof avpw$?t.avpw$(n).ready(s):s()};e&&(e.openType="aviary",e.layout="desktop"),e=e||{},a.launchData=a.util.extend(a.baseConfig,e);var c=function(){function e(e){var t=a.build.feather_baseURL+"css/"+e;a.util.loadFile(t+".css","css")}var t,n;if(a.featherUseFlash=!a.featherCanvasOk()&&a.featherFlashOk(),a.featherGLEnabled=a.launchData.forceGL||a.shouldUseWebGL(),a.featherUseFlash&&(a.launchData.forceHiResSave=!0),a.launchData.language=a.launchData.language.toLowerCase(),!a.feather_loaded&&!a.feather_loading){switch(a.feather_loading=!0,t=a.launchData.language||"en",n="js/feathercontrols_",n+=a.validLanguages&&a.validLanguages[t]?t+".js":"en.js",!a.launchData.theme&&a.launchData.minimumStyling&&(a.launchData.theme="minimum"),"minimum"===a.launchData.theme&&(a.launchData.minimumStyling=!0),a.launchData.theme||(a.launchData.theme="dark"),a.launchData.theme){case"dark":case"light":case"minimum":break;default:a.errorNotify("ERROR_BAD_THEME")}var o;o=a.launchData.minimumStyling?"feather_core_":"feather_theme_aviary_",o+=a.launchData.theme,e(o),a.build.bundled?l():a.util.loadFile(a.build.feather_baseURL+n,"js",l)}};c();var u=function(){return a.paintWidgetInstance?!1:void a.paintWidgetLauncher(a.launchData.image,a.launchData.url)};return i.launch=function(e){if(!a.feather_loaded)return!1;var t=n.getElementById("avpw_holder");if(t||a.injectControls(),a.paintWidgetInstance){if(t)return!1;i.close(!0)}if(a.launchData&&(a.launchData.hiresWidth||a.launchData.hiresHeight)&&(a.launchData.hiresWidth=null,a.launchData.hiresHeight=null),e&&e.language&&delete e.language,a.launchData=e?a.util.extend(a.launchData,e):a.launchData,!a.launchData.image)return a.errorNotify("BAD_IMAGE"),!1;if(!a.launchData.apiKey)return a.errorNotify("NO_APIKEY"),!1;if("object"==typeof e.forceCropPreset?(a.launchData.forceCropPreset=[e.forceCropPreset],a.launchData.initTool="forcecrop"):a.launchData.forceCropPreset=null,a.launchData.initTool&&(t.className+=" avpw_init_hide"),a.featherUseFlash)u();else{if(!a.featherSupported())return a.errorNotify("UNSUPPORTED")&&(a.controlsWidgetInstance=new a.ControlsWidget,a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"placeControls",[a.util.getApiVersion(a.launchData)>1?a.launchData.appendTo:void 0]),a.controlsWidgetInstance.bindControls(),n.getElementById("avpw_controls").style.display="block",a.controlsWidgetInstance.messager.show("avpw_aviary_unsupported",!0)),!0;a.util.nextFrame(u)}return!0},i.showWaitIndicator=function(){return a.controlsWidgetInstance&&a.controlsWidgetInstance.showWaitThrobber?(a.controlsWidgetInstance.showWaitThrobber(!0),!0):!1},i.hideWaitIndicator=function(){return a.controlsWidgetInstance&&a.controlsWidgetInstance.showWaitThrobber?(a.controlsWidgetInstance.showWaitThrobber(!1),!0):!1},i.getImageDimensions=function(){var e=null;return a.paintWidgetInstance&&(e=a.paintWidgetInstance.getScaledSize(),a.launchData.hiresWidth&&a.launchData.hiresHeight||(delete e.hiresWidth,delete e.hiresHeight)),e},i.save=function(){return a.paintWidgetInstance?a.controlsWidgetInstance.save():!1},i.saveHiRes=function(){return a.paintWidgetInstance?a.launchData.authenticationURL?(o.trigger("auth:update",function(){a.controlsWidgetInstance.save("saveHiRes")}),!0):a.controlsWidgetInstance.save("saveHiRes"):!1},i.getImageData=function(e,t,n){return a.paintWidgetInstance?a.controlsWidgetInstance.save("getImageData",e,t,n):!1},i.close=function(e){return a.paintWidgetInstance?void a.paintWidgetCloser(e):!1},i.relaunch=function(){return o.trigger("usage:interact","api","relaunch"),a.isRelaunched=!0,a.launchData?void i.launch(a.launchData):!1},i.activateTool=function(e){o.trigger("tool:open",e,a.controlsWidgetInstance)},i.replaceImage=function(e){return o.trigger("usage:interact","api","replaceImage"),a.launchData?(i.close(!0),void a.util.nextFrame(function(){a.launchData.url=e,i.launch(a.launchData)})):!1},i.updateConfig=function(e,t){if(!a.launchData)return!1;if(e&&"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(a.launchData[n]=e[n]);else{if(!e||"string"!=typeof e)return!1;a.launchData[e]=t}},i.getIsDirty=function(){return a.paintWidgetInstance?a.paintWidgetInstance.dirty:!1},i.getActionList=function(){return a.paintWidgetInstance?(o.trigger("tool:commit"),a.paintWidgetInstance.actions.exportJSON(!0)):void 0},i.disableControls=function(){a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"disableControls")},i.enableControls=function(){a.controlsWidgetInstance.layoutNotify(a.launchData.openType,"enableControls")},i.on=function(e,t){o&&e&&t&&"function"==typeof t&&o.on(e,t)},i.off=function(e,t){o&&e&&t&&"function"==typeof t&&o.off(e,t)},i},a.loadStageFinal=function(){a.feather_loaded=!0;var e=function(){"function"==typeof a.launchData.onLoad&&a.launchData.onLoad()};a.launchData.authenticationURL?o.trigger("auth:update",e):e()},a.featherSupported=function(){return a.featherCanvasOk()||a.featherFlashOk()||a.launchData.forceSupport},a.featherFlashOk=function(){return a.launchData.forceFlash?!0:t.avpw_swfobject&&t.avpw_swfobject.hasFlashPlayerVersion(a.build.MINIMUM_FLASH_PLAYER_VERSION)},a.featherCanvasOk=function(){if(a.launchData.forceFlash)return!1;var e=!!n.createElement("canvas").getContext,o="function"==typeof t.postMessage;return e&&o},a.shouldUseWebGL=function(){if(a.launchData.disableWebGL)return!1;var e=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./);if(-1===navigator.userAgent.indexOf("Chrome")&&-1===navigator.userAgent.indexOf("Firefox")&&!e)return!1;if(-1!==navigator.userAgent.indexOf("Firefox")){var o=parseInt(navigator.userAgent.toLowerCase().split("firefox/")[1]);if(!o||33>o)return!1}var i=n.createElement("canvas");if("undefined"==typeof t.WebGLRenderingContext)return!1;if(!i||!i.getContext)return!1;var r=i.getContext("webgl")||i.getContext("experimental-webgl");if(!r)return!1;var s=r.getParameter(r.MAX_TEXTURE_SIZE);return a.launchData.maxSize>s?!1:!0},a.getFlashMovie=function(e){var a=t[e]||n[e];return a},a.msie=function(){for(var e,t=3,a=n.createElement("div"),o=a.getElementsByTagName("i");a.innerHTML="",o[0];);return t>4?t:e}(),a.firefox=function(){var e;return"Gecko"===t.navigator.product&&(e=navigator.userAgent.split("Firefox/")[1],e=parseInt(e,10)),e}(),a.PAGE_WIDTH=360,a.setPageWidth=function(e){a.PAGE_WIDTH=e},e}(this,"undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{}),AV.S3Uploader=function(){function e(e,t){e=atob(e);for(var n=new ArrayBuffer(e.length),a=new Uint8Array(n),o=0;o=a||l>0&&2.3>=l)},d.isIPhoneOrIPod=function(){return 2===t||3===t},d.isAndroid=function(){return 1===s},d.getAndroidVersion=function(){return l},d.getVendorProperty=function(){var e={},t=function(e,t){var n,a,o=["webkit","ms","Moz","O"],i=e.style;if(void 0!==i[t])return t;for(t=t.charAt(0).toUpperCase()+t.slice(1),a=0;a", 29 | "repository": { 30 | "type": "git", 31 | "url": "git@github.com:m00s/angular-aviary.git" 32 | }, 33 | "license": "MIT" 34 | } 35 | -------------------------------------------------------------------------------- /tests.js: -------------------------------------------------------------------------------- 1 | /* 2 | (c) 2015 Massimiliano Sartoretto 3 | License: MIT 4 | */ 5 | 6 | describe('module ngAviary', function () { 7 | var $rootScope, $compile, $window, AdobeAviary, ngAviary, mockEditor; 8 | var imageElement = document.createElement('img'); 9 | 10 | mockEditor = { 11 | launch: function(a){return false;} 12 | }; 13 | 14 | beforeEach(module('ngAviary', function(ngAviaryProvider){ 15 | ngAviaryProvider.configure({ 16 | apiKey: 'my-awesome-api-key', 17 | theme: 'light' 18 | }); 19 | })); 20 | 21 | beforeEach(function(){ 22 | module(function($provide) { 23 | $provide.constant('Aviary', { 24 | Feather: jasmine.createSpy('Feather') 25 | }); 26 | }); 27 | }); 28 | 29 | beforeEach(inject(function ($injector, $window) { 30 | $rootScope = $injector.get('$rootScope'); 31 | $compile = $injector.get('$compile'); 32 | $window = $injector.get('$window'); 33 | ngAviary = $injector.get('ngAviary'); 34 | 35 | // Mocking Aviary Global Object 36 | (function($window) { 37 | window = $window; 38 | spyOn(window.Aviary, 'Feather').and.returnValue(mockEditor); 39 | spyOn(window.document, 'querySelector').and.returnValue(imageElement); 40 | spyOn(mockEditor, 'launch'); 41 | })(); 42 | })); 43 | 44 | afterEach(function () { 45 | jasmine.clock().uninstall(); 46 | }); 47 | 48 | describe('ngAviary configuration', function () { 49 | it('should has an awesome api key', function () { 50 | expect(ngAviary.configuration.apiKey).toEqual('my-awesome-api-key'); 51 | }); 52 | 53 | it('should has the light theme active', function () { 54 | expect(ngAviary.configuration.theme).toEqual('light'); 55 | }); 56 | }); 57 | 58 | describe('ngAviary directive', function() { 59 | var element, scope; 60 | 61 | function compileElementAndClick(el, click) { 62 | el = el ? el : angular.element(''); 63 | scope = $rootScope.$new(); 64 | element = $compile(el)(scope); 65 | scope.$digest(); 66 | if(click) { 67 | element.triggerHandler('click'); 68 | } 69 | } 70 | 71 | beforeEach(function() { 72 | spyOn(document, 'getElementById').and.returnValue(imageElement); 73 | }); 74 | 75 | describe('should launch the Feather editor', function() { 76 | it('when clicked', function(){ 77 | compileElementAndClick(null, true); 78 | expect(mockEditor.launch).toHaveBeenCalled(); 79 | }); 80 | 81 | it('with target-selector by default', function() { 82 | compileElementAndClick( 83 | angular.element(''), true 84 | ); 85 | var paramsObj = {image: imageElement, url: imageElement.src}; 86 | expect(mockEditor.launch).toHaveBeenCalledWith(paramsObj); 87 | }); 88 | 89 | it('with target-src if provided', function(){ 90 | compileElementAndClick( 91 | angular.element(''), 94 | true 95 | ); 96 | var paramsObj = {image: imageElement, url: 'towel.png'}; 97 | expect(mockEditor.launch).toHaveBeenCalledWith(paramsObj); 98 | }); 99 | }); 100 | }); 101 | }); 102 | --------------------------------------------------------------------------------