Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 1 | // ERPNext - web based ERP (http://erpnext.com) |
| 2 | // Copyright (C) 2012 Web Notes Technologies Pvt Ltd |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
Rushabh Mehta | 3a751e8 | 2012-01-27 18:00:14 +0530 | [diff] [blame] | 17 | |
| 18 | pscript.onload_blog = function(wrapper) { |
| 19 | wrapper.blog_list = new wn.widgets.Listing({ |
| 20 | parent: $(wrapper).find('.web-main-section').get(0), |
| 21 | query: 'select tabBlog.name, title, left(content, 300) as content, tabBlog.modified, \ |
| 22 | ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \ |
| 23 | from tabProfile, tabBlog\ |
| 24 | where ifnull(published,1)=1 and tabBlog.owner = tabProfile.name', |
| 25 | hide_refresh: true, |
| 26 | render_row: function(parent, data) { |
| 27 | if(data.content.length==300) data.content += '...'; |
| 28 | data.date = prettyDate(data.modified); |
Rushabh Mehta | b8d6497 | 2012-02-08 12:33:13 +0530 | [diff] [blame] | 29 | parent.innerHTML = repl('<h3><a href="#!%(name)s">%(title)s</a></h3>\ |
| 30 | <p><div class="help">By %(first_name)s %(last_name)s on %(date)s</div></p>\ |
| 31 | <div class="comment">%(content)s</div><br>', data); |
Rushabh Mehta | 3a751e8 | 2012-01-27 18:00:14 +0530 | [diff] [blame] | 32 | }, |
| 33 | page_length: 10 |
| 34 | }); |
| 35 | wrapper.blog_list.run(); |
| 36 | |
| 37 | // subscribe button |
| 38 | $('#blog-subscribe').click(function() { |
| 39 | var email = $(wrapper).find('input[name="blog-subscribe"]').val(); |
| 40 | if(!validate_email(email)) { |
| 41 | msgprint('Please enter a valid email!'); |
| 42 | } |
| 43 | wn.call({ |
| 44 | module:'website', |
| 45 | page:'blog', |
| 46 | method:'subscribe', |
| 47 | args:email, |
| 48 | btn: this, |
| 49 | callback: function() { |
| 50 | $(wrapper).find('input[name="blog-subscribe"]').val(''); |
| 51 | } |
| 52 | }); |
| 53 | }) |
| 54 | } |