THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

Add clipboard.js and use it on copy methods.

tags/v1.8.0
Sang Jun Lee Suwon Chae 2 years ago
parent
commit
c7db1fe484
6 changed files with 86 additions and 17 deletions
  1. +24
    -0
      NOTICE
  2. +28
    -10
      app/views/code/history.scala.html
  3. +1
    -1
      minify-js.sh
  4. +7
    -0
      public/javascripts/lib/clipboard.min.js
  5. +19
    -6
      public/javascripts/service/yobi.project.Home.js
  6. +7
    -0
      public/javascripts/yona-common.js

+ 24
- 0
NOTICE View File

@@ -881,4 +881,28 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

=======================================================================
clipboard.js (https://github.com/zenorocha/clipboard.js)
=======================================================================

Copyright © 2017 Zeno Rocha <hi@zenorocha.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

END OF NOTICE FOR YOBI

+ 28
- 10
app/views/code/history.scala.html View File

@@ -223,24 +223,42 @@ $(document).ready(function(){
location.href = evt.val;
});

var clipboard;

// Copy CommitId
$("#history").find(".btn-copy-commitId").each(function(i, el){
var welBtnCopy = $(el);

// zclip() works only in visible element
welBtnCopy.on("mouseenter", function(){
if(!welBtnCopy.data("zclipped")){
welBtnCopy.data("zclipped", true);

$(this).zclip({
"path": "@routes.Assets.at("javascripts/lib/jquery/ZeroClipboard.swf")",
"copy": function(){
return $(this).data("commitid");
},
"afterCopy": function(){
$yobi.notify("@Messages("code.copyCommitId.copied")", 1000);
if (Clipboard && Clipboard.isSupported()) {
// Using clipboard.min.js if supports clipboard api.
if (clipboard) {
clipboard.destroy(); // Destroy previous instance before locate new instance.
}
clipboard = new Clipboard(this, {
text: function() {
return $(welBtnCopy).data("commitid");
}
}).on('success', function(e) {
$yobi.notify("@Messages("code.copyCommitId.copied")", 1000);
e.clearSelection();
});
} else {
// Use zclipboard(Flash based) if not support clipboard api.
if (!welBtnCopy.data("zclipped")){
welBtnCopy.data("zclipped", true);

$(this).zclip({
"path": "@routes.Assets.at("javascripts/lib/jquery/ZeroClipboard.swf")",
"copy": function(){
return $(this).data("commitid");
},
"afterCopy": function(){
$yobi.notify("@Messages("code.copyCommitId.copied")", 1000);
}
});
}
}
});
});

+ 1
- 1
minify-js.sh View File

@@ -12,7 +12,7 @@ java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/lib/nprogress/nprogress.js


# yona-common.js
java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.tmpl.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.form.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.validate.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.requestAs.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.search.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.zclip.min.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.placeholder.min.js $PUBLIC/bootstrap/js/bootstrap.js $PUBLIC_JAVASCRIPTS/lib/rgbcolor.js $PUBLIC_JAVASCRIPTS/lib/humanize.js $PUBLIC_JAVASCRIPTS/lib/validate.js $PUBLIC_JAVASCRIPTS/lib/xss.js --js_output_file $OUT_DIR/yona-common.js
java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.tmpl.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.form.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.validate.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.requestAs.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.search.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.zclip.min.js $PUBLIC_JAVASCRIPTS/lib/jquery/jquery.placeholder.min.js $PUBLIC/bootstrap/js/bootstrap.js $PUBLIC_JAVASCRIPTS/lib/rgbcolor.js $PUBLIC_JAVASCRIPTS/lib/humanize.js $PUBLIC_JAVASCRIPTS/lib/validate.js $PUBLIC_JAVASCRIPTS/lib/xss.js $PUBLIC_JAVASCRIPTS/lib/clipboard.min.js --js_output_file $OUT_DIR/yona-common.js

# yona-lib.js
java -jar $CLOSURE_COMPILER --js $PUBLIC_JAVASCRIPTS/common/yobi.Attachments.js $PUBLIC_JAVASCRIPTS/common/yobi.Files.js $PUBLIC_JAVASCRIPTS/common/yobi.Mention.js $PUBLIC_JAVASCRIPTS/common/yobi.Markdown.js $PUBLIC_JAVASCRIPTS/common/yobi.Pagination.js $PUBLIC_JAVASCRIPTS/common/yobi.ShortcutKey.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Dropdown.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Typeahead.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Dialog.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Toast.js $PUBLIC_JAVASCRIPTS/common/yobi.ui.Tabs.js $PUBLIC_JAVASCRIPTS/common/yobi.OriginalMessage.js --js_output_file $OUT_DIR/yona-lib.js

+ 7
- 0
public/javascripts/lib/clipboard.min.js
File diff suppressed because it is too large
View File


+ 19
- 6
public/javascripts/service/yobi.project.Home.js View File

@@ -68,13 +68,26 @@
function _attachEvent(){
htElement.welRepoURL.click(_onClickRepoURL);

htElement.welBtnCopy.zclip({
"path": htVar.sURLZeroClipboard,
"copy": htElement.welInputCloneURL.val(),
"afterCopy": function(){
if (Clipboard && Clipboard.isSupported()) {
// Using clipboard.min.js if supports clipboard api.
new Clipboard(htElement.welBtnCopy[0], {
target: function() {
return document.getElementById('cloneURL');
}
}).on('success', function(e) {
yobi.Common.notify(Messages("code.copyUrl.copied"), 1000);
}
});
e.clearSelection();
});
} else {
// Use zclipboard(Flash based) if not support clipboard api.
htElement.welBtnCopy.zclip({
"path": htVar.sURLZeroClipboard,
"copy": htElement.welInputCloneURL.val(),
"afterCopy": function () {
yobi.Common.notify(Messages("code.copyUrl.copied"), 1000);
}
});
}

htElement.welInputCloneURL.on('click',function(){
$(this).select();

+ 7
- 0
public/javascripts/yona-common.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save