diff --git a/README.md b/README.md index 5686a3c..694abff 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ Default values in example. app.config(function(ionGalleryConfigProvider) { ionGalleryConfigProvider.setGalleryConfig({ action_label: 'Close', + template_gallery: 'gallery.html', + template_slider: 'slider.html', toggle: false, row_size: 3, fixed_row_size: true @@ -71,6 +73,8 @@ app.config(function(ionGalleryConfigProvider) { ``` Default values action_label - 'Close' (String) +template_gallery - 'gallery.html' (String) +template_slider - 'slider.html' (String) toggle - false (Boolean) row_size - 3 (Int) fixed_row_size - true (boolean). If true, thumbnails in gallery will always be sized as if there are "row_size" number of images in a row (even if there aren't). If set to false, the row_size will be dynamic until it reaches the set row_size (Ex: if only 1 image it will be rendered in the entire row, if 2 images, both will be rendered in the entire row) diff --git a/dist/ion-gallery.js b/dist/ion-gallery.js index 5edd032..5c918ca 100644 --- a/dist/ion-gallery.js +++ b/dist/ion-gallery.js @@ -20,7 +20,7 @@ controller: controller, link: link, replace: true, - templateUrl: 'gallery.html' + templateUrl: ionGalleryConfig.template_gallery }; function controller($scope) { @@ -66,6 +66,8 @@ function ionGalleryConfig(){ this.config = { action_label: 'Done', + template_gallery: 'gallery.html', + template_slider: 'slider.html', toggle: true, row_size: 3, fixed_row_size: true, @@ -278,9 +280,9 @@ .module('ion-gallery') .directive('ionSlider',ionSlider); - ionSlider.$inject = ['$ionicModal','$timeout','$ionicScrollDelegate','ionSliderHelper']; + ionSlider.$inject = ['$ionicModal','$timeout','$ionicScrollDelegate','ionSliderHelper','ionGalleryConfig']; - function ionSlider($ionicModal,$timeout,$ionicScrollDelegate,ionSliderHelper){ + function ionSlider($ionicModal,$timeout,$ionicScrollDelegate,ionSliderHelper,ionGalleryConfig){ controller.$inject = ["$scope"]; return { @@ -430,7 +432,7 @@ function link(scope, element, attrs) { var _modal; - $ionicModal.fromTemplateUrl('slider.html', { + $ionicModal.fromTemplateUrl(ionGalleryConfig.template_slider, { scope: scope, animation: 'fade-in' }).then(function(modal){ diff --git a/dist/ion-gallery.min.js b/dist/ion-gallery.min.js index 04668cb..15bdd1b 100644 --- a/dist/ion-gallery.min.js +++ b/dist/ion-gallery.min.js @@ -1 +1 @@ -!function(){"use strict";function n(n,e,i){function o(n){var o=parseInt(n.ionGalleryRowSize),t=function(){n.ionGalleryRowSize=e.getRowSize(o||i.row_size,n.ionGalleryItems.length),n.actionLabel=i.action_label,n.items=e.buildGallery(n.ionGalleryItems,n.ionGalleryRowSize),n.responsiveGrid=parseInt(1/n.ionGalleryRowSize*100)};t(),function(){n.$watch(function(){return n.ionGalleryItems.length},function(n,e){n!==e&&t()})}()}function t(n,e,o){n.customItemAction=angular.isFunction(n.ionItemAction)&&o.hasOwnProperty("ionItemAction"),n.ionSliderToggle="false"===o.ionGalleryToggle?!1:i.toggle}return o.$inject=["$scope"],{restrict:"AE",scope:{ionGalleryItems:"=ionGalleryItems",ionGalleryRowSize:"=?ionGalleryRow",ionItemAction:"&?ionItemAction",ionZoomEvents:"=?ionZoomEvents"},controller:o,link:t,replace:!0,templateUrl:"gallery.html"}}angular.module("ion-gallery",["templates"]).directive("ionGallery",n),n.$inject=["$ionicPlatform","ionGalleryHelper","ionGalleryConfig"]}(),function(){"use strict";function n(){this.config={action_label:"Done",toggle:!0,row_size:3,fixed_row_size:!0,zoom_events:!0},this.$get=function(){return this.config},this.setGalleryConfig=function(n){angular.extend(this.config,this.config,n)}}angular.module("ion-gallery").provider("ionGalleryConfig",n),n.$inject=[]}(),function(){"use strict";function n(n){this.getRowSize=function(e,i){var o;return o=isNaN(e)===!0||0>=e?n.row_size:e>i&&!n.fixed_row_size?i:e},this.buildGallery=function(n,e){for(var i=[],o=-1,t=0,l=0;l0&&(n.naturalHeight>=n.naturalWidth?e.attr("width","100%"):e.attr("height",e.parent()[0].offsetHeight+"px"))};e.bind("load",function(i){var t=this;e.parent()[0].offsetHeight>0&&o(this,e.parent()[0].offsetHeight),n.$watch(function(){return e.parent()[0].offsetHeight},function(n){o(t,n)})})}return{restrict:"A",link:n}}angular.module("ion-gallery").directive("ionImageScale",n),n.$inject=[]}(),function(){"use strict";function n(n){function e(n,e,i){n.$watch(function(){return n.ionGalleryRowSize},function(i,o){i>0&&e.css("height",e[0].offsetWidth*parseInt(n.responsiveGrid)/100+"px")})}return{restrict:"A",link:e}}angular.module("ion-gallery").directive("ionRowHeight",n),n.$inject=["ionGalleryConfig"]}(),function(){"use strict";function n(n,e){function i(i,o,t){var l=!1,r=function(){i.$emit("ZoomStarted")},s=function(n){l=!0,e(function(){l=!1,i.$emit("DoubleTapEvent",{x:n.gesture.touches[0].pageX,y:n.gesture.touches[0].pageY})},200)},a=function(n){l!==!0&&e(function(){l!==!0&&i.$emit("TapEvent")},200)},c=n.on("pinch",r,o),u=n.on("doubletap",function(n){s(n)},o),d=n.on("tap",a,o);i.$on("$destroy",function(){n.off(u,"doubletap",s),n.off(d,"tap",a),n.off(c,"pinch",r)})}return{restrict:"A",link:i}}angular.module("ion-gallery").directive("ionSlideAction",n),n.$inject=["$ionicGesture","$timeout"]}(),function(){"use strict";function n(n,e,i,o){function t(n){function t(){s=!1,a()}var l,r,s=(n.ionGalleryRowSize,!1);n.selectedSlide=1,n.hideAll=!1,n.ionZoomEvents=o.setZoomEvents(n.ionZoomEvents),n.openSlider=function(e){n.slides=[],r=e;var i=n.ionGalleryItems.length,o=0>e-1?i-1:e-1,t=e+1>=i?0:e+1;n.slides[0]=n.ionGalleryItems[o],n.slides[1]=n.ionGalleryItems[e],n.slides[2]=n.ionGalleryItems[t],l=1,n.openModal()},n.slideChanged=function(e){if(e!==l){var o,t=n.slides.length-l-e,s=n.ionGalleryItems.length,a=l+">"+e;"0>1"===a||"1>2"===a||"2>0"===a?(r++,r>=s&&(r=0),o=r+1,o>=s&&(o=0)):("0>2"===a||"1>0"===a||"2>1"===a)&&(r--,0>r&&(r=s-1),o=r-1,0>o&&(o=s-1)),n.ionZoomEvents===!0&&i.$getByHandle("slide-"+t).zoomTo(1),n.slides[t]=n.ionGalleryItems[o],l=e}},n.$on("ZoomStarted",function(i){e(function(){s=!0,n.hideAll=!0})}),n.$on("TapEvent",function(n){e(function(){a()})}),n.$on("DoubleTapEvent",function(n,i){e(function(){c(i)})});var a=function(){return s===!0?(n.ionZoomEvents===!0&&i.$getByHandle("slide-"+l).zoomTo(1,!0),void e(function(){t()},300)):void(n.hasOwnProperty("ionSliderToggle")&&n.ionSliderToggle===!1&&n.hideAll===!1||s===!0||(n.hideAll=!n.hideAll))},c=function(e){s===!1?(n.ionZoomEvents===!0&&i.$getByHandle("slide-"+l).zoomTo(3,!0,e.x,e.y),s=!0,n.hideAll=!0):a()}}function l(e,i,o){var t;n.fromTemplateUrl("slider.html",{scope:e,animation:"fade-in"}).then(function(n){t=n}),e.openModal=function(){t.show()},e.closeModal=function(){t.hide()},e.$on("$destroy",function(){try{t.remove()}catch(n){}})}return t.$inject=["$scope"],{restrict:"A",controller:t,link:l}}angular.module("ion-gallery").directive("ionSlider",n),n.$inject=["$ionicModal","$timeout","$ionicScrollDelegate","ionSliderHelper"]}(),function(){"use strict";function n(n){this.setZoomEvents=function(e){return e===!1&&(n.zoom_events=!1),n.zoom_events}}angular.module("ion-gallery").service("ionSliderHelper",n),n.$inject=["ionGalleryConfig"]}(),angular.module("templates",[]).run(["$templateCache",function(n){n.put("gallery.html",'\n'),n.put("slider.html",'\n \n \n \n\n \n \n \n \n \n
\n \n
\n
\n
\n
\n
\n
\n')}]); \ No newline at end of file +!function(){"use strict";function n(n,e,i){function o(n){var o=parseInt(n.ionGalleryRowSize),t=function(){n.ionGalleryRowSize=e.getRowSize(o||i.row_size,n.ionGalleryItems.length),n.actionLabel=i.action_label,n.items=e.buildGallery(n.ionGalleryItems,n.ionGalleryRowSize),n.responsiveGrid=parseInt(1/n.ionGalleryRowSize*100)};t(),function(){n.$watch(function(){return n.ionGalleryItems.length},function(n,e){n!==e&&t()})}()}function t(n,e,o){n.customItemAction=angular.isFunction(n.ionItemAction)&&o.hasOwnProperty("ionItemAction"),n.ionSliderToggle="false"===o.ionGalleryToggle?!1:i.toggle}return o.$inject=["$scope"],{restrict:"AE",scope:{ionGalleryItems:"=ionGalleryItems",ionGalleryRowSize:"=?ionGalleryRow",ionItemAction:"&?ionItemAction",ionZoomEvents:"=?ionZoomEvents"},controller:o,link:t,replace:!0,templateUrl:i.template_gallery}}angular.module("ion-gallery",["templates"]).directive("ionGallery",n),n.$inject=["$ionicPlatform","ionGalleryHelper","ionGalleryConfig"]}(),function(){"use strict";function n(){this.config={action_label:"Done",template_gallery:"gallery.html",template_slider:"slider.html",toggle:!0,row_size:3,fixed_row_size:!0,zoom_events:!0},this.$get=function(){return this.config},this.setGalleryConfig=function(n){angular.extend(this.config,this.config,n)}}angular.module("ion-gallery").provider("ionGalleryConfig",n),n.$inject=[]}(),function(){"use strict";function n(n){this.getRowSize=function(e,i){var o;return o=isNaN(e)===!0||0>=e?n.row_size:e>i&&!n.fixed_row_size?i:e},this.buildGallery=function(n,e){for(var i=[],o=-1,t=0,l=0;l0&&(n.naturalHeight>=n.naturalWidth?e.attr("width","100%"):e.attr("height",e.parent()[0].offsetHeight+"px"))};e.bind("load",function(i){var t=this;e.parent()[0].offsetHeight>0&&o(this,e.parent()[0].offsetHeight),n.$watch(function(){return e.parent()[0].offsetHeight},function(n){o(t,n)})})}return{restrict:"A",link:n}}angular.module("ion-gallery").directive("ionImageScale",n),n.$inject=[]}(),function(){"use strict";function n(n){function e(n,e,i){n.$watch(function(){return n.ionGalleryRowSize},function(i,o){i>0&&e.css("height",e[0].offsetWidth*parseInt(n.responsiveGrid)/100+"px")})}return{restrict:"A",link:e}}angular.module("ion-gallery").directive("ionRowHeight",n),n.$inject=["ionGalleryConfig"]}(),function(){"use strict";function n(n,e){function i(i,o,t){var l=!1,r=function(){i.$emit("ZoomStarted")},s=function(n){l=!0,e(function(){l=!1,i.$emit("DoubleTapEvent",{x:n.gesture.touches[0].pageX,y:n.gesture.touches[0].pageY})},200)},a=function(n){l!==!0&&e(function(){l!==!0&&i.$emit("TapEvent")},200)},c=n.on("pinch",r,o),u=n.on("doubletap",function(n){s(n)},o),d=n.on("tap",a,o);i.$on("$destroy",function(){n.off(u,"doubletap",s),n.off(d,"tap",a),n.off(c,"pinch",r)})}return{restrict:"A",link:i}}angular.module("ion-gallery").directive("ionSlideAction",n),n.$inject=["$ionicGesture","$timeout"]}(),function(){"use strict";function n(n,e,i,o,t){function l(n){function t(){s=!1,a()}var l,r,s=(n.ionGalleryRowSize,!1);n.selectedSlide=1,n.hideAll=!1,n.ionZoomEvents=o.setZoomEvents(n.ionZoomEvents),n.openSlider=function(e){n.slides=[],r=e;var i=n.ionGalleryItems.length,o=0>e-1?i-1:e-1,t=e+1>=i?0:e+1;n.slides[0]=n.ionGalleryItems[o],n.slides[1]=n.ionGalleryItems[e],n.slides[2]=n.ionGalleryItems[t],l=1,n.openModal()},n.slideChanged=function(e){if(e!==l){var o,t=n.slides.length-l-e,s=n.ionGalleryItems.length,a=l+">"+e;"0>1"===a||"1>2"===a||"2>0"===a?(r++,r>=s&&(r=0),o=r+1,o>=s&&(o=0)):"0>2"!==a&&"1>0"!==a&&"2>1"!==a||(r--,0>r&&(r=s-1),o=r-1,0>o&&(o=s-1)),n.ionZoomEvents===!0&&i.$getByHandle("slide-"+t).zoomTo(1),n.slides[t]=n.ionGalleryItems[o],l=e}},n.$on("ZoomStarted",function(i){e(function(){s=!0,n.hideAll=!0})}),n.$on("TapEvent",function(n){e(function(){a()})}),n.$on("DoubleTapEvent",function(n,i){e(function(){c(i)})});var a=function(){return s===!0?(n.ionZoomEvents===!0&&i.$getByHandle("slide-"+l).zoomTo(1,!0),void e(function(){t()},300)):void(n.hasOwnProperty("ionSliderToggle")&&n.ionSliderToggle===!1&&n.hideAll===!1||s===!0||(n.hideAll=!n.hideAll))},c=function(e){s===!1?(n.ionZoomEvents===!0&&i.$getByHandle("slide-"+l).zoomTo(3,!0,e.x,e.y),s=!0,n.hideAll=!0):a()}}function r(e,i,o){var l;n.fromTemplateUrl(t.template_slider,{scope:e,animation:"fade-in"}).then(function(n){l=n}),e.openModal=function(){l.show()},e.closeModal=function(){l.hide()},e.$on("$destroy",function(){try{l.remove()}catch(n){}})}return l.$inject=["$scope"],{restrict:"A",controller:l,link:r}}angular.module("ion-gallery").directive("ionSlider",n),n.$inject=["$ionicModal","$timeout","$ionicScrollDelegate","ionSliderHelper","ionGalleryConfig"]}(),function(){"use strict";function n(n){this.setZoomEvents=function(e){return e===!1&&(n.zoom_events=!1),n.zoom_events}}angular.module("ion-gallery").service("ionSliderHelper",n),n.$inject=["ionGalleryConfig"]}(),angular.module("templates",[]).run(["$templateCache",function(n){n.put("gallery.html",'\n'),n.put("slider.html",'\n \n \n \n\n \n \n \n \n \n
\n \n
\n
\n
\n
\n
\n
\n')}]); \ No newline at end of file diff --git a/src/js/gallery.js b/src/js/gallery.js index 937fb79..79f6ec3 100644 --- a/src/js/gallery.js +++ b/src/js/gallery.js @@ -19,7 +19,7 @@ controller: controller, link: link, replace: true, - templateUrl: 'gallery.html' + templateUrl: ionGalleryConfig.template_gallery }; function controller($scope) { diff --git a/src/js/galleryConfig.js b/src/js/galleryConfig.js index e893098..639129a 100644 --- a/src/js/galleryConfig.js +++ b/src/js/galleryConfig.js @@ -10,6 +10,8 @@ function ionGalleryConfig(){ this.config = { action_label: 'Done', + template_gallery: 'gallery.html', + template_slider: 'slider.html', toggle: true, row_size: 3, fixed_row_size: true, diff --git a/src/js/slider.js b/src/js/slider.js index e23254f..d709763 100644 --- a/src/js/slider.js +++ b/src/js/slider.js @@ -5,9 +5,9 @@ .module('ion-gallery') .directive('ionSlider',ionSlider); - ionSlider.$inject = ['$ionicModal','$timeout','$ionicScrollDelegate','ionSliderHelper']; + ionSlider.$inject = ['$ionicModal','$timeout','$ionicScrollDelegate','ionSliderHelper','ionGalleryConfig']; - function ionSlider($ionicModal,$timeout,$ionicScrollDelegate,ionSliderHelper){ + function ionSlider($ionicModal,$timeout,$ionicScrollDelegate,ionSliderHelper,ionGalleryConfig){ return { restrict: 'A', @@ -156,7 +156,7 @@ function link(scope, element, attrs) { var _modal; - $ionicModal.fromTemplateUrl('slider.html', { + $ionicModal.fromTemplateUrl(ionGalleryConfig.template_slider, { scope: scope, animation: 'fade-in' }).then(function(modal){