diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..69fad35 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "bower_components" +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e717f5e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3018b3a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.tmp/ diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..741a4ef --- /dev/null +++ b/bower.json @@ -0,0 +1,37 @@ +{ + "name": "angular-ez-plus", + "version": "1.0.0", + "author": { + "name": "Igor Lino", + "url": "http://igorlino.github.io/angular-angular-elevatezoom-plus/" + }, + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + } + ], + "main": [ + "js/widget-ezplus-directive.js", + "images/loader-small.gif" + ], + "ignore": [ + "**/.*", + "node_modules", + "components" + ], + "bugs": "https://github.com/igorlino/angular-elevatezoom-plus/issues", + "homepage": "http://igorlino.github.io/angular-elevatezoom-plus/", + "docs" : "http://igorlino.github.io/angular-elevatezoom-plus/examples", + "demo" : "http://igorlino.github.io/angular-elevatezoom-plus/examples", + "dependencies": { + "jquery": "~2.1.1", + "angular": "~1.3.4" + }, + "devDependencies": { + }, + "resolutions": { + "jquery": "~2.1.1", + "angular": "~1.3.4" + } +} diff --git a/images/loader-small.GIF b/images/loader-small.GIF new file mode 100644 index 0000000..03c09e1 Binary files /dev/null and b/images/loader-small.GIF differ diff --git a/js/widget-ezplus-directive.js b/js/widget-ezplus-directive.js new file mode 100644 index 0000000..8070ccf --- /dev/null +++ b/js/widget-ezplus-directive.js @@ -0,0 +1,54 @@ +(function () { + 'use strict'; + + angular.module('ezplus') + .directive('ezPlus', ezPlus); + + function ezPlus() { + var service = { + restrict: 'A', + scope: { + ngModel: '=' + }, + link: link + }; + return service; + + //////////////////////////// + + + link.$inject = ['scope', 'element']; + function link(scope, element) { + scope.$watch('ngModel', function (image) { + var thumbMediumUrl = (image && image.thumbMediumUrl) || ''; + var fullSizeUrl = (image && image.fullSizeUrl) || ''; + + var plugin = angular.element(element).data('ezPlus'); + if (plugin) { + var loader = 'images/loader-small.gif'; + plugin.swaptheimage(loader, loader); + plugin.swaptheimage(thumbMediumUrl, fullSizeUrl); + } else if (image) { + element.attr('src', thumbMediumUrl); + element.attr('data-zoom-image', fullSizeUrl); + angular.element(element).elevateZoom({ + scrollZoom: true, + zoomWindowWidth: 600, + zoomWindowHeight: 600, + easing : true, + zoomWindowFadeIn: 500, + zoomWindowFadeOut: 500, + lensFadeIn: 500, + lensFadeOut: 500 + }); + } + }); + + scope.$on('$destroy', function () { + element.remove(); + }); + } + } + +}) +();