Display ASP.MVC view in CKEditor dialog window - asp.net-mvc

I created a plugin with a custom dialog window.
CKEDITOR.plugins.add('imggallery',
{
init: function (editor) {
var pluginName = 'imggallery';
editor.ui.addButton('Image',
{
label: 'Add image',
command: 'OpenWindow',
icon: CKEDITOR.plugins.getPath('imggallery') + 'lightbulb.gif'
});
editor.addCommand('OpenWindow', new CKEDITOR.dialogCommand('simpleLinkDialog'));
var html2 = "<h1>This is a heading</h1>";
CKEDITOR.dialog.add('simpleLinkDialog', function (editor) {
return {
title: 'LinkProperties',
minWidth: 400,
minHeight: 200,
contents:
[
{
id: 'general',
label: 'Settings',
elements:
[
{
type: 'html',
html: html2
}
]
}
]
};
});
}
});
My question is: Is it possible to somehow display ASP.MVC view in window content?
When I assign html2 to elements property the text is shown without formatting (plain text).

Are you sure it's plain text and not a H1 tag that is formatted to look like plain text? There's a big difference :). The CKE dialogs reset most of the standard browser styles so that elements appear like plain text, even though they are not.
As for the MVC view, I would recommend that you add an iframe within the CKE dialog and display the page normally there. Then you can control or get/set values from the iframe using JavaScript. It will be a bit tricky, but should work.
var html2 = '<iframe id="DialogIframe" src="/MyController/MyView?foo=bar"></iframe>';
The other option is to use something like jQuery to $.get() the HTML and then use it, should be relatively simple if you have worked with ajax before. If not, here's a good chance to start! :)

Related

Joomla tooltip not hiding

My problem is that tooltips are not hiding after the cursor is moved away from the text with tooltip. You can check this page for an example of this problem:
http://federationgenealogie.qc.ca/nous-contacter (which is an simple com_contacts page)
But the problem persists throughout the website.
I've tried to the a template override of the com_contacts and to change the way tool-tips are handled using: http://docs.joomla.org/How_to_add_tooltips_to_your_Joomla!_website
$toolTipArray = array('className' => 'mytooltipclass', 'showDelay'=>'500',
'hideDelay'=>'500', 'fixed'=>true,
'onShow'=>"function(tip) {tip.effect('opacity',
{duration: 500, wait: false}).start(0,1)}",
'onHide'=>"function(tip) {tip.effect('opacity',
{duration: 500, wait: false}).start(1,0)}");
JHTML::_('behavior.tooltip', '.hasTip', $toolTipArray); ?>
Only the 'fixed'=>true parameter works, so I get a feeling this kind of works. But since all other parameters are not working, this is not a solution.
I've also tried to make my own tooltip.js file containing:
window.addEvent('domready', function(){
//do your tips stuff in here...
var zoomTip = new Tips($$('.hasTip'), {
className: 'mytooltipclass', //this is the prefix for the CSS class
offsets: {
'x': 20, //default is 16
'y': 30 //default is 16
},
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity',
{duration: 1000, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(0,.8);
},
onHide: function(toolTip) {
this.fx.start(.8,0);
}
});
});
But I only get a tooltip that looks like an html alt, and changing my css files with according class names does not work.
Using a tooltip extension is not the solution because I need the default registration and contact page of joomla to work. And they both use class="hasTip"and changing this would require me to do some hacking which I can not do for durability reasons.
Using firebug and chrome, it does not seems like there is a conflict between javascripts.
Any ideas?

How to change Panel Size in mozilla like chrome extension

Panel Size is fixed in SDK-based Add-on
I want to change the size of panel automatically like chrome dictionary extension here
If you will search in panel it will show big and small data like content requirement.
In Mozilla panel we can fix only 1 type of size like width:400px and height:400px etc. but i want that panel size should based on data size means like chrome extensions.
You can implement this in the Add-on SDK with a little extra code.
In main.js:
var panel = require("panel").Panel({
contentURL: "https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK",
onShow: function() {
let worker = tabs.activeTab.attach({
contentScriptFile: [
data.url('windowsize.js')
]
});
worker.port.on('winsize', function(data) {
panel.resize((data.width-120), (data.height-120));
});
worker.port.emit('fetchwinsize');
}
});
In the content script:
self.port.on('fetchwinsize', function() {
self.port.emit("winsize", {height: window.innerHeight, width: window.innerWidth});
});
Here's a working example of this:
https://builder.addons.mozilla.org/package/150225/latest/

