From ec2d586f5c165980308a6719c7d8d39d0cd1b205 Mon Sep 17 00:00:00 2001 From: Todd Horst Date: Fri, 18 Apr 2014 13:30:04 -0400 Subject: [PATCH 1/4] only object api allow user to only pass in an object, with a key of url. maintains backwards compatibility. --- jquery.popupwindow.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jquery.popupwindow.js b/jquery.popupwindow.js index 79ed5a6..61dad06 100644 --- a/jquery.popupwindow.js +++ b/jquery.popupwindow.js @@ -18,10 +18,15 @@ status: false, toolbar: false, top: 0, - width: 500 + width: 500, + url: "" }; $.popupWindow = function(url, opts) { + if ($.isPlainObject(url)) { + opts = url; + url = opts.url; + } var options = $.extend({}, defaults, opts); // center the window From e88631103e0828963352553df6a4b1a448a3ac45 Mon Sep 17 00:00:00 2001 From: Todd Horst Date: Mon, 21 Apr 2014 07:17:53 -0400 Subject: [PATCH 2/4] Fix indent --- jquery.popupwindow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.popupwindow.js b/jquery.popupwindow.js index 61dad06..46c1028 100644 --- a/jquery.popupwindow.js +++ b/jquery.popupwindow.js @@ -19,7 +19,7 @@ toolbar: false, top: 0, width: 500, - url: "" + url: "" }; $.popupWindow = function(url, opts) { From df17d7d93f01f990aa89cdd76ee6039ab02a9ff9 Mon Sep 17 00:00:00 2001 From: Todd Horst Date: Tue, 22 Apr 2014 09:00:02 -0400 Subject: [PATCH 3/4] Update object as parameter --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a1b862c..abd1248 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,16 @@ minimal chrome. $.popupWindow('http://www.google.com', { height: 300, width: 200 }); ``` +### Simple Example with Object as Parameter + +Another option is to call `popupWindow` with a single object that contains a url +key and any other settings. This is functionally the same as the above example +and is only a stylistic difference. + +``` +$.popupWindow({ url: 'http://www.google.com', height: 300, width: 200 }); +``` + ### More Examples There are more [examples] to look at as well. From 1c882e8034f5f6ee18ee521c0697e4ef2c68231d Mon Sep 17 00:00:00 2001 From: Todd Horst Date: Fri, 25 Apr 2014 14:50:17 -0400 Subject: [PATCH 4/4] Add object only example --- example.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/example.html b/example.html index 610e0b6..1547a02 100644 --- a/example.html +++ b/example.html @@ -28,6 +28,14 @@ } }); }); + + $('.example-objectapi').on('click', function(event) { + event.preventDefault(); + $.popupWindow({ + url: 'http://google.com' + }); + }); + }) @@ -41,6 +49,7 @@

Examples

  • Open window (with defaults)
  • Open window (custom size: 200x200)
  • Open window (close callback)
  • +
  • Object API
  • More Details