Browse Source

Simplification et utilisation de la version 2.2.0 de zeroclipboard

Version 0.4.0
master
kent1@arscenic.info 8 years ago
parent
commit
7534924d69
  1. BIN
      images/zeroclipboard_logo.png
  2. 136
      javascript/spip_zeroclipboard.js
  3. 6
      paquet.xml
  4. 2
      zeroclipboard.js.html
  5. 2
      zeroclipboard_options.php
  6. 4
      zeroclipboard_pipelines.php

BIN
images/zeroclipboard_logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

136
javascript/spip_zeroclipboard.js

@ -3,96 +3,68 @@ var clip = null;
;(function($){
$(function(){
function clipcomplete(client,text){
$(client.domElement)
.html(locale.zeroclipboard.link_title_copied)
.removeClass('copypaste_link')
.addClass('copypaste_copied')
.attr('title',locale.zeroclipboard.link_title_copied);
$('.copypaste_copied').not($(client.domElement)).each(function(){
$(this)
.html(locale.zeroclipboard.link_title_copy)
.toggleClass('copypaste_copied','copypaste_link')
.attr('title',locale.zeroclipboard.link_title_copy);
});
var width = $(client.domElement).width(),
height = $(client.domElement).height();
clip.setSize(width,height);
clip.setCurrent(client.domElement);
$(client.domElement).parent().next('.copypaste').focus().select();
}
var copypaste_init = function(){
clip = new ZeroClipboard();
if(ZeroClipboard.detectFlashSupport()){
clip.on('mouseover',function(client){});
clip.on('mousedown',function(client){});
clip.on('complete',clipcomplete);
$('.copypaste').each(function(){
if(!$(this).prev().is('.copypaste_container'))
$(this).before('<div class="copypaste_container" style="position:relative"><a title="'+locale.zeroclipboard.link_title_copy+'" class="copypaste_link">'+locale.zeroclipboard.link_title_copy+'</a></div>');
$(this).prev('div').find('a').unbind('mouseover').mouseover( function() {
if(!clip.htmlBridge)
clip.glue(this);
else{
clip.setCurrent(this);
var width = $(this).width(),
height = $(this).height();
clip.setSize(width,height);
clip.domElement = $(this);
}
clip.setText($(this).parent().next('.copypaste').val());
clip.receiveEvent('mouseover', null);
});
});
$('.copypaste').each(function(){
if(!$(this).prev().is('.copypaste_container'))
$(this).before('<div class="copypaste_container" style="position:relative"><a title="'+locale.zeroclipboard.link_title_copy+'" class="copypaste_link">'+locale.zeroclipboard.link_title_copy+'</a></div>');
});
$('.coloration_code .cadre_download').each(function(){
/**
* Ajouter le lien dans le <p class="cadre_download"...
* On ajoute la class si pas déjà fait
*/
$('.coloration_code .cadre_download').each(function(){
/**
* On ajoute la class si pas déjà fait
*/
if(!$(this).is('.copypaste_container'))
$(this)
.addClass('copypaste_container')
.css({'position':"relative"})
.append(' - <a title="'+locale.zeroclipboard.link_title_copy+'" class="copypaste_link">'+locale.zeroclipboard.link_title_copy+'</a>');
});
$('.coloration_code').each(function(){
if(!$(this).find('.cadre_download')[0] && !$(this).next().is('.cadre_download') && $(this).attr('data-clipboard-text') != '')
$(this).append('<p class="download cadre_download copypaste_container" style="position:relative"><a title="'+locale.zeroclipboard.link_title_copy+'" class="copypaste_link">'+locale.zeroclipboard.link_title_copy+'</a></p>');
if(!$(this).is('.copypaste_container'))
$(this)
.addClass('copypaste_container')
.css({'position':"relative"})
.append(' - <a title="'+locale.zeroclipboard.link_title_copy+'" class="copypaste_link">'+locale.zeroclipboard.link_title_copy+'</a>');
});
$('.coloration_code').each(function(){
if(!$(this).is('.code') && !$(this).find('.cadre_download')[0] && !$(this).next().is('.cadre_download') && $(this).attr('data-clipboard-text') != '')
$(this).append('<p class="download cadre_download copypaste_container" style="position:relative"><a title="'+locale.zeroclipboard.link_title_copy+'" class="copypaste_link">'+locale.zeroclipboard.link_title_copy+'</a></p>');
});
$('.cadre_download a.copypaste_link').each(function() {
var code = $(this).parent('.cadre_download').prev('.cadre'),me = this;
var content_data = code.attr('data-clipboard-text'),
width = $(this).width(),height = $(this).height();
if(!content_data && $(this).parent().find('a').eq(0)){
$.get($(this).parent().find('a').eq(0).attr('href'),function(data) {
$(me).parent().append('<div style="display:none" class="data-clipboard-hidden">'+data+'</div>');
});
}else{
$(me).attr('data-clipboard-text',content_data);
}
});
ZeroClipboard.destroy();
var clip = new ZeroClipboard( $('.copypaste_link') );
clip.on('ready', function(event) {
$('.copypaste_copied').html(locale.zeroclipboard.link_title_copy)
.attr('title',locale.zeroclipboard.link_title_copy)
.removeClass('copypaste_copied');
clip.on('copy', function(event) {
if(typeof($(event.target).attr('data-clipboard-text')) == "undefined"){
event.clipboardData.setData('text/plain', $(event.target).parent().find('.data-clipboard-hidden').html());
}
});
$('.cadre_download a.copypaste_link').unbind('mouseover').mouseover(function() {
var code = $(this).parent('.cadre_download').prev('.cadre'),me = this;
var content_data = code.attr('data-clipboard-text'),
width = $(this).width(),height = $(this).height();
clip.domElement = me;
if(!content_data){
$.get($(this).parent().find('a').eq(0).attr('href'),function(data) {
content_data = data;
clip.setText(content_data);
clip.setCurrent(me);
clip.setSize(width,height);
clip.receiveEvent('mouseover', null);
$(me).parent('.cadre_download').prev('.cadre').attr('data-clipboard-text',content_data);
clip.on('aftercopy', function(event) {
if(event.data['text/plain'] != undefined){
$(event.target)
.html(locale.zeroclipboard.link_title_copied).attr('title',locale.zeroclipboard.link_title_copied).addClass('copypaste_copied');
$('.copypaste_copied').not($(event.target)).each(function(i){
$(this)
.html(locale.zeroclipboard.link_title_copy)
.attr('title',locale.zeroclipboard.link_title_copy)
.removeClass('copypaste_copied');
});
}else{
clip.setText(content_data);
clip.setCurrent(me);
clip.setSize(width,height);
clip.receiveEvent('mouseover', null);
}
});
var copies = $('.copypaste_container');
if(copies.size() && !clip.htmlBridge){
clip.setText($('.copypaste').eq(0).val());
clip.glue($('.copypaste_container')[0]);
clip.receiveEvent('mouseover', null);
}
}
});
clip.on( 'error', function(event) {
ZeroClipboard.destroy();
});
}
copypaste_init();
onAjaxLoad(copypaste_init);
});
})(jQuery);

6
paquet.xml

@ -1,9 +1,9 @@
<paquet
prefix="zeroclipboard"
categorie="divers"
version="0.3.0"
version="0.4.0"
etat="stable"
compatibilite="[3.0.5;3.0.*]"
compatibilite="[3.0.5;3.1.*]"
logo="images/zeroclipboard_logo.png"
documentation="http://www.mediaspip.net/technical-documentation/plugins-used-by-mediaspip/article/copier-coller-facile-zeroclipboard"
>
@ -16,5 +16,5 @@
<pipeline nom="header_prive" inclure="zeroclipboard_pipelines.php" />
<pipeline nom="insert_head" inclure="zeroclipboard_pipelines.php" />
<pipeline nom="jquery_plugins" inclure="zeroclipboard_pipelines.php" />
<lib nom="zeroclipboard-1.1.7" lien="https://github.com/jonrohan/ZeroClipboard/archive/v1.1.7.zip" />
<lib nom="zeroclipboard-2.2.0" lien="https://github.com/zeroclipboard/zeroclipboard/archive/v2.2.0.zip" />
</paquet>

2
zeroclipboard.js.html

@ -2,7 +2,7 @@
#HTTP_HEADER{Content-Type: text/javascript; charset=#CHARSET}
#HTTP_HEADER{Vary: Accept-Encoding}
ZeroClipboard.setDefaults({moviePath:'#EVAL{_DIR_LIB_ZEROCLIPBOARD}ZeroClipboard.swf'});
ZeroClipboard.config({swfPath:'#EVAL{_DIR_LIB_ZEROCLIPBOARD}dist/ZeroClipboard.swf'});
if(typeof(window.locale) == 'undefined') window.locale = {};

2
zeroclipboard_options.php

@ -9,5 +9,5 @@ if (!defined("_ECRIRE_INC_VERSION")) return;
/**
* On définit le chemin du répertoire _DIR_LIB_ZEROCLIPBOARD
*/
define('_DIR_LIB_ZEROCLIPBOARD',_DIR_LIB.'zeroclipboard-1.1.7/');
define('_DIR_LIB_ZEROCLIPBOARD',_DIR_LIB.'zeroclipboard-2.2.0/');
?>

4
zeroclipboard_pipelines.php

@ -52,9 +52,9 @@ function zeroclipboard_insert_head($flux){
*/
function zeroclipboard_jquery_plugins($plugins){
if(!test_espace_prive())
$plugins[] = _DIR_LIB_ZEROCLIPBOARD.'ZeroClipboard.js';
$plugins[] = _DIR_LIB_ZEROCLIPBOARD.'dist/ZeroClipboard.js';
else
$plugins[] = str_replace(_DIR_RACINE,'',_DIR_LIB_ZEROCLIPBOARD).'ZeroClipboard.js';
$plugins[] = str_replace(_DIR_RACINE,'',_DIR_LIB_ZEROCLIPBOARD).'dist/ZeroClipboard.js';
$plugins[] = 'javascript/spip_zeroclipboard.js';
return $plugins;

Loading…
Cancel
Save