<commit_before>var Backbone = require("backbone");
var _ = require("underscore");
require("queue.less");
var BaseViews = require("./../views");
var Models = require("./../models");
var DragHelper = require("edit_channel/utils/drag_drop");
var dialog = require("edit_channel/utils/dialog");

/* Loaded when user clicks clipboard button below navigation bar */
var Queue = BaseViews.BaseWorkspaceView.extend({
	template: require("./hbtemplates/queue.handlebars"),
	clipboard_queue:null,
	trash_queue:null,
	clipboard_selector: "#clipboard-queue",

	initialize: function(options) {
		_.bindAll(this, 'toggle_queue', 'open_queue', 'close_queue');
		this.clipboard_root = options.clipboard_root;
		this.trash_root = options.trash_root;
		this.collection = options.collection;
		this.render();
		window.workspace_manager.set_queue_view(this);
	},
	render: function() {
		this.$el.html(this.template());
		this.clipboard_queue = new ClipboardList({
			collection: this.collection,
			model: this.clipboard_root,
			el: this.$(this.clipboard_selector),
			add_controls : true,
			container: this,
			content_node_view:null
		});
		this.handle_checked();
	},
	events: {
		'click .queue-button' : 'toggle_queue'
	},
	toggle_queue: function(){
		(this.$("#queue").hasClass("closed")) ? this.open_queue() : this.close_queue();
	},
	open_queue:function(){
		this.$("#queue").removeClass("closed").addClass("opened");
	},
	close_queue:function(){
		this.$("#queue").removeClass("opened").addClass("closed");
	},
	handle_checked:function(){
		this.clipboard_queue.handle_checked();
	},
	move_items:function(){
		var list = this.get_selected(true);
		var move_collection = new Models.ContentNodeCollection();
		/* Create list of nodes to move */
		for(var i = 0; i < list.length; i++){
			var model = list[i].model;
			model.view = list[i];
			move_collection.add(model);
		}
		this.move_content(move_collection);
	}
});

var ClipboardList = BaseViews.BaseWorkspaceListView.extend({
	template: require("./hbtemplates/queue_list.handlebars"),
	selectedClass: "queue-selected",
	default_item: ".queue-list-wrapper >.content-list >.default-item, >.content-list >.default-item",
	list_selector: ".queue-list-wrapper >.content-list, >.content-list",
	badge_selector: ".queue-badge",
	tab_selector: "#switch_to_queue",
	list_wrapper_selector: "#clipboard-queue",
	item_class_selector: ".queue-item",
	'id': function() {
		return "list_" + this.model.get("id");
	},
	initialize: function(options) {
		_.bindAll(this, 'delete_items', 'edit_items', 'handle_drop', 'move_items', 'update_badge_count');
		this.bind_workspace_functions();
		this.collection = options.collection;
		this.container = options.container;
		this.add_controls = options.add_controls;
		this.content_node_view = options.content_node_view;
		this.render();
		this.container.lists.push(this);
		this.listenTo(this.model, 'change:children', this.update_views);
		this.listenTo(this.model, 'change:metadata', this.update_badge_count);
	},
	render: function() {
		this.$el.html(this.template({
			is_clipboard : true,
			add_controls : this.add_controls,
			id: this.model.id
		}));
		window.workspace_manager.put_list(this.model.get("id"), this);
		this.$(this.default_item).text("Loading...");
		var self = this;
		self.make_droppable();
		this.retrieve_nodes(this.model.get("children")).then(function(fetchedCollection){
			self.$(self.default_item).text("No items found.");
			fetchedCollection.sort_by_order();
			self.load_content(fetchedCollection);
			self.refresh_droppable();
		});
	},
	events: {
		'change .select_all' : 'check_all',
		'click .delete_items' : 'delete_items',
		'click .edit_items' : 'edit_items',
		'click .move_items' : 'move_items',
		'click .create_new_content' : 'add_topic',
		'click .upload_files_button': 'add_files',
		'click .import_content' : 'import_content',
		'click .create_exercise_button' : 'add_exercise'
	},
	update_badge_count:function(){
	  	var self = this;
	  	if(this.add_controls){
	  		self.model.fetch({
	  			success:function(root){
	  				$(self.badge_selector).html(root.get("metadata").resource_count);
	  			}
	  		});
		}
	},
	delete_items:function(){
		var self = this;

        dialog.dialog("WARNING", "Are you sure you want to delete these selected items?", {
            "CANCEL":function(){},
            "DELETE ITEMS": function(){
				self.delete_selected();
				self.$(".select_all").attr("checked", false);
            },
        }, null);
	},
	handle_if_empty:function(){
		this.$(this.default_item).css("display", (this.model.get("children").length > 0) ? "none" : "block");
		this.update_badge_count();
	},
	handle_checked:function(){
		var checked_count = this.$el.find(".queue-selected").length;
		this.$(".queue-disable-none-selected *").prop("disabled", checked_count === 0);
		(checked_count > 0)? this.$(".queue-disable-none-selected *").removeClass("disabled") : this.$(".queue-disable-none-selected *").addClass("disabled");
	},
	create_new_view:function(model){
		var item_view = new ClipboardItem({
				containing_list_view: this,
				model: model,
				container : this.container
			});
		this.views.push(item_view);
		return item_view;
	},
	delete_items:function(){
		var self = this;
        dialog.dialog("WARNING", "Are you sure you want to delete these selected items PERMANENTLY? Changes cannot be undone!", {
            "CANCEL":function(){},
            "DELETE ITEMS": function(){
				self.delete_items_permanently("Deleting Content...");
				self.$(".select_all").attr("checked", false);
            },
        }, null);
	},
	edit_items:function(){
		this.container.edit_selected();
	},
	move_items:function(){
		this.container.move_items();
	}
	/* Implementation for creating copies of nodes when dropped onto clipboard */
	// handle_drop:function(collection){
	// 	this.$(this.default_item).css("display", "none");
	// 	console.log(this.model)
	// 	return collection.duplicate(this.model);
 // 	},
});

