Results 1 to 7 of 7

Thread: jQuery Image Magnify v1.11--Disable javascript

  1. #1
    Join Date
    Sep 2012
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default jQuery Image Magnify v1.11--Disable javascript

    1) Script Title: jQuery Image Magnify v1.11

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...agemagnify.htm

    3) Describe problem:

    Hello,

    I'm looking for code that will disable the javascript for "jQuery Image Magnify v1.11" on smartphones devices via media queries or some other method?

    Thank you!

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    Just letting you i am doing research but i know you have to place this code somewhere:
    Code:
    if( !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {
     // some code..
    }
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Deadweight is on the right track. Inside the magnifier.js, find the following line, and add to it the part in red below:

    Code:
    jQuery(document).ready(function($){
    	if( !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {
    	 	return //exit
    	}
    "
    "
    That should do the trick.
    DD Admin

  4. #4
    Join Date
    Sep 2012
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi Deadweight,

    Thanks very much for your help, it's greatly appreciated! Unfortunately, I don't know javascript, so I'm having difficulty placing your code in the correct spot within the original javascript. I believe the code should go under the other "if" statements, but then the curly braces seem out of place. Can you assist further? Here is part of the original javascritpt:

    jQuery(document).ready(function($){
    var $targets=$('.magnify')
    $targets.each(function(i){
    var $target=$(this)
    var options={}
    if ($target.attr('data-magnifyto'))
    options.magnifyto=parseFloat($target.attr('data-magnifyto'))
    if ($target.attr('data-magnifyby'))
    options.magnifyby=parseFloat($target.attr('data-magnifyby'))
    if ($target.attr('data-magnifyduration'))
    options.duration=parseInt($target.attr('data-magnifyduration'))
    $target.imageMagnify(options)
    })
    var $triggers=$('a[rel^="magnify["]')
    $triggers.each(function(i){
    var $trigger=$(this)
    var targetid=$trigger.attr('rel').match(/\[.+\]/)[0].replace(/[\[\]']/g, '') //parse 'id' from rel='magnify[id]'
    $trigger.data('magnifyimageid', targetid)
    $trigger.click(function(e){
    $('#'+$(this).data('magnifyimageid')).trigger('click.magnify')
    e.preventDefault()
    })

    })
    })

  5. #5
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    ddadmin said it correctly:
    Code:
    jQuery(document).ready(function($){
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
    	 	return //exit
    var $targets=$('.magnify')
    I had to change it from
    Code:
    if( !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {
    	 	return //exit
    	}
    to
    Code:
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
    	 	return;
    because the first one was saying if its not one of those mobile devices then exit. The second one says if it is one of these then exit
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

  6. The Following User Says Thank You to Deadweight For This Useful Post:

    More2Do (08-15-2014)

  7. #6
    Join Date
    Jun 2013
    Location
    Westminster, MD
    Posts
    18
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default

    I use Image Magnify all over my website (Love it BTW!), can someone quickly explain the benefit/downside of adding this code?

    My Site-> www.boltonhooks.com

  8. #7
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    Are you talking about the code that I posted?
    All it does it not allow it to magnify if it is on a mobile device.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

Similar Threads

  1. jQuery Image Magnify - magnify.cur in IE 10
    By geotso in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 04-09-2013, 02:29 PM
  2. jQuery Image Magnify v1.11
    By armasmike in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 06-08-2011, 07:52 PM
  3. Resolved jQuery Image Magnify v1.11
    By rexi in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 04-15-2011, 11:32 AM
  4. Help with jQuery Image Magnify v1.1
    By MJT in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 12-15-2010, 07:48 PM
  5. Jquery image magnify, magnify onmouseover
    By azoomer in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 10-15-2009, 09:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •