Skip to content

Commit

Permalink
#25 toggle selection button
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuque committed Feb 4, 2014
1 parent 59eb19e commit db2570c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 4 additions & 1 deletion inner/js/selection/selection-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ if (!window.mobmap) { window.mobmap={}; }

this.fireNewSession();
this.currentSelectionSession = new mobmap.RectSelectionSession();
this.fireAfterNewSession();
},

fireSessionDispose: function() { this.callResponders('selWillDisposeCurrentSession'); },
fireNewSession: function() { this.callResponders('selWillStartNewSession'); },
fireAfterNewSession: function() { this.callResponders('selDidStartNewSession'); },

callResponders: function(methodName, arg1, arg2) {
var required = SelectionControllerResponderMethodList[methodName] || false;
Expand All @@ -70,7 +72,8 @@ if (!window.mobmap) { window.mobmap={}; }
var SelectionControllerResponderMethodList = {
// name | required
selWillDisposeCurrentSession : false,
selWillStartNewSession : false
selWillStartNewSession : false,
selDidStartNewSession : false
};

aGlobal.mobmap.SelectionController = SelectionController;
Expand Down
20 changes: 17 additions & 3 deletions inner/js/ui/edit-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (!window.mobmap) { window.mobmap={}; }

this.groupColumnMap = {};
this.addPresetColumns();
this.addSelectionButtons('sel');
this.selectionButtonNameMap = this.addSelectionButtons('sel');
}

MobmapEditToolBar.prototype = {
Expand Down Expand Up @@ -57,6 +57,8 @@ if (!window.mobmap) { window.mobmap={}; }
targetCol.appendChild(btnObj.element);
this.observeSelectionButton(btnObj);
}

return generatedButtonMap;
},

observeSelectionButton: function (btnObj) {
Expand Down Expand Up @@ -112,8 +114,8 @@ if (!window.mobmap) { window.mobmap={}; }
},

// Responder methods for controller
selWillStartNewSession: function(selController) {
var currentType = SelectionSessionType.Unknown;
selDidStartNewSession: function(selController) {
var currentType = mobmap.SelectionSessionType.Unknown;
var sess = selController.getCurrentSession();
if (sess) {
currentType = sess.getType();
Expand All @@ -123,7 +125,19 @@ if (!window.mobmap) { window.mobmap={}; }
},

updateSelectionButtonsState: function(currentSessionType) {
var sel_name = null;
switch(currentSessionType) {
case mobmap.SelectionSessionType.Rect: sel_name = 'sel_rect'; break;
}

var setButtonNames = ['sel_rect'];
var len = setButtonNames.length;
for (var i = 0;i < len;++i) {
var targetName = setButtonNames[i];
var btn = this.selectionButtonNameMap[targetName];
console.log(targetName , sel_name)
btn.setSelectedStyle(targetName === sel_name);
}
}
};

Expand Down

0 comments on commit db2570c

Please sign in to comment.