diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 8d6a72efd..3bc74393a 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -31,7 +31,7 @@ var gzip = require('gzip'); var server = require('../server'); var os = require('os'); -var padJS = ["jquery.min.js", "pad_utils.js", "plugins.js", "undo-xpopup.js", "json2.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "ace.js", "collab_client.js", "pad_userlist.js", "pad_impexp.js", "pad_savedrevs.js", "pad_connectionstatus.js", "pad2.js", "jquery-ui.js", "chat.js"]; +var padJS = ["jquery.min.js", "pad_utils.js", "plugins.js", "undo-xpopup.js", "json2.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "ace.js", "collab_client.js", "pad_userlist.js", "pad_impexp.js", "pad_savedrevs.js", "pad_connectionstatus.js", "pad2.js", "jquery-ui.js", "chat.js", "farbtastic.js"]; var timesliderJS = ["jquery.min.js", "plugins.js", "undo-xpopup.js", "json2.js", "colorutils.js", "draggable.js", "pad_utils.js", "pad_cookie.js", "pad_editor.js", "pad_editbar.js", "pad_docbar.js", "pad_modals.js", "easysync2_client.js", "domline_client.js", "linestylefilter_client.js", "cssmanager_client.js", "broadcast.js", "broadcast_slider.js", "broadcast_revisions.js"]; diff --git a/static/css/pad.css b/static/css/pad.css index 16ce18390..9d854b171 100644 --- a/static/css/pad.css +++ b/static/css/pad.css @@ -347,9 +347,9 @@ a#hidetopmsg { position: absolute; right: 5px; bottom: 5px; } } #myswatch { width: 100%; height: 100%; background: transparent;/*...initially*/ } + #mycolorpicker { - /*background: url(../img/colorpicker.gif) no-repeat left top;*/ - width: 232px; height: 230px; + width: 232px; height: 265px; position: absolute; left: -240px; top: 0px; z-index: 101; display: none;/*...initially*/ @@ -358,8 +358,10 @@ a#hidetopmsg { position: absolute; right: 5px; bottom: 5px; } border-color: #000; background: #fff; border-width:1px; + padding-left:10px; + padding-top:10px; } - +/* #mycolorpicker ul li { float: left; @@ -367,12 +369,16 @@ a#hidetopmsg { position: absolute; right: 5px; bottom: 5px; } #mycolorpicker .picked { border: 1px solid #000 !important; } #mycolorpicker .picked .pickerswatch { border: 1px solid #fff; } -#mycolorpickersave { position: absolute; left: 10px; top: 192px; - width: 60px; padding: 4px; overflow: hidden; color: #000; - cursor: pointer; color:#000; font-size:13px; border-radius:5px; border-style:solid; border-color:#000; border-width:1px;text-align:center;background-color:#86DC6C;} -#mycolorpickercancel { position: absolute; left: 87px; top: 192px; +*/ +#mycolorpickersave { position: absolute; left: 10px; top: 240px; + width: 80px; padding: 4px; overflow: hidden; color: #000; + cursor: pointer; color:#000; font-size:13px; border-radius:5px; border-style:solid; border-color:#000; border-width:1px;text-align:center;background-color:lightgrey;} +#mycolorpickercancel { position: absolute; left: 107px; top: 240px; width: 60px; padding: 4px; overflow: hidden; color: #000; - cursor: pointer; color:#000; font-size:13px; border-radius:5px; border-style:solid; border-color:#000; border-width:1px;text-align:center;background-color:#FF8F8F;} + cursor: pointer; color:#000; font-size:13px; border-radius:5px; border-style:solid; border-color:#000; border-width:1px;text-align:center;background-color:lightgrey;} +#mycolorpickerpreview { position: absolute; left: 207px; top: 240px; width:15px; padding:4px; overflow: hidden; color: #fff; border-radius:5px; border-style: solid; border-width:1px;border-color:#000; height:15px;} + + #myusernameform { margin-left: 35px; } #myusernameedit { font-size: 1.3em; color: #fff; padding: 3px; height: 18px; margin: 0; border: 0; diff --git a/static/js/broadcast.js b/static/js/broadcast.js index 442c52ced..c2ab308e2 100644 --- a/static/js/broadcast.js +++ b/static/js/broadcast.js @@ -741,13 +741,10 @@ function loadBroadcastJS() for (var author in newAuthorData) { var data = newAuthorData[author]; - if ((typeof data.colorId) == 'number') + var bgcolor = data.colorId; + if (bgcolor && dynamicCSS) { - var bgcolor = clientVars.colorPalette[data.colorId]; - if (bgcolor && dynamicCSS) - { - dynamicCSS.selectorStyle('.' + linestylefilter.getAuthorClassName(author)).backgroundColor = bgcolor; - } + dynamicCSS.selectorStyle('.' + linestylefilter.getAuthorClassName(author)).backgroundColor = bgcolor; } authorData[author] = data; } diff --git a/static/js/collab_client.js b/static/js/collab_client.js index ff3395c7a..dd744be43 100644 --- a/static/js/collab_client.js +++ b/static/js/collab_client.js @@ -471,26 +471,19 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options) function tellAceAuthorInfo(userId, colorId, inactive) { - if (colorId || (typeof colorId) == "number") + var cssColor = colorId; + if (inactive) { - colorId = Number(colorId); - if (options && options.colorPalette && options.colorPalette[colorId]) - { - var cssColor = options.colorPalette[colorId]; - if (inactive) - { - editor.setAuthorInfo(userId, { - bgcolor: cssColor, - fade: 0.5 - }); - } - else - { - editor.setAuthorInfo(userId, { - bgcolor: cssColor - }); - } - } + editor.setAuthorInfo(userId, { + bgcolor: cssColor, + fade: 0.5 + }); + } + else + { + editor.setAuthorInfo(userId, { + bgcolor: cssColor + }); } } diff --git a/static/js/farbtastic.js b/static/js/farbtastic.js new file mode 100644 index 000000000..7bc99487a --- /dev/null +++ b/static/js/farbtastic.js @@ -0,0 +1,531 @@ +// Farbtastic 2.0 alpha +(function ($) { + +var __debug = false; + +var __factor = 0.5; + +$.fn.farbtastic = function (options) { + $.farbtastic(this, options); + return this; +}; + +$.farbtastic = function (container, options) { + var container = $(container)[0]; + return container.farbtastic || (container.farbtastic = new $._farbtastic(container, options)); +} + +$._farbtastic = function (container, options) { + var fb = this; + + ///////////////////////////////////////////////////// + + /** + * Link to the given element(s) or callback. + */ + fb.linkTo = function (callback) { + // Unbind previous nodes + if (typeof fb.callback == 'object') { + $(fb.callback).unbind('keyup', fb.updateValue); + } + + // Reset color + fb.color = null; + + // Bind callback or elements + if (typeof callback == 'function') { + fb.callback = callback; + } + else if (typeof callback == 'object' || typeof callback == 'string') { + fb.callback = $(callback); + fb.callback.bind('keyup', fb.updateValue); + if (fb.callback[0].value) { + fb.setColor(fb.callback[0].value); + } + } + return this; + } + fb.updateValue = function (event) { + if (this.value && this.value != fb.color) { + fb.setColor(this.value); + } + } + + /** + * Change color with HTML syntax #123456 + */ + fb.setColor = function (color) { + var unpack = fb.unpack(color); + if (fb.color != color && unpack) { + fb.color = color; + fb.rgb = unpack; + fb.hsl = fb.RGBToHSL(fb.rgb); + fb.updateDisplay(); + } + return this; + } + + /** + * Change color with HSL triplet [0..1, 0..1, 0..1] + */ + fb.setHSL = function (hsl) { + fb.hsl = hsl; + + var convertedHSL = [hsl[0]] + convertedHSL[1] = hsl[1]*__factor+((1-__factor)/2); + convertedHSL[2] = hsl[2]*__factor+((1-__factor)/2); + + fb.rgb = fb.HSLToRGB(convertedHSL); + fb.color = fb.pack(fb.rgb); + fb.updateDisplay(); + + return this; + } + + ///////////////////////////////////////////////////// + + /** + * Initialize the color picker widget. + */ + fb.initWidget = function () { + + // Insert markup and size accordingly. + var dim = { + width: options.width, + height: options.width + }; + $(container) + .html( + '