PHP Web Host - Quality Web Hosting For All PHP Applications $35/month $250/year (Unlimited) - $25/month - 200,000 impressions - Your Ad Could be Here - Click For Details
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
benny_tllh
Hangin' Around


Joined: Dec 29, 2006
Posts: 31

PostPosted: Tue Jun 15, 2010 2:33 pm Reply with quote Back to top

Found this
Only registered users can see links on this board!
Get registered or login to the forums!


but putting it in includes/javascript.php only collapses textarea it wont expand on click.

I would like to use it on my intranet where i have big bulky forms.

(i opened the example's source code, inserted head stuff outside php tags in javascript.php, and added class to form and text area in my module)

anyone know how to integrate it correct in a module if possible ?
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Tue Jun 15, 2010 3:06 pm Reply with quote Back to top

Make a file called head-collapse_textarea.php and put the following code in it. Then upload it to includes/addons/. Then you should be able to use this all over your site. You will just have to add "class="collapse_tareas" to your forms.

Code:

<?php

$inlineCSS = '
<style type="text/css">
   .collapse_tareas input, .collapse_tareas textarea { font: 10pt arial, sans-serif; border: 1px solid #888; }
   .collapse_tareas textarea { height: 1.45em; }
   .collapse_tareas textarea.compact { height: 1.45em !important; }
   .collapse_tareas textarea.expanded { height: 5em !important; }
</style>';
addCSSToHead($inlineCSS, 'inline');

$inlineJS = '<script type="text/javascript">
      /*  Collapsible Textareas, version 1.0
       *  (c) 2007 SiteCrafting, Inc. <service@sitecrafting.com>
       *
       *  Collapsible Textareas is available under the Creative Commons Attribution
       *  3.0 License (http://creativecommons.org/licenses/by/3.0/).
       *
      /*--------------------------------------------------------------------------*/


      // find all the forms with textareas we want to allow to collapse
      function setupTextareas() {
         var pageForms = document.getElementsByTagName("form");

         for( var j=0; j<pageForms.length; j++) {
            var formArea = pageForms[j];

            if( formArea.className.indexOf("collapse_tareas") > -1 ) {
               var txtAreas = formArea.getElementsByTagName("textarea");
               for( var i=0; i<txtAreas.length; i++ ) {
                  var thisTxtArea = txtAreas[i];

                  if( thisTxtArea.addEventListener ) {
                     thisTxtArea.addEventListener("focus", bigSmlTextarea, false);
                     thisTxtArea.addEventListener("blur", bigSmlTextarea, false);
                  } else { // IE
                     thisTxtArea.attachEvent("onfocus", bigSmlTextarea);
                     thisTxtArea.attachEvent("onblur", bigSmlTextarea);
                  }
               }
            }
         }
      }

      // collapse or expand a textarea
      function bigSmlTextarea(e)
      {
         var node = ( e.target ? e.target : e.srcElement );

         if( node.className.indexOf("expanded") == -1 )
            node.className += " expanded";
         else
            node.className = node.className.replace(/expanded/gi, "");
      }

      // prep the the desired textareas to collapse and expand
      window.onload = setupTextareas;
</script>';
addJSToHead($inlineJS,'inline');

?>


P.S. For anyone else looking at this code on the linked page it is incomplete. You need to view the example and view source to get the proper javascript.
View user's profile Send private message
benny_tllh
Hangin' Around


Joined: Dec 29, 2006
Posts: 31

PostPosted: Wed Jun 16, 2010 2:01 pm Reply with quote Back to top

Thanks for the speedy answer, where do i put the include for rn2.20.01.
Or is it the last straw that makes a upgrade of RN a thing to use the weekend on. Smile
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Jun 16, 2010 2:53 pm Reply with quote Back to top

includes/custom_files/custom_head.php

Code:

<?php

echo '
<style type="text/css">
   .collapse_tareas input, .collapse_tareas textarea { font: 10pt arial, sans-serif; border: 1px solid #888; }
   .collapse_tareas textarea { height: 1.45em; }
   .collapse_tareas textarea.compact { height: 1.45em !important; }
   .collapse_tareas textarea.expanded { height: 5em !important; }
</style>';

echo '<script type="text/javascript">
      /*  Collapsible Textareas, version 1.0
       *  (c) 2007 SiteCrafting, Inc. <service@sitecrafting.com>
       *
       *  Collapsible Textareas is available under the Creative Commons Attribution
       *  3.0 License (http://creativecommons.org/licenses/by/3.0/).
       *
      /*--------------------------------------------------------------------------*/


      // find all the forms with textareas we want to allow to collapse
      function setupTextareas() {
         var pageForms = document.getElementsByTagName("form");

         for( var j=0; j<pageForms.length; j++) {
            var formArea = pageForms[j];

            if( formArea.className.indexOf("collapse_tareas") > -1 ) {
               var txtAreas = formArea.getElementsByTagName("textarea");
               for( var i=0; i<txtAreas.length; i++ ) {
                  var thisTxtArea = txtAreas[i];

                  if( thisTxtArea.addEventListener ) {
                     thisTxtArea.addEventListener("focus", bigSmlTextarea, false);
                     thisTxtArea.addEventListener("blur", bigSmlTextarea, false);
                  } else { // IE
                     thisTxtArea.attachEvent("onfocus", bigSmlTextarea);
                     thisTxtArea.attachEvent("onblur", bigSmlTextarea);
                  }
               }
            }
         }
      }

      // collapse or expand a textarea
      function bigSmlTextarea(e)
      {
         var node = ( e.target ? e.target : e.srcElement );

         if( node.className.indexOf("expanded") == -1 )
            node.className += " expanded";
         else
            node.className = node.className.replace(/expanded/gi, "");
      }

      // prep the the desired textareas to collapse and expand
      window.onload = setupTextareas;
</script>';

?>


I did not test this as 2.20.01 is not supported anymore. The upgrade may not be the easiest since you are still back on 2.20.01, but I suggest to upgrade.
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum