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) {
|
||||
var ctor = this.constructor;
|
||||
if ([Story, Image, File, Poll].indexOf(ctor) > -1) {
|
||||
res.write('<span class="macro-code">');
|
||||
res.encode("<% ");
|
||||
res.write(handler || ctor.name.toLowerCase());
|
||||
res.write(String.SPACE);
|
||||
res.write(quote(this.name || this._id));
|
||||
res.encode(" %>");
|
||||
res.write('</span>');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,10 +64,11 @@ $(function() {
|
|||
<% listItemFlag <% gettext custom %> %>
|
||||
%>
|
||||
<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
|
||||
<% 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 rowspan="2" width="10" nowrap="nowrap"> </td>
|
||||
<td valign="bottom" rowspan="2" align="right" class="small">
|
||||
|
|
|
@ -1,10 +1,33 @@
|
|||
$(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) {
|
||||
event.preventDefault();
|
||||
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 = [],
|
||||
element = $("form#prefs #timeZone");
|
||||
element.find("option").each(function(index, item) {
|
||||
|
@ -25,6 +48,7 @@ $(function() {
|
|||
$(item).html($(item).html().replace(key, ""));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue