///////////////////////////////////// ///////////////////////////////////// !function(t,e){"function"==typeof define&&define.amd?define([],e()):"object"==typeof module&&module.exports?module.exports=e():function n(){document&&document.body?t.zenscroll=e():setTimeout(n,9)}()}(this,function(){"use strict";var t=function(t){return t&&"getComputedStyle"in window&&"smooth"===window.getComputedStyle(t)["scroll-behavior"]};if("undefined"==typeof window||!("document"in window))return{};var e=function(e,n,o){n=n||999,o||0===o||(o=9);var i,r=function(t){i=t},u=function(){clearTimeout(i),r(0)},c=function(t){return Math.max(0,e.getTopOf(t)-o)},a=function(o,i,c){if(u(),0===i||i&&i<0||t(e.body))e.toY(o),c&&c();else{var a=e.getY(),f=Math.max(0,o)-a,s=(new Date).getTime();i=i||Math.min(Math.abs(f),n),function t(){r(setTimeout(function(){var n=Math.min(1,((new Date).getTime()-s)/i),o=Math.max(0,Math.floor(a+f*(n<.5?2*n*n:n*(4-2*n)-1)));e.toY(o),n<1&&e.getHeight()+os?f(t,n,i):u+o>d?a(u-s+o,n,i):i&&i()},l=function(t,n,o,i){a(Math.max(0,e.getTopOf(t)-e.getHeight()/2+(o||t.getBoundingClientRect().height/2)),n,i)};return{setup:function(t,e){return(0===t||t)&&(n=t),(0===e||e)&&(o=e),{defaultDuration:n,edgeOffset:o}},to:f,toY:a,intoView:s,center:l,stop:u,moving:function(){return!!i},getY:e.getY,getTopOf:e.getTopOf}},n=document.documentElement,o=function(){return window.scrollY||n.scrollTop},i=e({body:document.scrollingElement||document.body,toY:function(t){window.scrollTo(0,t)},getY:o,getHeight:function(){return window.innerHeight||n.clientHeight},getTopOf:function(t){return t.getBoundingClientRect().top+o()-n.offsetTop}});if(i.createScroller=function(t,o,i){return e({body:t,toY:function(e){t.scrollTop=e},getY:function(){return t.scrollTop},getHeight:function(){return Math.min(t.clientHeight,window.innerHeight||n.clientHeight)},getTopOf:function(t){return t.offsetTop}},o,i)},"addEventListener"in window&&!window.noZensmooth&&!t(document.body)){var r="history"in window&&"pushState"in history,u=r&&"scrollRestoration"in history;u&&(history.scrollRestoration="auto"),window.addEventListener("load",function(){u&&(setTimeout(function(){history.scrollRestoration="manual"},9),window.addEventListener("popstate",function(t){t.state&&"zenscrollY"in t.state&&i.toY(t.state.zenscrollY)},!1)),window.location.hash&&setTimeout(function(){var t=i.setup().edgeOffset;if(t){var e=document.getElementById(window.location.href.split("#")[1]);if(e){var n=Math.max(0,i.getTopOf(e)-t),o=i.getY()-n;0<=o&&o<9&&window.scrollTo(0,n)}}},9)},!1);var c=new RegExp("(^|\\s)noZensmooth(\\s|$)");window.addEventListener("click",function(t){for(var e=t.target;e&&"A"!==e.tagName;)e=e.parentNode;if(!(!e||1!==t.which||t.shiftKey||t.metaKey||t.ctrlKey||t.altKey)){if(u){var n=history.state&&"object"==typeof history.state?history.state:{};n.zenscrollY=i.getY();try{history.replaceState(n,"")}catch(t){}}var o=e.getAttribute("href")||"";if(0===o.indexOf("#")&&!c.test(e.className)){var a=0,f=document.getElementById(o.substring(1));if("#"!==o){if(!f)return;a=i.getTopOf(f)}t.preventDefault();var s=function(){window.location=o},l=i.setup().edgeOffset;l&&(a=Math.max(0,a-l),r&&(s=function(){history.pushState({},"",o)})),i.toY(a,null,s)}}},!1)}return i});///////////////////////////////////// ///////////////////////////////////// angular.module("angularLazyImg",[]),angular.module("angularLazyImg").factory("LazyImgMagic",["$window","$rootScope","lazyImgConfig","lazyImgHelpers",function(n,e,t,o){"use strict";function r(){for(var n=y.length-1;n>=0;n--){var e=y[n];e&&o.isElementInView(e.$elem[0],p.offset,m)&&(u(e),y.splice(n,1))}y.length||s()}function i(n){z.forEach(function(e){e[n]("scroll",I),e[n]("touchmove",I)}),f[n]("resize",I),f[n]("resize",d)}function a(){h=!0,setTimeout(function(){r(),i("on")},1)}function s(){h=!1,i("off")}function c(n){var e=y.indexOf(n);-1!==e&&y.splice(e,1)}function u(n){var t=new Image;t.onerror=function(){p.errorClass&&n.$elem.addClass(p.errorClass),n.errorSrc&&l(n.$elem,n.errorSrc),e.$apply(function(){e.$emit("lazyImg:error",n),p.onError(n)})},t.onload=function(){l(n.$elem,n.src),p.successClass&&n.$elem.addClass(p.successClass),e.$apply(function(){e.$emit("lazyImg:success",n),p.onSuccess(n)})},t.src=n.src}function l(n,e){"img"===n[0].nodeName.toLowerCase()?n[0].src=e:n.css("background-image",'url("'+e+'")')}function g(n){this.$elem=n}var m,f,y,h,p,I,d,z;return y=[],h=!1,p=t.getOptions(),f=angular.element(n),m=o.getWinDimensions(),d=o.throttle(function(){m=o.getWinDimensions()},60),p.container=p.containers||p.container,z=p.container?[].concat(p.container):[f],I=o.throttle(r,30),g.prototype.setSource=function(n){this.src=n,y.unshift(this),a()},g.prototype.setErrorSource=function(n){this.errorSrc=n},g.prototype.removeImage=function(){c(this),y.length||s()},g.prototype.checkImages=r,g.addContainer=function(n){s(),z.push(n),a()},g.removeContainer=function(n){s(),z.splice(z.indexOf(n),1),a()},g}]),angular.module("angularLazyImg").provider("lazyImgConfig",function(){"use strict";this.options={offset:100,errorClass:null,successClass:null,onError:function(){},onSuccess:function(){}},this.$get=function(){var n=this.options;return{getOptions:function(){return n}}},this.setOptions=function(n){angular.extend(this.options,n)}}),angular.module("angularLazyImg").factory("lazyImgHelpers",["$window",function(n){"use strict";return{isElementInView:function(n,e,t){var o=n.getBoundingClientRect();return o.left<=t.width+e&&o.right>=0-e&&o.top<=t.height+e&&o.bottom>=0-e},getWinDimensions:function(){return{height:n.innerHeight,width:n.innerWidth}},throttle:function(n,e,t){var o,r;return function(){var i=t||this,a=+new Date,s=arguments;o&&a=k?h():g.set(l/k)),a):(f.error("Broken interceptor detected: Config object not supplied in response:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),a)},responseError:function(a){return a&&a.config?(a.config.ignoreLoadingBar||i(a.config)||(l++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url,result:a}),l>=k?h():g.set(l/k)),b.reject(a)):(f.error("Broken interceptor detected: Config object not supplied in rejection:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),b.reject(a))}}}];a.interceptors.push(b)}]),angular.module("cfp.loadingBar",[]).provider("cfpLoadingBar",function(){this.autoIncrement=!0,this.includeSpinner=!0,this.includeBar=!0,this.latencyThreshold=100,this.startSize=.02,this.parentSelector="body",this.spinnerTemplate='
',this.loadingBarTemplate='
',this.$get=["$injector","$document","$timeout","$rootScope",function(a,b,c,d){function e(){if(k||(k=a.get("$animate")),c.cancel(m),!r){var e=b[0],g=e.querySelector?e.querySelector(n):b.find(n)[0];g||(g=e.getElementsByTagName("body")[0]);var h=angular.element(g),i=g.lastChild&&angular.element(g.lastChild);d.$broadcast("cfpLoadingBar:started"),r=!0,v&&k.enter(o,h,i),u&&k.enter(q,h,o),f(w)}}function f(a){if(r){var b=100*a+"%";p.css("width",b),s=a,t&&(c.cancel(l),l=c(function(){g()},250))}}function g(){if(!(h()>=1)){var a=0,b=h();a=b>=0&&.25>b?(3*Math.random()+3)/100:b>=.25&&.65>b?3*Math.random()/100:b>=.65&&.9>b?2*Math.random()/100:b>=.9&&.99>b?.005:0;var c=h()+a;f(c)}}function h(){return s}function i(){s=0,r=!1}function j(){k||(k=a.get("$animate")),d.$broadcast("cfpLoadingBar:completed"),f(1),c.cancel(m),m=c(function(){var a=k.leave(o,i);a&&a.then&&a.then(i),k.leave(q)},500)}var k,l,m,n=this.parentSelector,o=angular.element(this.loadingBarTemplate),p=o.find("div").eq(0),q=angular.element(this.spinnerTemplate),r=!1,s=0,t=this.autoIncrement,u=this.includeSpinner,v=this.includeBar,w=this.startSize;return{start:e,set:f,status:h,inc:g,complete:j,autoIncrement:this.autoIncrement,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector,startSize:this.startSize}}]})}();///////////////////////////////////// !function(){"use strict";var t="angular-inview";function e(t){return angular.isArray(t)?2==t.length?t.concat(t):3==t.length?t.concat([t[1]]):t:[t,t,t,t]}function n(t,e){if(!e)return t;var n=i(e[0])?parseFloat(e[0])*t.height/100:e[0],o=i(e[1])?parseFloat(e[1])*t.width/100:e[1],r=i(e[2])?parseFloat(e[2])*t.height/100:e[2],u=i(e[3])?parseFloat(e[3])*t.width/100:e[3];return{top:t.top-n,left:t.left-u,bottom:t.bottom+r,right:t.right+o,height:t.height+n+r,width:t.width+u+o}}function i(t){return angular.isString(t)&&t.indexOf("%")>0}function o(t){this.didSubscribeFunc=t}function r(t,e){return new o(function(n){var i=function(t){n(t)},o=angular.element(t);e.split(" ").map(t=>o[0].addEventListener(t,i,!0)),n.$dispose=function(){e.split(" ").map(t=>o[0].removeEventListener(t,i,!0))}})}angular.module(t,[]).directive("inView",["$parse",function(t){return{restrict:"A",require:"?^^inViewContainer",link:function(i,u,c,s){var l={};c.inViewOptions&&(l=i.$eval(c.inViewOptions)),l.offset&&(l.offset=e(l.offset)),l.viewportOffset&&(l.viewportOffset=e(l.viewportOffset));var a,f=(a={type:"initial"},new o(function(t){setTimeout(function(){t(a)})})).merge(r(window,"checkInView click ready wheel mousewheel DomMouseScroll MozMousePixelScroll resize scroll touchmove mouseup keydown"));s&&(f=f.merge(s.eventsSignal)),l.throttle&&(f=f.throttle(l.throttle));var p=f.map(function(t){var e;e=n(e=s?s.getViewportRect():function(){var t={top:0,left:0,width:window.innerWidth,right:window.innerWidth,height:window.innerHeight,bottom:window.innerHeight};if(t.height)return t;"CSS1Compat"===document.compatMode?(t.width=t.right=document.documentElement.clientWidth,t.height=t.bottom=document.documentElement.clientHeight):(t.width=t.right=document.body.clientWidth,t.height=t.bottom=document.body.clientHeight);return t}(),l.viewportOffset);var i,o,r=n(u[0].getBoundingClientRect(),l.offset),c=!!(u[0].offsetWidth||u[0].offsetHeight||u[0].getClientRects().length),a={inView:c&&(i=r,o=e,!(o.left>i.right||o.righti.bottom||o.bottom=e.top,a.parts.left=r.left>=e.left,a.parts.bottom=r.bottom<=e.bottom,a.parts.right=r.right<=e.right),a}).scan({},function(t,e){return l.generateDirection&&e.inView&&t.elementRect&&(e.direction={horizontal:e.elementRect.left-t.elementRect.left,vertical:e.elementRect.top-t.elementRect.top}),e.changed=e.inView!==t.inView||!angular.equals(e.parts,t.parts)||!angular.equals(e.direction,t.direction),e}).filter(function(t){return!!t.changed&&!("initial"===t.event.type&&!t.inView)}),h=t(c.inView),d=p.subscribe(function(t){i.$applyAsync(function(){h(i,{$inview:t.inView,$inviewInfo:t})})});i.$on("$destroy",d)}}}]).directive("inViewContainer",function(){return{restrict:"A",controller:["$element",function(t){this.element=t,this.eventsSignal=r(t,"scroll"),this.getViewportRect=function(){return t[0].getBoundingClientRect()}}]}}),o.prototype.subscribe=function(t){this.didSubscribeFunc(t);return function(){t.$dispose&&(t.$dispose(),t.$dispose=null)}},o.prototype.map=function(t){var e=this;return new o(function(n){n.$dispose=e.subscribe(function(e){n(t(e))})})},o.prototype.filter=function(t){var e=this;return new o(function(n){n.$dispose=e.subscribe(function(e){t(e)&&n(e)})})},o.prototype.scan=function(t,e){var n=this;return new o(function(i){var o=t;i.$dispose=n.subscribe(function(t){o=e(o,t),i(o)})})},o.prototype.merge=function(t){return function(){var t=arguments;return new o(function(e){for(var n=[],i=t.length-1;i>=0;i--)n.push(t[i].subscribe(function(){e.apply(null,arguments)}));e.$dispose=function(){for(var t=n.length-1;t>=0;t--)n[t]&&n[t]()}})}(this,t)},o.prototype.throttle=function(t){var e,n,i=this;return new o(function(o){var r=i.subscribe(function(){var i=+new Date,r=arguments;e&&i>16)+(t>>16)+(r>>16)<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)]=r;var e,i,a,d,h,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e>5]>>>t%32&255);return r}function d(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(o=i(o,8*n.length)),r=0;r<16;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(d(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="";for(r=0;r>>4&15)+"0123456789abcdef".charAt(15&t);return e}function v(n){return unescape(encodeURIComponent(n))}function m(n){return h(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}"function"==typeof define&&define.amd?define(function(){return A}):"object"==typeof module&&module.exports?module.exports=A:n.md5=A}(this); ///////////////////////////////////// var restApiRoot='/wp-json/wp/v2/'; var apiRoot=wp_template_dir+'/functions/api.php?get='; var apiRoot= '/api/?get='; var timeZone; var widgetAnim; var app = angular.module("mullerApp", ['ngRoute','angular-loading-bar','angular-inview','angularLazyImg','cfp.loadingBar']) .config( [ '$compileProvider', function( $compileProvider ) { $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|whatsapp|mailto|chrome-extension):/); } ]) .config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) { cfpLoadingBarProvider.includeSpinner = false; }]) .run(['$rootScope', '$location',function ($rootScope, $location) { $rootScope.$on('$routeChangeStart', function (event, next, current) { angular.element(document.querySelector('.page')).removeClass('on'); }); }]) .config(['lazyImgConfigProvider', function(lazyImgConfigProvider){ lazyImgConfigProvider.setOptions({ successClass: 'loaded' }); }]) .config(['$locationProvider','$routeProvider', function($locationProvider,$routeProvider) { $routeProvider .when("/", { //templateUrl: wp_template_dir+'/templates/main-page.html', templateUrl: 'main-page.html', controller:'appCtrl' }) .when("/:post_type", { template: '', controller:'appCtrl' }) .when("/:post_type/:slug", { template: '', template: '', controller:'appCtrl' }) $locationProvider.html5Mode(true); }]) .service('apiService', ['$http', function($http) { this.callApi = function (api,method,data,action,callBack) { var options={ method : method, url : api, data : data, headers : { 'Content-Type': 'application/x-www-form-urlencoded' } }; if(action)options.headers={ 'Content-Type': 'application/x-www-form-urlencoded' ,"action": action}; $http(options).then(function mySucces(response) { if(callBack)callBack(response); }, function myError(response) { }); } }]) /*.controller('mainCtrl', function($scope, $routeParams ) { //console.log($routeParams) $scope.wp_template_dir=wp_template_dir; angular.element(document.querySelector('.page')).addClass('on'); $scope.tips_titles={}; }) */ .controller('timeZoneCtrl',['$scope' ,'apiService','$filter','$timeout','$rootScope','$route','$window' , function($scope ,apiService,$filter,$timeout,$rootScope,$route,$window ) { $scope.setTimeZone=function(t,l){ if(l){ $scope.timeZone=t; return; } apiService.callApi(apiRoot+'set_time@t='+t,'GET','','',function(response){ $scope.timeZone=t; /// $rootScope.$broadcast('timeZone',t); }); } }]) .controller('appCtrl', ['$scope', '$routeParams','apiService','$filter','$timeout','$rootScope' ,'cfpLoadingBar','$window',function($scope, $routeParams,apiService,$filter,$timeout,$rootScope ,cfpLoadingBar,$window) { angular.element(document.querySelector('.component ')).attr('id','') $scope.wp_template_dir=wp_template_dir; $scope.products_all=true; $rootScope.page_title='תודה לטבע - Müller'; if($routeParams.post_type){ var templatePage = $filter('filter')(JSON.parse(post_types), function (d) {return d.slug ===$routeParams.post_type;})[0]; if(templatePage){ api=apiRoot+templatePage.name; templateName = 'archive-'+templatePage.name; if($routeParams.slug&&$routeParams.slug!='הכל'){ angular.element(document.querySelector('.component ')).attr('id','c_'+md5($routeParams.post_type+$routeParams.slug)) api=apiRoot+templatePage.name+'/?slug='+$routeParams.slug; templateName = 'single-'+templatePage.name; }else{ angular.element(document.querySelector('.component ')).attr('id','c_'+md5($routeParams.post_type)) } if($routeParams.slug==='הכל')$scope.products_all=true; }else{ var templateName='page'; var templatePage = $filter('filter')(JSON.parse(page_templates), function (d) {return d.slug === encodeURI($routeParams.post_type).toLowerCase();})[0]; if(templatePage) templateName=templatePage.template; var api=apiRoot+'pages'+'/@template='+templateName+'^slug='+$routeParams.post_type; angular.element(document.querySelector('.component ')).attr('id','c_'+md5($routeParams.post_type)) } document.querySelector('body').dataset.page=md5($routeParams.post_type); $scope.templateUrl= templateName+'.html' ; //$scope.templateUrl= wp_template_dir+'/templates/'+templateName+'.html' ; apiService.callApi(api,'GET','','',function(response){ //console.log(document.querySelector('.page')) angular.element(document.querySelector('.page')).addClass('on'); $scope.mainData=response.data; var subtitle=$scope.mainData.subtitle?$scope.mainData.subtitle:''; $rootScope.page_title='תודה לטבע - Müller - '+$scope.mainData.title+ ' '+subtitle; //console.log($scope.mainData) var defaultDuration = 333 ; var edgeOffset = 0; zenscroll.setup(defaultDuration, edgeOffset); zenscroll.toY(0); $scope.clearRecipesFilter(); if($routeParams.post_type=='מאמרים'&&!$routeParams.slug) $scope.sortArticles($scope.timeZone); }) } else{ angular.element(document.querySelector('.component ')).attr('id','home') angular.element(document.querySelector('.page')).addClass('on'); $scope.tips_titles={}; } $scope.getMoodProducts=function(term_id){ cfpLoadingBar.start(); var p=$filter('filter')($scope.mainData.moods, function (d) {return d.term_id ===term_id;})[0].pids; var products=$scope.mainData.products.filter(function(e){ if(inArray(e.ID,p)) return e }) $scope.mood={}; $scope.mood.moodProducts=products; $scope.mood.name=$filter('filter')($scope.mainData.moods, function (d) {return d.term_id ===term_id;})[0].name;; $scope.mood.text=$filter('filter')($scope.mainData.moods, function (d) {return d.term_id ===term_id;})[0].text;; $timeout(function(){$rootScope.$emit('lazyImg:refresh');cfpLoadingBar.complete()},400) } $scope.setRecipesFilter=function(d,i){ $scope.noResults=false; $scope.recipesFilterd=$scope.mainData.recipes; $scope.recipeFilter[i]=d; $scope.showClear=true; var fields=['time_zone_id','term_id','difficulty_level','product_id']; for(i=0;i<4;i++){ if($scope.recipeFilter[i]){ $scope.recipesFilterd=$scope.recipesFilterd.filter(function(e){ switch(i){ case 0:case 1: if(inArray($scope.recipeFilter[i].term_id,e[fields[i]]))return e; break; case 3: if(inArray(e[fields[i]],$scope.recipeFilter[i].ids))return e; break; default: if(e[fields[i]]==$scope.recipeFilter[i].term_id)return e; } }) } } if($scope.recipesFilterd.length===0){ $scope.noResults=true; $scope.recipesFilterd= $scope.mainData.recipes.sort(function(a, b){return 0.5 - Math.random()}).slice(0,6); } } $scope.clearRecipesFilter=function(){ $scope.recipesFilterd=$scope.mainData.recipes; $scope.recipeFilter=[]; $scope.recipeFilterOpend=[] $scope.showClear=false; $scope.noResults=false; } $scope.openFilter=function(n){ var isOpen=$scope.recipeFilterOpend[n]; $scope.recipeFilterOpend=[] if(!isOpen) $scope.recipeFilterOpend[n]=true; } $scope.getTermNames=function(id){ var rt=[]; for(i=0;i'+c[i].name+''); for(i=0;i'+c[i].name+''); return rt.join(' / '); } var appWindow = angular.element($window); appWindow.bind('resize', function () { $scope.setSize(); $scope.$apply(); }); $scope.setSize=function(){ switch(true){ case $window.innerWidth<=1023: $scope.device='mobile'; $scope.isMobile=true; $rootScope.device='mobile'; break; case $window.innerWidth>1023: $scope.device='desktop'; $scope.isMobile=false; $rootScope.device='web'; break; } } $scope.setSize(); $scope.goToProductCat=function(e){ e.preventDefault; $scope.mainData.catOpen=false; var offset= (window.innerHeight/100)*8; zenscroll.setup(300,offset) zenscroll.to(document.getElementById('prod_cat_'+e)) return false; } $scope.sortArticles=function(t){ if(!$scope.mainData)return; var lasts=[]; var firsts=$scope.mainData.articles.filter(function(e){ if(inArray(t,e.time_zones)){ return e; }else{ lasts.push(e); } }).sort(function(a,b) {return (a.stamp > b.stamp) ? 1 : ((b.stamp > a.stamp) ? -1 : 0);} ).reverse() lasts=lasts.sort(function(a,b) {return (a.stamp > b.stamp) ? 1 : ((b.stamp > a.stamp) ? -1 : 0);} ).reverse(); $scope.blogData={articles:firsts.concat(lasts)} } $scope.$watch('$parent.timeZone',function(t){ if(t){ if($routeParams.post_type=='מאמרים'&&!$routeParams.slug) $scope.sortArticles(t); } }) $scope.getFullUrl=function(url){ if(!url) return window.location.href; return window.location.protocol+'//'+window.location.hostname+url; } }]) .directive("homeSlider", ['apiService','$timeout','$window',function(apiService,$timeout,$window) { return { restrict : "E", scope:{}, // templateUrl : wp_template_dir+'/templates/slider-home.html', templateUrl :'slider-home.html', link: function(scope, elem, attrs) { var bgswiper=slider=false; scope.wp_template_dir=wp_template_dir; scope.$watch('$parent.timeZone',function(newValue){ if(!newValue)return; //console.log('newValue ' +newValue) scope.time=newValue; getData() }) function getData(){ if(slider)slider.destroy(); if(bgswiper)bgswiper.destroy(); var appWindow = angular.element($window); appWindow.bind('resize', function () { scope.setSize(); scope.$apply(); }); scope.setSize=function(){ switch(true){ case $window.innerWidth<=1023: scope.device='mobile'; break; case $window.innerWidth>1023: scope.device='desktop'; break; } } scope.setSize(); apiService.callApi(apiRoot+'home-slider','GET','','',function(response){ scope.sliderData=response.data; scope.sliderData.main_slider_first=scope.sliderData.main_slider_first.filter(function(e){ if(e.timezone==scope.time) return e; }) function countProperties(obj) { var count = 0; for(var prop in obj) { if(obj.hasOwnProperty(prop)) ++count; } return count; } scope.sliderData.slides=scope.sliderData.main_slider_first if( countProperties(scope.sliderData.main_slider[0])>3)scope.sliderData.slides=scope.sliderData.main_slider_first.concat(scope.sliderData.main_slider); //console.log(scope.sliderData.slides) $timeout(function(){ var bgswiper=new Swiper('.slider-wraper .slider-images.swiper-container', { loop: true, effect:'fade', fadeEffect: { crossFade: true }, a11y: { prevSlideMessage: 'מעבר למצג הקודם', nextSlideMessage: 'מעבר למצג הבא', }, }); var slider= new Swiper('.slider-wraper .slider-content.swiper-container', { loop: true, speed:1000, effect:'fade', a11y: { prevSlideMessage: 'מעבר למצג הקודם', nextSlideMessage: 'מעבר למצג הבא', }, fadeEffect: { crossFade: true }, navigation: { nextEl: '.slider-wraper .slider-button-next', prevEl: '.slider-wraper .slider-button-prev', }, controller: { control: bgswiper, }, }); scope.$apply() },100) }) } } }; }]) .directive("productsList", ['$filter',function($filter) { return { restrict : "E", scope: false, //templateUrl : wp_template_dir+'/templates/product-cat.html', templateUrl : 'product-cat.html', link:function(scope, elem, attrs ){ var productsInRow=4; var p=$filter('filter')(scope.mainData.terms, function (d) {return d.term_id ===Number(attrs.termid);})[0].pids; var products=scope.mainData.products.filter(function(e){ if(inArray(e.ID,p)) return e }) scope.prd=Array(); scope.quantity=Array(); scope.prd[Number(attrs.termid)]=products; scope.cat_name=attrs.name scope.logo=attrs.logo scope.cat_text=attrs.text scope.termid=attrs.termid scope.quantity[Number(attrs.termid)]=4; scope.toggleProductsCat=function(termid){ scope.quantity[termid]==productsInRow?scope.quantity[termid]=666:scope.quantity[termid]=productsInRow; } } }; }]) .directive('sharePage',[function(){ return { restrict: 'A', link: function (scope, element, attr) { element.bind('click',function(){ switch(attr.type){ case 'facebook': FB.ui({ method: 'share', href:window.location.protocol+'//'+window.location.hostname+attr.url , }, function(response){ }); break; } }) } } }]) .directive("relatedProductsSwiper", ['$filter','$timeout',function($filter,$timeout) { return { restrict : "A", scope: false, template :'', link:function(scope, elem, attrs ){ var col_size=3; scope.groups=[]; var t=[] for(i=1,k=0,j=0;k<=(scope.mainData.related.length);i++,k++){ t.push(scope.mainData.related[k]); if(i==col_size){ scope.groups[j]=t; t=[]; j++; i=0; } } if(i ', link:function(scope, elem, attrs ){ } }; }]) .directive("productsSidebar", ['$window',function($window) { return { restrict : "A", link: function(scope, elem, attrs) { angular.element($window).bind('scroll',function(){ if(!document.querySelector('.floating-sidebar')){ angular.element($window).unbind('scroll'); return false; }; if((elem[0].getBoundingClientRect().top/2)angular.element(document.querySelector('.floating-sidebar'))[0].offsetTop*3)){ scope.showSideBar=true; }else{ scope.showSideBar=false; } scope.$apply(); }) } }; }]) .directive("scrollTo",[ function() { return { restrict : "A", scope:false, link: function(scope, elem, attrs) { elem.bind('click',function(e){ if(elem.attr('href'))var el=elem.attr('href'); if(attrs.target)var el=attrs.target; if(attrs.offset)var offset=attrs.offset; if(!el)return; var offset= (window.innerHeight/100)*8; zenscroll.setup(300,offset) zenscroll.to(document.getElementById(el)) e.preventDefault(); }) } }; }]) .directive("clubForm", [function() { return { restrict : "E", // templateUrl : wp_template_dir+'/templates/club.html' templateUrl :'club.html' }; }]) .directive("homeCubes", ['apiService','$timeout',function(apiService,$timeout) { return { restrict : "E", scope:{}, templateUrl : 'home-cubes.html', // templateUrl : wp_template_dir+'/templates/home-cubes.html', link: function(scope, elem, attrs) { //console.warn('xXXXX') scope.wp_template_dir=wp_template_dir; apiService.callApi(apiRoot+'home-cubes','GET','','',function(response){ //console.warn('111111111XXX') scope.mainData=response.data; $timeout(function(){ new Swiper('.mobile-adver-swiper', { loop: false, slidesPerView:2, observe:true, a11y: { prevSlideMessage: 'מעבר למצג הקודם', nextSlideMessage: 'מעבר למצג הבא', }, pagination: { el: '.mobile-adver-swiper .swiper-pagination', clickable:true, }, navigation: { nextEl: '.mobile-adver-swiper .button-next', prevEl: '.mobile-adver-swiper .button-prev', } , breakpoints: { 1024: { slidesPerView: 1, }, } }); new Swiper('.mobile-tips-swiper', { a11y: { prevSlideMessage: 'מעבר למצג הקודם', nextSlideMessage: 'מעבר למצג הבא', }, loop: false, slidesPerView:2, observe:true, pagination: { el: '.mobile-tips-swiper .swiper-pagination', clickable:true, }, navigation: { nextEl: '.mobile-tips-swiper .button-next', prevEl: '.mobile-tips-swiper .button-prev', }, breakpoints: { 1024: { slidesPerView: 1, }, } }); }) }) }}}]) .directive("recipesSlider", ['apiService','$timeout',function(apiService,$timeout) { return { restrict : "E", scope:{tips_titles:'=bind'}, // templateUrl : wp_template_dir+'/templates/recipes-slider.html', templateUrl : 'recipes-slider.html', link: function(scope, elem, attrs) { scope.wp_template_dir=wp_template_dir; var bgswiper=slider=false; scope.$watch('$parent.timeZone',function(val){ if(val)getData() }) scope.getTermNames=function(id){ var rt=[]; for(i=0;i this.scrollY; scope.$apply(); this.oldScroll = this.scrollY; }) apiService.callApi(apiRoot+'get_times','GET','','',function(response){ scope.showWidget=true; scope.help=response.data.help; scope.showhelp=response.data.showhelp; scope.timeouts=response.data.timeouts; var times=[]; for(i=0;i0){ $timeout(function(){ scope.nohlep=true; },scope.timeouts.help*1000); } if(scope.timeouts.widget>0){ $timeout(function(){ scope.navStatus=false; scope.notFirst=true },scope.timeouts.widget*1000) } scope.setTime=function(t,l){ scope.twObj.currentTime=t.name; scope.navStatus=false; scope.setTimeZone(t.term_id,l); scope.notFirst=false; } for(i=0;i