PageRenderTime 435ms CodeModel.GetById 58ms RepoModel.GetById 6ms app.codeStats 1ms

/client/public/javascripts/app.js

https://bitbucket.org/namart/weddynize
JavaScript | 1695 lines | 1249 code | 375 blank | 71 comment | 199 complexity | 74d08b912d536d22279ef772b6434cf9 MD5 | raw file
  1. (function(/*! Brunch !*/) {
  2. 'use strict';
  3. var globals = typeof window !== 'undefined' ? window : global;
  4. if (typeof globals.require === 'function') return;
  5. var modules = {};
  6. var cache = {};
  7. var has = function(object, name) {
  8. return hasOwnProperty.call(object, name);
  9. };
  10. var expand = function(root, name) {
  11. var results = [], parts, part;
  12. if (/^\.\.?(\/|$)/.test(name)) {
  13. parts = [root, name].join('/').split('/');
  14. } else {
  15. parts = name.split('/');
  16. }
  17. for (var i = 0, length = parts.length; i < length; i++) {
  18. part = parts[i];
  19. if (part === '..') {
  20. results.pop();
  21. } else if (part !== '.' && part !== '') {
  22. results.push(part);
  23. }
  24. }
  25. return results.join('/');
  26. };
  27. var dirname = function(path) {
  28. return path.split('/').slice(0, -1).join('/');
  29. };
  30. var localRequire = function(path) {
  31. return function(name) {
  32. var dir = dirname(path);
  33. var absolute = expand(dir, name);
  34. return require(absolute);
  35. };
  36. };
  37. var initModule = function(name, definition) {
  38. var module = {id: name, exports: {}};
  39. definition(module.exports, localRequire(name), module);
  40. var exports = cache[name] = module.exports;
  41. return exports;
  42. };
  43. var require = function(name) {
  44. var path = expand(name, '.');
  45. if (has(cache, path)) return cache[path];
  46. if (has(modules, path)) return initModule(path, modules[path]);
  47. var dirIndex = expand(path, './index');
  48. if (has(cache, dirIndex)) return cache[dirIndex];
  49. if (has(modules, dirIndex)) return initModule(dirIndex, modules[dirIndex]);
  50. throw new Error('Cannot find module "' + name + '"');
  51. };
  52. var define = function(bundle) {
  53. for (var key in bundle) {
  54. if (has(bundle, key)) {
  55. modules[key] = bundle[key];
  56. }
  57. }
  58. }
  59. globals.require = require;
  60. globals.require.define = define;
  61. globals.require.brunch = true;
  62. })();
  63. window.require.define({"application": function(exports, require, module) {
  64. // Application bootstrapper.
  65. Application = {
  66. initialize: function() {
  67. // load in App data
  68. _.extend(this, App);
  69. var Router = require('lib/router');
  70. var ViewHelper = require('lib/view_helper');
  71. var HeaderView = require('views/headerView');
  72. var AddNizeView = require('views/nize/addNizeView');
  73. var NizeLayoutView = require('views/nizeLayoutView');
  74. this.headerView = new HeaderView();
  75. var nizeLayoutView = new NizeLayoutView();
  76. var addNizeView = new AddNizeView();
  77. this.router = new Router();
  78. if (typeof Object.freeze === 'function') Object.freeze(this);
  79. }
  80. };
  81. module.exports = Application;
  82. }});
  83. window.require.define({"initialize": function(exports, require, module) {
  84. var application = require('application');
  85. $(function() {
  86. var options = {
  87. lng: application.lang,
  88. useLocalStorage: false,
  89. resGetPath: '/locales/resources.json?lng=__lng__&ns=__ns__',
  90. dynamicLoad: true,
  91. sendMissing: false
  92. };
  93. //First of all, we need to load locales, after that we can do all the rest
  94. $.i18n.init(options, function() {
  95. application.initialize();
  96. Backbone.history.start({pushState: true});
  97. });
  98. //This is a little form helper to remove form-labels when user clicks in input field
  99. $("input.error").focus(function(){
  100. $(this).parent().find("label.errormessage").fadeOut(200);
  101. });
  102. });
  103. }});
  104. window.require.define({"lib/router": function(exports, require, module) {
  105. var application = require('application');
  106. module.exports = Backbone.Router.extend({
  107. routes: {
  108. '' : 'home',
  109. 'all': 'homeAll',
  110. 'nize/add' : 'addNize',
  111. 'nize/:id' : 'nize',
  112. '_=_' : 'facebookLoginBug'
  113. },
  114. home: function() {
  115. Backbone.Mediator.publish('nizeLayoutView:render');
  116. },
  117. homeAll: function() {
  118. Backbone.Mediator.publish('nizeLayoutView:render', true);
  119. },
  120. addNize: function() {
  121. Backbone.Mediator.publish('addNize:init');
  122. },
  123. nize: function(nizeId) {
  124. Backbone.Mediator.publish('openNize:init', nizeId);
  125. },
  126. facebookLoginBug: function() {
  127. this.navigate("/", {trigger: true, replace: true});
  128. }
  129. });
  130. }});
  131. window.require.define({"lib/view_helper": function(exports, require, module) {
  132. // Put your handlebars.js helpers here.
  133. Handlebars.registerHelper('t',
  134. function(str){
  135. trans = $.t(str);
  136. if(trans != "") {
  137. str = trans;
  138. }
  139. return str;
  140. }
  141. );
  142. }});
  143. window.require.define({"models/collection": function(exports, require, module) {
  144. // Base class for all collections.
  145. module.exports = Backbone.Collection.extend({
  146. });
  147. }});
  148. window.require.define({"models/listCollection": function(exports, require, module) {
  149. var Collection = require('./collection');
  150. var ListModel = require('./listModel');
  151. module.exports = Collection.extend({
  152. url: '/list',
  153. model: ListModel,
  154. showByAttribute: function(attr) {
  155. var filteredLists = this.where(attr);
  156. this.trigger('filteredLists', filteredLists);
  157. }
  158. });
  159. }});
  160. window.require.define({"models/listModel": function(exports, require, module) {
  161. var Model = require('./model');
  162. module.exports = Model.extend({
  163. idAttribute: '_id',
  164. urlRoot: '/list',
  165. defaults: function() {
  166. return {
  167. open: false,
  168. checked : false
  169. };
  170. }
  171. });
  172. }});
  173. window.require.define({"models/model": function(exports, require, module) {
  174. // Base class for all models.
  175. module.exports = Backbone.Model.extend({
  176. });
  177. }});
  178. window.require.define({"models/nizeCollection": function(exports, require, module) {
  179. var Collection = require('./collection');
  180. var NizeModel = require('./nizeModel');
  181. module.exports = Collection.extend({
  182. urlRoot: '/nize',
  183. model: NizeModel,
  184. initialize: function() {
  185. this.listFilter = '';
  186. this.listFilterName = '';
  187. this.ratingFilter = '';
  188. this.keyFilter = '';
  189. this.open = false;
  190. this.limit = 20;
  191. this.setSearchDefaults();
  192. },
  193. setSearchDefaults: function() {
  194. this.offset = 0;
  195. this.endReached = false;
  196. },
  197. setListFilter: function(listId, listName) {
  198. console.log(listName);
  199. this.setSearchDefaults();
  200. this.listFilter = listId;
  201. this.listFilterName = listName;
  202. this.search();
  203. },
  204. setRatingFilter: function(ratingValue) {
  205. this.setSearchDefaults();
  206. this.ratingFilter = ratingValue;
  207. this.search();
  208. },
  209. setKeyFilter: function(key) {
  210. this.setSearchDefaults();
  211. this.keyFilter = key;
  212. this.search();
  213. },
  214. setOpenFilter: function(state) {
  215. this.setSearchDefaults();
  216. this.open = state;
  217. this.search();
  218. },
  219. getNext: function() {
  220. this.offset += this.limit;
  221. this.search();
  222. },
  223. getFilters: function() {
  224. if(this.listFilter || this.ratingFilter || this.keyFilter) {
  225. return {
  226. list: this.listFilterName,
  227. rating: this.ratingFilter,
  228. key: this.keyFilter
  229. };
  230. } else {
  231. return null;
  232. }
  233. },
  234. search: function(data) {
  235. if(this.endReached) return;
  236. var url = this.urlRoot + '/search.json';
  237. var self = this;
  238. data = _.extend({
  239. key: this.keyFilter,
  240. list: this.listFilter,
  241. rating: this.ratingFilter,
  242. limit: this.limit,
  243. open: this.open,
  244. offset: this.offset
  245. },data);
  246. $.ajax({
  247. url:url,
  248. data: data,
  249. dataType:"json",
  250. success:function (data) {
  251. //console.log("search success: " + data.length, data);
  252. // append or reset
  253. if(self.offset === 0) {
  254. self.reset(data);
  255. } else {
  256. self.add(data);
  257. }
  258. // send event if all data already loaded
  259. if(data.length < self.limit) {
  260. self.endReached = true;
  261. self.trigger('finished');
  262. } else {
  263. self.trigger('newSearch');
  264. }
  265. }
  266. });
  267. }
  268. });
  269. }});
  270. window.require.define({"models/nizeModel": function(exports, require, module) {
  271. var Model = require('./model');
  272. var ListModel = require('./listModel');
  273. module.exports = Model.extend({
  274. idAttribute: '_id',
  275. urlRoot: '/nize',
  276. });
  277. }});
  278. window.require.define({"views/headerView": function(exports, require, module) {
  279. var View = require('./view');
  280. var application = require('application');
  281. module.exports = View.extend({
  282. el: '#header',
  283. events: {
  284. "click a.nize-state": "changeNizeState",
  285. "click .dropdown a.select-button": "toggleBox",
  286. },
  287. initialize: function() {
  288. _.bindAll(this, 'smallerHeader', 'biggerHeader');
  289. this.buttons = [];
  290. // Save join Button
  291. var joinButton = this.$el.find('.join.button');
  292. joinButton.data('class', 'join');
  293. this.buttons.push(joinButton);
  294. // Save login Button
  295. var loginButton = this.$el.find('.login.button');
  296. loginButton.data('class', 'login');
  297. this.buttons.push(loginButton);
  298. var self = this;
  299. $(window).scroll(function(){
  300. if($(document).scrollTop() > 0 && !self.$el.hasClass("sticky")){
  301. self.fixHeader();
  302. } else {
  303. setTimeout(function(){
  304. if($(document).scrollTop() == 0 && self.$el.hasClass("sticky")) {
  305. self.unfixHeader();
  306. }
  307. }, 1);
  308. }
  309. });
  310. },
  311. toggleBox: function(evt) {
  312. var self = this;
  313. var element = $(evt.target).closest(".dropdown");
  314. evt.stopPropagation();
  315. if(element.hasClass('open')) {
  316. this.closeBox(element);
  317. } else {
  318. element.addClass('open');
  319. $(document).bind('click', function(evt) {
  320. self.closeBox(element);
  321. });
  322. }
  323. return false;
  324. },
  325. closeBox: function(element) {
  326. element.removeClass('open');
  327. },
  328. fixHeader: function() {
  329. this.$el.addClass("sticky");
  330. this.$el.next().css({"margin-top": (this.$el.outerHeight(true) - 6)});
  331. this.smallerHeader();
  332. this.trigger('change', true);
  333. },
  334. unfixHeader: function() {
  335. this.$el.removeClass("sticky");
  336. this.$el.next().css({'margin-top': '0'});
  337. this.biggerHeader();
  338. this.trigger('change', false);
  339. },
  340. smallerHeader: function() {
  341. this.$el.addClass('smaller');
  342. },
  343. biggerHeader: function() {
  344. this.$el.removeClass('smaller');
  345. },
  346. changeNizeState: function(evt) {
  347. var url = Backbone.history.fragment;
  348. if(url === '' || url === 'all') {
  349. application.router.navigate($(evt.target).attr('href'), {trigger: true});
  350. return false;
  351. }
  352. },
  353. });
  354. }});
  355. window.require.define({"views/list/listUnitView": function(exports, require, module) {
  356. var View = require('../view');
  357. var template = require('../templates/list/listUnit');
  358. module.exports = View.extend({
  359. template: template,
  360. getRenderData: function() {
  361. return {
  362. list: this.model.toJSON()
  363. };
  364. }
  365. });
  366. }});
  367. window.require.define({"views/nize/addNizeView": function(exports, require, module) {
  368. var View = require('../view');
  369. var Nize = require('models/nizeModel');
  370. var List = require('models/listModel');
  371. var ListCollection = require('models/listCollection');
  372. var template = require('../templates/nize/addNizeForm');
  373. var ListUnitView = require('../list/listUnitView');
  374. var application = require('application');
  375. module.exports = View.extend({
  376. el: '.add-nize-right',
  377. template: template,
  378. initialize: function() {
  379. //console.debug('init#addNize', this.collection);
  380. _.bindAll(this, 'addOneList');
  381. this.c = document.createElement( 'canvas' );
  382. this.img = null;
  383. this.file = null;
  384. this.lists = null;
  385. // supported file types
  386. this.fileSupport = ['image/jpeg', 'image/png'];
  387. },
  388. events: {
  389. 'change .fileselect' : 'fileSelectHandler',
  390. 'dragover .filedrag' : 'fileDragHover',
  391. 'dragleave .filedrag' : 'fileDragHover',
  392. 'drop .filedrag' : 'fileSelectHandler',
  393. 'keypress .nize-new-list' : 'newList',
  394. 'click .nize-submit' : 'createNize'
  395. },
  396. subscriptions: {
  397. 'addNize:init': 'init'
  398. },
  399. init: function() {
  400. // only if browser supports File API
  401. if (window.File && window.FileList && window.FileReader) {
  402. var xhr = new XMLHttpRequest();
  403. if(xhr.upload) {
  404. this.$el.find('.filedrag').css('display', 'block');
  405. this.$el.find('.submitbutton').css('display', 'none');
  406. }
  407. } else {
  408. this.undelegateEvents();
  409. }
  410. },
  411. fileDragHover: function(e) {
  412. e.stopPropagation();
  413. e.preventDefault();
  414. if(e.type == "dragover") {
  415. $(e.target).addClass("hover");
  416. } else {
  417. $(e.target).removeClass("hover");
  418. }
  419. },
  420. fileSelectHandler: function(e) {
  421. // cancel event and hover styling
  422. this.fileDragHover(e);
  423. // fetch FileList object
  424. var files = e.target.files || e.originalEvent.dataTransfer.files;
  425. var file = files[0];
  426. this.file = file;
  427. if ( file.type.indexOf( 'image' ) === 0 ) {
  428. this.showNizeForm();
  429. } else {
  430. alert('Only Images allowed');
  431. }
  432. },
  433. showNizeForm: function() {
  434. var url = window.URL || window.webkitURL,
  435. self = this,
  436. data = null,
  437. img = new Image(),
  438. reader = new FileReader(),
  439. objURL = url.createObjectURL || false;
  440. this.lists = new ListCollection(application.lists);
  441. this.bindTo(this.lists, 'add', this.addOneList);
  442. this.$el.find('.upload').css('display', 'none');
  443. this.$el.append(this.template( { lists: this.lists.toJSON() } ));
  444. // add lists
  445. _.each(this.lists.models, _.bind(function(list) {
  446. this.renderView(this.$el.find('.nize-lists'), 'append', new ListUnitView({ model: list }));
  447. }, this));
  448. // add rating
  449. _.each(application.ratings, _.bind(function(rating) {
  450. this.$el.find('.nize-rating select').append($('<option>', {value: rating.value, text: rating.text}))
  451. }, this));
  452. // show image
  453. if(objURL) {
  454. img.src = url.createObjectURL(this.file);
  455. this.$el.prepend(img);
  456. } else {
  457. reader.readAsDataURL( this.file );
  458. reader.onload = function ( ev ) {
  459. img.src = ev.target.result;
  460. img.onload = function() {
  461. self.$el.prepend(this);
  462. };
  463. };
  464. }
  465. },
  466. addOneList: function(list) {
  467. this.renderView(this.$el.find('.nize-lists'), 'append', new ListUnitView({ model: list }));
  468. },
  469. newList: function(evt) {
  470. if(evt.which == 13) {
  471. var listName = this.$el.find('.nize-new-list input').val();
  472. var self = this;
  473. var list = new List();
  474. list.save({ name: listName, checked: true }, {
  475. wait:true,
  476. success:function(model, response) {
  477. self.lists.add(model);
  478. },
  479. error: function(model, error) {
  480. console.log(model.toJSON());
  481. console.log('error.responseText');
  482. }
  483. });
  484. }
  485. },
  486. createNize: function() {
  487. var title = this.$el.find('.nize-title input').val();
  488. var rating = this.$el.find('.nize-rating select').val();
  489. var description = this.$el.find('.nize-description input').val();
  490. var self = this;
  491. var lists = $('.nize-lists input:checked');
  492. lists = $.map(lists, function(v, k) {
  493. return $(v).val();
  494. });
  495. var nizeObj = {
  496. title: title,
  497. description: description,
  498. lists: lists,
  499. rating: rating,
  500. link: ''
  501. };
  502. this.nize = new Nize();
  503. this.nize.save(nizeObj, {
  504. wait:true,
  505. success:function(model, response) {
  506. console.log('successfully added nize');
  507. self.uploadImage();
  508. },
  509. error: function(model, error) {
  510. console.log(model.toJSON());
  511. console.log('error.responseText');
  512. }
  513. });
  514. },
  515. uploadImage: function() {
  516. var xhr = new XMLHttpRequest();
  517. if (xhr.upload && this.fileSupport.indexOf(this.file.type) > -1 && this.file.size <= this.$el.find("#MAX_FILE_SIZE").val()) {
  518. // progress bar
  519. xhr.upload.addEventListener("progress", function(e) {
  520. var pc = parseInt(100 - (e.loaded / e.total * 100), 10);
  521. debug.log(pc + "%");
  522. }, false);
  523. // file received/failed
  524. xhr.onreadystatechange = function(e) {
  525. if (xhr.readyState == 4) {
  526. debug.log(xhr.status == 200 ? "success upload" : "upload failure");
  527. }
  528. };
  529. var formdata = new FormData();
  530. formdata.append(this.file.name, this.file);
  531. formdata.append('nizeId', this.nize.get('_id'));
  532. // start upload
  533. xhr.open("PUT", this.$el.find('.upload').get(0).action, true);
  534. xhr.setRequestHeader("X_FILENAME", this.file.name);
  535. xhr.send(formdata);
  536. }
  537. }
  538. });
  539. }});
  540. window.require.define({"views/nize/nizeUnitView": function(exports, require, module) {
  541. var View = require('../view');
  542. var template = require('../templates/nize/nizeUnit');
  543. var ratingTemplate = require('../templates/shared/rating');
  544. var application = require('application');
  545. module.exports = View.extend({
  546. className: 'nize',
  547. template: template,
  548. getRenderData: function() {
  549. return {
  550. nize: this.model.toJSON()
  551. };
  552. },
  553. events: {
  554. "click a.nize-image": "openNize"
  555. },
  556. initialize: function() {
  557. //console.log('order: ', this.options.order);
  558. var cssOptions = _.extend({opacity: 0}, this.options.css);
  559. this.$el.css(cssOptions);
  560. this.bindTo(this.model, 'change', this.updateView);
  561. // fade in depending on the order
  562. setTimeout(_.bind(function() {
  563. this.$el.css('opacity', 1);
  564. }, this), 50*this.options.index);
  565. },
  566. afterRender: function() {
  567. var perc = 100/4*this.model.get('rating');
  568. this.$el.append(ratingTemplate({
  569. ratings: application.ratings,
  570. rating: perc,
  571. current: this.model.get('rating'),
  572. notActive: true,
  573. }));
  574. },
  575. openNize: function(evt) {
  576. evt.preventDefault();
  577. application.router.navigate('nize/' + this.model.get('_id'), {trigger: true});
  578. },
  579. updateView: function(obj) {
  580. this.$el.find("*[role=title]").text(obj.get("title"));
  581. this.$el.find("*[role=description]").text(obj.get("description"));
  582. this.$el.find("ul.rating .current").text("" + obj.get("rating") + " out of 4");
  583. this.$el.find("ul.rating .current").width("" + obj.get("rating")*25 + "%");
  584. },
  585. });
  586. }});
  587. window.require.define({"views/nize/nizesView": function(exports, require, module) {
  588. var View = require('../view');
  589. var NizeUnitView = require('./nizeUnitView');
  590. var noNizeFoundView = require('../search/noNizeFoundView');
  591. var application = require('application');
  592. module.exports = View.extend({
  593. gridOptions: {
  594. itemWidth: 232,
  595. gutter: 24
  596. },
  597. initialize: function() {
  598. //console.debug('init#nizeView', this.collection);
  599. // Layout variables.
  600. this.columns = null;
  601. this.columnWidth = null;
  602. this.heights = [];
  603. //More Nize index holder
  604. this.nizeIndex = 0;
  605. //Bindings
  606. this.bindTo(this.collection, 'reset', this.addAll);
  607. this.bindTo(this.collection, 'add', this.addOne);
  608. this.bindTo(this.options.parent, 'more', function(){ this.nizeIndex = 0;});
  609. this.bindTo(this.collection, 'destroy', function(){
  610. this.addAll;
  611. this.addAll(this.collection);
  612. });
  613. //we need to add this margin, for the scrolling effect
  614. $("#header").css({"margin-bottom": "55px"});
  615. //window resize event
  616. var resizeTimer = null;
  617. $(window).resize(_.bind(function(event) {
  618. if(resizeTimer) clearTimeout(resizeTimer);
  619. resizeTimer = setTimeout(
  620. _.bind(
  621. this.layout,
  622. this,
  623. this.$el.find('.nize').length < 7 ? 1020 : null
  624. ), 100
  625. );
  626. }, this));
  627. },
  628. layout: function(maxContainerWidth) {
  629. // Calculate basic layout parameters.
  630. var containerWidth = maxContainerWidth || $(window).outerWidth();
  631. this.columnWidth = this.gridOptions.itemWidth + this.gridOptions.gutter;
  632. var columns = Math.floor((containerWidth + this.gridOptions.gutter)/this.columnWidth);
  633. // minimal 4 columns
  634. if(columns < 4) columns = 4;
  635. var oldColumns = this.columns;
  636. this.columns = columns = columns%2 ? (columns-1<4 ? columns : columns-1) : columns;
  637. var newContainerWidth = Math.round(columns*this.columnWidth-this.gridOptions.gutter);
  638. this.$el.css('width', newContainerWidth);
  639. // Prepare Array to store height of columns.
  640. this.heights = [];
  641. while(this.heights.length < columns) {
  642. this.heights.push(0);
  643. }
  644. // resize items if exists
  645. if(this.$el.find('.nize').length && oldColumns !== columns) {
  646. this.disposeViews();
  647. this.collection.each(_.bind(this.addOne, this));
  648. }
  649. },
  650. addAll: function(nizes) {
  651. this.disposeViews();
  652. this.layout(nizes.length < 7 ? 1020 : null);
  653. if(nizes.length === 0) {
  654. this.renderView(this.$el, 'append', new noNizeFoundView({parent: this, filters: nizes.getFilters()}));
  655. } else {
  656. this.nizeIndex = 0;
  657. nizes.each(_.bind(function(nize, counter) {
  658. this.addOne(nize, nizes, {index: counter});
  659. }, this));
  660. }
  661. },
  662. addOne: function(nize, nizes, options) {
  663. var index = options.index;
  664. if(this.nizeIndex === 0) this.nizeIndex = index;
  665. options.index = index - this.nizeIndex;
  666. var self = this;
  667. // Find the shortest column.
  668. var shortest = null;
  669. var shortestIndex = 0;
  670. for(k=0; k<this.columns; k++) {
  671. if(shortest === null || this.heights[k] < shortest) {
  672. shortest = this.heights[k];
  673. shortestIndex = k;
  674. }
  675. }
  676. var cssChanges = {
  677. position: 'absolute',
  678. top: shortest,
  679. left: shortestIndex * self.columnWidth,
  680. };
  681. var nizeUnitView = new NizeUnitView({
  682. model:nize,
  683. css: cssChanges,
  684. id: nize.get('_id'),
  685. index: options.index
  686. });
  687. this.renderView(this.$el, 'append', nizeUnitView);
  688. var colHeight = shortest + nizeUnitView.$el.outerHeight() + this.gridOptions.gutter;
  689. this.heights[shortestIndex] = colHeight;
  690. this.$el.css('height', colHeight);
  691. }
  692. });
  693. }});
  694. window.require.define({"views/nize/open/nizeOpenUnitView": function(exports, require, module) {
  695. var View = require('../../view');
  696. var application = require('application');
  697. var template = require('../../templates/nize/open/nize');
  698. var ratingTemplate = require('../../templates/shared/rating');
  699. module.exports = View.extend({
  700. className: 'nize-open-unit nize',
  701. template: template,
  702. getRenderData: function() {
  703. return {
  704. nize: this.model.toJSON()
  705. };
  706. },
  707. events: {
  708. "click .nize-field-edit" : "inlineEditBegin",
  709. "blur .nize-field-edit" : "inlineEditEnd",
  710. "click a.delete" : "deleteNize",
  711. "click ul.rating" : "changeRating",
  712. "click" : "preventClosing",
  713. //"keydown .nize-field-edit" : "preventMultiline",
  714. },
  715. initialize: function() {
  716. //console.debug('init#nizeOpenUnit', this.collection);
  717. this.$el.css(this.options.css);
  718. if(this.canEditNize()) {
  719. this.model.set("editable", true);
  720. }
  721. },
  722. afterRender: function() {
  723. // Load big picture
  724. var $image = this.$el.find('img');
  725. var img = new Image();
  726. var self = this;
  727. $(img).bind('load error', function(e){
  728. //now its loaded so show it
  729. $image.css('visibility', 'visible');
  730. // setting css properties for nice opening animation
  731. $image.css('margin-left',-($image.width()-200)/2);
  732. $image.css('height', img.height);
  733. //notify as ready
  734. self.trigger('imgLoaded');
  735. //wait for animation
  736. setTimeout(function() {
  737. self.loadContent();
  738. }, 300);
  739. });
  740. img.src = $image.attr('src');
  741. },
  742. loadContent: function() {
  743. this.$el.parent().removeClass('loading').addClass('loaded');
  744. // show rating
  745. var perc = 100/4*this.model.get('rating');
  746. this.$el.find('.nize-open-header').append(ratingTemplate({
  747. ratings: application.ratings,
  748. rating: perc,
  749. notActive: !this.canEditNize(),
  750. }));
  751. if(this.canEditNize) {
  752. this.$el.find('.nize-field-edit').addClass('show-edit');
  753. this.$el.find('.nize-field-edit').attr("contenteditable", true);
  754. setTimeout(_.bind(function() {
  755. this.$el.find('.nize-field-edit').removeClass('show-edit');
  756. }, this), 1000);
  757. }
  758. },
  759. canEditNize: function() {
  760. if(application.user == this.model.get("_creator")) {
  761. return true;
  762. }
  763. return false;
  764. },
  765. preventClosing: function(evt) {
  766. evt.stopPropagation();
  767. },
  768. inlineEditBegin: function(evt) {
  769. if(this.canEditNize()) {
  770. //evt.target.setAttribute("contenteditable", true);
  771. }
  772. },
  773. inlineEditEnd: function(evt) {
  774. if(this.canEditNize()) {
  775. // disable content editable
  776. //evt.target.setAttribute("contenteditable", false);
  777. this.highlight(evt.target);
  778. // get element role and change attribute if valid
  779. role = evt.target.getAttribute("role");
  780. if(this.model.has(role)) {
  781. this.model.save(role, evt.target.innerHTML, {error: this.errorOnSave});
  782. }
  783. }
  784. },
  785. changeRating: function(evt) {
  786. if(this.canEditNize()) {
  787. if(evt.target.hasAttribute("data-rating-value")) {
  788. this.model.save("rating", evt.target.getAttribute("data-rating-value"), {error: this.errorOnSave});
  789. this.$el.find("ul.rating").removeClass("no-active");
  790. this.$el.find("ul.rating .current").text("" + this.model.get("rating") + " out of 4");
  791. this.$el.find("ul.rating .current").width("" + this.model.get("rating")*25 + "%");
  792. }
  793. }
  794. },
  795. errorOnSave: function(model, response) {
  796. alert("ERROR WHILE SAVING!");
  797. },
  798. preventMultiline: function(evt) {
  799. if(evt.keyCode == 13) {
  800. evt.stopPropagation();
  801. return false;
  802. }
  803. },
  804. deleteNize: function(evt) {
  805. if (confirm('Are you sure you want to delete this nize?')) {
  806. this.model.destroy({wait: true});
  807. }
  808. },
  809. highlight: function(obj, error){
  810. $(obj).addClass("highlight");
  811. if(error) {
  812. $(obj).addClass("error");
  813. }
  814. setTimeout(function(){
  815. $(obj).removeClass("highlight");
  816. $(obj).removeClass("error");
  817. }, 200);
  818. }
  819. });
  820. }});
  821. window.require.define({"views/nize/open/nizeOpenView": function(exports, require, module) {
  822. var View = require('../../view');
  823. var NizeOpenUnitView = require('./nizeOpenUnitView');
  824. var application = require('application');
  825. module.exports = View.extend({
  826. className: 'nize-open',
  827. events: {
  828. "click": "close"
  829. },
  830. initialize: function() {
  831. //console.debug('init#nizeOpen', this.collection);
  832. this.bindTo(this.collection, 'destroy', this.close);
  833. var $nizeElement = $('#'+this.options.nizeId);
  834. var startPosition = $nizeElement.offset();
  835. var self = this;
  836. // calculate top for scrolled states
  837. startPosition.top = startPosition.top - $(document).scrollTop();
  838. // Set page to the background
  839. this.scrollBarWidth = this.getScrollBarWidth();
  840. $('body').addClass('noscroll');
  841. $('body').css('margin-right', this.scrollBarWidth);
  842. $('.l-search-controls-inner').css('width', $('.l-search-controls-inner').width() + this.scrollBarWidth);
  843. // add open nize
  844. this.nizeOpenUnitView = new NizeOpenUnitView({css: startPosition, model: this.collection.get(this.options.nizeId)});
  845. this.bindTo(this.nizeOpenUnitView, 'imgLoaded', this.open);
  846. this.renderView(this.$el, 'append', this.nizeOpenUnitView);
  847. $('body').append(this.$el);
  848. //start loading state
  849. this.$el.addClass('loading');
  850. },
  851. open: function() {
  852. // start visible state
  853. this.$el.addClass('visible');
  854. // center nize
  855. var viewportWidth = $(document).outerWidth();
  856. this.nizeOpenUnitView.$el.css('left', viewportWidth/2 - 326 - (this.scrollBarWidth/2));
  857. // set css properties for nize opening animation
  858. this.nizeOpenUnitView.$el.find('img').css('margin-left', 0);
  859. },
  860. close: function(evt) {
  861. // stop loading nize when hin as target
  862. if(typeof(evt.preventDefault) == "function") {
  863. evt.preventDefault();
  864. }
  865. // Bring Backgroun back to front
  866. $('body').removeClass('noscroll');
  867. $('body').css('margin-right', 0);
  868. $('.l-search-controls-inner').css('width', $('.l-search-controls-inner').width() - this.scrollBarWidth);
  869. application.router.navigate('/');
  870. this.dispose();
  871. },
  872. //Helper
  873. getScrollBarWidth: function() {
  874. var inner = document.createElement('p');
  875. inner.style.width = "100%";
  876. inner.style.height = "200px";
  877. var outer = document.createElement('div');
  878. outer.style.position = "absolute";
  879. outer.style.top = "0px";
  880. outer.style.left = "0px";
  881. outer.style.visibility = "hidden";
  882. outer.style.width = "200px";
  883. outer.style.height = "150px";
  884. outer.style.overflow = "hidden";
  885. outer.appendChild (inner);
  886. document.body.appendChild (outer);
  887. var w1 = inner.offsetWidth;
  888. outer.style.overflow = 'scroll';
  889. var w2 = inner.offsetWidth;
  890. if (w1 == w2) w2 = outer.clientWidth;
  891. document.body.removeChild (outer);
  892. return (w1 - w2);
  893. }
  894. });
  895. }});
  896. window.require.define({"views/nizeLayoutView": function(exports, require, module) {
  897. var View = require('./view');
  898. var application = require('../application');
  899. var NizeCollection = require('../models/nizeCollection');
  900. var ListCollection = require('../models/listCollection');
  901. var NizesView = require('./nize/nizesView');
  902. var NizeOpenView = require('./nize/open/nizeOpenView');
  903. var searchControlsView = require('./searchControlsView');
  904. module.exports = View.extend({
  905. el: '.nize-layout',
  906. events: {
  907. "click .load-more": "moreNizes"
  908. },
  909. subscriptions: {
  910. 'nizeLayoutView:render': 'load',
  911. 'openNize:init': 'openNize'
  912. },
  913. load: function(open) {
  914. // set open state depending if the user is logged in
  915. this.open = application.user ? false : true;
  916. // If url points to /all then show open nizes
  917. if(open) this.open = true;
  918. if (this.open) {
  919. this.manageMenu("/all");
  920. } else {
  921. this.manageMenu("/");
  922. }
  923. this.nizes || (this.nizes = new NizeCollection());
  924. this.lists || (this.lists = new ListCollection(application.lists));
  925. // bindings
  926. this.bindTo(this.nizes, 'finished', this.endNizes);
  927. this.bindTo(this.nizes, 'newSearch', this.newNizes);
  928. // sub views
  929. this.nizesView || (this.nizesView = new NizesView({
  930. el: this.$('.l-nizes'),
  931. collection: this.nizes,
  932. parent: this
  933. }));
  934. this.searchControlsView || (this.searchControlsView = new searchControlsView({
  935. el: $('.l-search-controls-inner'),
  936. listCollection: this.lists,
  937. nizeCollection: this.nizes
  938. }));
  939. // Set filter for the right nizes
  940. this.nizes.setOpenFilter(this.open);
  941. // start fetching lists
  942. this.lists.showByAttribute({open: this.open});
  943. },
  944. manageMenu: function(url) {
  945. //reset all menu items
  946. var items = $("nav.top-menu.filter ul li a");
  947. items.addClass("small");
  948. items.addClass("lightgrey");
  949. items.removeClass("blue");
  950. //mark current element
  951. var items = $('nav.top-menu.filter ul li a[href="' + url + '"]');
  952. items.removeClass("lightgrey");
  953. items.removeClass("small");
  954. },
  955. moreNizes: function() {
  956. this.trigger('more');
  957. this.nizes.getNext();
  958. },
  959. endNizes: function() {
  960. this.$el.find('.load-more').addClass('disabled');
  961. },
  962. newNizes: function() {
  963. this.$el.find('.load-more').removeClass('disabled');
  964. },
  965. openNize: function(nizeId) {
  966. var nizeOpenView = new NizeOpenView({nizeId: nizeId, collection: this.nizes});
  967. }
  968. });
  969. }});
  970. window.require.define({"views/search/listUnitView": function(exports, require, module) {
  971. var View = require('../view');
  972. module.exports = View.extend({
  973. tagName: 'li',
  974. className: 'text-type',
  975. events: {
  976. "click": "selected"
  977. },
  978. attributes: function() {
  979. return {
  980. 'data-list-id': this.model.get('_id') ? this.model.get('_id') : 0
  981. }
  982. },
  983. render: function() {
  984. $(this.el).html(this.model.get('name'));
  985. this.afterRender();
  986. return this;
  987. },
  988. selected: function() {
  989. this.trigger('selection', this);
  990. }
  991. });
  992. }});
  993. window.require.define({"views/search/listsView": function(exports, require, module) {
  994. var View = require('../view');
  995. var List = require('/models/listModel');
  996. var ListUnitView = require('./listUnitView');
  997. var template = require('../templates/search/dropdown');
  998. module.exports = View.extend({
  999. className: 'dropdown',
  1000. template: template,
  1001. getRenderData: function() {
  1002. return {
  1003. title: "Category:",
  1004. defaultValue: "All"
  1005. };
  1006. },
  1007. events: {
  1008. "click a.current": "toggleBox"
  1009. },
  1010. initialize: function() {
  1011. _.bindAll(this, 'addOne', 'addAll', 'selected');
  1012. this.bindTo(this.collection, 'filteredLists', this.addAll);
  1013. },
  1014. addAll: function(lists) {
  1015. this.disposeViews();
  1016. this.addOne(new List({_id: '0', name: 'all'}));
  1017. _.each(lists, this.addOne);
  1018. },
  1019. addOne: function(list) {
  1020. var listUnitView = new ListUnitView({ model: list });
  1021. this.bindTo(listUnitView, 'selection', this.selected);
  1022. this.renderView(this.$el.find('ul'), 'append', listUnitView);
  1023. },
  1024. toggleBox: function(evt) {
  1025. var self = this;
  1026. evt.stopPropagation();
  1027. if(this.$el.hasClass('open')) {
  1028. this.closeBox();
  1029. } else {
  1030. this.$el.addClass('open');
  1031. $(document).bind('click', function(evt) {
  1032. self.closeBox();
  1033. });
  1034. }
  1035. return false;
  1036. },
  1037. closeBox: function() {
  1038. this.$el.removeClass('open');
  1039. },
  1040. selected: function(list) {
  1041. this.$el.find('.current').html(list.$el.html());
  1042. this.trigger('selection', list.$el.data('list-id'), list.$el.text());
  1043. }
  1044. });
  1045. }});
  1046. window.require.define({"views/search/noNizeFoundView": function(exports, require, module) {
  1047. var View = require('../view');
  1048. var template = require('../templates/nize/noNize');
  1049. module.exports = View.extend({
  1050. className: 'no-nize-found',
  1051. template: template,
  1052. getRenderData: function() {
  1053. return {
  1054. filters: this.options.filters
  1055. };
  1056. },
  1057. afterRender: function() {
  1058. this.options.parent.$el.css('height', 'auto');
  1059. }
  1060. });
  1061. }});
  1062. window.require.define({"views/search/ratingsView": function(exports, require, module) {
  1063. var View = require('../view');
  1064. var application = require('application');
  1065. var ratingTemplate = require('../templates/shared/rating');
  1066. module.exports = View.extend({
  1067. tagName: 'div',
  1068. className: 'ratingfilter',
  1069. events: {
  1070. "click": "removeRate",
  1071. "click .rating": "selection"
  1072. },
  1073. initialize: function() {
  1074. this.$el.addClass("bordered");
  1075. },
  1076. afterRender: function() {
  1077. var description = $('<label>', {text:'Rating: '});
  1078. this.$el.append(description);
  1079. this.$el.append(ratingTemplate({ratings: application.ratings, rating: 0}));
  1080. },
  1081. removeRate: function() {
  1082. this.setRate(0);
  1083. this.trigger('selection', 0);
  1084. return false;
  1085. },
  1086. selection: function(evt) {
  1087. evt.stopPropagation();
  1088. var rate = $(evt.target).text();
  1089. this.setRate(rate);
  1090. this.trigger('selection', rate);
  1091. return false;
  1092. },
  1093. setRate: function(rate) {
  1094. var perc = 100/4*rate;
  1095. this.$el.find('.current').css('width', perc+'%');
  1096. }
  1097. });
  1098. }});
  1099. window.require.define({"views/search/searchView": function(exports, require, module) {
  1100. var View = require('../view');
  1101. var template = require('../templates/search/searchForm');
  1102. module.exports = View.extend({
  1103. className: 'search',
  1104. template: template,
  1105. events: {
  1106. 'keyup': 'newSearch'
  1107. },
  1108. initialize: function() {
  1109. this.counter = 10;
  1110. this.searched = false;
  1111. },
  1112. newSearch: function() {
  1113. this.counter = 10;
  1114. var self = this;
  1115. var time = 30;
  1116. var timerCallback = function() {
  1117. self.counter--;
  1118. if(self.counter === 0) {
  1119. self.searched = false;
  1120. self.trigger('newSearch', self.$el.find('input').val());
  1121. } else {
  1122. setTimeout(timerCallback, time);
  1123. }
  1124. };
  1125. if(this.searched === false) {
  1126. this.searched = true;
  1127. setTimeout(timerCallback, time);
  1128. }
  1129. }
  1130. });
  1131. }});
  1132. window.require.define({"views/searchControlsView": function(exports, require, module) {
  1133. var View = require('./view');
  1134. var application = require('application');
  1135. var ListsView = require('./search/listsView');
  1136. var RatingsView = require('./search/ratingsView');
  1137. var SearchView = require('./search/searchView');
  1138. module.exports = View.extend({
  1139. initialize: function() {
  1140. // add list dropdown control
  1141. var listsView = new ListsView({ collection: this.options.listCollection });
  1142. this.bindTo(listsView, 'selection', this.newListSelection);
  1143. this.renderView(this.$el, 'append', listsView );
  1144. // add rating dropdown control
  1145. var ratingsView = new RatingsView();
  1146. this.bindTo(ratingsView, 'selection', this.newRatingSelection);
  1147. this.renderView(this.$el, 'append', ratingsView );
  1148. // add search control
  1149. var searchView = new SearchView();
  1150. this.bindTo(searchView, 'newSearch', this.newSearch);
  1151. this.renderView(this.$el, 'append', searchView);
  1152. // Fetch Nizes
  1153. this.options.nizeCollection.search();
  1154. },
  1155. newListSelection: function(listId, listName) {
  1156. this.options.nizeCollection.setListFilter(listId, listName);
  1157. },
  1158. newRatingSelection: function(ratingValue) {
  1159. this.options.nizeCollection.setRatingFilter(ratingValue);
  1160. },
  1161. newSearch: function(key) {
  1162. this.options.nizeCollection.setKeyFilter(key);
  1163. },
  1164. changeStyle: function(state) {
  1165. }
  1166. });
  1167. }});
  1168. window.require.define({"views/templates/layouts/nize": function(exports, require, module) {
  1169. module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  1170. helpers = helpers || Handlebars.helpers;
  1171. var buffer = "", stack1, stack2, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
  1172. buffer += "<div class=\"nizeControls\">\n</div>\n<div class=\"nizes\">\n</div>\n<p class=\"grid_1\">\n <a href=\"#\" class=\"medium button\">";
  1173. stack1 = "button.load-more";
  1174. foundHelper = helpers['t'];
  1175. stack2 = foundHelper || depth0['t'];
  1176. if(typeof stack2 === functionType) { stack1 = stack2.call(depth0, stack1, { hash: {} }); }
  1177. else if(stack2=== undef) { stack1 = helperMissing.call(depth0, "t", stack1, { hash: {} }); }
  1178. else { stack1 = stack2; }
  1179. buffer += escapeExpression(stack1) + "</a>\n</p>";
  1180. return buffer;});
  1181. }});
  1182. window.require.define({"views/templates/list/listUnit": function(exports, require, module) {
  1183. module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  1184. helpers = helpers || Handlebars.helpers;
  1185. var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
  1186. function program1(depth0,data) {
  1187. var buffer = "", stack1;
  1188. buffer += "\n <input name=\"";
  1189. foundHelper = helpers.list;
  1190. stack1 = foundHelper || depth0.list;
  1191. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1192. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1193. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list._id", { hash: {} }); }
  1194. buffer += escapeExpression(stack1) + "\" value=\"";
  1195. foundHelper = helpers.list;
  1196. stack1 = foundHelper || depth0.list;
  1197. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1198. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1199. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list._id", { hash: {} }); }
  1200. buffer += escapeExpression(stack1) + "\" type=\"checkbox\" checked=\"checked\">\n ";
  1201. return buffer;}
  1202. function program3(depth0,data) {
  1203. var buffer = "", stack1;
  1204. buffer += "\n <input name=\"";
  1205. foundHelper = helpers.list;
  1206. stack1 = foundHelper || depth0.list;
  1207. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1208. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1209. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list._id", { hash: {} }); }
  1210. buffer += escapeExpression(stack1) + "\" value=\"";
  1211. foundHelper = helpers.list;
  1212. stack1 = foundHelper || depth0.list;
  1213. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1214. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1215. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list._id", { hash: {} }); }
  1216. buffer += escapeExpression(stack1) + "\" type=\"checkbox\">\n ";
  1217. return buffer;}
  1218. buffer += "<div class=\"list-item\" data-id=\"";
  1219. foundHelper = helpers.list;
  1220. stack1 = foundHelper || depth0.list;
  1221. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1222. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1223. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list._id", { hash: {} }); }
  1224. buffer += escapeExpression(stack1) + "\">\n <label for=\"";
  1225. foundHelper = helpers.list;
  1226. stack1 = foundHelper || depth0.list;
  1227. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1228. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1229. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list._id", { hash: {} }); }
  1230. buffer += escapeExpression(stack1) + "\">";
  1231. foundHelper = helpers.list;
  1232. stack1 = foundHelper || depth0.list;
  1233. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.name);
  1234. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1235. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "list.name", { hash: {} }); }
  1236. buffer += escapeExpression(stack1) + "\n ";
  1237. foundHelper = helpers.list;
  1238. stack1 = foundHelper || depth0.list;
  1239. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.checked);
  1240. stack2 = helpers['if'];
  1241. tmp1 = self.program(1, program1, data);
  1242. tmp1.hash = {};
  1243. tmp1.fn = tmp1;
  1244. tmp1.inverse = self.program(3, program3, data);
  1245. stack1 = stack2.call(depth0, stack1, tmp1);
  1246. if(stack1 || stack1 === 0) { buffer += stack1; }
  1247. buffer += "\n </label>\n</li>\n";
  1248. return buffer;});
  1249. }});
  1250. window.require.define({"views/templates/nize/addNizeForm": function(exports, require, module) {
  1251. module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  1252. helpers = helpers || Handlebars.helpers;
  1253. var foundHelper, self=this;
  1254. return "<ul>\n <li class=\"nize-field\">\n <label for=\"nize-title\">Title</label>\n <div class=\"nize-title\">\n <input name=\"nize-title\" type=\"text\">\n </div>\n </li>\n <li class=\"nize-field\">\n <label for=\"nize-description\">Description</label>\n <div class=\"nize-description\">\n <input name=\"nize-description\" type=\"text\">\n </div>\n </li>\n <li class=\"nize-field\">\n <label for=\"nize-lists\">lists</label>\n <div class=\"nize-lists\"></div>\n </li>\n <li class=\"nize-field\">\n <label for=\"nize-new-list\">new List</label>\n <div class=\"nize-new-list\">\n <input name=\"nize-new-list\" type=\"text\">\n </div>\n </li>\n <li class=\"rating-field\">\n <label for=\"rating-field\">Rating</label>\n <div class=\"nize-rating\">\n <select name=\"rating\">\n <option value=\"0\" selected=\"selected\">Choose a rating</option>\n </select>\n </div>\n </li>\n <li class=\"nize-field\">\n <input class=\"nize-submit\" type=\"submit\" value=\"create Nize\">\n </li>\n</ul>\n";});
  1255. }});
  1256. window.require.define({"views/templates/nize/nizeUnit": function(exports, require, module) {
  1257. module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  1258. helpers = helpers || Handlebars.helpers;
  1259. var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
  1260. buffer += "<a href=\"/nize/";
  1261. foundHelper = helpers.nize;
  1262. stack1 = foundHelper || depth0.nize;
  1263. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1._id);
  1264. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1265. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nize._id", { hash: {} }); }
  1266. buffer += escapeExpression(stack1) + "\" class=\"nize-image image-box\"><img src=\"";
  1267. foundHelper = helpers.nize;
  1268. stack1 = foundHelper || depth0.nize;
  1269. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.thumb);
  1270. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1271. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nize.thumb", { hash: {} }); }
  1272. buffer += escapeExpression(stack1) + "\" class=\"thumb\"></a>\n<h2 role=\"title\">";
  1273. foundHelper = helpers.nize;
  1274. stack1 = foundHelper || depth0.nize;
  1275. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.title);
  1276. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1277. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nize.title", { hash: {} }); }
  1278. buffer += escapeExpression(stack1) + "</h2>\n<p class=\"description\" role=\"description\">\n ";
  1279. foundHelper = helpers.nize;
  1280. stack1 = foundHelper || depth0.nize;
  1281. stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.description);
  1282. if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
  1283. else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nize.description", { hash: {} }); }
  1284. buffer += escapeExpression(stack1) + "\n</p>";
  1285. return buffer;});
  1286. }});
  1287. window.require.define({"views/templates/nize/noNize": function(exports, require, module) {
  1288. module.exports = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
  1289. helpers = helpers || Handlebars.helpers;
  1290. var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
  1291. function program1(depth0,data) {
  1292. var buffer = "", stack1, stack2;
  1293. buffer += "\n<div class=\"container_12\">\n <h2>";
  1294. stack1 = "headline.no-nize-in-category";
  1295. foundHelper = helpers['t'];
  1296. stack2 = foundHelper || depth0['t'];
  1297. if(typeof stack2 === functionType) { stack1 = stack2.call(depth0, stack1, { hash: {} }); }
  1298. else if(stack2=== undef) { stack1 = helperMissing.call(depth0, "t", stack1, { hash: {} }); }
  1299. else { stack1 = stack2; }
  1300. buffer += escapeExpression(stack1) + "</h2>\n <ol class=\"grid_4 push_4\">\n <li>";
  1301. stack1 = "paragraph.add-bookmarklet";
  1302. foundHelper = helpers['t'];
  1303. stack2 = foundHelper || depth0['t'];
  1304. if(typeof stack2 === functionType) { stack1 = stack2.call(depth0, stack1, { hash: {} }); }
  1305. else if(stack2=== undef) { stack1 = helperMissing.call(depth0, "t", stack1, { hash: {} }); }
  1306. else { stack1 = stack2; }
  1307. if(stack1 || stack1 === 0) { buffer += stack1; }
  1308. buffer += "</li>\n <li>";
  1309. stack1 = "paragraph.upload-nize";
  1310. foundHelper = helpers['t'];
  1311. stack2 = foundHelper || depth0['t'];
  1312. if(typeof stack2 === functionType) { stack1 = stack2.call(depth0, stack1, { hash: {} }); }
  1313. else if(stack2=== undef) { stack1 = helperMissing.call(depth0, "t", stack1, { hash: {} }); }
  1314. else { stack1 = stack2; }
  1315. if(stack1 || stack1 === 0) { buffer += stack1; }
  1316. buffer += "</li>\n </ol>\n</div>\n";
  1317. return buffer;}
  1318. function program3(depth0,data) {
  1319. var buffer = "", stack1, stack2;
  1320. buffer += "\n<