Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #6 from ypzhao/cloud-new

dynamically loading tizen apis
  • Loading branch information...
commit 070355a8b9e3bb34c410ca65eb094dcc74dc329d 2 parents b6d3172 + 2042f3a
@zhizhangchen authored
Showing with 30 additions and 32 deletions.
  1. +30 −32 src/extensions/default/AutoComplete/main.js
View
62 src/extensions/default/AutoComplete/main.js
@@ -53,40 +53,37 @@ define(function (require, exports, module) {
return "file://" + path;
}
+ function _absolutepath(){
+ var absolute_path = FileUtils.getNativeModuleDirectoryPath(module) + "/";
+ return absolute_path;
+ }
/**
* Inject platform namespace and its module APIs
*/
function _injectPlatformNamespace() {
- var platformApis, platform;
-
- platformApis = {
- tizen: ['alarm', 'application', 'bluetooth', 'calendar', 'call',
- 'contact', 'filesystem', 'lbs', 'mediacontent', 'messaging',
- 'nfc', 'systeminfo', 'time', 'power', 'download',
- 'notification']
- };
-
- function _inject(mod) {
- var relPath, apiUrl;
-
- relPath = 'apis/' + platform + '/' + mod+ '.json';
- apiUrl = brackets.getModule("utils/ExtensionUtils")
- .getModuleUrl(module, relPath);
-
- $.getJSON(apiUrl, function (apiObj) {
- if (platform === mod) {
- window[platform] = apiObj;
- return;
- } else if (window[platform]) {
- window[platform][mod] = apiObj;
- }
- });
- }
-
- for (platform in platformApis) {
- _inject(platform);
- platformApis[platform].forEach(_inject);
- }
+ brackets.fs.readdir(_absolutepath() + 'apis/', function(err, platforms) {
+ for(var i in platforms){
+ var platform = platforms[i];
+ window[platform] = {};
+ var platformPath = _absolutepath() + 'apis/' + platform+'/';
+ brackets.fs.readdir(platformPath,function(err, modules) {
+ for (var j in modules){
+ var module = modules[j],
+ modulePath = _extensionUrl() + 'apis/' + this + '/' + module;
+ module = module.substring(0, module.lastIndexOf("."));
+ $.getJSON(modulePath, function (moduleObj) {
+ var platform = this.platform, module = this.module;
+ if (platform === module) {
+ $.extend(window[platform], moduleObj);
+ return;
+ } else if (window[platform]) {
+ window[platform][module] = moduleObj;
+ }
+ }.bind({platform:this, module:module}));
+ }
+ }.bind(platform));
+ }
+ });
}
/**
@@ -102,8 +99,9 @@ define(function (require, exports, module) {
cmEditor = curEditor._codeMirror;
var extraKeys = cmEditor.getOption("extraKeys");
- if (extraKeys)
- extraKeys["Ctrl-P"] = "autocomplete";
+
+ if (extraKeys)
+ extraKeys["Ctrl-P"] = "autocomplete";
onKeyEventBase = cmEditor.getOption("onKeyEvent");
cmEditor.setOption("onKeyEvent", function (cm, ev) {
Please sign in to comment.
Something went wrong with that request. Please try again.