From 53caebc6cc9b28e628cba26248c79cd08a83901f Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 1 Aug 2017 15:47:22 +0800 Subject: [PATCH] add --- Gruntfile.js | 1 - bi/core.js | 61 +----------------------------------------------- docs/core.js | 61 +----------------------------------------------- src/core/load.js | 60 ----------------------------------------------- 4 files changed, 2 insertions(+), 181 deletions(-) delete mode 100644 src/core/load.js diff --git a/Gruntfile.js b/Gruntfile.js index 0cdf1d2cb..1f1f46d42 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -127,7 +127,6 @@ module.exports = function (grunt) { 'src/core/shortcut.js', 'src/core/plugin.js', 'src/core/controller.js', - 'src/core/load.js', 'src/core/proto/**/*.js', 'src/core/utils/**/*.js', 'src/core/behavior/behavior.js', diff --git a/bi/core.js b/bi/core.js index 191ff2377..e4b54a49a 100644 --- a/bi/core.js +++ b/bi/core.js @@ -5926,66 +5926,7 @@ BI.Controller = BI.inherit(BI.OB, { } }); -BI.Controller.EVENT_CHANGE = "__EVENT_CHANGE__";$.extend(BI, { - $defaultImport: function () { - var ars = arguments; - if (ars[0] != null) { - ars[0] = BI.servletURL + '?op=resource&resource=' + ars[0]; - } - this.$import.apply(null, ars); - }, - - $import: function () { - var _LOADED = {}; // alex:保存加载过的 - function loadReady(src, must) { - var $scripts = $("head script"); - $.each($scripts, function (i, item) { - if (item.src.indexOf(src) != -1) { - _LOADED[src] = true; - } - }); - var $links = $("head link"); - $.each($links, function (i, item) { - if (item.href.indexOf(src) != -1 && must) { - _LOADED[src] = false; - $(item).remove(); - } - }); - } - - // must=true 强行加载 - return function (src, ext, must) { - loadReady(src, must); - // alex:如果已经加载过了的,直接return - if (_LOADED[src] === true) return; - if (ext === 'css') { - var link = document.createElement('link'); - link.rel = 'stylesheet' - link.type = 'text/css'; - link.href = src; - var head = document.getElementsByTagName('head')[0]; - head.appendChild(link); - _LOADED[src] = true; - } else { - // alex:这里用同步调用的方式,必须等待ajax完成 - $.ajax({ - url: src, - dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情 - async: false, - complete: function (res, status) { - /* - * alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval - * 所以当status为success时就不需要再把其中的内容加到script里面去了 - */ - if (status == 'success') { - _LOADED[src] = true; - } - } - }) - } - } - }() -});/** +BI.Controller.EVENT_CHANGE = "__EVENT_CHANGE__";/** * 对数组对象的扩展 * @class Array */ diff --git a/docs/core.js b/docs/core.js index 672f7330b..6fe5dd752 100644 --- a/docs/core.js +++ b/docs/core.js @@ -23074,66 +23074,7 @@ BI.ShowListener = BI.inherit(BI.OB, { }) } }); -BI.ShowListener.EVENT_CHANGE = "ShowListener.EVENT_CHANGE";$.extend(BI, { - $defaultImport: function () { - var ars = arguments; - if (ars[0] != null) { - ars[0] = BI.servletURL + '?op=resource&resource=' + ars[0]; - } - this.$import.apply(null, ars); - }, - - $import: function () { - var _LOADED = {}; // alex:保存加载过的 - function loadReady(src, must) { - var $scripts = $("head script"); - $.each($scripts, function (i, item) { - if (item.src.indexOf(src) != -1) { - _LOADED[src] = true; - } - }); - var $links = $("head link"); - $.each($links, function (i, item) { - if (item.href.indexOf(src) != -1 && must) { - _LOADED[src] = false; - $(item).remove(); - } - }); - } - - // must=true 强行加载 - return function (src, ext, must) { - loadReady(src, must); - // alex:如果已经加载过了的,直接return - if (_LOADED[src] === true) return; - if (ext === 'css') { - var link = document.createElement('link'); - link.rel = 'stylesheet' - link.type = 'text/css'; - link.href = src; - var head = document.getElementsByTagName('head')[0]; - head.appendChild(link); - _LOADED[src] = true; - } else { - // alex:这里用同步调用的方式,必须等待ajax完成 - $.ajax({ - url: src, - dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情 - async: false, - complete: function (res, status) { - /* - * alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval - * 所以当status为success时就不需要再把其中的内容加到script里面去了 - */ - if (status == 'success') { - _LOADED[src] = true; - } - } - }) - } - } - }() -});/** +BI.ShowListener.EVENT_CHANGE = "ShowListener.EVENT_CHANGE";/** * style加载管理器 * * Created by GUY on 2015/9/7. diff --git a/src/core/load.js b/src/core/load.js deleted file mode 100644 index ae62faa72..000000000 --- a/src/core/load.js +++ /dev/null @@ -1,60 +0,0 @@ -$.extend(BI, { - $defaultImport: function () { - var ars = arguments; - if (ars[0] != null) { - ars[0] = BI.servletURL + '?op=resource&resource=' + ars[0]; - } - this.$import.apply(null, ars); - }, - - $import: function () { - var _LOADED = {}; // alex:保存加载过的 - function loadReady(src, must) { - var $scripts = $("head script"); - $.each($scripts, function (i, item) { - if (item.src.indexOf(src) != -1) { - _LOADED[src] = true; - } - }); - var $links = $("head link"); - $.each($links, function (i, item) { - if (item.href.indexOf(src) != -1 && must) { - _LOADED[src] = false; - $(item).remove(); - } - }); - } - - // must=true 强行加载 - return function (src, ext, must) { - loadReady(src, must); - // alex:如果已经加载过了的,直接return - if (_LOADED[src] === true) return; - if (ext === 'css') { - var link = document.createElement('link'); - link.rel = 'stylesheet' - link.type = 'text/css'; - link.href = src; - var head = document.getElementsByTagName('head')[0]; - head.appendChild(link); - _LOADED[src] = true; - } else { - // alex:这里用同步调用的方式,必须等待ajax完成 - $.ajax({ - url: src, - dataType: "script", // alex:指定dataType为script,jquery会帮忙做globalEval的事情 - async: false, - complete: function (res, status) { - /* - * alex:发现jquery会很智能地判断一下返回的数据类型是不是script,然后做一个globalEval - * 所以当status为success时就不需要再把其中的内容加到script里面去了 - */ - if (status == 'success') { - _LOADED[src] = true; - } - } - }) - } - } - }() -}); \ No newline at end of file