From f11b6d598c6ece376ff207b9a3d321c3de29c668 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 18 Apr 2017 17:42:53 -0400 Subject: Lightbox using Bootstrap modal --- app/assets/javascripts/dispatcher.js | 7 +- app/assets/javascripts/gl_lightbox.js | 133 +++++++++++++------------ app/assets/javascripts/issue.js | 1 - app/assets/javascripts/merge_request.js | 1 - app/assets/javascripts/notes.js | 1 - app/assets/stylesheets/framework/lightbox.scss | 51 +++------- lib/banzai/filter/image_link_filter.rb | 6 +- 7 files changed, 92 insertions(+), 108 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index abb871c3af0..5a0f3598379 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -35,7 +35,7 @@ /* global ShortcutsWiki */ import Issue from './issue'; - +import Lightbox from './gl_lightbox'; import BindInOut from './behaviors/bind_in_out'; import DeleteModal from './branches/branches_delete_modal'; import Group from './group'; @@ -132,6 +132,7 @@ const ShortcutsBlob = require('./shortcuts_blob'); new Issue(); shortcut_handler = new ShortcutsIssuable(); new ZenMode(); + new Lightbox(); break; case 'projects:milestones:show': case 'groups:milestones:show': @@ -187,6 +188,7 @@ const ShortcutsBlob = require('./shortcuts_blob'); shortcut_handler = new ShortcutsNavigation(); new gl.GLForm($('.issue-form')); new IssuableForm($('.issue-form')); + new Lightbox(); new LabelsSelect(); new MilestoneSelect(); new gl.IssuableTemplateSelectors(); @@ -198,6 +200,7 @@ const ShortcutsBlob = require('./shortcuts_blob'); shortcut_handler = new ShortcutsNavigation(); new gl.GLForm($('.merge-request-form')); new IssuableForm($('.merge-request-form')); + new Lightbox(); new LabelsSelect(); new MilestoneSelect(); new gl.IssuableTemplateSelectors(); @@ -215,10 +218,12 @@ const ShortcutsBlob = require('./shortcuts_blob'); new gl.Diff(); shortcut_handler = new ShortcutsIssuable(true); new ZenMode(); + new Lightbox(); break; case "projects:merge_requests:diffs": new gl.Diff(); new ZenMode(); + new Lightbox(); break; case 'dashboard:activity': new gl.Activities(); diff --git a/app/assets/javascripts/gl_lightbox.js b/app/assets/javascripts/gl_lightbox.js index 6dd6cfa1a0b..66bc2e14779 100644 --- a/app/assets/javascripts/gl_lightbox.js +++ b/app/assets/javascripts/gl_lightbox.js @@ -1,73 +1,82 @@ -/* eslint-disable no-new */ -/* jshint esversion: 6 */ - -$(() => { - const IMAGE_SELECTOR = '.no-attachment-icon'; - - class GitLabLightbox { - constructor() { - this.$lightbox = null; - this.$lbLink = null; - this.$lbImage = null; - this.$closeBtn = null; - this.initLightbox(); - this.addBindings(); - } - - initLightbox() { - /* Create base lightbox template -
- - +export default class Lightbox { + constructor(selector) { + this.selector = selector || 'a.no-attachment-icon img'; + this.modal = null; + this.modalDialog = null; + this.link = null; + this.image = null; + this.images = null; + this.buffer = 60; + this.bsMobile = 576; + this.maxWidth = 'none'; + this.template = ` +