Commit 4431f45b authored by Timothy Steiner's avatar Timothy Steiner
Browse files

[#642] Adding a button for adding month widgets.

parent 18d1936d
......@@ -287,6 +287,23 @@ Unl.hasParentNodeWithClass = function(childNode, parentClass) {
});
ed.addButton('unlTooltip', {title : 'Add Tooltip', cmd : 'mceUnlTooltip', 'class' : 'unlTooltip'});
ed.addCommand('mceUnlEventMonthWidget', function() {
ed.windowManager.open({
file: url + '/event-monthwidget.html',
width: 500,
height: 200,
inline: 1
});
});
ed.onNodeChange.addToTop(function(ed, cm, n) {
cm.setActive('unlEventMonthWidget', n.id == 'monthwidget');
if (n.id == 'monthwidget') {
ed.selection.select(n);
}
});
ed.addButton('unlEventMonthWidget', {title: 'Add Month Widget', cmd : 'mceUnlEventMonthWidget', 'class' : 'unlEventMonthWidget'});
},
/**
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Add Event Month Widget</title>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/mctabs.js"></script>
<script type="text/javascript" src="../../utils/form_utils.js"></script>
<script type="text/javascript" src="../../utils/validate.js"></script>
<script type="text/javascript" src="js/event-monthwidget.js"></script>
<script type="text/javascript" src="editor_plugin.js"></script>
</head>
<body id="link" style="display: none">
<form action="#" id="unlEventMonthWidgetForm">
<div class="tabs">
<ul>
<li id="general_tab" class="current">
<span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">Add Event Month Widget</a></span>
</li>
</ul>
</div>
<div class="panel_wrapper">
<div id="general_panel" class="panel current">
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="nowrap"><label for="href">Event URI:</label></td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<input id="unlEventUri" name="unlEventUri" type="text" class="mceFocus" value="" style="width: 200px"" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<div class="mceActionPanel">
<input type="submit" id="insert" name="insert" value="Add Event Month Widget" />
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
</div>
</form>
</body>
</html>
tinyMCEPopup.requireLangPack();
var UnlMonthWidgetDialog = {
init : function() {
var selection = tinyMCEPopup.editor.selection;
var node = selection.getNode();
if (node && node.id == 'monthwidget') {
var matches = selection.getContent().match(/UNLevent_monthWidget\.init\(([^)]*)\)/i);
var calendarUri = matches[1].substr(1, matches[1].length - 2);
document.getElementById('unlEventUri').value = calendarUri;
UnlMonthWidgetDialog.calendarUri = calendarUri;
}
document.getElementById('unlEventMonthWidgetForm').onsubmit = UnlMonthWidgetDialog.submit;
},
submit : function() {
var selection = tinyMCEPopup.editor.selection;
var eventUri = document.getElementById('unlEventUri').value;
var node = selection.getNode();
if (node && node.id == 'monthwidget') {
var html = selection.getContent()
selection.setContent(html.replace(UnlMonthWidgetDialog.calendarUri, eventUri));
} else {
selection.setContent("<div id=\"monthwidget\"><script type=\"text/javascript\">function getElementsByClass(node,searchClass,tag) {return WDN.jQuery(tag+'.'+searchClass, node);} WDN.loadCSS('http://www.unl.edu/ucomm/templatedependents/templatecss/components/monthwidget.css'); WDN.loadJS('http://www.unl.edu/ucomm/templatedependents/templatesharedcode/scripts/UNLevent_monthWidget.js', function() {UNLevent_monthWidget.init('" + eventUri + "');});</script></div>");
}
tinyMCEPopup.close();
return false;
},
calendarUri : ''
};
tinyMCEPopup.onInit.add(UnlMonthWidgetDialog.init, UnlMonthWidgetDialog);
......@@ -57,3 +57,9 @@ scrollbar-track-color:#F5F5F5;
border:1px dashed #ccc;
margin:-1px;
}
#monthwidget {
width:206px;
height:196px;
background-image:url("img/monthwidget.png");
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment