Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Improve zoom plugin #5407

Closed
wants to merge 3 commits into from

4 participants

@doom777

Zoom plugin was scanning for initially disabled zoom with an improper regex that didn't catch every case. This patches the regex string, which will now catch more cases where zoom should be set to to initiallydisabled.

See later comments of issue #4024 where white screen flashes during transitions; this is what fixed it for me.

@nickwb

Good patch.
Perhaps you should consider adding support for user-scalable=0 also.

@doom777

@nickwb you're right, according to http://dev.w3.org/csswg/css-device-adapt/#meta-properties, acceptable values are yes, ≤-1, ≥1 or no, and between 1 and -1

@doom777 doom777 Update js/jquery.mobile.zoom.js
fixed up more regex to be more to spec; see http://dev.w3.org/csswg/css-device-adapt/#meta-properties
which says user-scalable can be yes, no, or a number, where anything between 1 and -1 is interpreted as no. Also switched to non-capturing groups
496c305
@gseguin
Collaborator

@doom777, It seems like you haven't signed a CLA. Please visit http://contribute.jquery.org/CLA/ and sign it so we can look into your PR.

Thank you.

@arschmitz
Owner

no reply to CLA request closing

@arschmitz arschmitz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2012
  1. @doom777
  2. @doom777
Commits on Jan 7, 2013
  1. @doom777

    Update js/jquery.mobile.zoom.js

    doom777 authored
    fixed up more regex to be more to spec; see http://dev.w3.org/csswg/css-device-adapt/#meta-properties
    which says user-scalable can be yes, no, or a number, where anything between 1 and -1 is interpreted as no. Also switched to non-capturing groups
This page is out of date. Refresh to see the latest.
View
2  js/jquery.mobile.zoom.js
@@ -10,7 +10,7 @@ define( [ "jquery", "./jquery.mobile.core" ], function( $ ) {
initialContent = meta.attr( "content" ),
disabledZoom = initialContent + ",maximum-scale=1, user-scalable=no",
enabledZoom = initialContent + ",maximum-scale=10, user-scalable=yes",
- disabledInitially = /(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test( initialContent );
+ disabledInitially = /(?:user-scalable\s*=\s*(?:no(?:,|\s|$)|-?0(?:,|\.\d|\s|$)))|(?:maximum-scale\s*=\s*1)(?:,|\.0|\s|$)/.test( initialContent );
$.mobile.zoom = $.extend( {}, {
enabled: !disabledInitially,
View
46 tests/unit/zoom/initial-disable-maxscale.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>jQuery Mobile Zoom Maniplation Integration Test</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0">
+
+ <script src="../../../external/requirejs/require.js"></script>
+ <script src="../../../js/jquery.js"></script>
+ <script src="../jquery.setNameSpace.js"></script>
+ <script src="../../../tests/jquery.testHelper.js"></script>
+ <script src="../../../external/qunit.js"></script>
+ <script>
+ $.testHelper.asyncLoad([
+ [
+ "jquery.mobile.zoom"
+ ],
+ [ "jquery.mobile.init" ],
+ [
+ "./zoom-initial-disable.js"
+ ]
+ ]);
+ </script>
+
+ <link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
+ <link rel="stylesheet" href="../../../external/qunit.css"/>
+
+ <script src="../swarminject.js"></script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery Mobile FieldContainer Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests">
+</ol>
+
+<div data-nstest-role="page">
+
+
+</div>
+
+
+
+</body>
+</html>
Something went wrong with that request. Please try again.