How do I remove the drop-shadow from a YUI menu at runtime? - yui

I have a menu-button that I want to remove the drop-shadow from. I would like to not have to instantiate a menu object first (since it requires me to specify a div in the DOM to attach it to). I am able to instantiate a menu in the JS, but when I try to remove the drop shadow via: this.menuButton.getMenu().cfg.setProperty('shadow', false); the drop shadow still appears. I checked the cfg object in the JS debugger and shadow is set to false, but the shadow still appears.
Another option would be to remove the shadow div from the dom, but that doesn't seem like the right thing to do.

I did eventually create a div in my DOM to hold my menu. I was wary at first because my layout is not very robust (we outsourced to a graphic designer and have been trying to integrate his work with our code); this was why I didn't want to introduce a div into the DOM.
The key for me was to include the div in a place where it wouldn't affect the layout. Originally I had something that looked like this:
<input> type="button" id="srchType" />
<input type="text" id="first-name" value="First Name" />
<input type="submit" id="profiles-search-submit" value="Search" />
I inserted the div between two of the inputs; this screwed up my layout. The key was to insert the div before or after; this wouldn't screw up my layout. YMMV, depending on how sensitive your DOM is to changes; I hope this helps someone out if they're wondering what they should do.
After you do this (create your div) you can create a YUI Menu object like so:
var searchMenuItems =
[{ text: "First Name", value: 'firstName', onclick: {fn: onMenuItemClick}},
{ text: "Last Name", value: 'lastName', onclick: {fn: onMenuItemClick}}];
var srchTypeMenuConfig = { shadow: false,
effect: {
effect: YAHOO.widget.ContainerEffect.FADE,
duration: .25
}
};
this.srchTypeMenu = new YAHOO.widget.Menu(this.searchMenuEl,
srchTypeMenuConfig);

Related

How to edit style attribute on Angular six component

I'm new to Angular development.
I have started developing a web site using Angular 6 Material (material.angular.io) and kicked this off with navigation schematic that delivers a responsive toolbar and side nav component for navigation. The default HTML layout looks something like this:
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav"
...
<mat-toolbar color="primary">
...
</mat-toolbar>
<mat-nav-list>
<a mat-list-item routerLink='/menu1'>menu 1</a>
...
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content >
<mat-toolbar color="primary" >
<mat-toolbar color="primary" class="mat-toolbar" >
<mat-toolbar-row >
...
</mat-toolbar-row>
</mat-toolbar>
</mat-toolbar>
<!-- Application components go here-->
<router-outlet></router-outlet>
</mat-sidenav-content>
</mat-sidenav-container>
mat-sidenav-container contains the 'drawer' mat-sidenav to the left of mat-sidenav-content
I want to programmaticaly shrink the width of mat-sidenav, subsequently shifting mat-sidenav-content to the left.
I can do the first part, by using [ngClass] on mat-sidenav and changing this on demand -
However, I'm not having the same success with the content section on the right of the drawer, by just merely changing its CSS Class to have the correct width..
Looking at the source code, I see mat-sidenav-content not only has CSS Classes but also has style attribute as "margin-left:200px"
(which overrides any CSS class styling I set)
I want to programmaticaly change this margin-left value.
How do I do that ?
Thanks -
html:
<mat-sidenav #drawer [(ngStyle)]="{'width': myWidth}">
typescript:
export class HeroesComponent implements OnInit {
myWidth: 25px;
}

Best practice to add a Test-Button in a Orchard-AdminView

I'd like to add a "Test"-Button to the Create/Edit-AdminViews in my Orchard-Module.
The Button itself is rendered fine using an additional shape.
Question: how can I make the button's action point to a "Test"-Action which gets the current ViewModel, performs the "Test", displays an info and returns the user to the view (passing the ViewModel back in again).
At the Moment, it completely ignores it's surrounding Form.
Maybe there's already some working example and I simply couldn't find it?
Thanks for any help.
Sascha
PS: Code in Content.TestButton.cshtml
#using ( Html.BeginFormAntiForgeryPost(Url.Action("Test", new { controller = "DnsCheckAdmin" }), FormMethod.Post, new { #class = "col-md-5" }) )
{
<fieldset class="test-button">
<button type="submit" name="submit.Test" value="submit.Test">#T("Test settings")</button>
</fieldset>
}

Can a Url.Action specify a route in MVC5?

In our default layout we have our logo wrapped with a URL.Action to navigate back to the home screen. However, if we are in an Area, it tries to navigate to the home controller in that area, which doesn't exist.
Our home controller is Submission. Here is the link in the layout file:
<a class="navbar-brand custm-navbar-brand" href="#Url.Action("Index", "Submission")">
<img src="#Url.Content("~/Content/images/eed-main-logo.png")" alt="E-Editorial Discovery" width="335" height="56">
</a>
If I am in an area like this: /Admin/Security/Index
the above link tries to go to: /Admin/Submission/Index
but it should go to: /Submission/Index
I'm sure there's a better way, but I haven't found it yet.
Specify the area like you would a parameter. So your first line should be:
<a class="navbar-brand custm-navbar-brand" href="#Url.Action("Index", "Submission", new { Area = "AreaName" })">
You could specify the area in the Url.Action call but this can get messy.
Rather than having to specify the area, why not sort the route out itself so it knows to tie it down to that namespace:
context.MapRoute("ExpressCheckoutRoute",
"expresscheckout/stage/{stageName}/{id}",
new { controller = "ExpressCheckout", action = "Stage", area = "FrontEnd", id = UrlParameter.Optional },
new[] { "Web.Areas.FrontEnd.Controllers" }
).DataTokens["UseNamespaceFallback"] = false;
This sorted the issue out for me and I no longer have to specify the area paramter (take note of the last 2 parts to that mapping).

Primefaces: Input Text / Overlay panel / Retain focus

We have a p:inputText element that should display an overlay panel for various options. (Its a global search, so you can tick categories to search in)
Users usually click in the textbox, start typing and THEN look at the screen again
The Problem is: As soon as the overlay panel is shown, the textbox looses its focus.
<p:inputText id="searchItem"></p:inputText>
<p:overlayPanel id="gsOverlay" for="searchItem" my="left top"
at="left bottom" dynamic="true"
onShow="resizeGSOverlay();">
So i tried to fix this, by immediately focusing back on the "search" inputtext using
<p:overlayPanel id="gsOverlay" for="searchItem" my="left top"
at="left bottom" dynamic="true"
onShow="PrimeFaces.focus('globalSearchForm:searchItem'); resizeGSOverlay();">
However, there is a split second, where the inputfield lost focus, leading to searches missing the first charater.
Can i display the overlay panel, without having the inputtext loosing its focus? (Each component inside the overlay panel will focus back after clicking, that's fast enough - just the initial focus-back is to slow)
Just found the "holy grail":
Default for the overlayPanel is:
PrimeFaces.widget.OverlayPanel.prototype.applyFocus = function(){
this.jq.find(':not(:submit):not(:button):input:visible:enabled:first').focus();
}
so, I just put the following javascript AFTER including the primefaces resources, which will then override the default implementation:
<script type="text/javascript">
PrimeFaces.widget.OverlayPanel.prototype.applyFocus = function() {
if (this.id == "globalSearchForm:gsOverlay")
return;
else
this.jq.find(':not(:submit):not(:button):input:visible:enabled:first').focus();
}
</script>
So - No focus for any element within the overlay panel in question once it becomes visible. Works like a charm.
Update:
using the Proxy Pattern (http://api.jquery.com/Types/#Proxy_Pattern) seems a more reliable solution, as it avoids the need to duplicate the content of the original implementation, which might be different in one of the next Primefaces releases:
<script type="text/javascript">
(function() {
var proxied = PrimeFaces.widget.OverlayPanel.prototype.applyFocus;
PrimeFaces.widget.OverlayPanel.prototype.applyFocus = function(){
if (this.id == "globalSearchForm:gsOverlay")
return;
return proxied.apply(this, arguments);
};
})();
</script>

Trying to create onclick event in node js grid using KOGrid

I would like to have a nice interactive grid view in an HTML page. I am using nodejs, express, twitterbootstrap, knockoutjs, for my technology stack. I am trying to use KOGrid to display various data points with some nice built in column sorting and other grid functionality.
My issue is trying to fire an event when a button is clicked in a row. And pass to that event, some of the various data fields from that specific row. So in KOGrid specifics, I am using cellTemplates and I need to call some function in the onclick event, but pass that function some KOGRID data bounded values. So, in my input element I would have
data-bind="onclick: [Name of my function]( [name of some data bounded variable], [name of some other data bounded variable])
Can someone show me how to do this?
Here is a sample of my code...the input/onclick in the CBTemplate is where I am having issues.
CBTEMPLATE:
<script type="text/html" id="actionTemplate">
<div data-bind="kgCell: $cell">
<input type="checkbox" value="1" class="checkbox" checked="checked" data-bind="onclick: 'MyOnClickFunction( siteId(), status() )'"/>
</div>
</script>
DIV TAG:
<div data-bind="koGrid: { data: offer.siteCounts,
columnDefs: [ { field: 'templateField0', displayName: 'Site', cellTemplate: 'siteTemplate', width: 150},
{ field: 'status', displayName: 'Current Status', cellClass: 'site', cellTemplate: 'statusTemplate', width: 115},
{ field: 'details', displayName: 'Details', width: 175},
{ field: 'actionField0', displayName: 'Action', cellTemplate: 'cbTemplate', width: 200}],
autogenerateColumns: false,
displaySelectionCheckbox: false,
isMultiSelect: false }">
</div>
The click event binding should look like this with KO:
data-bind="click: function(data,event) { MyOnClickFunction(siteId(), status()) }"
Here is a working JSFiddle where you can play with it.
Some sidenotes:
In my sample I have used the $root binding context property to access the sample function: $root.offer.MyOnClickFunction. You will need to adjust this depending on which level you have defined the MyOnClickFunction on your viewmodels.
You need to return true from the click binding handler if you do want to let the default click action proceed (e.g checking the checkbox etc.)

Resources