Changeset 1750923
- Timestamp:
- 10/23/2017 06:37:33 AM (8 years ago)
- Location:
- wp-appkit/trunk
- Files:
-
- 17 edited
-
app/core/app.js (modified) (8 diffs)
-
app/core/models/comments.js (modified) (1 diff)
-
app/core/router.js (modified) (7 diffs)
-
app/core/theme-app.js (modified) (7 diffs)
-
default-themes/q-android/js/functions.js (modified) (9 diffs)
-
default-themes/q-android/layout.html (modified) (2 diffs)
-
default-themes/q-android/readme.md (modified) (1 diff)
-
default-themes/q-android/single.html (modified) (1 diff)
-
default-themes/q-ios/js/functions.js (modified) (2 diffs)
-
default-themes/q-ios/readme.md (modified) (1 diff)
-
lib/components/components-bo-settings.php (modified) (1 diff)
-
lib/components/components-types/page.php (modified) (1 diff)
-
lib/components/components-utils.php (modified) (6 diffs)
-
lib/themes/themes-storage.php (modified) (1 diff)
-
lib/themes/themes.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
wp-appkit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-appkit/trunk/app/core/app.js
r1634492 r1750923 94 94 * @param data see models/custom-page.js for data fields 95 95 */ 96 app.showCustomPage = function(template,data, id){96 app.showCustomPage = function(template,data,fragment,silent){ 97 97 var args = {template: template, data: data}; 98 if( id!== undefined ){99 args.id = id;98 if( fragment !== undefined ){ 99 args.id = fragment; 100 100 } 101 101 current_custom_page = new CustomPage(args); 102 app.router.navigate( app.getScreenFragment( 'custom-page' ), { trigger: true } ); 102 if ( silent === true ) { 103 app.router.execute_route_silently( app.getScreenFragment( 'custom-page' ) ); 104 app.router.navigate( fragment, { trigger: false } ); 105 } else { 106 app.router.navigate( app.getScreenFragment( 'custom-page' ), { trigger: true } ); 107 } 103 108 }; 104 109 … … 375 380 var history_action = ''; 376 381 377 if( queried_screen_data.screen_type == 'list' ){ 382 if( queried_screen_data.fragment == current_screen.fragment ) { 383 //Redisplaying same screen: do nothing 384 history_action = 'none'; 385 }else if( queried_screen_data.screen_type == 'list' ){ 378 386 history_action = 'empty-then-push'; 379 387 }else if( queried_screen_data.screen_type == 'single' ){ … … 894 902 comments.add( value ); 895 903 } ); 904 905 post.set( 'nb_comments', comments.length ); 906 post.save(); 907 896 908 cb_ok( comments, post, item_global ); 897 909 }; … … 916 928 }; 917 929 918 app.getPostComments = function ( post_id, cb_ok, cb_error ) { 930 app.getPostComments = function ( post_id, cb_ok, cb_error, force_refresh ) { 931 932 force_refresh = force_refresh === true; 919 933 920 934 var post_comments_memory = app.comments.get( post_id ); 921 if ( post_comments_memory ) {922 935 if ( post_comments_memory && !force_refresh ) { 936 923 937 var post_comments = post_comments_memory.get( 'post_comments' ); 924 938 var post = post_comments_memory.get( 'post' ); … … 930 944 931 945 } else { 946 932 947 fetchPostComments( 933 948 post_id, … … 1343 1358 var auto_interpret_result = !options.hasOwnProperty('auto_interpret_result') || options.auto_interpret_result === true; 1344 1359 1345 //interpretation_type defaults to ' update' :1360 //interpretation_type defaults to 'replace-keep-global-items' : 1346 1361 var interpretation_type = options.hasOwnProperty('type') ? options.type : 'replace-keep-global-items'; 1347 1362 … … 1509 1524 $.ajax( ajax_args ); 1510 1525 }; 1526 1527 app.getPageComponentByPageId = function( page_id, default_to_first_component ) { 1528 var page_component = _.find( this.getComponents(), function( component ){ 1529 return component.type === 'page' && component.global === 'pages' && component.data.root_id === page_id; 1530 } ); 1531 1532 if ( !page_component && default_to_first_component === true ) { 1533 page_component = this.findFirstComponentOfType( 'page' ); 1534 } 1535 1536 return page_component; 1537 }; 1511 1538 1512 1539 app.getComponentData = function(component_id){ … … 1684 1711 return item; 1685 1712 }; 1713 1714 /** 1715 * Retrieve items (posts/pages etc) from remote server and merge them into existing app's items. 1716 * 1717 * @param Array items array of ids of pages/posts to retrieve. 1718 * @param JSON Object options: 1719 * - component_id: Int (optional) Slug of the component we want to retrieve items for. 1720 * If not provided, the first component of "component_type" found 1721 * will be used. 1722 * - component_type: String (optional) Type of component ("posts-list", "pages") we want to 1723 * retrieve items for. Only useful if component_id is not provided. 1724 * If not provided, defaults to "posts-list". 1725 * - persistent: Boolean (optional) Whether to persist retrieved items to local storage. 1726 * Defaults to true. 1727 * - success: Callback (optional) Called if items are retrieved successfully 1728 * - error: Callback (optional) Called if an error occured while retrieving items from server. 1729 * App error events are also triggered in that case. 1730 */ 1731 app.getItemsFromRemote = function ( items_ids, options ) { 1732 1733 options = options || {}; 1734 1735 Utils.log('Retrieving items from remote server.', items_ids); 1736 1737 //Posts/pages/items can only be retrieved by component, as their content is formatted 1738 //according to the component type they belong to. 1739 var component = null; 1740 if ( options.component_id ) { 1741 if ( this.components.get( options.component_id ) ) { 1742 component = this.components.get( options.component_id ); 1743 } else { 1744 this.triggerError( 1745 'get-items:remote:wrong-component-given', 1746 { type:'wrong-data', where:'app::getItemsFromRemote', message: 'Provided component not found ['+ options.component_id +']', data: { options: options, items_ids: items_ids } }, 1747 options.error 1748 ); 1749 return; 1750 } 1751 } 1752 1753 if ( !component ) { 1754 var component_type = options.component_type ? options.component_type : 'posts-list'; 1755 component = this.findFirstComponentOfType( component_type ); 1756 } 1757 1758 if ( component ) { 1759 1760 var _this = this; 1761 1762 var persistent = !options.persistent || options.persistent === true; 1763 1764 //Call liveQuery to retrieve the given items from server and store them in local storage: 1765 this.liveQuery( 1766 { 1767 wpak_component_slug: component.id, 1768 wpak_query_action: 'get-items', 1769 wpak_items_ids: items_ids 1770 }, 1771 function( answer, results ){ 1772 1773 var items_found = _.find( results, function( result ) { 1774 return result.data.new_items.length > 0; 1775 } ); 1776 1777 if ( items_found ) { 1778 Utils.log('Items retrieved successfully from remote server.', items_ids, results); 1779 if ( options.success ) { 1780 options.success( answer, component, results ); 1781 } 1782 } else { 1783 //Requested posts where not found. Trigger error 1784 if ( options.error ) { 1785 _this.triggerError( 1786 'get-items:remote:no-item-found', 1787 { type:'not-found', where:'app::getItemsFromRemote', message: 'Requested items not found', data: { options: options, items_ids: items_ids } }, 1788 options.error 1789 ); 1790 } 1791 } 1792 1793 }, 1794 function( error ){ 1795 //liveQuery error: error event has been triggered in liveQuery, 1796 //simply call the error callback here: 1797 if ( options.error ) { 1798 options.error( error ); 1799 } 1800 }, 1801 { 1802 type: 'update', 1803 persistent: persistent 1804 } 1805 ); 1806 1807 } else { 1808 app.triggerError( 1809 'get-items:remote:wrong-component', 1810 { type:'wrong-data', where:'app::getItemsFromRemote', message: 'Could not find a valid component', data: { options: options, items_ids: items_ids } }, 1811 options.error 1812 ); 1813 } 1814 }; 1815 1816 app.findFirstComponentOfType = function( component_type ) { 1817 return _.findWhere( this.getComponents(), { type: component_type } ) 1818 }; 1819 1820 app.loadRouteItemFromRemote = function( item_id, item_global, component_type, options ){ 1821 var load_from_remote = Hooks.applyFilters('load-unfound-items-from-remote', true, [item_id,item_global]); 1822 if ( load_from_remote ) { 1823 1824 /** 1825 * Use 'load-unfound-items-component-id' and 'load-unfound-items-component-type' to customize 1826 * which component is used to retrieve the item from remote. 1827 * Default is the first "posts-list" component found. 1828 */ 1829 var item_component_id = Hooks.applyFilters('load-unfound-items-component-id', '', [item_id,item_global]); 1830 var item_component_type = Hooks.applyFilters('load-unfound-items-component-type', component_type, [item_id,item_global]); 1831 1832 this.triggerInfo( 'load-item-from-remote:start', { 1833 item_id: item_id, item_global: item_global, item_component_id: item_component_id, item_component_type: item_component_type 1834 } ); 1835 1836 var global = this.globals[item_global]; 1837 1838 var _this = this; 1839 1840 this.getItemsFromRemote( [item_id], { 1841 component_id: item_component_id, 1842 component_type: item_component_type, 1843 success: function( answer, component, results ) { 1844 var item = global.get(item_id); 1845 1846 _this.triggerInfo( 'load-item-from-remote:stop', { 1847 item_id: item_id, item_global: item_global, item: item, 1848 item_component_id: item_component_id, item_component_type: item_component_type, 1849 success: !!item 1850 } ); 1851 1852 if ( item ) { 1853 1854 //Success! 1855 if ( options.success ) { 1856 options.success( item, component ); 1857 } 1858 1859 } else { 1860 Utils.log('loadRouteItemFromRemote : unexpected error "'+ item_id +'" not found in global "'+ item_global +'" even after remote call.'); 1861 1862 _this.triggerError( 1863 'get-items:remote:item-not-found-in-global', 1864 { type:'not-found', where:'app::loadRouteItemFromRemote', message: 'Requested items not found', data: { 1865 item_id: item_id, item_global: item_global, item: item, 1866 item_component_id: item_component_id, item_component_type: item_component_type 1867 } } 1868 ); 1869 1870 if ( options.error ) { 1871 options.error(); 1872 } 1873 } 1874 }, 1875 error: function() { 1876 1877 _this.triggerInfo( 'load-item-from-remote:stop', { 1878 item_id: item_id, item_global: item_global, 1879 item_component_id: item_component_id, item_component_type: item_component_type, 1880 success: false 1881 } ); 1882 1883 if ( options.error ) { 1884 options.error(); 1885 } 1886 } 1887 1888 } ); 1889 1890 } else { 1891 if ( options.error ) { 1892 options.error(); 1893 } 1894 } 1895 }; 1686 1896 1687 1897 /** -
wp-appkit/trunk/app/core/models/comments.js
r1634492 r1750923 30 30 model: PostComments, 31 31 addPostComments: function( post_id, post, item_global, comments ) { 32 this.add( { id: post_id, post: post, item_global: item_global, post_comments: comments.clone() } );32 this.add( { id: post_id, post: post, item_global: item_global, post_comments: comments.clone() }, { merge: true } ); 33 33 } 34 34 } ); -
wp-appkit/trunk/app/core/router.js
r1634492 r1750923 26 26 "single/:global/:id" : "single", 27 27 "page/:component_id/:page_id" : "page", 28 "page/:page_id" : "page_no_component", 28 29 "comments-:post_id" : "comments", 29 30 "component-:id" : "component", … … 106 107 route_asked = 'single/'+ item_global +'/'+ item_id; 107 108 109 var show_single = function( item ) { 110 var item_json = item.toJSON(); 111 var item_data = item_global == 'posts' ? {post:item_json} : {item:item_json}; 112 113 if( check_route('single/'+ item_global +'/'+ item_id) ){ 114 RegionManager.show( 115 'single', 116 {item:item,global:item_global}, 117 {screen_type:'single',component_id:'',item_id:parseInt(item_id),global:item_global,data:item_data,label:item_json.title} 118 ); 119 } 120 }; 121 108 122 require(["core/app"],function(App){ 109 123 var global = App.globals[item_global]; … … 111 125 var item = global.get(item_id); 112 126 if( item ){ 113 var item_json = item.toJSON(); 114 var item_data = item_global == 'posts' ? {post:item_json} : {item:item_json}; 115 116 if( check_route('single/'+ item_global +'/'+ item_id) ){ 117 RegionManager.show( 118 'single', 119 {item:item,global:item_global}, 120 {screen_type:'single',component_id:'',item_id:parseInt(item_id),global:item_global,data:item_data,label:item_json.title} 121 ); 122 } 123 127 128 show_single( item ); 129 124 130 }else{ 125 Utils.log('Error : router single route : item with id "'+ item_id +'" not found in global "'+ item_global +'".'); 126 App.router.default_route(); 131 132 Utils.log('Router single route : item with id "'+ item_id +'" not found in global "'+ item_global +'".'); 133 134 App.loadRouteItemFromRemote( item_id, item_global, 'posts-list', { 135 success: function( item ) { 136 show_single( item ); 137 }, 138 error: function() { 139 App.router.default_route(); 140 } 141 } ); 142 127 143 } 128 144 }else{ … … 136 152 route_asked = 'page/'+ component_id +'/'+ page_id; 137 153 154 var item_global = 'pages'; 155 156 var _this = this; 157 138 158 require(["core/app"],function(App){ 139 var item_global = 'pages'; 159 160 var show_page = function( item, page_component_id ) { 161 162 //To allow page route with no component (#page/[page_id]): 163 if ( page_component_id === 'wpak-page-component-placeholder' ) { 164 //If the page was loaded dynamically, it has no corresponding component, 165 //so we pass true to getPageComponentByPageId() so that the first page component 166 //found is used in that case: 167 var page_component = App.getPageComponentByPageId( item.get('id'), true ); 168 if ( page_component ) { 169 page_component_id = page_component.id; 170 } 171 } 172 173 var component = App.getComponentData( page_component_id ); 174 175 if( component ){ 176 177 var item_data = { 178 post:item.toJSON(), 179 is_tree_page:component.data.is_tree, 180 is_tree_root:(page_id == component.data.root_id), 181 root_id:component.data.root_id, 182 root_depth:component.data.root_depth 183 }; 184 185 //This is still component_id to check the route and not page_component_id, to handle the case 186 //where the page was not in the app and was retrieved from remote. 187 if( check_route('page/'+ component_id +'/'+ page_id) ) { 188 RegionManager.show( 189 'page', 190 {item:item,global:item_global}, 191 {screen_type:'page',component_id:page_component_id,item_id:parseInt(page_id),global:item_global,data:item_data,label:item_data.post.title} 192 ); 193 } 194 195 }else{ 196 Utils.log('Error : router : page route : component with id "'+ page_component_id +'" not found'); 197 _this.default_route(); 198 } 199 }; 200 140 201 var global = App.globals[item_global]; 141 202 if( global ){ 142 203 var item = global.get(page_id); 143 204 if( item ){ 144 var component = App.getComponentData(component_id); 145 if( component ){ 146 147 var item_data = { 148 post:item.toJSON(), 149 is_tree_page:component.data.is_tree, 150 is_tree_root:(page_id == component.data.root_id), 151 root_id:component.data.root_id, 152 root_depth:component.data.root_depth 153 }; 154 155 if( check_route('page/'+ component_id +'/'+ page_id) ){ 156 RegionManager.show( 157 'page', 158 {item:item,global:item_global}, 159 {screen_type:'page',component_id:component_id,item_id:parseInt(page_id),global:item_global,data:item_data,label:item_data.post.title} 160 ); 205 show_page( item, component_id ); 206 }else{ 207 208 Utils.log('Error : router : page route : item with id "'+ page_id +'" not found in global "'+ item_global +'".'); 209 210 App.loadRouteItemFromRemote( page_id, item_global, 'page', { 211 success: function( item, item_component ) { 212 show_page( item, item_component.id ); 213 }, 214 error: function() { 215 App.router.default_route(); 161 216 } 162 163 }else{ 164 Utils.log('Error : router : page route : component with id "'+ component_id +'" not found'); 165 App.router.default_route(); 166 } 167 }else{ 168 Utils.log('Error : router : page route : item with id "'+ page_id +'" not found in global "'+ item_global +'".'); 169 App.router.default_route(); 217 } ); 218 170 219 } 171 220 }else{ … … 175 224 }); 176 225 }, 226 227 page_no_component: function ( page_id ) { 228 this.page( 'wpak-page-component-placeholder', page_id ); 229 }, 177 230 178 231 comments: function ( post_id ) { … … 246 299 if( !_.isEmpty(custom_route) ){ 247 300 fragment_not_found = ''; 248 App.showCustomPage(custom_route.template,custom_route.data,fragment );301 App.showCustomPage(custom_route.template,custom_route.data,fragment,true); 249 302 } 250 303 … … 254 307 }); 255 308 256 } 309 }, 310 311 /** 312 * Execute router's method corresponding to the given route without 313 * changing current url or fragment. 314 * Used for custom routes. 315 */ 316 execute_route_silently: function ( route ) { 317 318 var fragment = Backbone.history.getFragment( route ); 319 var route_handler = _.find( Backbone.history.handlers, function ( handler ) { 320 return handler.route.test( fragment ); 321 } ); 322 323 if ( route_handler !== undefined ) { 324 this.execute( route_handler.callback, [ fragment ], '' ); 325 } else { 326 Utils.log( 'Router.js error: execute_route_silently: route not found.' ); 327 } 328 329 } 330 257 331 258 332 }); -
wp-appkit/trunk/app/core/theme-app.js
r1703622 r1750923 10 10 Backbone = require( 'backbone' ), 11 11 RegionManager = require( 'core/region-manager' ), 12 Utils = require( 'core/app-utils' ),13 Config = require( 'root/config' ),14 12 Messages = require( 'core/messages' ), 15 13 App = require( 'core/app' ), … … 332 330 var current_view = RegionManager.getCurrentView(); 333 331 current_view.render(); 332 }; 333 334 /** 335 * Retrieve current Backbone view object 336 */ 337 themeApp.getCurrentView = function() { 338 var current_view = RegionManager.getCurrentView(); 339 return current_view; 334 340 }; 335 341 … … 436 442 437 443 }; 444 445 /** 446 * When on a comments screen, reloads the comments for the current post and 447 * re-renders the view to display new comments. 448 * 449 * @param {function} cb_ok What to do when comment screen was updated successfully 450 * @param {function} cb_error What to do if an error occurs while updating comment screen 451 */ 452 themeApp.updateCurrentCommentScreen = function ( cb_ok, cb_error ) { 453 454 var current_screen_info = this.getCurrentScreenObject(); 455 456 if ( current_screen_info.screen_type !== 'comments' ) { 457 return; 458 } 459 460 //Retrieve post id corresponding to the current comments screen: 461 var post_id = current_screen_info.post.id; 462 463 var _this = this; 464 465 //Reload post comments from server: 466 App.getPostComments( 467 post_id, 468 function ( comments, post ) { 469 //New comments loaded successfully 470 471 //Update current view's comments with new comments 472 var comments_view = RegionManager.getCurrentView(); 473 comments_view.comments = comments; 474 475 //Rerender screen: 476 _this.rerenderCurrentScreen(); 477 478 cb_ok( comments, post ); 479 }, 480 function ( error ) { 481 cb_error( error ); 482 }, 483 true //To force post comments cache flush 484 ); 485 } 438 486 439 487 /************************************************ … … 770 818 */ 771 819 772 themeApp.showCustomPage = function( template, data, id) {820 themeApp.showCustomPage = function( template, data, fragment, silent ) { 773 821 if ( template === undefined ) { 774 822 template = 'custom'; … … 777 825 data = {}; 778 826 } 779 if ( id === undefined ) { 780 id = 'auto-custom-page'; 781 } 782 App.showCustomPage( template, data, id ); 827 if ( fragment === undefined ) { 828 fragment = 'auto-custom-page'; 829 } 830 if ( silent === undefined ) { 831 silent = true; 832 } 833 App.showCustomPage( template, data, fragment, silent ); 783 834 }; 784 835 … … 834 885 * @param {int} item_id Post ID of the post to retrieve 835 886 * @param {string} global_key (Optional) global to retrieve the item from: 'posts' (default) or 'pages'. 836 * @returns {JSON Object } item (post or page) object887 * @returns {JSON Object | null} item (post or page) object if found, null if no post found with the given item_id. 837 888 */ 838 889 themeApp.getItem = function( item_id, global_key ) { … … 841 892 842 893 return App.getGlobalItem( global_key, item_id ); 894 }; 895 896 /** 897 * Retrieve items (posts/pages etc) from remote server and merge them into existing app's items. 898 * 899 * @param Array items array of ids of pages/posts to retrieve. 900 * @param JSON Object options: 901 * - component_id: Int (optional) Slug of the component we want to retrieve items for. 902 * If not provided, the first component of "component_type" found 903 * will be used. 904 * - component_type: String (optional) Type of component ("posts-list", "pages") we want to 905 * retrieve items for. Only useful if component_id is not provided. 906 * If not provided, defaults to "posts-list". 907 * - persistent: Boolean (optional) Whether to persist retrieved items to local storage. 908 * Defaults to true. 909 * - success: Callback (optional) Called if items are retrieved successfully 910 * - error: Callback (optional) Called if an error occured while retrieving items from server. 911 * App error events are also triggered in that case. 912 */ 913 themeApp.getItemsFromRemote = function( items_ids, options ) { 914 App.getItemsFromRemote( items_ids, options ); 843 915 }; 844 916 -
wp-appkit/trunk/default-themes/q-android/js/functions.js
r1634492 r1750923 28 28 ], function($,App,Storage,TemplateTags,Config,Moment,Velocity) { 29 29 30 31 30 32 31 /* 33 32 * App's parameters … … 114 113 } ); 115 114 115 //@desc Memorize the last history action so that we can decide what to do when 116 //doing "single to single" transitions: 117 var last_history_action = ''; 118 116 119 // @desc Catch if we're going to a single and coming from a single (it is the case when clicking on a post in the last posts widget at the bottom of a post) 117 120 // Update properly the history stack … … 126 129 } 127 130 131 last_history_action = history_action; 132 128 133 // Return the proper history action 129 134 return history_action; … … 131 136 }); 132 137 133 134 138 // @desc Handle "single to single" transition: 139 App.filter( 'transition-direction', function( transition, current_screen, next_screen ){ 140 141 if( current_screen.screen_type === 'single' && next_screen.screen_type === 'single' ) { 142 if ( last_history_action === 'push' ) { 143 transition = 'next-screen'; 144 } else { 145 transition = 'previous-screen'; 146 } 147 148 } 149 150 return transition; 151 }); 152 153 // @desc Handle transitions for deeplinks: 154 App.filter( 'transition-direction', function( transition, current_screen, next_screen ){ 155 156 //Display single in a slide up panel when opening from deeplinks: 157 if( next_screen.screen_type === 'single' && _.isEmpty( current_screen ) ) { 158 transition = 'next-screen'; 159 } 160 161 return transition; 162 }); 163 135 164 /* 136 165 * Actions 137 166 */ 138 167 139 168 // @desc Detect transition types (aka directions) and launch corresponding animations 140 169 App.action( 'screen-transition', function( $wrapper, $current, $next, current_screen, next_screen, $deferred ) { … … 238 267 $current.remove(); 239 268 $wrapper.empty().append( $next ); 269 if ( $currentContainer ) { 270 removeContainer($currentContainer); 271 } 240 272 $deferred.resolve(); 241 273 … … 285 317 286 318 }); 319 320 // @desc The app starts retrieving a new post from remote server 321 App.on('info:load-item-from-remote:start',function(){ 322 // Start refresh icon animation 323 $("#refresh-button").hide(); 324 $(".loading-from-remote-button").show(); 325 }); 326 327 // @desc A new post was retrieved from remote server 328 App.on('info:load-item-from-remote:stop',function(){ 329 // Stop refresh icon animation 330 $(".loading-from-remote-button").hide(); 331 $("#refresh-button").show(); 332 }); 287 333 288 334 // @desc An error occurs … … 345 391 if (current_screen.screen_type=="single" || current_screen.screen_type=="page") { 346 392 347 // Redirect all content hyperlinks clicks348 // @todo: put it into prepareContent()349 $("#app-layout").on("click", ".single-content a", openInBrowser);350 351 393 // Make any necessary modification to post/page content 352 394 prepareContent( currentScreenObject ); … … 464 506 $('#app-layout').on( 'touchend', '.has-ripple-feedback', rippleItemTapOff ); 465 507 466 508 // Redirect all content hyperlinks clicks 509 // @todo: put it into prepareContent() 510 $("#app-layout").on("click", ".single-content a", openInBrowser); 467 511 468 512 /* … … 749 793 } else { // href begins with # (ie. it's an internal link) 750 794 751 App.navigate( href ); // Navigate to the corresponding screen 752 753 } 754 795 App.navigate( href ); 796 797 } 755 798 756 799 } -
wp-appkit/trunk/default-themes/q-android/layout.html
r1634492 r1750923 13 13 <div id="menu-button" class="menu-button"></div> 14 14 <div id="refresh-button" class="refresh-off"></div> 15 <div class="loading-from-remote-button refresh-on" style="display:none"></div> 15 16 <h1></h1> 16 17 </div> … … 26 27 <div id="panel-header" class="panel-header has-ripple-feedback ripple-small"> 27 28 <div id="back-button" class="back-button"></div> 29 <div class="loading-from-remote-button refresh-on" style="display:none"></div> 28 30 <h1></h1> 29 31 </div> -
wp-appkit/trunk/default-themes/q-android/readme.md
r1703622 r1750923 2 2 Theme Name: Q for Android 3 3 Description: A clean and simple Android app news theme featuring: back button, comments, content refresh, custom post types, embeds, infinite list, latest posts, native sharing, network detection, off-canvas menu, offline content, pages, posts, pull to refresh, responsive, status bar, touch, transitions 4 Version: 1.0. 54 Version: 1.0.6 5 5 Theme URI: https://github.com/uncatcrea/q-android 6 6 Author: Uncategorized Creations -
wp-appkit/trunk/default-themes/q-android/single.html
r1634492 r1750923 39 39 <div id="single-content" class="single-content"> 40 40 41 <%= post.content %>41 <%= post.content %> 42 42 43 </div>43 </div> 44 44 45 45 </div> -
wp-appkit/trunk/default-themes/q-ios/js/functions.js
r1634492 r1750923 104 104 105 105 } ); 106 106 107 //@desc Memorize the last history action so that we can decide what to do when 108 //doing "single to single" transitions: 109 var last_history_action = ''; 110 111 // @desc Catch if we're going to a single and coming from a single (it is the case when clicking on a post in the last posts widget at the bottom of a post) 112 // Update properly the history stack 113 App.filter( 'make-history', function( history_action, history_stack, queried_screen, current_screen, previous_screen ) { 114 115 if( queried_screen.screen_type === 'single' && current_screen.screen_type === 'single' ) { 116 if ( ( queried_screen.item_id !== previous_screen.item_id ) ) { // Going to a single to another single that is not the one we came from 117 history_action = 'push'; 118 } else { // Going back to the previous single 119 history_action = 'pop'; 120 } 121 } 122 123 last_history_action = history_action; 124 125 // Return the proper history action 126 return history_action; 127 128 }); 129 130 // @desc Handle "single to single" transition: 131 App.filter( 'transition-direction', function( transition, current_screen, next_screen ){ 132 133 if( current_screen.screen_type === 'single' && next_screen.screen_type === 'single' ) { 134 if ( last_history_action === 'push' ) { 135 transition = 'next-screen'; 136 } else { 137 transition = 'previous-screen'; 138 } 139 140 } 141 142 return transition; 143 }); 144 145 // @desc Handle transitions for deeplinks: 146 App.filter( 'transition-direction', function( transition, current_screen, next_screen ){ 147 148 //Display single in a slide up panel when opening from deeplinks: 149 if( next_screen.screen_type === 'single' && _.isEmpty( current_screen ) ) { 150 transition = 'next-screen'; 151 } 152 153 return transition; 154 }); 107 155 108 156 … … 283 331 }); 284 332 333 // @desc The app starts retrieving a new post from remote server 334 App.on('info:load-item-from-remote:start',function(){ 335 // Start refresh icon animation 336 $("#refresh-button").removeClass("refresh-off").addClass("refresh-on"); 337 }); 338 339 // @desc A new post was retrieved from remote server 340 App.on('info:load-item-from-remote:stop',function(){ 341 // Stop refresh icon animation 342 $("#refresh-button").removeClass("refresh-on").addClass("refresh-off"); 343 }); 344 285 345 // @desc An error occurs 286 346 // @param error -
wp-appkit/trunk/default-themes/q-ios/readme.md
r1703622 r1750923 2 2 Theme Name: Q for iOS 3 3 Description: A clean and simple iOS app news theme featuring: back button, content refresh, custom post types, embeds, infinite list, network detection, off-canvas menu, offline content, pages, posts, responsive, touch, transitions 4 Version: 1.0. 54 Version: 1.0.6 5 5 Theme URI: https://github.com/uncatcrea/q-ios/ 6 6 Author: Uncategorized Creations -
wp-appkit/trunk/lib/components/components-bo-settings.php
r1634492 r1750923 296 296 } 297 297 298 if ( is_numeric( $component_label ) ) { 299 $answer['message'] = __( "The component label can't be numeric.", WpAppKit::i18n_domain ); 300 self::exit_sending_json( $answer ); 301 } 302 303 $component_slug = $edit ? trim( $data['component_slug'] ) : $component_label; 298 $component_slug = $edit ? trim( $data['component_slug'] ) : ( !is_numeric( $component_label ) ? $component_label : 'slug-'. $component_label ); 304 299 $component_slug = sanitize_title_with_dashes( remove_accents( $component_slug ) ); 305 300 -
wp-appkit/trunk/lib/components/components-types/page.php
r1634492 r1750923 128 128 foreach ( $items_ids as $post_id ) { 129 129 $post = get_post( $post_id ); 130 if( !empty($post) ) {130 if( !empty($post) && $post->post_status == 'publish' && $post->post_type == 'page' ) { 131 131 $posts_by_ids[$post_id] = self::get_page_data( $component, $post ); 132 132 } -
wp-appkit/trunk/lib/components/components-utils.php
r1634492 r1750923 7 7 */ 8 8 public static function get_post_data( $wp_post, $component = null ) { 9 9 10 10 if ( $component === null ) { 11 11 $component = new WpakComponent( 'wpak-internal', 'Internal', 'wpak-internal' ); 12 12 } 13 13 14 14 global $post; 15 15 $post = $wp_post; … … 20 20 'post_type' => $post->post_type, 21 21 'date' => strtotime( $post->post_date ), 22 'title' => $post->post_title,22 'title' => apply_filters( 'the_title', $post->post_title, $post->ID ), 23 23 'content' => '', 24 24 'excerpt' => '', … … 52 52 $post_featured_img_id = get_post_thumbnail_id( $post->ID ); 53 53 if ( !empty( $post_featured_img_id ) ) { 54 54 55 55 /** 56 56 * Use this 'wpak_post_featured_image_size' to define a specific image … … 59 59 */ 60 60 $featured_image_size = apply_filters( 'wpak_post_featured_image_size', 'full', $post, $component ); 61 61 62 62 $featured_img_src = wp_get_attachment_image_src( $post_featured_img_id, $featured_image_size ); 63 @$post_data['thumbnail']['src'] = $featured_img_src[0]; 63 $post_data['thumbnail'] = array(); 64 $post_data['thumbnail']['src'] = $featured_img_src[0]; 64 65 $post_data['thumbnail']['width'] = $featured_img_src[1]; 65 66 $post_data['thumbnail']['height'] = $featured_img_src[2]; … … 79 80 return $post_data; 80 81 } 81 82 82 83 public static function get_formated_content() { 83 84 84 85 //Set global $more to 1 so that get_the_content() behaves correctly with <!-- more --> tag: 85 86 //(See wp-includes/class-wp.php::register_globals() and get_the_content()) 86 87 global $more; 87 $more = 1; 88 88 $more = 1; 89 89 90 $post = get_post(); 90 91 … … 109 110 $content = strip_tags( $content, $allowed_tags ); 110 111 } 111 112 112 113 /** 113 114 * Filter a single post content. -
wp-appkit/trunk/lib/themes/themes-storage.php
r1634492 r1750923 93 93 94 94 if( empty($themes) || !isset( $themes['current_theme'] ) ) { 95 if ( !is_array( $themes ) ) { 96 $themes = array(); 97 } 95 98 $themes['current_theme'] = ''; 96 99 } -
wp-appkit/trunk/lib/themes/themes.php
r1703622 r1750923 19 19 'q-ios' => array( 20 20 'name' => 'Q for iOS', 21 'version' => '1.0. 5',21 'version' => '1.0.6', 22 22 ), 23 23 24 24 'q-android' => array( 25 25 'name' => 'Q for Android', 26 'version' => '1.0. 5',26 'version' => '1.0.6', 27 27 ), 28 28 -
wp-appkit/trunk/readme.txt
r1703651 r1750923 4 4 Requires at least: 4.0 5 5 Tested up to: 4.8 6 Stable tag: 1. 16 Stable tag: 1.2 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 113 113 114 114 Also see [changelog on github](https://github.com/uncatcrea/wp-appkit/blob/master/CHANGELOG.md) for full details. 115 116 = 1.2 (2017-10-22) = 117 118 *Features* 119 120 * Automatically retrieve posts and pages from server if not in the app 121 * Allow easy comment screen refresh from theme 122 123 *Default themes update* 124 125 * Embed last version (1.0.6) of [Q for iOS](https://github.com/uncatcrea/q-ios/releases/tag/v1.0.6) and [Q for Android](https://github.com/uncatcrea/q-android/releases/tag/v1.0.6) default app themes 126 127 *Bugfixes* 128 129 * Better history management when re-triggering same route 130 * Can't go back from custom page 131 * Component's label can't be numeric 132 * Apply "the_title" filter on post title returned in webservice 133 * Warning: Illegal string offset 'current_theme' 134 * Warning on post's thumbnail array 115 135 116 136 = 1.1 (2017-07-26) = -
wp-appkit/trunk/wp-appkit.php
r1703622 r1750923 4 4 Plugin URI: https://github.com/uncatcrea/wp-appkit 5 5 Description: Build Phonegap Mobile apps based on your WordPress content. 6 Version: 1. 16 Version: 1.2 7 7 Author: Uncategorized Creations 8 8 Author URI: http://getwpappkit.com
Note: See TracChangeset
for help on using the changeset viewer.