Esempio n. 1
0
Dom.prototype.addClass = function (cl, el) {
  classes(el).add(cl)
}
Esempio n. 2
0
page('/law/:id', citizen.optional, load, loadSidebar, function(ctx, next) {
  function validUrl() {
    var pathname = window.location.pathname;
    return pathname == '/' ||  /^\/(law|proposal)/.test(pathname);
  }

  if (!validUrl()) return classes(document.body).remove('browser-page');

  bus.emit('page:render');

  if (!ctx.law) {
    log('Law %s not found', ctx.params.id);
    return next();
  }

  ctx.sidebar.replace('aside.nav-proposal');

  // Clean page's content
  empty(o('section.app-content'))


  // Build article's content container
  // and render to section.app-content
  var article = new Article(ctx.law, nextLaw);
  article.render('section.app-content');

  // Build article's meta
  // and render to section.app-content
  var options = new Options(ctx.law, ctx.citizen);
  options.render('section.app-content');

  var nextLaw = new NextLaw(ctx);
  nextLaw.appendTo('section.app-content');


  // Build article's comments, feth them
  // and render to section.app-content
  if (ctx.law.votable) {
    var comments = new Comments('law', ctx.law.id);
    comments.render('section.app-content');
    comments.initialize();
  }

  classes(document.body).add('browser-page');
  title(ctx.law.mediaTitle);

  log('render %s', ctx.params.id);

  bus.once('page:change', pagechange);
  function pagechange(url) {
    // restore page's original title
    title();

    // lock article's section
    locker.lock();

    // hide it from user
    classes(o('section.app-content')).add('hide');

    // once render, unlock and show
    bus.once('page:render', function() {
      locker.unlock();
      classes(o('section.app-content')).remove('hide');
    });

    // check if loading to same page
    // and if not, scroll to top
    if (url !== ctx.path) o('section#browser').scrollTop = 0;

    // don't remove 'browser-page' body class
    // if we still are in a browsing laws page
    if (/^\/law/.test(url)) return;
    classes(document.body).remove('browser-page');
  };
});
Esempio n. 3
0
Powerange.prototype.extraClass = function(klass) {
  if (this.options.klass) classes(this.slider).add(klass);
};
Esempio n. 4
0
 clear: function() {
     for (var i = 0, il = buttons.els.length; i < il; i++) {
         classes(buttons.els[i]).remove('asc');
         classes(buttons.els[i]).remove('desc');
     }
 },
Esempio n. 5
0
  redraw(this.el); // to force an initial show to take
}


/**
 * Mixin emitter.
 */

Emitter(Overlay.prototype);


/**
 * Mixin classes.
 */

Classes(Overlay.prototype);


/**
 * Show the overlay.
 *
 * @param {Function} callback
 * @return {Overlay}
 */

