Limiting the Options on Image inserts on Drupal TinyMCE [closed] - tinymce

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using Drupal 7 with TinyMCE via the Wysywig module.
I have enabled the insert image option but when the insert image dialogue pops up the user is shown a number of options for the image which would be undesirable. In addition there is no option to add a CSS class to the image. Is there a way that I can easily change this dialogue to remove options like dimensions, alignment, border etc and add in a class option?

To apply CSS classes to images: Normally, there is an option under the "Appearance" tab to add a CSS class to the image by a drop-down of available classes. If there are no tabs in the pop-up box (sounds like there aren't), go to the "Buttons and Plugins" section of the settings for your WYSWIWYG profile (under Configuration > Content Authoring) and tick the "Advanced image" box.
This by default gives a crazy long list of every class in your theme. To change this to something more useful, go to the CSS section and change the "Editor CSS" drop down. This is used for the image classes in Advanced Image settings as well as other lists of classes. You probably want to set it to "Define CSS" and create a CSS file with a limited selection of classes, then point to this in CSS Path.
To prune the user interface to get a more limited, user-friendly range of options: I don't know of any way to do this through configuration. There are, however, two brute-force methods:
Hide them with CSS (display: none;) This is what I use. It's a little harder than it should be because the HTML markup is ghastly - all tables with no classes or ids in useful places - but it's reasonably straightforward if you use things like nth child rules and count how many <tr> elements there are until you reach the one(s) you want to remove (this assumes your users won't be administrating content using IE 8 or less, or FF3 - if they might, write some jQuery instead).
Hack the TinyMCE code. I haven't tried this. Investigate the HTML files in sites/all/libraries/tinymce/jscripts/tiny_mce/themes/advanced. Messing around with this doesn't look pleasant, it's probably very easy to break the interactivity.
Here's what I use to get a nice, simple, one tab interface which has nothing but Image URL, alt text, mouseover text, preview, dimensions, and a CSS class dropdown. I have the following CSS code added to the end of sites/all/libraries/tinymce/jscripts/tiny_mce/themes/advanced/skins/default/dialog.css. It turns off the features I don't want, kills the tabs, and squeezes it all neatly into the size of the popup:
#appearance_panel.panel { display: block; }
.tabs { display: none; }
#appearance_panel tr:nth-child(1), #appearance_panel tr:nth-child(3), #appearance_panel tr:nth-child(4), #appearance_panel tr:nth-child(5), #appearance_panel tr:nth-child(6)#appearance_panel tr:nth-child(4), #appearance_panel tr:nth-child(5), #appearance_panel tr:nth-child(6), #appearance_panel tr:nth-child(8) { display: none; }
.panel_wrapper #general_panel { height: 270px; }
.panel_wrapper { padding: 3px 10px 3px;}
body { margin: 0; }

Related

ion-toggle : Reduce size of toggle button

Is there any way to reduce the size of ion-toggle button.
The picture depicts my problem.
try this
ion-toggle {
zoom: 0.8;
}
In case you are creating toggle button like this:
<label class="toggle">
<input type="checkbox">
<div class="track">
<div class="handle"></div>
</div>
</label>
Use .toggle .track class to adjust following css properties:
width: 51px;
height: 31px;
and then .toggle .handle to adjust following css properties:
width: 20px;
height: 20px;
border-radius: 20px;
top: 7px;
left: 7px;
You may also add your own class name to change appearance of specific toggle buttons.
In case you are using ion-toggle directive as in
<ion-toggle ng-model="airplaneMode" class="toggle-small" toggle-class="toggle-calm">Airplane Mode</ion-toggle>
You can try to see if applying class="toggle-small" changes appearance as per your need. However, above class modifications can still be applied to this directive.
From what I can tell you will need to customize three CSS definitions: .toggle-icon, .toggle-inner, and .toggle-checked .toggle-inner.
.toggle-icon: width and height change the size of the toggle "track"
.toggle-inner: width and height change the size of the toggle "button" that slides in the track
.toggle-checked .toggle-inner.: transform: translate3d(27px, 0, 0) The first arg changes the position of the button when it is pressed
The following shows how to enlarge so to answer the OP you can simply use smaller values to get a minuscule toggle.
CSS zoom suggested above appears to be outdated 2017 post in my calendar is not that old. Anyways, it does not take virtual units.
While I am constantly fighting all this non-sense of frameworks and CSS cryptic lingo I have been always trying to use virtual units even for font-size. Because they are a percentage of the real-estate a platform presents, I feel they provide better results with a single specification, occasionally I specify separately for portrait and landscape.
So for the toggle I have derived the following gathering from all your inputs and other posts. In order to have a decent appearance I tend to like things large but they still have to fit an iphone, android and my TV 1920 x 1000
I personally think it's totally stupid to keep speaking and specifying CSS with weird units like px, em, etc....
Here is the looks on an iphone
Here is the looks on my large TV
As you can see I still have some more styling to do for the radio-buttons they are tiny on my 1920 x 1080 TV. I will derive a style common for both that will work (unlike the Ionic default which DOES NOT, otherwise we won't be here, would we?).
Programmers should NOT have to do this, It's a shame frameworks make it such a pain, when they claim to do the opposite (enabling you to publish on various platform).
Thanks for #amuramoto for the translate, I am just hacking my way thru the dev tools figuring out all this terrible mess.
Here is what I cooked up for the radio-buttons I don't know why I am having to use 5.5vmin to center the .radio-icon ?? it's not looking great on the iphone yet. Perhaps someone can improve on this?
here are the radio-buttons on the 1920 x 1080 resolution

Hide sidebar on a page in Confluence 5.1

I'm using Confluence 5.1 and I'd like to hide the sidebar - but only on a few pages. I only found a JQuery based solution which does not seem to work right in all browsers. It seems to hide the sidebar completely regardless of the default settings.
I found a CSS based solution for this after searching around the web for a long time.
Basically, all you need to do is add a CSS macro to the page which shouldn't have a sidebar containing the code below.
CSS Stylesheet macro
#splitter-content {
width: 100% !important;
left: 0px !important;
}
.vsplitbar{
visibility: hidden;
}
This CSS block spans the page content over the whole page width and removes the left margin normally reserved for the sidebar. It also hides the split bar which is normally used to change the sidebar size.
The nice thing is that you don't have to mess with cookies this way or make sure the sidebar is turned back on on the following pages.
There was a Confluence bug filed for this and it was rejected* due to a desire to have a more simplified configuration system. In that bug, a workaround is proposed.
Add this to a <script> stanza at the bottom of the <head> tag in your custom HTML:
AJS.toInit(function(){
if (AJS.$("div.ia-fixed-sidebar").width() > 55){
AJS.Confluence.Sidebar.toggle();
}
});
Since I don't have that level of control, I opted for a Greasemonkey script instead. This only affects me, but it does solve my problem (I just have to make sure I don't take too much advantage of the extra width this affords me). Here is a sample userscript for this, also posted to Github [install]
// ==UserScript==
// #name Confluence - Hide sidebar
// #namespace https://github.com/adamhotep
// #description Collapse the sidebar upon page load
// #include https://confluence.*
// #include http://confluence.*
// #version 1
// #grant none
// #license GPL
// ==/UserScript==
// from https://confluence.atlassian.com/confkb/how-do-i-remove-the-side-bar-in-confluence-5-330796984.html
if (typeof AJS === 'function') {
AJS.toInit(function(){
if (AJS.$("div.ia-fixed-sidebar").width() > 55){
AJS.Confluence.Sidebar.toggle();
}
});
}
This is theme-specific. The above code assumes the default theme and is not guaranteed to work in later versions of Confluence. See the "workaround" link for the code needed for the documentation theme.
* There's also another bug related to a cookie that is supposed to preserve whether or not to show or hide the sidebar. Supposedly, the bug is fixed, but this directly contradicts the first bug linked in this answer, so I can't make sense of it.

Ignoring 'Unknown property value' in Chrome dev tools

Chrome's dev tools become almost unusable if you use a lot of vendor prefixes and have long property values...
Is there a way to tell the dev tools not to display the 'Unknown property values' (e.g the ones with a triangle)?
You probably don't want to fully hide all unrecognized style properties, because that would make it too easy to accidentally overlook a mistake.
You can customize the developer tools via a custom User style (it's not an extension).
First locate your profile directory, then enter the User StyleSheets subdirectory. You'll find a file called Custom.css. Edit this file, and add the following:
EDIT: Custom user styles have been removed from Chromium. To change the appearance of the developer tools, the new chrome.devtools.panels.applyStyleSheet method can be used (sample code).
#-webkit-web-inspector .properties > .not-parsed-ok:not(.child-editing):not(:hover) {
white-space: pre;
}
This CSS selector selects all CSS property-value pairs which are invalid, and force all content on single line, unless you're editing it, or hovering your mouse on it. If you really want to hide styles, use display:none;.
For the reasons given above, I would use something else, such as max-height: 8px; background-color: rgba(0,0,0,0.5); instead of display:none; to hide the properties. Then, you can still see that incorrect properties exist, without being bothered too much.
An alternative style is to indeed hide all properties by default, and only show the hidden properties when the mouse is on the CSS declaration:
#-webkit-web-inspector .properties:not(:hover) > .not-parsed-ok:not(.child-editing) {
display: none;
}
Hiding these unconditionally puts you on a slippery road. Consider yourself adding a property and inadvertently dropping a single character in the property name (background-colr) or value (rb(128,120,120)) (these typos are there for a reason, do not edit!). This property will instantly disappear, and you will have no way to restore it (by editing the CSS model), yet this broken property will remain in the style sheet text forever. That's why we don't hide them.

