-
Notifications
You must be signed in to change notification settings - Fork 4
/
ng-juxtapose.min.js
10 lines (9 loc) · 2.77 KB
/
ng-juxtapose.min.js
1
2
3
4
5
6
7
8
9
10
/**
* ng-juxtapose - v1.0.1 - 2015-09-06
* http://github.com/tinesoft/ng-juxtapose
*
* Copyright (c) 2015 Tine Kondo
* Licensed MIT
*/
!function(a,b,c){b.module("ngJuxtapose",[]).provider("juxtaposeConfig",function(){var a={startingPosition:"50%",showLabels:!0,showCredits:!0,animate:!0,vertical:!1},c=b.extend({},a);return{setStartingPosition:function(a){c.startingPosition=a},setShowLabels:function(a){c.showLabels=a},setShowCredits:function(a){c.showCredits=a},setAnimate:function(a){c.animate=a},setVertical:function(a){c.vertical=a},$get:function(){return{startingPosition:"50%",showLabels:!0,showCredits:!0,animate:!0,vertical:!1}}}}).controller("JuxtaposeController",["$scope","$attrs","$parse","$window","juxtaposeConfig",function(a,c,d,e,f){var g=this;if(!e.juxtapose)return void console.error("Cannot find 'juxtapose'. Make sure you've included the JuxtaposeJS library before this directive");b.forEach(["startingPosition","showLabels","showCredits","animate","vertical"],function(e,g){a[e]=b.isDefined(c[e])?1>g?d(c[e])(a.$parent):a.$parent.$eval(c[e]):f[e]});"#"+c.id;b.forEach(["startingPosition","showLabels","showCredits","animate","vertical"],function(b){c[b]&&a.$parent.$watch(d(c[b]),function(c,d){c!==d&&(a[b]=c,g.updateSlider())})}),a.$watchCollection("[beforeImageUrl, beforeImageLabel, beforeImageCredit, beforeImageAlt, afterImageUrl, afterImageLabel, afterImageCredit, afterImageAlt]",function(a){var b=a[0],c=a[4];b&&c&&g.updateSlider()}),a.$on("$destroy",function(){g.$element=null,g.slider=null}),this.init=function(a){g.$element=a,g.slider=null},this.updateSlider=function(){var d="#"+c.id,e=[{src:a.beforeImageUrl,label:a.beforeImageLabel,credit:a.beforeImageCredit},{src:a.afterImageUrl,label:a.afterImageLabel,credit:a.afterImageCredit}],f={animate:a.animate,showLabels:a.showLabels,showCredits:a.showCredits,mode:a.vertical?"vertical":"horizontal",startingPosition:a.startingPosition,callback:a.callback};if(g.$element.empty(),g.slider=new juxtapose.JXSlider(d,e,f),c.beforeImageAlt||c.afterImageAlt){var h=(g.$element.find("img"),g.$element.children(),g.$element.children().eq(0)),i=h.children().eq(1),j=h.children().eq(2);b.element(i.eq(0)[0]).attr("alt",a.beforeImageAlt),b.element(j.eq(0)[0]).attr("alt",a.afterImageAlt)}},this.getElement=function(){return g.$element},this.getSlider=function(){return g.slider}}]).directive("juxtapose",function(){var a=0,b="juxtapose";return{restrict:"EA",scope:{beforeImageUrl:"=",beforeImageLabel:"=?",beforeImageCredit:"=?",beforeImageAlt:"=?",afterImageUrl:"=",afterImageLabel:"=?",afterImageCredit:"=?",afterImageAlt:"=?",callback:"&?"},template:'<div class="juxtapose"></div>',replace:!0,controller:"JuxtaposeController",link:function(c,d,e,f){e.$set("id",b+"-"+a++),f.init(d)}}})}(window,window.angular);
//# sourceMappingURL=ng-juxtapose.min.js.map