Skip to content

Commit

Permalink
Output friendly error message when Microplugin is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
joallard authored and ss-agent-marine-scotland committed Oct 4, 2016
1 parent b540988 commit caa19d4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Output friendly error message when Microplguin is missing (#1137).
Special thanks to @styxxx for proposing the improvement.

*Jonathan Allard* (@joallard)

* Fix open keyboard bug under iOS after closing selection (#1127)

*@zeitiger*
Expand Down
13 changes: 12 additions & 1 deletion src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,18 @@ var Selectize = function($input, settings) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

MicroEvent.mixin(Selectize);
MicroPlugin.mixin(Selectize);

if(typeof MicroPlugin !== "undefined"){
MicroPlugin.mixin(Selectize);
}else{
logError("Dependency MicroPlugin is missing",
{explanation:
"Make sure you either: (1) are using the \"standalone\" "+
"version of Selectize, or (2) require MicroPlugin before you "+
"load Selectize."}
);
}


// methods
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
14 changes: 14 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,17 @@ var domToString = function(d) {

return tmp.innerHTML;
};

var logError = function(message, options){
if(!options) options = {};
var component = "Selectize";

console.error(component + ": " + message)

if(options.explanation){
// console.group is undefined in <IE11
if(console.group) console.group();
console.error(options.explanation);
if(console.group) console.groupEnd();
}
}

0 comments on commit caa19d4

Please sign in to comment.