This problems seems to be an issue on some web servers with filenames with ".cookie" in them. It took me a while to find the solution, so I thought other users of this module might appreciate the info. Perhaps the default file names could change to use an underscore to avoid any changes?

* Rename /sites/all/modules/text_resize/jquery.cookie.js to jquery_cookie.js ("." to "_")
* In your page.tpl.php file in your theme templates folder (or copy from your base theme) change
print $scripts;
to
print str_replace("jquery.cookie.js", "jquery_cookie.js", $scripts);

Hope this helps.

Comments

attheshow’s picture

Status: Active » Closed (won't fix)

Because the jquery cookie is an existing project outside of Text Resize, I'd rather stick with the name of the current project file. Thanks for the info though.

MJD’s picture

For anyone using CiviCRM... this module will break all the CiviCRM javascript (JS) for dates / access keys etc on most admin pages...

As the maintainer has marked this as "won't fix"... I'm just posting this for anyone else who may experience problems now or in the future...

p.s. I'm still checking but I think it is the $.cookie that's the problem in jquery.cookie.js

fuerst’s picture

Status: Closed (won't fix) » Needs review

The reason for this error probably is you are using multiple jQuery installations at the same page. That's the case when running CiviCRM (at least 3.1.3) as Drupal module. The jQuery documentation has a solution for this: http://api.jquery.com/ready/ (in the Aliasing the jQuery Namespace section).

You can get it working by changing line 4 of modules/text_resize/text_resize.js from

$(document).ready(function() {

to

$(document).ready(function($) {

BTW: Same issue in the Superfish module: #761034: Superfish and CiviCRM 3.1.3 conflict

jhedstrom’s picture

Why not use Drupal.behaviors instead?

Drupal.behaviors.textResize = function (context) {
...
}
attheshow’s picture

Status: Needs review » Closed (won't fix)

Still haven't seen a convincing argument for changing the code here. Setting back to won't fix.

mrfelton’s picture

Status: Closed (won't fix) » Active

This is definitely a problem when using in conjunction with CiviCRM. Using Drupal.behaviors would surely be a better approach... any specific reason why you are not using Drupal.behaviors?

attheshow’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Status: Active » Needs review

Read a little more about Drupal.behaviors and it sounds like that is a convention. Give the dev version a shot please and see if this fixes the issue.

mparker17’s picture

@attheshow — I've confirmed that it works correctly with Drupal 6.19, CiviCRM 3.2.0 and the development version of text_resize-6.x-1.x from 2010-Sep-26!

Someone should probably test and confirm that it works with the latest stable CiviCRM before marking it as RTBC.

attheshow’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

3dloco’s picture

Version: 6.x-1.x-dev » 6.x-1.6
Status: Closed (fixed) » Active

Reopening as I am still getting this error even after upgrading to 1.6...
Firebug points to text_resize.js

 // Set the initial font size if necessary
  if ($.cookie('text_resize') != null) {
    element_to_resize.css('font-size', parseFloat($.cookie('text_resize')) + 'px');
    //alert( "Should be size: " + $.cookie('text_resize'));
  }
attheshow’s picture

Status: Active » Postponed (maintainer needs more info)

Are you using CiviCRM? Or is your issue unrelated to the issue above? Just the same error?

attheshow’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Re-marking this as fixed.

EmperorForearm’s picture

Status: Closed (fixed) » Active

I'm getting the same javascript error as 3dloco using the latest 1.6 version, but I am not using CiviCRM. I have this module working on a different site (with a different theme) and would love to get it working on this current site as well.

EmperorForearm’s picture

Realizing that I haven't included much information I wanted to add the following in the hopes of getting a response:

Drupal Core 6.22
Theme is from Template Monster and required explicit loading of Jquery (isn't included in the print $scripts action)
In addition to not re-sizing the page when the options are selected, it breaks the yui menu.

mbsmetal’s picture

Hi,

Just Copy the line of code in below of 'print $scripts;' in page.tpl.php file (ur Theme Directory):

  print '<script src="' . $base_path . 'sites/all/libraries/jquery.ui/external/jquery.cookie.js" type="text/javascript"></script>';

this line will insert jquery.cookie.js in your theme.

attheshow’s picture

Status: Active » Postponed (maintainer needs more info)

@EmperorForearm - I'm going to need to know how to duplicate the problem before I can do anything to fix it. Do you have a public-facing site that showcases the error you mention?

EmperorForearm’s picture

Status: Postponed (maintainer needs more info) » Active

@mbsmetal Thanks for the tip , but I've tried calling jquery.cookie.js using the line you provided (file location changed appropriately) as well as a couple of other versions with no luck.

@atttheshow I've messaged you a site where you can see the error, the conversation can continue there or here as appropriate. (obviously the solution should end up here)

EmperorForearm’s picture

@mbsmetal Thanks for the tip , but I've tried calling jquery.cookie.js using the line you provided (file location changed appropriately) as well as a couple of other versions with no luck.

@atttheshow I've messaged you a site where you can see the error, the conversation can continue there or here as appropriate. (obviously the solution should end up here)

attheshow’s picture

@EmporerForearm, I do see that error on your site you emailed to me, but it looks like the necessary .js files are included in the head tag. I'd try disabling other custom scripts to see if one of those is causing the problem. Also, be sure you are using $scripts to print out all JS. That could well be the problem if the theme has the funky configuration you mentioned above.

EmperorForearm’s picture

Status: Active » Closed (fixed)

I've found the culprit
<script type="text/javascript" src="<?php print base_path().path_to_theme() ?>/js/jquery00.js"></script>
This code is in the page.tpl file, and is for the slider that comes with the theme. Unfortunately, removing it causes the image slider not to work (the only part that was working).

After much ado, I was able to get the problem script loaded in the template .php by adding the line

<?php
drupal_add_js(drupal_get_path('theme', 'mytheme') .'/js/jquery00.js', 'theme');
?>

Now the menu, slider, and text resize all play nice together

Thanks for your patience, and help.

novicesmith’s picture

I donot know whether this will help

Drupal.behaviors.formPrepopulateFromCookie = {
  attach: function (context, settings) {
    $('form.form-prepopulate-from-cookie').once('form-prepopulate-from-cookie', function () {
      var formContext = this;
      $.each(['name', 'mail', 'homepage'], function () {
        var $element = $('[name=' + this + ']', formContext);
        var cookie = $.cookie('Drupal.visitor.' + this);
        if ($element.length && cookie) {
          $element.val(cookie);
        }
      });
    });
  }
};

I change the code and it help

avinash_thombre’s picture

Issue summary: View changes

There are instances when $.cookie function does not work. For such instances use another method. Place this code in your js file:

function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

Then you can use, setCookie(cname, cvalue, exdays) and getCookie(cname) to use set and get cookie functionalities.