Overlay.prototype.show = function (callback) {
  var visible = ! this.hasClass('hidden');
  var showing = this.hasClass('showing');

  if('function' === typeof callback) {
    visible && !showing ? callback() : this.once('show', callback);
Esempio n. 6
0
 this._onClick = function () {
   classes(target).add('hide')
 }
Esempio n. 7
0
SlideShow.prototype.enableTransitions = function(el) {
  classes(el).remove('no-transitions');
};
    var refresh = function() {
        var item,
            l = list.matchingItems.length,
            index = list.i,
            page = list.page,
            pages = Math.ceil(l / page),
            currentPage = Math.ceil((index / page)),
            innerWindow = options.innerWindow || 2,
            left = options.left || options.outerWindow || 0,
            right = options.right || options.outerWindow || 0,
            includeDirectionLinks = options.includeDirectionLinks || false,
            leftDirectionText = options.leftDirectionText || '&laquo;',
            rightDirectionText = options.rightDirectionText || '&raquo;';

        right = pages - right;
        
        pagingList.clear();
        
        if (includeDirectionLinks) {
          // Include previous link
          item = pagingList.add({
              page: leftDirectionText,
              dotted: false
          })[0];
          classes(item.elm).add("prev");
          if (currentPage - 1 > 0) {
            addEvent(item.elm, currentPage - 1, page);
          } else {
            classes(item.elm).add("disabled");
          }
        }
        
        for (var i = 1; i <= pages; i++) {
            var className = (currentPage === i) ? "active" : "";

            //console.log(i, left, right, currentPage, (currentPage - innerWindow), (currentPage + innerWindow), className);

            if (is.number(i, left, right, currentPage, innerWindow)) {
                item = pagingList.add({
                    page: i,
                    dotted: false
                })[0];
                if (className) {
                    classes(item.elm).add(className);
                }
                addEvent(item.elm, i, page);
            } else if (is.dotted(i, left, right, currentPage, innerWindow, pagingList.size())) {
                item = pagingList.add({
                    page: "...",
                    dotted: true
                })[0];
                classes(item.elm).add("disabled");
            }
        }
        
        if (includeDirectionLinks) {
          // Include next link
          item = pagingList.add({
              page: rightDirectionText,
              dotted: false
          })[0];
          classes(item.elm).add("next");
          if (currentPage + 1 <= pages) {
            addEvent(item.elm, currentPage + 1, page);
          } else {
            classes(item.elm).add("disabled");
          }
        }
    };
Esempio n. 9
0
  this._overlay = overlay();

  var el = this.el;

  this.on('showing', function() {
    document.body.appendChild(el);
  });

  this.on('hide', function() {
    document.body.removeChild(el);
  });
}

Emitter(Modal.prototype);
Showable(Modal.prototype);
Classes(Modal.prototype);

/**
 * Set the transition in/out effect
 *
 * @param {String} type
 * @return {Modal}
 */
Modal.prototype.effect = function(type) {
  this.el.setAttribute('effect', type);
  return this;
};

/**
 * Add an overlay
 *
Esempio n. 10
0
  dragStart: function(e) {
    var restrictX = this.restrictX,
        restrictY = this.restrictY,
        limitsX = this.limitsX,
        limitsY = this.limitsY,
        relativeX = this.position[0],
        relativeY = this.position[1],
        posX = isTouch ? e.touches[0].pageX : e.clientX,
        posY = isTouch ? e.touches[0].pageY : e.clientY,
        newX, newY,
        self = this; // The DOM element

    // Allow nested draggable elements
    e.stopPropagation();

    classes(this).add('activeDrag');

    d.addEventListener(events.move, dragMove);
    d.addEventListener(events.end, dragEnd);
    
    // Move draggy object using CSS3 translate3d
    function dragMove (e) {
      e.preventDefault();
      var movedX, movedY, relX, relY,
          clientX = isTouch ? e.touches[0].pageX : e.clientX,
          clientY = isTouch ? e.touches[0].pageY : e.clientY;
      if (!restrictX) {
        // Mouse movement (x axis) in px
        movedX = clientX - posX;
        // New pixel value (x axis) of element
        newX = relativeX + movedX;
        if (newX >= limitsX[0] && newX <= limitsX[1]) {
          posX = clientX;
          relativeX = newX;
        }
        else if (newX < limitsX[0]) {
          relativeX = limitsX[0];
        }
        else if (newX > limitsX[1]) {
          relativeX = limitsX[1];
        }
      }
      if (!restrictY) {
        movedY = clientY - posY;
        newY = relativeY + movedY;
        if (newY >= limitsY[0] && newY <= limitsY[1]) {
          posY = clientY;
          relativeY = newY;
        }
        else if (newY < limitsY[0]) {
          relativeY = limitsY[0];
        }
        else if (newY > limitsY[1]) {
          relativeY = limitsY[1];
        }
      }
      self.draggy.position = self.position = [relativeX, relativeY];
      stylar(self).set('transform', 'translate(' + relativeX + 'px,' + relativeY + 'px)');
      self.onChange(relativeX, relativeY);
      self.dispatchEvent(onDrag);
    }
    // Stop moving draggy object, save position and dispatch onDrop event
    function dragEnd (e) {
      self.draggy.position = self.position;
      classes(self.draggy.ele).remove('activeDrag');
      self.dispatchEvent(onDrop);
      d.removeEventListener(events.move, dragMove);
      d.removeEventListener(events.end, dragEnd);
    }

  },
Esempio n. 11
0
 CommentsRepliesView.prototype.oncanceledit = function(el) {
  classes(el.parentNode).remove('edit');
  var btn = o('.btn-reply-edit', el.parentNode);
  classes(btn).remove('hide');
  el.parentNode.removeChild(el);
};
Esempio n. 12
0
File: view.js Progetto: 89berner/app
 CommentsRepliesEditView.prototype.oncancel = function(ev) {
  ev.preventDefault();
  classes(this.el.parentNode).remove('edit');
  this.switchOff();
};
Esempio n. 13
0
Dom.prototype.hasClass = function (cl, el) {
  return classes(el).has(cl)
}
Esempio n. 14
0
Dom.prototype.removeClass = function (cl, el) {
  classes(el).remove(cl)
}
Esempio n. 15
0
 function onclick(e) {
   var state = classes(node).toggle(my.state).has(my.state);
   e.preventDefault();
   my.fn.call(null, state);
 }
Esempio n. 16
0
 nodes.each(function(node) {
   var id = dataset(node, 'resort');
   state[id] = classes(node).has(st);
 });
Esempio n. 17
0
page('/law/:id', citizen.optional, load, function(ctx, next) {
  bus.emit('page:render');

  // Render sidebar list
  sidebar.ready(function() {
    select() && filter.on('reload', select);

    function select() {
      log('select sidebar law %s', ctx.law.id);
      return setTimeout(sidebar.select.bind(sidebar, ctx.law.id), 0);
    }
  });

  // Clean page's content
  empty(o('section.app-content'))

  // Build article's content container
  // and render to section.app-content
  var article = new Article(ctx.law);
  article.render('section.app-content');

  // Build article's meta
  // and render to section.app-content
  var options = new Options(ctx.law, ctx.citizen);
  options.render('section.app-content');

  // Build article's comments, feth them
  // and render to section.app-content
  var comments = new Comments('law', ctx.law.id);
  comments.render('section.app-content');
  comments.fetch();

  classes(document.body).add('browser-page');
  title(ctx.law.mediaTitle);

  log('render %s', ctx.params.id);

  bus.once('page:change', pagechange);
  function pagechange(url) {
    // restore page's original title
    title();

    // lock article's section
    locker.lock();

    // hide it from user
    classes(o('section.app-content')).add('hide');

    // once render, unlock and show
    bus.once('page:render', function() {
      locker.unlock();
      classes(o('section.app-content')).remove('hide');
    });

    // check if loading to same page
    // and if not, scroll to top
    if (url !== ctx.path) o('section#browser').scrollTop = 0;

    // don't remove 'browser-page' body class
    // if we still are in a browsing laws page
    if (/^\/$/.test(url)) return;
    if (/^\/(law|proposal)/.test(url)) return;
    classes(document.body).remove('browser-page');
  };
});
Esempio n. 18
0
 .filter(function(node) {
   return classes(node).has(st);
 })
Esempio n. 19
0
dropdown.prototype.hide = function () {
  classes(this.target).add('hide')
}
Esempio n. 20
0
 selected.forEach(function(id) {
   var node = find(id);
   if (node) {
     classes(node).add(st);
   }
 });
Esempio n. 21
0
SlideShow.prototype.disableTransitions = function(el) {
  classes(el).add('no-transitions');
};
Esempio n. 22
0
 nodes.each(function(node) {
   classes(node)[fn](st);
 });
Esempio n. 23
0
module.exports = function(options)
{	
	var self = this;

	//have emit capabilities -- let other know when certain events are triggered
	emitter(self);

	//given a div, we need to make our publishing adjustments
	if(!options.objectSize)
		throw new Error("Need object size for publish view!");

	var modalNames = {
		bPublish: "modal-publish",
		bCancel: "modal-cancel",
		iTitle: "modal-title",
		iTags : "modal-tags",
		dArtifact : "modal-artifact-object",
		dTop : "modal-top",
		dBottom: "modal-bottom",
		dParent : "modal-parent"
	}


	//now, we setup our div objects
	self.createModalWindow = function()
	{
		//we need to make a full blown UI and hook it up to events that will be emitted

		var div = element('div', {id: modalNames.dParent, class: "container fullSize flexContainerColumn"});

		var row = element('div', {id: modalNames.dTop, class: "noPadding flexRow flexSeparate"});

		var titleObject = element('div', {class: "title fullWidth flexContainerRow noPadding"}, 
			[ 
				element('div', {class: "col-xs-3 noPadding"}, 'Title: '),
				element('input', {id: modalNames.iTitle, type : "text", class: "col-auto noPadding titleText"})
			]);

		var tagObject = element('div', {id: "tag-holder", class: "fullSize flexContainerRow noPadding"}, 
			[
				element('div', {class: "col-xs-3 noPadding"}, 'Tags: '),
				element('input', {id: modalNames.iTags, type: "text", class: "col-auto noPadding"})
			]);

		var rightColumn = element('div', {id: "text-col"}, [titleObject, tagObject]);


		var widthAndHeight = "width: " + options.objectSize.width + "px; height: " + options.objectSize.height + "px;"; 
		var leftColumn = element('div', {id: "art-col", class: "col-xs-5"}, element('div', {id: modalNames.dArtifact, style: widthAndHeight, class: "border"}, "artifact here"));

		row.appendChild(leftColumn);
		row.appendChild(rightColumn);


		var pubButton = element('div', {id: modalNames.bPublish, class: "col-auto modalButton publish centerRow"}, "Publish");
		var cancelButton = element('div', {id: modalNames.bCancel, class: "col-auto modalButton cancel centerRow"}, "Cancel");

		var bottom = element('div', {id: modalNames.dBottom, class: "noPadding fullWidth flexContainerRow flexSeparate"}, [pubButton, cancelButton]);

		//now add the top row
		div.appendChild(row);
		div.appendChild(bottom);

		return div;
	}

	var div = self.createModalWindow();

	//do we need this piece?
	document.body.appendChild(div);

	var artifactDiv = document.getElementById(modalNames.dArtifact);

	var title = document.getElementById(modalNames.iTitle);
	//add tags to artifact-tag object
	var tags = document.getElementById(modalNames.iTags);

	var input = pillbox(tags, { lowercase : true, space: true });
	classes(tags.parentNode)
		.add("col-auto")
		.add("noPadding");

	//now we add listeners for publish/cancel
	var pub = document.getElementById(modalNames.bPublish);

	pub.addEventListener('click', function()
	{
		//for right now, we just close the modal
		self.publishArtifact();
	})

	var cancel = document.getElementById(modalNames.bCancel);
	cancel.addEventListener('click', function()
	{
		//for right now, we just close the modal
		self.cancelArtifact();
	})

	var view = modal(div)
		.overlay()
	    .effect('fade-and-scale');


    var currentID;

    self.launchPublishModal = function(eID)
    {
    	if(currentID != eID)
    	{
    		//clear tag and titles
    		tags.value = "";
    		title.value = "";
    	}
    	currentID = eID;
    	view.show();

    	var fc;
    	while((fc = artifactDiv.firstChild) != undefined)
    	{
    		artifactDiv.removeChild(fc);
    	}

    	//showing an object with a given id -- removed the innards for replacement
    	self.emit("publishShown", eID, artifactDiv, function()
		{
			//this doesn't have to be called, but it's good to be in the habbit -- since we may also want to display a loading gif
		});
    }

    self.cancelArtifact = function()
    {
    	view.hide();
    	self.emit("publishHidden", currentID);
    }

    self.publishArtifact = function()
    {
    	if(!self.hasListeners("publishArtifact"))
    	{
    		console.log("Warning: No listeners for publishing");
    		view.hide();
    	}
    	else{
    		var meta = {title: title.value, tags: input.values()};
	    	self.emit("publishArtifact", currentID, meta, function()
	    	{
	    		//when finished -- hide the mofo!p
	    		view.hide();
	    	});
	    }
    }


     return self;
}
Esempio n. 24
0
  this.el = domify(this.template);
  this.reactive = reactive(this.el, this.schema, this);
  this.input = this.el.querySelector('input');
}

/**
 * Mixin emitter.
 */

Emitter(Field.prototype);

/**
 * Mixin classes.
 */

Classes(Field.prototype);


/**
 * Template.
 */

Field.prototype.template = template;


/**
 * Get the field's name.
 *
 * @return {String}
 */
Esempio n. 25
0
 animate(this.el, this.animationOut, function(el){
   classes(_this.el).remove('in');
   _this.emit('modalOut');
 });
Esempio n. 26
0
File: index.js Progetto: mnmly/drag
Drag.prototype.ontouchend = function( e ) {
  classes( this.el ).remove( 'is-dragging' );
  this.docEvents.unbind();
  this.emit( 'dragend', e );
};
Esempio n. 27
0
 bus.once('page:render', function() {
   locker.unlock();
   classes(o('section.app-content')).remove('hide');
 });
Esempio n. 28
0
SortableTable.prototype.bind = function(){
  proto.bind.call(this)
  this.clone = clone(this.els[0]);
  classes(this.clone).add('sortable-placeholder');
  return this;
};
Esempio n. 29
0
function Vertical() {
  Powerange.apply(this, arguments);
  classes(this.slider).add('vertical');
  if (this.options.step) this.step(this.slider.offsetHeight, this.handle.offsetHeight);
  this.setStart(this.options.start);
}
Esempio n. 30
0
domready(function () {
  cls(document.body).remove("hidden");
});