Modernizer conditional load of polyfill - modernizr

I am using a javascript library that uses CustomEvent that doesnt seem to be fully supported in Android 4.1. So I thought I'd use Modernizer to conditionally load a CustomEvent polyfill in browsers where it is missing.
I went here: https://modernizr.com/download?customevent-dontmin
Selected 'CustomeEvent',
Downloaded the suggested EventListner.js polyfill,
Pressed 'Build' and downloaded the custom Modernizer.
I added to my index.html: <script src="js/modernizr-custom.js"></script>
And added this to my javascript:
Modernizr.load({
test: Modernizr.customevent,
nope: 'EventListener.js'
});
But I get an error: TypeError: Modernizr.load is not a function
Can someone please confirm I've not gone completely off piste here and I'm using modernizer correctly? And do I have to download another script or something to get the Modernizer.load function? (Modernizer seems to have changed since similar questions were asked).

Modernizr.load was removed from Modernizr
Modernizr.load has been deprecated in favor of using yepnope.js directly; from v3.0, yepnope.js must be included in the page in order for Modernizr.load to work: calling .load() will simply pass the arguments on to yepnope(); this will be removed fully in a future release (#1241)

Related

Rxjs with Angular 1.5

I Would like to add Rxjs to my project which is based on Angular 1.5. I install Rxjs by npm i -D rxjs, add to my index.html like this
<script src="../node_modules/rxjs/Rx.js"></script>
Also added rx to my app.module.js file.
Console returned me
Rx.ts:5 Uncaught ReferenceError: require is not defined
at Rx.ts:5
Where it could be a problem ?
You should use one of the UMD bundles in the node_modules/rxjs/bundles directory. For example:
<script src="../node_modules/bundles/Rx.js"></script>
Which contains the unminified source.
The file you have used - node_modules/rxjs/Rx.js - is a CommonJS module, hence the error you received regarding require not being defined. CommonJS modules are not directly usable in script elements.

How to call a Javascript function inside an webview on nativescript?

How to call a Javascript function (and register a callback function to be executed after the method execution from web view is done) inside an webview on nativescript?
First the bad new, nothing is "built" in to do this. This requires you to add some code to communicate back from the webview. In the nativescript-webworkers plugins that I wrote; the way I did it was I used the onJsConfirm function on Android. On iOS I used the userContentControllerDidReceiveScriptMessage callback to communicate back. If you want to develop your own code; just grab a copy of my webworkers plugin and you can see the way to do it.
Now to the good news, is that it appears there is already a plugin called "nativescript-webview-interface" which gives you this facility so you don't have to build all that binding code yourself. It looks like all you need to do is include it and you will have bi-directional communications with your webview on both iOS and Android.
Note; to see if a plugin exists in the NativeScript community; your best bet is to look on http://plugins.nativescript.rocks, that is how I found out about the above listed plugin.

Kendo UI MVC cant find KendoNotification widget?

Similar to a previous post, but this time Im using MVC and the html helper
Using Kendo.MVC ver# 2015.1.318.545
and script ui library 2013.3.1324
#(Html.Kendo().Notification()
.Name("popupNotification")
)
At run time the above results in this code:
<span id="popupNotification"></span><script>
jQuery(function(){jQuery("#popupNotification").kendoNotification({});});
</script>
, in chrome developer tools, I see an error:
Uncaught TypeError: jQuery(...).kendoNotification is not a function
Its strange that I can put in a datepicker in the same spot, but the notification blows chunks.
[ See reply by user Win below - that was the answer ]
Ideally, you want to use all 3 files (CSS and images too) in same version. Otherwise, they will be out of sync.
Kendo.Mvc.dll
kendo.aspnetmvc.min.js
kendo.all.min.js (this might vary if you use individual widget)
FYI: Also make sure that you use Kendo supported jQuery version. New version requires new jQuery version.

Webfont Loader & Google JSAPI Cannot load together?

I'm not sure why, though getting a similar issue.
Trying to load in a font from fonts.com with webfontloader so I can call functions after they're loaded.
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
<script>
WebFont.load({
monotype: {
projectId: 'xxxxxxxxxxxxxxxxxxxx'
},
active: function() {
mainNav();
}
});
But when ever I include it WITH the jsapi
<script src="https://www.google.com/jsapi"></script>
I get the following issue in the console:
Uncaught TypeError: Cannot call method 'hasAttribute' of null
Yet if loaded in separately, they're fine...
Any ideas?
Try using the following url to load the webfonts api:
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.1.2/webfont.js"></script>
Check the following post for more details: https://groups.google.com/forum/#!msg/google-ajax-search-api/dWVzQF_YWCM/Y3-R738wh78J
We no longer support partial version aliases for new versions of
libraries. Any partial version aliases already in place will continue
to be supported and updated. The reason is that URLs like
https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js
which is saying "give me the most recent version of jquery 1.x.x) have
very short cache lifetimes since the most recent version can change at
any time. This is bad for performance. This is also bad for your web
site, in the event that a library makes breaking changes in its APIs
between versions that cause your page to suddenly render differently.
Libraries do not usually make such changes intentionally but pages
sometimes depend on behavior of an unspecified corner case of an API
that may be changed intentionally or inadvertently as the library is
updated.
So we strongly recommend that you specify the complete version string
when referencing libraries hosted on the Google AJAX APIs. You can
always find the most recent version at
https://developers.google.com/speed/libraries/devguide. In this case,
the most recent 1.9.x version is currently 1.9.1 so we suggest using
the URL
https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js
to get a stable version and better caching.
(Also, your example above doesn't have a closing </script> tag. Just want to verify this doesn't exist in your own code).

npp_destroy gets called immediately after npp_new

I am trying to make a NPAPI plugin for chrome on Mac. I have written a basic npapi plugin and a basic manifest.json and background.html to load it. My background.html has a embed tag to fetch the plugin by Mimetype.
Now when I load my unpackaged extension from Chrome and try to debug the c++ code (in xcode4), I found that the functions are getting called in following order:
NP_Initialize
NP_GetEntryPoints
NPP_New
NPP_Destroy
After this when I click on the extension icon, the popup.html should get executed. My popup.html has these lines:
line 1:
var pluginObj = document.getElementById("pluginId");
line 2:
pluginObj.Myfunction();
But on line 1, NP_Getvalue() function doesnt get called and so a "scriptable NPObject" is not instantiated. On line 2, the Chrome JavaScript console says:
Error in event handler for 'undefined': Object #<HTMLEmbedElement> has no method 'Myfunction' TypeError: Object #<HTMLEmbedElement> has no method 'Myfunction'
Why does the NPP_Destroy functions gets called immediately after the NPP_New function?
Have you done drawing and event model negotiation in your plugin? Starting with Chrome 22 for Mac, the long-deprecated QuickDraw and Carbon models are no longer supported, and if your plugin doesn't negotiate modern models, it will be destroyed just after init. See here for example code that does this.
(Yes, it's unfortunate that the default models for 32-bit plugins are the old, deprecated models, but there's no way to change that in the spec due to all the existing plugins that expect the old behavior.)

Resources