Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ <h3>The Code</h3>
</div>
</div>

<div class="example">
<h2>iFrame</h2>

<p> <a href="http://www.fire.coop" rel="[facebox]" rev="iframe|700|600">View 'http://www.fire.coop' in the Facebox</a> </p>

<div class="code">
<h3>The Code</h3>
<code>&lt;a href="http://www.fire.coop" rev="iframe|700|600" rel="[facebox]"&gt;text&lt;/a&gt;</code>
</div>
</div>

<div class="example">
<h2>Load Dependencies</h2>

Expand Down
32 changes: 20 additions & 12 deletions src/facebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@
var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
if (klass) klass = klass[1]

fillFaceboxFromHref(this.href, klass)
fillFaceboxFromHref(this.href, klass, this.rev)

return false
}

Expand Down Expand Up @@ -234,23 +235,30 @@
// div: #id
// image: blah.extension
// ajax: anything else
function fillFaceboxFromHref(href, klass) {
function fillFaceboxFromHref(href, klass, rev) {
// div
if (href.match(/#/)) {
var url = window.location.href.split('#')[0]
var target = href.replace(url,'')
if (target == '#') return
$.facebox.reveal($(target).html(), klass)
var url = window.location.href.split('#')[0]
var target = href.replace(url, '')
$.facebox.reveal($(target).clone().show(), klass)

// image
// image
} else if (href.match($.facebox.settings.imageTypesRegexp)) {
fillFaceboxFromImage(href, klass)
// ajax
fillFaceboxFromImage(href, klass)

// iframe
} else if (rev.split('|')[0] == 'iframe') {
fillFaceboxFromIframe(href, klass, rev.split('|')[1], rev.split('|')[2])

// ajax
} else {
fillFaceboxFromAjax(href, klass)
fillFaceboxFromAjax(href, klass)
}
}
}

function fillFaceboxFromIframe(href, klass, width, height) {
$.facebox.reveal('<iframe scrolling="no" marginwidth="0" width="'+width+'" height="' + height + '" frameborder="0" src="' + href + '" marginheight="0"></iframe>', klass)
}
function fillFaceboxFromImage(href, klass) {
var image = new Image()
image.onload = function() {
Expand All @@ -259,7 +267,7 @@
image.src = href
}

function fillFaceboxFromAjax(href, klass) {
function fillFaceboxFromImagex(href, klass) {
$.facebox.jqxhr = $.get(href, function(data) { $.facebox.reveal(data, klass) })
}

Expand Down