var ClipboardItem = BaseViews.BaseWorkspaceListNodeItemView.extend({
	list_selector: "#clipboard_list",
	template: require("./hbtemplates/queue_item.handlebars"),
	selectedClass: "queue-selected",
	expandedClass: "glyphicon-menu-down",
	collapsedClass: "glyphicon-menu-up",
	className: "queue-item",
	getToggler: function () { return this.$("#menu_toggle_" + this.model.id); },
	getSubdirectory: function () {return this.$("#" + this.id() +"_sub"); },
	'id': function() {
		return this.model.get("id");
	},
	reload:function(model){
		this.model.set(model.attributes);
		this.$el.find(">label .title").text(this.model.get("title"));
		this.$el.find(">label .badge").text(this.model.get("metadata").resource_count);
	},
	handle_checked:function(){
		this.checked = this.$el.find(">input[type=checkbox]").is(":checked");
		(this.checked)? this.$el.addClass(this.selectedClass) : this.$el.removeClass(this.selectedClass);
		this.container.handle_checked();
	},

	initialize: function(options) {
		_.bindAll(this, 'delete_content');
		this.bind_workspace_functions();
		this.containing_list_view = options.containing_list_view;
		this.container = options.container;
		this.render();
	},
	render: function(renderData) {
		this.$el.html(this.template({
			node:this.model.toJSON(),
			isfolder: this.model.get("kind") === "topic",
			is_clipboard : true,
			checked: this.checked
		}));
		this.handle_checked();
		window.workspace_manager.put_node(this.model.get("id"), this);
		this.make_droppable();
	},
	events: {
		'click .delete_content' : 'delete_content',
		'click .tog_folder' : 'toggle',
		'click .edit_content' : 'edit_item',
		'change input[type=checkbox]': 'handle_checked'
	},
	edit_item:function(event){
		event.stopPropagation();
		event.preventDefault();
		this.open_edit(true);
	},
	load_subfiles:function(){
		if(!this.subcontent_view){
			var data = {
				collection: this.containing_list_view.collection,
				el: this.$el.find("#" + this.id() +"_sub"),
				add_controls : false,
				model: this.model,
				container: this.container,
				content_node_view:this
			}
			this.subcontent_view = new ClipboardList(data);
			this.$el.find("#" + this.id() +"_sub").append(this.subcontent_view.el);
		}
	},
	delete_content:function(){
        dialog.dialog("WARNING", "Are you sure you want to PERMANENTLY delete " + this.model.get("title") + "? Changes cannot be undone!", {
            "CANCEL":function(){},
            "DELETE": this.add_to_trash,
        }, null);
	},
	/* Implementation for creating copies of nodes when dropped onto clipboard */
	// handle_drop:function(collection){
	// 	return collection.duplicate(window.workspace_manager.get_queue_view().clipboard_queue.model);
 // 	},
});

module.exports = {
	Queue:Queue
}<commit_msg>Fixed deleting from queue<commit_after>var Backbone = require("backbone");
var _ = require("underscore");
require("queue.less");
var BaseViews = require("./../views");
var Models = require("./../models");
var DragHelper = require("edit_channel/utils/drag_drop");
var dialog = require("edit_channel/utils/dialog");

/* Loaded when user clicks clipboard button below navigation bar */
var Queue = BaseViews.BaseWorkspaceView.extend({
	template: require("./hbtemplates/queue.handlebars"),
	clipboard_queue:null,
	trash_queue:null,
	clipboard_selector: "#clipboard-queue",

	initialize: function(options) {
		_.bindAll(this, 'toggle_queue', 'open_queue', 'close_queue');
		this.clipboard_root = options.clipboard_root;
		this.trash_root = options.trash_root;
		this.collection = options.collection;
		this.render();
		window.workspace_manager.set_queue_view(this);
	},
	render: function() {
		this.$el.html(this.template());
		this.clipboard_queue = new ClipboardList({
			collection: this.collection,
			model: this.clipboard_root,
			el: this.$(this.clipboard_selector),
			add_controls : true,
			container: this,
			content_node_view:null
		});
		this.handle_checked();
	},
	events: {
		'click .queue-button' : 'toggle_queue'
	},
	toggle_queue: function(){
		(this.$("#queue").hasClass("closed")) ? this.open_queue() : this.close_queue();
	},
	open_queue:function(){
		this.$("#queue").removeClass("closed").addClass("opened");
	},
	close_queue:function(){
		this.$("#queue").removeClass("opened").addClass("closed");
	},
	handle_checked:function(){
		this.clipboard_queue.handle_checked();
	},
	move_items:function(){
		var list = this.get_selected(true);
		var move_collection = new Models.ContentNodeCollection();
		/* Create list of nodes to move */
		for(var i = 0; i < list.length; i++){
			var model = list[i].model;
			model.view = list[i];
			move_collection.add(model);
		}
		this.move_content(move_collection);
	}
});

var ClipboardList = BaseViews.BaseWorkspaceListView.extend({
	template: require("./hbtemplates/queue_list.handlebars"),
	selectedClass: "queue-selected",
	default_item: ".queue-list-wrapper >.content-list >.default-item, >.content-list >.default-item",
	list_selector: ".queue-list-wrapper >.content-list, >.content-list",
	badge_selector: ".queue-badge",
	tab_selector: "#switch_to_queue",
	list_wrapper_selector: "#clipboard-queue",
	item_class_selector: ".queue-item",
	'id': function() {
		return "list_" + this.model.get("id");
	},
	initialize: function(options) {
		_.bindAll(this, 'delete_items', 'edit_items', 'handle_drop', 'move_items', 'update_badge_count');
		this.bind_workspace_functions();
		this.collection = options.collection;
		this.container = options.container;
		this.add_controls = options.add_controls;
		this.content_node_view = options.content_node_view;
		this.render();
		this.container.lists.push(this);
		this.listenTo(this.model, 'change:children', this.update_views);
		this.listenTo(this.model, 'change:metadata', this.update_badge_count);
	},
	render: function() {
		this.$el.html(this.template({
			is_clipboard : true,
			add_controls : this.add_controls,
			id: this.model.id
		}));
		window.workspace_manager.put_list(this.model.get("id"), this);
		this.$(this.default_item).text("Loading...");
		var self = this;
		self.make_droppable();
		this.retrieve_nodes(this.model.get("children")).then(function(fetchedCollection){
			self.$(self.default_item).text("No items found.");
			fetchedCollection.sort_by_order();
			self.load_content(fetchedCollection);
			self.refresh_droppable();
		});
	},
	events: {
		'change .select_all' : 'check_all',
		'click .delete_items' : 'delete_items',
		'click .edit_items' : 'edit_items',
		'click .move_items' : 'move_items',
		'click .create_new_content' : 'add_topic',
		'click .upload_files_button': 'add_files',
		'click .import_content' : 'import_content',
		'click .create_exercise_button' : 'add_exercise'
	},
	update_badge_count:function(){
	  	var self = this;
	  	if(this.add_controls){
	  		self.model.fetch({
	  			success:function(root){
	  				$(self.badge_selector).html(root.get("metadata").resource_count);
	  			}
	  		});
		}
	},
	delete_items:function(){
		var self = this;

        dialog.dialog("WARNING", "Are you sure you want to delete these selected items?", {
            "CANCEL":function(){},
            "DELETE ITEMS": function(){
				self.delete_selected();
				self.$(".select_all").attr("checked", false);
            },
        }, null);
	},
	handle_if_empty:function(){
		this.$(this.default_item).css("display", (this.model.get("children").length > 0) ? "none" : "block");
		this.update_badge_count();
	},
	handle_checked:function(){
		var checked_count = this.$el.find(".queue-selected").length;
		this.$(".queue-disable-none-selected *").prop("disabled", checked_count === 0);
		(checked_count > 0)? this.$(".queue-disable-none-selected *").removeClass("disabled") : this.$(".queue-disable-none-selected *").addClass("disabled");
	},
	create_new_view:function(model){
		var item_view = new ClipboardItem({
				containing_list_view: this,
				model: model,
				container : this.container
			});
		this.views.push(item_view);
		return item_view;
	},
	delete_items:function(){
		var self = this;
        dialog.dialog("WARNING", "Are you sure you want to delete these selected items PERMANENTLY? Changes cannot be undone!", {
            "CANCEL":function(){},
            "DELETE ITEMS": function(){
				self.delete_items_permanently("Deleting Content...");
				self.$(".select_all").attr("checked", false);
            },
        }, null);
	},
	edit_items:function(){
		this.container.edit_selected();
	},
	move_items:function(){
		this.container.move_items();
	}
	/* Implementation for creating copies of nodes when dropped onto clipboard */
	// handle_drop:function(collection){
	// 	this.$(this.default_item).css("display", "none");
	// 	console.log(this.model)
	// 	return collection.duplicate(this.model);
 // 	},
});