Assign Class to CKEditor using a DIV

I am using CKEditor in DIV mode, as compared to an IFRAME and I am attempting to assign a class to the editor itself. I have found where to add it to things within the editor, but not the editor itself. And, I would prefer to not wrap the editor within another DIV to get the effect I want.
I am also using version 4 of CKEditor.
Edit: The following was my questions to Reinmar after he suggested the Shared Space plugin, which at least for now I have chosen not to use.
Edit: In response to Reinmar I have begun using the Shared Space plugin, and do see the potential benefits of using it over a DIV.
With that said I have the following code:
<div id="topSpace"></div>
<textarea name="data[ArchiveQuarter][description]" class="userContent" id="editor1" cols="30" rows="6"></textarea>
At the bottom of the page I have:
<script type="text/javascript">
CKEDITOR.disableAutoInline = true;
CKEDITOR.replace( 'editor1', {
extraPlugins: 'sharedspace',
sharedSpaces: {
top: 'topSpace',
}
});
</script>
It currently creates the toolbar within the top space, and has the textarea, but both of them are disabled. I probably just messed up some of the configuration, but I'm not sure what.
I would greatly prefer it to use the textarea configuration as it is part of a form instead of extracting the data from inline.
You might be interested in using Shared space plugin:
addon page,
sample.
I'm proposing this instead of using div, because I've got mixed feelings regarding divarea plugin. Your original container is wrapped with editor's structure what changes the real context. IMO it's better to use real inline editing + the shared spaces feature to place toolbar and bottom bar where you need them.
Update:
When you're using inline editor, you don't need textarea. Textarea is only a data container which framed or div based editors replace with themselves.
Inline editing is all about editing real existing elements. So this can be your HTML:
<div id="topSpace"></div>
<div class="userContent" id="editor1"><h1>My page</h1><p>Fooo!</p></div>
And JS:
<script type="text/javascript">
CKEDITOR.disableAutoInline = true;
CKEDITOR.inline( 'editor1', {
extraPlugins: 'sharedspace',
sharedSpaces: {
top: 'topSpace',
}
} );
</script>
Note that I used CKEDITOR.inline not CKEDITOR.replace.
And the huge advantage of inline editing is that that <div> is a real element on your page - it is not wrapped (as in div based editor) and its contents is not moved to the frame (as in framed editor). So your content will inherit styles of your page.
The downside is that you need to implement custom data saving, because there's no form. The simplest way is to add a "save" button which clicked will send editor.getData() via AJAX to your server.
BTW. You probably was confused by the fact that in the shared spaces sample 2 editors are framed and 2 are inline. All of them reuses one top space and one bottom space.
BTW2. To make use of inline editing you don't need shared spaces in fact. Then the "floating toolbar" will be used as in here: http://ckeditor.com/demo#inline

Twitter Widget ignoring font-size css on iPhone

My website uses the Twitter widget to grab tweet and uses the "twtr-tweet-text" class to change the font family and size.
Unfortunately, on my iPhone (not on iPad) it seems to ignore the font size completely which causes it to overlap my footer. Looking closer it seems that the font-size is right for the 'reply retweet favourite' section but not for the actual tweet.
http://jshjohnson.com
How would I go about stopping this happening?
Thanks
The twitter widget has code that is setting the font-size in the linked widgit.css. I don't know if you have access to change to CSS within that file, but you can get more specific than the widget.css by targeting the div with your own style. You may have an ugly css rule but it's a quick and dirty fix.
If you can target this more specifically than the widget.css the rule should be applied. The following might work, if I'm targeting the text you had in mind.
div.twtr-tweet-wrap p {
font-size: .75em; /* set whatever font size you want */
...
}
Anyway you have the idea, just find the div you want and get specific. You could check to see what the twitter css is doing here. If you really wanted you could try and match the rule and set the font-size to inherit, so only one font-size rule would have the specific size, to ease future adjustments.