Changeset 1132529
- Timestamp:
- 04/11/2015 05:24:16 AM (11 years ago)
- Location:
- angularjs-for-wp/trunk
- Files:
-
- 1 added
- 6 edited
-
angularjs-templates/post-content.html (modified) (1 diff)
-
includes/contentFilter.php (modified) (1 diff)
-
js/angular-app.js (modified) (2 diffs)
-
js/angular-posts-directives.js (modified) (4 diffs)
-
js/angular-sanitize.min.js (added)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
angularjs-for-wp/trunk/angularjs-templates/post-content.html
r932250 r1132529 3 3 --> 4 4 5 <div ng-bind-html=" post.content_raw| unsafe"></div>5 <div ng-bind-html="content | unsafe"></div> -
angularjs-for-wp/trunk/includes/contentFilter.php
r1105778 r1132529 4 4 global $post; 5 5 6 $content = '<div ng-app="wpAngularPlugin">'.$content.'</div>';7 8 6 $meta = get_post_meta($post->ID, 'angularjsLoad', true); 9 7 $meta = intval($meta); 10 8 11 9 if($meta){ 12 $content = '<ng-post-content id="'.$post->ID.'"></ng-post-content>'; 10 $content = '<div ng-app="wpAngularPlugin"><ng-post-content id="'.$post->ID.'" content="'.$content.'"></ng-post-content></div>'; 11 } else { 12 $content = '<div ng-app="wpAngularPlugin">'.$content.'</div>'; 13 13 } 14 14 -
angularjs-for-wp/trunk/js/angular-app.js
r1105778 r1132529 1 var angular_app = angular.module('wpAngularPlugin', [ ]);1 var angular_app = angular.module('wpAngularPlugin', ['ngSanitize']); 2 2 3 3 angular_app.filter('unsafe', function($sce) { 4 4 return function(val) { 5 return $sce.trustAsHtml(val); 5 if( $sce.trustAsHtml(val) ) 6 return $sce.trustAsHtml(val).toString(); 6 7 }; 7 8 }); … … 12 13 }); 13 14 }); 15 16 angular_app.directive('ngRender', ['$compile', function ($compile) { 17 return { 18 restrict: 'E', 19 scope: { 20 html: '=' 21 }, 22 link: function postLink(scope, element, attrs) { 23 24 function appendHtml() { 25 if(scope.html) { 26 var newElement = angular.element(scope.html); 27 $compile(newElement)(scope); 28 element.append(newElement); 29 } 30 } 31 32 scope.$watch(function() { return scope.html }, appendHtml); 33 } 34 }; 35 }]); -
angularjs-for-wp/trunk/js/angular-posts-directives.js
r1105778 r1132529 13 13 search: '@search', 14 14 postType: '@postType', 15 perPage: '@perPage' 15 perPage: '@perPage', 16 page: '@page' 16 17 }, 17 18 controller: ['$scope', '$http', function($scope, $http) { 18 $scope.getPosts = function(filters, postType ){19 $scope.getPosts = function(filters, postType, page){ 19 20 $scope.baseURL = wpAngularVars.base + '/posts?'; 20 21 … … 25 26 } 26 27 if(postType){ 27 $scope.baseURL = $scope.baseURL + ' type[]=' + postType;28 $scope.baseURL = $scope.baseURL + '&type[]=' + postType; 28 29 } 30 if(page){ 31 $scope.baseURL = $scope.baseURL + '&page=' + page; 32 } 29 33 $http.get($scope.baseURL).then(function(res){ 30 34 $scope.postsD = res.data; … … 45 49 if($scope.search) { $scope.filters.push({'filter': 's', 'value': $scope.search}); } 46 50 if($scope.perPage) { $scope.filters.push({'filter': 'posts_per_page', 'value': $scope.perPage}); } 47 if($scope.page) { $scope.filters.push({'filter': 'posts_per_page', 'value': $scope.page}); } 48 51 if($scope.page) { $scope.filters.push({'filter': 'posts_per_page', 'value': $scope.page}); } 52 49 53 $scope.getPosts($scope.filters, $scope.postType); 50 54 }, … … 79 83 restrict: 'E', 80 84 scope: { 81 id: '=' 85 id: '=', 86 content: '@' 82 87 }, 83 controller: ['$scope', '$http', function($scope, $http) {84 $scope.getPost = function(id) {85 $http.get(wpAngularVars.base + '/posts/' + id + '?context=edit&_wp_json_nonce=' + wpAngularVars.nonce).then(function(res){86 $scope.post = res.data;87 });88 }89 }],90 link: function($scope, $elm, attrs, ctrl){91 $scope.getPost($scope.id);92 },93 88 template: '<div class="ngSingleWrapper"><ng-include src="\''+wpAngularVars.template_directory.post_content+'\'"></ng-include></div>' 94 89 } 95 90 }]); 91 96 92 97 93 angular_app.directive('ngNewPost', ['$http', '$rootScope', function($http, $rootScope){ -
angularjs-for-wp/trunk/plugin.php
r1105778 r1132529 26 26 // Angular Core 27 27 wp_enqueue_script('angular-core', plugin_dir_url( __FILE__ ).'js/angular.min.js', array('jquery'), null, false); 28 wp_enqueue_script('angular-sanitize', plugin_dir_url( __FILE__ ).'js/angular-sanitize.min.js', array('jquery'), null, false); 28 29 wp_enqueue_script('angular-app', plugin_dir_url( __FILE__ ).'js/angular-app.js', array('jquery'), null, false); 29 30 -
angularjs-for-wp/trunk/readme.txt
r1105778 r1132529 15 15 AngularJS for WordPress was created to help anyone leverage the power of AngularJS and easily add it into their own theme. 16 16 17 AngularJS is a client-side template framework that lets you extend HTML vocabulary for your applications. It has a markup more similar to what HTML used to be. HTML its not a dynamic language 18 by itself, with AngularJS it is. 17 AngularJS is a client-side template framework that lets you extend HTML vocabulary for your applications. It has a markup more similar to what HTML used to be. HTML its not a dynamic language by itself, with AngularJS it is. 19 18 20 19 AngularJS for WordPress includes several directives (html elements) that will help you easily add in a block for a single post/page or a list. More directives will be added in. … … 23 22 24 23 For even easier use for specific pages a new post meta box has been added. If selected the AngularJS directive will take over loading the content of the page client-side. This feature uses the post-content.html template. 25 24 26 25 View [documentation](http://www.roysivan.com/angularjs-for-wordpress) for how to utilize the directives and shortcodes 27 28 26 29 27 == Installation == … … 67 65 * Added Taxonomy and post type to new post creation 68 66 69 = 1.1.2=67 = 1.2 = 70 68 * Fix for new post template [fixing issue](https://wordpress.org/support/topic/template-override-for-new-posthtml-appears-to-not-be-working?replies=2#post-6635530) 71 72 =1.2=73 * No more global Angular App - redefined app to be more modular friendly
Note: See TracChangeset
for help on using the changeset viewer.