Sha256: e16cbe8b0875268571dfbae52b4470248a2075d98100384649e031e1713cbf92

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

Spontaneous.AddHomeDialogue = (function($, S) {
	var dom = S.Dom, Dialogue = Spontaneous.Dialogue;

	var AddHomeDialogue = new JS.Class(Dialogue, {
		initialize: function(types) {
			this.types = types;
		},
		title: function() {
			return "Create site home page";
		},
		width: function() {
			return '50%';
		},
		buttons: function() {
			var btns = {};
			btns["Create"] = this.create_home.bind(this);
			return btns;
		},

		uid: function() {
			return this.content.uid() + '!editing';
		},
		create_home: function() {
			if (this.type) {
				S.Ajax.post('/site/home', {'type':this.type.schema_id}, this.home_created.bind(this));
			}
		},
		home_created: function(data) {
			window.location.href = S.Ajax.namespace
		},
		select_type: function(type) {
			this.type = type;
		},
		body: function() {
			var editing = dom.div('#create-home-dialogue'), outer = dom.div(), instructions = dom.p('.instructions'),
				types = this.types, __dialogue = this;
			instructions.html("You don't have a home page. Please choose a type below and hit <span class=\"button\">Create</span> to add one")
			$.each(types, function(i, type) {
				if (type.is_page()) {
					var d = dom.div('.type').text(type.title).click(function() {
						$('.type', outer).removeClass('selected');
						__dialogue.select_type(type);
						$(this).addClass('selected');;
					});
					outer.append(d)
				}
			});
			editing.append(instructions, outer)
			return editing;
		},
		cancel_button: function() {
			return false;
		},
	});
	return AddHomeDialogue;
})(jQuery, Spontaneous);


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta5 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta4 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta3 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta2 application/js/add_home_dialogue.js