From 9f4ae3ba79223fc6ff8db7685f11e33dbc348b75 Mon Sep 17 00:00:00 2001 From: Kin Blas Date: Fri, 17 Jun 2011 18:22:00 -0700 Subject: [PATCH] Documenting isSameDomain(), isRelativeUrl(), isAbsoluteUrl(), makePathAbsolute(), and makeUrlAbsolute(). --- docs/api/methods.html | 190 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 186 insertions(+), 4 deletions(-) diff --git a/docs/api/methods.html b/docs/api/methods.html index ab9a9f37..a6810e8b 100755 --- a/docs/api/methods.html +++ b/docs/api/methods.html @@ -21,7 +21,7 @@
-

jQuery Mobile exposes several methods and properties on the $.mobile object for use in your applications.

+

jQuery Mobile exposes several methods and properties on the $.mobile object for use in your applications.

@@ -244,8 +244,8 @@ $.mobile.hidePageLoadingMsg(); // Parsing the Url below results an object that is returned with the // following properties: // -// obj.href: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content -// obj.hrefNoHash: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread +// obj.href: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content +// obj.hrefNoHash: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread // obj.hrefNoSearch: http://jblas:password@mycompany.com:8080/mail/inbox // obj.domain: http://jblas:password@mycompany.com:8080 // obj.protocol: http: @@ -258,7 +258,7 @@ $.mobile.hidePageLoadingMsg(); // obj.pathname: /mail/inbox // obj.directory: /mail/ // obj.filename: inbox -// obj.search: ?msg=1234&type=unread +// obj.search: ?msg=1234&type=unread // obj.hash: #msg-content var obj = $.mobile.path.parseUrl("http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234"); @@ -268,6 +268,188 @@ var obj = $.mobile.path.parseUrl("http://jblas:password@mycompany.com:8080/mail/ +
$.mobile.path.makePathAbsolute (method)
+
Utility method for converting a relative file or directory path into an absolute path.
+
+
+
Arguments
+
relPath (string, required) A relative file or directory path.
+
absPath (string, required) An absolute file or relative path to resolve against.
+ +
Return Value
+
This function returns a string that is an absolute version of the relative path passed in.
+ +
+
+
Examples: +
+			
+// Returns: /a/b/c/file.html
+var absPath = $.mobile.path.makePathAbsolute("file.html", "/a/b/c/bar.html");
+
+// Returns: /a/foo/file.html
+var absPath = $.mobile.path.makePathAbsolute("../../foo/file.html", "/a/b/c/bar.html");
+
+			
+			
+
+ + +
$.mobile.path.makeUrlAbsolute (method)
+
Utility method for converting a relative URL to an absolute URL.
+
+ +
+
Arguments
+
relUrl (string, required) A relative URL.
+
absUrl (string, required) An absolute URL to resolve against.
+ +
Return Value
+
This function returns a string that is an absolute version of the relative URL passed in.
+ +
+
+
Examples: +
+			
+// Returns: http://foo.com/a/b/c/file.html
+var absUrl = $.mobile.path.makeUrlAbsolute("file.html", "http://foo.com/a/b/c/test.html");
+
+// Returns: http://foo.com/a/foo/file.html
+var absUrl = $.mobile.path.makeUrlAbsolute("../../foo/file.html", "http://foo.com/a/b/c/test.html");
+
+// Returns: http://foo.com/bar/file.html
+var absUrl = $.mobile.path.makeUrlAbsolute("//foo.com/bar/file.html", "http://foo.com/a/b/c/test.html");
+
+// Returns: http://foo.com/a/b/c/test.html?a=1&b=2
+var absUrl = $.mobile.path.makeUrlAbsolute("?a=1&b=2", "http://foo.com/a/b/c/test.html");
+
+// Returns: http://foo.com/a/b/c/test.html#bar
+var absUrl = $.mobile.path.makeUrlAbsolute("#bar", "http://foo.com/a/b/c/test.html");
+
+			
+			
+ +
+ + +
$.mobile.path.isSameDomain (method)
+
Utility method for comparing the domain of 2 URLs.
+
+ +
+
Arguments
+
url1 (string, required) A relative URL.
+
url2 (string, required) An absolute URL to resolve against.
+ +
Return Value
+
This function returns a boolean true if the domains match, false if they don't.
+ +
+
+
Examples: +
+			
+// Returns: true
+var same = $.mobile.path.isSameDomain("http://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
+
+// Returns: false
+var same = $.mobile.path.isSameDomain("file://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
+
+// Returns: false
+var same = $.mobile.path.isSameDomain("https://foo.com/a/file.html", "http://foo.com/a/b/c/test.html");
+
+// Returns: false
+var same = $.mobile.path.isSameDomain("http://foo.com/a/file.html", "http://bar.com/a/b/c/test.html");
+
+			
+			
+ +
+ + +
$.mobile.path.isRelativeUrl (method)
+
Utility method for determining if a URL is a relative variant.
+
+ +
+
Arguments
+
url (string, required) A relative or absolute URL.
+ +
Return Value
+
This function returns a boolean true if the URL is relative, false if it is absolute.
+ +
+
+
Examples: +
+			
+// Returns: false
+var isRel = $.mobile.path.isRelativeUrl("http://foo.com/a/file.html");
+
+// Returns: true
+var isRel = $.mobile.path.isRelativeUrl("//foo.com/a/file.html");
+
+// Returns: true
+var isRel = $.mobile.path.isRelativeUrl("/a/file.html");
+
+// Returns: true
+var isRel = $.mobile.path.isRelativeUrl("file.html");
+
+// Returns: true
+var isRel = $.mobile.path.isRelativeUrl("?a=1&b=2");
+
+// Returns: true
+var isRel = $.mobile.path.isRelativeUrl("#foo");
+
+
+			
+			
+ +
+ + +
$.mobile.path.isAbsoluteUrl (method)
+
Utility method for determining if a URL is absolute.
+
+ +
+
Arguments
+
url (string, required) A relative or absolute URL.
+ +
Return Value
+
This function returns a boolean true if the URL is absolute, false if it is absolute.
+ +
+
+
Examples: +
+			
+// Returns: true
+var isAbs = $.mobile.path.isAbsoluteUrl("http://foo.com/a/file.html");
+
+// Returns: false
+var isAbs = $.mobile.path.isAbsoluteUrl("//foo.com/a/file.html");
+
+// Returns: false
+var isAbs = $.mobile.path.isAbsoluteUrl("/a/file.html");
+
+// Returns: false
+var isAbs = $.mobile.path.isAbsoluteUrl("file.html");
+
+// Returns: false
+var isAbs = $.mobile.path.isAbsoluteUrl("?a=1&b=2");
+
+// Returns: false
+var isAbs = $.mobile.path.isAbsoluteUrl("#foo");
+
+
+			
+			
+ +
+ +
$.mobile.base (methods, properties)
Utilities for working with generated base element. TODO: document as public API is finalized.