Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: zhizhangchen/brackets
...
head fork: zhizhangchen/brackets
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 28, 2013
yunpeng dynamically loading tizen apis 2042f3a
@zhizhangchen Merge pull request #6 from ypzhao/cloud-new
dynamically loading tizen apis
070355a
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) {

No commit comments for this range

Something went wrong with that request. Please try again.