Execute action (task) in a toolbar button joomla 2.5 - joomla

i am trying to modify the com_phocamaps to add the "Copy marker" action.
I have created the button modifying function addToolbar with this line JToolBarHelper::customX( 'phocamapsmarker.copy', 'copy.png', 'copy_f2.png', 'Copy Marker' ); in the com_phocamaps/views/phocamapsmarkers/view.html.php but i don´t know where i have to set the action to execute de COPY task.
When I click this new button, Joomla throws a 500 Error.
I want to implement a litle function to copy the marker and set Publish = 0 to change the map.
Thanks

you need to write that function in controller
go to administrator\components\com_phocamaps\controllers\phocamapsmarker.php
and write this function
function copy(){
// your code here
}

Related

Access the child (Button) of a prefab and add function OnClick to it. Unity

I have a prefab which contains some buttons and I want to get the buttons and add specific onClick functions to them via script. I cant find the right way to get the buttons.
What I am trying is:
tempGo = Instantiate(prefabs[0]);
tempGo.transform.SetParent(transform, false);
tempGo.transform.localScale = Vector3.one;
tempGo.transform.localPosition = Vector3.zero;
Transform t = tempGo.GetComponentInChildren<Transform>().Find("AddGoals");
"AddGoals" Is my Buttons(Tag name)
So after this point how can I code it to add a specific function when the button gets clicked?
Any help would be appreciated thank you!
Get button component and add listener to it. Listener will call the function when that button is clicked. TaskOnClick is an example function that will be called when the button is clicked.
t.GetComponent<Button>().onClick.AddListener(TaskOnClick);
void TaskOnClick()
{
Debug.Log("You have clicked the button!");
}
Using .Find(""), you are looking for a gameobject with that name, not its tag. What you can do is after instantiating the object, use GameObject.FindGameObjectsWithTag("AddGoals"). This will return an array of all of the objects with that tag. Then with Linq you can do something like:
var items = GameObject.FindGameObjectsWithTag("AddGoals"); //This gives gameobject array
var itemTansforms = items.Select(x=>x.transfrom).ToList(); //gives you a list of the object tansforms
As for adding an event, you would need to grab the button component of the object and then add the onclick event.
items.ForEach(x=>x.GetComponent<Button>().AddListener(delegate {Debug.Log($"{x.name} has been clicked")}));
You would have to make sure it is actually a button, or the code will fail. This of course can be modified and is just an example. I hope this helps!

Kendo ui grid inline and popup mixed and template on popup

I just saw this link which is a great explanation by onabai, but i´m trying to also set a template for the temporary popup and i can´t make it work:
$(".k-grid-popup", grid.element).on("click", function () {
// Temporarily set editable to "popup"
grid.options.editable = "popup";
// Insert row
grid.addRow();
// Revert editable to inline
grid.options.editable = "inline";
});
How do you set the template of the popup?
Regards.
While you can access the grid options directly, any change to the options should be made using the setOptions method. This function will notify the grid of any options change and it will be able to make all the internal change the handle the event according the the new options.
$(".k-grid-popup", grid.element).on("click", function () {
grid.setOptions({editable: "popup"});
grid.addRow();
grid.setOptions({editable: "inline"});
});
I don't have any working example of your code so I can't tell if you need to change something else in your code.

angular ui-grid filter on button click

I'm new in angular. We are using UI-grid for data presentation is is possible to customize filter process. I want to customize it in that way, that filtering is peformmed on button click, not on keydown?
This is idea
$scope.search = function (){
$scope.personCardGrid.useExternalFiltering = false; $scope.grid1Api.core.notifyDataChange(uiGridConstants.dataChange.ALL);
$scope.gridApi.core.refresh() $scope.personCardGrid.useExternalFiltering = true;
$scope.grid1Api.core.notifyDataChange(uiGridConstants.dataChange.ALL);
$scope.gridApi.core.refresh() }
Regards
You need to define your own headerCellTemplate for the column. In the template, add a input text box and a button too. Then, define a function in the controller and call it using the external scope which will filter the records.

