Sha256: eb0225a522a097b37557db86398dce909945832141e90812b6ffae601f73a581

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

Spontaneous.AddHomeDialogue = (function($, S, window) {
	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, window);


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta10 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta9 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta8 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta7 application/js/add_home_dialogue.js
spontaneous-0.2.0.beta6 application/js/add_home_dialogue.js