Skip to content

Commit

Permalink
Merge pull request #2 from esiao/master
Browse files Browse the repository at this point in the history
Adding button to composer + colorpicker working. Updated regex for perfs.
  • Loading branch information
Toolito committed Oct 1, 2014
2 parents 6d86338 + ba86064 commit 2053f47
Show file tree
Hide file tree
Showing 32 changed files with 707 additions and 14 deletions.
35 changes: 35 additions & 0 deletions button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$('document').ready(function() {
require(['composer', 'composer/controls'], function(composer, controls) {
var text, start, end;
composer.addButton('fa fa-eyedropper', function(textarea, selectionStart, selectionEnd) {
text = textarea;
});
$(document).on('click','.fa-eyedropper',function(){
$('.fa-eyedropper').ColorPicker({
onShow: function (el) {
$(el).fadeIn(500);
return false;
controls.updateTextareaSelection(text, start, end);
},
onHide: function (el) {
$(el).fadeOut(500);
return false;
},
onSubmit: function (hsb, hex, rgb, el) {
$(el).ColorPickerHide();
if(start === end){
controls.insertIntoTextarea(text, '%(#'+hex+')[Insert Text Here]');
controls.updateTextareaSelection(text, start + 11, end + 27);
} else {
controls.wrapSelectionInTextareaWith(text, '%(#'+hex+')[',']');
controls.updateTextareaSelection(text, start + 11, end + 11);
}
}
}).trigger('click');
});
$(document).on('blur','textarea.write',function(){
start = this.selectionStart;
end = this.selectionEnd;
});
});
});
162 changes: 162 additions & 0 deletions lib/colorpicker/css/colorpicker.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
.colorpicker {
width: 356px;
height: 176px;
overflow: hidden;
position: absolute;
background: url(/plugins/nodebb-plugin-color/images/colorpicker_background.png);
font-family: Arial, Helvetica, sans-serif;
display: none;
z-index: 999;
}
.colorpicker_color {
width: 150px;
height: 150px;
left: 14px;
top: 13px;
position: absolute;
background: #f00;
overflow: hidden;
cursor: crosshair;
}
.colorpicker_color div {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 150px;
background: url(/plugins/nodebb-plugin-color/images/colorpicker_overlay.png);
}
.colorpicker_color div div {
position: absolute;
top: 0;
left: 0;
width: 11px;
height: 11px;
overflow: hidden;
background: url(/plugins/nodebb-plugin-color/images/colorpicker_select.gif);
margin: -5px 0 0 -5px;
}
.colorpicker_hue {
position: absolute;
top: 13px;
left: 171px;
width: 35px;
height: 150px;
cursor: n-resize;
}
.colorpicker_hue div {
position: absolute;
width: 35px;
height: 9px;
overflow: hidden;
background: url(/plugins/nodebb-plugin-color/images/colorpicker_indic.gif) left top;
margin: -4px 0 0 0;
left: 0px;
}
.colorpicker_new_color {
position: absolute;
width: 60px;
height: 30px;
left: 213px;
top: 13px;
background: #f00;
}
.colorpicker_current_color {
position: absolute;
width: 60px;
height: 30px;
left: 283px;
top: 13px;
background: #f00;
}
.colorpicker input {
background-color: transparent;
border: 1px solid transparent;
position: absolute;
font-size: 10px;
font-family: Arial, Helvetica, sans-serif;
color: #898989;
top: 4px;
right: 11px;
text-align: right;
margin: 0;
padding: 0;
height: 11px;
}
.colorpicker_hex {
position: absolute;
width: 72px;
height: 22px;
background: url(/plugins/nodebb-plugin-color/images/colorpicker_hex.png) top;
left: 212px;
top: 142px;
}
.colorpicker_hex input {
right: 6px;
}
.colorpicker_field {
height: 22px;
width: 62px;
background-position: top;
position: absolute;
}
.colorpicker_field span {
position: absolute;
width: 12px;
height: 22px;
overflow: hidden;
top: 0;
right: 0;
cursor: n-resize;
}
.colorpicker_rgb_r {
background-image: url(/plugins/nodebb-plugin-color/images/colorpicker_rgb_r.png);
top: 52px;
left: 212px;
}
.colorpicker_rgb_g {
background-image: url(/plugins/nodebb-plugin-color/images/colorpicker_rgb_g.png);
top: 82px;
left: 212px;
}
.colorpicker_rgb_b {
background-image: url(/plugins/nodebb-plugin-color/images/colorpicker_rgb_b.png);
top: 112px;
left: 212px;
}
.colorpicker_hsb_h {
background-image: url(/plugins/nodebb-plugin-color/images/colorpicker_hsb_h.png);
top: 52px;
left: 282px;
}
.colorpicker_hsb_s {
background-image: url(/plugins/nodebb-plugin-color/images/colorpicker_hsb_s.png);
top: 82px;
left: 282px;
}
.colorpicker_hsb_b {
background-image: url(/plugins/nodebb-plugin-color/images/colorpicker_hsb_b.png);
top: 112px;
left: 282px;
}
.colorpicker_submit {
position: absolute;
width: 22px;
height: 22px;
background: url(/plugins/nodebb-plugin-color/images/colorpicker_submit.png) top;
left: 322px;
top: 142px;
overflow: hidden;
}
.colorpicker_focus {
background-position: center;
}
.colorpicker_hex.colorpicker_focus {
background-position: bottom;
}
.colorpicker_submit.colorpicker_focus {
background-position: bottom;
}
.colorpicker_slider {
background-position: bottom;
}
Binary file added lib/colorpicker/images/Thumbs.db
Binary file not shown.
Binary file added lib/colorpicker/images/blank.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_hex.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_hsb_b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_hsb_h.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_hsb_s.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_indic.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_overlay.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_rgb_b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_rgb_g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_rgb_r.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_select.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/colorpicker_submit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_hex.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_hsb_b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_hsb_h.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_hsb_s.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_indic.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_rgb_b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_rgb_g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_rgb_r.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/custom_submit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/select.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/select2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/colorpicker/images/slider.png

0 comments on commit 2053f47

Please sign in to comment.