From 4465c58f4b1b7e1f9d5cc17fa4fcee352d572092 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 2 Oct 2015 19:58:36 -0400 Subject: new quick start page --- public/js/gogs.js | 36 ++++++++++++++++++++++++++++++++++- public/js/libs/clipboard-1.3.1.min.js | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 public/js/libs/clipboard-1.3.1.min.js (limited to 'public/js') diff --git a/public/js/gogs.js b/public/js/gogs.js index d38e8976..d835fa05 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -396,6 +396,22 @@ function initRepository() { }); } + // Quick start + if ($('.repository.quickstart').length > 0) { + $('#repo-clone-ssh').click(function () { + $('.clone-url').text($(this).data('link')); + $('#repo-clone-url').val($(this).data('link')); + $(this).addClass('blue'); + $('#repo-clone-https').removeClass('blue'); + }); + $('#repo-clone-https').click(function () { + $('.clone-url').text($(this).data('link')); + $('#repo-clone-url').val($(this).data('link')); + $(this).addClass('blue'); + $('#repo-clone-ssh').removeClass('blue'); + }); + } + // Pull request if ($('.repository.compare.pull').length > 0) { var $branch_dropdown = $('.choose.branch .dropdown'); @@ -478,7 +494,7 @@ function initAdmin() { $('.local').show(); $('#user_name').focus(); - if($(this).data('password')=="required"){ + if ($(this).data('password') == "required") { $('#password').attr('required', 'required'); } @@ -608,6 +624,24 @@ $(document).ready(function () { emojify.run($(this)[0]); }); + // Clipboard JS + var clipboard = new Clipboard('.clipboard'); + clipboard.on('success', function (e) { + e.clearSelection(); + + $('#' + e.trigger.getAttribute('id')).popup('destroy'); + e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success')) + $('#' + e.trigger.getAttribute('id')).popup('show'); + e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')) + }); + + clipboard.on('error', function (e) { + $('#' + e.trigger.getAttribute('id')).popup('destroy'); + e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error')) + $('#' + e.trigger.getAttribute('id')).popup('show'); + e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')) + }); + // Helpers. $('.delete-button').click(function () { var $this = $(this); diff --git a/public/js/libs/clipboard-1.3.1.min.js b/public/js/libs/clipboard-1.3.1.min.js new file mode 100755 index 00000000..ed23e3e5 --- /dev/null +++ b/public/js/libs/clipboard-1.3.1.min.js @@ -0,0 +1 @@ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Clipboard=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gd;d++)c[d].fn.apply(c[d].ctx,b);return this},off:function(a,b){var c=this.e||(this.e={}),d=c[a],e=[];if(d&&b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&e.push(d[f]);return e.length?c[a]=e:delete c[a],this}},b.exports=d},{}],6:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}c.__esModule=!0;var e=function(){function a(a,b){for(var c=0;c