What is the replacement of create() in tinymce 6? - tinymce

create() function is used to add a class, subclass or static singleton.
Example :
tinymce.create('tinymce.somepackage.SomeClass', {
SomeClass: function() {
// Class constructor
},
method: function() {
// Some method
}
});
I have used this function to add custom utility functions on my tinymce object, but this is being removed in tinymce 6. I am planning to upgrade to latest version but I am not finding any alternative method to register my functions on tinymce object.

Related

XML View Event Handler Helper

I am trying to use a helper class to invoke a method in xml view as detailed in documentation
https://sapui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe
<Button text="Press Me" press="ZUI5.ZTESTAPP.TestClass.handlePress.call($controller, 'Hello World')"/>
However the object does not get resolved in jQuery.sap.getObject (returns undefined).
Here is the helper class code
sap.ui.define(["sap/ui/base/Object"],
function (Object) {
"use strict";
var o = Object.extend("ZUI5.ZTESTAPP.TestClass", {
constructor: function(){
},
initalize: function(oView){
this._view = oView;
},
handlePress: function(oEvent){
debugger;
//alert('Message Set');
}
});
return o;
});
This feature is not available in version 1.44.x
Based on the documentation it seems to be introduced in version 1.56 only.
Compare the following documentations
1.56.x - Handling Events in XML Views
1.54.x - Handling Events in XML Views

How to override zk.Widget method for only concrete object?

<script type="text/javascript">
function move() {
var pMeter = zk.Widget.$('$curr_met');
// TODO override pMeter method here
}
</script>
<progressmeter id="curr_met" value="0" width="280px" />
I want to override _fixImgWidth for pMeter object. Is it possible ?
This answer is given at ZK forum by cor3000 :
I'm only adding this answer for the future readers.
yes it is possible. Like with any JS object you can override methods
by replacing them. (This is not ZK specific.)
var oldMethod = pMeter._fixImgWidth;
pMeter._fixImgWidth = function(){
// your implementation
// or call original method
oldMethod.apply(this, arguments)
}
However there are some supporting functions in ZK to make this simpler
from both ZUL or java code (see documentation links below):
Override in zul
file
Override using the java API (same
page)
In case you just want to change the animation-speed follow this
example
using the ca:animation-speed client/attribute (7.0.3+):

SAPUI5 - extend a sap.ui.controller implementation

I would like to implement a new controller that would redefine some methods from an existing controller.
Let say I have:
MyForm.controller.js
sap.ui.controller("MyForm", {
showMyName: function() {
alert("MyForm.showMyName");
},
onSearch: function(oEvent) {
// Do something...
},
});
I would like a new MyNewForm controller that would override the method showMyName but would inherit the onSearch method.
Any ideas how this could achieved?
Thanks in advance.
it works like this:
code of the base controller:
sap.ui.core.mvc.Controller.extend("MyForm", {
showMyName: function() {
alert("MyForm.showMyName");
},
//Further functions ....
});
code of the MyNewForm controller using the MyForm as base:
//require the base first
jQuery.sap.require("MyForm");
//extent the base
MyNewForm.extend("MyForm", {
onInit : function() {
this.showMyName(); //alerts
}
})
In this demoapp you see it in action:
https://sapui5.netweaver.ondemand.com/sdk/test-resources/sap/m/demokit/tdg/index.html?responderOn=true
look for util/Controller.js as base class
and for view/Master.Controller.js as usage of the class.
Best Regards
I think it should be:
MyForm.extend("MyNewForm", {
By calling method sap.ui.controller("MyForm", {}),
the "MyForm" controller is not defined and is never available in execution scope.
Where
sap.ui.core.mvc.Controller.extend("MyForm", {}) defines function and referred by "MyForm", and has extend defined on it.

Possible bug with GWT gwtquery .live() method

I'm trying to do the following:
I want to add a specific handler for some links, denoted by a class.
$("a.link_list").live("click", new ListLinkHandler());
I need .live() instead of .bind() because new such links will be generated. (I know jQuery's .live() is deprecated in favor of .on(), but gwt-query doesn't have a .on() yet.)
I defined the handler like this (just as the gwtquery example does):
public class ListLinkHandler extends Function {
#Override
public boolean f(Event e) { [...] }
}
However, the handler method is never called when I click the links.
I can see the event listener in Chrome Dev Tools: http://screencloud.net/v/bV5V. I think it's on the body because it's a .live().
I tried using .bind() and it worked fine. The body event listener changed in a a.link_list and the handler does what it's supposed to do, but (as documented, I didn't test) not for newly created links.
I filed a bug for the .live() method, but maybe I'm doing something wrong.
Also, I have no idea how to do it without gwtquery, GWT doesn't seem to have a method for selecting elements by class, neither to continually add the listener to new elements.
It seems you are doing something wrong, but I need more code to be sure. Could you send the complete onModuleLoad code which demonstrates this wrong behavior?
I have written a quick example using live, and it works either when adding new gwt widgets or dom elements with gquery, in both Chrome and FF
public void onModuleLoad() {
$("a.link_list").live("click", new ListLinkHandler());
// Add a new link via gquery
$("<a class='link_list' href=javascript:alert('href') onClick=alert('onClick')>Click </a>").appendTo(document);
// Add a new link via gwt widgets
Anchor a = new Anchor("click");
a.setStyleName("link_list");
a.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Window.alert("clickHandler");
}
});
RootPanel.get().add(a);
}
public class ListLinkHandler extends Function {
#Override
public boolean f(Event e) {
Window.alert("live");
return true;
}
}

What to use instead of `toggle(...)` in jQuery > 1.8?

Now that toggle(...) was deprecated in jQuery 1.8 and then removed in jQuery 1.9
What could be used in general (aside from using the jQuery migrate script) instead of toggle(fn, fn2); thats has the same type of functionality?
Related question (asked about a specific case): What to use instead toggle?
I know that toggle() functionality was not removed, just the ability to add custom toggle functions (aside from the show/hide default functionality).
Here is a simple implementation:
$.fn.toggleClick = function() {
var methods = arguments; // Store the passed arguments for future reference
var count = methods.length; // Cache the number of methods
// Use return this to maintain jQuery chainability
// For each element you bind to
return this.each(function(i, item){
// Create a local counter for that element
var index = 0;
// Bind a click handler to that element
$(item).on('click', function() {
// That when called will apply the 'index'th method to that element
// the index % count means that we constrain our iterator between 0
// and (count-1)
return methods[index++ % count].apply(this, arguments);
});
});
};
and use it as
$('selector').toggleClick( function1, function2, ... );