Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
1 lines (1 loc) · 1.67 KB
/
Copy pathmain.js
File metadata and controls
1 lines (1 loc) · 1.67 KB
1
define(function(require,exports,module){var FileUtils=brackets.getModule("file/FileUtils"),ExtensionUtils=brackets.getModule("utils/ExtensionUtils"),DocumentManager=brackets.getModule("document/DocumentManager"),MainViewFactory=brackets.getModule("view/MainViewFactory"),Mustache=brackets.getModule("thirdparty/mustache/mustache"),ConfigViewContent=require("text!htmlContent/Config.html"),_module=module;function ConfigView(doc,$container){this.$container=$container,this.doc=doc,this.json=JSON.parse(this.doc.getText()),this.$view=$(Mustache.render(ConfigViewContent,this.json)),this.$view.css({"background-image":"url(file://"+FileUtils.getNativeModuleDirectoryPath(_module)+"/htmlContent/logo-sm.png)","background-position":"bottom right","background-repeat":"no-repeat"}),$container.append(this.$view)}function _createConfigViewOf(file,pane){var result=new $.Deferred,view=pane.findViewOfFile(file.fullPath);return view?(pane.showView(view),result.resolve(view.getFile())):DocumentManager.getDocumentForPath(file.fullPath).done(function(doc){var view=new ConfigView(doc,pane.$el);pane.addView(view,!0),result.resolve(doc.file)}).fail(function(fileError){result.reject(fileError)}),result.promise()}ConfigView.prototype.getFile=function(){return this.doc.file},ConfigView.prototype.updateLayout=function(){},ConfigView.prototype.destroy=function(){this.$view.remove()};var configViewFactory={canOpenFile:function(fullPath){var filename;return".phcode.json"===fullPath.substr(fullPath.lastIndexOf("/")+1).toLowerCase()},openFile:function(file,pane){return _createConfigViewOf(file,pane)}};ExtensionUtils.loadStyleSheet(module,"styles/styles.css"),MainViewFactory.registerViewFactory(configViewFactory)});