function FAQView() { if (!(this instanceof FAQView)) { return new FAQView(); }; View.call(this, template, { md: marked(md) }); }
/** * Creates `Sidebar` view for admin */ function Sidebar() { if (!(this instanceof Sidebar)) { return new Sidebar(); }; View.call(this, template); }
function BillProposalViewer(lawId) { View.call(this, template); this.lawId = lawId; this.bills = []; this.selected = null; this.progressContainer = this.find('div.progress-container'); this.progress = new Progress('#00708f'); this.progressContainer.append(this.progress.element); this.onlawsload = this.onlawsload.bind(this); this.refresh = this.refresh.bind(this); this.reload = this.reload.bind(this); this.add = this.add.bind(this); laws.on('loaded', this.onlawsload); //TODO: make all this dependent on `bus` when making views reactive in #284 // This should fetch stuff again from backend so voted stuff is updated citizen.on('loaded', this.refresh); citizen.on('unloaded', this.refresh); this.refresh(); }
function CommentVote(comment) { if (!(this instanceof CommentVote)) { return new CommentVote(comment); } View.call(this, template); // Posible values: 'upvote','downvote','unvote'; this.$_status = ''; this.$_count = 0; this.comment = comment; this.upvoteButton = this.find('.vote.up'); this.downvoteButton = this.find('.vote.down'); this.counter = this.find('.counter'); //Calculate the current comment scoring this.count(this.comment.upvotes.length - this.comment.downvotes.length); if (this.voted(this.comment.upvotes)) { this.status('upvote'); } if (this.voted(this.comment.downvotes)) { this.status('downvote'); } }
function ProposalArticle (proposal, reference) { if (!(this instanceof ProposalArticle)) { return new ProposalArticle(proposal, reference); }; this.proposal = proposal; this.clauses = proposal.clauses.sort(function(a, b) { var sort = a.order - b.order; sort = sort > 0 ? 1 : -1; return sort; }); this.clauses.forEach(function(c) { if (isHTML(c.text)) { var text = o(c.text); var div = text.find('div:first-child'); div.html((c.clauseName ? c.clauseName + ': ' : '') + div.html()); var temp = document.createElement('div'); temp.appendChild(text[0]); c.text = temp.innerHTML; } else { c.text = (c.clauseName ? c.clauseName + ': ' : '') + c.text; } }); var baseUrl = config.protocol + "://" + config.host + (config.publicPort && config.publicPort != 80 ? (":" + config.publicPort) : ""); View.call(this, template, { proposal: proposal, clauses: this.clauses, baseUrl: baseUrl, truncate: truncate }); this.participants = new Participants(proposal.participants || []); this.participants.appendTo(this.find('.participants')[0]); this.participants.fetch(); this.proposalClauses = new ProposalClauses(proposal, reference); this.proposalClauses.appendTo('.clauses'); this.renderedClauses = this.find('.clauses'); this.embedResponsively(this.renderedClauses); this.summary = this.find('.summary').html(proposal.summary); this.shortsummary = this.find('.shortsummary').html(proposal.shortsummary); this.pros = this.find('.pros').html(proposal.pros); this.cons = this.find('.cons').html(proposal.cons); this.friendlyURL = this.find('.friendlyURL').html(proposal.friendlyURL); this.commentable(this.summary, proposal.id); this.embedResponsively(this.summary); this.truncate(this.find('.summary')); log("call this.renderChart()"); this.renderChart(); }
function CommentsFilter() { if (!(this instanceof CommentsFilter)) { return new CommentsFilter(); }; this.refresh(); View.call(this, template, { label: this.get().label, sorts: sorts }); }
function Title(doc){ View.call(this, template); Editable.call(this, this.$el[0]); this.placeholder('Title'); this.enableEditing(); this.bindEvents(); }
/** * Creates a profile edit view */ //TODO: user = citizen. All should be unified all to user instead of citizen function UserProfile(user) { if (!(this instanceof UserProfile)) { return new UserProfile(user); } View.call(this, template, {loadedCitizen: user}); this.loadTags(user.tags); this.shouldShowEdition(user.id); }
function MarkdownView() { if (!(this instanceof MarkdownView)) { return new MarkdownView(); }; View.call(this, template, { marked: marked, dosMarkdown: dosMarkdown }); this.playground = this.find('textarea.playground'); this.result = this.find('.result'); }
function TextSection(paragraph) { if (!this instanceof TextSection) { return new TextSection(paragraph); } View.call(this, template); this.createSection(paragraph); }
function BillProposal(law, options) { this.options = options || {}; this.options.delayNextLaw = this.options.delayNextLaw === undefined || this.options.delayNextLaw; this.law = law; this.previousLaw = laws.prev(law); this.nextLaw = laws.next(law); View.call(this, template, {law: law}); }
function ViewCollection(options) { if (!(this instanceof ViewCollection)) { return new ViewCollection(options); } View.call(this, options); this.collection = options.collection || new Collection([]); this.collection.model = this.viewmodel; this.listen(this.collection, this.messages); this.viewmodels = {}; }
/** * Navigatable content viev. If the collection is provided, navigation * functionality is enabled, meaning navigation arrows show up on both sides of * the content and clicking them will navigate to other pieces of content. * @extends {View} * @param {Object} opts Configuration options. */ function CarouselContentView(opts) { View.call(this, opts); /** * Collection to use when navigating. * @type {SortedCollection=} */ this.collection = this.opts.collection; /** * Content to show. * @type {Content} */ this.content = this.opts.content; /** * View that triggered this modal. * @type {View=} */ this.listView = this.opts.listView; /** * Whether navigation is enabled. The collection must exist. * @type {boolean} */ this.navigationEnabled = !!this.collection; // If no collection is provided, don't do any collection related shenanigans. if (!this.collection) { return; } // Change the sort order of the collection to the order of the parent list // view so the content is consistent. this.collection.setSortOrder(COMPARATOR_MAP[this.listView.comparator]); // Find the currently content's index within the collection so that the // navigation and arrows can be maintained. this.updateContentIndex(); // Listen for content added to the collection, re-find the index of the // content that is currently visible in case content came in from of it, // and maybe update the navigation arrows. this.collection.on('added', function () { this.updateContentIndex(); this.maybeToggleArrows(); }.bind(this)); // Add a resize handler so the view can be adjusted when the window resizes. window.addEventListener('resize', debounce(this.repositionView.bind(this), 100)); // Add a keyup handler to listen for arrow keys for keyboard navigation. window.addEventListener('keyup', this.handleKeyUp.bind(this)); }
function CommentView(comment, user) { var el = domify(template()) // user ref this.user = user View.call(this, comment, el) // ui binds this.bind('click .delete', 'remove') }
function FormView(template, options) { if (!(this instanceof FormView)) return inherit(template, FormView); View.call(this, template, options); this.autovalidate('form[autovalidate]'); this.autosubmit('form[autosubmit]'); this.on('insert', this.bound('oninsert')); this.messages(); }
function Editor(doc){ View.call(this, template); Editable.call(this, this.$el[0]); this.placeholder('Write here...', this.$el.find('p')[0]); this.enableEditing(); this.bindEvents(); // editor events // this.on('save', this.bound('save')); // this.on('change', this.bound('onchange')); }
function TagsForm() { if (!(this instanceof TagsForm)) { return new TagsForm(); } View.call(this, template); this.pills = []; this.form = this.find('form'); this.tags = this.find('#availableTags'); this.tags.focus(); this.setTags(); }
function UserView(user, comments) { var el = domify(template()) View.call(this, user, el) this.comments = comments this.bind('click .twitter', 'loginTwitter') this.bind('click .facebook', 'loginFacebook') this.bind('click .logout', 'logout') this.bind('click .send', 'send') this.bind('keydown .message', 'sendKey') }
function InspectorView(){ View.call(this); this.markAsRoot(); this._panelsElement = this.element.createChild("div", "fill"); this._panels = {}; this._panelOrder = []; this._currentPanel = null; this._footerElementContainer = this.element.createChild("div", "inspector-footer status-bar hidden"); }
var CompositeView = function () { var args = Array.prototype.slice.call(arguments, 0); var hasOpts = !(args[args.length-1] instanceof View); var opts = hasOpts ? args.pop() : {}; View.call(this, opts); this._childViews = []; var subViews = hasOpts ? args.slice(0, args.length) : args; for (var i=0; i < subViews.length; i++) { this.add(subViews[i], { render: false }); } };
function CommentCard(comment) { if (!(this instanceof CommentCard)) { return new CommentCard(comment); } this.comment = comment; this.setLocals(); View.call(this, template, this.locals); this.initializeVote(); this.editButton = this.find('.btn-edit'); this.scoreCounter = this.find('.comment-counter'); this.mediaBody = this.find('.media-body'); }
var Navigable = function(opts) { View.call(this, opts); /** * @param {?string} */ this._actionDesc = opts.actionDesc; /** * @param {?function()} */ this._actionHandler = opts.actionHandler || function () {}; /** * The event to trigger when the user clicks the back button. * @type {?string} * @private */ this._backEvent = opts.backEvent; /** * The string to use for the back button. * @type {?string} * @private */ this._backStr = opts.backStr; /** * Title for the menu. * @param {?string} * @private */ this._title = opts.title; /** * Allows for the removal of the top nav bar. Not every subclass will want * one I'm guessing. * @type {boolean} * @private */ this.topNavEnabled = true; };
var ContentRepliesView = function (opts) { opts = opts || {}; if (! opts.content) { throw 'Expected opts.content when constructing ContentRepliesView'; } View.call(this, opts); opts.autoRender = false; this.createReplyView = opts.createReplyView; this.content = opts.content; this._contentViewFactory = opts.contentViewFactory || new ContentViewFactory(); this._maxNestLevel = opts.maxNestLevel; this._nestLevel = opts.nestLevel; this._contentIsVisible = opts.contentIsVisible || function () { return true; }; this._maxVisibleItems = opts.maxVisibleItems; this._order = opts.order || ContentRepliesView.ORDERS.CREATEDAT_DESCENDING; this.comparator = this._order.comparator; this._showQueueHeader = !!this._order.showVisibleItemsAtHead; this._queueInitial = opts.queueInitial; var listOpts = { comparator: this.comparator, autoRender: false, showMoreButton: opts.showMoreButton || new ShowMoreButton({ content: opts.content }), showQueueButton: opts.showQueueButton || new ShowMoreButton({ content: opts.content }), initial: this._maxVisibleItems, queueInitial: this._queueInitial }; this._listView = new ListView(listOpts); hasQueue(this._listView, listOpts); this._listView.render(); this.content.on('reply', function(reply) { this._onReply(reply); }.bind(this)); };
function ProposalOptions (proposal, reference) { if (!(this instanceof ProposalOptions)) { return new ProposalOptions(proposal, reference); } View.call(this, template, { proposal: proposal, reference: reference }); this.proposal = proposal; this.bind('click', '.vote-box .direct-vote .vote-option', 'vote'); this.bind('click', '.vote-box .meta-data .change-vote', 'changevote'); this.on('vote', this.onvote.bind(this)); this.on('voting', this.onvoting.bind(this)); this.on('voteerror', this.onvoteerror.bind(this)); this.buttonsBox = this.find('.vote-box .vote-options'); this.renderChart(); }
function CartItemView(item) { if (!item) { throw new Error('Missing item information.'); } this.item = item; var els = domify(html); var el = query('.cart-item', els); View.call(this, item.prod, el); var self = this; var position = query('.quantity-selector', this.el); this.quantitySelector = new NumberSelector({ min: 1, init: item.q }); this.quantitySelector.on('change', function(e) { return self.changeQuantity(e.value); }); this.el.replaceChild(this.quantitySelector.el, position); }
/** * Instagram native view. * @constructor * @extends {View} * @param {Object} opts */ function InstagramNativeView(opts) { View.call(this); /** * The first attachment in the list. This is where the thumbnail comes from. * @type {Object} */ this.attachment = (get(opts, 'content.attachments.0') || {}); /** * Should the JavaScript be loaded immediately? This should always be true * unless the GDPR media mask is going to display. * @type {boolean} */ this.autoload = typeof opts.autoload === 'boolean' ? opts.autoload : true; /** * Loading status of the native embed. * @type {boolean} */ this.loading = false; }
function Editable(el, stack){ if (!(this instanceof Editable)) return inherit(el, Editable); View.call(this, el); }
function HeaderView() { View.call(this, template); this.user = this.el.find('.user'); }
function ReportCreationView () { View.call(this); bindEvents.call(this); }
function BillProposal(law, options) { this.law = law; View.call(this, template, {law: law}); this.renderChart(); }