Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/views/clipboard_image_paste/_add_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<script type="text/javascript">
// translated labels go here (inside namespace)
(function(cbImagePaste, $, undefined) {
cbImagePaste.cbp_txt_add_image = "<%= escape_javascript(l(:cbp_txt_add_image )).html_safe %>";
cbImagePaste.cbp_txt_crop_box = "<%= escape_javascript(l(:cbp_txt_crop_box )).html_safe %>";
cbImagePaste.cbp_txt_print = "<%= escape_javascript(l(:cbp_txt_print )).html_safe %>";
cbImagePaste.cbp_txt_select = "<%= escape_javascript(l(:cbp_txt_select )).html_safe %>";
Expand Down
55 changes: 55 additions & 0 deletions assets/javascripts/clipboard_image_paste.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,50 @@
s.remove();
};

//----------------------------------------------------------------------------
cbImagePaste.onEncloseSelection = function(str) {
var attachId = cbImagePaste.cbp_act_update_id + "-" + imageAttachCount;
var pictureName = "picture" + attachId + ".png";
return str + "{{thumbnail(" + pictureName + ", size=500)}}";
}

function insertJsToolBarButton(toolbar, key, button, insertAfter){
var newElements = {}
for (var i in toolbar.elements) {
newElements[i] = toolbar.elements[i];
if (newElements[i] == insertAfter)
newElements[key] = button;
}
toolbar.elements = newElements;
}

function insertCbpJsToolBarButton(toolbar, insertAfter){
var button = {
type: 'button',
title: cbImagePaste.cbp_txt_add_image,
fn: {
wiki: function () {
var toolbar = this;
cbImagePaste.showPasteDialog();

var dlg_buttons = {};
dlg_buttons[cbImagePaste.cbp_txt_btn_ok] = function() {
var beforeCount = imageAttachCount;
var ret = insertAttachment();
var afterCount = imageAttachCount;
if (beforeCount != afterCount){
toolbar.encloseSelection('','', cbImagePaste.onEncloseSelection);
}
return ret;
};
dlg_buttons[cbImagePaste.cbp_txt_btn_cancel] = function() { $(this).dialog("close"); };
$("#cbp_paste_dlg").dialog('option', 'buttons', dlg_buttons);
}
}
}
insertJsToolBarButton(toolbar, 'cbp', button, insertAfter)
}

//------------------------------------------------------------------------------
// Move image attachment block to proper place (after "add another file" link).
// and detach element not required in DOM.
Expand Down Expand Up @@ -560,6 +604,17 @@
return;

addFile.after(imageForm);

// modify jsToolBar for objects to be created.
if(typeof jsToolBar !== 'undefined'){
insertCbpJsToolBarButton(jsToolBar.prototype, jsToolBar.prototype.elements.img);
}

// modify jsToolBar for objects that already exists.
if(typeof wikiToolbar !== 'undefined'){
insertCbpJsToolBarButton(wikiToolbar, wikiToolbar.elements.img);
wikiToolbar.draw();
}
});

}(window.cbImagePaste = window.cbImagePaste || {}, jQuery));
10 changes: 10 additions & 0 deletions assets/stylesheets/clipboard_image_paste.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,13 @@
.cbp_dlg_small {
font-size: 10pt;
}

/* Clipboard Image Paste button */
.jstb_cbp {
background-image: url(../../../images/jstoolbar/bt_img.png);
}

/* FIXME: dirty code. Disable button in comment form */
[id^="add_comment_form"] .jstb_cbp, [id^="wikiextensions_comment_"] .jstb_cbp {
display: none;
}