diff options
author | 无闻 <joe2010xtmf@163.com> | 2014-04-04 10:40:14 -0400 |
---|---|---|
committer | 无闻 <joe2010xtmf@163.com> | 2014-04-04 10:40:14 -0400 |
commit | 3a23476dbef0bb90ce5e8bc4c7ab8929bc04bb1b (patch) | |
tree | 8cfb016c545a0b7583fcb7e7acc5a11fc11c20a2 /public/js/app.js | |
parent | 48d3a1fef12242c6f5c1848ca58e02d946a709da (diff) | |
parent | 75db79b4b6bcb8f61dd957c9bd21b32d4746f866 (diff) |
Merge pull request #61 from gogits/dev
Dev
Diffstat (limited to 'public/js/app.js')
-rw-r--r-- | public/js/app.js | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/public/js/app.js b/public/js/app.js index 5181933d..0ba0675f 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -159,6 +159,7 @@ var Gogits = { $tabs.tab("show"); $tabs.find("li:eq(0) a").tab("show"); }; + // fix dropdown inside click Gogits.initDropDown = function () { $('.dropdown-menu.no-propagation').on('click', function (e) { @@ -166,6 +167,7 @@ var Gogits = { }); }; + // render markdown Gogits.renderMarkdown = function () { var $md = $('.markdown'); @@ -192,6 +194,7 @@ var Gogits = { }); }; + // render code view Gogits.renderCodeView = function () { function selectRange($list, $select, $from) { $list.removeClass('active'); @@ -255,6 +258,43 @@ var Gogits = { }).trigger('hashchange'); }; + // copy utils + Gogits.bindCopy = function (selector) { + if ($(selector).hasClass('js-copy-bind')) { + return; + } + $(selector).zclip({ + path: "/js/ZeroClipboard.swf", + copy: function () { + var t = $(this).data("copy-val"); + var to = $($(this).data("copy-from")); + var str = ""; + if (t == "txt") { + str = to.text(); + } + if (t == 'val') { + str = to.val(); + } + if (t == 'html') { + str = to.html(); + } + return str; + }, + afterCopy: function () { + var $this = $(this); + $this.tooltip('hide') + .attr('data-original-title', 'Copied OK'); + setTimeout(function () { + $this.tooltip("show"); + }, 200); + setTimeout(function () { + $this.tooltip('hide') + .attr('data-original-title', 'Copy to Clipboard'); + }, 3000); + } + }).addClass("js-copy-bind"); + } + })(jQuery); // ajax utils @@ -343,7 +383,10 @@ function initRepository() { $clone.find('span.clone-url').text($this.data('link')); } }).eq(0).trigger("click"); - // todo copy to clipboard + $("#repo-clone").on("shown.bs.dropdown",function () { + Gogits.bindCopy("[data-init=copy]"); + }); + Gogits.bindCopy("[data-init=copy]:visible"); } })(); |