|
|
Forum moderator: bigblog |
uCoz Community » For Webmasters » Custom Solutions » Entry Preview in Modules |
Entry Preview in Modules |
The script works in the following way: after you've entered a post, the option to preview it before posting appears.
The script must be pasted after $BODY$ 1. Uses the preview feature of private messages: Pros: it is not necessary to install the Forum module. Cons: only BB codes can be used. Code <script type="text/javascript"> /* * Author: Sheriff * http://fi4a.ru/ */ function fi4adotru(){ var brf = $('#brief').val(); if(brf == '') brf = 'The brief description is not filled in!'; new _uWnd('fi4adotru', 'Entry brief description', 350, 250, {autosize:1}, {url:'/index/',xml:false,type:'post',data:{message:brf,a:70}}); } function fi4aru(){ var msg = $('#message').val(); if(msg == '') msg = 'The full entry text is not filled in!'; new _uWnd('fi4aru', 'Full entry text', 350, 250, {autosize:1}, {url:'/index/',xml:false,type:'post',data:{message:msg,a:70}}); } $("#brief").after("<input type='button' title='Entry preview' onclick='fi4adotru();' value='Preview' style='margin-left:20px;' class='codeButtons'>"); $("#message").after("<input type='button' title='Entry preview' onclick='fi4aru();' value='Preview' style='margin-left:20px;' class='codeButtons'>"); </script> 2. Uses the preview feature of the Forum module: Pros: both BB codes and HTML tags can be used. *Note: the Forum module must be installed, and the necessary groups should be allowed to use HTML tags (Control Panel -> Users -> User groups). Code <script type="text/javascript"> /* * Author: Sheriff * http://fi4a.ru/ */ function fi4adotru(){ var brf = $('#brief').val(); if(brf == '') brf = 'The brief description is not filled in!'; new _uWnd('fi4adotru', 'Entry brief description', 350, 250, {autosize:1}, {url:'/forum/',xml:false,type:'post',data:{message:brf,frmt1:1,ahtml1:1,sm:1,a:32}}); } function fi4aru(){ var msg = $('#message').val(); if(msg == '') msg = 'The full entry text is not filled in!'; new _uWnd('fi4aru', 'Full entry text', 350, 250, {autosize:1}, {url:'/forum/',xml:false,type:'post',data:{message:msg,frmt1:1,ahtml1:1,sm:1,a:32}}); } $("#brief").after("<input type='button' title='Entry preview' onclick='fi4adotru();' value='Preview' style='margin-left:20px;' class='codeButtons'>"); $("#message").after("<input type='button' title='Entry preview' onclick='fi4aru();' value='Preview' style='margin-left:20px;' class='codeButtons'>"); </script> 3. Uses the standard JS features: Pros: doesn't use the system modules, and doesn't send requests to the server. Code <script type="text/javascript"> /* * Author: Sheriff * http://fi4a.ru/ */ function fi4a(ru) { var text = $('#'+ru).val(); text = text.split('\n').join('<br/>').split('[l]').join('<div align=\'left\'>').split('[/l]').join('</div>').split('[r]').join('<div align=\'right\'>').split('[/r]').join('</div>').split('[c]').join('<div align=\'center\'>').split('[/c]').join('</div>').split('[img]').join('<img src=\'').split('[/img]').join('\'/>').split('[url').join('<a href').split('url]').join('a>').split('[size').join('<font size').split('size]').join('font>').split('[color').join('<font color').split('color]').join('font>').split('<').join('<').split('[').join('<').split(']').join('>').split('[/').join('</'); if(text == '') text = 'The entry description is not filled in!'; new _uWnd('HelpWd','Entry preview',350, 250, {modal:1,autosize:1,closeonesc:1,resize:1,align:'justify',maxh:400},''+text+'');return false; } $("#brief").after('<input type="button" title="Entry preview" onclick="fi4a(\'brief\')" value="Preview (HTML + BB)" style="margin-left:20px;" class="codeButtons">'); $("#message").after('<input type="button" title="Entry preview" onclick="fi4a(\'message\')" value="Preview (HTML + BB)" style="margin-left:20px;" class="codeButtons">'); </script> *Note: some modules, like Site News, Blog, FAQ don't have a separate entry posting page, therefore in these modules the script must be used with $PAGE_ID$: Code <?if($PAGE_ID$="add")?>SCRIPT<?endif?> I'm not active on the forum anymore. Please contact other forum staff.
|
Sunny, Yes I did dear . But you know what ...! I get the preview button but when I add content to the short and full description and hit the preview it it says " Entry not filled in " That's why I would need to know how to use it please.
Visit and Register with our website now !![ Looking for Posters and up-loaders ]
http://www.tinymb.com |
| |||
| |||