Need help in Kendo Window UI control

I am working on a councelor portal which is a part of our project in company and my boss advised me to use kendow windo pop control for popups on certain links.
I have done it by using the kendo application control but a little problem arouse which makes my look and feel bad a little.
we got links on one page and our application is supposed to show use popup window when any of the link will be clicked but when I actually runs the page then a popup kendo window comes first and when I minimize it or close it then link starts working according to our desire.
I am sure there is some problem with jquery code which shows the popup window on document.ready(function(){}); but it should work when a link is clicked.
I am posting my code here please help me out to make it more refined and good looking
var window = $("#window"),
undo = $("#undo")
.bind("click", function () {
window.data("kendoWindow").open();
window.data("kendoWindow").center();
undo.hide();
});
var onClose = function () {
undo.show();
}
if (!window.data("kendoWindow")) {
window.kendoWindow({
width: "600px",
height: "500px",
draggable: false,
actions: ["Minimize", "Maximize", "Close"],
resizable: false,
title: "Report Activity",
content: "../../AlertCounselor.htm",
close: onClose
});
}
HTML:
<div id="window"></div>
<label id="undo" style="display:none; width:200px;" class="k-group" >Alert Counselor</label>
If you don't want the window to be displayed when the document is loaded, you should specify visible: false in the initialization (check documentation here ).
Lets assume that you have the following link:
Click here for opening the window and not before
Then define the window as:
var myWindow = window.kendoWindow({
visible : false,
width : "600px",
height : "500px",
draggable: false,
actions : ["Minimize", "Maximize", "Close"],
resizable: false,
title : "Report Activity",
content : "../../AlertCounselor.htm",
close : onClose
}).data("kendoWindow");
This should leave the window closed waiting for something else that open it.
Finally define a click event handler for the link:
$("#open").on("click", function() {
myWindow.open();
});

Making a panel only available for certain URLs

Chrome has something called "Page Actions", and I'm roughly trying to replicate that functionality with the Firefox Addon SDK/Jetpack. There's probably a better approach than what I've tried so far, and I'm open to suggestions.
Using tabs, I'm able to listen for tab ready and activate events, and if the tab's URL matches, the addon widget should be enabled; if not, disabled. I've got to the point where I can change the icon when appropriate, but I'd like to disable the panel as well.
Strategy 1: Steal the click event and only show the panel if we're on the right page; otherwise, ignore. Problem is, according to the docs, manually showing the panel causes it not to be anchored, a bug that's not had much progress on it.
Strategy 2: Set the contentURL to null when disabling. Get an error whining about it not being an URL.
Strategy 3: Use a different HTML document for the disabled state. Setting panel.contentURL to another URL doesn't work after going to a different page?
Here's the code:
const widgets = require("widget");
const Panel = require("panel").Panel;
const tabs = require("tabs");
const data = require("self").data;
const prefs = require("simple-prefs").prefs;
var panel = Panel({
width: 480,
height: 640,
contentURL: data.url("panel.html"),
contentScriptFile: [data.url('jquery.min.js'), data.url('panel.js')],
onMessage: function (msg) { console.log(msg) }
});
var widget = widgets.Widget({
id: "icon",
label: "Export",
contentURL: data.url("icon.png"),
panel: panel
});
function enable() {
widget.contentURL = data.url('icon.png');
panel.contentURL = data.url("panel.html");
}
function disable() {
widget.contentURL = data.url('icon_disabled.png');
panel.contentURL = data.url("panel_disabled.html");
}
function on_change_tab(tab) {
console.log(tab.url);
if (/http:\/\/example.com\/.*/.exec(tab.url)) {
console.log('ENABLE');
enable();
} else {
console.log('DISABLE');
disable();
}
console.log(panel.contentURL);
}
tabs.on('ready', on_change_tab);
tabs.on('activate', on_change_tab);
Related, but should have the anchoring problem? How to reload a widget popup panel with firefox addon sdk?
In case you still haven't solved your issue (and for anyone else having a similar problem):
I had a similar issue and resolved it by using erikvold's ToolbarButton package. Once you've installed that and its dependencies, something like this in your main.js file should work.
var pan = require("panel").Panel({
width: 400,
height: 600,
contentURL: "http://stackoverflow.com"
//maybe some more options here
});
var button = require("toolbarbutton").ToolbarButton({
id: "myButton",
label: "My Button",
image: data.url("someicon.png"),
panel: pan //This binds the panel to this toolbarbutton
});
I hope you can find some way to adapt this to your project.
toolbarbutton.ToolbarButton({
id: "MyAddon",
label: "My Addon",
tooltiptext: "My Addon Tooltip",
image: data.url("logo.png"),
onCommand: function() {
var dictionary_panel = require("panel").Panel({
width:630,
height:600,
contentURL: data.url("HtmlPage.html"),
contentScriptWhen: 'ready',
contentScriptFile: [data.url("style.css"),data.url("jquery-1.7.1.js"),
data.url("javascriptquezz.js"),data.url("create.js")]
});
dictionary_panel.show();
}
});

