I'm trying to use a ColdFusion<cftextarea richedit="true"> tag that uses FCKEditor 2.x, to feed into a textfield in <cfreportparam> which only understands the <FONT> tag, not the <span style=""> that FCKEditor 2.x generates.
How can I customize fckconfig.js to have FCKEditor 2.x generates <FONT face="" size="" color=""> ??
This link should be related: http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options/CoreStyles
Thank you
Found it! Append the following code to fckconfig.js
FCKConfig.CoreStyles['FontFace'] =
{
Element : 'font',
Attributes : { 'face' : '#("Font")' }
};
FCKConfig.CoreStyles['Size'] =
{
Element : 'font',
Attributes : { 'size' : '#("Size","fontSize")' }
};
FCKConfig.CoreStyles['Color'] =
{
Element : 'font',
Attributes : { 'color' : '#("Color","color")' }
};
FCKConfig.FontSizes = '1/xx-small;2/x-small;3/small;4/medium;5/large;6/x-large;7/xx-large' ;
source: http://drupal.fckeditor.net/filters
Related
I want to filter records by non keyword field.
I am using aws elasticsearch service, where there are some fields are keyword and some are normal. I want to apply filtration on non keyword (text) data type field.
GET ES_INDEX_NAME/_search
{
"query" : {
"term" : { "listing_group" : "Other"}
}
}
listing_group field name is of text data type.
Thanks in advance !
You can try with match or match_phrase?
For partial match,
GET ES_INDEX_NAME/_search
{
"query": {
"match" : {
"listing_group" : "Other"
}
}
}
For phrase match,
GET ES_INDEX_NAME/_search
{
"query" : {
"match_phrase" : {
"listing_group" : "Other"
}
}
}
I need a component that would;
Work within a web page to allow a nontechnical user to create and edit templates for customized reports.
Allow the user to easily place a set of pre-defined template data tokens in the report that conforms to the templating engine syntax without the user needing to know how to write the syntax themselves.
Support the ability to change and update data items that can be used in the report without extensive rewriting of the code or creating a new plugin.
The goal is for end users to create their own personalized templates for a specific set of JSON data. The ability to create templates would be available on a web page and the templates would be stored for later use. Storing and using the templates is not a problem, but an easy to use editor for the templates is.
I have been using jsRender for a templating engine and like it but I am open to other engines if what I need is easier to support.
My goal is to have an online editor, similar to MCE or CKEditor, that would have the ability to place a preset list of data tokens into a custom template the user creates. These templates would be used for auto-generated content based on the data supplied to the template engine.
The solution needs to be fairly simple on the user side. The user skills could range from "Not Ignorant" up to "Almost Programmer". I would like to avoid anything that involves the user actually having to learn to hand write HTML, understand jsRender or other template library syntax. A drop down list of insertable data would be ideal.
I don't see much need for any complex logic syntax. My need is basic data token replacement, not any complex logic.
You can use jsviews + inner jsrender.
Create custom tag:
$.views.tags({
render : {
isUpdate : false,
init : function (tagCtx, linkCtx) {
var tag = this;
tag._template = tagCtx.args[0];
tag._data = tagCtx.args[1];
tag.template = "<div class='content'></div>";
},
_render : function () {
var tag = this;
var template = $.templates(tag._template.text);
tag.linkedElem.html(template.render(tag._data));
},
onUpdateTemplate : function () {
this._render();
},
onUpdateData : function () {
this._render();
},
onAfterLink : function (tagCtx, linkCtx) {
var tag = this;
tag._template = tagCtx.args[0];
tag._data = tagCtx.args[1];
if (tag._.unlinked) {
if (!tag.linkedElem) {
tag.linkedElem = tag._.inline ? tag.contents("*").first() : $(linkCtx.elem);
}
$.observable(tag._template).observeAll($.proxy(tag.onUpdateTemplate, tag));
$.observable(tag._data).observeAll($.proxy(tag.onUpdateData, tag));
} else {
$.observable(tag._template).unobserveAll($.proxy(tag.onUpdateTemplate, tag));
$.observable(tag._data).unobserveAll($.proxy(tag.onUpdateData, tag));
$.observable(tag._template).observeAll($.proxy(tag.onUpdateTemplate, tag));
$.observable(tag._data).observeAll($.proxy(tag.onUpdateData, tag));
}
tag._render();
},
onDispose : function () {
debugger;
var tag = this;
$.observable(tag._template).unobserveAll($.proxy(tag.onUpdateTemplate, tag));
$.observable(tag._data).unobserveAll($.proxy(tag.onUpdateData, tag));
},
onUpdate : function () {
return false;
},
dataBoundOnly : true
}
});
Create html:
<div id="page"></div>
<script id="templateEditor" type="text/x-jsrender">
<select data-link="selectedTemplate">
<option value="-">Please select</option>
{^{for templates}}
<option data-link="value{:#index} {:name} selected{:#index == ~root.selectedTemplate}"></option>
{{/for}}
</select>
<button data-link="{on addNew}">Add</button>
<br/>
<br/>
{^{if selectedTemplate!=="-"}}
template Name:<input data-link="templates[selectedTemplate].name" />
<br/>
<br/>
<textarea name="template" cols="40" rows="5" data-link="templates[selectedTemplate].text trigger=true"></textarea>
{{/if}}
<br/>
<br/>
{^{if selectedTemplate!=="-"}}
{^{render templates[selectedTemplate] data/}}
{{/if}}
</script>
And add app code:
var app = {
data : {
value : "test"
},
templates : [{
name : "Main",
text : "<span>{{:value}}</span>"
}
],
selectedTemplate : 0,
addNew : function () {
$.observable(this.templates).insert({
name : "new",
text : ""
});
}
};
$([app.templates]).on("arrayChange", function (o, e) {
if (e.change === "insert") {
$.observable(app).setProperty("selectedTemplate", e.index);
}
});
var templateEditor = $.templates("#templateEditor");
templateEditor.link("#page", app);
see live example on jsfiddle
Update 1:
I don't see much need for any complex logic syntax. My need is basic data token replacement, not any complex logic.
If you do not want to use jsRender use this code:
function template(str, data) {
return str.replace(/%(\w*)%/g, function (m, key) {
return data.hasOwnProperty(key) ? data[key] : "";
});
}
example on jsfiddle
Is it possible to link multiple documents in one view.
Eg :
{
"_id" : "0b86008d8490abf0b7e4f15f0c6a463b",
"name" : "copenhagen"}
{
"_id" : "8986008d8490abf0b7e4f15f0c6a333b",
"player" : "Mark"
}
{
"_id" : "4b86008d8490abf0b7e4f15f0c6a463c",
"location" : { "uuid" : "0b86008d8490abf0b7e4f15f0c6a463b"},
"player" : { "uuid" : "8986008d8490abf0b7e4f15f0c6a333b"},
"session" : "9876"
}
I want a view to include location document as well as the player document.
View :
"fetchByLocationAndPlayer": {
"map": "function(doc) { if (doc.session) { emit(doc.session, { _id : **doc.location.uuid** }); } }"
}
In the query I use includedocs = true.
How do I emit multiple documents corresponding to multiple keys in one document?
Yes it is possible. Just use two emits instead of one
emit(doc.session, {_id:doc.location.uuid});
emit(doc.session,{_id:doc.player.uuid});
Couch db wiki lists yet another way of doing this by iterating over the array and emitting linked docs one by one.
I'm a Scala/Lift beginner and I'm having trouble with rendering a list with optional "tags" on each item.
My HTML template says
<lift:Items.list>
<e:name>Rock</e:name><br />
<e:warning><span style="color:#ff0000;">DANGER!</span></e:warning>
</lift:Items.list>
And on the Items.scala I have
def list(node : NodeSeq) : NodeSeq = {
getItems flatMap( it => {
Helpers.bind("e", node,
"name" -> { Text(it.name) },
"warning" -> {
if (it.isDangerous) { <<INSERT HTML FROM TEMPLATE>> }
else { Text("") }
}
)
})
}
I'd like to, in certain cases, have the contents of the "e:warning" tag rendered verbatim. I'm sure there's an easy way to extract them from "node", but I guess I have some major gaps in my Lift knowledge because I can't figure out how.
If anyone could point out the proper procedure to me I'd be very thankful.
ANSWERED:
Thanks for the advice. I ended up structuring my code like this:
"warning" -> { (n : NodeSeq) => {
if (it.isDangerous) { n } else { Text("") }
}}
You can simply bind a function to the node’s name which takes a NodeSeq and returns a NodeSeq.
E.g.:
def warning(in: NodeSeq): NodeSeq = doSomethingWith(in)
// ...
Helpers.bind("e", node, "warning" -> warning _)
The contents of the <e:warning> node will then be transformed and inserted.
I'm not sure on the purpose of what you are trying to do. If you want to display one thing or the other, use chooseTemplate and a Box.
This code:
Html.CheckBoxList(ViewData.TemplateInfo.HtmlFieldPrefix, myList)
Produces this mark-up:
<ul><li><input name="Header.h_dist_cd" type="checkbox" value="BD" />
<span>BD - Dist BD Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="SS" />
<span>SS - Dist SS Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="DS" />
<span>DS - Dist DS Name</span></li>
<li><input name="Header.h_dist_cd" type="checkbox" value="SW" />
<span>SW - Dist SW Name </span></li>
</ul>
You can check multiple selections. The return string parameter Header.h_dist_cd only contains the first value selected. What do I need to do to get the other checked values?
The post method parameter looks like this:
public ActionResult Edit(Header header)
I'm assuming that Html.CheckBoxList is your extension and that's markup that you generated.
Based on what you're showing, two things to check:
The model binder is going to look for an object named Header with string property h_dist_cd to bind to. Your action method looks like Header is the root view model and not a child object of your model.
I don't know how you are handling the case where the checkboxes are cleared. The normal trick is to render a hidden field with the same name.
Also a nit, but you want to use 'label for="..."' so they can click the text to check/uncheck and for accessibility.
I've found that using extensions for this problem is error prone. You might want to consider a child view model instead. It fits in better with the EditorFor template system of MVC2.
Here's an example from our system...
In the view model, embed a reusable child model...
[AtLeastOneRequired(ErrorMessage = "(required)")]
public MultiSelectModel Cofamilies { get; set; }
You can initialize it with a standard list of SelectListItem...
MyViewModel(...)
{
List<SelectListItem> initialSelections = ...from controller or domain layer...;
Cofamilies = new MultiSelectModel(initialSelections);
...
The MultiSelectModel child model. Note the setter override on Value...
public class MultiSelectModel : ICountable
{
public MultiSelectModel(IEnumerable<SelectListItem> items)
{
Items = new List<SelectListItem>(items);
_value = new List<string>(Items.Count);
}
public int Count { get { return Items.Count(x => x.Selected); } }
public List<SelectListItem> Items { get; private set; }
private void _Select()
{
for (int i = 0; i < Items.Count; i++)
Items[i].Selected = Value[i] != "false";
}
public List<SelectListItem> SelectedItems
{
get { return Items.Where(x => x.Selected).ToList(); }
}
private void _SetSelectedValues(IEnumerable<string> values)
{
foreach (var item in Items)
{
var tmp = item;
item.Selected = values.Any(x => x == tmp.Value);
}
}
public List<string> SelectedValues
{
get { return SelectedItems.Select(x => x.Value).ToList(); }
set { _SetSelectedValues(value); }
}
public List<string> Value
{
get { return _value; }
set { _value = value; _Select(); }
}
private List<string> _value;
}
Now you can place your editor template in Views/Shared/MultiSelectModel.ascx...
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebUI.Cofamilies.Models.Shared.MultiSelectModel>" %>
<div class="set">
<%=Html.LabelFor(model => model)%>
<ul>
<% for (int i = 0; i < Model.Items.Count; i++)
{
var item = Model.Items[i];
string name = ViewData.ModelMetadata.PropertyName + ".Value[" + i + "]";
string id = ViewData.ModelMetadata.PropertyName + "_Value[" + i + "]";
string selected = item.Selected ? "checked=\"checked\"" : "";
%>
<li>
<input type="checkbox" name="<%= name %>" id="<%= id %>" <%= selected %> value="true" />
<label for="<%= id %>"><%= item.Text %></label>
<input type="hidden" name="<%= name %>" value="false" />
</li>
<% } %>
</ul>
<%= Html.ValidationMessageFor(model => model) %>
Two advantages to this approach:
You don't have to treat the list of items separate from the selection value. You can put attributes on the single property (e.g., AtLeastOneRequired is a custom attribute in our system)
you separate model and view (editor template). We have a horizontal and a vertical layout of checkboxes for example. You could also render "multiple selection" as two listboxes with back and forth buttons, multi-select list box, etc.
I think what you need is how gather selected values from CheckBoxList that user selected and here is my solution for that:
1- Download Jquery.json.js and add it to your view as reference:
2- I've added a ".cssMyClass" to all checkboxlist items so I grab the values by their css class:
<script type="text/javascript" >
$(document).ready(function () {
$("#btnSubmit").click(sendValues);
});
function populateValues()
{
var data = new Array();
$('.myCssClas').each(function () {
if ($(this).attr('checked')) {
var x = $(this).attr("value");
data.push(x);
}
});
return data;
}
function sendValues() {
var data = populateValues();
$.ajax({
type: 'POST',
url: '#Url.Content("~/Home/Save")',
data: $.json.encode(data),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function () { alert("1"); }
});
}
</script>
3- As you can see I've added all selected values to an Array and I've passed it to "Save" action of "Home" controller by ajax 4- in Controller you can receive the values by adding an array as argument:
[HttpPost]
public ActionResult Save(int[] val)
{
I've searched too much but apparently this is the only solution. Please let me know if you find a better solution for it.
when you have multiple items with the same name you will get their values separated with coma