File

projects/app-base-library/src/lib/angular/modules/wordpress/wordpress.service.ts

Index

Properties

Constructor

constructor()

Properties

menus
menus: any
Type : any
Default value : this.model.menus
params
params: any
Type : any
import { Injectable } from '@angular/core';
// import { HttpClient } from '@angular/common/http';
import { Wordpress } from '../../../shared/cms/wordpress';
declare var _: any;
declare var Promise: any;

@Injectable()
export class WordpressService extends Wordpress {
    menus: any = this.model.menus;
    params: any;

    constructor() {
        super();
    }

}

// angular.module('stoute.wordpress', [])
//
//     .service('WordPress',['$http','$q','$window',function($http,$q,$window){
//       $window.wp = $window.wp || {};
//       // defaults
//       this.domain = "www.streamer.nl/wordpress";
//       this.path_to_templates = "app/components/lib/views/";
//       this.path_to_theme = '';
//       this.static = false;
//       this.model = {};
//       this.model.pids = this.menus = this.params = {};
//
//       this.init = function(options){
//         var deferred = $q.defer();
//         var _this = this;
//         this.version = options.version || '3.19';
//         this.domain = options.domain || this.domain;
//         this.static = options.static || this.static;
//         this.path_to_theme = options.path_to_theme || this.path_to_theme;
//         this.path_to_templates = options.path_to_templates || this.path_to_templates;
//         this.base_path = options.base_path || '/';
//         this.protocol = options.protocol || 'http:';
//         this.baseUrl = this.protocol + '//' + this.domain + this.base_path;
//         this.jsonApiBasUrl =  this.baseUrl;
//         $http.get(this.jsonApiBasUrl+'api/params/get_params/').then(function(result){
//           _this.params = result.data;
//           _this.ready = true;
//           deferred.resolve(result.data);
//         });
//         return deferred.promise;
//       };
//
//       this.fetch = function(queryString){
//         var deferred = $q.defer();
//         var query = '?json=get_recent_posts';
//         if(queryString){
//           query = queryString + '?json=1';
//         }
//         $http.get(this.jsonApiBasUrl+query).then(function(result){
//           deferred.resolve(result.data);
//         });
//         return deferred.promise;
//       };
//       this.getPost = function(pid){
//         var deferred = $q.defer();
//         var _this=this;
//         if(this.model.pids[pid] && this.static == true){
//           deferred.resolve(this.model.pids[pid]);
//         }else{
//           $http.get(this.jsonApiBasUrl+'?json=1&p='+pid).then(function(result){
//             _this.model.pids[result.data.post.id]=result.data.post;
//             deferred.resolve(result.data.post);
//           });
//         }
//         return deferred.promise;
//       };
//       this.getCollection = function(collection){
//         var deferred = $q.defer();
//         var _this=this;
//         var parse = function(list){
//           angular.forEach(list,function(post){
//             _this.model.pids[post.ID]=post;
//           });
//           deferred.resolve(list);
//         };
//         $http.get(this.jsonApiBasUrl+'?json=get_posts&post_type='+ collection).then(function(list){
//           _this.model[collection] = list.data.posts;
//           parse(list.data.posts);
//         });
//         return deferred.promise;
//       };
//       this.getMenu = function(mid){ // fixme:
//         var deferred = $q.defer();
//         var _this = this;
//         $http.get(this.jsonApiBasUrl+'api/menus/get_menu/?menu_id='+mid+'/').then(function(result){
//           _this.menus[mid]=result.data.menu;
//           deferred.resolve(result.data.menu);
//         });
//         return deferred.promise;
//       };
//       this.getMenus = function(){
//         var deferred = $q.defer();
//         var _this = this;
//         var mids = [];
//         var i = 0;
//         angular.forEach(this.params.menus, function (menu) {
//           mids.push(menu.term_id);
//         });
//         angular.forEach(mids, function (mid) {
//           _this.getMenu(mid).then(function(menu){
//             _this.menus[mid] = menu;
//             i++;
//             if(i===mids.length){
//               deferred.resolve(_this.menus);
//             }
//           })
//         });
//         return deferred.promise;
//       }
//     }])
//

//

//
// ;

results matching ""

    No results matching ""