Styling Panels of a Firefox Addon

So I created a Widget that the user clicks on and it opens up a Panel, I have a couple of Questions about the panel.
How Do I style the Panels borders, background color, etc..? I'm including an HTML file in it's contentURL, can I add CSS to alter it? If so how do I select it via CSS?
I also want to add a Close Button and keep the panel open always unless they click the close button.
On second thought, for the Add-on i'm trying to program it might be better if I make a window, is a window pretty stylable so I can make it look cooler?
Thanks for any help.
I don't think you can style panel borders. The panel border styles depend on the operating system and you cannot touch them. You can only really influence the inner area of the panel, effectively you get an iframe inside the panel that you can play with. E.g. to change the background your panel can contain:
<style type="text/css">
html
{
background-color: red;
}
</style>
You cannot, the panel is not a real HTML object, but a XUL window with an iframe or HTML inside.
I believe since Firefox 30 you can access to this object, you can read:
Avoid panel to autoHide in Firefox extension
Of course it's a kind of hack, looks like Mozilla is not really "open" ^^
I was able to modify the border of the panel:
/*run this first*/
var win = Services.wm.getMostRecentWindow('navigator:browser');
var panel = win.document.createElement('panel');
var screen = Services.appShell.hiddenDOMWindow.screen;
var props = {
noautohide: true,
noautofocus: false,
level: 'top',
style: 'padding:15px; margin:0; width:150px; height:200px; background-color:steelblue;border-radius:15px'
}
for (var p in props) {
panel.setAttribute(p, props[p]);
}
win.document.querySelector('#mainPopupSet').appendChild(panel);
panel.addEventListener('dblclick', function () {
panel.parentNode.removeChild(panel)
}, false);
panel.openPopup(null, 'overlap', screen.availLeft, screen.availTop);
So if you know the panel of your id just do this:
var sss = Cc['#mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
var css = '';
css += '#YourPanelIdHere { border-radius:15px; opacity:.5; border:1px solid red; }';
var cssEnc = encodeURIComponent(css);
var newURIParam = {
aURL: 'data:text/css,' + cssEnc,
aOriginCharset: null,
aBaseURI: null
}
var cssUri = Services.io.newURI(newURIParam.aURL, newURIParam.aOriginCharset, newURIParam.aBaseURI);
sss.loadAndRegisterSheet(cssUri, sss.USER_SHEET);
//sss.unregisterSheet(cssUri, sss.USER_SHEET);
That will style your panel. You don't have to use panel id in the style sheet, just anything that target your panel will do.

Resources