From b026a2afe8d6215c79054be612d91f7aafcb0089 Mon Sep 17 00:00:00 2001 From: Sandip Trivedi Date: Thu, 28 May 2015 22:20:52 -0400 Subject: [PATCH] Replaces facebox vendored asset with rails gem #5194 closes #6005 --- Changelog.md | 1 + Gemfile | 2 + Gemfile.lock | 4 + app/assets/images/facebox/closelabel.png | Bin 168 -> 0 bytes app/assets/images/facebox/loading.gif | Bin 2767 -> 0 bytes app/assets/javascripts/main.js | 2 +- app/assets/stylesheets/application.scss | 2 +- app/assets/stylesheets/vendor/facebox.css | 72 ----- vendor/assets/javascripts/facebox.js | 309 ---------------------- 9 files changed, 9 insertions(+), 383 deletions(-) delete mode 100644 app/assets/images/facebox/closelabel.png delete mode 100644 app/assets/images/facebox/loading.gif delete mode 100644 app/assets/stylesheets/vendor/facebox.css delete mode 100644 vendor/assets/javascripts/facebox.js diff --git a/Changelog.md b/Changelog.md index 5ea4158c1..5ae16c5c8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -20,6 +20,7 @@ * Gracefully handle XML parse errors within federation [#5991](https://github.com/diaspora/diaspora/pull/5991) * Remove zip-zip workaround gem [#6001](https://github.com/diaspora/diaspora/pull/6001) * Cleanup and reorganize image assets [#6004](https://github.com/diaspora/diaspora/pull/6004) +* Replace vendored assets for facebox by gem [#6005](https://github.com/diaspora/diaspora/pull/6005) ## Bug fixes * Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846) diff --git a/Gemfile b/Gemfile index 537928c80..0b7ad9875 100644 --- a/Gemfile +++ b/Gemfile @@ -112,6 +112,8 @@ source "https://rails-assets.org" do gem "rails-assets-jakobmattsson--jquery-elastic", "1.6.11" end +gem "facebox-rails", "0.2.0" + # Localization gem "http_accept_language", "2.0.5" diff --git a/Gemfile.lock b/Gemfile.lock index cfd7d8e8d..363901f12 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -182,6 +182,9 @@ GEM sigar (~> 0.7.2) state_machine thor + facebox-rails (0.2.0) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) factory_girl (4.5.0) activesupport (>= 3.0.0) factory_girl_rails (4.5.0) @@ -746,6 +749,7 @@ DEPENDENCIES diaspora-vines (~> 0.1.27) entypo-rails (= 2.2.3) eye (= 0.7.pre) + facebox-rails (= 0.2.0) factory_girl_rails (= 4.5.0) faraday (= 0.9.1) faraday-cookie_jar (= 0.0.6) diff --git a/app/assets/images/facebox/closelabel.png b/app/assets/images/facebox/closelabel.png deleted file mode 100644 index cd04455803cd2a6b1b23504785146faa84fcc64b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFq`JOJ0Arezt`}cA(8;UgBOY4}f z|0=|&KQTwPfNj@o#q*g-JJejJ3cTp=c(HBy66tskskK|vUA`n$Gkrf}5-UighUoqS4*7En} Rdw^Cmc)I$ztaD0e0s!iEL0SL+ diff --git a/app/assets/images/facebox/loading.gif b/app/assets/images/facebox/loading.gif deleted file mode 100644 index f864d5fd38b7466c76b5a36dc0e3e9455c0126e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2767 zcmeH``%_bA0*1eHPVNawNVtR;Fkp-nQj8edfS`v<5L7TgR6wi;WfgH-0}4fE+c_uU zB6tf6auF}FAcDdgg|bMU&H)LR5jARM!8$tuwd$nHqS?K-=JNZ+yGvz=Iegxp{+qWGZ9j{-%9vvN>n3$NJp6==CAqYaF(LfM1Z{EEA{{Gt9 z+Ba|B7z_sR+xabl|E~mm-*OXmhLq??y)HONjX>1ze1D?RIn=G1`RR-%fb}zgSh6^a z(}Zw20U1L^Cs9UcyJfc+al#}J2xVlYUoR{`gd&QDxAb1w4>I~5gc?ccq(G+T!I;H};U_uyHR0@hr>Qk1P1=6fvUBhR zb|&^^cEQtu&W}=-=YR7o5UI)AD*~%J7bkVd5`xrdw{bHm;|Bf^_|FG$9l}`ruhnVF zO%=6X*I#yro*pmfB;-A0cVjz73Q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ets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -12,7 +12,7 @@ //= require jquery.charcount //= require jquery-placeholder //= require rails-timeago -//= require facebox +//= require jquery.facebox //= require browser_detection //= require jquery.events.input //= require jakobmattsson-jquery-elastic diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a4f8ce423..3638522c2 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -47,7 +47,7 @@ /* conversations */ @import 'conversations'; -@import 'vendor/facebox'; +@import 'jquery.facebox'; @import 'facebox'; /* publisher */ diff --git a/app/assets/stylesheets/vendor/facebox.css b/app/assets/stylesheets/vendor/facebox.css deleted file mode 100644 index 511a9ef36..000000000 --- a/app/assets/stylesheets/vendor/facebox.css +++ /dev/null @@ -1,72 +0,0 @@ -#facebox { - position: absolute; - top: 0; - left: 0; - z-index: 100; - text-align: left; -} - -#facebox .popup{ - position:relative; - border:1px solid #999; - border-radius:2px; - box-shadow:0 0 10px rgba(0,0,0,0.8), 0 2px 200px rgba(255,255,255,0.2);; -} - -#facebox .content { - display:table; - width: 370px; - padding: 20px; - background: #fff; - border-radius:2px; -} - -#facebox .content > p:first-child{ - margin-top:0; -} -#facebox .content > p:last-child{ - margin-bottom:0; -} - -#facebox .close{ - position:absolute; - top:15px; - right:20px; - padding:2px; -} -#facebox .close img{ - opacity:0.3; -} -#facebox .close:hover img{ - opacity:1.0; -} - -#facebox .loading { - text-align: center; -} - -#facebox .image { - text-align: center; -} - -#facebox img { - border: 0; - margin: 0; -} - -#facebox_overlay { - position: fixed; - top: 0px; - left: 0px; - height:100%; - width:100%; -} - -.facebox_hide { - z-index:-100; -} - -.facebox_overlayBG { - background-color: #000; - z-index: 99; -} diff --git a/vendor/assets/javascripts/facebox.js b/vendor/assets/javascripts/facebox.js deleted file mode 100644 index 763aa5a8d..000000000 --- a/vendor/assets/javascripts/facebox.js +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Facebox (for jQuery) - * version: 1.3 - * @requires jQuery v1.2 or later - * @homepage https://github.com/defunkt/facebox - * - * Licensed under the MIT: - * http://www.opensource.org/licenses/mit-license.php - * - * Copyright Forever Chris Wanstrath, Kyle Neath - * - * Usage: - * - * jQuery(document).ready(function() { - * jQuery('a[rel*=facebox]').facebox() - * }) - * - * Terms - * Loads the #terms div in the box - * - * Terms - * Loads the terms.html page in the box - * - * Terms - * Loads the terms.png image in the box - * - * - * You can also use it programmatically: - * - * jQuery.facebox('some html') - * jQuery.facebox('some html', 'my-groovy-style') - * - * The above will open a facebox with "some html" as the content. - * - * jQuery.facebox(function($) { - * $.get('blah.html', function(data) { $.facebox(data) }) - * }) - * - * The above will show a loading screen before the passed function is called, - * allowing for a better ajaxy experience. - * - * The facebox function can also display an ajax page, an image, or the contents of a div: - * - * jQuery.facebox({ ajax: 'remote.html' }) - * jQuery.facebox({ ajax: 'remote.html' }, 'my-groovy-style') - * jQuery.facebox({ image: 'stairs.jpg' }) - * jQuery.facebox({ image: 'stairs.jpg' }, 'my-groovy-style') - * jQuery.facebox({ div: '#box' }) - * jQuery.facebox({ div: '#box' }, 'my-groovy-style') - * - * Want to close the facebox? Trigger the 'close.facebox' document event: - * - * jQuery(document).trigger('close.facebox') - * - * Facebox also has a bunch of other hooks: - * - * loading.facebox - * beforeReveal.facebox - * reveal.facebox (aliased as 'afterReveal.facebox') - * init.facebox - * afterClose.facebox - * - * Simply bind a function to any of these hooks: - * - * $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... }) - * - */ -(function($) { - $.facebox = function(data, klass) { - $.facebox.loading() - - if (data.ajax) fillFaceboxFromAjax(data.ajax, klass) - else if (data.image) fillFaceboxFromImage(data.image, klass) - else if (data.div) fillFaceboxFromHref(data.div, klass) - else if ($.isFunction(data)) data.call($) - else $.facebox.reveal(data, klass) - } - - /* - * Public, $.facebox methods - */ - - $.extend($.facebox, { - settings: { - opacity : 0.2, - overlay : true, - loadingImage : '/facebox/loading.gif', - closeImage : '/facebox/closelabel.png', - imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ], - faceboxHtml : '\ - ' - }, - - loading: function() { - init() - if ($('#facebox .loading').length == 1) return true - showOverlay() - - $('#facebox .content').empty(). - append('
') - - $('#facebox').show().css({ - top: getPageScroll()[1] + (getPageHeight() / 10), - left: $(window).width() / 2 - ($('#facebox .popup').width() / 2) - }) - - $(document).bind('keydown.facebox', function(e) { - if (e.keyCode == 27) $.facebox.close() - return true - }) - $(document).trigger('loading.facebox') - }, - - reveal: function(data, klass) { - $(document).trigger('beforeReveal.facebox') - if (klass) $('#facebox .content').addClass(klass) - $('#facebox .content').empty().append(data) - $('#facebox .popup').children().fadeIn('normal') - $('#facebox').css('left', $(window).width() / 2 - ($('#facebox .popup').width() / 2)) - $(document).trigger('reveal.facebox').trigger('afterReveal.facebox') - }, - - close: function() { - $(document).trigger('close.facebox') - return false - } - }) - - /* - * Public, $.fn methods - */ - - $.fn.facebox = function(settings) { - if ($(this).length == 0) return - - init(settings) - - function clickHandler() { - $.facebox.loading(true) - - // support for rel="facebox.inline_popup" syntax, to add a class - // also supports deprecated "facebox[.inline_popup]" syntax - var klass = this.rel.match(/facebox\[?\.(\w+)\]?/) - if (klass) klass = klass[1] - - fillFaceboxFromHref(this.href, klass) - return false - } - - return this.bind('click.facebox', clickHandler) - } - - /* - * Private methods - */ - - // called one time to setup facebox on this page - function init(settings) { - if ($.facebox.settings.inited) return true - else $.facebox.settings.inited = true - - $(document).trigger('init.facebox') - makeCompatible() - - var imageTypes = $.facebox.settings.imageTypes.join('|') - $.facebox.settings.imageTypesRegexp = new RegExp('\\.(' + imageTypes + ')(\\?.*)?$', 'i') - - if (settings) $.extend($.facebox.settings, settings) - $('body').append($.facebox.settings.faceboxHtml) - - var preload = [ new Image(), new Image() ] - preload[0].src = $.facebox.settings.closeImage - preload[1].src = $.facebox.settings.loadingImage - - $('#facebox').find('.b:first, .bl').each(function() { - preload.push(new Image()) - preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1') - }) - - $('#facebox .close') - .click($.facebox.close) - .append('') - } - - // getPageScroll() by quirksmode.com - function getPageScroll() { - var xScroll, yScroll; - if (self.pageYOffset) { - yScroll = self.pageYOffset; - xScroll = self.pageXOffset; - } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict - yScroll = document.documentElement.scrollTop; - xScroll = document.documentElement.scrollLeft; - } else if (document.body) {// all other Explorers - yScroll = document.body.scrollTop; - xScroll = document.body.scrollLeft; - } - return new Array(xScroll,yScroll) - } - - // Adapted from getPageSize() by quirksmode.com - function getPageHeight() { - var windowHeight - if (self.innerHeight) { // all except Explorer - windowHeight = self.innerHeight; - } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode - windowHeight = document.documentElement.clientHeight; - } else if (document.body) { // other Explorers - windowHeight = document.body.clientHeight; - } - return windowHeight - } - - // Backwards compatibility - function makeCompatible() { - var $s = $.facebox.settings - - $s.loadingImage = $s.loading_image || $s.loadingImage - $s.closeImage = $s.close_image || $s.closeImage - $s.imageTypes = $s.image_types || $s.imageTypes - $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml - } - - // Figures out what you want to display and displays it - // formats are: - // div: #id - // image: blah.extension - // ajax: anything else - function fillFaceboxFromHref(href, klass) { - // div - if (href.match(/#/)) { - var url = window.location.href.split('#')[0] - var target = href.replace(url,'') - if (target == '#') return - $.facebox.reveal($(target).html(), klass) - - // image - } else if (href.match($.facebox.settings.imageTypesRegexp)) { - fillFaceboxFromImage(href, klass) - // ajax - } else { - fillFaceboxFromAjax(href, klass) - } - } - - function fillFaceboxFromImage(href, klass) { - var image = new Image() - image.onload = function() { - $.facebox.reveal('
', klass) - } - image.src = href - } - - function fillFaceboxFromAjax(href, klass) { - $.get(href, function(data) { $.facebox.reveal(data, klass) }) - } - - function skipOverlay() { - return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null - } - - function showOverlay() { - if (skipOverlay()) return - - if ($('#facebox_overlay').length == 0) - $("body").append('
') - - $('#facebox_overlay').hide().addClass("facebox_overlayBG") - .css('opacity', $.facebox.settings.opacity) - .click(function() { $(document).trigger('close.facebox') }) - .fadeIn(200) - return false - } - - function hideOverlay() { - if (skipOverlay()) return - - $('#facebox_overlay').fadeOut(200, function(){ - $("#facebox_overlay").removeClass("facebox_overlayBG") - $("#facebox_overlay").addClass("facebox_hide") - $("#facebox_overlay").remove() - }) - - return false - } - - /* - * Bindings - */ - - $(document).bind('close.facebox', function() { - $(document).unbind('keydown.facebox') - $('#facebox').fadeOut(function() { - $('#facebox .content').removeClass().addClass('content') - $('#facebox .loading').remove() - $(document).trigger('afterClose.facebox') - }) - hideOverlay() - }) - -})(jQuery);