var ClipboardItem = BaseViews.BaseWorkspaceListNodeItemView.extend({
	list_selector: "#clipboard_list",
	template: require("./hbtemplates/queue_item.handlebars"),
	selectedClass: "queue-selected",
	expandedClass: "glyphicon-menu-down",
	collapsedClass: "glyphicon-menu-up",
	className: "queue-item",
	getToggler: function () { return this.$("#menu_toggle_" + this.model.id); },
	getSubdirectory: function () {return this.$("#" + this.id() +"_sub"); },
	'id': function() {
		return this.model.get("id");
	},
	reload:function(model){
		this.model.set(model.attributes);
		this.$el.find(">label .title").text(this.model.get("title"));
		this.$el.find(">label .badge").text(this.model.get("metadata").resource_count);
	},
	handle_checked:function(){
		this.checked = this.$el.find(">input[type=checkbox]").is(":checked");
		(this.checked)? this.$el.addClass(this.selectedClass) : this.$el.removeClass(this.selectedClass);
		this.container.handle_checked();
	},

	initialize: function(options) {
		_.bindAll(this, 'delete_content');
		this.bind_workspace_functions();
		this.containing_list_view = options.containing_list_view;
		this.container = options.container;
		this.render();
	},
	render: function(renderData) {
		this.$el.html(this.template({
			node:this.model.toJSON(),
			isfolder: this.model.get("kind") === "topic",
			is_clipboard : true,
			checked: this.checked
		}));
		this.handle_checked();
		window.workspace_manager.put_node(this.model.get("id"), this);
		this.make_droppable();
	},
	events: {
		'click .delete_content' : 'delete_content',
		'click .tog_folder' : 'toggle',
		'click .edit_content' : 'edit_item',
		'change input[type=checkbox]': 'handle_checked'
	},
	edit_item:function(event){
		event.stopPropagation();
		event.preventDefault();
		this.open_edit(true);
	},
	load_subfiles:function(){
		if(!this.subcontent_view){
			var data = {
				collection: this.containing_list_view.collection,
				el: this.$el.find("#" + this.id() +"_sub"),
				add_controls : false,
				model: this.model,
				container: this.container,
				content_node_view:this
			}
			this.subcontent_view = new ClipboardList(data);
			this.$el.find("#" + this.id() +"_sub").append(this.subcontent_view.el);
		}
	},
	delete_content:function(){
		var self = this;
        dialog.dialog("WARNING", "Are you sure you want to PERMANENTLY delete " + this.model.get("title") + "? Changes cannot be undone!", {
            "CANCEL":function(){},
            "DELETE": function(){
            	self.add_to_trash()
            }
        }, null);
	},
	/* Implementation for creating copies of nodes when dropped onto clipboard */
	// handle_drop:function(collection){
	// 	return collection.duplicate(window.workspace_manager.get_queue_view().clipboard_queue.model);
 // 	},
});

module.exports = {
	Queue:Queue
}<|endoftext|>


<commit_before>// --------------------------------------------------------------------------------------------------------------------
//
// elb-config.js - config for AWS Elastic Load Balancing
//
// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
// Written by Andrew Chilton <chilts@appsattic.com>
//
// License: http://opensource.org/licenses/MIT
//
// --------------------------------------------------------------------------------------------------------------------

