How to change ng-grid foot language - ng-grid

I am using ng-grid for my web site table Plug-in and
I want to change "items per page" into another language
How to do this? Can any body help me about this?
I've try the code below but no user:
$scope.gridOptions = {
i18n: function ($scope, i18nService) {
i18nService.setCurrentLang('zh-cn');
}
}

$scope.gridOptions = {
i18n: "es" // assign language code here
}

Related

CKEditor 5 custom plugin not disabled in read mode

Right now I'm integrating custom plugins into the ckeditor 5. I created and added plugins using the ckeditor 5 documentation.
I also have a custom "super" build (similar to this example) that I use in my web application.
Now my problem is that my plugins will not be disabled in the ckeditor read mode (as showcased in the image at the button). The ckeditor documentation mentions that this should be the "default" behaviour for plugins / buttons.
If someone has an idea where I'm going wrong that'd be greatly appreciated!
Here is a skeleton example of my custom plugin class.
import { Plugin } from 'ckeditor5/src/core';
import { ButtonView } from 'ckeditor5/src/ui';
import ckeditor5Icon from './icons/insertvariable.svg';
export default class HWInsertVariable extends Plugin {
static get pluginName() {
return 'HWInsertVariable';
}
init() {
const that = this;
const editor = this.editor;
const model = editor.model;
let labelTxt = 'Variable einfügen';
editor.ui.componentFactory.add( 'hwInsertVariableButton', locale => {
const view = new ButtonView( locale );
view.set( {
label: labelTxt,
icon: ckeditor5Icon,
tooltip: true,
affectsData: true
} );
this.listenTo( view, 'execute', () => {
model.change( writer => {
that.buttonClicked();
} );
editor.editing.view.focus();
} );
return view;
} );
}
buttonClicked() {
//code
}
}
Im not sure what the correct method to resolve this is, as I also am facing the same. But what I have found so far, is that there might be a hacky way to get around this.
Checkout the docs regarding "disabling commands", "read-only" mode, and notice the CSS class "ck-disabled"
if/when I find a working way, I will try to come back here and post a better solution
Update:
I fixed this for me when I found that I was missing the section of the code in my my_plugin_ui.js where
const command = editor.commands.get('nameOfCommand');
// Execute the command when the button is clicked (executed).
buttonView.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');

Kendo UI custom validation rules not validation properly in MVVM

Here I have a Kendo view model.
$(document).ready(function () {
var viewModel = kendo.observable({
addData : function (e) {
if (val.validate()) {
// this will send data to server if only view is valid.
}
}
});
kendo.bind($("#my-form"), viewModel);
var val = $("#my-form").kendoValidator({
messages : {
my custom messages
},
rules: {
my custom rules
}
}).data("kendoValidator");
});
What happen here, when I try to submit the form it did not validate the form. simply it gets true for val.validate(). Then I remove data("kendoValidator") because this is now not a HTML5 validations. So after remove that it is like this...
var val = $("#my-form").kendoValidator({
messages : {
my custom messages
},
rules: {
my custom rules
}
});
Then I try to submit the form, it refresh the page. Where I have been wrong in this ??
Your setup should work fine. Perhaps it is really matter of validation rules.
By all means you should not remove the
data("kendoValidator")
part, because this is how you get reference to the Validator object.
Have a look at this example I have prepared for your reference. Let me know if you have further questions.
http://dojo.telerik.com/ovUCA

Joomla custom toolbar button message

The standard admin toolbar buttons have the possibility that you can give them a message. For example: a "really delete" message or something...
JToolBarHelper::deleteList('Do you wanna really delete?', 'controller.delete');
Is that also possible for a custom button? In the documentation is no parameter for this. http://docs.joomla.org/JToolBarHelper/custom
Did Joomla have another solution? Show the user a message and after his confirmation... execute my code! Is that possible?
Sorry for my bad english :)
thanks!
Sure it is possible :)
Simply add to your component template view (for example:)
administrator/components/com_yourcomponent/views/your_view/tmpl/default.php
this code:
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'customcontroller.delete')
{
if (confirm(Joomla.JText._('Do you really want to delete these items?'))) {
Joomla.submitform(task);
} else {
return false;
}
}
}
</script>
Just change the task and edit the message and you should be ready to go
Add this code to this url :
administrator/components/com_yourcomponent/views/your_view/tmpl/default.php
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'customcontroller.delete')
{
if (confirm('Do you really want to delete these items?')== true)
{
Joomla.submitform(task);
}
else {
return false;
}
}
else
{
Joomla.submitform(task);
}
}
</script>

ajax loading query in separate div

My problem is: when a user presses a key, a div will be shown with all the users who have a firstname starting with the users input. It's mandatory that I need to select something.
The problem is when user enter an invalid entry instead of selecting it from the showned div. How to validate it
function getDcode(str)
{
document.getElementById("codes").style.display = "block";
if (str.length==0)
{
document.getElementById("codes").innerHTML="";
return;
}
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support XMLHTTP!");
return;
}
var url="<?php print WEB_URL?>load_code/";
url = url + str;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
I believe want to have an auto-complete text field?,
If yes I suggest try jquery auto-complete
http://www.pengoworks.com/workshop/jquery/autocomplete.htm
I am not getting this...
You do want to have manual entry but are allowing the users to press a key?
I am not sure if that is possible to implement.
Here's one solution, using jQuery. Customize to use your own class/regex
Odell, Den. "Chapter 8 - Form
Controls". Pro JavaScript RIA
Techniques: Best Practices,
Performance, and Presentation. Apress.
© 2009. Books24x7.
http://common.books24x7.com/book/id_31169/book.asp
(accessed December 29, 2009)
$(document).ready(function() {
$("form").keypress(function(e) {
switch(e.target.className) {
case "numerical":
if (e.key.match(/[^0-9]/g)) {
e.preventDefault();
}
break;
case "email":
// The following regular expression matches all characters not
// permitted within an email address
if (e.key.match(/[^a-zA-Z0-9#!#$%&'*+-\/=?^_{}~.]+/g)) {
e.preventDefault();
}
break;
}
});
});
edit: modified the above in order to work properly with jQuery's events

jQuery plugin that accepts and returns value using val() method

Does anyone knows how to create a jQuery plugin that will react to the call to val() method?
Here's the scenario:
Take a set of DIVs using jQuery selector and apply a plugin on them (let's say the plugin is called "mytest".
Using the val() method on the same set of DIVs I'd like to set them some properties.
What's the proper way to do this sort of things?
$.fn.example = function(options) {
return this.each(function() {
var edits = $("<input type='text'/><input type='text' />");
$(this).html(edits);
});
}
$(document).ready(function() {
$("#example").example();
$("#example").val("value1 value2");
window.alert($("#example").val());
});
In this case the first edit should have the value "value1" and the second edit the value "value2". And v.v. by calling the "val()" method I'd like to get the string "value1 value2" back.
Best regards,
Matthias
I've realized that by using additional methods and then calling them using
$("...").pluginname("methodname", ..parameters..);
syntax. It works exactly like other plugins so I guess that's the right way to go.
In the case of the example above the code would look like this:
$.widget("ui.example", {
_init: function() {
}
});
$.extend($.ui.example, {
version: "1.7.1",
defaults: {
value: ""
}
});
And then the usage would be:
$("#example").example("option", "value", "value1 value2");
var value = $("#example").example("option", "value");
window.alert(value);

Resources