diff --git a/app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js b/app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js index 8e50990..f4de057 100644 --- a/app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js +++ b/app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js @@ -5856,7 +5856,9 @@ var Editor_Editor = /*#__PURE__*/function () { value: function beforeCommand() { this.context.triggerEvent('before.command', this.$editable.html()); // Set styleWithCSS before run a command - document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution + try { + document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution + } catch (e) {} this.focus(); } diff --git a/app/index.js b/app/index.js index 9f92da5..92c3596 100644 --- a/app/index.js +++ b/app/index.js @@ -79,29 +79,29 @@ Router.add('/test', function(render) { // nodepad Router.add('/notepad', function(render) { // load resources - Browser.addResources([ - { - type: "javascript", - url: "app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js" - }, - { - type: "stylesheet", - url: "app/assets/mixed/summernote-0.8.18-dist/summernote-lite.css" - } - ]); + Browser.addStylesheet("app/assets/mixed/summernote-0.8.18-dist/summernote-lite.css"); + Browser.waitUntil(function(test, ttl) { + Browser.addScript("app/assets/mixed/summernote-0.8.18-dist/summernote-lite.js", function(el) { + // set DOM id + var target_dom_id = "summernote"; - // set DOM id - var target_dom_id = "summernote"; + // load HTML + render("app/notepad.html", { + "target_dom_id": target_dom_id + }); - // load HTML - render("app/notepad.html", { - "target_dom_id": target_dom_id + // load Summernote (wysiwyg editor) + $('#' + target_dom_id).summernote({ + minHeight: 300 + }); + + }, test, ttl); + }, function(el) { + alert(typeof $.summernote); + return $.summernote; }); - // load Summernote (wysiwyg editor) - $('#' + target_dom_id).summernote({ - minHeight: 300 - }); + document.getElementById("useragent").innerHTML = window.navigator.userAgent; }); // go diff --git a/app/notepad.html b/app/notepad.html index 118a3ed..b00a97f 100644 --- a/app/notepad.html +++ b/app/notepad.html @@ -8,5 +8,18 @@ + +
+
+
User Agent
+
+
+
+ +
+
+
+
+
diff --git a/lib/browser.js b/lib/browser.js index cb8447c..4b0b111 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -128,7 +128,7 @@ function getIEVersion() { }; //////////////////////////////////////////////////////////////////////// -// exports.waitUntil() +// waitUntil() //////////////////////////////////////////////////////////////////////// function waitUntil(f, test, ttl) { if (typeof f !== "function") return; @@ -177,34 +177,26 @@ function addScript(url, callback, test, ttl) { return el; }; -//////////////////////////////////////////////////////////////////////// -// addResources() -//////////////////////////////////////////////////////////////////////// -function addResources(resources, callback) { - resources.forEach(function(resource) { - if (["javascript", "text/javascript"].indexOf(resource.type) > -1) { - addScript(resource.url, callback); - } else if (["stylesheet", "text/css"].indexOf(resource.type) > -1) { - addStylesheet(resource.url, callback); - } else { - console.warn("Not supported resource type"); - } - }); -}; - //////////////////////////////////////////////////////////////////////// // addStylesheet() //////////////////////////////////////////////////////////////////////// -function addStylesheet(url, callback) { +function addStylesheet(url, callback, test, ttl) { + if (typeof test !== "function") { + test = function(el, callback, ttl) {}; + } + var ttl = (typeof ttl === "number" ? ttl : 30000); // TTL(Time-To-Live) + var el = document.createElement("link"); el.href = url; el.rel = "stylesheet"; el.type = "text/css"; el.media = "screen, projection"; document.head.appendChild(el); - if (typeof(callback) === "function") { - el.onload = callback(el); + + if (typeof test === "function") { + test(el, callback, ttl); } + return el; }; @@ -274,14 +266,13 @@ function close() { exports.getIEVersion = getIEVersion; exports.waitUntil = waitUntil; exports.addScript = addScript; -exports.addResources = addResources; exports.addStylesheet = addStylesheet; exports.setContent = setContent; exports.start = start; exports.reload = reload; exports.close = close; -exports.VERSIONINFO = "Browser Library (browser.js) version 0.1.3"; +exports.VERSIONINFO = "Browser Library (browser.js) version 0.1.4"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;