module.exports = {

    ApplySecurityGroupsToLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_ApplySecurityGroupsToLoadBalancer.html',
        defaults : {
            Action : 'ApplySecurityGroupsToLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            SecurityGroups : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    AttachLoadBalancerToSubnets : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_AttachLoadBalancerToSubnets.html',
        defaults : {
            Action : 'AttachLoadBalancerToSubnets'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            Subnets : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    ConfigureHealthCheck : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_ConfigureHealthCheck.html',
        defaults : {
            Action : 'ConfigureHealthCheck'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            HealthyThreshold : {
                name     : 'Healthcheck.HealthyThreshold',
                required : true,
                type     : 'param',
            },
            Interval : {
                name     : 'Healthcheck.Interval',
                required : true,
                type     : 'param',
            },
            Target : {
                name     : 'Healthcheck.Target',
                required : true,
                type     : 'param',
            },
            Timeout : {
                name     : 'Healthcheck.Timeout',
                required : true,
                type     : 'param',
            },
            UnhealthyThreshold : {
                name     : 'Healthcheck.UnhealthyThreshold',
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateAppCookieStickinessPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateAppCookieStickinessPolicy.html',
        defaults : {
            Action : 'CreateAppCookieStickinessPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            CookieName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateLBCookieStickinessPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLBCookieStickinessPolicy.html',
        defaults : {
            Action : 'CreateLBCookieStickinessPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            CookieExpirationPeriod : {
                required : false,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLoadBalancer.html',
        defaults : {
            Action : 'CreateLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            AvailabilityZones : {
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
            Listeners : {
                required : true,
                type     : 'param-array-of-objects',
                setName  : 'Listeners.member',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            SecurityGroups : {
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
            Subnets : {
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    CreateLoadBalancerListeners : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLoadBalancerListeners.html',
        defaults : {
            Action : 'CreateLoadBalancerListeners'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            Listeners : {
                required : true,
                type     : 'param-array-of-objects',
                setName  : 'Listeners.member',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateLoadBalancerPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLoadBalancerPolicy.html',
        defaults : {
            Action : 'CreateLoadBalancerPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            Listeners : {
                // creates Listeners.member.1, Listeners.member.2, ...etc...
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyAttributes : {
                // wanted: AttributeName and AttributeValue for each object
                required : false,
                type     : 'param-array-of-objects',
                setName  : 'PolicyAttributes.member',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
            PolicyTypeName : {
                required : true,
                type     : 'param',
            },
        },
    },

    DeleteLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancer.html',
        defaults : {
            Action : 'DeleteLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
        },
    },

    DeleteLoadBalancerListeners : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancerListeners.html',
        defaults : {
            Action : 'DeleteLoadBalancerListeners'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerPorts : {
                required : true,
                type     : 'param-set',
                prefix   : 'member',
            },
        },
    },

    DeleteLoadBalancerPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancerPolicy.html',
        defaults : {
            Action : 'DeleteLoadBalancerPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
        },
    },

    DeregisterInstancesFromLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeregisterInstancesFromLoadBalancer.html',
        defaults : {
            Action : 'DeregisterInstancesFromLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            // do an array-set instead of an array-of-objects (since it only has one item)
            Instances : {
                name     : 'InstanceId',
                required : true,
                type     : 'param-array-set',
                setName  : 'Instances.member',
            },
        },
    },

    DescribeInstanceHealth : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeInstanceHealth.html',
        defaults : {
            Action : 'DescribeInstanceHealth'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            // do an array-set instead of an array-of-objects (since it only has one item)
            Instances : {
                name     : 'InstanceId',
                required : false,
                type     : 'param-array-set',
                setName  : 'Instances.member',
            },
        },
    },

    DescribeLoadBalancerPolicies : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancerPolicies.html',
        defaults : {
            Action : 'DescribeLoadBalancerPolicies'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : false,
                type     : 'param',
            },
            PolicyNames : {
                required : false,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

    DescribeLoadBalancerPolicyTypes : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancerPolicyTypes.html',
        defaults : {
            Action : 'DescribeLoadBalancerPolicyTypes'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            PolicyTypeNames : {
                required : false,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

    DescribeLoadBalancers : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancers.html',
        defaults : {
            Action : 'DescribeLoadBalancers'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerNames : {
                // LoadBalancerNames.member.1, LoadBalancerNames.member.2, ...etc...
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
            Marker : {
                required : false,
                type     : 'param',
            },
        },
    },

    DetachLoadBalancersFromSubnets : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DetachLoadBalancerFromSubnets.html',
        defaults : {
            Action : 'DetachLoadBalancersFromSubnets'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            Subnets : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    DisableAvailabilityZonesForLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DisableAvailabilityZonesForLoadBalancer.html',
        defaults : {
            Action : 'DisableAvailabilityZonesForLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            AvailabilityZones : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    EnableAvailabilityZonesForLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_EnableAvailabilityZonesForLoadBalancer.html',
        defaults : {
            Action : 'EnableAvailabilityZonesForLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            AvailabilityZones : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    RegisterInstancesWithLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_RegisterInstancesWithLoadBalancer.html',
        defaults : {
            Action : 'RegisterInstancesWithLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            Instances : {
                required : true,
                type     : 'param-array-of-objects',
                setName  : 'Instances.member',
            },
        },
    },

    // check capitalisation
    SetLoadBalancerListenerSslCertificate : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerListenerSSLCertificate.html',
        defaults : {
            Action : 'SetLoadBalancerListenerSSLCertificate'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerPort : {
                required : true,
                type     : 'param',
            },
            SslCertificateId : {
                name     : 'SSLCertificateId',
                required : true,
                type     : 'param',
            },
        },
    },

    SetLoadBalancerPoliciesForBackendServer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerPoliciesForBackendServer.html',
        defaults : {
            Action : 'SetLoadBalancerPoliciesForBackendServer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            InstancePort : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyNames : {
                required : true,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

    SetLoadBalancerPoliciesOfListener : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerPoliciesOfListener.html',
        defaults : {
            Action : 'SetLoadBalancerPoliciesOfListener'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerPort : {
                required : true,
                type     : 'param',
            },
            PolicyNames : {
                required : true,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

};

// --------------------------------------------------------------------------------------------------------------------
<commit_msg>validationerror fixed<commit_after>// --------------------------------------------------------------------------------------------------------------------
//
// elb-config.js - config for AWS Elastic Load Balancing
//
// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
// Written by Andrew Chilton <chilts@appsattic.com>
//
// License: http://opensource.org/licenses/MIT
//
// --------------------------------------------------------------------------------------------------------------------

module.exports = {

    ApplySecurityGroupsToLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_ApplySecurityGroupsToLoadBalancer.html',
        defaults : {
            Action : 'ApplySecurityGroupsToLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            SecurityGroups : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    AttachLoadBalancerToSubnets : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_AttachLoadBalancerToSubnets.html',
        defaults : {
            Action : 'AttachLoadBalancerToSubnets'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            Subnets : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    ConfigureHealthCheck : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_ConfigureHealthCheck.html',
        defaults : {
            Action : 'ConfigureHealthCheck'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            HealthyThreshold : {
                name     : 'Healthcheck.HealthyThreshold',
                required : true,
                type     : 'param',
            },
            Interval : {
                name     : 'Healthcheck.Interval',
                required : true,
                type     : 'param',
            },
            Target : {
                name     : 'Healthcheck.Target',
                required : true,
                type     : 'param',
            },
            Timeout : {
                name     : 'Healthcheck.Timeout',
                required : true,
                type     : 'param',
            },
            UnhealthyThreshold : {
                name     : 'Healthcheck.UnhealthyThreshold',
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateAppCookieStickinessPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateAppCookieStickinessPolicy.html',
        defaults : {
            Action : 'CreateAppCookieStickinessPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            CookieName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateLBCookieStickinessPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLBCookieStickinessPolicy.html',
        defaults : {
            Action : 'CreateLBCookieStickinessPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            CookieExpirationPeriod : {
                required : false,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLoadBalancer.html',
        defaults : {
            Action : 'CreateLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            AvailabilityZones : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
            Listeners : {
                required : true,
                type     : 'param-array-of-objects',
                setName  : 'Listeners.member',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            SecurityGroups : {
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
            Subnets : {
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    CreateLoadBalancerListeners : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLoadBalancerListeners.html',
        defaults : {
            Action : 'CreateLoadBalancerListeners'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            Listeners : {
                required : true,
                type     : 'param-array-of-objects',
                setName  : 'Listeners.member',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
        },
    },

    CreateLoadBalancerPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_CreateLoadBalancerPolicy.html',
        defaults : {
            Action : 'CreateLoadBalancerPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            Listeners : {
                // creates Listeners.member.1, Listeners.member.2, ...etc...
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyAttributes : {
                // wanted: AttributeName and AttributeValue for each object
                required : false,
                type     : 'param-array-of-objects',
                setName  : 'PolicyAttributes.member',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
            PolicyTypeName : {
                required : true,
                type     : 'param',
            },
        },
    },

    DeleteLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancer.html',
        defaults : {
            Action : 'DeleteLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
        },
    },

    DeleteLoadBalancerListeners : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancerListeners.html',
        defaults : {
            Action : 'DeleteLoadBalancerListeners'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerPorts : {
                required : true,
                type     : 'param-set',
                prefix   : 'member',
            },
        },
    },

    DeleteLoadBalancerPolicy : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeleteLoadBalancerPolicy.html',
        defaults : {
            Action : 'DeleteLoadBalancerPolicy'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyName : {
                required : true,
                type     : 'param',
            },
        },
    },

    DeregisterInstancesFromLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DeregisterInstancesFromLoadBalancer.html',
        defaults : {
            Action : 'DeregisterInstancesFromLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            // do an array-set instead of an array-of-objects (since it only has one item)
            Instances : {
                name     : 'InstanceId',
                required : true,
                type     : 'param-array-set',
                setName  : 'Instances.member',
            },
        },
    },

    DescribeInstanceHealth : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeInstanceHealth.html',
        defaults : {
            Action : 'DescribeInstanceHealth'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            // do an array-set instead of an array-of-objects (since it only has one item)
            Instances : {
                name     : 'InstanceId',
                required : false,
                type     : 'param-array-set',
                setName  : 'Instances.member',
            },
        },
    },

    DescribeLoadBalancerPolicies : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancerPolicies.html',
        defaults : {
            Action : 'DescribeLoadBalancerPolicies'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : false,
                type     : 'param',
            },
            PolicyNames : {
                required : false,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

    DescribeLoadBalancerPolicyTypes : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancerPolicyTypes.html',
        defaults : {
            Action : 'DescribeLoadBalancerPolicyTypes'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            PolicyTypeNames : {
                required : false,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

    DescribeLoadBalancers : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DescribeLoadBalancers.html',
        defaults : {
            Action : 'DescribeLoadBalancers'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerNames : {
                // LoadBalancerNames.member.1, LoadBalancerNames.member.2, ...etc...
                required : false,
                type     : 'param-array',
                prefix   : 'member',
            },
            Marker : {
                required : false,
                type     : 'param',
            },
        },
    },

    DetachLoadBalancersFromSubnets : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DetachLoadBalancerFromSubnets.html',
        defaults : {
            Action : 'DetachLoadBalancersFromSubnets'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            Subnets : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    DisableAvailabilityZonesForLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_DisableAvailabilityZonesForLoadBalancer.html',
        defaults : {
            Action : 'DisableAvailabilityZonesForLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            AvailabilityZones : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    EnableAvailabilityZonesForLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_EnableAvailabilityZonesForLoadBalancer.html',
        defaults : {
            Action : 'EnableAvailabilityZonesForLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            AvailabilityZones : {
                required : true,
                type     : 'param-array',
                prefix   : 'member',
            },
        },
    },

    RegisterInstancesWithLoadBalancer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_RegisterInstancesWithLoadBalancer.html',
        defaults : {
            Action : 'RegisterInstancesWithLoadBalancer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            Instances : {
                required : true,
                type     : 'param-array-of-objects',
                setName  : 'Instances.member',
            },
        },
    },

    // check capitalisation
    SetLoadBalancerListenerSslCertificate : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerListenerSSLCertificate.html',
        defaults : {
            Action : 'SetLoadBalancerListenerSSLCertificate'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerPort : {
                required : true,
                type     : 'param',
            },
            SslCertificateId : {
                name     : 'SSLCertificateId',
                required : true,
                type     : 'param',
            },
        },
    },

    SetLoadBalancerPoliciesForBackendServer : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerPoliciesForBackendServer.html',
        defaults : {
            Action : 'SetLoadBalancerPoliciesForBackendServer'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            InstancePort : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            PolicyNames : {
                required : true,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

    SetLoadBalancerPoliciesOfListener : {
        url : 'http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_SetLoadBalancerPoliciesOfListener.html',
        defaults : {
            Action : 'SetLoadBalancerPoliciesOfListener'
        },
        args : {
            Action : {
                required : true,
                type     : 'param',
            },
            LoadBalancerName : {
                required : true,
                type     : 'param',
            },
            LoadBalancerPort : {
                required : true,
                type     : 'param',
            },
            PolicyNames : {
                required : true,
                type     : 'param-array',
                prefix   : 'member'
            },
        },
    },

};

// --------------------------------------------------------------------------------------------------------------------
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
 *
 * See the COPYING-README file.
 *
 */

/* global Handlebars */

(function (OCA) {

	_.extend(OC.Files.Client, {
		PROPERTY_TAGS: '{' + OC.Files.Client.NS_OWNCLOUD + '}tags',
		PROPERTY_FAVORITE: '{' + OC.Files.Client.NS_OWNCLOUD + '}favorite'
	});

	/**
	 * Returns the icon class for the matching state
	 *
	 * @param {boolean} state true if starred, false otherwise
	 * @return {string} icon class for star image
	 */
	function getStarIconClass (state) {
		return state ? 'icon-starred' : 'icon-star';
	}

	/**
	 * Render the star icon with the given state
	 *
	 * @param {boolean} state true if starred, false otherwise
	 * @return {Object} jQuery object
	 */
	function renderStar (state) {
		return OCA.Files.Templates['favorite_mark']({
			isFavorite: state,
			altText: state ? t('files', 'Favorited') : t('files', 'Not favorited'),
			iconClass: getStarIconClass(state)
		});
	}

	/**
	 * Toggle star icon on favorite mark element
	 *
	 * @param {Object} $favoriteMarkEl favorite mark element
	 * @param {boolean} state true if starred, false otherwise
	 */
	function toggleStar ($favoriteMarkEl, state) {
		$favoriteMarkEl.removeClass('icon-star icon-starred').addClass(getStarIconClass(state));
		$favoriteMarkEl.toggleClass('permanent', state);
	}

	/**
	 * Remove Item from Quickaccesslist
	 *
	 * @param {String} appfolder folder to be removed
	 */
	function removeFavoriteFromList (appfolder) {
		var quickAccessList = 'sublist-favorites';
		var listULElements = document.getElementById(quickAccessList);
		if (!listULElements) {
			return;
		}

		var apppath=appfolder;
		if(appfolder.startsWith("//")){
			apppath=appfolder.substring(1, appfolder.length);
		}

		$(listULElements).find('[data-dir="' + apppath + '"]').remove();

		if (listULElements.childElementCount === 0) {
			var collapsibleButton = $(listULElements).parent().find('button.collapse');
			collapsibleButton.hide();
			$("#button-collapse-parent-favorites").removeClass('collapsible');
		}
	}

	/**
	 * Add Item to Quickaccesslist
	 *
	 * @param {String} appfolder folder to be added
	 */
	function addFavoriteToList (appfolder) {
		var quickAccessList = 'sublist-favorites';
		var listULElements = document.getElementById(quickAccessList);
		if (!listULElements) {
			return;
		}
		var listLIElements = listULElements.getElementsByTagName('li');

		var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
		var apppath = appfolder;

		if(appfolder.startsWith("//")){
			apppath = appfolder.substring(1, appfolder.length);
		}
		var url = OC.generateUrl('/apps/files/?dir=' + apppath + '&view=files');

		var innerTagA = document.createElement('A');
		innerTagA.setAttribute("href", url);
		innerTagA.setAttribute("class", "nav-icon-files svg");
		innerTagA.innerHTML = _.escape(appName);

		var length = listLIElements.length + 1;
		var innerTagLI = document.createElement('li');
		innerTagLI.setAttribute("data-id", apppath.replace('/', '-'));
		innerTagLI.setAttribute("data-dir", apppath);
		innerTagLI.setAttribute("data-view", 'files');
		innerTagLI.setAttribute("class", "nav-" + appName);
		innerTagLI.setAttribute("folderpos", length.toString());
		innerTagLI.appendChild(innerTagA);

		$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/NodeType"),{folderpath: apppath}, function (data, status) {
				if (data === "dir") {
					if (listULElements.childElementCount <= 0) {
						listULElements.appendChild(innerTagLI);
						var collapsibleButton = $(listULElements).parent().find('button.collapse');
						collapsibleButton.show();
						$(listULElements).parent().addClass('collapsible');
					} else {
						listLIElements[listLIElements.length - 1].after(innerTagLI);
					}
				}
			}
		);
	}

	OCA.Files = OCA.Files || {};

	/**
	 * Extends the file actions and file list to include a favorite mark icon
	 * and a favorite action in the file actions menu; it also adds "data-tags"
	 * and "data-favorite" attributes to file elements.
	 *
	 * @namespace OCA.Files.TagsPlugin
	 */
	OCA.Files.TagsPlugin = {
		name: 'Tags',

		allowedLists: [
			'files',
			'favorites',
			'systemtags',
			'shares.self',
			'shares.others',
			'shares.link'
		],

		_extendFileActions: function (fileActions) {
			var self = this;

			fileActions.registerAction({
				name: 'Favorite',
				displayName: function (context) {
					var $file = context.$file;
					var isFavorite = $file.data('favorite') === true;

					if (isFavorite) {
						return t('files', 'Remove from favorites');
					}

					// As it is currently not possible to provide a context for
					// the i18n strings "Add to favorites" was used instead of
					// "Favorite" to remove the ambiguity between verb and noun
					// when it is translated.
					return t('files', 'Add to favorites');
				},
				mime: 'all',
				order: -100,
				permissions: OC.PERMISSION_NONE,
				iconClass: function (fileName, context) {
					var $file = context.$file;
					var isFavorite = $file.data('favorite') === true;

					if (isFavorite) {
						return 'icon-star-dark';
					}

					return 'icon-starred';
				},
				actionHandler: function (fileName, context) {
					var $favoriteMarkEl = context.$file.find('.favorite-mark');
					var $file = context.$file;
					var fileInfo = context.fileList.files[$file.index()];
					var dir = context.dir || context.fileList.getCurrentDirectory();
					var tags = $file.attr('data-tags');

					if (_.isUndefined(tags)) {
						tags = '';
					}
					tags = tags.split('|');
					tags = _.without(tags, '');
					var isFavorite = tags.indexOf(OC.TAG_FAVORITE) >= 0;
					if (isFavorite) {
						// remove tag from list
						tags = _.without(tags, OC.TAG_FAVORITE);
						removeFavoriteFromList(dir + '/' + fileName);
					} else {
						tags.push(OC.TAG_FAVORITE);
						addFavoriteToList(dir + '/' + fileName);
					}

					// pre-toggle the star
					toggleStar($favoriteMarkEl, !isFavorite);

					context.fileInfoModel.trigger('busy', context.fileInfoModel, true);

					self.applyFileTags(
						dir + '/' + fileName,
						tags,
						$favoriteMarkEl,
						isFavorite
					).then(function (result) {
						context.fileInfoModel.trigger('busy', context.fileInfoModel, false);
						// response from server should contain updated tags
						var newTags = result.tags;
						if (_.isUndefined(newTags)) {
							newTags = tags;
						}
						context.fileInfoModel.set({
							'tags': newTags,
							'favorite': !isFavorite
						});
					});
				}
			});
		},

		_extendFileList: function (fileList) {
			// extend row prototype
			var oldCreateRow = fileList._createRow;
			fileList._createRow = function (fileData) {
				var $tr = oldCreateRow.apply(this, arguments);
				var isFavorite = false;
				if (fileData.tags) {
					$tr.attr('data-tags', fileData.tags.join('|'));
					if (fileData.tags.indexOf(OC.TAG_FAVORITE) >= 0) {
						$tr.attr('data-favorite', true);
						isFavorite = true;
					}
				}
				var $icon = $(renderStar(isFavorite));
				$tr.find('td.filename .thumbnail').append($icon);
				return $tr;
			};
			var oldElementToFile = fileList.elementToFile;
			fileList.elementToFile = function ($el) {
				var fileInfo = oldElementToFile.apply(this, arguments);
				var tags = $el.attr('data-tags');
				if (_.isUndefined(tags)) {
					tags = '';
				}
				tags = tags.split('|');
				tags = _.without(tags, '');
				fileInfo.tags = tags;
				return fileInfo;
			};

			var oldGetWebdavProperties = fileList._getWebdavProperties;
			fileList._getWebdavProperties = function () {
				var props = oldGetWebdavProperties.apply(this, arguments);
				props.push(OC.Files.Client.PROPERTY_TAGS);
				props.push(OC.Files.Client.PROPERTY_FAVORITE);
				return props;
			};

			fileList.filesClient.addFileInfoParser(function (response) {
				var data = {};
				var props = response.propStat[0].properties;
				var tags = props[OC.Files.Client.PROPERTY_TAGS];
				var favorite = props[OC.Files.Client.PROPERTY_FAVORITE];
				if (tags && tags.length) {
					tags = _.chain(tags).filter(function (xmlvalue) {
						return (xmlvalue.namespaceURI === OC.Files.Client.NS_OWNCLOUD && xmlvalue.nodeName.split(':')[1] === 'tag');
					}).map(function (xmlvalue) {
						return xmlvalue.textContent || xmlvalue.text;
					}).value();
				}
				if (tags) {
					data.tags = tags;
				}
				if (favorite && parseInt(favorite, 10) !== 0) {
					data.tags = data.tags || [];
					data.tags.push(OC.TAG_FAVORITE);
				}
				return data;
			});
		},

		attach: function (fileList) {
			if (this.allowedLists.indexOf(fileList.id) < 0) {
				return;
			}
			this._extendFileActions(fileList.fileActions);
			this._extendFileList(fileList);
		},

		/**
		 * Replaces the given files' tags with the specified ones.
		 *
		 * @param {String} fileName path to the file or folder to tag
		 * @param {Array.<String>} tagNames array of tag names
		 * @param {Object} $favoriteMarkEl favorite mark element
		 * @param {boolean} isFavorite Was the item favorited before
		 */
		applyFileTags: function (fileName, tagNames, $favoriteMarkEl, isFavorite) {
			var encodedPath = OC.encodePath(fileName);
			while (encodedPath[0] === '/') {
				encodedPath = encodedPath.substr(1);
			}
			return $.ajax({
				url: OC.generateUrl('/apps/files/api/v1/files/') + encodedPath,
				contentType: 'application/json',
				data: JSON.stringify({
					tags: tagNames || []
				}),
				dataType: 'json',
				type: 'POST'
			}).fail(function (response) {
				var message = '';
				// show message if it is available
				if (response.responseJSON && response.responseJSON.message) {
					message = ': ' + response.responseJSON.message;
				}
				OC.Notification.show(t('files', 'An error occurred while trying to update the tags' + message), {type: 'error'});
				toggleStar($favoriteMarkEl, isFavorite);
			});
		}
	};
})
(OCA);

OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin);
<commit_msg>Allow to unfavorite all files<commit_after>/*
 * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
 *
 * See the COPYING-README file.
 *
 */

/* global Handlebars */

(function (OCA) {

	_.extend(OC.Files.Client, {
		PROPERTY_TAGS: '{' + OC.Files.Client.NS_OWNCLOUD + '}tags',
		PROPERTY_FAVORITE: '{' + OC.Files.Client.NS_OWNCLOUD + '}favorite'
	});

	/**
	 * Returns the icon class for the matching state
	 *
	 * @param {boolean} state true if starred, false otherwise
	 * @return {string} icon class for star image
	 */
	function getStarIconClass (state) {
		return state ? 'icon-starred' : 'icon-star';
	}

	/**
	 * Render the star icon with the given state
	 *
	 * @param {boolean} state true if starred, false otherwise
	 * @return {Object} jQuery object
	 */
	function renderStar (state) {
		return OCA.Files.Templates['favorite_mark']({
			isFavorite: state,
			altText: state ? t('files', 'Favorited') : t('files', 'Not favorited'),
			iconClass: getStarIconClass(state)
		});
	}

	/**
	 * Toggle star icon on favorite mark element
	 *
	 * @param {Object} $favoriteMarkEl favorite mark element
	 * @param {boolean} state true if starred, false otherwise
	 */
	function toggleStar ($favoriteMarkEl, state) {
		$favoriteMarkEl.removeClass('icon-star icon-starred').addClass(getStarIconClass(state));
		$favoriteMarkEl.toggleClass('permanent', state);
	}

	/**
	 * Remove Item from Quickaccesslist
	 *
	 * @param {String} appfolder folder to be removed
	 */
	function removeFavoriteFromList (appfolder) {
		var quickAccessList = 'sublist-favorites';
		var listULElements = document.getElementById(quickAccessList);
		if (!listULElements) {
			return;
		}

		var apppath=appfolder;
		if(appfolder.startsWith("//")){
			apppath=appfolder.substring(1, appfolder.length);
		}

		$(listULElements).find('[data-dir="' + _.escape(apppath) + '"]').remove();

		if (listULElements.childElementCount === 0) {
			var collapsibleButton = $(listULElements).parent().find('button.collapse');
			collapsibleButton.hide();
			$("#button-collapse-parent-favorites").removeClass('collapsible');
		}
	}

	/**
	 * Add Item to Quickaccesslist
	 *
	 * @param {String} appfolder folder to be added
	 */
	function addFavoriteToList (appfolder) {
		var quickAccessList = 'sublist-favorites';
		var listULElements = document.getElementById(quickAccessList);
		if (!listULElements) {
			return;
		}
		var listLIElements = listULElements.getElementsByTagName('li');

		var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
		var apppath = appfolder;

		if(appfolder.startsWith("//")){
			apppath = appfolder.substring(1, appfolder.length);
		}
		var url = OC.generateUrl('/apps/files/?dir=' + apppath + '&view=files');

		var innerTagA = document.createElement('A');
		innerTagA.setAttribute("href", url);
		innerTagA.setAttribute("class", "nav-icon-files svg");
		innerTagA.innerHTML = _.escape(appName);

		var length = listLIElements.length + 1;
		var innerTagLI = document.createElement('li');
		innerTagLI.setAttribute("data-id", apppath.replace('/', '-'));
		innerTagLI.setAttribute("data-dir", apppath);
		innerTagLI.setAttribute("data-view", 'files');
		innerTagLI.setAttribute("class", "nav-" + appName);
		innerTagLI.setAttribute("folderpos", length.toString());
		innerTagLI.appendChild(innerTagA);

		$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/NodeType"),{folderpath: apppath}, function (data, status) {
				if (data === "dir") {
					if (listULElements.childElementCount <= 0) {
						listULElements.appendChild(innerTagLI);
						var collapsibleButton = $(listULElements).parent().find('button.collapse');
						collapsibleButton.show();
						$(listULElements).parent().addClass('collapsible');
					} else {
						listLIElements[listLIElements.length - 1].after(innerTagLI);
					}
				}
			}
		);
	}

	OCA.Files = OCA.Files || {};

	/**
	 * Extends the file actions and file list to include a favorite mark icon
	 * and a favorite action in the file actions menu; it also adds "data-tags"
	 * and "data-favorite" attributes to file elements.
	 *
	 * @namespace OCA.Files.TagsPlugin
	 */
	OCA.Files.TagsPlugin = {
		name: 'Tags',

		allowedLists: [
			'files',
			'favorites',
			'systemtags',
			'shares.self',
			'shares.others',
			'shares.link'
		],

		_extendFileActions: function (fileActions) {
			var self = this;

			fileActions.registerAction({
				name: 'Favorite',
				displayName: function (context) {
					var $file = context.$file;
					var isFavorite = $file.data('favorite') === true;

					if (isFavorite) {
						return t('files', 'Remove from favorites');
					}

					// As it is currently not possible to provide a context for
					// the i18n strings "Add to favorites" was used instead of
					// "Favorite" to remove the ambiguity between verb and noun
					// when it is translated.
					return t('files', 'Add to favorites');
				},
				mime: 'all',
				order: -100,
				permissions: OC.PERMISSION_NONE,
				iconClass: function (fileName, context) {
					var $file = context.$file;
					var isFavorite = $file.data('favorite') === true;

					if (isFavorite) {
						return 'icon-star-dark';
					}

					return 'icon-starred';
				},
				actionHandler: function (fileName, context) {
					var $favoriteMarkEl = context.$file.find('.favorite-mark');
					var $file = context.$file;
					var fileInfo = context.fileList.files[$file.index()];
					var dir = context.dir || context.fileList.getCurrentDirectory();
					var tags = $file.attr('data-tags');

					if (_.isUndefined(tags)) {
						tags = '';
					}
					tags = tags.split('|');
					tags = _.without(tags, '');
					var isFavorite = tags.indexOf(OC.TAG_FAVORITE) >= 0;
					if (isFavorite) {
						// remove tag from list
						tags = _.without(tags, OC.TAG_FAVORITE);
						removeFavoriteFromList(dir + '/' + fileName);
					} else {
						tags.push(OC.TAG_FAVORITE);
						addFavoriteToList(dir + '/' + fileName);
					}

					// pre-toggle the star
					toggleStar($favoriteMarkEl, !isFavorite);

					context.fileInfoModel.trigger('busy', context.fileInfoModel, true);

					self.applyFileTags(
						dir + '/' + fileName,
						tags,
						$favoriteMarkEl,
						isFavorite
					).then(function (result) {
						context.fileInfoModel.trigger('busy', context.fileInfoModel, false);
						// response from server should contain updated tags
						var newTags = result.tags;
						if (_.isUndefined(newTags)) {
							newTags = tags;
						}
						context.fileInfoModel.set({
							'tags': newTags,
							'favorite': !isFavorite
						});
					});
				}
			});
		},

		_extendFileList: function (fileList) {
			// extend row prototype
			var oldCreateRow = fileList._createRow;
			fileList._createRow = function (fileData) {
				var $tr = oldCreateRow.apply(this, arguments);
				var isFavorite = false;
				if (fileData.tags) {
					$tr.attr('data-tags', fileData.tags.join('|'));
					if (fileData.tags.indexOf(OC.TAG_FAVORITE) >= 0) {
						$tr.attr('data-favorite', true);
						isFavorite = true;
					}
				}
				var $icon = $(renderStar(isFavorite));
				$tr.find('td.filename .thumbnail').append($icon);
				return $tr;
			};
			var oldElementToFile = fileList.elementToFile;
			fileList.elementToFile = function ($el) {
				var fileInfo = oldElementToFile.apply(this, arguments);
				var tags = $el.attr('data-tags');
				if (_.isUndefined(tags)) {
					tags = '';
				}
				tags = tags.split('|');
				tags = _.without(tags, '');
				fileInfo.tags = tags;
				return fileInfo;
			};

			var oldGetWebdavProperties = fileList._getWebdavProperties;
			fileList._getWebdavProperties = function () {
				var props = oldGetWebdavProperties.apply(this, arguments);
				props.push(OC.Files.Client.PROPERTY_TAGS);
				props.push(OC.Files.Client.PROPERTY_FAVORITE);
				return props;
			};

			fileList.filesClient.addFileInfoParser(function (response) {
				var data = {};
				var props = response.propStat[0].properties;
				var tags = props[OC.Files.Client.PROPERTY_TAGS];
				var favorite = props[OC.Files.Client.PROPERTY_FAVORITE];
				if (tags && tags.length) {
					tags = _.chain(tags).filter(function (xmlvalue) {
						return (xmlvalue.namespaceURI === OC.Files.Client.NS_OWNCLOUD && xmlvalue.nodeName.split(':')[1] === 'tag');
					}).map(function (xmlvalue) {
						return xmlvalue.textContent || xmlvalue.text;
					}).value();
				}
				if (tags) {
					data.tags = tags;
				}
				if (favorite && parseInt(favorite, 10) !== 0) {
					data.tags = data.tags || [];
					data.tags.push(OC.TAG_FAVORITE);
				}
				return data;
			});
		},

		attach: function (fileList) {
			if (this.allowedLists.indexOf(fileList.id) < 0) {
				return;
			}
			this._extendFileActions(fileList.fileActions);
			this._extendFileList(fileList);
		},

		/**
		 * Replaces the given files' tags with the specified ones.
		 *
		 * @param {String} fileName path to the file or folder to tag
		 * @param {Array.<String>} tagNames array of tag names
		 * @param {Object} $favoriteMarkEl favorite mark element
		 * @param {boolean} isFavorite Was the item favorited before
		 */
		applyFileTags: function (fileName, tagNames, $favoriteMarkEl, isFavorite) {
			var encodedPath = OC.encodePath(fileName);
			while (encodedPath[0] === '/') {
				encodedPath = encodedPath.substr(1);
			}
			return $.ajax({
				url: OC.generateUrl('/apps/files/api/v1/files/') + encodedPath,
				contentType: 'application/json',
				data: JSON.stringify({
					tags: tagNames || []
				}),
				dataType: 'json',
				type: 'POST'
			}).fail(function (response) {
				var message = '';
				// show message if it is available
				if (response.responseJSON && response.responseJSON.message) {
					message = ': ' + response.responseJSON.message;
				}
				OC.Notification.show(t('files', 'An error occurred while trying to update the tags' + message), {type: 'error'});
				toggleStar($favoriteMarkEl, isFavorite);
			});
		}
	};
})
(OCA);

OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin);
<|endoftext|>


<commit_before>// Copyright 2015 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Gallery tile component.
 *
 * @author Sean Lip
 */

oppia.directive('explorationSummaryTile', [function() {
  return {
    restrict: 'E',
    scope: {
      getCollectionId: '&collectionId',
      getExplorationId: '&explorationId',
      getExplorationTitle: '&explorationTitle',
      getLastUpdatedMsec: '&lastUpdatedMsec',
      getNumViews: '&numViews',
      getObjective: '&objective',
      getCategory: '&category',
      getRatings: '&ratings',
      getContributorsSummary: '&contributorsSummary',
      getThumbnailIconUrl: '&thumbnailIconUrl',
      getThumbnailBgColor: '&thumbnailBgColor',
      // If this is not null, the new exploration opens in a new window when
      // the summary tile is clicked.
      openInNewWindow: '@openInNewWindow'
    },
    templateUrl: 'summaryTile/exploration',
    link: function(scope, element) {
      element.find('.exploration-summary-contributors').on('mouseenter',
        function() {
          element.find('.mask').attr('class',
            'exploration-summary-tile-mask mask');
          element.find('.contributors-num-minus-one').hide(1, function() {
            element.find('.all-contributors').slideDown();
          });
        }
      );

      element.find('.exploration-summary-contributors').on('mouseleave',
        function() {
          element.find('.mask').attr('class', 'top-section-mask mask');
          element.find('.all-contributors').slideUp(400, function() {
            element.find('.contributors-num-minus-one').show(1);
          });
        }
      );
    },
    controller: [
      '$scope', 'oppiaDatetimeFormatter', 'RatingComputationService',
      function($scope, oppiaDatetimeFormatter, RatingComputationService) {
        $scope.contributors = Object.keys(
          $scope.getContributorsSummary() || {}).sort(
          function(contributorUsername1, contributorUsername2) {
            var commitsOfContributor1 = $scope.getContributorsSummary()[
                contributorUsername1];
            var commitsOfContributor2 = $scope.getContributorsSummary()[
                contributorUsername2];
            return commitsOfContributor2 - commitsOfContributor1;
          }
        );

        $scope.MAX_CONTRIBUTORS_TO_DISPLAY = 5;

        $scope.getAverageRating = function() {
          return RatingComputationService.computeAverageRating(
            $scope.getRatings());
        };

        $scope.getLastUpdatedDatetime = function() {
          return oppiaDatetimeFormatter.getLocaleAbbreviatedDatetimeString(
            $scope.getLastUpdatedMsec());
        };

        $scope.wasRecentlyUpdated = function() {
          return oppiaDatetimeFormatter.isRecent($scope.getLastUpdatedMsec());
        };

        $scope.getExplorationLink = function() {
          var result = '/explore/' + $scope.getExplorationId();
          if ($scope.getCollectionId()) {
            result += ('?collection_id=' + $scope.getCollectionId());
          }
          return result;
        };
      }
    ]
  };
}]);
<commit_msg>fix animation threading issue<commit_after>// Copyright 2015 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Gallery tile component.
 *
 * @author Sean Lip
 */

oppia.directive('explorationSummaryTile', [function() {
  return {
    restrict: 'E',
    scope: {
      getCollectionId: '&collectionId',
      getExplorationId: '&explorationId',
      getExplorationTitle: '&explorationTitle',
      getLastUpdatedMsec: '&lastUpdatedMsec',
      getNumViews: '&numViews',
      getObjective: '&objective',
      getCategory: '&category',
      getRatings: '&ratings',
      getContributorsSummary: '&contributorsSummary',
      getThumbnailIconUrl: '&thumbnailIconUrl',
      getThumbnailBgColor: '&thumbnailBgColor',
      // If this is not null, the new exploration opens in a new window when
      // the summary tile is clicked.
      openInNewWindow: '@openInNewWindow'
    },
    templateUrl: 'summaryTile/exploration',
    link: function(scope, element) {
      element.find('.exploration-summary-contributors').on('mouseenter',
        function() {
          element.find('.mask').attr('class',
            'exploration-summary-tile-mask mask');
          element.find('.contributors-num-minus-one').stop(true).hide(1,
            function() {
              element.find('.all-contributors').stop(true).slideDown();
            }
          );
        }
      );

      element.find('.exploration-summary-contributors').on('mouseleave',
        function() {
          element.find('.mask').attr('class', 'top-section-mask mask');
          element.find('.all-contributors').stop(true).slideUp(400, function() {
            element.find('.contributors-num-minus-one').stop(true).show(1);
          });
        }
      );
    },
    controller: [
      '$scope', 'oppiaDatetimeFormatter', 'RatingComputationService',
      function($scope, oppiaDatetimeFormatter, RatingComputationService) {
        $scope.contributors = Object.keys(
          $scope.getContributorsSummary() || {}).sort(
          function(contributorUsername1, contributorUsername2) {
            var commitsOfContributor1 = $scope.getContributorsSummary()[
                contributorUsername1];
            var commitsOfContributor2 = $scope.getContributorsSummary()[
                contributorUsername2];
            return commitsOfContributor2 - commitsOfContributor1;
          }
        );

        $scope.MAX_CONTRIBUTORS_TO_DISPLAY = 5;

        $scope.getAverageRating = function() {
          return RatingComputationService.computeAverageRating(
            $scope.getRatings());
        };

        $scope.getLastUpdatedDatetime = function() {
          return oppiaDatetimeFormatter.getLocaleAbbreviatedDatetimeString(
            $scope.getLastUpdatedMsec());
        };

        $scope.wasRecentlyUpdated = function() {
          return oppiaDatetimeFormatter.isRecent($scope.getLastUpdatedMsec());
        };

        $scope.getExplorationLink = function() {
          var result = '/explore/' + $scope.getExplorationId();
          if ($scope.getCollectionId()) {
            result += ('?collection_id=' + $scope.getCollectionId());
          }
          return result;
        };
      }
    ]
  };
}]);
<|endoftext|>