Skip to content

Instantly share code, notes, and snippets.

@vasnake vasnake/1 meapp.js
Last active Dec 31, 2015

Embed
What would you like to do?
This dojo module (meapp.js) will be rewrited to CoffeeScript. Practical example.
// deprecated. using meapp.coffee now
console.log('meapp enter');
var vappFactory = null;
define(
["dojo/_base/declare", "dojo/dom", 'dojo/has',
"vs/mpvlib"],
function(declare, dom, has, mpvlib) {
console.log('meapp dojo/define. define app classes');
try {vslib.log('try vslib');} catch(ex) {vslib = new mpvlib();}
vslib.log('vs.mpvlib declare vappFactory');
vappFactory = {
constructor: function(args) {
vslib.log('vs.meapp constructor');
declare.safeMixin(this, args);
},
//Create menu of editor options
createEditorMenu : function createEditorMenu() {
require(
["dijit/Menu",
"dijit/MenuItem",
"dijit/CheckedMenuItem",
"dijit/MenuSeparator",
"dijit/PopupMenuItem",
"dojo/domReady!"],
dojo.hitch(this, function(Menu, MenuItem, CheckedMenuItem, MenuSeparator, PopupMenuItem){
this.log("createEditorMenu");
// editor menu
var menu = new dijit.DropDownMenu({
style : "display: none;"
});
var menuItem = new dijit.MenuItem({
label : "Шаблоны",
iconClass : "dijitIconSearch",
onClick : function() {
console.log("editor menu, templates menuitem onclick. ", arguments);
navigateStack('editPanel');
}
});
menu.addChild(menuItem);
// tables submenu
var tabsmenu = new Menu();
tabsmenu.addChild(new MenuItem({
label: "Отключающие устройства",
iconClass : "dijitFolderOpened",
onClick : dojo.hitch(this, function() {
console.log("editor menu, table onclick. ", arguments);
this.loadFCTable("http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/0");
})
}));
tabsmenu.addChild(new MenuItem({
label: "СКЗ",
iconClass : "dijitFolderOpened",
onClick : dojo.hitch(this, function() {
console.log("editor menu, table onclick. ", arguments);
this.loadFCTable("http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/1");
})
}));
tabsmenu.addChild(new MenuItem({
label: "Газопроводы",
iconClass : "dijitFolderOpened",
onClick : dojo.hitch(this, function() {
console.log("editor menu, table onclick. ", arguments);
this.loadFCTable("http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/2");
}) }));
tabsmenu.addChild(new MenuItem({
label: "ГРП",
iconClass : "dijitFolderOpened",
onClick : dojo.hitch(this, function() {
console.log("editor menu, table onclick. ", arguments);
this.loadFCTable("http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/3");
}) }));
menu.addChild(new PopupMenuItem({
label: "Таблицы",
popup: tabsmenu,
iconClass : "dijitFolderOpened"
}));
// create dropdown button to display menu
var menuButton = new dijit.form.DropDownButton({
label : "Редактирование",
id : 'editorDropDownButton',
title : "Шаблоны, таблицы",
dropDown : menu,
iconClass : "dijitFolderOpened"
});
menuButton.startup();
dojo.byId('webmap-toolbar-left').appendChild(menuButton.domNode);
}));
}, // createEditorMenu
//this.loadFCTable("http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/0");
loadFCTable: function(fcUrl) {
this.log("loadFCTable");
console.debug("loadFCTable. fcUrl: ", arguments);
}, // loadFCTable
log: function(str, doalert) { // write app messages to log
vslib.log("vs.meapp." + str, doalert);
} // log
}; // vlibFactory
vslib.log('meapp dojo/declare vs.meapp');
return declare("vs.meapp", null, vappFactory);
}
); // define
console.log('meapp leave');
###
Mapedit app classes.
Author: vasnake@gmail.com
###
console.log "meapp enter"
if vappFactory?
alert "vappFactory defined already!"
else
vappFactory = {}
define(["dojo/_base/declare", "dojo/dom", 'dojo/has', "vs/mpvlib"],
(declare, dom, has, mpvlib) ->
console.log 'meapp dojo/define. define app classes'
try
vslib.log('try vslib')
catch
window.vslib = new mpvlib()
vslib.log('vs.mpvlib declare vappFactory')
vappFactory = { # meapp object factory
# used as: require(["vs/obj/meapp"], function(meapp) { vsapp = new meapp(); ...
constructor: (args) ->
vslib.log('vs.meapp constructor')
declare.safeMixin(this, args)
log: (str, doalert) -> # write app messages to log
vslib.log("vs.meapp.#{str}", doalert);
# this.loadFCTable("http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/0");
loadFCTable: (fcUrl, fcName = '') ->
this.log("loadFCTable")
console.debug("loadFCTable. fcUrl: ", arguments)
# Create editor menu
createEditorMenu : () ->
require(
["dijit/Menu",
"dijit/MenuItem",
"dijit/CheckedMenuItem",
"dijit/MenuSeparator",
"dijit/PopupMenuItem",
"dojo/domReady!"],
dojo.hitch(this,
(Menu, MenuItem, CheckedMenuItem, MenuSeparator, PopupMenuItem) ->
this.log("createEditorMenu")
# tables submenu
subdata = [
{label: "Отключающие устройства", url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/0"},
{label: "СКЗ", url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/1"},
{label: "Газопроводы", url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/2"},
{label: "ГРП", url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/3"}
]
self = this
tabsmenu = new Menu
tabsmenu.addChild new MenuItem {
label: sd.label,
iconClass : "dijitFolderOpened",
fClassUrl: sd.url,
onClick : () ->
console.log("editor menu, table menuitem onclick. ", arguments)
self.loadFCTable(this.fClassUrl, this.label)
} for sd, idx in subdata
# editor menu
menu = new dijit.DropDownMenu { style : "display: none;" }
menu.addChild MenuItem {
label : "Шаблоны",
iconClass : "dijitIconSearch",
onClick : () ->
console.log("editor menu, templates menuitem onclick. ", arguments)
navigateStack('editPanel')
}
menu.addChild new PopupMenuItem {
label: "Таблицы",
popup: tabsmenu,
iconClass : "dijitFolderOpened"
}
# create dropdown button to display menu
menuButton = new dijit.form.DropDownButton {
label : "Редактирование",
id : 'editorDropDownButton',
title : "Шаблоны, таблицы",
dropDown : menu,
iconClass : "dijitFolderOpened"
}
menuButton.startup
dojo.byId('webmap-toolbar-left').appendChild(menuButton.domNode)
) # dojo.hitch
) # require
# createEditorMenu
} # vappFactory
vslib.log('meapp dojo/declare vs.meapp')
# return from define
declare("vs.meapp", null, vappFactory)
# define inner function
) # dojo/define
console.log "meapp leave"
// Generated by CoffeeScript 1.6.3
/*
Mapedit app classes.
Author: vasnake@gmail.com
*/
(function() {
var vappFactory;
console.log("meapp enter");
if (typeof vappFactory !== "undefined" && vappFactory !== null) {
alert("vappFactory defined already!");
} else {
vappFactory = {};
}
define(["dojo/_base/declare", "dojo/dom", 'dojo/has', "vs/mpvlib"], function(declare, dom, has, mpvlib) {
console.log('meapp dojo/define. define app classes');
try {
vslib.log('try vslib');
} catch (_error) {
window.vslib = new mpvlib();
}
vslib.log('vs.mpvlib declare vappFactory');
vappFactory = {
constructor: function(args) {
vslib.log('vs.meapp constructor');
return declare.safeMixin(this, args);
},
log: function(str, doalert) {
return vslib.log("vs.meapp." + str, doalert);
},
loadFCTable: function(fcUrl, fcName) {
if (fcName == null) {
fcName = '';
}
this.log("loadFCTable");
return console.debug("loadFCTable. fcUrl: ", arguments);
},
createEditorMenu: function() {
return require(["dijit/Menu", "dijit/MenuItem", "dijit/CheckedMenuItem", "dijit/MenuSeparator", "dijit/PopupMenuItem", "dojo/domReady!"], dojo.hitch(this, function(Menu, MenuItem, CheckedMenuItem, MenuSeparator, PopupMenuItem) {
var idx, menu, menuButton, sd, self, subdata, tabsmenu, _i, _len;
this.log("createEditorMenu");
subdata = [
{
label: "Отключающие устройства",
url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/0"
}, {
label: "СКЗ",
url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/1"
}, {
label: "Газопроводы",
url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/2"
}, {
label: "ГРП",
url: "http://cgis.allgis.org/arcgis/rest/services/edit_Газовая_сеть/FeatureServer/3"
}
];
self = this;
tabsmenu = new Menu;
for (idx = _i = 0, _len = subdata.length; _i < _len; idx = ++_i) {
sd = subdata[idx];
tabsmenu.addChild(new MenuItem({
label: sd.label,
iconClass: "dijitFolderOpened",
fClassUrl: sd.url,
onClick: function() {
console.log("editor menu, table menuitem onclick. ", arguments);
return self.loadFCTable(this.fClassUrl, this.label);
}
}));
}
menu = new dijit.DropDownMenu({
style: "display: none;"
});
menu.addChild(MenuItem({
label: "Шаблоны",
iconClass: "dijitIconSearch",
onClick: function() {
console.log("editor menu, templates menuitem onclick. ", arguments);
return navigateStack('editPanel');
}
}));
menu.addChild(new PopupMenuItem({
label: "Таблицы",
popup: tabsmenu,
iconClass: "dijitFolderOpened"
}));
menuButton = new dijit.form.DropDownButton({
label: "Редактирование",
id: 'editorDropDownButton',
title: "Шаблоны, таблицы",
dropDown: menu,
iconClass: "dijitFolderOpened"
});
menuButton.startup;
return dojo.byId('webmap-toolbar-left').appendChild(menuButton.domNode);
}));
}
};
vslib.log('meapp dojo/declare vs.meapp');
return declare("vs.meapp", null, vappFactory);
});
console.log("meapp leave");
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.