Skip to content

Commit

Permalink
release to 0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
caijf committed Sep 14, 2017
1 parent a237f9f commit a45ac45
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.4.5 (2017-09-14)
--------------------------------------------------------
- 功能支持
* util/ajax/tag 模块增加 _$loadTemplate 接口需要跨域载入的时候采用 ajax 先加载文本再解析内容

- 功能变化
* util/ajax/tag 模块 _$loadHtml 接口回退不支持跨域载入

0.4.4 (2017-09-12)
--------------------------------------------------------
- 功能支持
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nej",
"version": "0.4.4",
"version": "0.4.5",
"homepage": "https://github.com/genify/nej",
"authors": [
"genify <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nej-framework",
"description": "JavaScript Cross-Platform Framework",
"version": "0.4.4",
"version": "0.4.5",
"license": "MIT",
"keywords": [
"nej",
Expand Down
6 changes: 3 additions & 3 deletions src/util/ajax/demo/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
'../tag.js'
],function(_j){

_j._$loadHtml('./b.html',{
_j._$loadTemplate('./b.html',{
onload:function(result){
console.log('same domain');
console.log(result);
}
});

_j._$loadHtml('http://localhost:8080/nej/src/util/ajax/demo/b.html',{
_j._$loadTemplate('http://localhost:8080/nej/src/util/ajax/demo/b.html',{
onload: function(result){
console.log('same domain');
console.log(result);
}
});

_j._$loadHtml('http://a.b.com:8080/nej/src/util/ajax/demo/b.html',{
_j._$loadTemplate('http://a.b.com:8080/nej/src/util/ajax/demo/b.html',{
onload: function(result){
console.log('cross domain');
console.log(result);
Expand Down
32 changes: 31 additions & 1 deletion src/util/ajax/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,40 @@ NEJ.define([
* @return {Void}
*/
_p._$loadHtml = function(_url,_options){
_t1._$$LoaderHtml._$allocate(_options)._$load(_url);
};
/**
* 载入NEJ模板文件
*
* 脚本举例
* ```javascript
* NEJ.define([
* 'util/ajax/tag'
* ],function(_j){
* _j._$loadTemplate('http://123.163.com/a.html',{
* onload:function(){
* // 载入成功的回调方法
* },
* onerror:function(_error){
* // 异常回调方法
* }
* });
* });
* ```
*
* @method module:util/ajax/tag._$loadTemplate
* @param {String} arg0 - 文件地址
* @param {Object} arg1 - 可选配置参数
* @property {String} version - 版本信息
* @property {module:util/ajax/tag.onload} onload - 载入回调
* @property {module:util/ajax/tag.onerror} onerror - 异常回调
* @return {Void}
*/
_p._$loadTemplate = function(_url,_options){
var org1 = u._$url2origin(_url),
org2 = u._$url2origin(location.href);
if (!org1||org1==org2){
_t1._$$LoaderHtml._$allocate(_options)._$load(_url);
_p._$loadHtml(_url, _options);
}else{
var callback = _options.onload;
_options.onload = function(event){
Expand Down
2 changes: 1 addition & 1 deletion src/util/dispatcher/dsp/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ NEJ.define([
ret = _doParseModuleURL(
_module, _config
);
_j._$loadHtml(ret.url,{
_j._$loadTemplate(ret.url,{
version:ret.version,
onload:_t1._$parseTemplate
});
Expand Down
2 changes: 1 addition & 1 deletion src/util/template/tpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ NEJ.define([
onload:_onAddHtml
};
window.setTimeout(
_j0._$loadHtml._$bind(
_j0._$loadTemplate._$bind(
_j0,_src,_options
),0
);
Expand Down

0 comments on commit a45ac45

Please sign in to comment.