Sha256: e9e301bce7b5513612bcf41712caaef007276c08f781af9f36ffa4cdbbaf2bb8
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
CodeSync.plugins.ModeSelector = Backbone.View.extend className: "config-select mode-selector" events: "change select" : "onSelect" initialize: (options={})-> @editor = options.editor @modes = @editor.modes @modes.on "reset", @render, @ @editor.on "change:mode", (modeModel, modeId)=> @setValue(modeId) Backbone.View::initialize.apply(@, arguments) onSelect: ()-> selected = @$('select').val() mode = @modes.get(selected) @editor.setMode(mode) setValue: (val)-> @$('select').val(val) hideLabel: ()-> @$('label').hide() showLabel: ()-> @$('label').show() render: ()-> options = "" for mode in @modes.models options += "<option value='#{ mode.id }'>#{ mode.get('name') }</option>" @$el.html("<label>Language:</label> <select>#{ options }</select>") @hideLabel() unless @visibleLabel @ CodeSync.plugins.ModeSelector.setup = (editor)-> v = @views.modeSelector = new CodeSync.plugins.ModeSelector({editor}) @$('.toolbar-wrapper').append v.render().el editor.on "document:loaded", (doc)-> v.setValue(doc.get('mode'))
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
code_sync-0.6.7 | lib/assets/javascripts/code_sync/editor/plugins/mode_selector.coffee |