Rushabh Mehta | 3a751e8 | 2012-01-27 18:00:14 +0530 | [diff] [blame] | 1 | |
| 2 | pscript.onload_blog = function(wrapper) { |
| 3 | wrapper.blog_list = new wn.widgets.Listing({ |
| 4 | parent: $(wrapper).find('.web-main-section').get(0), |
| 5 | query: 'select tabBlog.name, title, left(content, 300) as content, tabBlog.modified, \ |
| 6 | ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \ |
| 7 | from tabProfile, tabBlog\ |
| 8 | where ifnull(published,1)=1 and tabBlog.owner = tabProfile.name', |
| 9 | hide_refresh: true, |
| 10 | render_row: function(parent, data) { |
| 11 | if(data.content.length==300) data.content += '...'; |
| 12 | data.date = prettyDate(data.modified); |
| 13 | parent.innerHTML = repl('<h4><a href="#!%(name)s">%(title)s</a></h4>\ |
| 14 | <div class="help">By %(first_name)s %(last_name)s on %(date)s</div>\ |
| 15 | <p><div class="comment">%(content)s</div></p><br>', data); |
| 16 | }, |
| 17 | page_length: 10 |
| 18 | }); |
| 19 | wrapper.blog_list.run(); |
| 20 | |
| 21 | // subscribe button |
| 22 | $('#blog-subscribe').click(function() { |
| 23 | var email = $(wrapper).find('input[name="blog-subscribe"]').val(); |
| 24 | if(!validate_email(email)) { |
| 25 | msgprint('Please enter a valid email!'); |
| 26 | } |
| 27 | wn.call({ |
| 28 | module:'website', |
| 29 | page:'blog', |
| 30 | method:'subscribe', |
| 31 | args:email, |
| 32 | btn: this, |
| 33 | callback: function() { |
| 34 | $(wrapper).find('input[name="blog-subscribe"]').val(''); |
| 35 | } |
| 36 | }); |
| 37 | }) |
| 38 | } |