Last active
August 29, 2015 13:58
-
-
Save leeight/9948109 to your computer and use it in GitHub Desktop.
app/ecom/dsp/trunk/dsp-web/dsp-static
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.gitignore b/.gitignore | |
new file mode 100644 | |
index 0000000..53752db | |
--- /dev/null | |
+++ b/.gitignore | |
@@ -0,0 +1 @@ | |
+output | |
diff --git a/assets/css/dsp.css b/assets/css/dsp.css | |
index fa7f7d0..6ca40f6 100644 | |
--- a/assets/css/dsp.css | |
+++ b/assets/css/dsp.css | |
@@ -1,73 +1,127 @@ | |
-@import '../../src/css/base.css'; | |
-@import '../../src/css/dsp.css'; | |
-@import '../../src/css/dsp-common.css'; | |
-@import '../../src/css/dsp-detail.css'; | |
-@import '../../src/css/dsp-edit.css'; | |
-@import '../../src/css/dsp-list.css'; | |
-@import '../../src/css/dsp-report.css'; | |
-@import '../../src/css/dsp-layout.css'; | |
-@import '../../src/css/dsp-client.css'; | |
-@import '../../src/css/dsp-people-homePage.css'; | |
-@import '../../src/css/dsp-account.css'; | |
-@import '../../src/css/dsp-order.css'; | |
-@import '../../src/css/dsp-adowner.css'; | |
-@import '../../src/css/dsp-group.css'; | |
-@import '../../src/css/dsp-printscreen.css'; | |
-@import '../../src/css/dsp-peopleTool.css'; | |
-@import '../../src/css/dsp-researchTool.css'; | |
-@import '../../src/css/dsp-historyTool.css'; | |
-@import '../../src/css/dsp-adliveTool.css'; | |
-@import '../../src/css/dsp-resource.css'; | |
-@import '../../src/css/dsp-help.css'; | |
- | |
- | |
- | |
- | |
-@import '../../src/css/ui-formfolder.css'; | |
-@import '../../src/css/ui-label.css'; | |
-@import '../../src/css/ui-link.css'; | |
-@import '../../src/css/ui-mcal.css'; | |
-@import '../../src/css/ui-month.css'; | |
-@import '../../src/css/ui-orient.css'; | |
-@import '../../src/css/ui-pageinfo.css'; | |
-@import '../../src/css/ui-richsel.css'; | |
-@import '../../src/css/ui-star.css'; | |
-@import '../../src/css/ui-summaryinfo.css'; | |
-@import '../../src/css/ui-tooltip.css'; | |
-@import '../../src/css/ui-urlmaker.css'; | |
-@import '../../src/css/ui-treeview.css'; | |
-@import '../../src/css/ui-sidebar.css'; | |
-@import '../../src/css/ui-region.css'; | |
-@import '../../src/css/ui-schedule.css'; | |
-@import '../../src/css/ui-tab.css'; | |
-@import '../../src/css/ui-togglebutton.css'; | |
-@import '../../src/css/ui-selectedlist.css'; | |
-@import '../../src/css/ui-rcal.css'; | |
-@import '../../src/css/ui-selector.css'; | |
-@import '../../src/css/ui-dynamictreeview.css'; | |
-@import '../../src/css/ui-searchtree.css'; | |
-@import '../../src/css/ui-textline.css'; | |
-@import '../../src/css/ui-contentlist.css'; | |
-@import '../../src/css/ui-itemgroup.css'; | |
-@import '../../src/css/ui-previewtpl.css'; | |
-@import '../../src/css/ui-period.css'; | |
-@import '../../src/css/ui-editor.css'; | |
-@import '../../src/css/ui-rbgroup.css'; | |
-@import '../../src/css/ui-draggableschedule.css'; | |
-@import '../../src/css/ui-crumb.css'; | |
-@import '../../src/css/ui-doubleSelColumnlist.css'; | |
-@import '../../src/css/ui-multiColumnTable.css'; | |
-@import '../../src/css/ui-vtModule.css'; | |
-@import '../../src/css/ui-multiinput.css'; | |
-@import '../../src/css/ui-itemselector.css'; | |
-@import '../../src/css/ui-sitecreate.css'; | |
-@import '../../src/css/ui-draggableschedule.css'; | |
-@import '../../src/css/ui-reportsubmenu.css'; | |
-@import '../../src/css/ui-toolbar.css'; | |
-@import '../../src/css/ui-slidebutton.css'; | |
-@import '../../src/css/ui-orientinput.css'; | |
-@import '../../src/css/ui-toolbar.css'; | |
-@import '../../src/css/ui-slidebutton.css'; | |
+@import '../../src/css/base.css'; | |
+@import '../../src/css/dsp.css'; | |
+@import '../../src/css/dsp-common.css'; | |
+@import '../../src/css/dsp-detail.css'; | |
+@import '../../src/css/dsp-edit.css'; | |
+@import '../../src/css/dsp-list.css'; | |
+@import '../../src/css/dsp-report.css'; | |
+@import '../../src/css/dsp-layout.css'; | |
+@import '../../src/css/dsp-client.css'; | |
+@import '../../src/css/dsp-people-homePage.css'; | |
+@import '../../src/css/dsp-account.css'; | |
+@import '../../src/css/dsp-order.css'; | |
+@import '../../src/css/dsp-adowner.css'; | |
+@import '../../src/css/dsp-group.css'; | |
+@import '../../src/css/dsp-printscreen.css'; | |
+@import '../../src/css/dsp-peopleTool.css'; | |
+@import '../../src/css/dsp-researchTool.css'; | |
+@import '../../src/css/dsp-historyTool.css'; | |
+@import '../../src/css/dsp-adliveTool.css'; | |
+@import '../../src/css/dsp-resource.css'; | |
+@import '../../src/css/dsp-help.css'; | |
+ | |
+ | |
+ | |
+ | |
+@import '../../src/css/ui-accordion.css'; | |
+@import '../../src/css/ui-areapicker.css'; | |
+@import '../../src/css/ui-button.css'; | |
+@import '../../src/css/ui-buttonmenu.css'; | |
+@import '../../src/css/ui-cal.css'; | |
+@import '../../src/css/ui-checkbox.css'; | |
+@import '../../src/css/ui-colorPalette.css'; | |
+@import '../../src/css/ui-columnList.css'; | |
+@import '../../src/css/ui-combobox.css'; | |
+@import '../../src/css/ui-combosearchlistselect.css'; | |
+@import '../../src/css/ui-contentlist.css'; | |
+@import '../../src/css/ui-copyarea.css'; | |
+@import '../../src/css/ui-crepeater.css'; | |
+@import '../../src/css/ui-crowdinfo.css'; | |
+@import '../../src/css/ui-crumb.css'; | |
+@import '../../src/css/ui-customList.css'; | |
+@import '../../src/css/ui-doubleSearchColumnlist.css'; | |
+@import '../../src/css/ui-doubleSelColumnlist.css'; | |
+@import '../../src/css/ui-doublecomplexselector.css'; | |
+@import '../../src/css/ui-draggableschedule.css'; | |
+@import '../../src/css/ui-drcal.css'; | |
+@import '../../src/css/ui-dynamictreeview.css'; | |
+@import '../../src/css/ui-editor.css'; | |
+@import '../../src/css/ui-extremum.css'; | |
+@import '../../src/css/ui-fcal.css'; | |
+@import '../../src/css/ui-formfolder.css'; | |
+@import '../../src/css/ui-industrypicker.css'; | |
+@import '../../src/css/ui-interest-compose.css'; | |
+@import '../../src/css/ui-interest-custom.css'; | |
+@import '../../src/css/ui-interest-select.css'; | |
+@import '../../src/css/ui-item-del.css'; | |
+@import '../../src/css/ui-item-select.css'; | |
+@import '../../src/css/ui-itemgroup.css'; | |
+@import '../../src/css/ui-itemselector.css'; | |
+@import '../../src/css/ui-krcreate.css'; | |
+@import '../../src/css/ui-ktCreate.css'; | |
+@import '../../src/css/ui-label.css'; | |
+@import '../../src/css/ui-link.css'; | |
+@import '../../src/css/ui-mask.css'; | |
+@import '../../src/css/ui-mcal.css'; | |
+@import '../../src/css/ui-mmcal.css'; | |
+@import '../../src/css/ui-modframe.css'; | |
+@import '../../src/css/ui-month.css'; | |
+@import '../../src/css/ui-multiColumnTable.css'; | |
+@import '../../src/css/ui-multiinput.css'; | |
+@import '../../src/css/ui-orient.css'; | |
+@import '../../src/css/ui-orientinput.css'; | |
+@import '../../src/css/ui-pageinfo.css'; | |
+@import '../../src/css/ui-pager.css'; | |
+@import '../../src/css/ui-pager1.css'; | |
+@import '../../src/css/ui-period.css'; | |
+@import '../../src/css/ui-previewtpl.css'; | |
+@import '../../src/css/ui-rbgroup.css'; | |
+@import '../../src/css/ui-rcal.css'; | |
+@import '../../src/css/ui-region.css'; | |
+@import '../../src/css/ui-reportsubmenu.css'; | |
@import '../../src/css/ui-resourceestimateitem.css'; | |
-@import '../../src/css/skin-white-mcal.css'; | |
- | |
+@import '../../src/css/ui-richsel.css'; | |
+@import '../../src/css/ui-schedule.css'; | |
+@import '../../src/css/ui-searchinfo.css'; | |
+@import '../../src/css/ui-searchinput.css'; | |
+@import '../../src/css/ui-searchtree.css'; | |
+@import '../../src/css/ui-select.css'; | |
+@import '../../src/css/ui-selectedlist.css'; | |
+@import '../../src/css/ui-selector.css'; | |
+@import '../../src/css/ui-sidebar.css'; | |
+@import '../../src/css/ui-sitecreate.css'; | |
+@import '../../src/css/ui-slidebutton.css'; | |
+@import '../../src/css/ui-star.css'; | |
+@import '../../src/css/ui-staticInterest.css'; | |
+@import '../../src/css/ui-summaryinfo.css'; | |
+@import '../../src/css/ui-tab.css'; | |
+@import '../../src/css/ui-table.css'; | |
+@import '../../src/css/ui-textinput.css'; | |
+@import '../../src/css/ui-textline.css'; | |
+@import '../../src/css/ui-tip.css'; | |
+@import '../../src/css/ui-togglebutton.css'; | |
+@import '../../src/css/ui-toolbar.css'; | |
+@import '../../src/css/ui-tooltip.css'; | |
+@import '../../src/css/ui-treeview.css'; | |
+@import '../../src/css/ui-uploader.css'; | |
+@import '../../src/css/ui-urlmaker.css'; | |
+@import '../../src/css/ui-vtModule.css'; | |
+ | |
+@import '../../src/ui/css/ui-adselector.css'; | |
+@import '../../src/ui/css/ui-checkboxGroupWrap.css'; | |
+@import '../../src/ui/css/ui-creativity.css'; | |
+@import '../../src/ui/css/ui-creativitylist.css'; | |
+@import '../../src/ui/css/ui-creativitypreview.css'; | |
+@import '../../src/ui/css/ui-dbitemselect.css'; | |
+@import '../../src/ui/css/ui-dialog.css'; | |
+@import '../../src/ui/css/ui-editableinput.css'; | |
+@import '../../src/ui/css/ui-editablelabel.css'; | |
+@import '../../src/ui/css/ui-filterbuttongroup.css'; | |
+@import '../../src/ui/css/ui-multiuploader.css'; | |
+@import '../../src/ui/css/ui-processbar.css'; | |
+@import '../../src/ui/css/ui-progress-bar.css'; | |
+@import '../../src/ui/css/ui-radiopanel-boxgroup.css'; | |
+@import '../../src/ui/css/ui-selected-right.css'; | |
+@import '../../src/ui/css/ui-tree-select.css'; | |
+ | |
+@import '../../src/css/skin-white-mcal.css'; | |
diff --git a/edp-build-config.js b/edp-build-config.js | |
index e5d24f8..0251d75 100644 | |
--- a/edp-build-config.js | |
+++ b/edp-build-config.js | |
@@ -3,187 +3,77 @@ exports.input = __dirname; | |
var path = require( 'path' ); | |
exports.output = path.resolve( __dirname, 'output' ); | |
-var moduleEntries = 'html,htm,phtml,tpl,vm,js'; | |
-var pageEntries = 'html,htm,phtml,tpl,vm'; | |
-var fs = require( 'fs' ); | |
-var eol = require('os').EOL; | |
-var excludeUI = [ | |
- "SimpleSelector", | |
- "SiteSelect", | |
- "StatusButton", | |
- "SummaryInfo", | |
- "Support", | |
- "Tracer", | |
- "VideoUploader", | |
- "Accordion", | |
- "BatchUploader", | |
- "BoxGroup", | |
- "BreadCrumb", | |
- "ButtonMenu", | |
- "ColorPalette", | |
- "ColumnList", | |
- "ContentList", | |
- "CopyableArea", | |
- "ColorPicker", | |
- "Crumb", | |
- "ctkrTableConfig", | |
- "Dialog.Interest", | |
- "DynamicTreeView", | |
- "FileListUploader", | |
- "FormFolder", | |
- "FormSwitch", | |
- "FormTab", | |
- "ItemGroup", | |
- "ItemSelectTable", | |
- "KeywordTip", | |
- "KtCreate", | |
- "LiGroup", | |
- "List", | |
- "ListInfoShort", | |
- "ListView", | |
- "MaterialUploader", | |
- "MediaUploader", | |
- "MultiCalendarWithMini", | |
- "Orientation", | |
- "OrientInput", | |
- "PagableListWithBorderPager", | |
- "Period", | |
- "PreviewTemplate", | |
- "Repeater", | |
- "ReportCalendar", | |
- "ReportCalendarForClient", | |
- "ReportSubmenu", | |
- "ResourceEstimateItem", | |
- "RichSelector", | |
- "Schedule" | |
-]; | |
-var bizModules = []; | |
-var uiModules = []; | |
- | |
-function traverseDir( dir, folderName, excludeList, arr ) { | |
- var files = fs.readdirSync( dir ); | |
- | |
- files.forEach( function ( file ) { | |
- if ( file === '.svn' || file === '.git' ) { | |
- return; | |
- } | |
- | |
- file = path.resolve( dir, file ); | |
- var stat = fs.statSync( file ); | |
- | |
- if ( stat.isDirectory() ) { | |
- traverseDir( file, folderName + '/' + path.basename(file), excludeList, arr ); | |
- } | |
- else { | |
- if (path.extname( file ).slice( 1 ) === 'js') { | |
- var baseName = path.basename(file, '.js'); | |
- if (excludeList && excludeList.indexOf(baseName) > -1) { | |
- return; | |
- } | |
- arr.push(folderName + '/' + baseName); | |
- } | |
- } | |
- }); | |
-} | |
- | |
-traverseDir( path.resolve( __dirname, 'src/biz' ) , 'biz', null, bizModules); | |
-traverseDir( path.resolve( __dirname, 'src/ui' ) , 'ui', excludeUI, uiModules); | |
-var toISOString = function(d) { | |
- function pad(number) { | |
- if ( number < 10 ) { | |
- return '0' + number; | |
- } | |
- return number; | |
- } | |
- return d.getUTCFullYear() + | |
- '' + pad( d.getUTCMonth() + 1 ) + | |
- '' + pad( d.getUTCDate() ) + | |
- 'T' + pad( d.getUTCHours() ) + | |
- '' + pad( d.getUTCMinutes() ) + | |
- '' + pad( d.getUTCSeconds() ) + | |
- 'Z'; | |
-}; | |
-var version = 'v' + toISOString(new Date()); | |
-var versionFolder = 'assets/' + version; | |
- | |
+var build = require( './tool/build' ); | |
+var buildVersion = build.getBuildVersion(); | |
+var versionFolder = 'assets-' + buildVersion; | |
exports.getProcessors = function () { | |
-PathMapper.prototype.replacers['regex'] = function (valueReplacer, data, file) { | |
- return data.replace(/assets\//g, versionFolder + '/'); | |
-}; | |
return [ | |
+ new LessCompiler({ | |
+ files: [ | |
+ 'src/css/dsp.less' | |
+ ], | |
+ pageFiles: [ | |
+ 'main.html' | |
+ ] | |
+ }), | |
+ new CssCompressor({ | |
+ files: [ | |
+ 'assets/css/dsp.css' | |
+ ] | |
+ }), | |
new ModuleCompiler( { | |
- configFile: 'module.conf', | |
- entryExtnames: 'js', | |
- exclude: [ | |
- 'zrender-echarts.js', | |
- 'entry.js', | |
- 'esl.js', | |
- 'login.js', | |
- 'tangram-base-1.3.7.1.js', | |
- 'jquery.js', | |
- 'jquery-placeholder.js', | |
- 'lessc.js' | |
+ files: [ | |
+ '*.js', | |
+ '!src/error/**', | |
+ '!src/common/esl.js', | |
+ '!src/dsp/editInfo.js', | |
+ '!src/dsp/lang.js', | |
+ '!src/dsp/dsp.js', | |
+ '!src/entry.js', | |
+ '!src/other/*.js' | |
], | |
- getCombineConfig: function (combineCfg) { | |
- combineCfg["assets/js/biz"].include = bizModules; | |
- combineCfg["assets/js/base-er"].include = combineCfg["assets/js/base-er"].include.concat(uiModules); | |
- return combineCfg; | |
- } | |
+ getCombineConfig: build.getCombineConfig | |
} ), | |
+ new TplMerge({ | |
+ files: [ | |
+ 'src/**/*.js', | |
+ '!src/error/**', | |
+ '!src/common/esl.js', | |
+ '!src/dsp/editInfo.js', | |
+ '!src/dsp/lang.js', | |
+ '!src/dsp/dsp.js', | |
+ '!src/entry.js', | |
+ '!src/other/*.js' | |
+ ] | |
+ }), | |
+ /* | |
new JsCompressor( { | |
- isExclude: function (file) { | |
- var fileName = path.basename(file.fullPath); | |
- if (file.extname !== 'js'|| | |
- fileName === 'zrender-echarts.js' || | |
- fileName === 'tangram-base-1.3.7.1.js' || | |
- fileName === 'lessc.js') { | |
- return true; | |
- } | |
- }, | |
- sourceMapOptions: { | |
- enable: true | |
- }, | |
- compressOptions: { | |
- global_defs: { | |
- DEBUG: false | |
- } | |
+ compressOptions: { | |
+ global_defs: { | |
+ DEBUG: false | |
} | |
} | |
- ), | |
+ }), | |
+ */ | |
new PathMapper( { | |
- replacements: [ | |
- { type: 'html', tag: 'script', attribute: 'src', extnames: pageEntries } | |
- ], | |
from: 'src', | |
- to: 'assets' | |
- } ), | |
- new PathMapper( { | |
- replacements: [ | |
- { extnames: moduleEntries + ',css,less', replacer: 'regex' }, | |
- ], | |
- from: 'assets', | |
to: versionFolder | |
} ), | |
- new LessCompiler({ | |
- isExclude: function (file) { | |
- // exclude js file, less compiler 会替换js的一些内容,而且会造成一些代码的丢失。 | |
- return file.extname === 'js'; | |
- } | |
- }), | |
- | |
- new CssCompressor() | |
]; | |
}; | |
exports.exclude = [ | |
- '/tool', | |
- '/doc', | |
- '/test', | |
- '/demo', | |
- '/src', | |
- '/dep', | |
- '/edp-*', | |
+ 'doc', | |
+ 'test', | |
+ 'demo', | |
+ 'dep/echarts/*/build/**', | |
+ 'dep/echarts/*/src/util/mapData/rawData/**', | |
+ 'dep/zrender/*/build/**', | |
+ 'dep/edp/**', | |
+ 'dep/esl/**', | |
+ 'dep/less/**', | |
+ 'edp-*', | |
'.*', | |
'Desktop.ini', | |
'Thumbs.db', | |
@@ -202,65 +92,16 @@ exports.exclude = [ | |
'accessdenied.html', | |
'build.js', | |
'build.sh', | |
- '/assets/css/dsp.css', | |
- 'lessc.js' | |
-]; | |
+ 'lessc.js', | |
+ 'assets/entry.js', | |
+ 'src/common/*-deploy.js', | |
+ 'src/tangram.*.js' | |
+].concat( build.getExcludedUIs().map(function( item ){ | |
+ return 'src/ui/' + item + '.js' | |
+}) ); | |
exports.injectProcessor = function ( processors ) { | |
for ( var key in processors ) { | |
global[ key ] = processors[ key ]; | |
} | |
}; | |
- | |
-function addFile(relativePath, arr) { | |
- var fullPath = path.resolve( __dirname, relativePath ); | |
- arr.push(fs.readFileSync( fullPath, 'UTF-8' )); | |
-} | |
- | |
-function writeFile(relativePath, arr) { | |
- fs.writeFileSync( path.resolve( __dirname, relativePath ), arr.join(eol)); | |
-} | |
- | |
-var charts = []; | |
-addFile('dep/zrender/build/zrender.js', charts); | |
-addFile('dep/echarts/build/echarts-map.js', charts); | |
-writeFile('assets/js/zrender-echarts.js', charts); | |
- | |
-var eslBundle = []; | |
-addFile('src/common/esl.js', eslBundle); | |
-addFile('src/common/js.js', eslBundle); | |
-addFile('src/common/css-deploy.js', eslBundle); | |
-addFile('src/common/tpl-deploy.js', eslBundle); | |
-writeFile('assets/common/esl.js', eslBundle); | |
- | |
-var cssFiles = []; | |
-var tplFiles = []; | |
-function traverseCopy( dir ) { | |
- var files = fs.readdirSync( dir ); | |
- | |
- files.forEach( function ( file ) { | |
- if ( file === '.svn' || file === '.git' ) { | |
- return; | |
- } | |
- | |
- file = path.resolve( dir, file ); | |
- var stat = fs.statSync( file ); | |
- | |
- if ( stat.isDirectory() ) { | |
- traverseCopy( file ); | |
- } | |
- else { | |
- var fileName = path.extname( file ).slice( 1 ); | |
- if (fileName === 'css' || | |
- fileName === 'less') { | |
- cssFiles.push(fs.readFileSync( file, 'UTF-8' )); | |
- } else if (fileName === 'html') { | |
- tplFiles.push(fs.readFileSync( file, 'UTF-8' )); | |
- } | |
- } | |
- }); | |
-} | |
- | |
-traverseCopy(path.resolve( __dirname, 'src' )) | |
-writeFile('assets/css/dsp.less', cssFiles); | |
-writeFile('assets/tpl/templates.html', tplFiles); | |
\ No newline at end of file | |
diff --git a/main.html b/main.html | |
index 74b52bc..9ea13ff 100644 | |
--- a/main.html | |
+++ b/main.html | |
@@ -6,6 +6,7 @@ | |
<meta http-equiv="pragma" content="no-cache" /> | |
<meta http-equiv="expires" content="0" /> | |
<title>百度DSP</title> | |
+<link rel="stylesheet" type="text/css" href="src/css/dsp.less" /> | |
<link rel="stylesheet" type="text/css" href="assets/css/dsp.css" /> | |
<link rel="SHORTCUT ICON" href="http://www.baidu.com/favicon.ico" /> | |
<script src="/api/system/fe-uc.properties"></script> | |
@@ -87,8 +88,49 @@ | |
</div> | |
<script type="text/javascript">document.domain="baidu.com";</script> | |
<script type="text/javascript" src="assets/js/tangram-base-1.3.7.1.js"></script> | |
-<script type="text/javascript" src="src/common/esl.js"></script> | |
-<script type="text/javascript" src="src/entry.js"></script> | |
+<script type="text/javascript" src="http://s1.bdstatic.com/r/www/cache/ecom/esl/1-6-10/esl.js"></script> | |
+<script type="text/javascript"> | |
+require.config( { | |
+ baseUrl: "src", | |
+ paths: { | |
+ "tpl": "common/tpl", | |
+ "css": "common/css" | |
+ }, | |
+ packages: [ | |
+ { | |
+ name: "echarts", | |
+ location: "../dep/echarts/1.3.8/src", | |
+ main: "echarts" | |
+ }, | |
+ { | |
+ name: "zrender", | |
+ location: "../dep/zrender/1.1.0/src", | |
+ main: "zrender" | |
+ }, | |
+ { | |
+ name: "etpl", | |
+ location: "../dep/etpl/2.0.6/src", | |
+ main: "main" | |
+ }, | |
+ { | |
+ name: "mini-event", | |
+ location: "../dep/mini-event/1.0.0/src", | |
+ main: "main" | |
+ } | |
+ ] | |
+} ); | |
+ | |
+// TODO 有优化的空间. | |
+require([ 'startup/ria' ], function( ria ){ | |
+ require( [ 'startup/dsp' ], function( dsp ){ | |
+ require([ 'dsp/windowConfig' ], function () { | |
+ require( [ 'startup/app' ], function( app ){ | |
+ app.start(); | |
+ }); | |
+ }); | |
+ }); | |
+}); | |
+</script> | |
</body> | |
</html> | |
diff --git a/module.conf b/module.conf | |
index 9dd440a..900a04d 100644 | |
--- a/module.conf | |
+++ b/module.conf | |
@@ -1,101 +1,29 @@ | |
{ | |
"baseUrl": "src", | |
"paths": { | |
- "assets": "assets", | |
- "dep": "dep" | |
+ "tpl": "common/tpl", | |
+ "css": "common/css" | |
}, | |
"packages": [ | |
{ | |
+ "name": "echarts", | |
+ "location": "../dep/echarts/1.3.8/src", | |
+ "main": "echarts" | |
+ }, | |
+ { | |
+ "name": "zrender", | |
+ "location": "../dep/zrender/1.1.0/src", | |
+ "main": "zrender" | |
+ }, | |
+ { | |
"name": "etpl", | |
- "location": "dep/etpl/src", | |
- "main": "main2" | |
+ "location": "../dep/etpl/2.0.6/src", | |
+ "main": "main" | |
}, | |
{ | |
"name": "mini-event", | |
- "location": "dep/mini-event/1.0.0/src", | |
+ "location": "../dep/mini-event/1.0.0/src", | |
"main": "main" | |
} | |
- ], | |
- "combine": { | |
- "assets/js/base-er": { | |
- "exclude": [ "dsp/*" ], | |
- "include": [ | |
- "er/dispatcher", | |
- "er/FormAction", | |
- "er/ListAction", | |
- "er/permission", | |
- "er/ReportAction", | |
- "er/template", | |
- "er/AbstractFormAction", | |
- "er/Action", | |
- "er/base", | |
- "er/config", | |
- "er/context", | |
- "er/DetailAction", | |
- "base/Object", | |
- "base/ObservableList", | |
- "base/ParamAdapter", | |
- "base/PropertyChangeNotifier", | |
- "base/RSDataSource", | |
- "base/Worker", | |
- "base/BaseModel", | |
- "base/Converter", | |
- "base/DataSource", | |
- "base/EventDispatcher", | |
- "base/ListDataSource", | |
- "Requester", | |
- "Validator" | |
- ] | |
- }, | |
- "assets/js/ui-components": { | |
- "exclude": [ | |
- "base/*", | |
- "etpl/*", | |
- "er/*", | |
- "Validator" | |
- ] | |
- }, | |
- "assets/js/biz": { | |
- "exclude": [ | |
- "base/*", | |
- "etpl/*", | |
- "er/*", | |
- "dsp/*", | |
- "mini-event/*", | |
- "dep/*", | |
- "Requester", | |
- "Validator", | |
- "ui/*" | |
- ] | |
- }, | |
- "assets/js/dsp-app": { | |
- "include": [ | |
- "dsp/util", | |
- "dsp/worker", | |
- "dsp/action", | |
- "dsp/config", | |
- "dsp/data", | |
- "dsp/init", | |
- "dsp/initConst", | |
- "dsp/isAllow", | |
- "dsp/windowConfig", | |
- "dsp/listHelper", | |
- "dsp/loading", | |
- "dsp/navigator", | |
- "dsp/notice", | |
- "dsp/tpl", | |
- "dsp/Breadcrumbs" | |
- ], | |
- "exclude": [ | |
- "base/*", | |
- "etpl/*", | |
- "er/*", | |
- "mini-event/*", | |
- "dep/*", | |
- "Requester", | |
- "Validator", | |
- "ui/*" | |
- ] | |
- } | |
- } | |
-} | |
\ No newline at end of file | |
+ ] | |
+} | |
diff --git a/src/Requester.js b/src/Requester.js | |
index 7abb83a..0d2709b 100644 | |
--- a/src/Requester.js | |
+++ b/src/Requester.js | |
@@ -29,7 +29,7 @@ define(function (require) { | |
} | |
}; | |
- var Ajax = require("dep/ajax"); | |
+ var Ajax = require("ajax/ajax"); | |
/** | |
* 请求发送器 | |
*/ | |
diff --git a/src/ajax/Deferred.js b/src/ajax/Deferred.js | |
new file mode 100644 | |
index 0000000..889942e | |
--- /dev/null | |
+++ b/src/ajax/Deferred.js | |
@@ -0,0 +1,454 @@ | |
+/** | |
+ * ER (Enterprise RIA) | |
+ * Copyright 2013 Baidu Inc. All rights reserved. | |
+ * | |
+ * @ignore | |
+ * @file Deferred类实现 | |
+ * @author otakustay | |
+ */ | |
+define( | |
+ function (require) { | |
+ var util = require('./util'); | |
+ var assert = require('./assert'); | |
+ | |
+ var setImmediate = typeof window.setImmediate === 'function' | |
+ ? function (fn) { window.setImmediate(fn); } | |
+ : function (fn) { window.setTimeout(fn, 0); }; | |
+ | |
+ /** | |
+ * 尝试执行相关的回调函数 | |
+ * | |
+ * 当`deferred`处于非`pending`状态时,根据其状态, | |
+ * 立即异步地运行对应的回调函数 | |
+ * | |
+ * @param {Deferred} deferred 需要处理的`Deferred`实例 | |
+ * @ignore | |
+ */ | |
+ function tryFlush(deferred) { | |
+ if (deferred.state === 'pending') { | |
+ return; | |
+ } | |
+ | |
+ var callbacks = deferred.state === 'resolved' | |
+ ? deferred._doneCallbacks.slice() | |
+ : deferred._failCallbacks.slice(); | |
+ | |
+ function flush() { | |
+ for (var i = 0; i < callbacks.length; i++) { | |
+ var callback = callbacks[i]; | |
+ try { | |
+ // 回调时的this应该是`Promise`,没有`resolve`等方法 | |
+ callback.apply(deferred.promise, deferred._args); | |
+ } | |
+ catch (ex) { | |
+ } | |
+ } | |
+ } | |
+ | |
+ if (deferred.syncModeEnabled) { | |
+ flush(); | |
+ } | |
+ else { | |
+ setImmediate(flush); | |
+ } | |
+ | |
+ deferred._doneCallbacks = []; | |
+ deferred._failCallbacks = []; | |
+ } | |
+ | |
+ /** | |
+ * 将一个原有的`Deferred`与一个新的`Deferred`对象连接起来 | |
+ * | |
+ * 该方法作为`then`方法的核心 | |
+ * | |
+ * @param {Deferred} original 原`Deferred`对象 | |
+ * @param {Deferred} deferred 新`Deferred`对象 | |
+ * @param {callback} 当`original`运行完毕后,需要执行的函数 | |
+ * @param {string} actionType 关联的动作类型,`"resolve"`或`"reject"` | |
+ * @return {Function} 关联函数,可注册在`original`的相关回调函数上 | |
+ * @ignore | |
+ */ | |
+ function pipe(original, deferred, callback, actionType) { | |
+ return function () { | |
+ // `.then(done)`及`.then(null, fail)`时使用 | |
+ // | |
+ // 根据`callback`的行为,进行以下处理: | |
+ // | |
+ // - 如果`callback`返回值,则用该值改`deferred`为`resolved` | |
+ // - 如果`callback`抛出异常,则用异常改`deferred`为`rejected` | |
+ if (typeof callback === 'function') { | |
+ var resolver = deferred.resolver; | |
+ try { | |
+ var returnValue = | |
+ callback.apply(original.promise, arguments); | |
+ | |
+ if (Deferred.isPromise(returnValue)) { | |
+ returnValue.then(resolver.resolve, resolver.reject); | |
+ } | |
+ else { | |
+ resolver.resolve(returnValue); | |
+ } | |
+ } | |
+ catch (error) { | |
+ /** | |
+ * @event exception | |
+ * | |
+ * 当回调函数执行出现错误时触发, | |
+ * 在此事件后会再触发{@link Deferred#event-reject}事件 | |
+ * | |
+ * | |
+ * @param {Deferred} deferred 当前的{@link Deferred}对象 | |
+ * @param {Array} args 抛出的错误对象形成的数组,肯定只有1项 | |
+ * @param {Mixed} reason 抛出的错误对象 | |
+ * @member Deferred | |
+ * @static | |
+ */ | |
+ Deferred.fire( | |
+ 'exception', | |
+ { | |
+ deferred: original, | |
+ args: [error], | |
+ reason: error | |
+ } | |
+ ); | |
+ resolver.reject(error); | |
+ } | |
+ } | |
+ // `.then()`及`.then(done, null)`时使用 | |
+ // | |
+ // 直接使用原`Deferred`保存的参数将`deferred`改为对应状态 | |
+ else { | |
+ deferred[actionType].apply(deferred, original._args); | |
+ } | |
+ }; | |
+ } | |
+ | |
+ /** | |
+ * Deferred类 | |
+ * | |
+ * 类似于jQuery的`Deferred`对象,是对异步操作的一种封装 | |
+ * | |
+ * 一个`Deferred`对象是一个{@link meta.Resolver}对象 | |
+ * 和一个{@link meta.Promise}的组合,同时提供两者的功能 | |
+ * | |
+ * 当创建一个`Deferred`对象后,通过其中的{@link meta.Resolver}对象定义的方法 | |
+ * 来控制状态的流转,并将{@link Deferred#promise}返回给调用者来追加回调 | |
+ * | |
+ * @mixins mini-event.EventTarget | |
+ * @constructor | |
+ */ | |
+ function Deferred() { | |
+ /** | |
+ * @property {string} state | |
+ * | |
+ * 当前对象的状态 | |
+ * | |
+ * 一个`Deferred`对象一共有3个状态: | |
+ * | |
+ * - `pending`:还处在等待状态,并没有明确最终结果 | |
+ * - `resolved`:任务已经完成,处在成功状态 | |
+ * - `rejected`:任务已经完成,处在失败状态 | |
+ */ | |
+ this.state = 'pending'; | |
+ this._args = null; | |
+ this._doneCallbacks = []; | |
+ this._failCallbacks = []; | |
+ | |
+ /** | |
+ * @property {meta.Promise} promise | |
+ * | |
+ * 与当前对象关联的{@link meta.Promise}对象 | |
+ */ | |
+ this.promise = { | |
+ done: util.bind(this.done, this), | |
+ fail: util.bind(this.fail, this), | |
+ ensure: util.bind(this.ensure, this), | |
+ then: util.bind(this.then, this) | |
+ }; | |
+ // 形成环引用,保证`.promise.promise`能运行 | |
+ this.promise.promise = this.promise; | |
+ | |
+ | |
+ /** | |
+ * @property {meta.Resolver} resolver | |
+ * | |
+ * 与当前对象关联的{@link meta.Resolver}对象 | |
+ */ | |
+ this.resolver = { | |
+ resolve: util.bind(this.resolve, this), | |
+ reject: util.bind(this.reject, this) | |
+ }; | |
+ } | |
+ | |
+ require('mini-event/EventTarget').enable(Deferred); | |
+ | |
+ /** | |
+ * 判断一个对象是否是一个{@link meta.Promise}对象 | |
+ * | |
+ * 该方法采用灵活的判断方式,并非要求`value`为`Deferred`的实例 | |
+ * | |
+ * @param {Mixed} value 需要判断的对象 | |
+ * @return {boolean} 如果`value`是{@link meta.Promise}对象,则返回`true` | |
+ */ | |
+ Deferred.isPromise = function (value) { | |
+ return value && typeof value.then === 'function'; | |
+ }; | |
+ | |
+ /** | |
+ * 是否启用同步模式。 | |
+ * | |
+ * 在同步模式下,`Deferred`对象并不符合Promise/A规范, | |
+ * 当对象进入或处于`resolved`或`rejected`状态时, | |
+ * 添加的回调函数会 **立即** 、 **同步** 地被执行。 | |
+ * | |
+ * @type {boolean} | |
+ */ | |
+ Deferred.prototype.syncModeEnabled = false; | |
+ | |
+ /** | |
+ * @inheritdoc meta.Resolver#resolve | |
+ */ | |
+ Deferred.prototype.resolve = function () { | |
+ if (this.state !== 'pending') { | |
+ return; | |
+ } | |
+ | |
+ this.state = 'resolved'; | |
+ this._args = [].slice.call(arguments); | |
+ | |
+ /** | |
+ * @event resolve | |
+ * | |
+ * 当任意一个`Deferred`对象进入`resolved`状态时触发 | |
+ * | |
+ * @param {Deferred} deferred 当前的{@link Deferred}对象 | |
+ * @param {Array} args 改变状态时提供的参数 | |
+ * @param {Mixed} reason 相当于`args[0]`,供多数场景下快速访问 | |
+ * @member Deferred | |
+ * @static | |
+ */ | |
+ Deferred.fire( | |
+ 'resolve', | |
+ { | |
+ deferred: this, | |
+ args: this._args, | |
+ reason: this._args[0] | |
+ } | |
+ ); | |
+ | |
+ tryFlush(this); | |
+ }; | |
+ | |
+ /** | |
+ * @inheritdoc meta.Resolver#reject | |
+ */ | |
+ Deferred.prototype.reject = function () { | |
+ if (this.state !== 'pending') { | |
+ return; | |
+ } | |
+ | |
+ this.state = 'rejected'; | |
+ this._args = [].slice.call(arguments); | |
+ | |
+ /** | |
+ * @event reject | |
+ * | |
+ * 当任意一个`Deferred`对象进入`rejected`状态时触发 | |
+ * | |
+ * @param {Deferred} deferred 当前的{@link Deferred}对象 | |
+ * @param {Array} args 改变状态时提供的参数 | |
+ * @param {Mixed} reason 相当于`args[0]`,供多数场景下快速访问 | |
+ * @member Deferred | |
+ * @static | |
+ */ | |
+ Deferred.fire( | |
+ 'reject', | |
+ { | |
+ deferred: this, | |
+ args: this._args, | |
+ reason: this._args[0] | |
+ } | |
+ ); | |
+ | |
+ tryFlush(this); | |
+ }; | |
+ | |
+ /** | |
+ * @inheritdoc meta.Promise#done | |
+ */ | |
+ Deferred.prototype.done = function (callback) { | |
+ return this.then(callback); | |
+ }; | |
+ | |
+ /** | |
+ * @inheritdoc meta.Promise#fail | |
+ */ | |
+ Deferred.prototype.fail = function (callback) { | |
+ return this.then(null, callback); | |
+ }; | |
+ | |
+ /** | |
+ * @inheritdoc meta.Promise#ensure | |
+ */ | |
+ Deferred.prototype.ensure = function (callback) { | |
+ return this.then(callback, callback); | |
+ }; | |
+ | |
+ /** | |
+ * @inheritdoc meta.Promise#then | |
+ */ | |
+ Deferred.prototype.then = function (done, fail) { | |
+ var deferred = new Deferred(); | |
+ deferred.syncModeEnabled = this.syncModeEnabled; | |
+ | |
+ this._doneCallbacks.push(pipe(this, deferred, done, 'resolve')); | |
+ this._failCallbacks.push(pipe(this, deferred, fail, 'reject')); | |
+ | |
+ tryFlush(this); | |
+ | |
+ return deferred.promise; | |
+ }; | |
+ | |
+ // 暂不支持`progress`, | |
+ // 社区对`progress`处理函数的返回值和异常的传递还在讨论中 | |
+ | |
+ /** | |
+ * 生成一个新的{@link meta.Promise}对象, | |
+ * 当所有给定的{@link meta.Promise}对象完成后触发 | |
+ * | |
+ * 其触发逻辑如下: | |
+ * | |
+ * - 如果所有给定的{@link meta.Promise}对象均进入`resolved`状态, | |
+ * 则该{@link meta.Promise}对象进入`resolved`状态 | |
+ * - 如果有至少一个{@link meta.Promise}对象进入`rejected`状态, | |
+ * 则该{@link meta.Promise}对象进入`rejected`状态 | |
+ * | |
+ * 当新的{@link meta.Promise}对象触发时, | |
+ * 将按照传入的{@link meta.Promise}对象的顺序, | |
+ * 依次提供参数,且根据原{@link meta.Promise}对象的回调参数,有以下情况: | |
+ * | |
+ * - 如果给定参数只有一个,使用这一个参数 | |
+ * - 如果给定多个参数,则提供一个数组包含这些参数 | |
+ * | |
+ * 本方法对参数的方法与`Array.prototyp.concat`相同,任意一个参数是数组则会展开 | |
+ * | |
+ * @param {meta.Promise... | meta.Promise[]...} args 需要组合的对象 | |
+ * @return {meta.Promise} | |
+ */ | |
+ Deferred.all = function () { | |
+ // 典型的异步并发归并问题,使用计数器来解决 | |
+ var workingUnits = [].concat.apply([], arguments); | |
+ var workingCount = workingUnits.length; | |
+ | |
+ // 如果没有任何任务,直接给处理完的 | |
+ if (!workingCount) { | |
+ return Deferred.resolved(); | |
+ } | |
+ | |
+ var actionType = 'resolve'; | |
+ var result = []; | |
+ | |
+ var jointDeferred = new Deferred(); | |
+ | |
+ function resolveOne(whichToFill) { | |
+ workingCount--; | |
+ | |
+ assert.greaterThanOrEquals( | |
+ workingCount, 0, 'workingCount should be positive' | |
+ ); | |
+ | |
+ var unitResult = [].slice.call(arguments, 1); | |
+ // 如果给定的结果只有一个,不要再组装成数组 | |
+ if (unitResult.length <= 1) { | |
+ unitResult = unitResult[0]; | |
+ } | |
+ result[whichToFill] = unitResult; | |
+ | |
+ if (workingCount === 0) { | |
+ jointDeferred[actionType].apply(jointDeferred, result); | |
+ } | |
+ } | |
+ | |
+ function rejectOne() { | |
+ actionType = 'reject'; | |
+ resolveOne.apply(this, arguments); | |
+ } | |
+ | |
+ for (var i = 0; i < workingUnits.length; i++) { | |
+ var unit = workingUnits[i]; | |
+ unit.then( | |
+ util.bind(resolveOne, unit, i), | |
+ util.bind(rejectOne, unit, i) | |
+ ); | |
+ } | |
+ | |
+ return jointDeferred.promise; | |
+ }; | |
+ | |
+ /** | |
+ * 返回一个已经处于`resolved`状态的{@link meta.Promise}对象 | |
+ * | |
+ * @param {Mixed...} args 用于调用{@link meta.Resolver#resolve}方法的参数 | |
+ * @return {meta.Promise} | |
+ */ | |
+ Deferred.resolved = function () { | |
+ var deferred = new Deferred(); | |
+ deferred.resolve.apply(deferred, arguments); | |
+ return deferred.promise; | |
+ }; | |
+ | |
+ /** | |
+ * 返回一个已经处于`rejected`状态的{@link meta.Promise}对象 | |
+ * | |
+ * @param {Mixed...} args 用于调用{@link meta.Resolver#reject}方法的参数 | |
+ * @return {meta.Promise} | |
+ */ | |
+ Deferred.rejected = function () { | |
+ var deferred = new Deferred(); | |
+ deferred.reject.apply(deferred, arguments); | |
+ return deferred.promise; | |
+ }; | |
+ | |
+ /** | |
+ * 返回一个以给定值为结果的`resolved`状态的{@link meta.Promise}对象, | |
+ * 该方法可用于统一同步和异步编程模型 | |
+ * | |
+ * @param {Mixed} value 给定的值 | |
+ * @return {meta.Promise} 如果`value`本身是一个{@link meta.Promise}, | |
+ * 则直接返回其本身。如果`value`是普通对象, | |
+ * 则返回一个 **同步** 的处于`resolved`状态的{@link meta.Promise}, | |
+ * 该{@link meta.Promise}以`value`为值进入`resolved`状态 | |
+ */ | |
+ Deferred.when = function (value) { | |
+ if (Deferred.isPromise(value)) { | |
+ return value; | |
+ } | |
+ | |
+ // `when`返回的`Promise`必须开启同步模式,以便保留堆栈供单步调度 | |
+ var deferred = new Deferred(); | |
+ deferred.syncModeEnabled = true; | |
+ deferred.resolve(value); | |
+ return deferred.promise; | |
+ }; | |
+ | |
+ /** | |
+ * 返回一个{@link meta.Promise}对象, | |
+ * 当指定的模块被AMD加载器加载后,进入`resolved`状态 | |
+ * | |
+ * @param {string[]} modules 需要加载的模块列表 | |
+ * @return {meta.Promise} | |
+ */ | |
+ Deferred.require = function () { | |
+ var modules = [].slice.call(arguments); | |
+ var deferred = new Deferred(); | |
+ | |
+ window.require(modules, deferred.resolver.resolve); | |
+ | |
+ deferred.promise.abort = deferred.resolver.reject; | |
+ | |
+ return deferred.promise; | |
+ }; | |
+ | |
+ return Deferred; | |
+ } | |
+); | |
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js | |
new file mode 100644 | |
index 0000000..4d9d12e | |
--- /dev/null | |
+++ b/src/ajax/ajax.js | |
@@ -0,0 +1,387 @@ | |
+/** | |
+ * ER (Enterprise RIA) | |
+ * Copyright 2013 Baidu Inc. All rights reserved. | |
+ * | |
+ * @ignore | |
+ * @file AJAX相关方法 | |
+ * @author otakustay | |
+ */ | |
+define( | |
+ function (require) { | |
+ | |
+ /** | |
+ * @class ajax | |
+ * | |
+ * AJAX模块 | |
+ * | |
+ * @mixins mini-event.EventTarget | |
+ * @singleton | |
+ */ | |
+ var ajax = {}; | |
+ require('mini-event/EventTarget').enable(ajax); | |
+ | |
+ /** | |
+ * 每次请求流程的勾子,可通过重写其中的函数来影响AJAX的行为 | |
+ * | |
+ * @type {meta.AjaxHook} | |
+ */ | |
+ ajax.hooks = {}; | |
+ | |
+ ajax.hooks.serializeArray = function (prefix, array) { | |
+ //var encodedKey = prefix ? encodeURIComponent(prefix) : ''; | |
+ var encodedKey = prefix || ''; | |
+ var encoded = []; | |
+ for (var i = 0; i < array.length; i++) { | |
+ var item = array[i]; | |
+ encoded[i] = ajax.hooks.serializeData('', item); | |
+ } | |
+ return encodedKey | |
+ ? encodedKey + '=' + encoded.join(',') | |
+ : encoded.join(','); | |
+ }; | |
+ | |
+ ajax.hooks.serializeData = function (prefix, data) { | |
+ if (arguments.length === 1) { | |
+ data = prefix; | |
+ prefix = ''; | |
+ } | |
+ | |
+ if (data == null) { | |
+ data = ''; | |
+ } | |
+ var getKey = ajax.hooks.serializeData.getKey; | |
+ //var encodedKey = prefix ? encodeURIComponent(prefix) : ''; | |
+ var encodedKey = prefix || ''; | |
+ | |
+ var type = Object.prototype.toString.call(data); | |
+ switch (type) { | |
+ case '[object Array]': | |
+ return ajax.hooks.serializeArray(prefix, data); | |
+ case '[object Object]': | |
+ var result = []; | |
+ for (var name in data) { | |
+ var propertyKey = getKey(name, prefix); | |
+ var propertyValue = | |
+ ajax.hooks.serializeData(propertyKey, data[name]); | |
+ result.push(propertyValue); | |
+ } | |
+ return result.join('&'); | |
+ default: | |
+ /* | |
+ return encodedKey | |
+ ? encodedKey + '=' + encodeURIComponent(data) | |
+ : encodeURIComponent(data); | |
+ */ | |
+ return encodedKey | |
+ ? encodedKey + '=' + data | |
+ : data; | |
+ } | |
+ }; | |
+ | |
+ ajax.hooks.serializeData.getKey = function (propertyName, parentKey) { | |
+ return parentKey ? parentKey + '.' + propertyName : propertyName; | |
+ }; | |
+ | |
+ /** | |
+ * AJAX的全局配置 | |
+ * | |
+ * @type {meta.AjaxOption} | |
+ */ | |
+ ajax.config = { | |
+ cache: false, | |
+ timeout: 0, | |
+ charset: '' | |
+ }; | |
+ | |
+ /** | |
+ * 发起`XMLHttpRequest`请求 | |
+ * | |
+ * @param {meta.AjaxOption} options 相关配置 | |
+ * @return {meta.FakeXHR} | |
+ */ | |
+ ajax.request = function (options) { | |
+ if (typeof ajax.hooks.beforeExecute === 'function') { | |
+ ajax.hooks.beforeExecute(options); | |
+ } | |
+ | |
+ var assert = require('./assert'); | |
+ assert.hasProperty(options, 'url', 'url property is required'); | |
+ | |
+ var defaults = { | |
+ method: 'POST', | |
+ data: {}, | |
+ cache: ajax.config.cache, | |
+ timeout: ajax.config.timeout, | |
+ charset: ajax.config.charset | |
+ }; | |
+ var util = require('./util'); | |
+ options = util.mix(defaults, options); | |
+ | |
+ var Deferred = require('./Deferred'); | |
+ var requesting = new Deferred(); | |
+ | |
+ if (typeof ajax.hooks.beforeCreate === 'function') { | |
+ var canceled = ajax.hooks.beforeCreate(options, requesting); | |
+ if (canceled === true) { | |
+ var fakeXHR = requesting.promise; | |
+ fakeXHR.abort = function () {}; | |
+ fakeXHR.setRequestHeader = function () {}; | |
+ return fakeXHR; | |
+ } | |
+ } | |
+ | |
+ var xhr = window.XMLHttpRequest | |
+ ? new XMLHttpRequest() | |
+ : new ActiveXObject('Microsoft.XMLHTTP'); | |
+ | |
+ var fakeXHR = requesting.promise; | |
+ var xhrWrapper = { | |
+ abort: function () { | |
+ // 有些浏览器`abort()`就会把`readyState`变成4, | |
+ // 这就会导致进入处理函数变成**resolved**状态, | |
+ // 因此事先去掉处理函数,然后直接进入**rejected**状态 | |
+ xhr.onreadystatechange = null; | |
+ xhr.abort(); | |
+ if (!fakeXHR.status) { | |
+ fakeXHR.status = 0; | |
+ } | |
+ fakeXHR.readyState = xhr.readyState; | |
+ fakeXHR.responseText = ''; | |
+ fakeXHR.responseXML = ''; | |
+ requesting.reject(fakeXHR); | |
+ }, | |
+ setRequestHeader: function (name, value) { | |
+ xhr.setRequestHeader(name, value); | |
+ } | |
+ }; | |
+ util.mix(fakeXHR, xhrWrapper); | |
+ | |
+ fakeXHR.then( | |
+ function () { | |
+ /** | |
+ * @event done | |
+ * | |
+ * 任意一个请求成功时触发 | |
+ * | |
+ * @param {meta.FakeXHR} xhr 请求对象 | |
+ */ | |
+ ajax.fire('done', { xhr: fakeXHR }); | |
+ }, | |
+ function () { | |
+ /** | |
+ * @event fail | |
+ * | |
+ * 任意一个请求失败时触发 | |
+ * | |
+ * @param {meta.FakeXHR} xhr 请求对象 | |
+ */ | |
+ ajax.fire('fail', { xhr: fakeXHR }); | |
+ } | |
+ ); | |
+ | |
+ xhr.onreadystatechange = function () { | |
+ if (xhr.readyState === 4) { | |
+ var status = fakeXHR.status || xhr.status; | |
+ // `file://`协议下状态码始终为0 | |
+ if (status === 0) { | |
+ status = 200; | |
+ } | |
+ // IE9会把204状态码变成1223 | |
+ else if (status === 1223) { | |
+ status = 204; | |
+ } | |
+ | |
+ fakeXHR.status = fakeXHR.status || status; | |
+ fakeXHR.readyState = xhr.readyState; | |
+ fakeXHR.responseText = xhr.responseText; | |
+ fakeXHR.responseXML = xhr.responseXML; | |
+ | |
+ if (typeof ajax.hooks.afterReceive === 'function') { | |
+ ajax.hooks.afterReceive(fakeXHR, options); | |
+ } | |
+ | |
+ // 如果请求不成功,也就不用再分解数据了,直接丢回去就好 | |
+ if (status < 200 || (status >= 300 && status !== 304)) { | |
+ requesting.reject(fakeXHR); | |
+ return; | |
+ } | |
+ | |
+ var data = xhr.responseText; | |
+ if (options.dataType === 'json') { | |
+ try { | |
+ data = util.parseJSON(data); | |
+ } | |
+ catch (ex) { | |
+ // 服务器返回的数据不符合JSON格式,认为请求失败 | |
+ fakeXHR.error = ex; | |
+ requesting.reject(fakeXHR); | |
+ return; | |
+ } | |
+ } | |
+ | |
+ if (typeof ajax.hooks.afterParse === 'function') { | |
+ try { | |
+ data = | |
+ ajax.hooks.afterParse(data, fakeXHR, options); | |
+ } | |
+ catch (ex) { | |
+ fakeXHR.error = ex; | |
+ requesting.reject(fakeXHR); | |
+ return; | |
+ } | |
+ } | |
+ | |
+ // 数据处理成功后,进行回调 | |
+ requesting.resolve(data); | |
+ } | |
+ }; | |
+ | |
+ var method = options.method.toUpperCase(); | |
+ var data = {}; | |
+ if (method === 'GET') { | |
+ util.mix(data, options.data); | |
+ } | |
+ if (options.cache === false) { | |
+ data['_'] = +new Date(); | |
+ } | |
+ var query = ajax.hooks.serializeData( | |
+ '', data, 'application/x-www-form-urlencoded'); | |
+ var url = options.url; | |
+ if (query) { | |
+ var delimiter = url.indexOf('?') >= 0 ? '&' : '?'; | |
+ url += delimiter + query; | |
+ } | |
+ | |
+ xhr.open(method, url, true); | |
+ | |
+ if (typeof ajax.hooks.beforeSend === 'function') { | |
+ ajax.hooks.beforeSend(fakeXHR, options); | |
+ } | |
+ | |
+ if (method === 'GET') { | |
+ xhr.send(); | |
+ } | |
+ else { | |
+ var contentType = | |
+ options.contentType || 'application/x-www-form-urlencoded'; | |
+ var query = ajax.hooks.serializeData( | |
+ '', options.data, contentType, fakeXHR); | |
+ if (options.charset) { | |
+ contentType += ';charset=' + options.charset; | |
+ } | |
+ xhr.setRequestHeader('Content-Type', contentType); | |
+ xhr.send(query); | |
+ } | |
+ | |
+ if (options.timeout > 0) { | |
+ var tick = setTimeout( | |
+ function () { | |
+ fakeXHR.status = 408; // HTTP 408: Request Timeout | |
+ fakeXHR.abort(); | |
+ }, | |
+ options.timeout | |
+ ); | |
+ fakeXHR.ensure(function () { clearTimeout(tick); }); | |
+ } | |
+ | |
+ return fakeXHR; | |
+ }; | |
+ | |
+ /** | |
+ * 发起一个`GET`请求 | |
+ * | |
+ * @param {string} url 请求的地址 | |
+ * @param {Object} [data] 请求的数据 | |
+ * @param {boolean} [cache] 决定是否允许缓存 | |
+ * @return {meta.FakeXHR} | |
+ */ | |
+ ajax.get = function (url, data, cache) { | |
+ var options = { | |
+ method: 'GET', | |
+ url: url, | |
+ data: data, | |
+ cache: cache || ajax.config.cache | |
+ }; | |
+ return ajax.request(options); | |
+ }; | |
+ | |
+ /** | |
+ * 发起一个`GET`请求并获取JSON数据 | |
+ * | |
+ * @param {string} url 请求的地址 | |
+ * @param {Object} [data] 请求的数据 | |
+ * @param {boolean} [cache] 决定是否允许缓存 | |
+ * @return {meta.FakeXHR} | |
+ */ | |
+ ajax.getJSON = function (url, data, cache) { | |
+ var options = { | |
+ method: 'GET', | |
+ url: url, | |
+ data: data, | |
+ dataType: 'json', | |
+ cache: cache || ajax.config.cache | |
+ }; | |
+ return ajax.request(options); | |
+ }; | |
+ | |
+ | |
+ /** | |
+ * 发起一个`POST`请求 | |
+ * | |
+ * @param {string} url 请求的地址 | |
+ * @param {Object} [data] 请求的数据 | |
+ * @param {string} [dataType="json"] 指定响应的数据格式 | |
+ * @return {meta.FakeXHR} | |
+ */ | |
+ ajax.post = function (url, data, dataType) { | |
+ var options = { | |
+ method: 'POST', | |
+ url: url, | |
+ data: data, | |
+ dataType: dataType || 'json' | |
+ }; | |
+ return ajax.request(options); | |
+ }; | |
+ | |
+ /** | |
+ * 发送一个日志请求,该请求只负责发出,不负责保证送达,且不支持回调函数 | |
+ * | |
+ * @param {string} url 发送的目标URL | |
+ * @param {Object} [data] 额外添加的参数 | |
+ */ | |
+ ajax.log = function (url, data) { | |
+ var img = new Image(); | |
+ var pool = window.ER_LOG_POOL || (window.ER_LOG_POOL = {}); | |
+ var id = +new Date(); | |
+ pool[id] = img; | |
+ | |
+ img.onload = img.onerror = img.onabort = function () { | |
+ // 如果这个img很不幸正好加载了一个存在的资源,又是个gif动画, | |
+ // 则在gif动画播放过程中,img会多次触发onload,因此一定要清空 | |
+ img.onload = img.onerror = img.onabort = null; | |
+ | |
+ pool[id] = null; | |
+ | |
+ // 下面这句非常重要, | |
+ // new Image创建的是DOM, | |
+ // DOM的事件中形成闭包环引用DOM是典型的内存泄露, | |
+ // 因此这里一定要置为null | |
+ img = null; | |
+ }; | |
+ | |
+ var query = ajax.hooks.serializeData( | |
+ '', data, 'application/x-www-form-urlencoded'); | |
+ if (query) { | |
+ var delimiter = url.indexOf('?') >= 0 ? ':' : '?'; | |
+ url += delimiter + query; | |
+ } | |
+ // 一定要在注册了事件之后再设置src, | |
+ // 不然如果图片是读缓存的话,会错过事件处理, | |
+ // 最后,对于url最好是添加客户端时间来防止缓存, | |
+ // 同时服务器也配合一下传递`Cache-Control: no-cache;` | |
+ img.src = url; | |
+ }; | |
+ | |
+ return ajax; | |
+ } | |
+); | |
diff --git a/src/ajax/assert.js b/src/ajax/assert.js | |
new file mode 100644 | |
index 0000000..5c56064 | |
--- /dev/null | |
+++ b/src/ajax/assert.js | |
@@ -0,0 +1,132 @@ | |
+/** | |
+ * ER (Enterprise RIA) | |
+ * Copyright 2013 Baidu Inc. All rights reserved. | |
+ * | |
+ * @ignore | |
+ * @file 简单的,仅调试期有效的断言库 | |
+ * @author otakustay | |
+ */ | |
+define( | |
+ function () { | |
+ if (typeof DEBUG === 'undefined') DEBUG = true; | |
+ if (DEBUG) { | |
+ /** | |
+ * @class assert | |
+ * | |
+ * 断言函数 | |
+ * | |
+ * 断言函数仅在开发期有效,当`window.DEBUG`属性为`true`时, | |
+ * 断言失败会抛出异常,其它情况下断言无任何作用 | |
+ * | |
+ * 断言是[契约式编程](http://en.wikipedia.org/wiki/Design_by_contract) | |
+ * 中很重要的一块,使用得当可以有效地提高程序的质量,因此ER提供了此功能 | |
+ * | |
+ * @param {boolean} condition 断言结果 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @singleton | |
+ */ | |
+ var assert = function (condition, message) { | |
+ if (!condition) { | |
+ throw new Error(message); | |
+ } | |
+ }; | |
+ | |
+ /** | |
+ * 断言一个对象有值(不为`null`或`undefined`) | |
+ * | |
+ * @param {Mixed} obj 用于判断的对象 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.has = function (obj, message) { | |
+ assert(obj != null, message); | |
+ }; | |
+ | |
+ | |
+ /** | |
+ * 断言两个对象相等 | |
+ * | |
+ * @param {Mixed} x 用于判断相等的左值 | |
+ * @param {Mixed} y 用于判断相等的右值 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.equals = function (x, y, message) { | |
+ assert(x === y, message); | |
+ }; | |
+ | |
+ /** | |
+ * 断言一个对象包含指定名称的属性 | |
+ * | |
+ * @param {Mixed} obj 用户断言的对象 | |
+ * @param {string} propertyName 属性的名称 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.hasProperty = function (obj, propertyName, message) { | |
+ assert(obj[propertyName] != null, message); | |
+ }; | |
+ | |
+ /** | |
+ * 断言一个对象小于另一个对象 | |
+ * | |
+ * @param {Mixed} value 用于判断的左值 | |
+ * @param {Mixed} max 用于判断的右值 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.lessThan = function (value, max, message) { | |
+ assert(value < max, message); | |
+ }; | |
+ | |
+ /** | |
+ * 断言一个对象大于另一个对象 | |
+ * | |
+ * @param {Mixed} value 用于判断的左值 | |
+ * @param {Mixed} min 用于判断的右值 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.greaterThan = function (value, min, message) { | |
+ assert(value > min, message); | |
+ }; | |
+ | |
+ /** | |
+ * 断言一个对象小于等于另一个对象 | |
+ * | |
+ * @param {Mixed} value 用于判断的左值 | |
+ * @param {Mixed} max 用于判断的右值 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.lessThanOrEquals = function (value, max, message) { | |
+ assert(value <= max, message); | |
+ }; | |
+ | |
+ /** | |
+ * 断言一个对象大于等于另一个对象 | |
+ * | |
+ * @param {Mixed} value 用于判断的左值 | |
+ * @param {Mixed} min 用于判断的右值 | |
+ * @param {string} message 断言结果为`false`时提示的信息 | |
+ * @member assert | |
+ */ | |
+ assert.greaterThanOrEquals = function (value, min, message) { | |
+ assert(value >= min, message); | |
+ }; | |
+ | |
+ return assert; | |
+ } | |
+ else { | |
+ var assert = function () {}; | |
+ assert.has = assert; | |
+ assert.equals = assert; | |
+ assert.hasProperty = assert; | |
+ assert.lessThan = assert; | |
+ assert.greaterThan = assert; | |
+ assert.lessThanOrEquals = assert; | |
+ assert.greaterThanOrEquals = assert; | |
+ return assert; | |
+ } | |
+ } | |
+); | |
diff --git a/src/ajax/util.js b/src/ajax/util.js | |
new file mode 100644 | |
index 0000000..489a4a4 | |
--- /dev/null | |
+++ b/src/ajax/util.js | |
@@ -0,0 +1,189 @@ | |
+/** | |
+ * ER (Enterprise RIA) | |
+ * Copyright 2013 Baidu Inc. All rights reserved. | |
+ * | |
+ * @ignore | |
+ * @file 杂而乱的工具对象 | |
+ * @author otakustay, errorrik | |
+ */ | |
+define( | |
+ function () { | |
+ var now = +new Date(); | |
+ | |
+ /** | |
+ * @class util | |
+ * | |
+ * 工具模块,放一些杂七杂八的东西 | |
+ * | |
+ * @singleton | |
+ */ | |
+ var util = {}; | |
+ | |
+ /** | |
+ * 获取一个唯一的ID | |
+ * | |
+ * @return {string} 一个唯一的ID | |
+ */ | |
+ util.guid = function () { | |
+ return 'er' + now++; | |
+ }; | |
+ | |
+ /** | |
+ * 混合多个对象 | |
+ * | |
+ * @param {Object} source 源对象 | |
+ * @param {Object...} destinations 用于混合的对象 | |
+ * @return 返回混合了`destintions`属性的`source`对象 | |
+ */ | |
+ util.mix = function (source) { | |
+ for (var i = 1; i < arguments.length; i++) { | |
+ var destination = arguments[i]; | |
+ | |
+ // 就怕有人传**null**之类的进来 | |
+ if (!destination) { | |
+ continue; | |
+ } | |
+ | |
+ // 这里如果`destination`是字符串的话,会遍历出下标索引来, | |
+ // 认为这是调用者希望的效果,所以不作处理 | |
+ for (var key in destination) { | |
+ if (destination.hasOwnProperty(key)) { | |
+ source[key] = destination[key]; | |
+ } | |
+ } | |
+ } | |
+ return source; | |
+ }; | |
+ | |
+ // `bind`的实现特别使用引擎原生的, | |
+ // 因为自己实现的`bind`很会影响调试时的单步调试, | |
+ // 跳进一个函数的时候还要经过这个`bind`几步很烦,原生的就不会 | |
+ var nativeBind = Function.prototype.bind; | |
+ /** | |
+ * 固定函数的`this`变量和若干参数 | |
+ * | |
+ * @param {Function} fn 操作的目标函数 | |
+ * @param {Mixed} context 函数的`this`变量 | |
+ * @param {Mixed...} args 固定的参数 | |
+ * @return {Function} 固定了`this`变量和若干参数后的新函数对象 | |
+ */ | |
+ util.bind = nativeBind | |
+ ? function (fn) { | |
+ return nativeBind.apply(fn, [].slice.call(arguments, 1)); | |
+ } | |
+ : function (fn, context) { | |
+ var extraArgs = [].slice.call(arguments, 2); | |
+ return function () { | |
+ var args = extraArgs.concat([].slice.call(arguments)); | |
+ return fn.apply(context, args); | |
+ }; | |
+ }; | |
+ | |
+ /** | |
+ * 空函数 | |
+ * | |
+ * @property | |
+ * @type {Function} | |
+ */ | |
+ util.noop = function () {}; | |
+ | |
+ var dontEnumBug = !(({ toString: 1 }).propertyIsEnumerable('toString')); | |
+ | |
+ /** | |
+ * 设置继承关系 | |
+ * | |
+ * @param {Function} type 子类 | |
+ * @param {Function} superType 父类 | |
+ * @return {Function} 子类 | |
+ */ | |
+ util.inherits = function (type, superType) { | |
+ var Empty = function () {}; | |
+ Empty.prototype = superType.prototype; | |
+ var proto = new Empty(); | |
+ | |
+ var originalPrototype = type.prototype; | |
+ type.prototype = proto; | |
+ | |
+ for (var key in originalPrototype) { | |
+ proto[key] = originalPrototype[key]; | |
+ } | |
+ if (dontEnumBug) { | |
+ // 其实还有好多其它的,但应该不会撞上吧(╯‵□′)╯︵┻━┻ | |
+ if (originalPrototype.hasOwnProperty('toString')) { | |
+ proto.toString = originalPrototype.toString; | |
+ } | |
+ if (originalPrototype.hasOwnProperty('valueOf')) { | |
+ proto.valueOf = originalPrototype.valueOf; | |
+ } | |
+ } | |
+ type.prototype.constructor = type; | |
+ | |
+ return type; | |
+ }; | |
+ | |
+ /** | |
+ * 将一段文本变为JSON对象 | |
+ * | |
+ * @param {string} text 文本内容 | |
+ * @return {Mixed} 对应的JSON对象 | |
+ */ | |
+ util.parseJSON = function (text) { | |
+ if (!text) { | |
+ return undefined; | |
+ } | |
+ /* | |
+ if (window.JSON && typeof JSON.parse === 'function') { | |
+ return JSON.parse(text); | |
+ } | |
+ else { | |
+ return eval('(' + text + ')'); | |
+ } | |
+ */ | |
+ //解决JSON.parse不能过滤注释问题 | |
+ return (new Function("return (" + text + ")"))(); | |
+ }; | |
+ | |
+ var whitespace = /(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+$)/g; | |
+ | |
+ /** | |
+ * 移除字符串前后空格字符 | |
+ * | |
+ * @param {string} source 源字符串 | |
+ * @return {string} 移除前后空格后的字符串 | |
+ */ | |
+ util.trim = function (source) { | |
+ return source.replace(whitespace, ''); | |
+ }; | |
+ | |
+ /** | |
+ * 对字符中进行HTML编码 | |
+ * | |
+ * @param {string} source 源字符串 | |
+ * @param {string} HTML编码后的字符串 | |
+ */ | |
+ util.encodeHTML = function (source) { | |
+ source = source + ''; | |
+ return source | |
+ .replace(/&/g, '&') | |
+ .replace(/</g, '<') | |
+ .replace(/>/g, '>') | |
+ .replace(/"/g, '"') | |
+ .replace(/'/g, '''); | |
+ }; | |
+ | |
+ /** | |
+ * 兼容性获取一个元素 | |
+ * | |
+ * @param {HTMLElement | string} element 元素或元素的id | |
+ * @return {HTMLElement} | |
+ */ | |
+ util.getElement = function (element) { | |
+ if (typeof element === 'string') { | |
+ element = document.getElementById(element); | |
+ } | |
+ return element; | |
+ }; | |
+ | |
+ return util; | |
+ } | |
+); | |
diff --git a/src/biz/ad/AdInfoList.base.js b/src/biz/ad/AdInfoList.base.js | |
index 38810cf..f42ac94 100644 | |
--- a/src/biz/ad/AdInfoList.base.js | |
+++ b/src/biz/ad/AdInfoList.base.js | |
@@ -19,7 +19,7 @@ define(function (require) { | |
var locator = dispatcher.locator; | |
var uiUtil = require('ui/util'); | |
var uiDialog = require('ui/Dialog.confirm'); | |
- var Deferred = require('dep/Deferred'); | |
+ var Deferred = require('ajax/Deferred'); | |
var dspUtil = require('dsp/util'); | |
var LISTNAME = 'list'; | |
diff --git a/src/biz/creativity/creativitiesList.js b/src/biz/creativity/creativitiesList.js | |
index 56483cc..7ee3194 100644 | |
--- a/src/biz/creativity/creativitiesList.js | |
+++ b/src/biz/creativity/creativitiesList.js | |
@@ -12,7 +12,7 @@ define(function (require) { | |
require('css!./css/creativity.css'); | |
var dspListAction = require('dsp/action');//FIXME 用相对路径 | |
var creativities = require('./creativitiesConfig'); | |
- var Deferred = require('dep/Deferred'); | |
+ var Deferred = require('ajax/Deferred'); | |
var ui = {} | |
ui.util = require('ui/util'); | |
ui.events = require('ui/events'); | |
diff --git a/src/biz/creativity/creativityList.js b/src/biz/creativity/creativityList.js | |
index 738cbb3..018320b 100644 | |
--- a/src/biz/creativity/creativityList.js | |
+++ b/src/biz/creativity/creativityList.js | |
@@ -12,7 +12,7 @@ define(function (require) { | |
require('css!./css/creativity.css'); | |
var dspListAction = require('dsp/action'); | |
var creativity = require('./creativityConfig'); | |
- var Deferred = require('dep/Deferred'); | |
+ var Deferred = require('ajax/Deferred'); | |
var previewDialog = require('ui/Dialog.preview'); | |
var ui = {} | |
ui.util = require('ui/util'); | |
diff --git a/src/biz/moduleConfig.js b/src/biz/moduleConfig.js | |
index 51c0c90..8523a7e 100644 | |
--- a/src/biz/moduleConfig.js | |
+++ b/src/biz/moduleConfig.js | |
@@ -6,7 +6,7 @@ define(function (require) { | |
require('biz/orderMgr/orderMgr'); | |
require('biz/community/config'); | |
- require('biz/demo/demo'); | |
+ // require('biz/demo/demo'); | |
require('biz/account/account'); | |
require('biz/order/config'); | |
require('biz/ad/config'); | |
diff --git a/src/common/css-deploy.js b/src/common/css-deploy.js | |
deleted file mode 100644 | |
index 908ce7b..0000000 | |
--- a/src/common/css-deploy.js | |
+++ /dev/null | |
@@ -1,15 +0,0 @@ | |
-/** | |
- * ESL (Enterprise Standard Loader) | |
- * Copyright 2013 Baidu Inc. All rights reserved. | |
- * | |
- * @file CSS Loader-Plugin | |
- * @author errorrik([email protected]) | |
- */ | |
- | |
-// 构建环境暂不支持分析,为了能合并该plugin到loader里, | |
-// 只能暂时使用具名id | |
-define( 'css', { | |
- load: function ( resourceId, req, load, config ) { | |
- load( true ); | |
- } | |
-} ); | |
diff --git a/src/common/css.js b/src/common/css.js | |
index 33645d6..6489bb7 100644 | |
--- a/src/common/css.js | |
+++ b/src/common/css.js | |
@@ -10,18 +10,7 @@ | |
// 只能暂时使用具名id | |
define( 'css', { | |
load: function ( resourceId, req, load, config ) { | |
- var link = document.createElement( 'link' ); | |
- link.setAttribute( 'rel', 'stylesheet' ); | |
- link.setAttribute( 'type', 'text/css' ); | |
- link.setAttribute( 'href', req.toUrl( resourceId ) ); | |
- | |
- var parent = document.getElementsByTagName( 'head' )[ 0 ] | |
- || document.body; | |
- parent.appendChild( link ); | |
- | |
- parent = null; | |
- link = null; | |
- | |
+ // 什么也不需要做了,以为assets/css/dsp.css已经加载了需要的css了 | |
load( true ); | |
} | |
} ); | |
diff --git a/src/common/esl.js b/src/common/esl.js | |
deleted file mode 100644 | |
index 4f073b2..0000000 | |
--- a/src/common/esl.js | |
+++ /dev/null | |
@@ -1,1790 +0,0 @@ | |
-/** | |
- * ESL (Enterprise Standard Loader) | |
- * Copyright 2013 Baidu Inc. All rights reserved. | |
- * | |
- * @file Browser端标准加载器,符合AMD规范 | |
- * @author errorrik([email protected]) | |
- * Firede([email protected]) | |
- */ | |
- | |
-var define; | |
-var require; | |
- | |
-(function ( global ) { | |
- // "mod"开头的变量或函数为内部模块管理函数 | |
- // 为提高压缩率,不使用function或object包装 | |
- | |
- /** | |
- * 模块容器 | |
- * | |
- * @inner | |
- * @type {Object} | |
- */ | |
- var modModules = {}; | |
- | |
- var MODULE_STATE_PRE_DEFINED = 1; | |
- var MODULE_STATE_PRE_ANALYZED = 2; | |
- var MODULE_STATE_ANALYZED = 3; | |
- var MODULE_STATE_READY = 4; | |
- var MODULE_STATE_DEFINED = 5; | |
- | |
- /** | |
- * 全局require函数 | |
- * | |
- * @inner | |
- * @type {Function} | |
- */ | |
- var actualGlobalRequire = createLocalRequire( '' ); | |
- | |
- // #begin-ignore | |
- /** | |
- * 超时提醒定时器 | |
- * | |
- * @inner | |
- * @type {number} | |
- */ | |
- var waitTimeout; | |
- // #end-ignore | |
- | |
- /** | |
- * 加载模块 | |
- * | |
- * @param {string|Array} requireId 模块id或模块id数组, | |
- * @param {Function=} callback 加载完成的回调函数 | |
- * @return {*} | |
- */ | |
- function require( requireId, callback ) { | |
- // #begin-ignore | |
- assertNotContainRelativeId( requireId ); | |
- | |
- // 超时提醒 | |
- var timeout = requireConf.waitSeconds; | |
- if ( isArray( requireId ) && timeout ) { | |
- if ( waitTimeout ) { | |
- clearTimeout( waitTimeout ); | |
- } | |
- waitTimeout = setTimeout( waitTimeoutNotice, timeout * 1000 ); | |
- } | |
- // #end-ignore | |
- | |
- return actualGlobalRequire( requireId, callback ); | |
- } | |
- | |
- /** | |
- * 将模块标识转换成相对的url | |
- * | |
- * @param {string} id 模块标识 | |
- * @return {string} | |
- */ | |
- require.toUrl = actualGlobalRequire.toUrl; | |
- | |
- // #begin-ignore | |
- /** | |
- * 超时提醒函数 | |
- * | |
- * @inner | |
- */ | |
- function waitTimeoutNotice() { | |
- var hangModules = []; | |
- var missModules = []; | |
- var missModulesMap = {}; | |
- var hasError; | |
- | |
- for ( var id in modModules ) { | |
- if ( !modIsDefined( id ) ) { | |
- hangModules.push( id ); | |
- hasError = 1; | |
- } | |
- | |
- each( | |
- modModules[ id ].realDeps || [], | |
- function ( depId ) { | |
- if ( !modModules[ depId ] && !missModulesMap[ depId ] ) { | |
- hasError = 1; | |
- missModules.push( depId ); | |
- missModulesMap[ depId ] = 1; | |
- } | |
- } | |
- ); | |
- } | |
- | |
- if ( hasError ) { | |
- throw new Error( '[MODULE_TIMEOUT]Hang( ' | |
- + ( hangModules.join( ', ' ) || 'none' ) | |
- + ' ) Miss( ' | |
- + ( missModules.join( ', ' ) || 'none' ) | |
- + ' )' | |
- ); | |
- } | |
- } | |
- // #end-ignore | |
- | |
- /** | |
- * 尝试完成模块定义的定时器 | |
- * | |
- * @inner | |
- * @type {number} | |
- */ | |
- var tryDefineTimeout; | |
- | |
- /** | |
- * 定义模块 | |
- * | |
- * @param {string=} id 模块标识 | |
- * @param {Array=} dependencies 依赖模块列表 | |
- * @param {Function=} factory 创建模块的工厂方法 | |
- */ | |
- function define() { | |
- var argsLen = arguments.length; | |
- if ( !argsLen ) { | |
- return; | |
- } | |
- | |
- var id; | |
- var dependencies; | |
- var factory = arguments[ --argsLen ]; | |
- | |
- while ( argsLen-- ) { | |
- var arg = arguments[ argsLen ]; | |
- | |
- if ( isString( arg ) ) { | |
- id = arg; | |
- } | |
- else if ( isArray( arg ) ) { | |
- dependencies = arg; | |
- } | |
- } | |
- | |
- // 出现window不是疏忽 | |
- // esl设计是做为browser端的loader | |
- // 闭包的global更多意义在于: | |
- // define和require方法可以被挂到用户自定义对象中 | |
- var opera = window.opera; | |
- | |
- // IE下通过current script的data-require-id获取当前id | |
- if ( | |
- !id | |
- && document.attachEvent | |
- && (!(opera && opera.toString() === '[object Opera]')) | |
- ) { | |
- var currentScript = getCurrentScript(); | |
- id = currentScript && currentScript.getAttribute('data-require-id'); | |
- } | |
- | |
- // 处理依赖声明 | |
- // 默认为['require', 'exports', 'module'] | |
- dependencies = dependencies || ['require', 'exports', 'module']; | |
- if ( id ) { | |
- modPreDefine( id, dependencies, factory ); | |
- | |
- // 在不远的未来尝试完成define | |
- // define可能是在页面中某个地方调用,不一定是在独立的文件被require装载 | |
- if ( tryDefineTimeout ) { | |
- clearTimeout( tryDefineTimeout ); | |
- } | |
- tryDefineTimeout = setTimeout( modPreAnalyse, 10 ); | |
- } | |
- else { | |
- // 纪录到共享变量中,在load或readystatechange中处理 | |
- wait4PreDefines.push( { | |
- deps : dependencies, | |
- factory : factory | |
- } ); | |
- } | |
- } | |
- | |
- define.amd = {}; | |
- | |
- /** | |
- * 获取相应状态的模块列表 | |
- * | |
- * @inner | |
- * @param {number} state 状态码 | |
- * @return {Array} | |
- */ | |
- function modGetByState( state ) { | |
- var modules = []; | |
- for ( var key in modModules ) { | |
- var module = modModules[ key ]; | |
- if ( module.state == state ) { | |
- modules.push( module ); | |
- } | |
- } | |
- | |
- return modules; | |
- } | |
- | |
- /** | |
- * 模块配置获取函数 | |
- * | |
- * @inner | |
- * @return {Object} 模块配置对象 | |
- */ | |
- function moduleConfigGetter() { | |
- var conf = requireConf.config[ this.id ]; | |
- if ( conf && typeof conf === 'object' ) { | |
- return conf; | |
- } | |
- | |
- return {}; | |
- } | |
- | |
- /** | |
- * 预定义模块 | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- * @param {Array.<string>} dependencies 显式声明的依赖模块列表 | |
- * @param {*} factory 模块定义函数或模块对象 | |
- */ | |
- function modPreDefine( id, dependencies, factory ) { | |
- if ( modExists( id ) ) { | |
- return; | |
- } | |
- | |
- var module = { | |
- id : id, | |
- deps : dependencies, | |
- factory : factory, | |
- exports : {}, | |
- config : moduleConfigGetter, | |
- state : MODULE_STATE_PRE_DEFINED, | |
- hardDeps : {} | |
- }; | |
- | |
- // 将模块预存入defining集合中 | |
- modModules[ id ] = module; | |
- } | |
- | |
- /** | |
- * 预分析模块 | |
- * | |
- * 首先,完成对factory中声明依赖的分析提取 | |
- * 然后,尝试加载"资源加载所需模块" | |
- * | |
- * 需要先加载模块的原因是:如果模块不存在,无法进行resourceId normalize化 | |
- * modAnalyse完成后续的依赖分析处理,并进行依赖模块的加载 | |
- * | |
- * @inner | |
- * @param {Object} modules 模块对象 | |
- */ | |
- function modPreAnalyse() { | |
- var pluginModuleIds = []; | |
- var pluginModuleIdsMap = {}; | |
- var modules = modGetByState( MODULE_STATE_PRE_DEFINED ); | |
- | |
- each( | |
- modules, | |
- function ( module ) { | |
- // 处理实际需要加载的依赖 | |
- var realDepends = module.deps.slice( 0 ); | |
- module.realDeps = realDepends; | |
- | |
- // 分析function body中的require | |
- // 如果包含显式依赖声明,为性能考虑,可以不分析factoryBody | |
- // AMD规范的说明是`SHOULD NOT`,所以这里还是分析了 | |
- var factory = module.factory; | |
- var requireRule = /require\(\s*(['"'])([^'"]+)\1\s*\)/g; | |
- var commentRule = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg; | |
- if ( isFunction( factory ) ) { | |
- factory.toString() | |
- .replace( commentRule, '' ) | |
- .replace( requireRule, function ( $0, $1, $2 ) { | |
- realDepends.push( $2 ); | |
- }); | |
- } | |
- | |
- // 分析resource加载的plugin module id | |
- each( | |
- realDepends, | |
- function ( dependId ) { | |
- var idInfo = parseId( dependId ); | |
- if ( idInfo.resource ) { | |
- var plugId = normalize( idInfo.module, module.id ); | |
- if ( !pluginModuleIdsMap[ plugId ] ) { | |
- pluginModuleIds.push( plugId ); | |
- pluginModuleIdsMap[ plugId ] = 1; | |
- } | |
- } | |
- } | |
- ); | |
- | |
- module.state = MODULE_STATE_PRE_ANALYZED; | |
- } | |
- ); | |
- | |
- nativeRequire( pluginModuleIds, function () { | |
- modAnalyse( modules ); | |
- } ); | |
- } | |
- | |
- /** | |
- * 分析模块 | |
- * 对所有依赖id进行normalize化,完成分析,并尝试加载其依赖的模块 | |
- * | |
- * @inner | |
- * @param {Array} modules 模块对象列表 | |
- */ | |
- function modAnalyse( modules ) { | |
- var requireModules = []; | |
- | |
- each( | |
- modules, | |
- function ( module ) { | |
- if ( module.state !== MODULE_STATE_PRE_ANALYZED ) { | |
- return; | |
- } | |
- | |
- var id = module.id; | |
- | |
- // 对参数中声明的依赖进行normalize | |
- var depends = module.deps; | |
- var hardDepends = module.hardDeps; | |
- var hardDependsCount = isFunction( module.factory ) | |
- ? module.factory.length | |
- : 0; | |
- | |
- each( | |
- depends, | |
- function ( dependId, index ) { | |
- dependId = normalize( dependId, id ); | |
- depends[ index ] = dependId; | |
- | |
- if ( index < hardDependsCount ) { | |
- hardDepends[ dependId ] = 1; | |
- } | |
- } | |
- ); | |
- | |
- // 依赖模块id normalize化,并去除必要的依赖。去除的依赖模块有: | |
- // 1. 内部模块:require/exports/module | |
- // 2. 重复模块:dependencies参数和内部require可能重复 | |
- // 3. 空模块:dependencies中使用者可能写空 | |
- var realDepends = module.realDeps; | |
- var existsDepend = {}; | |
- | |
- // 为保证模块和插件资源的请求顺序,此处正序遍历 | |
- for ( var i = 0, len = realDepends.length; i < len; ) { | |
- // 此处和上部分循环存在重复normalize,因为deps和realDeps是重复的 | |
- // 为保持逻辑分界清晰,就不做优化了先 | |
- var dependId = normalize( realDepends[ i ], id ); | |
- if ( !dependId | |
- || dependId in existsDepend | |
- || dependId in BUILDIN_MODULE | |
- ) { | |
- realDepends.splice( i, 1 ); | |
- len--; | |
- } | |
- else { | |
- existsDepend[ dependId ] = 1; | |
- realDepends[ i ] = dependId; | |
- | |
- // 将实际依赖压入加载序列中,后续统一进行require | |
- requireModules.push( dependId ); | |
- i++; | |
- } | |
- } | |
- | |
- module.realDepsIndex = existsDepend; | |
- module.state = MODULE_STATE_ANALYZED; | |
- | |
- modWaitDependenciesLoaded( module ); | |
- modInvokeFactoryDependOn( id ); | |
- } | |
- ); | |
- | |
- nativeRequire( requireModules ); | |
- } | |
- | |
- /** | |
- * 等待模块依赖加载完成 | |
- * 加载完成后尝试调用factory完成模块定义 | |
- * | |
- * @inner | |
- * @param {Object} module 模块对象 | |
- */ | |
- function modWaitDependenciesLoaded( module ) { | |
- var id = module.id; | |
- | |
- module.invokeFactory = invokeFactory; | |
- invokeFactory(); | |
- | |
- // 用于避免死依赖链的死循环尝试 | |
- var checkingLevel = 0; | |
- | |
- /** | |
- * 判断依赖加载完成 | |
- * | |
- * @inner | |
- * @return {boolean} | |
- */ | |
- function checkInvokeReadyState() { | |
- checkingLevel++; | |
- | |
- var isReady = 1; | |
- var tryDeps = []; | |
- | |
- each( | |
- module.realDeps, | |
- function ( depId ) { | |
- if ( !modIsAnalyzed( depId ) ) { | |
- isReady = 0; | |
- } | |
- else if ( !modIsDefined( depId ) ) { | |
- switch ( modHasCircularDependency( id, depId ) ) { | |
- case CIRCULAR_DEP_UNREADY: | |
- case CIRCULAR_DEP_NO: | |
- isReady = 0; | |
- break; | |
- case CIRCULAR_DEP_YES: | |
- if ( module.hardDeps[ depId ] ) { | |
- tryDeps.push( depId ); | |
- } | |
- break; | |
- } | |
- } | |
- | |
- return !!isReady; | |
- } | |
- ); | |
- | |
- | |
- // 只有当其他非循环依赖都装载了,才去尝试触发硬依赖模块的初始化 | |
- isReady && each( | |
- tryDeps, | |
- function ( depId ) { | |
- modTryInvokeFactory( depId ); | |
- } | |
- ); | |
- | |
- isReady = isReady && tryDeps.length === 0; | |
- isReady && (module.state = MODULE_STATE_READY); | |
- | |
- checkingLevel--; | |
- return isReady; | |
- } | |
- | |
- /** | |
- * 初始化模块 | |
- * | |
- * @inner | |
- */ | |
- function invokeFactory() { | |
- if ( module.state == MODULE_STATE_DEFINED | |
- || checkingLevel > 1 | |
- || !checkInvokeReadyState() | |
- ) { | |
- return; | |
- } | |
- | |
- // 调用factory函数初始化module | |
- try { | |
- var factory = module.factory; | |
- var exports = isFunction( factory ) | |
- ? factory.apply( | |
- global, | |
- modGetModulesExports( | |
- module.deps, | |
- { | |
- require : createLocalRequire( id ), | |
- exports : module.exports, | |
- module : module | |
- } | |
- ) | |
- ) | |
- : factory; | |
- | |
- if ( typeof exports != 'undefined' ) { | |
- module.exports = exports; | |
- } | |
- | |
- module.state = MODULE_STATE_DEFINED; | |
- module.invokeFactory = null; | |
- } | |
- catch ( ex ) { | |
- if ( /^\[MODULE_MISS\]"([^"]+)/.test( ex.message ) ) { | |
- // 出错说明在factory的运行中,该require的模块是需要的 | |
- // 所以把它加入硬依赖中 | |
- module.hardDeps[ RegExp.$1 ] = 1; | |
- return; | |
- } | |
- | |
- throw ex; | |
- } | |
- | |
- | |
- modInvokeFactoryDependOn( id ); | |
- modFireDefined( id ); | |
- } | |
- } | |
- | |
- /** | |
- * 根据模块id数组,获取其的exports数组 | |
- * 用于模块初始化的factory参数或require的callback参数生成 | |
- * | |
- * @inner | |
- * @param {Array} modules 模块id数组 | |
- * @param {Object} buildinModules 内建模块对象 | |
- * @return {Array} | |
- */ | |
- function modGetModulesExports( modules, buildinModules ) { | |
- var args = []; | |
- each( | |
- modules, | |
- function ( moduleId, index ) { | |
- args[ index ] = | |
- buildinModules[ moduleId ] | |
- || modGetModuleExports( moduleId ); | |
- } | |
- ); | |
- | |
- return args; | |
- } | |
- | |
- var CIRCULAR_DEP_UNREADY = 0; | |
- var CIRCULAR_DEP_NO = 1; | |
- var CIRCULAR_DEP_YES = 2; | |
- | |
- /** | |
- * 判断source是否处于target的依赖链中 | |
- * | |
- * @inner | |
- * @return {number} | |
- */ | |
- function modHasCircularDependency( source, target, meet ) { | |
- if ( !modIsAnalyzed( target ) ) { | |
- return CIRCULAR_DEP_UNREADY; | |
- } | |
- | |
- meet = meet || {}; | |
- meet[ target ] = 1; | |
- | |
- if ( target == source ) { | |
- return CIRCULAR_DEP_YES; | |
- } | |
- | |
- var module = modGetModule( target ); | |
- var depends = module && module.realDeps; | |
- | |
- | |
- if ( depends ) { | |
- var len = depends.length; | |
- | |
- while ( len-- ) { | |
- var dependId = depends[ len ]; | |
- if ( meet[ dependId ] ) { | |
- continue; | |
- } | |
- | |
- var state = modHasCircularDependency( source, dependId, meet ); | |
- switch ( state ) { | |
- case CIRCULAR_DEP_UNREADY: | |
- case CIRCULAR_DEP_YES: | |
- return state; | |
- } | |
- } | |
- } | |
- | |
- return CIRCULAR_DEP_NO; | |
- } | |
- | |
- /** | |
- * 让依赖自己的模块尝试初始化 | |
- * | |
- * @inner | |
- * @param {string} id 模块id | |
- */ | |
- function modInvokeFactoryDependOn( id ) { | |
- for ( var key in modModules ) { | |
- var realDeps = modModules[ key ].realDepsIndex || {}; | |
- realDeps[ id ] && modTryInvokeFactory( key ); | |
- } | |
- } | |
- | |
- /** | |
- * 尝试执行模块factory函数,进行模块初始化 | |
- * | |
- * @inner | |
- * @param {string} id 模块id | |
- */ | |
- function modTryInvokeFactory( id ) { | |
- var module = modModules[ id ]; | |
- | |
- if ( module && module.invokeFactory ) { | |
- module.invokeFactory(); | |
- } | |
- } | |
- | |
- /** | |
- * 模块定义完成的事件监听器 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var modDefinedListener = []; | |
- | |
- /** | |
- * 模块定义完成事件监听器的移除索引 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var modRemoveListenerIndex = []; | |
- | |
- /** | |
- * 模块定义完成事件fire层级 | |
- * | |
- * @inner | |
- * @type {number} | |
- */ | |
- var modFireLevel = 0; | |
- | |
- /** | |
- * 派发模块定义完成事件 | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- */ | |
- function modFireDefined( id ) { | |
- modFireLevel++; | |
- each( | |
- modDefinedListener, | |
- function ( listener ) { | |
- listener && listener( id ); | |
- } | |
- ); | |
- modFireLevel--; | |
- | |
- modSweepDefinedListener(); | |
- } | |
- | |
- /** | |
- * 清理模块定义完成事件监听器 | |
- * modRemoveDefinedListener时只做标记 | |
- * 在modFireDefined执行清除动作 | |
- * | |
- * @inner | |
- * @param {Function} listener 模块定义监听器 | |
- */ | |
- function modSweepDefinedListener() { | |
- if ( modFireLevel < 1 ) { | |
- modRemoveListenerIndex.sort( | |
- function ( a, b ) { return b - a; } | |
- ); | |
- | |
- each( | |
- modRemoveListenerIndex, | |
- function ( index ) { | |
- modDefinedListener.splice( index, 1 ); | |
- } | |
- ); | |
- | |
- modRemoveListenerIndex = []; | |
- } | |
- } | |
- | |
- /** | |
- * 移除模块定义监听器 | |
- * | |
- * @inner | |
- * @param {Function} listener 模块定义监听器 | |
- */ | |
- function modRemoveDefinedListener( listener ) { | |
- each( | |
- modDefinedListener, | |
- function ( item, index ) { | |
- if ( listener == item ) { | |
- modRemoveListenerIndex.push( index ); | |
- } | |
- } | |
- ); | |
- } | |
- | |
- /** | |
- * 添加模块定义监听器 | |
- * | |
- * @inner | |
- * @param {Function} listener 模块定义监听器 | |
- */ | |
- function modAddDefinedListener( listener ) { | |
- modDefinedListener.push( listener ); | |
- } | |
- | |
- /** | |
- * 判断模块是否存在 | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- * @return {boolean} | |
- */ | |
- function modExists( id ) { | |
- return id in modModules; | |
- } | |
- | |
- /** | |
- * 判断模块是否已定义完成 | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- * @return {boolean} | |
- */ | |
- function modIsDefined( id ) { | |
- return modExists( id ) | |
- && modModules[ id ].state == MODULE_STATE_DEFINED; | |
- } | |
- | |
- /** | |
- * 判断模块是否已分析完成 | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- * @return {boolean} | |
- */ | |
- function modIsAnalyzed( id ) { | |
- return modExists( id ) | |
- && modModules[ id ].state >= MODULE_STATE_ANALYZED; | |
- } | |
- | |
- /** | |
- * 获取模块的exports | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- * @return {*} | |
- */ | |
- function modGetModuleExports( id ) { | |
- if ( modIsDefined( id ) ) { | |
- return modModules[ id ].exports; | |
- } | |
- | |
- return null; | |
- } | |
- | |
- /** | |
- * 获取模块 | |
- * | |
- * @inner | |
- * @param {string} id 模块标识 | |
- * @return {Object} | |
- */ | |
- function modGetModule( id ) { | |
- return modModules[ id ]; | |
- } | |
- | |
- /** | |
- * 添加资源 | |
- * | |
- * @inner | |
- * @param {string} resourceId 资源标识 | |
- * @param {*} value 资源对象 | |
- */ | |
- function modAddResource( resourceId, value ) { | |
- modModules[ resourceId ] = { | |
- exports: value || true, | |
- state: MODULE_STATE_DEFINED | |
- }; | |
- | |
- modInvokeFactoryDependOn( resourceId ); | |
- modFireDefined( resourceId ); | |
- } | |
- | |
- /** | |
- * 内建module名称集合 | |
- * | |
- * @inner | |
- * @type {Object} | |
- */ | |
- var BUILDIN_MODULE = { | |
- require : require, | |
- exports : 1, | |
- module : 1 | |
- }; | |
- | |
- /** | |
- * 未预定义的模块集合 | |
- * 主要存储匿名方式define的模块 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var wait4PreDefines = []; | |
- | |
- /** | |
- * 完成模块预定义 | |
- * | |
- * @inner | |
- */ | |
- function completePreDefine( currentId ) { | |
- var preDefines = wait4PreDefines.slice( 0 ); | |
- | |
- wait4PreDefines.length = 0; | |
- wait4PreDefines = []; | |
- | |
- // 预定义模块: | |
- // 此时处理的模块都是匿名define的模块 | |
- each( | |
- preDefines, | |
- function ( module ) { | |
- var id = module.id || currentId; | |
- modPreDefine( id, module.deps, module.factory ); | |
- } | |
- ); | |
- | |
- modPreAnalyse(); | |
- } | |
- | |
- /** | |
- * 获取模块 | |
- * | |
- * @param {string|Array} ids 模块名称或模块名称列表 | |
- * @param {Function=} callback 获取模块完成时的回调函数 | |
- * @return {Object} | |
- */ | |
- function nativeRequire( ids, callback, baseId ) { | |
- callback = callback || new Function(); | |
- baseId = baseId || ''; | |
- | |
- // 根据 https://github.com/amdjs/amdjs-api/wiki/require | |
- // It MUST throw an error if the module has not | |
- // already been loaded and evaluated. | |
- if ( isString( ids ) ) { | |
- if ( !modIsDefined( ids ) ) { | |
- throw new Error( '[MODULE_MISS]"' + ids + '" is not exists!' ); | |
- } | |
- | |
- return modGetModuleExports( ids ); | |
- } | |
- | |
- if ( !isArray( ids ) ) { | |
- return; | |
- } | |
- | |
- if ( ids.length === 0 ) { | |
- callback(); | |
- return; | |
- } | |
- | |
- var isCallbackCalled = 0; | |
- modAddDefinedListener( tryFinishRequire ); | |
- each( | |
- ids, | |
- function ( id ) { | |
- if ( id in BUILDIN_MODULE ) { | |
- return; | |
- } | |
- | |
- ( id.indexOf( '!' ) > 0 | |
- ? loadResource | |
- : loadModule | |
- )( id, baseId ); | |
- } | |
- ); | |
- | |
- tryFinishRequire(); | |
- | |
- /** | |
- * 尝试完成require,调用callback | |
- * 在模块与其依赖模块都加载完时调用 | |
- * | |
- * @inner | |
- */ | |
- function tryFinishRequire() { | |
- if ( isCallbackCalled ) { | |
- return; | |
- } | |
- | |
- var visitedModule = {}; | |
- | |
- /** | |
- * 判断是否所有模块都已经加载完成,包括其依赖的模块 | |
- * | |
- * @inner | |
- * @param {Array} modules 直接模块标识列表 | |
- * @return {boolean} | |
- */ | |
- function isAllInited( modules ) { | |
- var allInited = 1; | |
- each( | |
- modules, | |
- function ( id ) { | |
- if ( visitedModule[ id ] ) { | |
- return; | |
- } | |
- visitedModule[ id ] = 1; | |
- | |
- if ( BUILDIN_MODULE[ id ] ) { | |
- return; | |
- } | |
- | |
- if ( | |
- !modIsDefined( id ) | |
- || !isAllInited( modGetModule( id ).realDeps ) | |
- ) { | |
- allInited = 0; | |
- return false; | |
- } | |
- } | |
- ); | |
- | |
- return allInited; | |
- } | |
- | |
- // 检测并调用callback | |
- if ( isAllInited( ids ) ) { | |
- isCallbackCalled = 1; | |
- modRemoveDefinedListener( tryFinishRequire ); | |
- | |
- callback.apply( | |
- global, | |
- modGetModulesExports( ids, BUILDIN_MODULE ) | |
- ); | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * 正在加载的模块列表 | |
- * | |
- * @inner | |
- * @type {Object} | |
- */ | |
- var loadingModules = {}; | |
- | |
- /** | |
- * 加载模块 | |
- * | |
- * @inner | |
- * @param {string} moduleId 模块标识 | |
- */ | |
- function loadModule( moduleId ) { | |
- if ( loadingModules[ moduleId ] ) { | |
- return; | |
- } | |
- | |
- if ( modExists( moduleId ) ) { | |
- modAnalyse( [ modGetModule( moduleId ) ] ); | |
- return; | |
- } | |
- | |
- loadingModules[ moduleId ] = 1; | |
- | |
- // 创建script标签 | |
- // | |
- // 这里不挂接onerror的错误处理 | |
- // 因为高级浏览器在devtool的console面板会报错 | |
- // 再throw一个Error多此一举了 | |
- var script = document.createElement( 'script' ); | |
- script.setAttribute( 'data-require-id', moduleId ); | |
- script.src = toUrl( moduleId + '.js' ) ; | |
- script.async = true; | |
- if ( script.readyState ) { | |
- script.onreadystatechange = loadedListener; | |
- } | |
- else { | |
- script.onload = loadedListener; | |
- } | |
- appendScript( script ); | |
- | |
- /** | |
- * script标签加载完成的事件处理函数 | |
- * | |
- * @inner | |
- */ | |
- function loadedListener() { | |
- var readyState = script.readyState; | |
- if ( | |
- typeof readyState == 'undefined' | |
- || /^(loaded|complete)$/.test( readyState ) | |
- ) { | |
- script.onload = script.onreadystatechange = null; | |
- script = null; | |
- | |
- completePreDefine( moduleId ); | |
- delete loadingModules[ moduleId ]; | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * 加载资源 | |
- * | |
- * @inner | |
- * @param {string} pluginAndResource 插件与资源标识 | |
- * @param {string} baseId 当前环境的模块标识 | |
- */ | |
- function loadResource( pluginAndResource, baseId ) { | |
- var idInfo = parseId( pluginAndResource ); | |
- var pluginId = idInfo.module; | |
- var resourceId = idInfo.resource; | |
- | |
- /** | |
- * plugin加载完成的回调函数 | |
- * | |
- * @inner | |
- * @param {*} value resource的值 | |
- */ | |
- function pluginOnload( value ) { | |
- modAddResource( pluginAndResource, value ); | |
- } | |
- | |
- /** | |
- * 该方法允许plugin使用加载的资源声明模块 | |
- * | |
- * @param {string} name 模块id | |
- * @param {string} body 模块声明字符串 | |
- */ | |
- pluginOnload.fromText = function ( id, text ) { | |
- new Function( text )(); | |
- completePreDefine( id ); | |
- }; | |
- | |
- /** | |
- * 加载资源 | |
- * | |
- * @inner | |
- * @param {Object} plugin 用于加载资源的插件模块 | |
- */ | |
- function load( plugin ) { | |
- if ( !modIsDefined( pluginAndResource ) ) { | |
- plugin.load( | |
- resourceId, | |
- createLocalRequire( baseId ), | |
- pluginOnload, | |
- moduleConfigGetter.call( { id: pluginAndResource } ) | |
- ); | |
- } | |
- } | |
- | |
- if ( !modIsDefined( pluginId ) ) { | |
- nativeRequire( [ pluginId ], load ); | |
- } | |
- else { | |
- load( modGetModuleExports( pluginId ) ); | |
- } | |
- } | |
- | |
- /** | |
- * require配置 | |
- * | |
- * @inner | |
- * @type {Object} | |
- */ | |
- var requireConf = { | |
- baseUrl : './', | |
- paths : {}, | |
- config : {}, | |
- map : {}, | |
- packages : [], | |
- // #begin-ignore | |
- waitSeconds : 0, | |
- // #end-ignore | |
- urlArgs : {} | |
- }; | |
- | |
- /** | |
- * 混合当前配置项与用户传入的配置项 | |
- * | |
- * @inner | |
- * @param {string} name 配置项名称 | |
- * @param {Any} value 用户传入配置项的值 | |
- */ | |
- function mixConfig( name, value ) { | |
- var originValue = requireConf[ name ]; | |
- var type = typeof originValue; | |
- if ( type == 'string' || type == 'number' ) { | |
- requireConf[ name ] = value; | |
- } | |
- else if ( isArray( originValue ) ) { | |
- each( value, function ( item ) { | |
- originValue.push( item ); | |
- } ); | |
- } | |
- else { | |
- for ( var key in value ) { | |
- originValue[ key ] = value[ key ]; | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * 配置require | |
- * | |
- * @param {Object} conf 配置对象 | |
- */ | |
- require.config = function ( conf ) { | |
- // 简单的多处配置还是需要支持 | |
- // 所以实现更改为二级mix | |
- for ( var key in requireConf ) { | |
- if ( conf.hasOwnProperty( key ) ) { | |
- var confItem = conf[ key ]; | |
- if ( key == 'urlArgs' && isString( confItem ) ) { | |
- defaultUrlArgs = confItem; | |
- } | |
- else { | |
- mixConfig( key, confItem ); | |
- } | |
- } | |
- } | |
- | |
- createConfIndex(); | |
- }; | |
- | |
- // 初始化时需要创建配置索引 | |
- createConfIndex(); | |
- | |
- /** | |
- * 创建配置信息内部索引 | |
- * | |
- * @inner | |
- */ | |
- function createConfIndex() { | |
- requireConf.baseUrl = requireConf.baseUrl.replace( /\/$/, '' ) + '/'; | |
- createPathsIndex(); | |
- createMappingIdIndex(); | |
- createPackagesIndex(); | |
- createUrlArgsIndex(); | |
- } | |
- | |
- /** | |
- * packages内部索引 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var packagesIndex; | |
- | |
- /** | |
- * 创建packages内部索引 | |
- * | |
- * @inner | |
- */ | |
- function createPackagesIndex() { | |
- packagesIndex = []; | |
- each( | |
- requireConf.packages, | |
- function ( packageConf ) { | |
- var pkg = packageConf; | |
- if ( isString( packageConf ) ) { | |
- pkg = { | |
- name: packageConf.split('/')[ 0 ], | |
- location: packageConf, | |
- main: 'main' | |
- }; | |
- } | |
- | |
- pkg.location = pkg.location || pkg.name; | |
- pkg.main = (pkg.main || 'main').replace(/\.js$/i, ''); | |
- packagesIndex.push( pkg ); | |
- } | |
- ); | |
- | |
- packagesIndex.sort( createDescSorter( 'name' ) ); | |
- } | |
- | |
- /** | |
- * paths内部索引 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var pathsIndex; | |
- | |
- /** | |
- * 创建paths内部索引 | |
- * | |
- * @inner | |
- */ | |
- function createPathsIndex() { | |
- pathsIndex = kv2List( requireConf.paths ); | |
- pathsIndex.sort( createDescSorter() ); | |
- } | |
- | |
- /** | |
- * 默认的urlArgs | |
- * | |
- * @inner | |
- * @type {string} | |
- */ | |
- var defaultUrlArgs; | |
- | |
- /** | |
- * urlArgs内部索引 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var urlArgsIndex; | |
- | |
- /** | |
- * 创建urlArgs内部索引 | |
- * | |
- * @inner | |
- */ | |
- function createUrlArgsIndex() { | |
- urlArgsIndex = kv2List( requireConf.urlArgs ); | |
- urlArgsIndex.sort( createDescSorter() ); | |
- } | |
- | |
- /** | |
- * mapping内部索引 | |
- * | |
- * @inner | |
- * @type {Array} | |
- */ | |
- var mappingIdIndex; | |
- | |
- /** | |
- * 创建mapping内部索引 | |
- * | |
- * @inner | |
- */ | |
- function createMappingIdIndex() { | |
- mappingIdIndex = []; | |
- | |
- mappingIdIndex = kv2List( requireConf.map ); | |
- mappingIdIndex.sort( createDescSorter() ); | |
- | |
- each( | |
- mappingIdIndex, | |
- function ( item ) { | |
- var key = item.k; | |
- item.v = kv2List( item.v ); | |
- item.v.sort( createDescSorter() ); | |
- item.reg = key == '*' | |
- ? /^/ | |
- : createPrefixRegexp( key ); | |
- } | |
- ); | |
- } | |
- | |
- /** | |
- * 将`模块标识+'.extension'`形式的字符串转换成相对的url | |
- * | |
- * @inner | |
- * @param {string} source 源字符串 | |
- * @return {string} | |
- */ | |
- function toUrl( source ) { | |
- // 分离 模块标识 和 .extension | |
- var extReg = /(\.[a-z0-9]+)$/i; | |
- var queryReg = /(\?[^#]*)$/i; | |
- var extname = ''; | |
- var id = source; | |
- var query = ''; | |
- | |
- if ( queryReg.test( source ) ) { | |
- query = RegExp.$1; | |
- source = source.replace( queryReg, '' ); | |
- } | |
- | |
- if ( extReg.test( source ) ) { | |
- extname = RegExp.$1; | |
- id = source.replace( extReg, '' ); | |
- } | |
- | |
- // 模块标识合法性检测 | |
- if ( !MODULE_ID_REG.test( id ) ) { | |
- return source; | |
- } | |
- | |
- var url = id; | |
- | |
- // paths处理和匹配 | |
- var isPathMap; | |
- each( pathsIndex, function ( item ) { | |
- var key = item.k; | |
- if ( createPrefixRegexp( key ).test( id ) ) { | |
- url = url.replace( key, item.v ); | |
- isPathMap = 1; | |
- return false; | |
- } | |
- } ); | |
- | |
- // packages处理和匹配 | |
- if ( !isPathMap ) { | |
- each( | |
- packagesIndex, | |
- function ( packageConf ) { | |
- var name = packageConf.name; | |
- if ( createPrefixRegexp( name ).test( id ) ) { | |
- url = url.replace( name, packageConf.location ); | |
- return false; | |
- } | |
- } | |
- ); | |
- } | |
- | |
- // 相对路径时,附加baseUrl | |
- if ( !/^([a-z]{2,10}:\/)?\//i.test( url ) ) { | |
- url = requireConf.baseUrl + url; | |
- } | |
- | |
- // 附加 .extension 和 query | |
- url += extname + query; | |
- | |
- | |
- var isUrlArgsAppended; | |
- | |
- /** | |
- * 为url附加urlArgs | |
- * | |
- * @inner | |
- * @param {string} args urlArgs串 | |
- */ | |
- function appendUrlArgs( args ) { | |
- if ( !isUrlArgsAppended ) { | |
- url += ( url.indexOf( '?' ) > 0 ? '&' : '?' ) + args; | |
- isUrlArgsAppended = 1; | |
- } | |
- } | |
- | |
- // urlArgs处理和匹配 | |
- each( urlArgsIndex, function ( item ) { | |
- if ( createPrefixRegexp( item.k ).test( id ) ) { | |
- appendUrlArgs( item.v ); | |
- return false; | |
- } | |
- } ); | |
- defaultUrlArgs && appendUrlArgs( defaultUrlArgs ); | |
- | |
- return url; | |
- } | |
- | |
- /** | |
- * 创建local require函数 | |
- * | |
- * @inner | |
- * @param {number} baseId 当前module id | |
- * @return {Function} | |
- */ | |
- function createLocalRequire( baseId ) { | |
- var requiredCache = {}; | |
- function req( requireId, callback ) { | |
- if ( isString( requireId ) ) { | |
- var requiredModule; | |
- if ( !( requiredModule = requiredCache[ requireId ] ) ) { | |
- requiredModule = nativeRequire( | |
- normalize( requireId, baseId ), | |
- callback, | |
- baseId | |
- ); | |
- requiredCache[ requireId ] = requiredModule; | |
- } | |
- | |
- return requiredModule; | |
- } | |
- else if ( isArray( requireId ) ) { | |
- // 分析是否有resource使用的plugin没加载 | |
- var unloadedPluginModules = []; | |
- each( | |
- requireId, | |
- function ( id ) { | |
- var idInfo = parseId( id ); | |
- var pluginId = normalize( idInfo.module, baseId ); | |
- if ( idInfo.resource && !modIsDefined( pluginId ) ) { | |
- unloadedPluginModules.push( pluginId ); | |
- } | |
- } | |
- ); | |
- | |
- // 加载模块 | |
- nativeRequire( | |
- unloadedPluginModules, | |
- function () { | |
- var ids = []; | |
- each( | |
- requireId, | |
- function ( id ) { | |
- ids.push( normalize( id, baseId ) ); | |
- } | |
- ); | |
- nativeRequire( ids, callback, baseId ); | |
- }, | |
- baseId | |
- ); | |
- } | |
- } | |
- | |
- /** | |
- * 将[module ID] + '.extension'格式的字符串转换成url | |
- * | |
- * @inner | |
- * @param {string} source 符合描述格式的源字符串 | |
- * @return {string} | |
- */ | |
- req.toUrl = function ( id ) { | |
- return toUrl( normalize( id, baseId ) ); | |
- }; | |
- | |
- return req; | |
- } | |
- | |
- /** | |
- * id normalize化 | |
- * | |
- * @inner | |
- * @param {string} id 需要normalize的模块标识 | |
- * @param {string} baseId 当前环境的模块标识 | |
- * @return {string} | |
- */ | |
- function normalize( id, baseId ) { | |
- if ( !id ) { | |
- return ''; | |
- } | |
- | |
- var idInfo = parseId( id ); | |
- if ( !idInfo ) { | |
- return id; | |
- } | |
- | |
- var resourceId = idInfo.resource; | |
- var moduleId = relative2absolute( idInfo.module, baseId ); | |
- | |
- each( | |
- packagesIndex, | |
- function ( packageConf ) { | |
- var name = packageConf.name; | |
- if ( name == moduleId ) { | |
- moduleId = name + '/' + packageConf.main; | |
- return false; | |
- } | |
- } | |
- ); | |
- | |
- moduleId = mappingId( moduleId, baseId ); | |
- | |
- if ( resourceId ) { | |
- var module = modGetModuleExports( moduleId ); | |
- resourceId = module && module.normalize | |
- ? module.normalize( | |
- resourceId, | |
- function ( resId ) { | |
- return normalize( resId, baseId ); | |
- } | |
- ) | |
- : normalize( resourceId, baseId ); | |
- | |
- return moduleId + '!' + resourceId; | |
- } | |
- | |
- return moduleId; | |
- } | |
- | |
- /** | |
- * 相对id转换成绝对id | |
- * | |
- * @inner | |
- * @param {string} id 要转换的id | |
- * @param {string} baseId 当前所在环境id | |
- * @return {string} | |
- */ | |
- function relative2absolute( id, baseId ) { | |
- if ( /^\.{1,2}/.test( id ) ) { | |
- var basePath = baseId.split( '/' ); | |
- var namePath = id.split( '/' ); | |
- var baseLen = basePath.length - 1; | |
- var nameLen = namePath.length; | |
- var cutBaseTerms = 0; | |
- var cutNameTerms = 0; | |
- | |
- pathLoop: for ( var i = 0; i < nameLen; i++ ) { | |
- var term = namePath[ i ]; | |
- switch ( term ) { | |
- case '..': | |
- if ( cutBaseTerms < baseLen ) { | |
- cutBaseTerms++; | |
- cutNameTerms++; | |
- } | |
- else { | |
- break pathLoop; | |
- } | |
- break; | |
- case '.': | |
- cutNameTerms++; | |
- break; | |
- default: | |
- break pathLoop; | |
- } | |
- } | |
- | |
- basePath.length = baseLen - cutBaseTerms; | |
- namePath = namePath.slice( cutNameTerms ); | |
- | |
- basePath.push.apply( basePath, namePath ); | |
- return basePath.join( '/' ); | |
- } | |
- | |
- return id; | |
- } | |
- | |
- // #begin-ignore | |
- /** | |
- * 确定require的模块id不包含相对id。用于global require,提前预防难以跟踪的错误出现 | |
- * | |
- * @inner | |
- * @param {string|Array} requireId require的模块id | |
- */ | |
- function assertNotContainRelativeId( requireId ) { | |
- var invalidIds = []; | |
- | |
- /** | |
- * 监测模块id是否relative id | |
- * | |
- * @inner | |
- * @param {string} id 模块id | |
- */ | |
- function monitor( id ) { | |
- if ( /^\.{1,2}/.test( id ) ) { | |
- invalidIds.push( id ); | |
- } | |
- } | |
- | |
- if ( isString( requireId ) ) { | |
- monitor( requireId ); | |
- } | |
- else { | |
- each( | |
- requireId, | |
- function ( id ) { | |
- monitor( id ); | |
- } | |
- ); | |
- } | |
- | |
- // 包含相对id时,直接抛出错误 | |
- if ( invalidIds.length > 0 ) { | |
- throw new Error( | |
- '[REQUIRE_FATAL]Relative ID is not allowed in global require: ' | |
- + invalidIds.join( ', ' ) | |
- ); | |
- } | |
- } | |
- // #end-ignore | |
- | |
- /** | |
- * 模块id正则 | |
- * | |
- * @const | |
- * @inner | |
- * @type {RegExp} | |
- */ | |
- var MODULE_ID_REG = /^[-_a-z0-9\.]+(\/[-_a-z0-9\.]+)*$/i; | |
- | |
- /** | |
- * 解析id,返回带有module和resource属性的Object | |
- * | |
- * @inner | |
- * @param {string} id 标识 | |
- * @return {Object} | |
- */ | |
- function parseId( id ) { | |
- var segs = id.split( '!' ); | |
- | |
- if ( MODULE_ID_REG.test( segs[ 0 ] ) ) { | |
- return { | |
- module : segs[ 0 ], | |
- resource : segs[ 1 ] || '' | |
- }; | |
- } | |
- | |
- return null; | |
- } | |
- | |
- /** | |
- * 基于map配置项的id映射 | |
- * | |
- * @inner | |
- * @param {string} id 模块id | |
- * @param {string} baseId 当前环境的模块id | |
- * @return {string} | |
- */ | |
- function mappingId( id, baseId ) { | |
- each( | |
- mappingIdIndex, | |
- function ( item ) { | |
- if ( item.reg.test( baseId ) ) { | |
- | |
- each( item.v, function ( mapData ) { | |
- var key = mapData.k; | |
- var rule = createPrefixRegexp( key ); | |
- | |
- if ( rule.test( id ) ) { | |
- id = id.replace( key, mapData.v ); | |
- return false; | |
- } | |
- } ); | |
- | |
- return false; | |
- } | |
- } | |
- ); | |
- | |
- return id; | |
- } | |
- | |
- /** | |
- * 将对象数据转换成数组,数组每项是带有k和v的Object | |
- * | |
- * @inner | |
- * @param {Object} source 对象数据 | |
- * @return {Array.<Object>} | |
- */ | |
- function kv2List( source ) { | |
- var list = []; | |
- for ( var key in source ) { | |
- if ( source.hasOwnProperty( key ) ) { | |
- list.push( { | |
- k: key, | |
- v: source[ key ] | |
- } ); | |
- } | |
- } | |
- | |
- return list; | |
- } | |
- | |
- // 感谢requirejs,通过currentlyAddingScript兼容老旧ie | |
- // | |
- // For some cache cases in IE 6-8, the script executes before the end | |
- // of the appendChild execution, so to tie an anonymous define | |
- // call to the module name (which is stored on the node), hold on | |
- // to a reference to this node, but clear after the DOM insertion. | |
- var currentlyAddingScript; | |
- var interactiveScript; | |
- | |
- /** | |
- * 获取当前script标签 | |
- * 用于ie下define未指定module id时获取id | |
- * | |
- * @inner | |
- * @return {HTMLDocument} | |
- */ | |
- function getCurrentScript() { | |
- if ( currentlyAddingScript ) { | |
- return currentlyAddingScript; | |
- } | |
- else if ( | |
- interactiveScript | |
- && interactiveScript.readyState == 'interactive' | |
- ) { | |
- return interactiveScript; | |
- } | |
- else { | |
- var scripts = document.getElementsByTagName( 'script' ); | |
- var scriptLen = scripts.length; | |
- while ( scriptLen-- ) { | |
- var script = scripts[ scriptLen ]; | |
- if ( script.readyState == 'interactive' ) { | |
- interactiveScript = script; | |
- return script; | |
- } | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * 向页面中插入script标签 | |
- * | |
- * @inner | |
- * @param {HTMLScriptElement} script script标签 | |
- */ | |
- function appendScript( script ) { | |
- currentlyAddingScript = script; | |
- | |
- var doc = document; | |
- (doc.getElementsByTagName('head')[0] || doc.body).appendChild( script ); | |
- | |
- currentlyAddingScript = null; | |
- } | |
- | |
- /** | |
- * 创建id前缀匹配的正则对象 | |
- * | |
- * @inner | |
- * @param {string} prefix id前缀 | |
- * @return {RegExp} | |
- */ | |
- function createPrefixRegexp( prefix ) { | |
- return new RegExp( '^' + prefix + '(/|$)' ); | |
- } | |
- | |
- /** | |
- * 判断对象是否数组类型 | |
- * | |
- * @inner | |
- * @param {*} obj 要判断的对象 | |
- * @return {boolean} | |
- */ | |
- function isArray( obj ) { | |
- return obj instanceof Array; | |
- } | |
- | |
- /** | |
- * 判断对象是否函数类型 | |
- * | |
- * @inner | |
- * @param {*} obj 要判断的对象 | |
- * @return {boolean} | |
- */ | |
- function isFunction( obj ) { | |
- return typeof obj == 'function'; | |
- } | |
- | |
- /** | |
- * 判断是否字符串 | |
- * | |
- * @inner | |
- * @param {*} obj 要判断的对象 | |
- * @return {boolean} | |
- */ | |
- function isString( obj ) { | |
- return typeof obj == 'string'; | |
- } | |
- | |
- /** | |
- * 循环遍历数组集合 | |
- * | |
- * @inner | |
- * @param {Array} source 数组源 | |
- * @param {function(Array,Number):boolean} iterator 遍历函数 | |
- */ | |
- function each( source, iterator ) { | |
- if ( isArray( source ) ) { | |
- for ( var i = 0, len = source.length; i < len; i++ ) { | |
- if ( iterator( source[ i ], i ) === false ) { | |
- break; | |
- } | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * 创建数组字符数逆序排序函数 | |
- * | |
- * @inner | |
- * @param {string} property 数组项对象名 | |
- * @return {Function} | |
- */ | |
- function createDescSorter( property ) { | |
- property = property || 'k'; | |
- | |
- return function ( a, b ) { | |
- var aValue = a[ property ]; | |
- var bValue = b[ property ]; | |
- | |
- if ( bValue == '*' ) { | |
- return -1; | |
- } | |
- | |
- if ( aValue == '*' ) { | |
- return 1; | |
- } | |
- | |
- return bValue.length - aValue.length; | |
- }; | |
- } | |
- | |
- // 暴露全局对象 | |
- global.define = define; | |
- global.require = require; | |
-})( this ); | |
diff --git a/src/common/tpl-deploy.js b/src/common/tpl-deploy.js | |
deleted file mode 100644 | |
index 6581421..0000000 | |
--- a/src/common/tpl-deploy.js | |
+++ /dev/null | |
@@ -1,44 +0,0 @@ | |
-/** | |
- * DSP | |
- * Copyright 2013 Baidu Inc. All rights reserved. | |
- * | |
- * @file tpl加载插件 | |
- * @author zhoulianjie([email protected]) | |
- * @date $DATE$ | |
- */ | |
- | |
-define('tpl', function (require) { | |
- return { | |
- loaded: false, | |
- /** | |
- * 加载模板 | |
- * | |
- * @param {string} resourceId 模板资源id, 多个用,分隔 | |
- * @param {function} `require`函数 | |
- * @param {function} load 加载完成后调用 | |
- */ | |
- load: function (resourceId, req, load) { | |
- var url = '/assets/tpl/templates.html'; | |
- var me = this; | |
- if (me.loaded) { | |
- load(true); | |
- return; | |
- } | |
- baidu.ajax.request(url, { | |
- 'method': 'get', | |
- 'noCache': false, | |
- 'onsuccess': function(text) { | |
- load(text.responseText); | |
- me.loaded = true; | |
- }, | |
- 'onfailure': function(){ | |
- if (console && console.log) { | |
- console.log('load tpl failed:' + url); | |
- } | |
- load(true); | |
- } | |
- }); | |
- } | |
- }; | |
-}); | |
- | |
diff --git a/src/common/tpl.js b/src/common/tpl.js | |
index faa3267..f9579b2 100644 | |
--- a/src/common/tpl.js | |
+++ b/src/common/tpl.js | |
@@ -24,15 +24,36 @@ define(function (require) { | |
'method': 'get', | |
'noCache': false, | |
'onsuccess': function(text) { | |
- template.compile(text.responseText); | |
- | |
+ try{ | |
+ template.compile(text.responseText); | |
+ } | |
+ catch(ex){ | |
+ console.log( ex ); | |
+ throw ex; | |
+ } | |
+ | |
var div = document.createElement('DIV'); | |
div.innerHTML = text.responseText.replace(/<img[^>]+/ig, ''); | |
var deps = util.getDepControls(div); | |
- window.require(deps, function(){ | |
- //console.log(+new Date + '--load tpl ' + resourceId) | |
- load(true); | |
- }); | |
+ var moduleIds = []; | |
+ for( var i = 0; i < deps.length; i ++ ) { | |
+ if ( moduleIds.indexOf( deps[ i ] ) === -1 ) { | |
+ moduleIds.push( deps[ i ] ); | |
+ } | |
+ } | |
+ | |
+ // "assets-v20140403T071524Z/b3a4c79f.tpl.html" | |
+ if ( /^assets\-v\d+T\d+Z\/\w{8}\.tpl\.html/.test( url ) ) { | |
+ // 发布模式下,ui模块都已经合并到ria里面去了,不需要require了 | |
+ // 如果require的话,可能导致循环依赖,无法触发load,原因未知 :-( | |
+ load( true ); | |
+ } | |
+ else { | |
+ window.require(moduleIds, function(){ | |
+ //console.log(+new Date + '--load tpl ' + resourceId) | |
+ load( true ); | |
+ }); | |
+ } | |
}, | |
'onfailure': function(){ | |
if (console && console.log) { | |
diff --git a/src/dsp/dsp.js b/src/dsp/dsp.js | |
deleted file mode 100644 | |
index b7c5b86..0000000 | |
--- a/src/dsp/dsp.js | |
+++ /dev/null | |
@@ -1,42 +0,0 @@ | |
-/*************************************************************************** | |
- * | |
- * Copyright (c) 2010 Baidu.com, Inc. All Rights Reserved | |
- * $Id: dsp.js 4196 2011-03-22 08:09:55Z liyubei $ | |
- * | |
- **************************************************************************/ | |
- | |
- | |
- | |
-/** | |
- * dsp/dsp.js ~ 2010/08/31 23:26:25 | |
- * @author zhaolei, erik, leeight([email protected]) | |
- * @version $Revision: 4196 $ | |
- * @description | |
- * 业务公共模块声明 | |
- **/ | |
- | |
-goog.provide('dsp'); | |
- | |
-/** | |
- * @define {string} 编译时间,调试的时候可以用它. | |
- */ | |
-var BUILD_TIME = '@BUILD_TIME@'; | |
- | |
-var BUILD_VERSION = '$Revision: 4196 $'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */ | |
diff --git a/src/dsp/editInfo.js b/src/dsp/editInfo.js | |
deleted file mode 100644 | |
index e83c19f..0000000 | |
--- a/src/dsp/editInfo.js | |
+++ /dev/null | |
@@ -1,180 +0,0 @@ | |
-/* | |
- * | |
- * Copyright 2010 Baidu Inc. All rights reserved. | |
- * | |
- * path: dsp/editInfo.js | |
- * desc: 修改密码功能 | |
- * author: yaofeifei | |
- */ | |
-dsp.profile = { | |
- | |
- config: { | |
- 'authority': 'ADMIN|ASSISTANT|IN_SALER|OUT_SALER|ADOWNER', | |
- 'action': [ | |
- { | |
- location: '/profile/editInfo', | |
- action: 'dsp.editInfo' | |
- } | |
- ], | |
- 'url': { | |
- 'editInfo' : '/account/updateInfo' | |
- } | |
- }, | |
- | |
- /** | |
- * 获取当前page | |
- */ | |
- getPage: function() { | |
- var action = er.controller.currentAction; | |
- var page; | |
- if(action){ | |
- page = action.page; | |
- } else { | |
- if(this.parentPage){ | |
- page = this.parentPage; | |
- } else { | |
- var dom = baidu.g('Main'), | |
- page = ui.util.createPage('', dom); | |
- page.lifePhase = 4; | |
- } | |
- } | |
- this.parentPage = page; | |
- | |
- return page; | |
- }, | |
- | |
- /** | |
- *显示修改密码对话框 | |
- */ | |
- showEditInfo: function() { | |
- var page = this.getPage(); | |
- | |
- var newAction = dsp.util.loadPopup( | |
- 'editInfoPopup', | |
- 'dsp.editInfo', | |
- { | |
- title: dsp.lang.editProfile, | |
- width: 570 | |
- }, | |
- '', | |
- page | |
- ); | |
- }, | |
- | |
- _onPasswordChange: function() { | |
- var page = this.getPage(); | |
- dsp.util.unloadPopup(page, "editInfoPopup"); | |
- // disable action back function | |
- return false; | |
- } | |
-}; | |
-er.controller.addModule(dsp.profile); | |
- | |
-/** | |
-*Action 修改密码 | |
-*/ | |
-dsp.editInfo = function() { | |
- er.FormAction.call(this); | |
- | |
- this.view = 'editInfo'; | |
- | |
- //修改密码的tab状态,0为修改密码,1为修改邮箱 | |
- this.tabStatus = 0; | |
-}; | |
-dsp.editInfo.prototype = { | |
- | |
- initModel: function(argMap, callback) { | |
- this.model.currentEmail = er.context.get("visitor")["email"]; | |
- this.model.tabConfig = [ | |
- { | |
- title: '修改密码' | |
- }, | |
- { | |
- title: '修改邮箱' | |
- } | |
- ]; | |
- callback(); | |
- }, | |
- | |
- afterInit: function(page) { | |
- this.form = page.c('form'); | |
- this.btnSubmit = page.c('form').c('btnSubmit'); | |
- this.btnCancel = page.c('form').c('btnCancel'); | |
- }, | |
- | |
- initBehavior: function(page) { | |
- dsp.editInfo.superClass.initBehavior.call(this, page); | |
- page.c("form").c("tab").onAfterSelect = | |
- baidu.fn.bind(this.toggleBlock, this); | |
- }, | |
- | |
- toggleBlock: function(index) { | |
- var index = parseInt(index, 10); | |
- if(index === 0) { | |
- this.editPassword(); | |
- } else if(index === 1) { | |
- this.editEmail(); | |
- } | |
- }, | |
- | |
- editPassword: function(){ | |
- this.tabStatus = 0; | |
- | |
- baidu.show("editPassword"); | |
- baidu.hide("editEmail"); | |
- | |
- this.form.c("password").enable(); | |
- this.form.c("newPassword").enable(); | |
- this.form.c("verifyPassword").enable(); | |
- | |
- this.form.c("newEmail").disable(); | |
- this.form.c("verifyNewEmail").disable(); | |
- this.form.c("newEmail").hideError(); | |
- this.form.c("verifyNewEmail").hideError(); | |
- | |
- }, | |
- | |
- editEmail: function(){ | |
- this.tabStatus = 1; | |
- | |
- baidu.show("editEmail"); | |
- baidu.hide("editPassword"); | |
- | |
- this.form.c("newEmail").enable(); | |
- this.form.c("verifyNewEmail").enable(); | |
- | |
- this.form.c("password").disable(); | |
- this.form.c("newPassword").disable(); | |
- this.form.c("verifyPassword").disable(); | |
- this.form.c("password").hideError(); | |
- this.form.c("newPassword").hideError(); | |
- this.form.c("verifyPassword").hideError(); | |
- }, | |
- | |
- enterDocumentInternal: function(page){ | |
- this.editPassword(); | |
- }, | |
- | |
- onFormSubmit: function(params) { | |
- var me = this; | |
- Requester.post( | |
- dsp.profile.config.url.editInfo, | |
- params, | |
- baidu.fn.bind(me.onSubmitFinish, me)); | |
- }, | |
- /* | |
- * 提交成功后在本地设置新的邮箱 , 再dsp.util.loadPopup方法中新加的事件接口 | |
- * */ | |
- onAfterSubmitSucceed: function() { | |
- if(this.tabStatus === 0){ return;} | |
- var visitor = er.context.get("visitor"); | |
- visitor["email"] = this.form.c("newEmail").getValue(); | |
- er.context.set("visitor", visitor); | |
- }, | |
- | |
- back: function() { | |
- var dialog = dsp.profile.parentPage.c('editInfoPopup'); | |
- dialog.close(); | |
- } | |
-}; | |
-baidu.inherits(dsp.editInfo, er.FormAction); | |
diff --git a/src/dsp/init.js b/src/dsp/init.js | |
index fe1e296..7e5a612 100644 | |
--- a/src/dsp/init.js | |
+++ b/src/dsp/init.js | |
@@ -9,7 +9,7 @@ | |
define( | |
function (require) { | |
require('tpl!./common.html'); | |
- var Deferred = require('dep/Deferred'); | |
+ var Deferred = require('ajax/Deferred'); | |
var Requester = require('Requester'); | |
var Breadcrumbs = require('./Breadcrumbs'); | |
diff --git a/src/dsp/lang.js b/src/dsp/lang.js | |
deleted file mode 100644 | |
index db4d3c9..0000000 | |
--- a/src/dsp/lang.js | |
+++ /dev/null | |
@@ -1,62 +0,0 @@ | |
-/* | |
- * | |
- * Copyright 2011 Baidu Inc. All rights reserved. | |
- * | |
- * path: dsp/lang.js | |
- * desc: 业务通用语言配置 | |
- * author: zhaolei,erik | |
- * date: $Date: 2011-03-25 20:40:17 +0800 (星期五, 25 三月 2011) $ | |
- */ | |
- | |
-goog.require('dsp'); | |
- | |
-goog.provide('dsp.lang'); | |
- | |
-/** | |
- * 广告位语言配置 | |
- * @enum {string} | |
- */ | |
-dsp.lang = { | |
- 'formOK' : '完成', | |
- 'saveOK' : '保存', | |
- 'formConfirm' : '确定', | |
- 'formCancel' : '返回', | |
- 'formCreate' : '新建', | |
- | |
- 'btnSearch' : '搜索', | |
- 'btnEnable' : '启用', | |
- 'btnDisable' : '停用', | |
- 'btnDelete' : '删除', | |
- 'btnPause' : '暂停', | |
- 'btnModify' : '修改', | |
- 'btnArchive' : '存档', | |
- 'btnStop' : '停用', | |
- 'btnResume' : '恢复', | |
- 'btnDownloadReport' : '下载报告', | |
- 'btnCreateAd' : '新建推广计划', | |
- 'btnAddProduct' : '调用未推广商品', | |
- 'batchSetting' : '批量设置', | |
- 'templateMaterial' : '模板物料', | |
- 'productInfo' : '商品信息', | |
- 'more' : '更多', | |
- | |
- 'labelStatus' : '状态:', | |
- 'labelType' : '类型:', | |
- 'labelSize' : '尺寸:', | |
- 'infoSeparator' : '且', | |
- 'itemPerPage' : '条/页', | |
- 'itemPerPage2' : '每页显示', | |
- 'optional' : '(选填)', | |
- | |
- 'dataLoading' : '加载中...', | |
- 'editProfile' : '修改资料', | |
- 'editPassword' : '修改密码', | |
- 'editEmail' : '修改邮箱', | |
- 'guide' : '新手入门', | |
- 'guideAddSlot' : '创建我的第一个广告位', | |
- 'btnCreateSPeople':'添加标准人群', | |
- 'btnCreateDPeople':'添加自定义人群', | |
- 'btnSharePeople':'共享人群', | |
- | |
- 'deleteConfirm' : '您确定要删除吗?' | |
-}; | |
diff --git a/src/dsp/windowConfig.js b/src/dsp/windowConfig.js | |
index 08628c2..e12998f 100644 | |
--- a/src/dsp/windowConfig.js | |
+++ b/src/dsp/windowConfig.js | |
@@ -46,7 +46,7 @@ define(function (require) { | |
ui.Tip = require('ui/Tip'); | |
ui.ToolTip = require('ui/ToolTip'); | |
ui.InputControl = require('ui/InputControl'); | |
- window.Deferred = require('dep/Deferred'); | |
+ window.Deferred = require('ajax/Deferred'); | |
if (typeof DEBUG === 'undefined') DEBUG = true; | |
if (DEBUG) { | |
//监听Deferred的报错信息 | |
diff --git a/src/entry.js b/src/entry.js | |
index 9876b75..d3f5a12 100644 | |
--- a/src/entry.js | |
+++ b/src/entry.js | |
@@ -1,40 +1 @@ | |
-require.config( { | |
- baseUrl: './src', | |
- paths: { | |
- 'base': 'base', | |
- 'er': 'er', | |
- 'ui': 'ui', | |
- 'tpl': 'common/tpl', | |
- 'js': 'common/js', | |
- 'css': 'common/css', | |
- 'uicss': 'css', | |
- 'dep': '../dep' | |
- }, | |
- packages: [ | |
- { | |
- name: 'echarts', | |
- location: '../dep/echarts/src', | |
- main: 'echarts' | |
- }, | |
- { | |
- name: 'zrender', | |
- location: '../dep/zrender/src', | |
- main: 'zrender' | |
- }, | |
- { | |
- name: 'etpl', | |
- location: '../dep/etpl/src', | |
- main: 'main' | |
- }, | |
- { | |
- name: 'mini-event', | |
- location: '../dep/mini-event/1.0.0/src', | |
- main: 'main' | |
- } | |
- ] | |
-} ); | |
-require(['dsp/windowConfig'], function () { | |
- require(['dsp/init', 'biz/moduleConfig'], function (init){ | |
- init(); | |
- }); | |
-}); | |
\ No newline at end of file | |
+ | |
diff --git a/src/startup/app.js b/src/startup/app.js | |
new file mode 100644 | |
index 0000000..4166773 | |
--- /dev/null | |
+++ b/src/startup/app.js | |
@@ -0,0 +1,46 @@ | |
+/*************************************************************************** | |
+ * | |
+ * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved | |
+ * $Id$ | |
+ * | |
+ **************************************************************************/ | |
+ | |
+ | |
+ | |
+/** | |
+ * src/startup/biz.js ~ 2014/04/03 10:19:24 | |
+ * @author leeight([email protected]) | |
+ * @version $Revision$ | |
+ * @description | |
+ * | |
+ **/ | |
+define(function( require, exports ){ | |
+ function start(){ | |
+ require([ 'dsp/init', 'biz/moduleConfig' ], function( init ){ | |
+ init(); | |
+ }); | |
+ } | |
+ | |
+ exports.start = start; | |
+}); | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+/* vim: set ts=4 sw=4 sts=4 tw=100: */ | |
diff --git a/src/startup/dsp.js b/src/startup/dsp.js | |
new file mode 100644 | |
index 0000000..882c453 | |
--- /dev/null | |
+++ b/src/startup/dsp.js | |
@@ -0,0 +1,38 @@ | |
+/*************************************************************************** | |
+ * | |
+ * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved | |
+ * $Id$ | |
+ * | |
+ **************************************************************************/ | |
+ | |
+ | |
+ | |
+/** | |
+ * src/startup/dsp-app.js ~ 2014/04/03 10:19:35 | |
+ * @author leeight([email protected]) | |
+ * @version $Revision$ | |
+ * @description | |
+ * | |
+ **/ | |
+define({}); | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+/* vim: set ts=4 sw=4 sts=4 tw=100: */ | |
diff --git a/src/startup/ria.js b/src/startup/ria.js | |
new file mode 100644 | |
index 0000000..dca3a83 | |
--- /dev/null | |
+++ b/src/startup/ria.js | |
@@ -0,0 +1,38 @@ | |
+/*************************************************************************** | |
+ * | |
+ * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved | |
+ * $Id$ | |
+ * | |
+ **************************************************************************/ | |
+ | |
+ | |
+ | |
+/** | |
+ * src/startup/ria.js ~ 2014/04/03 10:19:15 | |
+ * @author leeight([email protected]) | |
+ * @version $Revision$ | |
+ * @description | |
+ * | |
+ **/ | |
+define({}); | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+/* vim: set ts=4 sw=4 sts=4 tw=100: */ | |
diff --git a/src/ui/Accordion.js b/src/ui/Accordion.js | |
index d29af6f..5e8ef61 100644 | |
--- a/src/ui/Accordion.js | |
+++ b/src/ui/Accordion.js | |
@@ -21,7 +21,7 @@ goog.require('ui.events'); | |
goog.include('css/ui-accordion.css'); | |
goog.provide('ui.Accordion'); | |
-//require('css!uicss/ui-accordion.css'); | |
+//require('css!./css/ui-accordion.css'); | |
/** | |
* @constructor | |
diff --git a/src/ui/AreaPicker.js b/src/ui/AreaPicker.js | |
index 66cd1d8..d8564cd 100644 | |
--- a/src/ui/AreaPicker.js | |
+++ b/src/ui/AreaPicker.js | |
@@ -8,7 +8,7 @@ | |
* @description | |
**/ | |
define(function (require) { | |
- require('css!uicss/ui-areapicker.css'); | |
+ require('css!./css/ui-areapicker.css'); | |
var areaPickerInfo = require('./areaPickerInfo'); | |
var ui = {}; | |
diff --git a/src/ui/Button.js b/src/ui/Button.js | |
index 6eba9af..8cb498c 100644 | |
--- a/src/ui/Button.js | |
+++ b/src/ui/Button.js | |
@@ -16,7 +16,7 @@ goog.provide('ui.Button'); | |
define(function (require) { | |
- require('css!uicss/ui-button.css'); | |
+ require('css!./css/ui-button.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/ButtonMenu.js b/src/ui/ButtonMenu.js | |
index f9b085d..673ec6f 100644 | |
--- a/src/ui/ButtonMenu.js | |
+++ b/src/ui/ButtonMenu.js | |
@@ -12,7 +12,7 @@ goog.require('ui.Control'); | |
goog.include('css/ui-buttonmenu.css'); | |
goog.provide('ui.ButtonMenu'); | |
-//require('css!uicss/ui-buttonmenu.css'); | |
+//require('css!./css/ui-buttonmenu.css'); | |
/** | |
* 按钮目录控件 | |
diff --git a/src/ui/Calendar.js b/src/ui/Calendar.js | |
index 741582c..55ed838 100644 | |
--- a/src/ui/Calendar.js | |
+++ b/src/ui/Calendar.js | |
@@ -10,7 +10,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-cal.css'); | |
+ require('css!./css/ui-cal.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/CheckBox.js b/src/ui/CheckBox.js | |
index 0415ca5..091f208 100644 | |
--- a/src/ui/CheckBox.js | |
+++ b/src/ui/CheckBox.js | |
@@ -16,7 +16,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-checkbox.css'); | |
+ require('css!./css/ui-checkbox.css'); | |
var ui = {}; | |
ui.BaseBox = require('./BaseBox'); | |
diff --git a/src/ui/ColorPalette.js b/src/ui/ColorPalette.js | |
index fcd2214..e0eec63 100644 | |
--- a/src/ui/ColorPalette.js | |
+++ b/src/ui/ColorPalette.js | |
@@ -16,7 +16,7 @@ goog.require('ui.ColorPicker'); | |
goog.include('css/ui-colorPalette.css'); | |
goog.provide('ui.ColorPalette'); | |
-//require('css!uicss/ui-colorPalette.css'); //FIXME 找不到 | |
+//require('css!./css/ui-colorPalette.css'); //FIXME 找不到 | |
/** | |
* 选色板控件 | |
* @constructor | |
diff --git a/src/ui/ColumnList.js b/src/ui/ColumnList.js | |
index fca9aa4..bea20fb 100644 | |
--- a/src/ui/ColumnList.js | |
+++ b/src/ui/ColumnList.js | |
@@ -25,7 +25,7 @@ goog.provide('ui.ColumnListBase'); | |
goog.provide('ui.XtInclude'); | |
goog.provide('ui.XtExclude'); | |
goog.provide('ui.XtCreate'); | |
-//require('css!uicss/ui-columnList.css'); | |
+//require('css!./css/ui-columnList.css'); | |
//TODO FIXME | |
//columnlist控件需求数据 | |
var PACK_TYPE = { | |
diff --git a/src/ui/ComboBox.js b/src/ui/ComboBox.js | |
index 9679de3..576f284 100644 | |
--- a/src/ui/ComboBox.js | |
+++ b/src/ui/ComboBox.js | |
@@ -12,7 +12,7 @@ | |
//goog.include('css/ui-ComboBox.css'); | |
define(function (require) { | |
- require('css!uicss/ui-combobox.css'); | |
+ require('css!./css/ui-combobox.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/ComboSearchListSelect.js b/src/ui/ComboSearchListSelect.js | |
index 8b6323c..2b02e00 100644 | |
--- a/src/ui/ComboSearchListSelect.js | |
+++ b/src/ui/ComboSearchListSelect.js | |
@@ -8,7 +8,7 @@ | |
* @param {Object} options 参数 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-combosearchlistselect.css'); | |
+ require('css!./css/ui-combosearchlistselect.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/ComboSearchListSelectV2.js b/src/ui/ComboSearchListSelectV2.js | |
index afdb439..8cfc1c2 100644 | |
--- a/src/ui/ComboSearchListSelectV2.js | |
+++ b/src/ui/ComboSearchListSelectV2.js | |
@@ -5,7 +5,7 @@ | |
* @author lixiang05([email protected]) | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-combosearchlistselect.css'); | |
+ require('css!./css/ui-combosearchlistselect.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/ContentList.js b/src/ui/ContentList.js | |
index 36275f5..230cca9 100644 | |
--- a/src/ui/ContentList.js | |
+++ b/src/ui/ContentList.js | |
@@ -16,7 +16,7 @@ goog.require('ui.Button'); | |
goog.include('css/ui-contentlist.css'); | |
goog.provide('ui.ContentList'); | |
-//require('css!uicss/ui-contentlist.css');//FIXME 找不到 | |
+//require('css!./css/ui-contentlist.css');//FIXME 找不到 | |
/** | |
* 已选择的结果框控件 | |
* @constructor | |
diff --git a/src/ui/ControlRepeater.js b/src/ui/ControlRepeater.js | |
index 982d8fd..6ff623a 100644 | |
--- a/src/ui/ControlRepeater.js | |
+++ b/src/ui/ControlRepeater.js | |
@@ -7,7 +7,7 @@ | |
* @extends {ui.InputControl} | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-crepeater.css'); | |
+ require('css!./css/ui-crepeater.css'); | |
var InputControl = require('./InputControl'); | |
var ArrayConverter = require('base/Converter').ArrayConverter; | |
diff --git a/src/ui/CopyableArea.js b/src/ui/CopyableArea.js | |
index 60a03ec..fa1ba2b 100644 | |
--- a/src/ui/CopyableArea.js | |
+++ b/src/ui/CopyableArea.js | |
@@ -7,7 +7,7 @@ | |
* author: zhaolei,erik | |
* date: $Date: 2011-02-26 12:04:36 +0800 (星期六, 26 二月 2011) $ | |
*/ | |
-//require('css!uicss/ui-copyarea.css'); | |
+//require('css!./css/ui-copyarea.css'); | |
/** | |
* 文本输入框组件 | |
* @constructor | |
diff --git a/src/ui/CrowdInfo.js b/src/ui/CrowdInfo.js | |
index 0b1a100..24212c8 100644 | |
--- a/src/ui/CrowdInfo.js | |
+++ b/src/ui/CrowdInfo.js | |
@@ -7,7 +7,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-crowdinfo.css'); | |
+ require('css!./css/ui-crowdinfo.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/CustomList.js b/src/ui/CustomList.js | |
index 9469932..0008c7f 100644 | |
--- a/src/ui/CustomList.js | |
+++ b/src/ui/CustomList.js | |
@@ -10,7 +10,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/CustomList.html'); | |
- require('css!uicss/ui-customList.css'); | |
+ require('css!./css/ui-customList.css'); | |
var ui = {}; | |
ui.Form = require('./Form'); | |
diff --git a/src/ui/DateRangeCalendar.js b/src/ui/DateRangeCalendar.js | |
index 1f43b9f..28e06f6 100644 | |
--- a/src/ui/DateRangeCalendar.js | |
+++ b/src/ui/DateRangeCalendar.js | |
@@ -7,7 +7,7 @@ | |
* 可以选择开始、结束日期 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-drcal.css'); | |
+ require('css!./css/ui-drcal.css'); | |
require('tpl!ui/DateRangeCalendar.html'); | |
var dateFormat = require('./Calendar').PARAM_FORMAT; | |
diff --git a/src/ui/DoubleComplexSelector.js b/src/ui/DoubleComplexSelector.js | |
index bd3cec3..6cd760f 100644 | |
--- a/src/ui/DoubleComplexSelector.js | |
+++ b/src/ui/DoubleComplexSelector.js | |
@@ -6,7 +6,7 @@ | |
define(function (require) { | |
require('tpl!ui/DoubleComplexSelector.html'); | |
- require('css!uicss/ui-doublecomplexselector.css'); | |
+ require('css!./css/ui-doublecomplexselector.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/DoubleSelColumnList.js b/src/ui/DoubleSelColumnList.js | |
index f9edc8b..48609ba 100644 | |
--- a/src/ui/DoubleSelColumnList.js | |
+++ b/src/ui/DoubleSelColumnList.js | |
@@ -10,7 +10,7 @@ | |
* @param {Object} options: 参数 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-doubleSelColumnList.css'); | |
+ require('css!./css/ui-doubleSelColumnList.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/DraggableSchedule.js b/src/ui/DraggableSchedule.js | |
index 0e8b751..edad518 100644 | |
--- a/src/ui/DraggableSchedule.js | |
+++ b/src/ui/DraggableSchedule.js | |
@@ -11,7 +11,7 @@ | |
* @extends {ui.InputControl} | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-draggableschedule.css'); | |
+ require('css!./css/ui-draggableschedule.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/DynamicTreeView.js b/src/ui/DynamicTreeView.js | |
index 142c2f4..b2e9e2d 100644 | |
--- a/src/ui/DynamicTreeView.js | |
+++ b/src/ui/DynamicTreeView.js | |
@@ -19,7 +19,7 @@ goog.require('ui.Panel'); | |
goog.require('ui.TextInput'); | |
goog.include('ui/DynamicTreeView.html'); | |
goog.provide('ui.DynamicTreeView'); | |
-//require('css!uicss/ui-dynamictreeview.css'); | |
+//require('css!./css/ui-dynamictreeview.css'); | |
/** | |
* @constructor | |
* @extends {ui.InputControl} | |
diff --git a/src/ui/Extremum.js b/src/ui/Extremum.js | |
index 5bd7914..e0b94c6 100644 | |
--- a/src/ui/Extremum.js | |
+++ b/src/ui/Extremum.js | |
@@ -9,7 +9,7 @@ | |
* date: 2014.2.18 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-extremum.css'); | |
+ require('css!./css/ui-extremum.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/FixedCalendar.js b/src/ui/FixedCalendar.js | |
index 2d9064c..3d61e3d 100644 | |
--- a/src/ui/FixedCalendar.js | |
+++ b/src/ui/FixedCalendar.js | |
@@ -10,7 +10,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-fcal.css'); | |
+ require('css!./css/ui-fcal.css'); | |
var ui = {}; | |
ui.Button = require('./Button'); | |
diff --git a/src/ui/FormFolder.js b/src/ui/FormFolder.js | |
index 2b116b9..605bcee 100644 | |
--- a/src/ui/FormFolder.js | |
+++ b/src/ui/FormFolder.js | |
@@ -7,7 +7,7 @@ | |
* author: zhaolei,erik | |
* date: $Date: 2011-02-26 12:04:36 +0800 (星期六, 26 二月 2011) $ | |
*/ | |
-//require('css!uicss/ui-formfolder.css'); | |
+//require('css!./css/ui-formfolder.css'); | |
/** | |
* ui.FormFolder | |
* @constructor | |
diff --git a/src/ui/FullSizeDialog.js b/src/ui/FullSizeDialog.js | |
index 43ad5b2..f868ce3 100644 | |
--- a/src/ui/FullSizeDialog.js | |
+++ b/src/ui/FullSizeDialog.js | |
@@ -12,7 +12,7 @@ define(function (require) { | |
var ui = {}; | |
ui.Control = require('./Control'); | |
ui.Mask = require('./Mask'); | |
- //require('css!uicss/ui-dialog.css'); | |
+ //require('css!./css/ui-dialog.css'); | |
/** | |
* 对话框控件 | |
* @constructor | |
diff --git a/src/ui/IndustryPicker.js b/src/ui/IndustryPicker.js | |
index 7a1bfd1..1d027eb 100644 | |
--- a/src/ui/IndustryPicker.js | |
+++ b/src/ui/IndustryPicker.js | |
@@ -8,7 +8,7 @@ | |
* @description 行业选择控件 | |
**/ | |
define(function (require) { | |
- require('css!uicss/ui-industrypicker.css'); | |
+ require('css!./css/ui-industrypicker.css'); | |
var industryPickerInfo = require('./industryPickerInfo'); | |
var ui = {}; | |
diff --git a/src/ui/InterestComposeTool.js b/src/ui/InterestComposeTool.js | |
index d474dc8..6ca86dd 100644 | |
--- a/src/ui/InterestComposeTool.js | |
+++ b/src/ui/InterestComposeTool.js | |
@@ -10,7 +10,7 @@ | |
* @param {Object} options: 参数 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-interest-compose.css'); | |
+ require('css!./css/ui-interest-compose.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/InterestCustom.js b/src/ui/InterestCustom.js | |
index c04d04f..bef60de 100644 | |
--- a/src/ui/InterestCustom.js | |
+++ b/src/ui/InterestCustom.js | |
@@ -12,7 +12,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/InterestCustom.html'); | |
- require('css!uicss/ui-interest-custom.css'); | |
+ require('css!./css/ui-interest-custom.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/InterestSelect.js b/src/ui/InterestSelect.js | |
index 8d7543f..9706799 100644 | |
--- a/src/ui/InterestSelect.js | |
+++ b/src/ui/InterestSelect.js | |
@@ -10,7 +10,7 @@ | |
* @param {Object} options: 参数 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-interest-select.css'); | |
+ require('css!./css/ui-interest-select.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/ItemDel.js b/src/ui/ItemDel.js | |
index fbecc97..e8f6654 100644 | |
--- a/src/ui/ItemDel.js | |
+++ b/src/ui/ItemDel.js | |
@@ -9,7 +9,7 @@ | |
* @param {Object} options | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-item-del.css'); | |
+ require('css!./css/ui-item-del.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/ItemSelect.js b/src/ui/ItemSelect.js | |
index f6b382d..43f8a75 100644 | |
--- a/src/ui/ItemSelect.js | |
+++ b/src/ui/ItemSelect.js | |
@@ -10,7 +10,7 @@ | |
* @param {Object} options: 参数 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-item-select.css'); | |
+ require('css!./css/ui-item-select.css'); | |
var ui = {}; | |
ui.Control = require('./InputControl'); | |
diff --git a/src/ui/ItemSelectTable.js b/src/ui/ItemSelectTable.js | |
index 6c2fb14..4cc40cc 100644 | |
--- a/src/ui/ItemSelectTable.js | |
+++ b/src/ui/ItemSelectTable.js | |
@@ -12,7 +12,7 @@ goog.require('ui.Link'); | |
goog.include('css/ui-item-select.css'); | |
goog.provide('ui.ItemSelectTable'); | |
-//require('css!uicss/ui-item-select.css'); | |
+//require('css!./css/ui-item-select.css'); | |
/** | |
* ui.ItemSelectTable | |
* | |
diff --git a/src/ui/ItemSelector.js b/src/ui/ItemSelector.js | |
index 0d592ee..5c5385c 100644 | |
--- a/src/ui/ItemSelector.js | |
+++ b/src/ui/ItemSelector.js | |
@@ -10,7 +10,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/ItemSelector.html'); | |
- require('css!uicss/ui-interest-select.css'); | |
+ require('css!./css/ui-interest-select.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/KtCreate.js b/src/ui/KtCreate.js | |
index cbc370c..0932968 100644 | |
--- a/src/ui/KtCreate.js | |
+++ b/src/ui/KtCreate.js | |
@@ -11,7 +11,7 @@ goog.require('ui.Select'); | |
goog.include('css/ui-ktCreate.css'); | |
goog.provide('ui.TargetAreaInput'); | |
-//require('css!uicss/ui-ktCreate.css'); | |
+//require('css!./css/ui-ktCreate.css'); | |
/** | |
* ui.TargetAreaInput 输入关键词控件 | |
* | |
diff --git a/src/ui/Mask.js b/src/ui/Mask.js | |
index d3adad7..490021e 100644 | |
--- a/src/ui/Mask.js | |
+++ b/src/ui/Mask.js | |
@@ -16,7 +16,7 @@ goog.provide('ui.Mask'); | |
define(function (require) { | |
- require('css!uicss/ui-mask.css'); | |
+ require('css!./css/ui-mask.css'); | |
var ui = {}; | |
/** | |
diff --git a/src/ui/MiniMultiCalendar.js b/src/ui/MiniMultiCalendar.js | |
index ebd6189..8e3c0dd 100644 | |
--- a/src/ui/MiniMultiCalendar.js | |
+++ b/src/ui/MiniMultiCalendar.js | |
@@ -12,7 +12,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-mmcal.css'); | |
+ require('css!./css/ui-mmcal.css'); | |
var ui = {}; | |
ui.config = require('./config'); | |
diff --git a/src/ui/ModFrame.js b/src/ui/ModFrame.js | |
index 244bb11..e70a18c 100644 | |
--- a/src/ui/ModFrame.js | |
+++ b/src/ui/ModFrame.js | |
@@ -9,7 +9,7 @@ goog.include('css/ui-modframe.css');//FIXME | |
goog.provide('ui.ModFrame'); | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-modframe.css'); | |
+ require('css!./css/ui-modframe.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/MonthView.js b/src/ui/MonthView.js | |
index e3825c7..d1ac729 100644 | |
--- a/src/ui/MonthView.js | |
+++ b/src/ui/MonthView.js | |
@@ -11,7 +11,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-month.css'); | |
+ require('css!./css/ui-month.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/MultiCalendar.js b/src/ui/MultiCalendar.js | |
index 1caad23..663e520 100644 | |
--- a/src/ui/MultiCalendar.js | |
+++ b/src/ui/MultiCalendar.js | |
@@ -10,7 +10,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-mcal.css'); | |
+ require('css!./css/ui-mcal.css'); | |
var ui = {}; | |
ui.Button = require('./Button'); | |
diff --git a/src/ui/MultiColumnTable.js b/src/ui/MultiColumnTable.js | |
index 38829db..b1aea59 100644 | |
--- a/src/ui/MultiColumnTable.js | |
+++ b/src/ui/MultiColumnTable.js | |
@@ -6,7 +6,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-multiColumnTable.css'); | |
+ require('css!./css/ui-multiColumnTable.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/MultiDateRangeCalendar.js b/src/ui/MultiDateRangeCalendar.js | |
index 88a6b8e..7500077 100644 | |
--- a/src/ui/MultiDateRangeCalendar.js | |
+++ b/src/ui/MultiDateRangeCalendar.js | |
@@ -7,7 +7,7 @@ | |
* @extends {ui.InputControl} | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-multiinput.css'); | |
+ require('css!./css/ui-multiinput.css'); | |
var uiUtil = require('./util'); | |
diff --git a/src/ui/MultiInput.js b/src/ui/MultiInput.js | |
index 9603ae4..b63d078 100644 | |
--- a/src/ui/MultiInput.js | |
+++ b/src/ui/MultiInput.js | |
@@ -7,7 +7,7 @@ | |
* @extends {ui.InputControl} | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-multiinput.css'); | |
+ require('css!./css/ui-multiinput.css'); | |
var ui = {}; | |
ui.TextInput = require('./TextInput'); | |
diff --git a/src/ui/Pager.js b/src/ui/Pager.js | |
index 0f6e1f5..08e0172 100644 | |
--- a/src/ui/Pager.js | |
+++ b/src/ui/Pager.js | |
@@ -9,7 +9,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-pager.css'); | |
+ require('css!./css/ui-pager.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/Region.js b/src/ui/Region.js | |
index 2606dba..5f66256 100644 | |
--- a/src/ui/Region.js | |
+++ b/src/ui/Region.js | |
@@ -12,7 +12,7 @@ | |
* @extends {ui.InputControl} | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-region.css'); | |
+ require('css!./css/ui-region.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/RichCalendar.js b/src/ui/RichCalendar.js | |
index e944dd7..b9ac9d2 100644 | |
--- a/src/ui/RichCalendar.js | |
+++ b/src/ui/RichCalendar.js | |
@@ -11,7 +11,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-rcal.css'); | |
+ require('css!./css/ui-rcal.css'); | |
require('tpl!ui/RichCalendar.html'); | |
var ui = {}; | |
diff --git a/src/ui/SearchInfo.js b/src/ui/SearchInfo.js | |
index 10e62a8..aa55735 100644 | |
--- a/src/ui/SearchInfo.js | |
+++ b/src/ui/SearchInfo.js | |
@@ -9,7 +9,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-searchinfo.css'); | |
+ require('css!./css/ui-searchinfo.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/SearchInput.js b/src/ui/SearchInput.js | |
index fa9ac84..7005ecf 100644 | |
--- a/src/ui/SearchInput.js | |
+++ b/src/ui/SearchInput.js | |
@@ -13,7 +13,7 @@ | |
**/ | |
define(function (require) { | |
- require('css!uicss/ui-searchinput.css'); | |
+ require('css!./css/ui-searchinput.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/SearchTree.js b/src/ui/SearchTree.js | |
index 52c5b43..ee8b371 100644 | |
--- a/src/ui/SearchTree.js | |
+++ b/src/ui/SearchTree.js | |
@@ -17,7 +17,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/SearchTree.html'); | |
- require('css!uicss/ui-searchtree.css'); | |
+ require('css!./css/ui-searchtree.css'); | |
var ui = {}; | |
ui.Panel = require('./Panel'); | |
diff --git a/src/ui/Select.js b/src/ui/Select.js | |
index 0307839..1cbc273 100644 | |
--- a/src/ui/Select.js | |
+++ b/src/ui/Select.js | |
@@ -9,7 +9,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-select.css'); | |
+ require('css!./css/ui-select.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/SelectedList.js b/src/ui/SelectedList.js | |
index 2ca2c2f..c5d1db4 100644 | |
--- a/src/ui/SelectedList.js | |
+++ b/src/ui/SelectedList.js | |
@@ -7,7 +7,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/SelectedList.html'); | |
- require('css!uicss/ui-selectedlist.css'); | |
+ require('css!./css/ui-selectedlist.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
ui.Button = require('./Button'); | |
diff --git a/src/ui/Selector.js b/src/ui/Selector.js | |
index d45f8cf..6175652 100644 | |
--- a/src/ui/Selector.js | |
+++ b/src/ui/Selector.js | |
@@ -16,7 +16,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/Selector.html'); | |
- require('css!uicss/ui-selector.css'); | |
+ require('css!./css/ui-selector.css'); | |
var ui = {}; | |
ui.Button = require('./Button'); | |
diff --git a/src/ui/SideBar.js b/src/ui/SideBar.js | |
index 668d0b2..d613901 100644 | |
--- a/src/ui/SideBar.js | |
+++ b/src/ui/SideBar.js | |
@@ -11,7 +11,7 @@ | |
* @export | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-sidebar.css'); | |
+ require('css!./css/ui-sidebar.css'); | |
var ui = {}; | |
ui.Button = require('./Button'); | |
diff --git a/src/ui/SiteCreate.js b/src/ui/SiteCreate.js | |
index b16d010..c185eb2 100644 | |
--- a/src/ui/SiteCreate.js | |
+++ b/src/ui/SiteCreate.js | |
@@ -18,7 +18,8 @@ | |
define(function(require) { | |
- require('tpl!uicss/ui-sitecreate.css'); | |
+ require('css!./css/ui-sitecreate.css'); | |
+ | |
var ui = {}; | |
ui.TextLine = require('./TextLine'); | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/SlideButton.js b/src/ui/SlideButton.js | |
index 3cd32d4..26e81ae 100644 | |
--- a/src/ui/SlideButton.js | |
+++ b/src/ui/SlideButton.js | |
@@ -4,7 +4,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-slidebutton.css'); | |
+ require('css!./css/ui-slidebutton.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/StaticInterest.js b/src/ui/StaticInterest.js | |
index 4e3c705..d0a311b 100644 | |
--- a/src/ui/StaticInterest.js | |
+++ b/src/ui/StaticInterest.js | |
@@ -10,7 +10,7 @@ | |
*/ | |
define(function (require) { | |
require('tpl!ui/StaticInterest.html'); | |
- require('css!uicss/ui-staticInterest.css'); | |
+ require('css!./css/ui-staticInterest.css'); | |
var ui = {}; | |
ui.Form = require('./Form'); | |
diff --git a/src/ui/Tab.js b/src/ui/Tab.js | |
index a3a5deb..a51d4c0 100644 | |
--- a/src/ui/Tab.js | |
+++ b/src/ui/Tab.js | |
@@ -11,7 +11,7 @@ | |
* @param {Object} options 控件初始化参数. | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-tab.css'); | |
+ require('css!./css/ui-tab.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/Table.js b/src/ui/Table.js | |
index b7c3eed..c6b6cb2 100644 | |
--- a/src/ui/Table.js | |
+++ b/src/ui/Table.js | |
@@ -24,7 +24,7 @@ | |
define(function (require) { | |
- require('css!uicss/ui-table.css'); | |
+ require('css!./css/ui-table.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/TargetAreaInput.js b/src/ui/TargetAreaInput.js | |
index 384db0b..7c93e4d 100644 | |
--- a/src/ui/TargetAreaInput.js | |
+++ b/src/ui/TargetAreaInput.js | |
@@ -4,7 +4,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-ktCreate.css'); | |
+ require('css!./css/ui-ktCreate.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/TargetListPanel.js b/src/ui/TargetListPanel.js | |
index c85dc4b..b1a69c1 100644 | |
--- a/src/ui/TargetListPanel.js | |
+++ b/src/ui/TargetListPanel.js | |
@@ -14,7 +14,7 @@ | |
* @param {Object} options 参数 | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-ktCreate.css'); | |
+ require('css!./css/ui-ktCreate.css'); | |
var ui = {}; | |
ui.SearchInput = require('./SearchInput'); | |
diff --git a/src/ui/TargetTableList.js b/src/ui/TargetTableList.js | |
index e6c4e84..523dce2 100644 | |
--- a/src/ui/TargetTableList.js | |
+++ b/src/ui/TargetTableList.js | |
@@ -14,7 +14,7 @@ | |
* @extends {ui.Control} | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-ktCreate.css'); | |
+ require('css!./css/ui-ktCreate.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/TextInput.js b/src/ui/TextInput.js | |
index c6114e5..bbb93e9 100644 | |
--- a/src/ui/TextInput.js | |
+++ b/src/ui/TextInput.js | |
@@ -11,7 +11,7 @@ | |
//goog.include('css/ui-textinput.css'); | |
define(function (require) { | |
- require('css!uicss/ui-textinput.css'); | |
+ require('css!./css/ui-textinput.css'); | |
var ui = {}; | |
ui.InputControl = require('./InputControl'); | |
diff --git a/src/ui/TextLine.js b/src/ui/TextLine.js | |
index f5a0015..6bcd0f7 100644 | |
--- a/src/ui/TextLine.js | |
+++ b/src/ui/TextLine.js | |
@@ -10,7 +10,7 @@ | |
* @param {Object} options 控件初始化参数. | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-textline.css'); | |
+ require('css!./css/ui-textline.css'); | |
var ui = {}; | |
ui.TextInput = require('./TextInput'); | |
diff --git a/src/ui/Tip.js b/src/ui/Tip.js | |
index 24b83f1..c876816 100644 | |
--- a/src/ui/Tip.js | |
+++ b/src/ui/Tip.js | |
@@ -9,7 +9,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-tip.css'); | |
+ require('css!./css/ui-tip.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/ToggleButton.js b/src/ui/ToggleButton.js | |
index 123cc28..45a7ee5 100644 | |
--- a/src/ui/ToggleButton.js | |
+++ b/src/ui/ToggleButton.js | |
@@ -9,7 +9,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-togglebutton.css'); | |
+ require('css!./css/ui-togglebutton.css'); | |
var ui = {}; | |
ui.Control = require('ui/Control'); | |
diff --git a/src/ui/Toolbar.js b/src/ui/Toolbar.js | |
index 804474f..637b82b 100644 | |
--- a/src/ui/Toolbar.js | |
+++ b/src/ui/Toolbar.js | |
@@ -6,7 +6,7 @@ | |
*/ | |
define(function(require) { | |
- require('css!uicss/ui-toolbar.css'); | |
+ require('css!./css/ui-toolbar.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/TreeSelect.js b/src/ui/TreeSelect.js | |
index 9ef938f..4bc01cf 100644 | |
--- a/src/ui/TreeSelect.js | |
+++ b/src/ui/TreeSelect.js | |
@@ -6,7 +6,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-interest-select.css'); | |
+ require('css!./css/ui-interest-select.css'); | |
var ui = {}; | |
ui.Control = require('./Control'); | |
diff --git a/src/ui/TreeView.js b/src/ui/TreeView.js | |
index ffde23b..ccad103 100644 | |
--- a/src/ui/TreeView.js | |
+++ b/src/ui/TreeView.js | |
@@ -9,7 +9,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-treeview.css'); | |
+ require('css!./css/ui-treeview.css'); | |
var ui = {}; | |
ui.Control = require('ui/Control'); | |
diff --git a/src/ui/Uploader.js b/src/ui/Uploader.js | |
index 5b6f2c8..6bf3577 100644 | |
--- a/src/ui/Uploader.js | |
+++ b/src/ui/Uploader.js | |
@@ -11,7 +11,7 @@ | |
* @param {Object} options 控件初始化参数. | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-uploader.css'); | |
+ require('css!./css/ui-uploader.css'); | |
require('tpl!ui/uploader.html'); | |
var ui = {}; | |
diff --git a/src/ui/VtModule.js b/src/ui/VtModule.js | |
index cf8715f..1487636 100644 | |
--- a/src/ui/VtModule.js | |
+++ b/src/ui/VtModule.js | |
@@ -7,7 +7,7 @@ | |
*/ | |
define(function (require) { | |
- require('css!uicss/ui-vtModule.css'); | |
+ require('css!./css/ui-vtModule.css'); | |
//var toolsRequest = require('dsp/data'); | |
diff --git a/src/ui/ctkrTableConfig.js b/src/ui/ctkrTableConfig.js | |
index cbc370c..0932968 100644 | |
--- a/src/ui/ctkrTableConfig.js | |
+++ b/src/ui/ctkrTableConfig.js | |
@@ -11,7 +11,7 @@ goog.require('ui.Select'); | |
goog.include('css/ui-ktCreate.css'); | |
goog.provide('ui.TargetAreaInput'); | |
-//require('css!uicss/ui-ktCreate.css'); | |
+//require('css!./css/ui-ktCreate.css'); | |
/** | |
* ui.TargetAreaInput 输入关键词控件 | |
* | |
diff --git a/src/ui/krCreate.js b/src/ui/krCreate.js | |
index eea4421..329aa69 100644 | |
--- a/src/ui/krCreate.js | |
+++ b/src/ui/krCreate.js | |
@@ -18,7 +18,7 @@ | |
define(function(require) { | |
- require('css!uicss/ui-krcreate.css'); | |
+ require('css!./css/ui-krcreate.css'); | |
var ui = {}; | |
ui.TextLine = require('./TextLine'); | |
ui.InputControl = require('./InputControl'); | |
diff --git a/tool/build.js b/tool/build.js | |
new file mode 100644 | |
index 0000000..617626c | |
--- /dev/null | |
+++ b/tool/build.js | |
@@ -0,0 +1,152 @@ | |
+/*************************************************************************** | |
+ * | |
+ * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved | |
+ * $Id$ | |
+ * | |
+ **************************************************************************/ | |
+ | |
+ | |
+ | |
+/** | |
+ * tool/build.js ~ 2014/04/03 09:53:02 | |
+ * @author leeight([email protected]) | |
+ * @version $Revision$ | |
+ * @description | |
+ * | |
+ **/ | |
+exports.getBuildVersion = function(){ | |
+ var toISOString = function(d) { | |
+ function pad(number) { | |
+ if ( number < 10 ) { | |
+ return '0' + number; | |
+ } | |
+ return number; | |
+ } | |
+ return d.getUTCFullYear() + | |
+ '' + pad( d.getUTCMonth() + 1 ) + | |
+ '' + pad( d.getUTCDate() ) + | |
+ 'T' + pad( d.getUTCHours() ) + | |
+ '' + pad( d.getUTCMinutes() ) + | |
+ '' + pad( d.getUTCSeconds() ) + | |
+ 'Z'; | |
+ }; | |
+ | |
+ var version = 'v' + toISOString(new Date()); | |
+ | |
+ return version; | |
+}; | |
+ | |
+function negative( array ) { | |
+ return array.map(function( item ){ | |
+ return '!' + item; | |
+ }); | |
+} | |
+ | |
+exports.getCombineConfig = function(){ | |
+ var ria = [ 'er/*', 'base/*', 'Requester', 'Validator', 'ui/*', 'tpl', 'css' ]; | |
+ var config = { | |
+ 'startup/ria': { | |
+ 'files': [ | |
+ ria, | |
+ negative( exports.getExcludedUIs() ) | |
+ ] | |
+ }, | |
+ 'startup/dsp': { | |
+ 'files': [ | |
+ 'dsp/**', | |
+ negative( ria ), | |
+ negative( [ 'etpl/*', 'mini-event/*', 'dep/*' ] ), | |
+ ] | |
+ }, | |
+ 'startup/app': { | |
+ 'files': [ | |
+ 'biz/**', | |
+ '!biz/demo/**', | |
+ negative( ria ), | |
+ negative( [ | |
+ 'etpl/*', 'mini-event/*', 'dep/*', 'zrender/**', | |
+ 'dsp/*' | |
+ ] ) | |
+ ] | |
+ } | |
+ } | |
+ return config; | |
+}; | |
+ | |
+/** | |
+ * 这些都是非标准的amd模块,项目中没有用到 | |
+ * 因此在build的阶段,先排除了 | |
+ */ | |
+exports.getExcludedUIs = function(){ | |
+ var excludeUI = [ | |
+ 'SimpleSelector', | |
+ 'SiteSelect', | |
+ 'StatusButton', | |
+ 'SummaryInfo', | |
+ 'Support', | |
+ 'Tracer', | |
+ 'VideoUploader', | |
+ 'Accordion', | |
+ 'BatchUploader', | |
+ 'BoxGroup', | |
+ 'BreadCrumb', | |
+ 'ButtonMenu', | |
+ 'ColorPalette', | |
+ 'ColumnList', | |
+ 'ContentList', | |
+ 'CopyableArea', | |
+ 'ColorPicker', | |
+ 'Crumb', | |
+ 'ctkrTableConfig', | |
+ 'Dialog.Interest', | |
+ 'DynamicTreeView', | |
+ 'FileListUploader', | |
+ 'FormFolder', | |
+ 'FormSwitch', | |
+ 'FormTab', | |
+ 'ItemGroup', | |
+ 'ItemSelectTable', | |
+ 'KeywordTip', | |
+ 'KtCreate', | |
+ 'LiGroup', | |
+ 'List', | |
+ 'ListInfoShort', | |
+ 'ListView', | |
+ 'MaterialUploader', | |
+ 'MediaUploader', | |
+ 'MultiCalendarWithMini', | |
+ 'Orientation', | |
+ 'OrientInput', | |
+ 'PagableListWithBorderPager', | |
+ 'Period', | |
+ 'PreviewTemplate', | |
+ 'Repeater', | |
+ 'ReportCalendar', | |
+ 'ReportCalendarForClient', | |
+ 'ReportSubmenu', | |
+ 'ResourceEstimateItem', | |
+ 'RichSelector', | |
+ 'Schedule' | |
+ ]; | |
+ return excludeUI; | |
+}; | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+ | |
+/* vim: set ts=4 sw=4 sts=4 tw=100: */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment