Created
October 15, 2010 03:11
-
-
Save nenjiru/627543 to your computer and use it in GitHub Desktop.
別窓展開 jQuery plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////////// | |
// Open new window - jQuery plugin | |
// target属性で指定する別窓展開プラグイン | |
// | |
// Copyright 2010, Minoru Nakanow | |
// Licensed under the MIT licenses. | |
// http://www.opensource.org/licenses/mit-license.html | |
// | |
// Usage: | |
// <a href="example.html?width=full&height=full" target="new">全画面展開</a></p> | |
// <a href="example.html?width=400&height=400" target="new">サイズ指定あり</a></p> | |
// <a href="example.html" target="new" title="newwindow">サイズ指定なし</a></p> | |
// | |
// $("a.[target=new]").newWindow(); | |
// | |
//////////////////////////////////////////////////////////////////////////////// | |
(function($) { | |
//-------------------------------------------------------------------------- | |
// jQuery extend | |
//-------------------------------------------------------------------------- | |
jQuery.fn.extend({ | |
/** | |
* Open new window | |
* | |
* @requires jquery.toObject.js | |
* @return {jQuery} | |
*/ | |
newWindow: function() { | |
return this.each(function() { | |
var init = "toolbar = no" | |
+", menubar = no" | |
+", location = no" | |
+", scrollbars = no" | |
+", directories = no" | |
+", status = no" | |
+", resizable = no"; | |
$(this).bind("click", function() { | |
var link = $(this); | |
var url = link.attr("href"); | |
var size = $.toObject(url); | |
var name = link.attr("title") || "newWindow"; | |
if (size.width) init += ", width="+ ((size.width == "full") ? screen.availWidth : size.width); | |
if (size.height) init += ", height="+ ((size.width == "full") ? screen.availHeight : size.height); | |
var newWindow = window.open(url, name, init); | |
newWindow.focus(); | |
return false; | |
}); | |
}); | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment