Skip to content

Commit

Permalink
Show/hide the styles box on hover.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Jan 26, 2011
1 parent af2afa9 commit 051e4af
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/public/javascripts/refinery/boot_wym.js
Expand Up @@ -245,7 +245,7 @@ WYMeditor.editor.prototype.loadIframe = function(iframe) {
doc.write(html);
doc.close();

$.each(["wymeditor/skins/refinery/wymiframe", "formatting", "theme"], function(i, href) {
$.each(["wymeditor/skins/refinery/wymiframe", "formatting", "refinery/theme", "theme"], function(i, href) {
$("<link href='/stylesheets/" + href + ".css' media='all' rel='stylesheet' />").appendTo(doc.head);
});
$("<script src='/javascripts/modernizr-min.js'></script>").appendTo(doc.head);
Expand Down
20 changes: 16 additions & 4 deletions core/public/javascripts/wymeditor/jquery.refinery.wymeditor.js
Expand Up @@ -839,7 +839,7 @@ WYMeditor.editor.prototype.bindEvents = function() {
.blur(function() { $(this).toggleClass('hasfocus'); });

//handle click event on classes buttons
$(this._box).find(this._options.classSelector).click(function() {
$(this._box).find(this._options.classSelector).bind('click', function() {

var aClasses = eval(wym._options.classesItems);
var sName = $(this).attr(WYMeditor.NAME);
Expand Down Expand Up @@ -970,8 +970,7 @@ WYMeditor.editor.prototype.exec = function(cmd) {

case WYMeditor.APPLY_CLASS:
wym = this;
$(wym._box).find(this._options.classUnhiddenSelector).toggleClass(this._options.classHiddenSelector.substring(1)); // substring(1) to remove the . at the start
$(wym._box).find("a[name=" + WYMeditor.APPLY_CLASS +"]").toggleClass('selected').parent().toggleClass('activated');
wym.toggleClassSelector();
// determine whether any classes are already selected and add the enabled class to them.
$(wym._box).find(this._options.classUnhiddenSelector).find("a[name]").each(function(index, rule){
if ($(wym.selected()).hasClass($(rule).attr('name'))) {
Expand Down Expand Up @@ -1082,6 +1081,16 @@ WYMeditor.editor.prototype.toggleClass = function(sClass, jqexpr) {

};

WYMeditor.editor.prototype.toggleClassSelector = function() {
// substring(1) to remove the . at the start
var wym = this;
$(wym._box).find(wym._options.classUnhiddenSelector)
.toggleClass(wym._options.classHiddenSelector.substring(1));

$(wym._box).find("a[name=" + WYMeditor.APPLY_CLASS +"]")
.toggleClass('selected').parent().toggleClass('activated');
}

/* @name removeClass
* @description Removes class on selected element, or one of its parents
*/
Expand Down Expand Up @@ -1640,12 +1649,15 @@ WYMeditor.editor.prototype.listen = function() {
}

// ensure links can't be navigated to.
$(this._doc).find('a[href]').click(function(e){e.preventDefault();});
$(this._doc).find('a[href]').click(function(e){
e.preventDefault();
});
};

WYMeditor.editor.prototype.mousedown = function(e) {

var wym = WYMeditor.INSTANCES[this.ownerDocument.title];

wym._selected_image = (e.target.tagName.toLowerCase() == WYMeditor.IMG) ? e.target : null;
$(wym._iframe).contents().find('.selected_by_wym').removeClass('selected_by_wym');
if (!$.browser.mozilla) { $(wym._selected_image).addClass('selected_by_wym'); }
Expand Down
8 changes: 8 additions & 0 deletions core/public/javascripts/wymeditor/skins/refinery/skin.js
Expand Up @@ -25,6 +25,14 @@ WYMeditor.SKINS['refinery'] = {
},function(){
$(this).removeClass('hover');
});

// show or hide CSS class options on hover
$(wym._box).find('.wym_tools_class')
.hover($.proxy(function(){
this.toggleClassSelector();
}, wym), $.proxy(function(){
this.toggleClassSelector();
}, wym));

// adjust sizing
$(wym._box).css('width', $(wym._element).width() - 2)
Expand Down
6 changes: 2 additions & 4 deletions core/public/stylesheets/wymeditor/skins/refinery/skin.css
Expand Up @@ -471,11 +471,9 @@ a.wym_wymeditor_link {
display: block;
position: absolute;
left: 0px;
top: 29px;
top: 23px;
padding-top: 6px !important;
width: 200px;
border-color: gray;
border-style: solid;
border-width: 0px 1px 1px 1px !important;
}
.wym_classes_hidden {
display: none;
Expand Down

0 comments on commit 051e4af

Please sign in to comment.