CKEditor - Trigger dialog ok button

I'm using CKEditor and I wrote a plugin that pops up a the CKEditor dialog.
I need to re design the ok button and add to the footer more elements like textbox and checkbox but it's seems to be to complicated to do so, so I've hide the footer part and created a uiElement in the dialog content with all what I need but now what I want is to trigger the okButton in the hidden footer but I can't find a way to do it..
Anyone?!
There may be a better way, but here's how I'm doing it:
var ckDialog = window.CKEDITOR.dialog.getCurrent(),
ckCancel = ckDialog._.buttons['cancel'],
ckOk = ckDialog._.buttons['ok'];
ckOK.click();
The trick is to get the button and then use the CKEditor Button API to simulate the click. For some reason, I was unable to call dialog.getButton('ok') because getButton is undefined for some reason. My method digs into the private data, which I doubt is the best way to do it.
From the onShow event (when defining the dialog), I was able to get the ok button like the docs indicate:
onShow: function () {
var okBtn = this.getButton('ok');
...
}
Here's the Button API: http://docs.ckeditor.com/#!/api/CKEDITOR.ui.dialog.button, and you can access the dialog API there too (I'm assuming you've already been there!!!)
You might try to add this line in your plugin.js.
var dialog = this.getDialog();
document.getElementById(dialog.getButton('ok').domId).click();
In my custom plugin, i just hide the "ok" button instead of the whole footer.
Below is a part of my plugin.js statements.
{
type : 'fileButton',
id : 'uploadButton',
label : 'Upload file',
'for' : [ 'tab1', 'upload' ],
filebrowser :
{
action : 'QuickUpload',
onSelect : function(fileUrl, data){
var dialog = this.getDialog();
dialog.getContentElement('tab1','urlTxt').setValue(fileUrl);
document.getElementById(dialog.getButton('ok').domId).click();
}
}
}
btw, i'm using CKEditor 4.0 (revision 769d96134b)

ExtJS 4 how to properly create a KeyMap for a window when using MVC

I have a simple ExtJS application that is written MVC style (much of my information from here).
My application creates a viewport, and has a view with a form, some fields and a button.
The application has a controller with a 'loginButtonClick" function, and the controller watches the click event with a:
this.control({
'loginwindow button[action=save]': {
click: this.loginButtonClick
}
}
That works great, but now when the login window is showing, I want the enter key to also execute the loginButtonClick method.
I have tried all kinds of things, but the basic issue I am having is WHERE to put the code for creating the keymap, and how to bind it to the proper instances.
For example, if I create the keymap in the controller (which is my preference), I need to get the specific view instance for that controller (I might have multiple windows open of the same kind).
So, How would you create a key map (or?) from within a controller for it's view (window), calling a local method (this.loginButtonClick) when the enter key is pressed?
What you can do is bind the code that initializes the keyMap to the login window afterrender event like this:
this.control{(
'loginwindow' : {
afterrender: this.initializeKeyMap
}
Then make a function that sets up the keyNav:
initializeKeyMap: function(window, options) {
this.keyNav = Ext.create('Ext.util.KeyNav', window.el, {
enter: this.loginButtonClick,
scope: this
});
}
Now when the dialog is loaded if the user presses the Enter key, it should execute your function.
You could setup all these things on your window render event. So when it is rendered you add an eventlistener for the enter key, and in the handler you call programatically click on the login button.
You can achieve this by adding the following listeners to your text/password fields in the form
listeners: {
specialkey: function(field, e){
if (e.getKey() == e.ENTER) {
var form = this.up('form').getForm();
submitLoginForm(form);
}
}
}
Here 'form' is your form and 'submitLoginForm' is the function called at form submit which I guess is loginButtonClick in your case.
Hope this helps.

Resources