Implemented selection of macro code on click
This commit is contained in:
parent
c321c837d0
commit
8e0e494d9a
3 changed files with 30 additions and 3 deletions
|
@ -476,11 +476,13 @@ HopObject.prototype.upload_macro = function(param, name) {
|
||||||
HopObject.prototype.macro_macro = function(param, handler) {
|
HopObject.prototype.macro_macro = function(param, handler) {
|
||||||
var ctor = this.constructor;
|
var ctor = this.constructor;
|
||||||
if ([Story, Image, File, Poll].indexOf(ctor) > -1) {
|
if ([Story, Image, File, Poll].indexOf(ctor) > -1) {
|
||||||
|
res.write('<span class="macro-code">');
|
||||||
res.encode("<% ");
|
res.encode("<% ");
|
||||||
res.write(handler || ctor.name.toLowerCase());
|
res.write(handler || ctor.name.toLowerCase());
|
||||||
res.write(String.SPACE);
|
res.write(String.SPACE);
|
||||||
res.write(quote(this.name || this._id));
|
res.write(quote(this.name || this._id));
|
||||||
res.encode(" %>");
|
res.encode(" %>");
|
||||||
|
res.write('</span>');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,11 @@ $(function() {
|
||||||
<% listItemFlag <% gettext custom %> %>
|
<% listItemFlag <% gettext custom %> %>
|
||||||
%>
|
%>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<div class="ample"><strong><% gettext Macro suffix=: %></strong> <%
|
<div class="ample"><strong><% gettext Macro suffix=: %></strong>
|
||||||
|
<span class='macro-code'><%
|
||||||
<% if <% skin.prototype %> is Global then
|
<% if <% skin.prototype %> is Global then
|
||||||
<% skin.name prefix="skin " %> else
|
<% skin.name prefix="skin " %> else
|
||||||
<% skin.name prefix=<% skin.prototype suffix=".skin " | lowercase %> %> %> %></div>
|
<% skin.name prefix=<% skin.prototype suffix=".skin " | lowercase %> %> %> %></span></div>
|
||||||
</td>
|
</td>
|
||||||
<td rowspan="2" width="10" nowrap="nowrap"> </td>
|
<td rowspan="2" width="10" nowrap="nowrap"> </td>
|
||||||
<td valign="bottom" rowspan="2" align="right" class="small">
|
<td valign="bottom" rowspan="2" align="right" class="small">
|
||||||
|
|
|
@ -1,10 +1,33 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
// Extend jQuery with selectText() method.
|
||||||
|
$.fn.selectText = function() {
|
||||||
|
var element = this.get(0);
|
||||||
|
if (document.body.createTextRange) { // ms
|
||||||
|
var range = document.body.createTextRange();
|
||||||
|
range.moveToElementText(element);
|
||||||
|
range.select();
|
||||||
|
} else if (window.getSelection) { // moz, opera, webkit
|
||||||
|
var selection = window.getSelection();
|
||||||
|
var range = document.createRange();
|
||||||
|
range.selectNodeContents(element);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go back one step in history when clicking on links with the cancel class.
|
||||||
$("a.cancel").click(function(event) {
|
$("a.cancel").click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
history.back();
|
history.back();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Group related <option> elements by inserting additional <optgroup> elements:
|
// Select the macro code when clicking on elements with the macro-code class.
|
||||||
|
$('.macro-code').click(function(event) {
|
||||||
|
$(this).selectText();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Group related <option> elements by inserting additional <optgroup> elements.
|
||||||
var groups = [],
|
var groups = [],
|
||||||
element = $("form#prefs #timeZone");
|
element = $("form#prefs #timeZone");
|
||||||
element.find("option").each(function(index, item) {
|
element.find("option").each(function(index, item) {
|
||||||
|
@ -25,6 +48,7 @@ $(function() {
|
||||||
$(item).html($(item).html().replace(key, ""));
|
$(item).html($(item).html().replace(key, ""));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue