Skip to content

Commit

Permalink
Commit of Popit plugin JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
offthehandle committed May 24, 2014
1 parent ad515f1 commit 66d3ce9
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
53 changes: 53 additions & 0 deletions js/jquery.popit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

/*
* Popit Plugin for jQuery JavaScript Library
*
* Copyright (c) 2014 Adam J De Lucia
* Licensed under the MIT License.
* http://opensource.org/licenses/MIT
*
* Author: Adam J De Lucia
* Version: 1.0.0
* Date: May 24 2014
*
*/

$.fn.popit = function (options) {
this.each(function () {
var settings = $.extend({
popup: $(this),
defaultWidth: 960,
defaultHeight: 285,
url: $(this).attr("href"),
name: $(this).attr("target"),
dynamicWidth: $(this).data("width"),
dynamicHeight: $(this).data("height")
}, options);

var show = function (e) {
e.preventDefault();
if (settings.dynamicWidth && settings.dynamicHeight) {
var popitWindow = window.open(settings.url, settings.name, "location=0, menubar=0, status=0, toolbar=0, width=" + settings.dynamicWidth + ", height=" + settings.dynamicHeight + '"', false)
} else if (settings.dynamicWidth || settings.dynamicHeight) {
if (settings.dynamicWidth) {
var popitWindow = window.open(settings.url, settings.name, "location=0, menubar=0, status=0, toolbar=0, width=" + settings.dynamicWidth + ", height=" + settings.defaultHeight + '"', false)
} else {
var popitWindow = window.open(settings.url, settings.name, "location=0, menubar=0, status=0, toolbar=0, width=" + settings.defaultWidth + ", height=" + settings.dynamicHeight + '"', false)
}
} else {
var popitWindow = window.open(settings.url, settings.name, "location=0, menubar=0, status=0, toolbar=0, width=" + settings.defaultWidth + ", height=" + settings.defaultHeight + '"', false)
}

// Brings the new window to the front
popitWindow.focus();

// Reloads window to process JS like location.hash for playlist index in named windows
var isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
if (!isFirefox) popitWindow.location.reload();
if (isFirefox) popitWindow.history.go(0);
return popitWindow;
};

settings.popup.on("click.popit", show);
});
};
18 changes: 18 additions & 0 deletions js/jquery.popit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions js/jquery.popit.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 66d3ce9

Please sign in to comment.